/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/yandex-messenger-widget-beta@1.24.5/lib_cjs/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var HOST_PROD="https://yandex.{tld}/chat",BACKEND_PROD="production",BUILD_EXTERNAL="chamb-external",extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},extendStatics(e,t)};function __extends$i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var __assign$2=function(){return __assign$2=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},__assign$2.apply(this,arguments)};function __decorate$9(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function __spreadArrays(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n}function preset(e){return e}var type={multiChats:function(e){return preset({flags:__assign$2({newHeader:"1",embedButton:"1"},(null==e?void 0:e.inline)&&{hideClose:"1"})})},singleChat:function(e){return preset({flags:__assign$2({disableNavigation:"1",disableChatList:"1",newHeader:"1",embedButton:"1"},(null==e?void 0:e.inline)&&{hideClose:"1"})})}},external={config:BACKEND_PROD,origin:HOST_PROD,build:BUILD_EXTERNAL};function hasAuth(){return-1!==document.cookie.search(/(^|; )yandex_login=[^;]+/)}function safeRemoveNode(e){try{e&&e.parentNode&&e.parentNode.removeChild(e)}catch(e){}}function setLocalStorageJsonItem(e,t){try{window.localStorage&&window.localStorage.setItem(e,JSON.stringify(t))}catch(e){}}function getLocalStorageJsonItem(e){try{var t=window.localStorage&&window.localStorage.getItem(e);if("string"==typeof t){var r=JSON.parse(t);if(r&&"object"==typeof r)return r}}catch(e){}return null}function removeLocalStorageJsonItem(e){try{window.localStorage&&window.localStorage.removeItem(e)}catch(e){}}function escapeDot(e){return e.replace(/\./g,"\\.")}var YANDEX_TLD=["com.tr","com.ge","com.am","co.il","ua","ru","kz","by","com","net","uz","fr","az","kg","lv","lt","md","tj","tm","ee"],URL_REGEX_YANDEX_TLD_LIST="("+YANDEX_TLD.map((function(e){return escapeDot(e)})).join("|")+")",URL_REGEX_YANDEX_TLD="yandex\\."+URL_REGEX_YANDEX_TLD_LIST,URL_REGEX_YANDEX_YA_TLD="(?:yandex|ya)\\."+URL_REGEX_YANDEX_TLD_LIST,DEFAULT_TLD="ru";function getYandexTld(e){var t=new RegExp(URL_REGEX_YANDEX_TLD+"$").exec(e);return t&&t[1]||""}function isCookiedYandexTld(e){return e&&"net"!==e}function getTld(e){var t=getYandexTld(e);return isCookiedYandexTld(t)?t:DEFAULT_TLD}var getCurrentTld=function(){return getCurrentTld.memo||(getCurrentTld.memo=getTld(window.location.hostname)),getCurrentTld.memo};function replaceTld(e,t){return void 0===t&&(t=getCurrentTld()),e.replace(/\{tld\}/,t)}function buildParam(e,t){return null==t||""===t?"":encodeURIComponent(e)+"="+encodeURIComponent(String(t))}function buildParams(e){return e.map((function(e){var t=e.name,r=e.value;return Array.isArray(r)?r.map((function(e){return buildParam(t,e)})).filter(Boolean).join("&"):buildParam(t,r)})).filter(Boolean).join("&")}function queryStringify$1(e,t){var r=-1===e.search(/\?/)?"?":"&",n=buildParams(Object.keys(t).map((function(e){return{name:e,value:t[e]}})));return e+(n?r+n:"")}function getOrigin(){return window.location.origin||window.location.protocol+"//"+window.location.host}var compareOrigins=function(e,t){return!!e.trim()&&t.some((function(t){return t===e}))},DEFAULT_GUID_MASK="xxxx-xxxx-xxxx-xxxx",UUID_MASK="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";function guid(e){return void 0===e&&(e=DEFAULT_GUID_MASK),e.replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function createUUID(){return guid(UUID_MASK)}var noop=function(){},__values=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Event=function(){function e(){this.listeners=new Set}return e.prototype.addListener=function(e){return!this.listeners.has(e)&&(this.listeners.add(e),!0)},e.prototype.removeListener=function(e){return this.listeners.delete(e)},e.prototype.removeAllListener=function(){this.listeners.clear()},e.prototype.hasListeners=function(){return this.listeners.size>0},e.prototype.dispatch=function(t){var r,n;try{for(var o=__values(this.listeners),i=o.next();!i.done;i=o.next()){var a=i.value;try{var s=a(t);if(s&&s.stopPropagation)return}catch(t){e.errorHandler(t)}}}catch(e){r={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}},e.errorHandler=noop,e}();function isDefined(e){return void 0!==e}function assertDefined(e,t){if(void 0===e)throw new Error(t)}function isString(e){return"string"==typeof e}function isObject(e){return"object"==typeof e&&null!==e}function isBoolean(e){return"boolean"==typeof e}function isNumber(e){return"number"==typeof e&&!Number.isNaN(e)}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},lib$3={},attachRef$1={};function attachRef(e){return function(t,r){Object.defineProperty(t,r,{configurable:!0,get:function(){var t=this,n=function(r){n.current=r;var o=t.props[e];o&&("function"==typeof o?o(r):"object"==typeof o&&(o.current=r))};return n.current=null,Object.defineProperty(this,r,{configurable:!0,value:n}),n}})}}Object.defineProperty(attachRef$1,"__esModule",{value:!0}),attachRef$1.attachRef=void 0,attachRef$1.attachRef=attachRef;var bind={};Object.defineProperty(bind,"__esModule",{value:!0}),bind.bind=void 0,bind.bind=function(e,t,r){if("function"==typeof e)throw new TypeError("Cannot bind static method "+t);var n=r.value,o=!1;return{configurable:!0,get:function(){if(o)return n;var e=n.bind(this);return o=!0,Object.defineProperty(this,t,{configurable:!0,get:function(){return e}}),o=!1,e}}},function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(attachRef$1,e),r(bind,e)}(lib$3);var __decorate$8=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},Timer=function(){function e(e,t,r){void 0===r&&(r=500),this.callback=e,this.timeout=t,this.step=r,this.timeoutId=void 0,this.endTime=0,this.endTime=Date.now()+t,this.tick()}return e.prototype.cancel=function(){this.timeoutId&&clearTimeout(this.timeoutId)},e.prototype.tick=function(){var e=Date.now();if(this.endTime<=e||this.timeout<=0)return this.timeoutId=void 0,void this.callback();this.timeoutId=setTimeout(this.tick,this.endTime-e>this.step?this.step:this.endTime-e)},__decorate$8([lib$3.bind],e.prototype,"tick",null),e}();function isRemoveOldByTag(e){return"tag"in e}var Queue=function(){function e(e){void 0===e&&(e=!1),this.isLocked=e,this.queue=[],this.isExecuting=!1,this.isFreezed=!1}return e.prototype.lock=function(){this.isLocked=!0},e.prototype.unlock=function(){this.isLocked&&(this.isLocked=!1,this.execute())},e.prototype.push=function(e,t){return!this.isFreezed&&(t&&this.cancel(t),this.queue.push(e),this.execute(),!0)},e.prototype.execute=function(){if(!this.isLocked&&!this.isExecuting){for(this.isExecuting=!0;this.queue.length&&!this.isLocked;){var e=this.queue.shift();e&&e.run()}this.isExecuting=!1}},e.prototype.cancel=function(e,t){e?(this.isFreezed=!0,this.queue=this.queue.filter((function(r){var n=isRemoveOldByTag(e)?r.tag===e.tag:r.id===e.id;return n&&r.cancel(t),!n})),this.isFreezed=!1):this.cancelAll(t)},e.prototype.isEmpty=function(){return!this.queue.length},e.prototype.cancelAll=function(e){this.isFreezed=!0,this.queue.forEach((function(t){t.cancel(e)})),this.queue=[],this.isFreezed=!1},e}(),DEFAULT_TAG="default",QueueTask=function(){function e(e,t){var r=void 0===t?{}:t,n=r.tag,o=void 0===n?DEFAULT_TAG:n,i=r.id,a=void 0===i?createUUID():i,s=r.onCancel;this.task=e,this.tag=o,this.onCancel=s,this.id=a}return e.prototype.run=function(){try{this.task()}catch(e){}},e.prototype.cancel=function(e){if(this.onCancel)try{this.onCancel(e)}catch(e){}},e}(),lib$2={},BaseError$3={},ErrorVisitor$3={};Object.defineProperty(ErrorVisitor$3,"__esModule",{value:!0}),ErrorVisitor$3.createHandler=ErrorVisitor$3.ErrorVisitor=void 0;var ErrorVisitor$2=function(e,t){this.error=e,this.callback=t};function createHandler$1(e,t){return Object.keys(e).reduce((function(e,r){return e[r]=function(e){return t(e,r)},e}),{})}ErrorVisitor$3.ErrorVisitor=ErrorVisitor$2,ErrorVisitor$3.createHandler=createHandler$1;var __extends$h=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(BaseError$3,"__esModule",{value:!0}),BaseError$3.BaseError=void 0;var ErrorVisitor_1$1=ErrorVisitor$3,BaseError$2=function(e){function t(r,n){var o=e.call(this,r)||this;return n&&(o.stack=n),Object.setPrototypeOf(o,t.prototype),o}return __extends$h(t,e),t.handle=function(e){return new ErrorVisitor_1$1.ErrorVisitor(this,e)},t.is=function(e){return e instanceof this},t.prototype.accept=function(e){this instanceof e.error&&e.callback(this)},t}(Error);BaseError$3.BaseError=BaseError$2;var LoggableError$3={},__extends$g=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(LoggableError$3,"__esModule",{value:!0}),LoggableError$3.LoggableError=void 0;var BaseError_1$5=BaseError$3,LoggableError$2=function(e){function t(r,n,o){var i=e.call(this,r)||this;return i.loggerFields=n,i.additional=n&&n.additional,o&&(i.stack=o),Object.setPrototypeOf(i,t.prototype),i}return __extends$g(t,e),t}(BaseError_1$5.BaseError);LoggableError$3.LoggableError=LoggableError$2;var SerializableError$3={},__extends$f=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(SerializableError$3,"__esModule",{value:!0}),SerializableError$3.serializeId=SerializableError$3.SerializableError=void 0;var BaseError_1$4=BaseError$3,SerializableError$2=function(e){function t(r,n){var o=e.call(this,r,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return __extends$f(t,e),t.makeSerializable=function(e){this.cache.set(e.SERIALIZE_ID,e)},t.serialize=function(e){return e.serialize()},t.deserialize=function(e){if(e.serializeId===t.SERIALIZE_ID)return new t(e.message);var r=this.cache.get(e.serializeId);return r?new r(e.message):new Error(e.message)},t.prototype.serialize=function(){return{serializeId:this.constructor.SERIALIZE_ID,message:this.message}},t.SERIALIZE_ID="@SerializableError",t.cache=new Map,t}(BaseError_1$4.BaseError);function serializeId$1(e){return function(t){t.SERIALIZE_ID=e,SerializableError$2.makeSerializable(t)}}SerializableError$3.SerializableError=SerializableError$2,SerializableError$3.serializeId=serializeId$1;var TransportError$3={},__extends$e=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(TransportError$3,"__esModule",{value:!0}),TransportError$3.TransportError=void 0;var BaseError_1$3=BaseError$3,TransportError$2=function(e){function t(r,n){var o=e.call(this,"TransportError, "+r,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return __extends$e(t,e),t}(BaseError_1$3.BaseError);TransportError$3.TransportError=TransportError$2;var RequestTimeoutError$3={},__extends$d=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(RequestTimeoutError$3,"__esModule",{value:!0}),RequestTimeoutError$3.RequestTimeoutError=void 0;var TransportError_1$1=TransportError$3,RequestTimeoutError$2=function(e){function t(r){var n=e.call(this,"Request timeout",r)||this;return Object.setPrototypeOf(n,t.prototype),n}return __extends$d(t,e),t}(TransportError_1$1.TransportError);RequestTimeoutError$3.RequestTimeoutError=RequestTimeoutError$2,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.LoggableError=e.ErrorVisitor=e.createHandler=e.BaseError=void 0;var n=BaseError$3;Object.defineProperty(e,"BaseError",{enumerable:!0,get:function(){return n.BaseError}});var o=ErrorVisitor$3;Object.defineProperty(e,"createHandler",{enumerable:!0,get:function(){return o.createHandler}}),Object.defineProperty(e,"ErrorVisitor",{enumerable:!0,get:function(){return o.ErrorVisitor}});var i=LoggableError$3;Object.defineProperty(e,"LoggableError",{enumerable:!0,get:function(){return i.LoggableError}}),r(SerializableError$3,e),r(TransportError$3,e),r(RequestTimeoutError$3,e)}(lib$2);var DEFAULT_TIMEOUT=1e4,Request=function(){function e(e,t,r){var n=this;void 0===t&&(t=DEFAULT_TIMEOUT),this.onResult=e,this.timeout=new Timer((function(){n.result(new r)}),t)}return e.prototype.result=function(e,t){this.clearTimeout(),e?this.onResult(e):this.onResult(void 0,t)},e.prototype.clearTimeout=function(){this.timeout&&(this.timeout.cancel(),this.timeout=void 0)},e}(),RequestsBucket=function(){function e(e){void 0===e&&(e=lib$2.RequestTimeoutError),this.RequestTimeoutErrorCtr=e,this.awaiters=new Map,this.seqNo=1}return e.prototype.event=function(e){var t=e(this.seqNo);return this.seqNo++,t},e.prototype.request=function(e,t){var r=this;return new Promise((function(n,o){var i=e(r.seqNo);r.seqNo++;var a=new Request((function(e,t){r.remove(i),e?o(e):n(t)}),t,r.RequestTimeoutErrorCtr);r.awaiters.set(i,a)}))},e.prototype.result=function(e,t,r){var n=this.awaiters.get(e);return!!n&&(t?n.result(t):n.result(void 0,r),!0)},e.prototype.drop=function(e){this.awaiters.forEach((function(t){return t.result(e)})),this.awaiters.clear(),this.seqNo=1},e.prototype.remove=function(e){return this.awaiters.delete(e)},e}();function isNumberAsString(e){if("string"!=typeof e)return!1;try{var t=Number(e);return!isNaN(t)}catch(e){return!1}}var Assert=function(){function e(){this.isOptional=!1,this.isUndefinable=!1,this.validators=[]}return Object.defineProperty(e.prototype,"string",{get:function(){return this.validators.push(isString),this},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"notEmptyString",{get:function(){return this.validators.push((function(e){return isString(e)&&""!==e})),this},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"object",{get:function(){return this.validators.push(isObject),this},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"number",{get:function(){return this.validators.push(isNumber),this},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numberAsString",{get:function(){return this.validators.push(isNumberAsString),this},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"boolean",{get:function(){return this.validators.push(isBoolean),this},enumerable:!1,configurable:!0}),e.prototype.shape=function(e){return this.validators.push((function(t){return e.validate(t)})),this},Object.defineProperty(e.prototype,"optional",{get:function(){return this.isOptional=!0,this},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"undefinable",{get:function(){return this.isUndefinable=!0,this},enumerable:!1,configurable:!0}),e.prototype.values=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.validators.push((function(t){return e.some((function(e){return t===e}))})),this},e.prototype.arrayOf=function(e){return this.validators.push((function(t){return Array.isArray(t)&&t.every(e)})),this},Object.defineProperty(e.prototype,"any",{get:function(){return this.isUndefinable=!0,this.validators.push((function(){return!0})),this},enumerable:!1,configurable:!0}),e.prototype.validate=function(e){return isDefined(e)?this.validators.some((function(t){return t(e)})):this.isOptional||this.isUndefinable},e}(),ShapeValidator=function(){function e(e){this.shape=e}return e.prototype.validate=function(e){var t=this;return!(!isDefined(e)||!isObject(e))&&Object.keys(this.shape).every((function(r){return r in e?t.shape[r].validate(e[r]):t.shape[r].isOptional}))},e.is=function(){return new Assert},e}(),Shape={get is(){return new Assert},create:function(e){return new ShapeValidator(e)}},__read$1=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},__spread$1=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read$1(arguments[t]));return e};function once(e){var t=!1;return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];t||(t=!0,e.apply(void 0,__spread$1(r)))}}var compareArray=function(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))},__read=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},__spread=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e},memo=function(e){var t=void 0,r=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];if(t&&compareArray(t.args,r))return t.result;var o=e.apply(void 0,__spread(r));return t={result:o,args:r},o};return r.clear=function(){t=void 0},r},fullscreen=preset({flags:{fullscreenSupported:"1"}}),STRICT_YANDEX_ORIGIN=new RegExp("^https://"+URL_REGEX_YANDEX_YA_TLD+"$"),getParentUrl=function(){var e=getOrigin();if(0===e.search(STRICT_YANDEX_ORIGIN)&&window.location.pathname){var t=window.location.pathname.split("/");return t[0],[e,t[1]].join("/")}return e},Config=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.values={},this.extend.apply(this,__spreadArrays(this.constructor.DEFAULTS,e))}return e.extend=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends$i(t,e),t}(this),e.DEFAULTS=t,e},e.prototype.extend=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.values=e.reduce((function(e,t){return __assign$2(__assign$2(__assign$2({},e),t),{iframeOpenData:__assign$2(__assign$2({},e.iframeOpenData),t.iframeOpenData),flags:__assign$2(__assign$2({},e.flags),t.flags)})}),__assign$2({},this.values))},e.prototype.getFlags=function(){var e=__assign$2(__assign$2({},this.values.flags),this.values.fullscreen?fullscreen.flags:void 0);return Object.keys(e).reduce((function(t,r){return null!=r&&void 0!==e[r]&&t.push(r+"="+e[r]),t}),[]).join(";")},e.prototype.getMessengerUrl=function(e,t,r){var n=this.values,o=n.origin,i=n.config,a=n.build,s=n.tld,l=n.lang,u=void 0===l?"ru":l,c=n.serviceId,d=n.workspaceId,p=n.orgId,h=n.catchUrlClick,f=n.unreadCounterChatId,v=n.unreadCounterOtherGuid,g=n.unreadCounterNsFilter,b=n.unreadWithCountChats,y=n.debug,m=n.authType,_=__assign$2({config:i,build:a,lang:u,debug:y,parentOrigin:getOrigin(),parentUrl:getParentUrl(),serviceId:c,workspaceId:d,orgId:p,utm_source:"widget",utm_medium:"iframe",widgetId:e,flags:this.getFlags(),protocolVersion:t,authType:m,unreadCounterChatId:f,unreadCounterOtherGuid:v,unreadCounterNsFilter:g,unreadWithCountChats:b,catchUrlClick:h?"true":void 0,widgetVersion:"1.24.0"},r);return queryStringify$1(replaceTld(replaceTld(o,s)),_)},e.DEFAULTS=[],e}(),lib$1={},settings={},__assign$1=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign$1=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},__assign$1.apply(this,arguments)};Object.defineProperty(settings,"__esModule",{value:!0}),settings.getSettings=settings.updateSettings=void 0;var baseSettings={clck:"https://yandex.ru/clck/click",project:"unknown",additional:{},level:"error"},updateSettings=function(e){baseSettings=__assign$1(__assign$1({},baseSettings),e)};settings.updateSettings=updateSettings;var getSettings=function(){return baseSettings};settings.getSettings=getSettings;var implementation={},send$1={};Object.defineProperty(send$1,"__esModule",{value:!0}),send$1.send=void 0;var settings_1=settings,getCounterSections=function(e,t){return["/path="+e,t?"/vars="+t:"","/cts="+(new Date).getTime(),"/*"]},send=function(e,t){var r=getCounterSections(e,t).join(""),n=settings_1.getSettings().clck;if(n&&!(navigator&&navigator.sendBeacon&&navigator.sendBeacon(n,r)))if("undefined"!=typeof window&&window.fetch)fetch(n,{method:"POST",body:r});else{var o=new XMLHttpRequest;o.open("POST",n),o.send(r)}};send$1.send=send,function(e){var t=commonjsGlobal&&commonjsGlobal.__assign||function(){return t=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},t.apply(this,arguments)},r=commonjsGlobal&&commonjsGlobal.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n};Object.defineProperty(e,"__esModule",{value:!0}),e.handleError=e.sendError=e.baseNormalizeError=void 0;var n=send$1,o=settings;e.baseNormalizeError=function(e){void 0===e&&(e={});var t=e.filename||e.fileName||"",r=e.error&&e.error.stack||e.stack||"",n=e.message||"";return{file:t,line:e.lineno||e.lineNumber,col:e.colno||e.colNumber,stack:r,message:n,additional:e.additional,referrer:"undefined"!=typeof location&&location.href}};function i(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];"undefined"!=typeof console&&(t=console.error).call.apply(t,r([console,e],n))}e.sendError=function(e,t){void 0===t&&(t={});var r=o.getSettings(),a={"-url":e.file,"-line":e.line,"-col":e.col,"-stack":e.stack,"-env":r.env,"-msg":e.message,"-project":r.project,"-page":e.page||r.page,"-level":e.level,"-version":r.version,"-referrer":e.referrer,"-additional":t.additional,"-ua":"undefined"!=typeof navigator&&navigator.userAgent,"-ts":+new Date};r.debug&&i("[error-counter]",a),n.send(e.path,function(e){var t=[];return Object.keys(e).map((function(r){if(e.hasOwnProperty(r)&&(e[r]||0===e[r])){var n=encodeURIComponent(e[r]).replace(/\*/g,"%2A");t.push(r+"="+n)}})),t.join(",")}(a))};e.handleError=function(r){var n=o.getSettings();r.path="690.2354";var a="";try{a=JSON.stringify(t(t({},n.additional),r.additional))}catch(e){i("[error-counter] json.stringify:",e)}e.sendError(r,{additional:a})}}(implementation);var logError$2={};Object.defineProperty(logError$2,"__esModule",{value:!0}),logError$2.logError=void 0;var implementation_1=implementation,fields=["type","additional","level","referrer"],logError$1=function(e,t){void 0===t&&(t={});var r=implementation_1.baseNormalizeError(e);r.message=[t.message,r.message].filter(Boolean).join("; ")||"Empty error";for(var n=0;n<fields.length;n++){var o=fields[n];t[o]?r[o]=t[o]:e&&e[o]&&(r[o]=e[o])}implementation_1.handleError(r)};logError$2.logError=logError$1,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(settings,e),r(implementation,e),r(logError$2,e)}(lib$1),lib$1.updateSettings({project:"messenger-widget-npm",version:"1.24.0",env:"production"});var LOGGED_SYMBOL="__logged__";function isLogged(e){return e&&!0===e[LOGGED_SYMBOL]}var logError=function(e,t){if(e instanceof Error){if(isLogged(e))return;Object.defineProperty(e,LOGGED_SYMBOL,{value:!0,enumerable:!1,configurable:!1})}lib$1.logError(e,t)},loggable=function(e){for(var t=function(e){function t(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=this;try{n=e.apply(this,t)||this}catch(e){throw logError(e),e}return n}return __extends$i(t,e),t}(e),r=function(r){if(!e.prototype.hasOwnProperty(r))return"continue";Object.defineProperty(t.prototype,r,{get:function(){var t=this,n=Object.getOwnPropertyDescriptor(e.prototype,r),o=n.get?n.get.call(t):n.value;if("function"!=typeof o)return o;function i(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];try{var n=o.apply(t,e);return isDefined(n)&&"function"==typeof n.catch&&n.catch(logError),n}catch(e){throw logError(e),e}}return Object.defineProperty(this,r,{value:i}),i},configurable:!0})},n=0,o=Object.keys(e.prototype);n<o.length;n++){r(o[n])}return t},EVENTS_NAMES=["ready","close","error","unload","chatHistoryLoaded","fullscreenOn","fullscreenOff","counter"],eventsFactory=function(){return Object.defineProperties({},EVENTS_NAMES.reduce((function(e,t){return e[t]={get:function(){var e=new Event;return Object.defineProperty(this,t,{value:e}),e},configurable:!0},e}),{}))},API$1=Symbol("API"),PublicWidgetAPI=function(){function e(e){this[API$1]=e}return e.prototype.serviceMeta=function(e){return this[API$1].serviceMeta(e)},e.prototype.setVisibility=function(e){return this[API$1].setVisibility(e)},e.prototype.setThemeVariables=function(e){return this[API$1].setThemeVariables(e)},e.prototype.chatMetadata=function(e){return this[API$1].chatMetadata(e)},e}(),WidgetHandlers=function(){this.uiInterceptor=new Event},lib={},BaseError$1={},ErrorVisitor$1={};Object.defineProperty(ErrorVisitor$1,"__esModule",{value:!0}),ErrorVisitor$1.createHandler=ErrorVisitor$1.ErrorVisitor=void 0;var ErrorVisitor=function(e,t){this.error=e,this.callback=t};function createHandler(e,t){return Object.keys(e).reduce((function(e,r){return e[r]=function(e){return t(e,r)},e}),{})}ErrorVisitor$1.ErrorVisitor=ErrorVisitor,ErrorVisitor$1.createHandler=createHandler;var __extends$c=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(BaseError$1,"__esModule",{value:!0}),BaseError$1.BaseError=void 0;var ErrorVisitor_1=ErrorVisitor$1,BaseError=function(e){function t(r,n){var o=e.call(this,r)||this;return n&&(o.stack=n),Object.setPrototypeOf(o,t.prototype),o}return __extends$c(t,e),t.handle=function(e){return new ErrorVisitor_1.ErrorVisitor(this,e)},t.is=function(e){return e instanceof this},t.prototype.accept=function(e){this instanceof e.error&&e.callback(this)},t}(Error);BaseError$1.BaseError=BaseError;var LoggableError$1={},__extends$b=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(LoggableError$1,"__esModule",{value:!0}),LoggableError$1.LoggableError=void 0;var BaseError_1$2=BaseError$1,LoggableError=function(e){function t(r,n,o){var i=e.call(this,r)||this;return i.loggerFields=n,i.additional=n&&n.additional,o&&(i.stack=o),Object.setPrototypeOf(i,t.prototype),i}return __extends$b(t,e),t}(BaseError_1$2.BaseError);LoggableError$1.LoggableError=LoggableError;var SerializableError$1={},__extends$a=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(SerializableError$1,"__esModule",{value:!0}),SerializableError$1.serializeId=SerializableError$1.SerializableError=void 0;var BaseError_1$1=BaseError$1,SerializableError=function(e){function t(r,n){var o=e.call(this,r,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return __extends$a(t,e),t.makeSerializable=function(e){this.cache.set(e.SERIALIZE_ID,e)},t.serialize=function(e){return e.serialize()},t.deserialize=function(e){if(e.serializeId===t.SERIALIZE_ID)return new t(e.message);var r=this.cache.get(e.serializeId);return r?new r(e.message):new Error(e.message)},t.prototype.serialize=function(){return{serializeId:this.constructor.SERIALIZE_ID,message:this.message}},t.SERIALIZE_ID="@SerializableError",t.cache=new Map,t}(BaseError_1$1.BaseError);function serializeId(e){return function(t){t.SERIALIZE_ID=e,SerializableError.makeSerializable(t)}}SerializableError$1.SerializableError=SerializableError,SerializableError$1.serializeId=serializeId;var TransportError$1={},__extends$9=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(TransportError$1,"__esModule",{value:!0}),TransportError$1.TransportError=void 0;var BaseError_1=BaseError$1,TransportError=function(e){function t(r,n){var o=e.call(this,"TransportError, "+r,n)||this;return Object.setPrototypeOf(o,t.prototype),o}return __extends$9(t,e),t}(BaseError_1.BaseError);TransportError$1.TransportError=TransportError;var RequestTimeoutError$1={},__extends$8=commonjsGlobal&&commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(RequestTimeoutError$1,"__esModule",{value:!0}),RequestTimeoutError$1.RequestTimeoutError=void 0;var TransportError_1=TransportError$1,RequestTimeoutError=function(e){function t(r){var n=e.call(this,"Request timeout",r)||this;return Object.setPrototypeOf(n,t.prototype),n}return __extends$8(t,e),t}(TransportError_1.TransportError);RequestTimeoutError$1.RequestTimeoutError=RequestTimeoutError,function(e){var t=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.LoggableError=e.ErrorVisitor=e.createHandler=e.BaseError=void 0;var n=BaseError$1;Object.defineProperty(e,"BaseError",{enumerable:!0,get:function(){return n.BaseError}});var o=ErrorVisitor$1;Object.defineProperty(e,"createHandler",{enumerable:!0,get:function(){return o.createHandler}}),Object.defineProperty(e,"ErrorVisitor",{enumerable:!0,get:function(){return o.ErrorVisitor}});var i=LoggableError$1;Object.defineProperty(e,"LoggableError",{enumerable:!0,get:function(){return i.LoggableError}}),r(SerializableError$1,e),r(TransportError$1,e),r(RequestTimeoutError$1,e)}(lib);var __extends$7=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate$7=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},RequestCanceledError=function(e){function t(t){var n=e.call(this,t)||this;return Object.setPrototypeOf(n,r.prototype),n}var r;return __extends$7(t,e),r=t,t=r=__decorate$7([lib.serializeId("RequestCanceledError")],t)}(lib.SerializableError),__extends$6=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate$6=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},CookieNeededError=function(e){function t(t){var n=e.call(this,t)||this;return Object.setPrototypeOf(n,r.prototype),n}var r;return __extends$6(t,e),r=t,t=r=__decorate$6([lib.serializeId("CookieNeededError")],t)}(lib.SerializableError),API_SCOPE="widgetTransport",API_VERSION=2,LoggerFacade=function(){function e(){}return e.prototype.configurate=function(e){this.loggerFactory=e},e.prototype.create=function(e){return this.loggerFactory?this.loggerFactory(e):{log:function(){},error:function(){}}},e}(),loggerFacade=new LoggerFacade;function createLogger(e){return loggerFacade.create(e)}var CLOSE_CODE,GUID_MASK="xxxx-xxxx-xxxx-xxxx";!function(e){e[e.NORMAL=0]="NORMAL",e[e.CONNECTION_CLOSED=1]="CONNECTION_CLOSED",e[e.ERROR=2]="ERROR",e[e.CONNECTION_TERMINATED=3]="CONNECTION_TERMINATED"}(CLOSE_CODE||(CLOSE_CODE={}));var PING_MESSAGE="@@@@ping",PONG_MESSAGE="@@@@pong",__extends$5=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate$5=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},ChannelError=function(e){function t(t){var n=e.call(this,t)||this;return Object.setPrototypeOf(n,r.prototype),n}var r;return __extends$5(t,e),r=t,t=r=__decorate$5([lib$2.serializeId("@ChannelError")],t)}(lib$2.SerializableError),__extends$4=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate$4=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},ConnectionClosedError=function(e){function t(t){var n=e.call(this,t)||this;return Object.setPrototypeOf(n,r.prototype),n}var r;return __extends$4(t,e),r=t,t=r=__decorate$4([lib$2.serializeId("@ConnectionClosedError")],t)}(ChannelError),__extends$3=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate$3=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},UnhandledResponseError=function(e){function t(t){var n=e.call(this,t)||this;return Object.setPrototypeOf(n,r.prototype),n}var r;return __extends$3(t,e),r=t,t=r=__decorate$3([lib$2.serializeId("@UnhandledResponseError")],t)}(ChannelError),validator=Shape.create({channelId:Shape.is.string,id:Shape.is.string,error:Shape.is.optional.any,type:Shape.is.values("request","response","registration","kill","observe","unobserve","notify","event","ready"),refId:Shape.is.optional.string,data:Shape.is.any});function isChannelEvent(e){return validator.validate(e)}function deserializeError(e){return lib$2.SerializableError.deserialize(e)||new ChannelError("unknown")}function serializeError(e){if(e)return"string"==typeof e?new ChannelError(e).serialize():e instanceof lib$2.SerializableError?lib$2.SerializableError.serialize(e):e instanceof Error?new ChannelError(e.message).serialize():new ChannelError("unknown").serialize()}function eventFactoryProvider(e){return function(t,r,n,o){return void 0===n&&(n=void 0),void 0===o&&(o=""),{channelId:e,id:guid(GUID_MASK),refId:o,type:t,data:r,error:serializeError(n)}}}var __decorate$2=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},log$1=createLogger("ChannelBase").log,ChannelBase=function(){function e(e){this.channelId=e,this.connectionStatus="closed",this.onRequest=new Event,this.onEvent=new Event,this.onClose=new Event,this.onObserve=new Event,this.observers=new Map,this.observables=new Set,this.requests=new RequestsBucket,this.queue=new Queue(!0),this.eventHandlers=new Map,this.eventFactory=eventFactoryProvider(this.channelId),this.eventHandlers.set("observe",this.handleObserveMessage).set("unobserve",this.handleUnobserveMessage).set("event",this.handleEventMessage).set("response",this.handleResponseMessage).set("request",this.handleRequestMessage).set("notify",this.handleNotifyMessage).set("kill",this.handleKillMessage)}return e.prototype.request=function(e,t,r){return(null==r?void 0:r.cancelPreviousRequestsWithSameType)&&this.queue.cancel({tag:e}),this.sendRequest(this.eventFactory("request",{type:e,data:t}),r)},e.prototype.event=function(e,t){this.sendEvent(this.eventFactory("event",{type:e,data:t}))},e.prototype.observe=function(e,t){return log$1("adding observer: %s",e),this.addObserver(e,t),this.sendRequest(this.eventFactory("observe",{objectName:e}))},e.prototype.unobserve=function(e,t){return this.removeObserver(e,t),this.getObserver(e).callbacks.size?Promise.resolve():this.sendRequest(this.eventFactory("unobserve",{objectName:e}))},e.prototype.notifyObservers=function(e,t){this.observables.has(e)&&this.sendEvent(this.eventFactory("notify",{object:t,objectName:e}))},e.prototype.setPort=function(e){this.port&&(this.port.close(),this.port.removeEventListener("message",this.handleMessage)),this.port=e,this.port.addEventListener("message",this.handleMessage),this.port.start()},e.prototype.unlock=function(){this.connectionStatus="opened",this.queue.unlock()},e.prototype.close=function(e){var t=e.closeCode,r=void 0===t?CLOSE_CODE.NORMAL:t,n=e.reason,o=void 0===n?"Transport was closed":n,i=e.error,a=void 0===i?new ConnectionClosedError(o):i,s=e.persistQueue,l=void 0!==s&&s;if(log$1("destroying",this.channelId,o),"closed"!==this.connectionStatus){this.closeCode=r,this.closeReason=o,this.closeError=a,this.connectionStatus="closed",this.cleanup(a,l),this.queue.lock();var u=this.port;if(u){u.removeEventListener("message",this.handleMessage);try{this.sendBypass(this.eventFactory("kill",void 0,a))}catch(e){}try{u.close()}catch(e){}}this.port=void 0,this.onClose.dispatch(this)}},e.prototype.cleanup=function(t,r){void 0===t&&(t=new e.CancelError("Cleanup")),void 0===r&&(r=!1),this.observers.clear(),r||this.queue.cancel(void 0,t),this.requests.drop(t)},e.prototype.sendRequest=function(t,r){var n=this;log$1("enqueue request: %o",t);var o=(t.data||{}).type;return new Promise((function(i,a){n.queue.push(new QueueTask((function(){n.requests.request((function(){return n.sendBypass(t)}),null==r?void 0:r.timeout).then(i).catch(a)}),{onCancel:function(t){void 0===t&&(t=new e.CancelError("Request cancelled")),a(t)},tag:o}))}))},e.prototype.sendEvent=function(e){var t=this;log$1("enqueue event: %o",e);var r=(e.data||{}).type;this.queue.push(new QueueTask((function(){t.sendBypass(e)}),{tag:r}))},e.prototype.sendBypass=function(e){if(!this.port)throw new ChannelError("Port not found");return log$1("sending message: %o",e),this.port.postMessage(e),e.id},e.prototype.handleMessage=function(e){var t,r=e.data;log$1("message handled: %o",r),isChannelEvent(r)&&r.channelId===this.channelId&&(e.stopImmediatePropagation(),null===(t=this.eventHandlers.get(r.type))||void 0===t||t(e))},e.prototype.handleResponseMessage=function(e){var t=e.data,r=t.refId,n=t.data,o=t.error;o?(log$1("handle response error: %o",o),this.requests.result(r,deserializeError(o))):(log$1("handle response: %o",e.data),this.requests.result(r,void 0,n))},e.prototype.handleRequestMessage=function(e){var t=this,r=e.data,n=r.data,o=r.id;this.onRequest.dispatch({type:n.type,payload:n.data,reject:function(e){t.sendBypass(t.eventFactory("response",void 0,e,o))},response:function(e){Promise.resolve(e).then((function(e){t.sendBypass(t.eventFactory("response",e,void 0,o))})).catch((function(e){t.sendBypass(t.eventFactory("response",void 0,e,o))}))}})},e.prototype.handleKillMessage=function(e){log$1("handle kill message: %o",e.data);var t=e.data.error?deserializeError(e.data.error):void 0;this.close({closeCode:ConnectionClosedError.is(t)?CLOSE_CODE.CONNECTION_CLOSED:CLOSE_CODE.ERROR,reason:"kill signal",error:t})},e.prototype.handleUnobserveMessage=function(e){var t;log$1("handle unobserve message: %o",e.data);var r=null===(t=e.data.data)||void 0===t?void 0:t.objectName;this.observables.delete(r),this.sendEvent(this.eventFactory("response",void 0,void 0,e.data.id))},e.prototype.handleObserveMessage=function(e){var t=this;log$1("handle observe message: %o",e);var r=e.data,n=r.data,o=r.id,i=n.objectName;this.observables.add(i),this.onObserve.dispatch({data:{objectName:i},notify:function(e){t.notifyObservers(i,e)}}),this.sendEvent(this.eventFactory("response",void 0,void 0,o))},e.prototype.handleNotifyMessage=function(e){log$1("handle notify message: %o",e.data);var t=e.data.data,r=t.objectName,n=t.object;this.getObserver(r).callbacks.forEach((function(e){return e(n)}))},e.prototype.handleEventMessage=function(e){log$1("handle event message: $o",e.data),this.onEvent.dispatch({type:e.data.data.type,data:e.data.data.data})},e.prototype.getObserver=function(e){var t=this.observers.get(e);return t||(t={callbacks:new Set},this.observers.set(e,t)),t},e.prototype.addObserver=function(e,t){this.getObserver(e).callbacks.add(t)},e.prototype.removeObserver=function(e,t){this.getObserver(e).callbacks.delete(t)},e.CancelError=ChannelError,__decorate$2([lib$3.bind],e.prototype,"handleMessage",null),__decorate$2([lib$3.bind],e.prototype,"handleResponseMessage",null),__decorate$2([lib$3.bind],e.prototype,"handleRequestMessage",null),__decorate$2([lib$3.bind],e.prototype,"handleKillMessage",null),__decorate$2([lib$3.bind],e.prototype,"handleUnobserveMessage",null),__decorate$2([lib$3.bind],e.prototype,"handleObserveMessage",null),__decorate$2([lib$3.bind],e.prototype,"handleNotifyMessage",null),__decorate$2([lib$3.bind],e.prototype,"handleEventMessage",null),e}(),__extends$2=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),__decorate$1=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},log=createLogger("ChannelOutgoing").log,ChannelOutgoing=function(e){function t(t,r,n){var o=e.call(this,t)||this;return o.channelTransportProvider=r,o.params=n,o.onConnectionEstablished=new Event,o.eventHandlers.set("ready",o.handleReady),o}return __extends$2(t,e),t.prototype.connect=function(){this.sendRegistrationEvent()},t.prototype.disposeTransport=function(){var e,t;null===(e=this.transport)||void 0===e||e.onClose.removeListener(this.handleClose),null===(t=this.transport)||void 0===t||t.onOpen.removeListener(this.handleOpen),this.transport=void 0,this.requestTransportCallback=void 0,this.connectionStatus="closed"},t.prototype.sendRegistrationEvent=function(e){var t,r=this;void 0===e&&(e=!1),this.ensureTransport()&&(log("connecting"),this.connectionStatus="connecting",this.closeReason=void 0,this.closeCode=void 0,this.closeError=void 0,this.requests.request((function(){var e,t=r.eventFactory("registration",null===(e=r.params)||void 0===e?void 0:e.scope);log("sending register event to receiver: %o, %s",t);var n=new MessageChannel;return r.setPort(n.port1),r.transport.send(t,[n.port2]),t.id}),null===(t=this.params)||void 0===t?void 0:t.connectTimeout).then((function(t){log("connected, status: %o",status),t.manualUnlock||r.ready(e)})).catch((function(e){log("failed to connect: %o",e),r.close({closeCode:CLOSE_CODE.ERROR,reason:null==e?void 0:e.message,error:e,persistQueue:!0})})))},t.prototype.sendRequest=function(t){return"closed"===this.connectionStatus&&this.connect(),e.prototype.sendRequest.call(this,t)},t.prototype.sendEvent=function(t){return"closed"===this.connectionStatus&&this.connect(),e.prototype.sendEvent.call(this,t)},t.prototype.ensureTransport=function(){return this.transport&&this.transport.closed()&&this.disposeTransport(),this.transport||this.requestTransportCallback||this.requestTransport(),Boolean(this.transport)},t.prototype.requestTransport=function(){var e=this,t=once((function(r,n){t===e.requestTransportCallback&&(e.requestTransportCallback=void 0,n?e.close({closeCode:CLOSE_CODE.ERROR,reason:"Request transport callback error",error:n,persistQueue:!0}):(e.transport=r,e.transport.onClose.addListener(e.handleClose),e.transport.onOpen.addListener(e.handleOpen),"opened"===e.transport.connectionStatus?e.connect():(e.connectionStatus="closed",e.transport.connect())))}));this.requestTransportCallback=t,this.connectionStatus="connecting";try{this.channelTransportProvider(this.requestTransportCallback)}catch(e){this.close({closeCode:CLOSE_CODE.ERROR,reason:"Transport provider error",error:e,persistQueue:!0})}},t.prototype.handleClose=function(e){this.close({closeCode:CLOSE_CODE.ERROR,reason:null==e?void 0:e.message,error:e})},t.prototype.handleOpen=function(e){var t=e.reconnect;log("handle open singal",t,this.connectionStatus),(t||"closed"===this.connectionStatus)&&(this.close({closeCode:CLOSE_CODE.CONNECTION_CLOSED,reason:"reconnecting"}),this.sendRegistrationEvent(t))},t.prototype.handleReady=function(){this.ready()},t.prototype.ready=function(e){void 0===e&&(e=!1),this.unlock(),this.onConnectionEstablished.dispatch({reconnect:e})},t.prototype.dispose=function(e,t){var r=this.connectionStatus;this.disposeTransport(),this.connectionStatus=r,this.close({closeCode:e,reason:t})},__decorate$1([lib$3.bind],t.prototype,"handleClose",null),__decorate$1([lib$3.bind],t.prototype,"handleOpen",null),__decorate$1([lib$3.bind],t.prototype,"handleReady",null),t}(ChannelBase),__decorate=function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a},PostMessageChannelTransport=function(){function e(e){void 0===e&&(e=!1),this.manualOpen=e,this.onMessage=new Event,this.onClose=new Event,this.onOpen=new Event,this.connectionStatus="closed",this.connectionCount=0,this.queue=new Queue(!0)}return e.prototype.send=function(e,t){var r=this;this.queue.push(new QueueTask((function(){r.sendBypass(e,t)})))},e.prototype.ping=function(){this.sendBypass(PING_MESSAGE)},e.prototype.pong=function(){this.sendBypass(PONG_MESSAGE)},e.prototype.close=function(e){"closed"!==this.connectionStatus&&(this.connectionStatus="closed",this.queue.cancel(void 0,null==e?void 0:e.message),this.queue.lock(),this.onClose.dispatch(e))},e.prototype.handleOpen=function(){var e="opened"===this.connectionStatus;e||(this.connectionStatus="opened"),this.connectionCount++,this.onOpen.dispatch({reconnect:this.connectionCount>1}),e||this.queue.unlock()},e.prototype.handleMessage=function(e){if(this.validateMessage(e)){if(isString(e.data))switch(e.data){case PING_MESSAGE:return this.pong(),void(this.manualOpen||this.handleOpen());case PONG_MESSAGE:return void(this.manualOpen||"connecting"!==this.connectionStatus||this.handleOpen())}"opened"===this.connectionStatus&&this.onMessage.dispatch(e)}},__decorate([lib$3.bind],e.prototype,"handleMessage",null),e}(),__extends$1=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),IframePostMessageTransport=function(e){function t(t,r){var n=e.call(this)||this;return n.childWindow=t,n.targetOrigin=r,t.parent.addEventListener("message",n.handleMessage),n}return __extends$1(t,e),t.prototype.connect=function(){this.connectionStatus="connecting",this.ping()},t.prototype.sendBypass=function(e,t){var r;null===(r=this.childWindow)||void 0===r||r.postMessage(e,this.targetOrigin,t)},t.prototype.validateMessage=function(e){return e.source===this.childWindow&&compareOrigins(e.origin,[this.targetOrigin])},t.prototype.dispose=function(){var e;null===(e=this.childWindow)||void 0===e||e.parent.removeEventListener("message",this.handleMessage),this.childWindow=void 0,this.close()},t.prototype.closed=function(){var e;return Boolean(null===(e=this.childWindow)||void 0===e?void 0:e.closed)},t}(PostMessageChannelTransport),__extends=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ChildWindowPostMessageTransport=function(e){function t(t,r,n,o){var i=e.call(this,!1)||this;return i.childWindow=t,i.currentWindow=r,i.targetOrigin=n,i.allowedOrigins=o,i.currentWindow.addEventListener("message",i.handleMessage),i}return __extends(t,e),t.prototype.connect=function(){this.connectionStatus="connecting",this.ping()},t.prototype.sendBypass=function(e,t){var r;null===(r=this.childWindow)||void 0===r||r.postMessage(e,this.targetOrigin,t)},t.prototype.validateMessage=function(e){return compareOrigins(e.origin,this.allowedOrigins)},t.prototype.dispose=function(){this.currentWindow.removeEventListener("message",this.handleMessage),this.childWindow=void 0,this.currentWindow=void 0,this.close()},t.prototype.closed=function(){return Boolean(this.childWindow.closed)},t}(PostMessageChannelTransport);function rnd(){return Math.random().toString(36).substring(7)}var hasDocument="undefined"!=typeof document,hasWindow="undefined"!=typeof window,hasNavigator="undefined"!=typeof navigator,hasScreen="undefined"!=typeof screen;function getCharset(){return hasDocument&&"string"==typeof document.charset?document.charset.toLowerCase():""}function getHost(){return hasWindow&&window.location?window.location.hostname:""}function getPageUrl(){return hasWindow&&window.location?window.location.href:""}function getReferrer(){return hasDocument?document.referrer:""}function getTitle(){return hasDocument?document.title:""}function cookieEnabled(){return!!hasNavigator&&navigator.cookieEnabled}function getScreenSize(){return hasScreen?[screen.width,screen.height,screen.colorDepth].join("x"):""}function truncate(e,t){return(e||"").slice(0,t)}function getRandom(){return Math.floor(1e6*Math.random())}var MAX_TITLE_LEN=512;function addParam(e,t,r){(r||0===r)&&e.push(t+":"+(!0===r?"1":r))}function getBrowserInfo(e,t){var r=[];return e&&Object.keys(e).forEach((function(t){return addParam(r,t,e[t])})),addParam(r,"rn",getRandom()),addParam(r,"c",cookieEnabled()),addParam(r,"s",getScreenSize()),addParam(r,"en",getCharset()),addParam(r,"t",truncate(t,MAX_TITLE_LEN)),r.join(":")}function queryStringify(e){return Object.keys(e).filter((function(t){var r=e[t];return""!==r&&null!=r})).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&")}var MAX_URL_LEN=1024;function prepareUrl(e){return truncate(e,MAX_URL_LEN)}function sendData(e,t){var r="https://mc.yandex.ru/watch/"+e+"?"+queryStringify(t);"undefined"!=typeof navigator&&navigator.sendBeacon?navigator.sendBeacon(r," "):"undefined"!=typeof fetch?fetch(r,{credentials:"include"}):"undefined"!=typeof Image&&((new Image).src=r)}function hitExt(e){var t=e.browserInfo,r=e.counterId,n=e.pageParams,o=e.userVars,i={"browser-info":getBrowserInfo(t,n.title),rn:getRandom(),ut:n.ut};n.url&&(i["page-url"]=prepareUrl(n.url)),n.referrer&&(i["page-ref"]=prepareUrl(n.referrer)),o&&(i["site-info"]=JSON.stringify(o)),sendData(r,i)}function hit(e,t,r){hitExt({counterId:e,pageParams:{referrer:t&&void 0!==t.referrer?t.referrer:getReferrer(),title:t&&void 0!==t.title?t.title:getTitle(),url:t&&void 0!==t.url?t.url:getPageUrl()},userVars:r})}function reachGoal(e,t,r){var n,o;t?(n=getPageUrl(),o="goal://"+getHost()+"/"+t):(n=getReferrer(),o=getPageUrl()),hitExt({counterId:e,pageParams:{referrer:n,url:o},userVars:r})}var COUNTER_ID="52122583";function metrikaHit(e,t){hit(COUNTER_ID,e,t)}function metrikaReachGoal(e,t){reachGoal(COUNTER_ID,e,t)}var OnlineEnsurer=function(){function e(){this.queue=new Queue(!0)}return e.prototype.init=function(){window.navigator.onLine&&this.queue.unlock(),window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline)},e.prototype.handleOnline=function(){this.queue.unlock()},e.prototype.handleOffline=function(){this.queue.lock()},e.prototype.run=function(e,t){this.queue.push(e,t)},e.prototype.destroy=function(){window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline),this.queue.cancel()},__decorate$9([lib$3.bind],e.prototype,"handleOnline",null),__decorate$9([lib$3.bind],e.prototype,"handleOffline",null),e}(),CONNECTION_TIMEOUT=15e3,WidgetEvent=function(){function e(e,t){this.data=e,this.defaultPrevented=!1,this.preventable=!1,this.preventable=Boolean(null==t?void 0:t.preventable)}return e.prototype.preventDefault=function(e){this.preventable&&(this.resolvedWith=e,this.defaultPrevented=!0)},e}();function channelFactory(e,t,r){var n;return new ChannelOutgoing(e,t,{scope:(n={},n[API_SCOPE]=r,n),connectTimeout:CONNECTION_TIMEOUT})}var WidgetTransport=function(){function e(e,t,r,n,o){this.widgetId=e,this.channelTransportFactory=t,this.initParams=r,this.events=n,this.handlers=o,this.onReloaded=new Event,this.onClose=new Event}return Object.defineProperty(e.prototype,"channel",{get:function(){return this.channelInstance||(this.channelInstance=channelFactory(this.widgetId,this.channelTransportFactory,this.initParams),this.channelInstance.onClose.addListener(this.handleClose),this.channelInstance.onConnectionEstablished.addListener(this.handleConnectionEstablished),this.channelInstance.onEvent.addListener(this.handleEvent),this.channelInstance.onRequest.addListener(this.handleRequest)),this.channelInstance},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){var e,t,r,n;null===(e=this.channelInstance)||void 0===e||e.onClose.removeListener(this.handleClose),null===(t=this.channelInstance)||void 0===t||t.onEvent.removeListener(this.handleEvent),null===(r=this.channelInstance)||void 0===r||r.onRequest.removeListener(this.handleRequest),null===(n=this.channelInstance)||void 0===n||n.dispose(),this.channelInstance=void 0},e.prototype.isConnectionClosed=function(){return!this.channelInstance||"closed"===this.channelInstance.connectionStatus},e.prototype.handleConnectionEstablished=function(e){e.reconnect&&this.onReloaded.dispatch()},e.prototype.handleClose=function(e){var t,r=e.closeCode===CLOSE_CODE.ERROR;r&&(null===(t=this.channelInstance)||void 0===t||t.disposeTransport()),this.onClose.dispatch({isCriticalError:r,error:e.closeError})},e.prototype.handleEvent=function(e){var t;null===(t=this.events[e.type])||void 0===t||t.dispatch(new WidgetEvent(e.data))},e.prototype.handleRequest=function(e){var t=this.handlers[e.type];t&&t.hasListeners()?t.dispatch(e):e.reject(new UnhandledResponseError("not_supported"))},__decorate$9([lib$3.bind],e.prototype,"handleConnectionEstablished",null),__decorate$9([lib$3.bind],e.prototype,"handleClose",null),__decorate$9([lib$3.bind],e.prototype,"handleEvent",null),__decorate$9([lib$3.bind],e.prototype,"handleRequest",null),e}();function createIframe(e){var t=document.createElement("iframe");return t.setAttribute("scrolling","no"),t.setAttribute("referrerpolicy","origin"),t.src=e.url,e.className&&(t.className=e.className),e.allow&&t.setAttribute("allow",e.allow.join("; ")),t}function generateClickId(){return rnd()}function beforeRequest(e){return function(t,r,n){var o=n.value;return{value:function(t){var r=new WidgetEvent({type:e,params:t},{preventable:!0});return this.dispatchLC("LCBeforeRequest",r),r.defaultPrevented?Promise.resolve().then((function(){return r.resolvedWith})):o.call(this,t)}}}}var WidgetAPI=function(){function e(e,t){this.getTransport=e,this.dispatchLC=t}return e.prototype.iframeOpen=function(e){return this.getTransport().channel.request("iframeOpen",e,{cancelPreviousRequestsWithSameType:!0})},e.prototype.serviceMeta=function(e){return this.getTransport().channel.request("serviceMeta",e)},e.prototype.pasteMessage=function(e){return this.getTransport().channel.request("pasteMessage",e)},e.prototype.setVisibility=function(e){return this.getTransport().channel.request("setVisibility",e,{cancelPreviousRequestsWithSameType:!0})},e.prototype.setThemeVariables=function(e){return this.getTransport().channel.request("setThemeVariables",e,{cancelPreviousRequestsWithSameType:!0})},e.prototype.chatMetadata=function(e){return this.getTransport().channel.request("chatMetadata",e)},e.prototype.actions=function(e){return this.getTransport().channel.request("actions",e)},e.prototype.requestCallback=function(e){return this.getTransport().channel.request("requestCallback",e)},e.prototype.sendTextMessage=function(e){return this.getTransport().channel.request("sendTextMessage",e)},e.prototype.sendImage=function(e){return this.getTransport().channel.request("sendImage",e)},e.prototype.sendBotRequest=function(e){return this.getTransport().channel.request("sendBotRequest",e)},e.prototype.isChatCreated=function(e){return this.getTransport().channel.request("isChatCreated",e)},__decorate$9([beforeRequest("iframeOpen")],e.prototype,"iframeOpen",null),__decorate$9([beforeRequest("serviceMeta")],e.prototype,"serviceMeta",null),__decorate$9([beforeRequest("pasteMessage")],e.prototype,"pasteMessage",null),__decorate$9([beforeRequest("setVisibility")],e.prototype,"setVisibility",null),__decorate$9([beforeRequest("setThemeVariables")],e.prototype,"setThemeVariables",null),__decorate$9([beforeRequest("chatMetadata")],e.prototype,"chatMetadata",null),__decorate$9([beforeRequest("actions")],e.prototype,"actions",null),__decorate$9([beforeRequest("requestCallback")],e.prototype,"requestCallback",null),__decorate$9([beforeRequest("sendTextMessage")],e.prototype,"sendTextMessage",null),__decorate$9([beforeRequest("sendImage")],e.prototype,"sendImage",null),__decorate$9([beforeRequest("sendBotRequest")],e.prototype,"sendBotRequest",null),__decorate$9([beforeRequest("isChatCreated")],e.prototype,"isChatCreated",null),e}();ChannelBase.CancelError=RequestCanceledError;var API=Symbol("API");function assertServiceId(e){if(!isNumber(e.serviceId))throw new Error("serviceId is required")}var Widget$1=function(){function e(e,r){var n=this;this.config=e,this.version="1.24.0",this.widgetId="msngr_widget_"+rnd(),this.plugins=[],this.forceSendOpenIframe=!0,this.onlineEnsurer=new OnlineEnsurer,this[t]=new WidgetAPI((function(){return n.transport}),(function(e,t){return n.dispatchLC(e,t)})),this.events=r.events(),this.handlers=new r.handlers,this.api=new r.api(this[API]),lib$1.updateSettings({service:""+this.options.serviceId,additional:__assign$2(__assign$2({},lib$1.getSettings().additional),{workspaceId:""+this.options.workspaceId,orgId:""+this.options.orgId})}),metrikaHit(void 0,{serviceId:""+this.options.serviceId,workspaceId:""+this.options.workspaceId,orgId:""+this.options.orgId,version:this.version,stat:"object"==typeof this.options.stat?this.options.stat:void 0,visitId:this.widgetId}),this.lastShowData=this.options.iframeOpenData,this.events.ready.addListener((function(){n.dispatchLC("LCReady",new WidgetEvent)})),this.events.close.addListener((function(){n.dispatchLC("LCHidden",new WidgetEvent)})),this.proxy={events:this.events,options:this.options,reload:function(){return n.transport.channel.connect()},show:function(e,t){return n.show(e,t)},hide:function(){return n.hide()}}}var t;return e.prototype.init=function(){var e=this,t=this.options;return assertServiceId(t),this.plugins.forEach((function(r){r.init(t,e.proxy)})),this.onlineEnsurer.init(),this},e.prototype.show=function(e,t){void 0===t&&(t=noop);var r=new WidgetEvent(e,{preventable:!0});if(this.dispatchLC("LCBeforeShow",r),r.defaultPrevented)t();else{var n=generateClickId();if(e||this.forceSendOpenIframe){this.forceSendOpenIframe=!1;var o=e||this.lastShowData;this.lastShowData=o,this[API].iframeOpen(__assign$2(__assign$2({},o),{visitId:this.widgetId,eventTimestamp:Date.now(),clickId:n,visible:!0})).then(t,t)}else this[API].setVisibility({visible:!0}).catch(noop),t();metrikaReachGoal("widget-opened",{clickId:n}),this.dispatchLC("LCShown",new WidgetEvent)}},e.prototype.hide=function(){var e=new WidgetEvent(void 0,{preventable:!0});(this.dispatchLC("LCBeforeHide",e),e.defaultPrevented)||(this.transport.isConnectionClosed()||this[API].setVisibility({visible:!1}).catch(noop),metrikaReachGoal("widget-closed",{clickId:generateClickId()}),this.dispatchLC("LCHidden",new WidgetEvent))},e.prototype.setUI=function(e){return this.uiPlugin=e,this.addPlugin(e)},e.prototype.addPlugin=function(e){return this.plugins.push(e),this},e.prototype.destroy=function(){var e,t;null===(e=this.transportInstance)||void 0===e||e.onClose.removeListener(this.handleErrorConnect),null===(t=this.transportInstance)||void 0===t||t.destroy(),this.transportInstance=void 0,this.onlineEnsurer.destroy(),this.dispatchLC("LCClose",new WidgetEvent)},Object.defineProperty(e.prototype,"options",{get:function(){return this.config.values},enumerable:!1,configurable:!0}),e.prototype.dispatchLC=function(e,t){for(var r=0,n=this.plugins;r<n.length;r++){var o=n[r];"function"==typeof o[e]&&o[e](t)}return t},e.prototype.getIframeUrl=function(e){return this.config.getMessengerUrl(this.widgetId,API_VERSION,__assign$2({utm_source:"widget",utm_medium:"iframe"},e))},e.prototype.handleErrorConnect=function(e){this.forceSendOpenIframe=!0,e.isCriticalError&&this.dispatchLC("LCErrorCritical",new WidgetEvent({error:e.error||new Error("Connection Terminated")}))},Object.defineProperty(e.prototype,"transport",{get:function(){var e=this;return this.transportInstance||(this.transportInstance=new WidgetTransport(this.widgetId,(function(t){e.onlineEnsurer.run(new QueueTask((function(){if(!e.uiPlugin)throw new Error("UI plugin was not initialized");e.uiPlugin.getChildWindowTransport({urlProvider:function(){return e.getIframeUrl()},allow:e.options.allow},t)}),{tag:"childWindowProvider"}),{tag:"childWindowProvider"})}),{authToken:this.options.authToken,themeVariables:this.options.themeVariables,authPartition:this.options.authPartition},this.events,this.handlers),this.transportInstance.onClose.addListener(this.handleErrorConnect)),this.transportInstance},enumerable:!1,configurable:!0}),t=API,__decorate$9([lib$3.bind],e.prototype,"handleErrorConnect",null),e}(),Widget=function(e){function t(t){return e.call(this,t,{events:eventsFactory,handlers:WidgetHandlers,api:PublicWidgetAPI})||this}return __extends$i(t,e),t=__decorate$9([loggable],t)}(Widget$1),externalPresets={type:type,external:external},createMultiChatsWidget=function(e){return new Widget(new Config(externalPresets.external,externalPresets.type.multiChats(),e))},createMultiChatsBlockUIWidget=function(e){return new Widget(new Config(externalPresets.external,externalPresets.type.multiChats({inline:!0}),e))},createSingleChatWidget=function(e){return new Widget(new Config(externalPresets.external,externalPresets.type.singleChat(),e))},createSingleChatBlockUIWidget=function(e){return new Widget(new Config(externalPresets.external,externalPresets.type.singleChat({inline:!0}),e))};function getMods(e){return Object.keys(e).filter((function(t){var r=e[t];return r||0===r})).map((function(t){var r=t.trim(),n=e[t];return!0===n?"_"+r:"_"+r+"_"+n}))}function block(e){return function(t,r){var n=block.prefix+e;"string"==typeof t&&(n+="__"+t);var o=[n],i={};return"object"==typeof t?i=t:"object"==typeof r&&(i=r),getMods(i).forEach((function(e){o.push(n+e)})),o.join(" ")}}function classname(e,t,r){return block(e)(t,r).split(" ").pop()||""}block.prefix="ya-chat-";var close$9="Закрыть",ru={close:close$9,"error-title":"Не удалось загрузить чат","error-try-again":"Попробовать ещё раз","button-text-default":"Напишите нам!","cookie-blocked-text":"К сожалению доступов к cookie нет.","new-window-button":"Подтвердите переход на новую страницу","support-unread-text":"Все обращения","support-unread-text-count":["Еще {value} обращение","Еще {value} обращения","Еще {value} обращений"]},close$8="Close",en={close:close$8,"error-title":"Failed to load chat","error-try-again":"Try again","button-text-default":"Write to us!","cookie-blocked-text":"Unfortunately, there is no access to cookies.","new-window-button":"Confirm the transition to a new page","support-unread-text":"All requests","support-unread-text-count":["{value} more request","{value} more requests","{value} more requests"]},close$7="Fermer",fr={close:close$7,"error-title":"Impossible de charger le chat","error-try-again":"Réessayer","button-text-default":"Write to us!","cookie-blocked-text":"Unfortunately, there is no access to cookies.","new-window-button":"Confirm the transition to a new page","support-unread-text":"All requests","support-unread-count":["{value} more request","{value} more requests","{value} more requests"]},close$6="Փակել",hy={close:close$6,"error-title":"Չհաջողվեց բեռնել չաթը","error-try-again":"Կրկին փորձել","button-text-default":"Write to us!","cookie-blocked-text":"Unfortunately, there is no access to cookies.","new-window-button":"Confirm the transition to a new page","support-unread-text":"All requests","support-unread-text-count":["{value} more request","{value} more requests","{value} more requests"]},close$5="Жабу",kk={close:close$5,"error-title":"Чатты жүктеу мүмкін емес","error-try-again":"Тағы бір рет көріңіз","button-text-default":"Напишите нам!","cookie-blocked-text":"К сожалению доступов к cookie нет.","new-window-button":"Подтвердите переход на новую страницу","support-unread-text":"Все обращения","support-unread-text-count":["Еще {value} обращение","Еще {value} обращения","Еще {value} обращений"]},close$4="Zatvori",sr={close:close$4,"error-title":"Učitavanje ćaskanja nije uspelo","error-try-again":"Pokušajte još jednom","button-text-default":"Write to us!","cookie-blocked-text":"Unfortunately, there is no access to cookies.","new-window-button":"Confirm the transition to a new page","support-unread-text":"All requests","support-unread-text-count":["{value} more request","{value} more requests","{value} more requests"]},close$3="Kapat",tr={close:close$3,"error-title":"Sohbet yüklenemedi","error-try-again":"Tekrar dene","button-text-default":"Write to us!","cookie-blocked-text":"Unfortunately, there is no access to cookies.","new-window-button":"Confirm the transition to a new page","support-unread-text":"All requests","support-unread-text-count":["{value} more request","{value} more requests","{value} more requests"]},close$2="Yopish",uz={close:close$2,"error-title":"Chatni yuklash imkoni boʻlmadi","error-try-again":"Qayta urinish","button-text-default":"Write to us!","cookie-blocked-text":"Unfortunately, there is no access to cookies.","new-window-button":"Confirm the transition to a new page","support-unread-text":"All requests","support-unread-text-count":["{value} more request","{value} more requests","{value} more requests"]},close$1="סגור",he={close:close$1,"error-title":"טעינת צ'אט נכשלה","error-try-again":"נסה שנית","button-text-default":"Write to us!","cookie-blocked-text":"Unfortunately, there is no access to cookies.","new-window-button":"Confirm the transition to a new page","support-unread-text":"All requests","support-unread-text-count":["{value} more request","{value} more requests","{value} more requests"]},texts={ru:ru,en:en,fr:fr,hy:hy,kk:kk,sr:sr,tr:tr,uz:uz,he:he},PLURAL_HANDLERS={ru:function(e,t){var r=Math.abs(t)%100;return r>=5&&r<=20?e[2]:1===(r%=10)?e[0]:r>=2&&r<=4?e[1]:e[2]},en:function(e,t){return 1===t?e[0]:e[1]}};function plural(e,t,r){var n=PLURAL_HANDLERS[t];if(n){var o=r;return"string"==typeof r&&(o=Number.parseInt(r),Number.isNaN(o))?e[0]:n(e,o).replace("{value}",r)}return e[0]}function i18n(e,t,r){var n=(texts[t]||{})[e]||"";return Array.isArray(n)?plural(n,t,r):n}var b$b=block("error");function errorTemplate(e){var t=e.useRef(),r=e.useRef();r.on("click",e.props.onRetryErrorClick);var n=e.props.lang;return"\n        <div\n            "+t.id+'\n            class="'+t.useClassName((function(e){var t=e.visible;return b$b({visible:t})}),["visible"])+'"\n        >\n            <div class="'+b$b("title")+'">'+i18n("error-title",n)+"</div>\n            <div "+r.id+' class="'+b$b("button")+'">'+i18n("error-try-again",n)+"</div>\n        </div>\n    "}var b$a=block("loader");function loaderTemplate(e){var t=e.useRef();return"\n        <div\n            "+t.id+'\n            class="'+t.useClassName((function(e){var t=e.visible;return b$a({visible:t})}),["visible"])+'">\n            <div class="'+b$a("spinner")+'"></div>\n        </div>\n    '}function render(e,t,r){var n=document.createDocumentFragment(),o=document.createElement("div");o.innerHTML=e(t);var i=o.firstElementChild;if(!i)throw new Error("Bad template");var a=document.createComment("noindex"),s=document.createComment("/noindex");n.appendChild(a),n.appendChild(i),n.appendChild(s),r.appendChild(n),t.mount([a,i,s])}function partialShallowEqual(e,t){if(e===t)return!0;if("object"==typeof e&&"object"==typeof t){for(var r in e)if(e[r]!==t[r])return!1;return!0}return!1}function camelCaseToStyle(e){return e.replace(/([a-z])([A-Z])/g,(function(e,t,r){return t+"-"+r.toLowerCase()}))}var DATA_REGEXP=/^data-/,FIRST_LETTER_REGEXP=/-(.)/g;function getDataset(e){if(e.dataset)return e.dataset;for(var t=e.attributes,r={},n=0;n<t.length;n++){var o=t[n];if(o&&o.name.match(DATA_REGEXP))r[o.name.slice(5).replace(FIRST_LETTER_REGEXP,(function(e,t){return t.toUpperCase()}))]=o.value}return r}var Ref=function(){function e(e){this.context=e,this.refId="widget_ref"+rnd(),this.detached=!1,this.listeners={},this.childrens=new Map,this.effects=[],this.subscriptions=[]}return Object.defineProperty(e.prototype,"id",{get:function(){return'id="'+this.refId+'"'},enumerable:!1,configurable:!0}),e.prototype.useClassName=function(e,t,r){var n=this;return this.subscribe((function(t,r){n.node?n.node.className=e(t,r):n.className=e(t,r)}),t,r),e(this.context.props,null==r?void 0:r.value)},e.prototype.useStyle=function(e,t,r){var n=this;this.subscribe((function(t,r){if(n.node){var o=e(t,r);Object.keys(o).forEach((function(e){isDefined(o[e])?n.node.style.setProperty(e,o[e],"important"):n.node.style[e]=""}))}else n.style=e(t,r)}),t,r);var o=e(this.context.props,null==r?void 0:r.value);return Object.keys(o).map((function(e){if(isDefined(o[e]))return camelCaseToStyle(e)+": "+o[e]})).filter(isDefined).join(";")},e.prototype.useText=function(e,t,r){var n=this;return this.subscribe((function(t,r){n.node?n.node.innerText=e(t,r):n.innerText=e(t,r)}),t,r),e(this.context.props,null==r?void 0:r.value)},e.prototype.useChildren=function(e,t,r){var n=this,o=rnd();return this.childrens.set(o,{provider:e,node:void 0}),this.subscribe((function(t,r){var i=n.childrens.get(o);i.node&&safeRemoveNode(i.node);var a=e(t,r);a&&(i.node=a,n.node.appendChild(a))}),t,r),""},e.prototype.useEffect=function(e,t,r){var n={id:rnd(),provider:e,result:void 0};this.effects.push(n),this.subscribe((function(t,r){n.result&&n.result(),n.result=e(t,r)}),t,r)},e.prototype.on=function(e,t){this.node&&this.listeners[e]&&this.node.removeEventListener(e,this.listeners[e]),this.listeners[e]=t,this.node&&this.node.addEventListener(e,t)},e.prototype.mount=function(){var e=document.getElementById(this.refId);if(!e)throw new Error("Attribute data-ref should be non empty string");"body"===getDataset(e).attachTo&&(this.detached=!0,document.body.appendChild(e)),this.setNode(e)},e.prototype.setNode=function(e){var t=this;this.node=e,this.className&&(this.node.className=this.className),this.innerText&&(this.node.innerText=this.innerText),this.style&&Object.keys(this.style).forEach((function(e){t.node.style.setProperty(e,t.style[e],"important")})),this.childrens.forEach((function(e){var r=e.provider(t.context.props);r&&t.node.appendChild(r)})),Object.keys(this.listeners).forEach((function(r){e.addEventListener(r,t.listeners[r])})),this.effects.forEach((function(e){e.result=e.provider(t.context.props,void 0)}))},e.prototype.subscribe=function(e,t,r){var n=this,o=function(n){var o=n.prevValue,i=n.value;t.some((function(e){return o[e]!==i[e]}))&&e(i,null==r?void 0:r.value)};if(this.context.onPropsChanged.addListener(o),this.subscriptions.push((function(){n.context.onPropsChanged.removeListener(o)})),r){var i=function(t){e(n.context.props,t.value)};null==r||r.onChange.addListener(i),this.subscriptions.push((function(){r.onChange.removeListener(i)}))}},e.prototype.getNode=function(){return this.node},e.prototype.remove=function(){var e=this;this.subscriptions.forEach((function(e){return e()})),this.subscriptions=void 0,this.effects.forEach((function(e){var t;null===(t=e.result)||void 0===t||t.call(e)})),this.node&&(Object.keys(this.listeners).forEach((function(t){e.node.removeEventListener(t,e.listeners[t])})),this.detached&&safeRemoveNode(this.node)),this.listeners=void 0,this.node=void 0,this.effects=void 0},e}(),StateGetter=function(){function e(e,t){this.getter=e,this.onChange=t}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getter()},enumerable:!1,configurable:!0}),e}(),State=function(){function e(e,t){this.id=e,this.value=t,this.onChange=new Event}return e.prototype.setState=function(e){var t=this.value;partialShallowEqual(e,this.value)||(this.value=__assign$2(__assign$2({},t),e),this.onChange.dispatch({value:this.value,prevValue:t}))},e.prototype.getValueProvider=function(){var e=this;return[new StateGetter((function(){return e.value}),this.onChange),function(t){e.setState(t(e.value))}]},e.prototype.destroy=function(){this.value=void 0,this.onChange.removeAllListener()},e}(),Context=function(){function e(e){this.refs=new Map,this.states=new Set,this.children=[],this._props=new State(rnd(),e)}return Object.defineProperty(e.prototype,"props",{get:function(){return this._props.value},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onPropsChanged",{get:function(){return this._props.onChange},enumerable:!1,configurable:!0}),e.prototype.getRef=function(e){return this.refs[e]},e.prototype.pipe=function(t){var r=new e(t(this.props));return this.onPropsChanged.addListener((function(e){var n=e.value;r.setProps(t(n))})),this.children.push(r),r},e.prototype.useState=function(e){var t=new State(rnd(),e);return this.states.add(t),t.getValueProvider()},e.prototype.setProps=function(e){this._props.setState(e)},e.prototype.useRef=function(){var e=new Ref(this);return this.refs.set(e.refId,e),e},e.prototype.mount=function(e){this.fragments=e,this.refs.forEach((function(e){e.mount()})),this.children.forEach((function(e){e.mount()}))},e.prototype.destroy=function(){if(this.refs.forEach((function(e){e.remove()})),this.refs.clear(),this.onPropsChanged.removeAllListener(),this.children.forEach((function(e){e.destroy()})),this.children=[],this.states.forEach((function(e){e.destroy()})),this.states.clear(),this._props=void 0,this.fragments)for(var e=0;e<this.fragments.length;e++)safeRemoveNode(this.fragments[e])},e}(),b$9=block("base");function baseTemplate(e,t){var r=e.useRef(),n=loaderTemplate(e.pipe((function(e){return{visible:"loader"===e.page}}))),o=errorTemplate(e.pipe((function(e){return{visible:"error"===e.page,lang:e.lang,onRetryErrorClick:e.onRetry}})));return'\n        <div class="'+b$9()+'">\n            '+(isDefined(t)?t:"")+"\n            <div\n                "+r.id+'\n                class="'+r.useClassName((function(e){return b$9("mount",{visible:"messenger"===e.page,fullscreen:e.fullscreen})}),["page","fullscreen"])+'"\n            >\n                '+r.useChildren((function(e){if(e.iframe)return e.iframe.className=b$9("iframe"),e.iframe}),["iframe"])+"\n            </div>\n            "+n+"\n            "+o+"\n        </div>\n    "}var BaseUI=function(){function e(e){this.template=e,this.ready=!1,this.destroyed=!1,this.initialized=!1}return e.prototype.render=function(e){if(!this.initialized)throw new Error("Widget should be initialized before mounting");render(this.template,this.context,e)},e.prototype.init=function(e,t){var r;this.widgetProxy=t,t.events.fullscreenOn.addListener(this.handleFullscreenOn),t.events.fullscreenOff.addListener(this.handleFullscreenOff),this._context=new Context(__assign$2({lang:this.options.lang||"ru",onRetry:this.handleErrorRetryClick},null===(r=this.contextProvider)||void 0===r?void 0:r.call(this,t))),this.initialized=!0},Object.defineProperty(e.prototype,"context",{get:function(){var e=this._context;return assertDefined(e,"Widget should be initalized before using context"),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){var e=this.widgetProxy;return assertDefined(e,"Widget should be initialzed before using options"),e.options},enumerable:!1,configurable:!0}),e.prototype.LCClose=function(){this.destroy()},e.prototype.iframeOpen=function(e){this.ready?this.showMount(e):this.showLoader(e)},e.prototype.toggleFullscreen=function(e){this.context.setProps({fullscreen:e})},e.prototype.showMount=function(e){this.ready=!0,this.context.setProps(__assign$2({page:"messenger"},e))},e.prototype.showError=function(e){this.context.setProps(__assign$2({page:"error"},e))},e.prototype.showLoader=function(e){this.context.setProps(__assign$2({page:"loader"},e))},e.prototype.destroy=function(){this.widgetProxy.events.fullscreenOn.removeListener(this.handleFullscreenOn),this.widgetProxy.events.fullscreenOff.removeListener(this.handleFullscreenOff),this.context.destroy(),this.ready=!1,this.destroyed=!0},e.prototype.handleFullscreenOn=function(){this.toggleFullscreen(!0)},e.prototype.handleFullscreenOff=function(){this.toggleFullscreen(!1)},e.prototype.handleErrorRetryClick=function(){this.iframeOpen(),this.widgetProxy.reload()},__decorate$9([lib$3.bind],e.prototype,"handleFullscreenOn",null),__decorate$9([lib$3.bind],e.prototype,"handleFullscreenOff",null),__decorate$9([lib$3.bind],e.prototype,"handleErrorRetryClick",null),e}(),b$8=block("block");function template$1(e){return'\n        <div class="'+b$8()+'">\n            '+baseTemplate(e)+"\n        </div>\n    "}function iframeChildWindowProvider(e,t,r){var n=e.urlProvider,o=e.allow,i=n({utm_medium:"iframe"}),a=t(i,o),s=new URL(i).origin;r(new IframePostMessageTransport(a,s))}function windowChildWindowProvider(e,t,r){var n=(0,e.urlProvider)({utm_medium:"new_tab"});try{var o=t(n),i=new URL(n).origin;r(new ChildWindowPostMessageTransport(o,window,i,[i]))}catch(e){r(void 0,e)}}function normalizeBadgeString(e,t){return String(t<e?t+"+":e)||""}var normalizeFeatureInfo=function(e){if("string"!=typeof e)return e;try{return JSON.parse(e)}catch(t){logError(t,{message:"Can not get yandex application availability feature",additional:{featureInfo:e}})}},getWindowWithFeature=function(){var e;return(null===(e=window.top)||void 0===e?void 0:e.YandexApplicationsFeatureAvailability)?window.top:window},getFeatureInfo=memo((function(e){var t=getWindowWithFeature(),r=normalizeFeatureInfo(t.YandexApplicationsFeatureAvailability&&t.YandexApplicationsFeatureAvailability.getFeatureInfo(e));return{isAvailable:Boolean(r&&r.isAvailable),params:r&&r.params}})),getNativeMessengerScheme=function(){return getFeatureInfo("messenger")},isNativeAvailable=function(){return getNativeMessengerScheme().isAvailable};getFeatureInfo.clear;var Block=function(e){function t(){return e.call(this,template$1)||this}return __extends$i(t,e),t.prototype.mount=function(e){this.render(e)},t.prototype.getChildWindowTransport=function(e,t){var r=this;iframeChildWindowProvider(e,(function(e,t){var n=createIframe({url:e,allow:t});return r.context.setProps({iframe:n}),n.contentWindow}),t)},t.prototype.LCShown=function(){this.iframeOpen()},t.prototype.LCReady=function(){this.showMount()},t.prototype.LCErrorCritical=function(){this.showError()},t}(BaseUI);function blockUIFactory(){return new Block}var hasTouchEvent=!1;try{document.createEvent("TouchEvent"),hasTouchEvent=!0}catch(e){}var MAX_TOUCH_SCREEN_SIZE=900,isSmallScreen=function(){return Math.max(window.screen.width,window.screen.height)<MAX_TOUCH_SCREEN_SIZE};function testIOS(e){return/iPad|iPhone|iPod/.test(e)}function testIsMobile(e){return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)}var isMobile=function(){return hasTouchEvent&&(isSmallScreen()||testIsMobile(window.navigator.userAgent))},isIOS=function(){return testIOS(window.navigator.userAgent)},NewWindowBlockedError=function(e){function t(r){var n=e.call(this,r)||this;return Object.setPrototypeOf(n,t.prototype),n}return __extends$i(t,e),t}(lib$2.BaseError),IframeStrategy=function(){function e(e){this.adapter=e}return e.prototype.show=function(){this.adapter.show()},e.prototype.hide=function(){this.adapter.hide()},e.prototype.remove=function(){this.adapter.remove()},e.prototype.ready=function(){},e.prototype.getChildWindowTransport=function(e,t){var r=this;iframeChildWindowProvider(e,(function(e,t){return r.remove(),r.adapter.create(e,t).contentWindow}),t)},e}(),WindowStrategy=function(){function e(e){this.adapter=e}return e.prototype.show=function(){var e;null===(e=this.childWindow)||void 0===e||e.focus()},e.prototype.ready=function(){var e;null===(e=this.adapter)||void 0===e||e.ready()},e.prototype.hide=function(){},e.prototype.remove=function(){var e;window.removeEventListener("unload",this.handleUnload),null===(e=this.childWindow)||void 0===e||e.close()},e.prototype.getChildWindowTransport=function(e,t){var r=this;windowChildWindowProvider(e,(function(e){if(r.remove(),r.childWindow=window.open(e),!r.childWindow)throw new NewWindowBlockedError("ChildWindow creation was failed");return window.addEventListener("unload",r.handleUnload),r.childWindow}),t)},e.prototype.handleUnload=function(){"visible"===window.document.visibilityState&&this.remove()},__decorate$9([lib$3.bind],e.prototype,"handleUnload",null),e}(),defaultBehaviorStrategies=[{name:"iframe",behavior:IframeStrategy},{name:"detached",behavior:WindowStrategy}],PageScrollController=function(){function e(){this.blockName="disable-page-scroll",this.POPUP_ANIMATION_TIMEOUT=300,this.marginLeft="",this.marginTop="",this.scrollX=0,this.scrollY=0,this.disabled=!1}return e.prototype.clearPageScrollTimeout=function(){window.clearTimeout(this.scrollTimeout)},e.prototype.handleChangeProps=function(e){e.visible&&e.isMobile?this.disable():this.enable()},e.prototype.disable=function(){var e=this;this.disabled||(this.clearPageScrollTimeout(),this.scrollTimeout=window.setTimeout((function(){try{var t=document.body;isIOS&&(e.scrollX=window.scrollX,e.scrollY=window.scrollY,e.marginLeft=t.style.marginLeft,e.marginTop=t.style.marginTop,t.style.marginLeft="-"+e.scrollX+"px",t.style.marginTop="-"+e.scrollY+"px",t.classList.add(classname(e.blockName,{ios:!0}))),t.classList.add(classname(e.blockName)),e.disabled=!0}catch(e){logError(e)}}),this.POPUP_ANIMATION_TIMEOUT))},e.prototype.enable=function(){try{if(this.clearPageScrollTimeout(),!this.disabled)return;var e=document.body;e.classList.remove(classname(this.blockName)),isIOS&&(e.classList.remove(classname(this.blockName,{ios:!0})),e.style.marginLeft=this.marginLeft,e.style.marginTop=this.marginTop,window.scrollTo(this.scrollX,this.scrollY)),this.disabled=!1}catch(e){logError(e)}},e}(),OFFSET=10,MIN_HEIGHT=250;function getViewportBounds(){var e=window.innerWidth,t=window.innerHeight;return{left:0+OFFSET,top:0+OFFSET,right:0+e-OFFSET,bottom:0+t-OFFSET,width:e,height:t}}function getPopupHeight(e,t,r,n,o){var i=n.offsetParent&&n.offsetParent.offsetTop||0,a="top"===o?r.top-OFFSET:e-(window.pageYOffset-i+r.bottom+2*OFFSET);return Math.max(MIN_HEIGHT,Math.min(a,t))}function parsePosition(e){return isDefined(e)?e.split("-"):["bottom","left"]}function calculatePosition(e,t,r,n){var o=t.getBoundingClientRect(),i=o.left,a=o.right,s=o.top,l=o.bottom,u=parsePosition(r),c="top"===u[0]?s:l,d="right"===u[1]?a:i,p=getViewportBounds(),h=e.offsetWidth,f=(null==n?void 0:n.naturalHeight)||e.offsetHeight,v=getPopupHeight(p.height,f,o,t,u[0]),g=p.left+(p.right-p.left)/2,b=p.top+(p.bottom-p.top)/2;return i+h>p.right&&(d=a>g?Math.max(a-h,OFFSET):Math.min(i,p.right-h)),l+v>p.bottom&&s>b&&(c=s-v),{left:Math.floor(d),top:Math.floor(c),height:v,naturalHeight:f}}var b$7=block("popup"),RESET_POSITION={left:void 0,top:void 0};function getPositionClass(e){return e.inner?"inner":e.target?"target":"fixed"}function popupTemplate(e,t,r){var n=e.useState(RESET_POSITION),o=n[0],i=n[1],a=e.useRef(),s=e.useRef(),l=e.useRef();return a.on("click",e.props.onParanjaClick),s.useEffect((function(e){function t(t){var r=t.target;r&&!s.getNode().contains(r)&&e.onParanjaClick()}return e.autocloseable&&e.visible&&document.addEventListener("click",t,!0),function(){document.removeEventListener("click",t,!0)}}),["visible","autocloseable","onParanjaClick"]),s.useEffect((function(e){function t(){i((function(t){return!e.visible||!e.target||e.isMobile||e.inner?RESET_POSITION:e.calculatePosition(l.getNode(),e.target,e.position,t)}))}return window.addEventListener("resize",t),window.addEventListener("scroll",t),window.addEventListener("orientationchange",t),t(),function(){window.removeEventListener("resize",t),window.removeEventListener("scroll",t),window.removeEventListener("orientationchange",t)}}),["target","position","visible","isMobile","inner","calculatePosition"]),s.useEffect((function(e){return function(){return e.pageScrollController.enable()}}),["pageScrollController"]),s.useEffect((function(e){e.pageScrollController.handleChangeProps(e)}),["visible","isMobile"]),'\n        <div\n            class="'+b$7("container")+'"\n        >\n            <div\n                '+a.id+'\n                class="'+a.useClassName((function(e){return b$7("paranja",{visible:e.visible&&(e.isMobile||e.paranjaVisible)})}),["visible","isMobile","paranjaVisible"])+'"\n            >\n            </div>\n            <div\n                '+s.id+'\n                style="'+s.useStyle((function(e,t){var r=t.left,n=t.top;return{left:isDefined(r)?r+"px":void 0,top:isDefined(n)?n+"px":void 0}}),[],o)+'"\n                class="'+s.useClassName((function(e){return b$7({button:e.buttonMode,position:getPositionClass(e),desktop:!e.isMobile,mobile:e.isMobile,visible:e.visible,fullscreen:e.fullscreen})}),["buttonMode","target","isMobile","visible","fullscreen","inner"])+'"\n            >\n                <div\n                    '+l.id+'\n                    class="'+b$7("content-wrapper")+'"\n                    style="'+l.useStyle((function(e,t){var r=t.height;return{height:isDefined(r)?r+"px":void 0}}),[],o)+'"\n                >\n                    '+(isDefined(r)?r:"")+"\n                    "+t+"\n                </div>\n            </div>\n        </div>\n    "}var PopupBase=function(e){function t(t,r,n){var o=e.call(this,t)||this;return o.props=n,o.hidden=!0,o.onToggled=new Event,o.contextProvider=function(e){return __assign$2({popupTarget:n.popupTargetNode,popupPosition:n.popupTargetPosition,popupAutocloseable:n.autocloseable,isMobile:isDefined(n.isMobile)?n.isMobile:isMobile(),paranjaVisible:n.paranjaVisible,calculatePosition:n.calculatePosition,onClose:function(){return e.hide()},onNewTab:o.handleNewWindowClick,pageScrollController:o.props.pageScrollController||new PageScrollController},r(e,n))},o.strategies=o.props.strategies||defaultBehaviorStrategies,o.currentStrategyName=o.strategies[0].name,o.setBehavior(o.getStrategyByName(o.currentStrategyName)),o}return __extends$i(t,e),t.prototype.getChildWindowTransport=function(e,t){this.behavior.getChildWindowTransport(e,t)},t.prototype.LCReady=function(){this.showMount(),this.behavior.ready()},t.prototype.LCErrorCritical=function(e){var t=e.data.error;if(NewWindowBlockedError.is(t))this.showNewWindowRequest();else{if(CookieNeededError.is(t)&&"iframe"===this.currentStrategyName&&this.getStrategyByName("detached"))try{return this.setBehavior(this.getStrategyByName("detached")),void this.widgetProxy.reload()}catch(e){}this.showError()}},t.prototype.LCHidden=function(){this.behavior.hide()},t.prototype.LCShown=function(){this.behavior.show()},t.prototype.hidePopup=function(){this.hidden||(this.hidden=!0,this.context.setProps({popupVisible:!1}),this.onToggled.dispatch({hidden:!0}))},t.prototype.showPopup=function(){this.hidden&&(this.hidden=!1,this.iframeOpen({popupVisible:!0}),this.onToggled.dispatch({hidden:!1}))},t.prototype.showNewWindowRequest=function(){this.context.setProps({page:"new-window-blocked"})},t.prototype.getStrategyByName=function(e){return this.strategies.filter((function(t){return t.name===e}))[0]},t.prototype.setBehavior=function(e){var t,r=this;this.behavior&&this.currentStrategyName===e.name||(null===(t=this.behavior)||void 0===t||t.remove(),this.currentStrategyName=e.name,"iframe"===e.name?this.behavior=new e.behavior({show:function(){r.showPopup()},hide:function(){r.hidePopup()},remove:function(){r.context.setProps({iframe:void 0})},create:function(e,t){var n=createIframe({url:e,allow:t});return r.context.setProps({iframe:n}),n}}):"detached"===e.name&&(this.behavior=new e.behavior({ready:function(){r.hidePopup()}})))},t.prototype.handleNewWindowClick=function(){this.setBehavior(this.getStrategyByName("detached"));try{this.widgetProxy.reload(),this.hidePopup()}catch(e){}},__decorate$9([lib$3.bind],t.prototype,"handleNewWindowClick",null),t}(BaseUI),Popup=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends$i(t,e),t.prototype.mount=function(){this.render(document.body)},t.prototype.setPopupTarget=function(e,t){this.context.setProps({popupTarget:e,popupPosition:t||this.context.props.popupPosition})},t}(PopupBase),b$6=block("close");function close(e){var t=e.useRef(),r=e.useRef();return r.on("click",e.props.onCloseClick),"\n        <div\n            "+t.id+'\n            class="'+t.useClassName((function(e){var t=e.visible;return b$6({visible:t})}),["visible"])+'"\n        >\n            <div '+r.id+' class="'+b$6("button-box")+'">\n                <div class="'+b$6("button")+'"></div>\n            </div>\n        </div>\n    '}var b$5=block("new-window");function newWindowBlockedError(e){var t=e.props.lang,r=e.useRef(),n=e.useRef();return n.on("click",e.props.onOpenNewTabClick),"\n        <div\n            "+r.id+'\n            class="'+r.useClassName((function(e){var t=e.visible;return b$5({visible:t})}),["visible"])+'"\n        >\n            <div class="'+b$5("title")+'">\n                '+i18n("cookie-blocked-text",t)+"\n            </div>\n            <div "+n.id+' class="'+b$5("button")+'">\n                '+i18n("new-window-button",t)+"\n            </div>\n        </div>\n    "}var b$4=block("popup-ui");function basePopupTemplate(e,t){if(!e.props.lang)throw new Error("");var r=close(e.pipe((function(e){return{visible:"messenger"!==e.page,onCloseClick:e.onClose}}))),n=newWindowBlockedError(e.pipe((function(e){return{visible:"new-window-blocked"===e.page,onOpenNewTabClick:e.onNewTab,lang:e.lang}}))),o=baseTemplate(e.pipe((function(e){return{lang:e.lang,onRetry:e.onRetry,fullscreen:e.fullscreen,iframe:e.iframe,page:e.page}})),r);return popupTemplate(e.pipe((function(e){return{isMobile:e.isMobile,onParanjaClick:e.onClose,buttonMode:e.buttonMode,position:e.popupPosition,autocloseable:e.popupAutocloseable,target:e.popupTarget,visible:e.popupVisible,fullscreen:e.fullscreen,inner:e.inner,paranjaVisible:e.paranjaVisible,calculatePosition:e.calculatePosition||calculatePosition,pageScrollController:e.pageScrollController}})),"\n            "+o+"\n            "+n+"\n        ",t)}function template(e,t){return'\n        <div data-ref="popup-ui" class="'+b$4()+'">\n            '+basePopupTemplate(e,t)+"\n        </div>\n    "}function popupUIFactory(e){return new Popup(template,(function(){return{}}),e)}var b$3=block("icon");function icon(){return'<svg class="'+b$3()+'" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">\n        <g clip-path="url(#clip-mssngr-widget-icon)">\n        <g filter="url(#filter0-mssngr-widget)">\n            <path fill-rule="evenodd" clip-rule="evenodd" d="M14 0C2.8 0 0 2.8 0 14C0 25.2 2.8 28 14 28C25.2 28 28 25.2 28 14C28 2.8 25.2 0 14 0Z" fill="#00D7D7"/>\n            <path fill-rule="evenodd" clip-rule="evenodd" d="M14 0C2.8 0 0 2.8 0 14C0 25.2 2.8 28 14 28C25.2 28 28 25.2 28 14C28 2.8 25.2 0 14 0Z" fill="url(#paint0_linear-mssngr-widget)"/>\n            <path fill-rule="evenodd" clip-rule="evenodd" d="M14 0C2.8 0 0 2.8 0 14C0 25.2 2.8 28 14 28C25.2 28 28 25.2 28 14C28 2.8 25.2 0 14 0Z" fill="url(#paint1_linear-mssngr-widget)"/>\n        </g>\n            <path d="M25.0249 13.7106C24.9593 13.5028 24.8061 13.3169 24.5983 13.1965L8.49834 4.16217C7.86396 3.81217 7.0874 4.2606 7.0874 4.99342V7.11529V8.38404L25.0249 13.7106Z" fill="#FAFFFE"/>\n            <path d="M7.0874 20.9013V23.0231C7.0874 23.745 7.86396 24.2044 8.49834 23.8544L24.5983 14.831C24.8171 14.7106 24.9593 14.5247 25.0249 14.3169L7.0874 19.6216V20.9013Z" fill="#C8F4F9"/>\n            <path d="M7.08759 8.37787L5.87353 8.01693C5.07509 7.77631 4.38603 8.60756 4.7579 9.35131L5.41415 10.6529L6.87978 13.5732L7.09853 13.9997V8.37787H7.08759Z" fill="#DEF8FB"/>\n            <path d="M7.0874 13.9998H25.0796C25.0796 13.8904 25.0577 13.792 25.0249 13.6936L7.0874 8.37793V13.9998Z" fill="#DEF8FB"/>\n            <path d="M7.09853 14.0005L4.7579 18.6489C4.38603 19.3927 5.07509 20.2239 5.87353 19.9833L7.08759 19.6224V14.0005H7.09853Z" fill="#FAFFFE"/>\n            <path d="M7.0874 19.6219L25.0358 14.3063C25.0686 14.2078 25.0905 14.0984 25.0905 14H7.0874V19.6219Z" fill="#FAFFFE"/>\n        </g>\n        <defs>\n        <filter id="filter0-mssngr-widget" x="-25.7204" y="-14.7308" width="79.4408" height="79.4408" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">\n            <feFlood flood-opacity="0" result="BackgroundImageFix"/>\n            <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>\n            <feOffset dy="10.9896"/>\n            <feGaussianBlur stdDeviation="12.8602"/>\n            <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0"/>\n            <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>\n            <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>\n        </filter>\n        <linearGradient id="paint0_linear-mssngr-widget" x1="44.8437" y1="-28.5469" x2="14" y2="16.5156" gradientUnits="userSpaceOnUse">\n            <stop stop-color="white"/>\n            <stop offset="1" stop-color="white" stop-opacity="0"/>\n        </linearGradient>\n        <linearGradient id="paint1_linear-mssngr-widget" x1="14" y1="33.3594" x2="34.3437" y2="-11.4844" gradientUnits="userSpaceOnUse">\n            <stop stop-color="#00BCBC"/>\n            <stop offset="1" stop-color="white" stop-opacity="0"/>\n        </linearGradient>\n        <clipPath id="clip-mssngr-widget-icon">\n            <path d="M0 0H28V28H0V0Z" fill="white"/>\n        </clipPath>\n        </defs>\n    </svg>'}var b$2=block("button");function buttonTemplate$1(e,t){var r=e.useRef();r.on("click",e.props.onClick);var n=e.props.buttonText?'\n        <div class="'+b$2("text")+'">\n            <div class="'+b$2("text-container")+'">'+e.props.buttonText+"</div>\n        </div>":"";return"\n        <a "+r.id+' class="'+r.useClassName((function(e){return b$2({mobile:e.isMobile,collapsed:e.collapsed,size:e.buttonSize,desktop:!e.isMobile,visible:e.visible})}),["isMobile","visible","buttonSize","collapsed"])+'">\n            <div class="'+b$2("container")+'">\n                <div class="'+b$2("icon")+'">\n                    '+icon()+"\n                </div>\n                "+n+"\n            </div>\n            "+(t||"")+"\n        </a>"}var b$1=block("badge");function getCount(e,t){return t?(null==e?void 0:e.valueForChat)||0:(null==e?void 0:e.value)||0}function badgeTemplate(e){var t,r,n=e.useState({count:getCount(null===(t=e.props.unreadCounterPlugin)||void 0===t?void 0:t.lastValue,null===(r=e.props.unreadCounterPlugin)||void 0===r?void 0:r.shouldUseValueForChat)}),o=n[0],i=n[1],a=e.useRef(),s=e.useRef();return a.useEffect((function(e){var t=e.unreadCounterPlugin,r=function(e){i((function(){return{count:getCount(e,null==t?void 0:t.shouldUseValueForChat)}}))};return t&&(i((function(){return{count:getCount(t.lastValue,t.shouldUseValueForChat)}})),t.onChanged.addListener(r)),function(){null==t||t.onChanged.removeListener(r)}}),["unreadCounterPlugin"]),"\n        <div\n            "+a.id+'\n            class="'+a.useClassName((function(e,t){var r=t.count;return b$1({"has-count":Boolean(r),type:e.badgeType,visible:Boolean(r)})}),["badgeType"],o)+'"\n        >\n            <div '+s.id+' class="'+b$1("count")+'">\n                '+s.useText((function(e,t){return normalizeBadgeString(t.count,e.badgeMaxCount)}),["badgeMaxCount"],o)+"\n            </div>\n        </div>\n    "}var b=block("button-ui");function buttonTemplate(e,t){var r=badgeTemplate(e.pipe((function(e){return{badgeMaxCount:e.badgeMaxCount,unreadCounterPlugin:e.unreadCounterPlugin,badgeType:e.badgeType}}))),n=basePopupTemplate(e.pipe((function(e){return{lang:e.lang,isMobile:e.isMobile,page:e.page,iframe:e.iframe,fullscreen:e.fullscreen,popupAutocloseable:e.popupAutocloseable,buttonMode:!0,popupVisible:e.popupVisible,popupPosition:void 0,popupTarget:void 0,paranjaVisible:e.paranjaVisible,onClose:e.onClose,onRetry:e.onRetry,onNewTab:e.onRetry,inner:!0,pageScrollController:e.pageScrollController}})),t);return'\n        <div class="'+b()+'">\n            '+buttonTemplate$1(e.pipe((function(e){return{isMobile:e.isMobile,lang:e.lang,collapsed:e.collapsed,buttonSize:e.buttonSize,buttonText:e.buttonText,visible:e.popupVisible,onClick:e.onButtonClick}})),r)+'\n            <div data-ref="popup-wrapper" class="'+b("popup-wrapper")+'">\n                '+n+"\n            </div>\n        </div>\n    "}function getNormalizeCollapsed(e){var t=e.isMobile,r=e.buttonText,n=e.collapsedDesktop,o=e.collapsedTouch,i=t?o:n;return r?t||-1!==["always","never","hover"].indexOf(i)?t&&-1===["always","never"].indexOf(i)?"always":i:"hover":"always"}function normalizeProps(e,t){return __assign$2(__assign$2({},e),{isMobile:isDefined(e.isMobile)?e.isMobile:isMobile(),buttonText:isDefined(e.buttonText)?e.buttonText:i18n("button-text-default",t),badgeType:e.badgeType||"num",badgeMaxCount:e.badgeMaxCount||99})}function buttonContextFactoryProvider(e){return function(t){var r=normalizeProps(e,t.options.lang),n=getNormalizeCollapsed(r);return{buttonMode:!0,badgeMaxCount:r.badgeMaxCount||99,badgeType:r.badgeType||"num",collapsed:n,buttonSize:"always"===n?"large":"normal",buttonText:r.buttonText,unreadCounterPlugin:r.unreadCounterPlugin,paranjaVisible:r.paranjaVisible,pageScrollController:e.pageScrollController||new PageScrollController,onButtonClick:function(){t.show()}}}}var ButtonUI=function(e){function t(t){return e.call(this,buttonTemplate,buttonContextFactoryProvider(t),t)||this}return __extends$i(t,e),t.prototype.mount=function(e){void 0===e&&(e=document.body),this.render(e)},t}(PopupBase);function buttonUIFactory(e){return new ButtonUI(e)}var MIN_UNREAD_TTL=10,MAX_UNREAD_TTL=300,MIN_UNREAD_TIMEOUT=1e3*MIN_UNREAD_TTL,MAX_UNREAD_TIMEOUT=1e3*MAX_UNREAD_TTL,LOCAL_STORAGE_KEY_NAME="yachat-unread",HEALTH_SERVICE_ID=19,HEALTH_NAMESPACE=5;function getServiceNamespace(e){return e===HEALTH_SERVICE_ID?HEALTH_NAMESPACE:void 0}function getLocalStorageTimeout(e){return e.expiredTimestamp-Date.now()}function isValidLocalStorageData(e){var t=Date.now();return Boolean(e&&e.currentTimestamp<t&&t<e.expiredTimestamp&&e.expiredTimestamp-t<=MAX_UNREAD_TIMEOUT&&e.hasAuth===hasAuth())}function prepareTtl(e){return e<MIN_UNREAD_TTL?MIN_UNREAD_TTL:e>MAX_UNREAD_TTL?MAX_UNREAD_TTL:e}function getErrorTimeout(e,t){var r=Math.max(MIN_UNREAD_TIMEOUT,t);return 401===e||403===e?MAX_UNREAD_TIMEOUT:Math.min(2*r,MAX_UNREAD_TIMEOUT)}var UnreadCounter=function(){function e(e){this.isStarted=!1,this.needFetch=!1,this.reqNum=0,this.rn=Math.floor(1e6*Math.random()),this.timeout=MIN_UNREAD_TIMEOUT,this.timeoutId=-1,this.params=e,this.fetch=this.fetch.bind(this),this.handleOnline=this.handleOnline.bind(this),this.handleVisibilityChange=this.handleVisibilityChange.bind(this)}return Object.defineProperty(e.prototype,"shouldUseSavedData",{get:function(){return(!this.params.ns||0===this.params.ns.length)&&void 0===this.params.workspaceId},enumerable:!1,configurable:!0}),e.prototype.start=function(){!this.isStarted&&this.params.url&&window.navigator.cookieEnabled&&(this.isStarted=!0,this.bindEvents(),this.fetch())},e.prototype.stop=function(){this.isStarted=!1,this.clearTimeout(),this.unbindEvents()},e.prototype.removeData=function(){removeLocalStorageJsonItem(LOCAL_STORAGE_KEY_NAME)},e.prototype.fetch=function(){if(this.clearTimeout(),document.hidden||!window.navigator.onLine)return this.needFetch=!0,void this.retryFetch();if(this.needFetch=!1,this.shouldUseSavedData){var e=getLocalStorageJsonItem(LOCAL_STORAGE_KEY_NAME);if(isValidLocalStorageData(e))return this.runCallback(e.response),void(this.timeoutId=window.setTimeout(this.fetch,getLocalStorageTimeout(e)))}this.makeRequest()},e.prototype.retryFetch=function(){this.clearTimeout(),this.timeoutId=window.setTimeout(this.fetch,this.timeout)},e.prototype.bindEvents=function(){document.addEventListener("visibilitychange",this.handleVisibilityChange,!1),window.addEventListener("online",this.handleOnline,!1)},e.prototype.unbindEvents=function(){document.removeEventListener("visibilitychange",this.handleVisibilityChange,!1),window.removeEventListener("online",this.handleOnline,!1)},e.prototype.handleVisibilityChange=function(){this.needFetch&&!document.hidden&&this.fetch()},e.prototype.handleOnline=function(){this.needFetch&&this.fetch()},e.prototype.makeRequest=function(){var e=this,t=new XMLHttpRequest;t.open("GET",this.getUrl(),!0),t.withCredentials=!0,this.params.authToken&&(t.withCredentials=!1,t.setRequestHeader("Authorization",this.params.authToken),this.params.authPartition&&t.setRequestHeader("X-Passp-Partition",this.params.authPartition)),t.onload=function(){if(e.isStarted)if(200===t.status){var r;try{r=JSON.parse(t.responseText)}catch(e){r=null}if(r&&"object"==typeof r){if("Status"in r)return void e.handleError(r);if("Ttl"in r)return void e.handleResponse(r)}e.stop()}else e.handleError({Status:t.status})},t.onerror=t.onabort=t.ontimeout=function(){return e.handleError({Status:t.status})},t.send(null)},e.prototype.runCallback=function(e){"Ttl"in e&&!("Status"in e)&&this.params.callback({lastTimestamp:e.LastUnreadTsMcs,value:e.UnreadCount||0,valueForChat:e.ChatUnreadCount||0,chatCount:e.ChatCount||0})},e.prototype.getUrl=function(){this.reqNum++;var e=this.params,t=e.serviceId,r=e.workspaceId,n=e.url,o=e.chatId,i=e.guid,a=e.ns,s=e.withCountChats,l=e.orgId;return queryStringify$1(n,{all_ns:getServiceNamespace(t),parentOrigin:getOrigin(),rn:this.rn,reqNum:this.reqNum,chat_id:o,other_guid:i,serviceId:t,client:r,ns:a,count_chats:s?"1":void 0,organization_id:l})},e.prototype.clearTimeout=function(){window.clearTimeout(this.timeoutId)},e.prototype.handleResponse=function(e){this.runCallback(e),this.timeout=1e3*prepareTtl(e.Ttl),this.saveData(e,this.timeout),this.retryFetch()},e.prototype.handleError=function(e){this.timeout=getErrorTimeout(e.Status,this.timeout),this.saveData(e,this.timeout),this.retryFetch()},e.prototype.saveData=function(e,t){if(this.shouldUseSavedData){var r=Date.now();setLocalStorageJsonItem(LOCAL_STORAGE_KEY_NAME,{currentTimestamp:r,expiredTimestamp:r+t,hasAuth:hasAuth(),response:e})}},e}(),__assign=function(){return __assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},__assign.apply(this,arguments)},UnreadCounterPlugin=function(){function e(e,t){this.unreadUrl=e,this.unreadCounterFactory=t,this.onChanged=new Event}return e.prototype.init=function(e,t){var r,n=e.serviceId,o=e.workspaceId,i=e.unreadCounterChatId,a=e.unreadCounterOtherGuid,s=e.unreadCounterNsFilter,l=e.unreadWithCountChats,u=e.orgId,c=e.authToken,d=e.authPartition;this.widgetProxy=t,this.widgetProxy.events.counter.addListener(this.handleUnreadCounter),this.unreadCounterClient=null==this?void 0:this.unreadCounterFactory({callback:this.update,url:replaceTld(this.unreadUrl),serviceId:n,workspaceId:o,chatId:i,guid:a,ns:s,withCountChats:l,orgId:u,authPartition:d,authToken:c}),null===(r=this.unreadCounterClient)||void 0===r||r.start()},e.prototype.handleUnreadCounter=function(e){var t=e.data;this.update(t)},e.prototype.update=function(e){var t=this.lastValue,r=e.valueForChat,n=void 0===r?0:r,o=e.value,i=void 0===o?0:o,a=e.lastTimestamp,s=void 0===a?0:a,l=e.seqnoForChat,u=void 0===l?0:l,c=e.chatCount,d=void 0===c?0:c;t&&i===t.value&&n===t.valueForChat&&s===t.lastTimestamp&&u===t.seqnoForChat&&d===t.chatCount||(this.lastValue={value:i,lastTimestamp:s,valueForChat:n,seqnoForChat:u,chatCount:d},this.onChanged.dispatch(this.lastValue))},Object.defineProperty(e.prototype,"shouldUseValueForChat",{get:function(){var e;return Boolean(null===(e=this.widgetProxy)||void 0===e?void 0:e.options.unreadCounterChatId)},enumerable:!1,configurable:!0}),e.prototype.LCClose=function(){var e;this.widgetProxy.events.counter.removeListener(this.handleUnreadCounter),null===(e=this.unreadCounterClient)||void 0===e||e.stop(),this.onChanged.removeAllListener()},e.prototype.LCReady=function(){var e;null===(e=this.unreadCounterClient)||void 0===e||e.stop()},__decorate$9([lib$3.bind],e.prototype,"handleUnreadCounter",null),__decorate$9([lib$3.bind],e.prototype,"update",null),e}(),YANDEX_UNREAD_COUNTER_ENDPOINT="https://yandex.{tld}/messenger/api/unread_count";function yandexUnreadCounterFactory(){return new UnreadCounterPlugin(YANDEX_UNREAD_COUNTER_ENDPOINT,(function(e){return new UnreadCounter(e)}))}var DEEP_LINK=/^https?:\/\/yandex\.[^/]+\/chat/,isAnchor=function(e){return"A"===e.tagName},Deeplinker=function(){function e(){}return e.prototype.init=function(e,t){isNativeAvailable()||(this.widgetProxy=t,window.addEventListener("click",this.handleClick,!0))},e.prototype.LCClose=function(){isNativeAvailable()||window.removeEventListener("click",this.handleClick,!0),this.widgetProxy=void 0},e.prototype.handleClick=function(e){for(var t,r=e.target;r;){if(isAnchor(r)&&DEEP_LINK.test(r.href))return null===(t=this.widgetProxy)||void 0===t||t.show({deeplink:r.href}),void e.preventDefault();r=r.parentElement}},__decorate$9([lib$3.bind],e.prototype,"handleClick",null),e}();exports.Block=Block,exports.Deeplinker=Deeplinker,exports.IframeStrategy=IframeStrategy,exports.Popup=Popup,exports.PopupBase=PopupBase,exports.UnreadCounterPlugin=UnreadCounterPlugin,exports.WindowStrategy=WindowStrategy,exports.YANDEX_UNREAD_COUNTER_ENDPOINT=YANDEX_UNREAD_COUNTER_ENDPOINT,exports.blockUIFactory=blockUIFactory,exports.buttonContextFactoryProvider=buttonContextFactoryProvider,exports.buttonUIFactory=buttonUIFactory,exports.createMultiChatsBlockUIWidget=createMultiChatsBlockUIWidget,exports.createMultiChatsWidget=createMultiChatsWidget,exports.createSingleChatBlockUIWidget=createSingleChatBlockUIWidget,exports.createSingleChatWidget=createSingleChatWidget,exports.defaultBehaviorStrategies=defaultBehaviorStrategies,exports.popupUIFactory=popupUIFactory,exports.yandexUnreadCounterFactory=yandexUnreadCounterFactory;
//# sourceMappingURL=/sm/642ca8f93ac9146afe3ded75399452d37895fba1490278fcfbb40ed20fb2d4c4.map