PageSourceSearch

https://cavina.ru/bitrix/js/ui/notification/dist/notification.bundle.js?178784563226544

js cavina.ru collected 2026-10-07 07:20:27 UTC 26,544 bytes, 925 lines download raw bytes

1/* eslint-disable */
2this.BX = this.BX || {};
3this.BX.UI = this.BX.UI || {};
4(function (exports, main_core) {
5	'use strict';
6
7	let Action = function () {
8		function Action(balloon, options = {}) {
9			babelHelpers.classCallCheck(this, Action);
10			babelHelpers.defineProperty(this, "balloon", void 0);
11			babelHelpers.defineProperty(this, "id", void 0);
12			babelHelpers.defineProperty(this, "href", void 0);
13			babelHelpers.defineProperty(this, "title", void 0);
14			babelHelpers.defineProperty(this, "window", void 0);
15			babelHelpers.defineProperty(this, "container", null);
16			babelHelpers.defineProperty(this, "events", {});
17			const opts = main_core.Type.isPlainObject(options) ? options : {};
18			this.balloon = balloon;
19			this.id = main_core.Type.isStringFilled(opts.id) ? opts.id : main_core.Text.getRandom(8).toLowerCase();
20			this.href = main_core.Type.isStringFilled(opts.href) ? opts.href : null;
21			this.title = main_core.Type.isStringFilled(opts.title) ? opts.title : null;
22			this.window = window;
23			if (main_core.Type.isPlainObject(opts.events)) {
24				for (const [eventName, fn] of Object.entries(opts.events)) {
25					if (!main_core.Type.isFunction(fn)) {
26						continue;
27					}
28					this.events[eventName] = event => {
29						fn.call(event.target, event, this.getBalloon(), this);
30					};
31				}
32			}
33		}
34		return babelHelpers.createClass(Action, [{
35			key: "getBalloon",
36			value: function getBalloon() {
37				return this.balloon;
38			}
39		}, {
40			key: "getId",
41			value: function getId() {
42				return this.id;
43			}
44		}, {
45			key: "getTitle",
46			value: function getTitle() {
47				return this.title;
48			}
49		}, {
50			key: "getHref",
51			value: function getHref() {
52				return this.href;
53			}
54		}, {
55			key: "getContainer",
56			value: function getContainer() {
57				if (this.container === null) {
58					const href = this.getHref();
59					const title = this.getTitle() ?? '';
60					this.container = href === null ? main_core.Tag.render`<span class="ui-notification-balloon-action">${title}</span>` : main_core.Tag.render`<a class="ui-notification-balloon-action" href="${href}">${title}</a>`;
61					for (const [eventName, handler] of Object.entries(this.events)) {
62						main_core.Event.bind(this.container, eventName, handler);
63					}
64				}
65				return this.container;
66			}
67		}, {
68			key: "getWindow",
69			value: function getWindow() {
70				return this.window;
71			}
72		}]);
73	}();
74
75	class NotificationEvent {
76		#balloon = null;
77		#name = null;
78		static getFullName(eventName) {
79			return `UI.Notification.Balloon:${eventName}`;
80		}
81		getBalloon() {
82			return this.#balloon;
83		}
84		setBalloon(balloon) {
85			if (main_core.Type.isObject(balloon)) {
86				this.#balloon = balloon;
87			}
88		}
89		getName() {
90			return this.#name;
91		}
92		setName(name) {
93			if (main_core.Type.isStringFilled(name)) {
94				this.#name = name;
95			}
96		}
97		getFullName() {
98			return NotificationEvent.getFullName(this.#name ?? '');
99		}
100	}
101
102	const Position = {
103		TOP_LEFT: 'top-left',
104		TOP_CENTER: 'top-center',
105		TOP_RIGHT: 'top-right',
106		BOTTOM_LEFT: 'bottom-left',
107		BOTTOM_CENTER: 'bottom-center',
108		BOTTOM_RIGHT: 'bottom-right'
109	};
110	const State = {
111		INIT: 0,
112		OPENING: 1,
113		OPEN: 2,
114		CLOSING: 3,
115		CLOSED: 4,
116		PAUSED: 5,
117		QUEUED: 6
118	};
119
120	class Stack {
121		id;
122		position;
123		spacing = 20;
124		offsetX = 25;
125		offsetY = 25;
126		newestOnTop = false;
127		balloonType = Balloon;
128		balloons = [];
129		queueStack = [];
130		constructor(options = {}) {
131			const opts = main_core.Type.isPlainObject(options) ? options : {};
132			this.id = main_core.Type.isStringFilled(opts.id) ? opts.id : main_core.Text.getRandom(8).toLowerCase();
133			this.position = Stack.getPositionCode(opts.position) ? opts.position : 'top-right';
134			this.setOptions(opts);
135			main_core.addCustomEvent(window, NotificationEvent.getFullName('onClose'), event => this.handleBalloonClose(event));
136		}
137		static getPositionCode(position) {
138			const entry = Object.entries(Position).find(([, value]) => value === position);
139			return entry ? entry[0] : null;
140		}
141		adjustPosition(balloon) {
142			let offset = 0;
143			this.getBalloons().forEach(currentBalloon => {
144				if (!balloon || balloon === currentBalloon) {
145					if (currentBalloon.doNotAdjustPosition) {
146						return;
147					}
148					const container = currentBalloon.getContainer();
149					const offsetX = `${this.getOffsetX()}px`;
150					const offsetY = `${offset + this.getOffsetY()}px`;
151					switch (this.getPosition()) {
152						case Position.TOP_LEFT:
153							main_core.Dom.style(container, {
154								left: offsetX,
155								top: offsetY
156							});
157							break;
158						case Position.TOP_CENTER:
159							main_core.Dom.style(container, {
160								left: '50%',
161								transform: 'translateX(-50%)',
162								top: offsetY
163							});
164							break;
165						case Position.TOP_RIGHT:
166							main_core.Dom.style(container, {
167								right: offsetX,
168								top: offsetY
169							});
170							break;
171						case Position.BOTTOM_LEFT:
172							main_core.Dom.style(container, {
173								left: offsetX,
174								bottom: offsetY
175							});
176							break;
177						case Position.BOTTOM_CENTER:
178							main_core.Dom.style(container, {
179								left: '50%',
180								transform: 'translateX(-50%)',
181								bottom: offsetY
182							});
183							break;
184						case Position.BOTTOM_RIGHT:
185							main_core.Dom.style(container, {
186								right: offsetX,
187								bottom: offsetY
188							});
189							break;
190					}
191				}
192				offset += this.getSpacing() + currentBalloon.getHeight();
193			});
194		}
195		add(balloon) {
196			if (this.getBalloons().length > 0 && (this.getQueue().length > 0 || !this.isBalloonFitToViewport(balloon))) {
197				this.queue(balloon);
198			} else {
199				this.push(balloon);
200			}
201		}
202		clear() {
203			const balloons = [...this.balloons, ...this.queueStack];
204			this.queueStack = [];
205			this.balloons = [];
206			balloons.forEach(balloon => balloon.close());
207		}
208		push(balloon) {
209			if (!(balloon instanceof Balloon)) {
210				throw new TypeError("'balloon' must be an instance of BX.UI.Notification.Balloon.");
211			}
212			if (!this.balloons.includes(balloon)) {
213				if (this.isNewestOnTop()) {
214					this.balloons.splice(0, 0, balloon);
215				} else {
216					this.balloons.push(balloon);
217				}
218			}
219		}
220		queue(balloon) {
221			if (!(balloon instanceof Balloon)) {
222				throw new TypeError("'balloon' must be an instance of BX.UI.Notification.Balloon.");
223			}
224			if (!this.queueStack.includes(balloon)) {
225				balloon.setState(State.QUEUED);
226				this.queueStack.push(balloon);
227			}
228		}
229		checkQueue() {
230			const queue = [...this.queueStack];
231			for (const balloon of queue) {
232				if (!this.isBalloonFitToViewport(balloon) && this.getBalloons().length > 0) {
233					break;
234				}
235				balloon.setState(State.INIT);
236				this.queueStack.shift();
237				this.push(balloon);
238				balloon.show();
239			}
240		}
241		getQueue() {
242			return this.queueStack;
243		}
244		isBalloonFitToViewport(balloon) {
245			const viewportHeight = document.documentElement.clientHeight;
246			const balloonHeight = this.getSpacing() + balloon.getHeight();
247			return this.getHeight() + balloonHeight <= viewportHeight;
248		}
249		handleBalloonClose(event) {
250			const closingBalloon = event.getBalloon();
251			if (closingBalloon === null || closingBalloon.getStack() !== this) {
252				return;
253			}
254			this.balloons = this.balloons.filter(balloon => closingBalloon !== balloon);
255			this.adjustPosition();
256			this.checkQueue();
257		}
258		setOptions(options) {
259			const opts = options ?? {};
260			this.setSpacing(opts.spacing);
261			this.setOffsetX(opts.offsetX);
262			this.setOffsetY(opts.offsetY);
263			this.setNewestOnTop(opts.newestOnTop);
264			this.setBalloonType(opts.balloonType);
265		}
266		getId() {
267			return this.id;
268		}
269		getBalloons() {
270			return this.balloons;
271		}
272		getPosition() {
273			return this.position;
274		}
275		getSpacing() {
276			return this.spacing;
277		}
278		setSpacing(spacing) {
279			if (main_core.Type.isNumber(spacing)) {
280				this.spacing = spacing;
281			}
282		}
283		getOffsetX() {
284			return this.offsetX;
285		}
286		setOffsetX(offsetX) {
287			if (main_core.Type.isNumber(offsetX)) {
288				this.offsetX = offsetX;
289			}
290		}
291		getOffsetY() {
292			return this.offsetY;
293		}
294		setOffsetY(offsetY) {
295			if (main_core.Type.isNumber(offsetY)) {
296				this.offsetY = offsetY;
297			}
298		}
299		getHeight() {
300			return this.getBalloons().reduce((height, balloon) => height + balloon.getHeight() + this.getSpacing(), this.getOffsetY());
301		}
302		getBalloonType(className) {
303			if (main_core.Type.isFunction(className)) {
304				return className;
305			}
306			if (main_core.Type.isStringFilled(className)) {
307				const classFn = main_core.Reflection.getClass(className);
308				if (main_core.Type.isFunction(classFn)) {
309					return classFn;
310				}
311			}
312			return this.balloonType || Balloon;
313		}
314		setBalloonType(balloonType) {
315			if (main_core.Type.isFunction(balloonType)) {
316				this.balloonType = balloonType;
317			} else if (main_core.Type.isStringFilled(balloonType)) {
318				const classFn = main_core.Reflection.getClass(balloonType);
319				if (main_core.Type.isFunction(classFn)) {
320					this.balloonType = classFn;
321				}
322			}
323		}
324		isNewestOnTop() {
325			return this.newestOnTop;
326		}
327		setNewestOnTop(onTop) {
328			if (main_core.Type.isBoolean(onTop)) {
329				this.newestOnTop = onTop;
330			}
331		}
332	}
333
334	let Balloon = function () {
335		function Balloon(options = {}) {
336			babelHelpers.classCallCheck(this, Balloon);
337			babelHelpers.defineProperty(this, "id", void 0);
338			babelHelpers.defineProperty(this, "stack", void 0);
339			babelHelpers.defineProperty(this, "state", State.INIT);
340			babelHelpers.defineProperty(this, "showOnTopWindow", void 0);
341			babelHelpers.defineProperty(this, "container", null);
342			babelHelpers.defineProperty(this, "content", null);
343			babelHelpers.defineProperty(this, "actions", []);
344			babelHelpers.defineProperty(this, "animationClassName", 'ui-notification-balloon-animate');
345			babelHelpers.defineProperty(this, "customRender", null);
346			babelHelpers.defineProperty(this, "category", null);
347			babelHelpers.defineProperty(this, "autoHide", true);
348			babelHelpers.defineProperty(this, "autoHideDelay", 8000);
349			babelHelpers.defineProperty(this, "autoHideTimeout", null);
350			babelHelpers.defineProperty(this, "useAirDesign", void 0);
351			babelHelpers.defineProperty(this, "data", {});
352			babelHelpers.defineProperty(this, "width", 400);
353			babelHelpers.defineProperty(this, "closeButton", null);
354			babelHelpers.defineProperty(this, "closeButtonVisibility", true);
355			const opts = main_core.Type.isPlainObject(options) ? options : {};
356			if (!(opts.stack instanceof Stack)) {
357				throw new TypeError("BX.UI.Notification.Balloon: 'stack' parameter is required.");
358			}
359			this.id = main_core.Type.isStringFilled(opts.id) ? opts.id : main_core.Text.getRandom(8).toLowerCase();
360			this.stack = opts.stack;
361			this.showOnTopWindow = opts.showOnTopWindow === true;
362			this.useAirDesign = opts.useAirDesign === true;
363			if (this.useAirDesign) {
364				this.width = 339;
365			}
366			if (main_core.Type.isPlainObject(opts.events)) {
367				for (const [eventName, handler] of Object.entries(opts.events)) {
368					this.addEvent(eventName, handler);
369				}
370			}
371			this.setOptions(opts);
372		}
373		return babelHelpers.createClass(Balloon, [{
374			key: "show",
375			value: function show() {
376				if (this.getState() === State.OPENING) {
377					return;
378				}
379				if (this.getState() === State.OPEN) {
380					this.activateAutoHide();
381					return;
382				}
383				let firstLaunch = false;
384				if (!this.getContainer().parentNode) {
385					firstLaunch = true;
386					const target = this.showOnTopWindow ? window.top.document.body : document.body;
387					main_core.Dom.append(this.getContainer(), target);
388					main_core.ZIndexManager.register(this.getContainer(), {
389						alwaysOnTop: true
390					});
391					this.getStack().add(this);
392					if (this.getState() === State.QUEUED) {
393						return;
394					}
395				}
396				const paused = this.getState() === State.PAUSED;
397				this.setState(State.OPENING);
398				this.adjustPosition();
399				main_core.ZIndexManager.bringToFront(this.getContainer());
400				this.animateIn(() => {
401					if (this.getState() !== State.OPENING) {
402						return;
403					}
404					this.setState(State.OPEN);
405					if (firstLaunch) {
406						this.fireEvent('onOpen');
407					}
408					if (!paused) {
409						this.activateAutoHide();
410					}
411				});
412			}
413		}, {
414			key: "setOptions",
415			value: function setOptions(options) {
416				if (!main_core.Type.isPlainObject(options)) {
417					return;
418				}
419				const opts = options;
420				this.setContent(opts.content);
421				this.setWidth(opts.width);
422				this.setData(opts.data);
423				this.setCloseButtonVisibility(opts.closeButton);
424				this.setActions(opts.actions);
425				this.setCategory(opts.category ?? undefined);
426				this.setAutoHide(opts.autoHide);
427				this.setCustomRender(opts.render);
428				this.setAutoHideDelay(opts.autoHideDelay);
429			}
430		}, {
431			key: "update",
432			value: function update(options) {
433				this.setOptions(options);
434				main_core.Dom.clean(this.getContainer());
435				main_core.Dom.append(this.render(), this.getContainer());
436				this.deactivateAutoHide();
437				this.activateAutoHide();
438			}
439		}, {
440			key: "close",
441			value: function close() {
442				const startState = this.getState();
443				if (startState === State.CLOSING || startState === State.CLOSED) {
444					return;
445				}
446				this.setState(State.CLOSING);
447				this.deactivateAutoHide();
448				const finalize = () => {
449					if (this.getState() !== State.CLOSING) {
450						return;
451					}
452					this.setState(State.CLOSED);
453					main_core.ZIndexManager.unregister(this.getContainer());
454					main_core.Dom.remove(this.getContainer());
455					this.container = null;
456					this.fireEvent('onClose');
457				};
458				if (startState === State.OPENING) {
459					finalize();
460				} else {
461					this.animateOut(() => finalize());
462				}
463			}
464		}, {
465			key: "blink",
466			value: function blink() {
467				this.animateOut(() => {
468					setTimeout(() => {
469						this.update(null);
470						this.animateIn(() => {});
471					}, 200);
472				});
473			}
474		}, {
475			key: "adjustPosition",
476			value: function adjustPosition() {
477				if (this.getStack().isNewestOnTop()) {
478					this.getStack().adjustPosition();
479				} else {
480					this.getStack().adjustPosition(this);
481				}
482			}
483		}, {
484			key: "getId",
485			value: function getId() {
486				return this.id;
487			}
488		}, {
489			key: "getCloseButton",
490			value: function getCloseButton() {
491				if (this.closeButton !== null) {
492					return this.closeButton;
493				}
494				this.closeButton = main_core.Tag.render`<div class="ui-notification-balloon-close-btn"></div>`;
495				main_core.Event.bind(this.closeButton, 'click', () => this.handleCloseBtnClick());
496				return this.closeButton;
497			}
498		}, {
499			key: "setCloseButtonVisibility",
500			value: function setCloseButtonVisibility(visibility) {
501				this.closeButtonVisibility = visibility !== false;
502			}
503		}, {
504			key: "isCloseButtonVisible",
505			value: function isCloseButtonVisible() {
506				return this.closeButtonVisibility;
507			}
508		}, {
509			key: "getContent",
510			value: function getContent() {
511				return this.content;
512			}
513		}, {
514			key: "setContent",
515			value: function setContent(content) {
516				if (main_core.Type.isString(content) || main_core.Type.isDomNode(content)) {
517					this.content = content;
518				}
519			}
520		}, {
521			key: "getWidth",
522			value: function getWidth() {
523				return this.width;
524			}
525		}, {
526			key: "setWidth",
527			value: function setWidth(width) {
528				if (main_core.Type.isNumber(width) || width === 'auto') {
529					this.width = width;
530				}
531			}
532		}, {
533			key: "getZIndex",
534			value: function getZIndex() {
535				const component = main_core.ZIndexManager.getComponent(this.getContainer());
536				return component ? component.getZIndex() : 0;
537			}
538		}, {
539			key: "setZIndex",
540			value: function setZIndex(_zIndex) {
541			}
542		}, {
543			key: "getHeight",
544			value: function getHeight() {
545				return this.getContainer().offsetHeight;
546			}
547		}, {
548			key: "getCategory",
549			value: function getCategory() {
550				return this.category;
551			}
552		}, {
553			key: "setCategory",
554			value: function setCategory(category) {
555				if (main_core.Type.isStringFilled(category) || category === null) {
556					this.category = category;
557				}
558			}
559		}, {
560			key: "setActions",
561			value: function setActions(actions) {
562				if (main_core.Type.isArray(actions)) {
563					this.actions = [];
564					actions.forEach(action => {
565						this.actions.push(new Action(this, action));
566					});
567				} else if (actions === null) {
568					this.actions = [];
569				}
570			}
571		}, {
572			key: "getActions",
573			value: function getActions() {
574				return this.actions;
575			}
576		}, {
577			key: "getAction",
578			value: function getAction(id) {
579				for (const action of this.actions) {
580					if (action.getId() === id) {
581						return action;
582					}
583				}
584				return null;
585			}
586		}, {
587			key: "getContainer",
588			value: function getContainer() {
589				if (this.container !== null) {
590					return this.container;
591				}
592				this.container = main_core.Tag.render`<div class="ui-notification-balloon" data-a11y-ignore-inert="true"></div>`;
593				main_core.Dom.append(this.render(), this.container);
594				main_core.Event.bind(this.container, 'mouseenter', () => this.handleMouseEnter());
595				main_core.Event.bind(this.container, 'mouseleave', () => this.handleMouseLeave());
596				return this.container;
597			}
598		}, {
599			key: "render",
600			value: function render() {
601				const customRender = this.getCustomRender();
602				if (customRender !== null) {
603					return customRender.call(this, this);
604				}
605				const content = this.getContent();
606				const width = this.getWidth();
607				const widthStyle = main_core.Type.isNumber(width) ? `${width}px` : width;
608				const message = main_core.Type.isDomNode(content) ? main_core.Tag.render`<div class="ui-notification-balloon-message"></div>` : main_core.Tag.render`<div class="ui-notification-balloon-message">${content ?? ''}</div>`;
609				if (main_core.Type.isDomNode(content)) {
610					main_core.Dom.append(content, message);
611				}
612				const actionsContainer = main_core.Tag.render`<div class="ui-notification-balloon-actions"></div>`;
613				this.getActions().forEach(action => main_core.Dom.append(action.getContainer(), actionsContainer));
614				const wrapper = main_core.Tag.render`<div class="ui-notification-balloon-content"></div>`;
615				main_core.Dom.style(wrapper, 'width', widthStyle);
616				main_core.Dom.append(message, wrapper);
617				main_core.Dom.append(actionsContainer, wrapper);
618				if (this.isCloseButtonVisible()) {
619					main_core.Dom.append(this.getCloseButton(), wrapper);
620				}
621				return wrapper;
622			}
623		}, {
624			key: "setCustomRender",
625			value: function setCustomRender(render) {
626				if (main_core.Type.isFunction(render)) {
627					this.customRender = render;
628				}
629			}
630		}, {
631			key: "getCustomRender",
632			value: function getCustomRender() {
633				return this.customRender;
634			}
635		}, {
636			key: "getStack",
637			value: function getStack() {
638				return this.stack;
639			}
640		}, {
641			key: "setState",
642			value: function setState(state) {
643				const code = this.getStateCode(state);
644				if (code !== null) {
645					this.state = state;
646				}
647			}
648		}, {
649			key: "getState",
650			value: function getState() {
651				return this.state;
652			}
653		}, {
654			key: "getStateCode",
655			value: function getStateCode(mode) {
656				const entry = Object.entries(State).find(([, value]) => value === mode);
657				return entry ? entry[0] : null;
658			}
659		}, {
660			key: "activateAutoHide",
661			value: function activateAutoHide() {
662				if (!this.getAutoHide()) {
663					return;
664				}
665				this.deactivateAutoHide();
666				this.autoHideTimeout = setTimeout(() => this.close(), this.getAutoHideDelay());
667			}
668		}, {
669			key: "deactivateAutoHide",
670			value: function deactivateAutoHide() {
671				if (this.autoHideTimeout !== null) {
672					clearTimeout(this.autoHideTimeout);
673					this.autoHideTimeout = null;
674				}
675			}
676		}, {
677			key: "setAutoHide",
678			value: function setAutoHide(autoHide) {
679				this.autoHide = autoHide !== false;
680			}
681		}, {
682			key: "getAutoHide",
683			value: function getAutoHide() {
684				return this.autoHide;
685			}
686		}, {
687			key: "setAutoHideDelay",
688			value: function setAutoHideDelay(delay) {
689				if (main_core.Type.isNumber(delay) && delay > 0) {
690					this.autoHideDelay = delay;
691				}
692			}
693		}, {
694			key: "getAutoHideDelay",
695			value: function getAutoHideDelay() {
696				return this.autoHideDelay;
697			}
698		}, {
699			key: "animateIn",
700			value: function animateIn(callback) {
701				const container = this.getContainer();
702				if (main_core.Dom.hasClass(container, this.animationClassName)) {
703					callback();
704					return;
705				}
706				const handleTransitionEnd = () => {
707					main_core.Event.unbind(container, 'transitionend', handleTransitionEnd);
708					callback();
709				};
710				main_core.Event.bind(container, 'transitionend', handleTransitionEnd);
711				main_core.Dom.addClass(container, this.animationClassName);
712				if (this.useAirDesign === true) {
713					main_core.Dom.addClass(container, ['--air', '—ui-context-content-dark']);
714				}
715			}
716		}, {
717			key: "animateOut",
718			value: function animateOut(callback) {
719				const container = this.getContainer();
720				if (!main_core.Dom.hasClass(container, this.animationClassName)) {
721					callback();
722					return;
723				}
724				const handleTransitionEnd = () => {
725					main_core.Event.unbind(container, 'transitionend', handleTransitionEnd);
726					callback();
727				};
728				main_core.Event.bind(container, 'transitionend', handleTransitionEnd);
729				main_core.Dom.removeClass(container, this.animationClassName);
730			}
731		}, {
732			key: "handleCloseBtnClick",
733			value: function handleCloseBtnClick() {
734				this.close();
735			}
736		}, {
737			key: "handleMouseEnter",
738			value: function handleMouseEnter() {
739				this.fireEvent('onMouseEnter');
740				this.deactivateAutoHide();
741				this.setState(State.PAUSED);
742				this.show();
743			}
744		}, {
745			key: "handleMouseLeave",
746			value: function handleMouseLeave() {
747				this.fireEvent('onMouseLeave');
748				this.activateAutoHide();
749			}
750		}, {
751			key: "fireEvent",
752			value: function fireEvent(eventName) {
753				const event = this.getEvent(eventName);
754				main_core.onCustomEvent(this, event.getFullName(), [event]);
755				return event;
756			}
757		}, {
758			key: "addEvent",
759			value: function addEvent(eventName, fn) {
760				if (main_core.Type.isFunction(fn)) {
761					main_core.addCustomEvent(this, NotificationEvent.getFullName(eventName), fn);
762				}
763			}
764		}, {
765			key: "removeEvent",
766			value: function removeEvent(eventName, fn) {
767				if (main_core.Type.isFunction(fn)) {
768					main_core.removeCustomEvent(this, NotificationEvent.getFullName(eventName), fn);
769				}
770			}
771		}, {
772			key: "getEvent",
773			value: function getEvent(eventName) {
774				const event = new NotificationEvent();
775				event.setBalloon(this);
776				event.setName(eventName);
777				return event;
778			}
779		}, {
780			key: "getData",
781			value: function getData() {
782				return this.data;
783			}
784		}, {
785			key: "setData",
786			value: function setData(data) {
787				if (main_core.Type.isPlainObject(data)) {
788					this.data = data;
789				}
790			}
791		}]);
792	}();
793
794	class Manager {
795		stacks = Object.create(null);
796		balloons = Object.create(null);
797		balloonDefaults = {};
798		stackDefaults = {};
799		defaultPosition = Position.TOP_RIGHT;
800		constructor() {
801			main_core.addCustomEvent(window, NotificationEvent.getFullName('onClose'), event => this.handleBalloonClose(event));
802		}
803		notify(options) {
804			const opts = main_core.Type.isPlainObject(options) ? options : {};
805			const currentBalloon = (opts.id ? this.getBalloonById(opts.id) : null) ?? (opts.category ? this.getBalloonByCategory(opts.category) : null);
806			if (currentBalloon) {
807				currentBalloon.setOptions(opts);
808				currentBalloon.show();
809				if (opts.blinkOnUpdate === false) {
810					currentBalloon.update(null);
811				} else {
812					currentBalloon.blink();
813				}
814				return undefined;
815			}
816			const stack = (() => {
817				if (opts.stack instanceof Stack) {
818					this.addStack(opts.stack);
819					return opts.stack;
820				}
821				const resolved = main_core.Type.isStringFilled(opts.position) ? this.getStackByPosition(opts.position) : this.getDefaultStack();
822				opts.stack = resolved;
823				return resolved;
824			})();
825			const balloonOptions = main_core.Runtime.merge({}, this.getBalloonDefaults(), opts);
826			const BalloonType = stack.getBalloonType(opts.type);
827			const balloon = new BalloonType(balloonOptions);
828			if (!(balloon instanceof Balloon)) {
829				throw new TypeError('Balloon type must be an instance of BX.UI.Notification.Balloon');
830			}
831			this.balloons[balloon.getId()] = balloon;
832			balloon.show();
833			return balloon;
834		}
835		getBalloonById(balloonId) {
836			return this.balloons[balloonId] ?? null;
837		}
838		getBalloonByCategory(category) {
839			if (main_core.Type.isStringFilled(category)) {
840				for (const balloon of Object.values(this.balloons)) {
841					if (balloon.getCategory() === category) {
842						return balloon;
843					}
844				}
845			}
846			return null;
847		}
848		removeBalloon(balloon) {
849			delete this.balloons[balloon.getId()];
850		}
851		handleBalloonClose(event) {
852			const balloon = event.getBalloon();
853			if (balloon !== null) {
854				this.removeBalloon(balloon);
855			}
856		}
857		getStack(stackId) {
858			return this.stacks[stackId] ?? null;
859		}
860		getDefaultStack() {
861			return this.getStackByPosition(this.getDefaultPosition());
862		}
863		getStackByPosition(position) {
864			let stack = this.getStack(position);
865			if (stack === null) {
866				stack = new Stack(main_core.Runtime.merge({}, this.getStackDefaults(), {
867					id: position,
868					position
869				}));
870				this.addStack(stack);
871			}
872			return stack;
873		}
874		addStack(stack) {
875			if (stack instanceof Stack && this.getStack(stack.getId()) === null) {
876				this.stacks[stack.getId()] = stack;
877			}
878		}
879		setBalloonDefaults(options) {
880			if (main_core.Type.isPlainObject(options)) {
881				Object.assign(this.balloonDefaults, main_core.Runtime.merge(this.balloonDefaults, options));
882			}
883		}
884		getBalloonDefaults() {
885			return this.balloonDefaults;
886		}
887		setStackDefaults(position, options) {
888			if (Stack.getPositionCode(position)) {
889				const stack = this.getStackByPosition(position);
890				stack.setOptions(options ?? null);
891			} else if (main_core.Type.isPlainObject(position)) {
892				const opts = position;
893				for (const pos of Object.values(Position)) {
894					this.setStackDefaults(pos, opts);
895				}
896			}
897		}
898		setDefaultPosition(position) {
899			if (Stack.getPositionCode(position)) {
900				this.defaultPosition = position;
901			}
902		}
903		getDefaultPosition() {
904			return this.defaultPosition;
905		}
906		getStackDefaults() {
907			return this.stackDefaults;
908		}
909	}
910
911	const UI = main_core.Reflection.getClass('BX.UI');
912	const Center = new Manager();
913
914	exports.Action = Action;
915	exports.Balloon = Balloon;
916	exports.Center = Center;
917	exports.Event = NotificationEvent;
918	exports.Manager = Manager;
919	exports.Position = Position;
920	exports.Stack = Stack;
921	exports.State = State;
922	exports.UI = UI;
923
924})(this.BX.UI.Notification = this.BX.UI.Notification || {}, BX);
925//# sourceMappingURL=notification.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.