UNPKG

@sberid/js-sdk

Version:

Javascript SDK для партнеров Сбер ID, упрощающая подключение SberbankID на сайте.

15 lines (13 loc) 110 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).createSberidSDK=t()}(this,(function(){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};var t=function(){return t=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},t.apply(this,arguments)};function n(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function i(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var r,o="https://online.sberbank.ru",s={method:"GET",credentials:"include"},a=function(e){return void 0===e&&(e=o),"".concat(e,"/CSAFront/oidc/authorize.do")};!function(e){e.SAFARI="Safari",e.PLAYSTATION_4="PlayStation 4",e.ANDROID_BROWSER="Android Browser",e.CHROME="Chrome",e.CHROMIUM="Chromium",e.ELECTRON="Electron",e.FIREFOX="Firefox",e.QUPZILLA="QupZilla",e.TIZEN="Tizen",e.BADA="Bada",e.WEBOS_BROWSER="WebOS Browser",e.BLACKBERRY="BlackBerry",e.SLIMERJS="SlimerJS",e.PHANTOMJS="PhantomJS",e.AMAZON_SILK="Amazon Silk",e.SAILFISH="Sailfish",e.SEAMONKEY="SeaMonkey",e.VIVALDI="Vivaldi",e.MICROSOFT_EDGE="Microsoft Edge",e.INTERNET_EXPLORER="Internet Explorer",e.WECHAT="WeChat",e.K_MELEON="K-Meleon",e.SLEIPNIR="Sleipnir",e.PUFFIN="Puffin",e.EPIPHANY="Epiphany",e.MAXTHON="Maxthon",e.UC_BROWSER="UC Browser",e.YANDEX_BROWSER="Yandex Browser",e.OPERA_COAST="Opera Coast",e.SWING="Swing",e.FOCUS="Focus",e.MZ_BROWSER="MZ Browser",e.NAVER_WHALE_BROWSER="NAVER Whale Browser",e.SAMSUNG_INTERNET_FOR_ANDROID="Samsung Internet for Android",e.OPERA_TOUCH="Opera Touch",e.OPERA="Opera",e.GOOGLEBOT="Googlebot",e.WINDOWS_PHONE="windows phone",e.GENERIC="Generic",e.ROKU="Roku"}(r||(r={}));var c,u,l,d,f={invalid_request:"В запросе отсутствуют обязательные атрибуты",unauthorized_client:"АС - источник запроса не зарегистрирована или заблокирована в банке либо значение атрибута client_id не соответствует формату",unsupported_response_type:"Значение атрибута response_type не равно «code»",invalid_scope:"Значение атрибута scope не содержит параметр openid в начальной позиции либо запрошенный scope содержит значения, недоступные для АС - источника запроса",access_denied:"Клиент отказался от передачи согласий",invalid_state:"Значение атрибута state не соответствует изначальному",window_closed:"Клиент закрыл окно авторизации через Сбер ID"},p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",h={needAdditionalRedirect:!0,universalLinkUrl:(void 0===c&&(c=o),"".concat(c,"/CSAFront/oidc/sberbank_id/authorize.do")),baseUrl:a(),deeplinkUrl:"sberbankidlogin://sberbankidsso",debug:!1,generateState:!1,display:"page"},b=function(e){return void 0===e&&(e=window.location.search.slice(1)),e?(/^[?#]/.test(e)?e.slice(1):e).split("&").reduce((function(e,t){var n=t.split("="),i=n[0],r=n[1];return e[i]=r?decodeURIComponent(r.replace(/\+/g," ")):"",e}),{}):{}},v=function(e,t){var n=Object.keys(t).map((function(e){return[e,t[e]].map(encodeURIComponent).join("=")})).join("&");return e?"".concat(e).concat(n?"?":"").concat(n):n},g={info:{color:"#0c5460",background:"#d1ecf1",border:"#bee5eb"},success:{color:"#155724",background:"#d4edda",border:"#c3e6cb"},error:{color:"#721c24",background:"#f8d7da",border:"#f5c6cb"}},w=function(e,t){void 0===t&&(t="info");var n=new Date,i="[".concat(n.getHours(),":").concat(n.getMinutes(),":").concat(n.getSeconds().toString().padStart(2,"0"),":").concat(n.getMilliseconds(),"] %c[").concat(t,"]%c "),r="color: ".concat(g[t].color,";background-color: ").concat(g[t].background,";border: 1px solid ").concat(g[t].border);console.info.apply(null,[i,r,""].concat(e))},m=function(e,t){var n=function(n){!e.contains(n.target)&&y(e)&&(t(),i())},i=function(){document.removeEventListener("click",n)};document.addEventListener("click",n)},y=function(e){return!!e&&!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},_=function(){for(var e=document.querySelectorAll(".sbid-button-loader"),t=0;t<e.length;t+=1){e[t].classList.add("sbid-button-loader--show")}},S=function(){for(var e=document.querySelectorAll(".sbid-button-loader"),t=0;t<e.length;t+=1){e[t].classList.remove("sbid-button-loader--show")}},k=function(){return window.crypto||window.msCrypto},O=function(e){var t=new Uint8Array(e);if("undefined"!=typeof window&&k())k().getRandomValues(t);else for(var n=0;n<e;n+=1)t[n]=Math.random()*p.length|0;return function(e){for(var t=[],n=0;n<e.byteLength;n+=1){var i=e[n]%p.length;t.push(p[i])}return t.join("")}(t)},x={url:"https://sve.online.sberbank.ru/metrics/partners",init:"auto",enable:!0,buffer:1,apiKey:"da8570065d949a8a3ee551b99f31f7774909575e702289b2743fab0aad0ffe41",subId:""},E=function(e){var n,i;if(window.sberbankIdAnalytics)w(["SberVisor уже иницилизирован"],"info");else{var r=t(t(t({},x),e.sa),{sberId:(null===(n=null==e?void 0:e.oidc)||void 0===n?void 0:n.client_id)||(null===(i=null==e?void 0:e.sa)||void 0===i?void 0:i.clientId)||""});try{Promise.resolve().then((function(){return Ge})).then((function(){window.sberbankIdAnalytics=new window.SberVisor(r)})).catch((function(e){return w(["Ошибка при инициализации SberVisor",e],"error")}))}catch(e){w(["Ошибка при инициализации SberVisor",e],"error")}}},A=function(e){var n=e.eventCategory,i=e.eventAction,r=e.eventType,o=e.result,s=e.description,a=e.extendedProperties,c=e.clientName;if(window.sberbankIdAnalytics){var u,l,d=c||(u="title",(l=document.querySelector('meta[name="'.concat(u,'"]')))&&l.getAttribute("content")||""),f=window.location.origin;try{var p={eventCategory:n,eventAction:i,eventType:r,properties:t(t(t({merchUrl:f,merchantTitle:d,sdkVersion:"js_3.0.3"},o?{result:o}:{}),s?{errorDescription:s}:{}),a)};window.sberbankIdAnalytics.push(p)}catch(e){w(["Ошибка при отправке события (".concat(n,", ").concat(i,", ").concat(r,") в SberVisor"),e],"error")}}},I="Facebook Messenger",L="Facebook",C="Twitter",R="Line",T="Wechat",M="Instagram",N="Electron Application",B="Microsoft Outlook",P="Pinterest App",D="Thunderbird",U="Webview Based Browser",j="Yandex App",F="Windows Phone",W="Windows",z="macOS",H="iOS",q="Android",V="WebOS",G="BlackBerry",K="Bada",Z="Tizen",Q="Linux",X="Chrome OS",Y="PlayStation 4",J="Roku",$="tablet",ee="mobile",te="desktop",ne="tv",ie=/version\/(\d+(\.?_?\d+)+)/i,re=function(e,t){var n=t.match(e);return n&&n.length>0&&n[1]||""},oe=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},se=[{test:[/googlebot/i],describe:function(e){var t={name:r.GOOGLEBOT},n=re(/googlebot\/(\d+(\.\d+))/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/opera/i],describe:function(e){var t={name:r.OPERA},n=re(ie,e)||re(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:r.OPERA},n=re(/(?:opr|opios)[\s/](\S+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/opt/i],describe:function(e){var t={name:r.OPERA_TOUCH},n=re(/(?:opt)[\s/](\S+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:r.SAMSUNG_INTERNET_FOR_ANDROID},n=re(ie,e)||re(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:r.NAVER_WHALE_BROWSER},n=re(ie,e)||re(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:r.MZ_BROWSER},n=re(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:r.FOCUS},n=re(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:r.SWING},n=re(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:r.OPERA_COAST},n=re(ie,e)||re(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:r.YANDEX_BROWSER},n=re(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:r.UC_BROWSER},n=re(ie,e)||re(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:r.MAXTHON},n=re(ie,e)||re(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:r.EPIPHANY},n=re(ie,e)||re(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:r.PUFFIN},n=re(ie,e)||re(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:r.SLEIPNIR},n=re(ie,e)||re(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:r.K_MELEON},n=re(ie,e)||re(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:r.WECHAT},n=re(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:r.INTERNET_EXPLORER},n=re(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:r.MICROSOFT_EDGE},n=re(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:r.MICROSOFT_EDGE},n=oe(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:r.VIVALDI},n=re(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:r.SEAMONKEY},n=re(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:r.SAILFISH},n=re(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:r.AMAZON_SILK},n=re(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:r.PHANTOMJS},n=re(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:r.SLIMERJS},n=re(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:r.BLACKBERRY},n=re(ie,e)||re(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:r.WEBOS_BROWSER},n=re(ie,e)||re(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:r.BADA},n=re(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:r.TIZEN},n=re(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:r.QUPZILLA},n=re(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:r.FIREFOX},n=re(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe:function(e){var t={name:r.ELECTRON},n=re(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe:function(e){var t={name:r.CHROMIUM},n=re(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||re(ie,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:r.CHROME},n=re(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:r.ANDROID_BROWSER},n=re(ie,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:r.PLAYSTATION_4},n=re(ie,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:r.SAFARI},n=re(ie,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:re(t,e),version:oe(t,e)}}}],ae=[{test:[/\bFB[\w_]+\/(Messenger|MESSENGER)/],describe:function(){return{name:I}}},{test:[/\bFB[\w_]+\//],describe:function(){return{name:L}}},{test:[/\bTwitter/i],describe:function(){return{name:C}}},{test:[/\bLine\//i],describe:function(){return{name:R}}},{test:[/\bMicroMessenger\//i],describe:function(){return{name:T}}},{test:[/\bInstagram/i],describe:function(){return{name:M}}},{test:[/\bElectron/i],describe:function(){return{name:N}}},{test:[/\bOutlook/i],describe:function(){return{name:B}}},{test:[/\bPinterest/i],describe:function(){return{name:P}}},{test:[/\bThunderbird/i],describe:function(){return{name:D}}},{test:[/\bwebview/i,/; wv/],describe:function(){return{name:U}}},{test:[/\bYaApp/i,/\bYandexSearch/i],describe:function(){return{name:j}}}],ce=[{test:[/Roku\/DVP/],describe:function(e){var t=re(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:J,version:t}}},{test:[/windows phone/i],describe:function(e){var t=re(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:F,version:t}}},{test:[/windows/i],describe:function(e){var t=re(/Windows ((NT|XP)( \d\d?.\d)?)/i,e);return{name:W,version:t}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:H},n=oe(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe:function(e){var t=re(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,".");return{name:z,version:t}}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=re(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:H,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=re(/android[\s/-](\d+(\.\d+)*)/i,e);return{name:q,version:t}}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=re(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:V};return t&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=re(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||re(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||re(/\bbb(\d+)/i,e);return{name:G,version:t}}},{test:[/bada/i],describe:function(e){var t=re(/bada\/(\d+(\.\d+)*)/i,e);return{name:K,version:t}}},{test:[/tizen/i],describe:function(e){var t=re(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:Z,version:t}}},{test:[/linux/i],describe:function(){return{name:Q}}},{test:[/CrOS/],describe:function(){return{name:X}}},{test:[/PlayStation 4/],describe:function(e){var t=re(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:Y,version:t}}}],ue=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=re(/(can-l01)/i,e)&&"Nova",n={type:ee,vendor:"Huawei",model:""};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:$,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:$,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:$,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:$,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:$,vendor:"Amazon"}}},{test:[/tablet/i],describe:function(){return{type:$}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=re(/(ipod|iphone)/i,e);return{type:ee,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:ee,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:ee}}},{test:function(e){return e.getBrowserName()===r.BLACKBERRY},describe:function(){return{type:ee,vendor:"BlackBerry"}}},{test:function(e){return e.getBrowserName()===r.BADA},describe:function(){return{type:ee}}},{test:function(e){return e.getBrowserName()===r.WINDOWS_PHONE},describe:function(){return{type:ee,vendor:"Microsoft"}}},{test:function(e){var t,n=Number(null===(t=String(e.getOSVersion()))||void 0===t?void 0:t.split(".")[0]);return"android"===e.getOSName(!0)&&n>=3},describe:function(){return{type:$}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:ee}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:te,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:te}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:te}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:ne}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:ne}}}],le=function(e){return String(e).toLowerCase()||""},de=function(){function e(e){if(!e)throw new Error("UserAgent parameter can't be empty ");this.ua=e,this.parsedResult={},this.parse()}return e.prototype.getUA=function(){return this.ua},e.prototype.test=function(e){return e.test(this.ua)},e.prototype.getDetailInfo=function(e){var t=this;return e.find((function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}))},e.prototype.parseBrowser=function(){this.parsedResult.browser={};var e=this.getDetailInfo(se);return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser},e.prototype.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},e.prototype.getBrowserName=function(e){return e?le(this.getBrowser().name):this.getBrowser().name||""},e.prototype.getBrowserVersion=function(){return this.getBrowser().version},e.prototype.parseOS=function(){this.parsedResult.os={};var e=this.getDetailInfo(ce);return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os},e.prototype.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},e.prototype.getOSName=function(e){var t=this.getOS().name;return e?le(t):t||""},e.prototype.getOSVersion=function(){return this.getOS().version},e.prototype.parseApp=function(){this.parsedResult.app={};var e=this.getDetailInfo(ae);return e&&(this.parsedResult.app=e.describe(this.getUA())),this.parsedResult.app},e.prototype.getApp=function(){return this.parsedResult.app?this.parsedResult.app:this.parseApp()},e.prototype.getAppName=function(e){return e?le(this.getApp().name):this.getApp().name||""},e.prototype.parsePlatform=function(){this.parsedResult.platform={};var e=this.getDetailInfo(ue);return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform},e.prototype.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},e.prototype.getPlatformType=function(e){var t=this.getPlatform().type;return e?le(t):t||""},e.prototype.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseApp(),this},e.prototype.getResult=function(){return t({},this.parsedResult)},e}(),fe=function(){function e(){}return e.getParser=function(e){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new de(e)},e.parse=function(e){return new de(e).getResult()},e}(),pe=function(){function e(){this.browserMode="unknown"}return e.prototype.retry=function(e){return new Promise((function(t){var n=0,i=!1,r=window.setInterval((function(){e()&&(window.clearInterval(r),t(i)),n++>50&&(window.clearInterval(r),t(i=!0))}),10)}))},e.prototype.run=function(){var e=this;return new Promise((function(t){(new he).browser(e).detectBrowsingMode(),e.retry((function(){return"unknown"!==e.browserMode})).then((function(){t(e.browserMode)}))}))},e}(),he=function(){function e(){this.browserData=void 0}return e.prototype.browser=function(e){return this.browserData&&"object"==typeof this.browserData||(this.browserData=this.resolve(e)),this.browserData},e.prototype.resolve=function(e){switch(fe.getParser(window.navigator.userAgent).getBrowserName()){case r.SAFARI:return new we(e);case r.FIREFOX:return new ve(e);case r.INTERNET_EXPLORER:return new ge(e);default:return"webkitRequestFileSystem"in window||"requestFileSystem"in window?new be(e):window.PointerEvent||"MSPointerEvent"in window?new ge(e):new me(e)}},e}(),be=function(){function e(e){this.navigator=navigator,this.STORAGE_QUOTA_LIMIT=12e7,this.TEMP_STORAGE_QUOTA_LIMIT=11e7,this.BrowserModeDetector=e}return e.prototype.callbackWhenWebkitTemporaryStorageQuotaNotLimited=function(){this.BrowserModeDetector.browserMode="normal"},e.prototype.callbackWhenWebkitTemporaryStorageQuotaLimited=function(){this.BrowserModeDetector.browserMode="incognito"},e.prototype.callbackWhenWebkitStorageQuotaLimited=function(){this.BrowserModeDetector.browserMode="incognito"},e.prototype.checkWebkitTemporaryStorageQuota=function(){var e=this;void 0!==this.navigator.webkitTemporaryStorage&&void 0!==this.navigator.webkitTemporaryStorage.queryUsageAndQuota?this.navigator.webkitTemporaryStorage.queryUsageAndQuota((function(t,n){n<e.TEMP_STORAGE_QUOTA_LIMIT?e.callbackWhenWebkitTemporaryStorageQuotaLimited():e.callbackWhenWebkitTemporaryStorageQuotaNotLimited()}),(function(){e.callbackWhenWebkitTemporaryStorageQuotaNotLimited()})):this.callbackWhenWebkitTemporaryStorageQuotaNotLimited()},e.prototype.checkStorageQuota=function(){var e=this;void 0!==navigator.storage&&void 0!==navigator.storage.estimate?navigator.storage.estimate().then((function(t){(null==t?void 0:t.quota)&&(null==t?void 0:t.quota)<e.STORAGE_QUOTA_LIMIT?e.callbackWhenWebkitStorageQuotaLimited():e.callbackWhenWebkitStorageQuotaNotLimited()})):this.callbackWhenWebkitStorageQuotaNotLimited()},e.prototype.callbackWhenWebkitStorageQuotaNotLimited=function(){this.checkWebkitTemporaryStorageQuota()},e.prototype.detectBrowsingMode=function(){this.checkStorageQuota()},e}(),ve=function(){function e(e){this.BrowserModeDetector=e}return e.prototype.callbackWhenIndexedDBNotWorking=function(){this.BrowserModeDetector.browserMode="incognito"},e.prototype.callbackWhenIndexedDBWorking=function(){var e=this;"unknown"===this.BrowserModeDetector.browserMode&&this.BrowserModeDetector.retry((function(){return"done"===e.db.readyState})).then((function(t){if(t)return e.callbackWhenIndexedDBNotWorking();e.db.result&&(e.BrowserModeDetector.browserMode="normal")}))},e.prototype.detectBrowsingMode=function(){this.db=indexedDB.open("i"),this.db.onsuccess=this.callbackWhenIndexedDBWorking.bind(this),this.db.onerror=this.callbackWhenIndexedDBNotWorking.bind(this)},e}(),ge=function(){function e(e){this.BrowserModeDetector=e}return e.prototype.detectBrowsingMode=function(){this.BrowserModeDetector.browserMode="normal";try{window.indexedDB||(this.BrowserModeDetector.browserMode="incognito")}catch(e){this.BrowserModeDetector.browserMode="incognito"}},e}(),we=function(){function e(e){this.BrowserModeDetector=e}return e.prototype.tryFillLocalStorage=function(e){var t={size:e,payload:new Array(e/4+1).join("aあ"),lastModifiedDate:new Date,name:1e5+~~(1e5*Math.random())+".txt"};try{localStorage.setItem(t.name,JSON.stringify(t))}catch(e){try{localStorage.removeItem(t.name)}catch(e){}return!1}try{localStorage.removeItem(t.name)}catch(e){}return!0},e.prototype.detectBrowsingMode=function(){var e,t,n=window,i=fe.getParser(window.navigator.userAgent),r=parseInt(null===(e=i.getOSVersion())||void 0===e?void 0:e.split(".")[0],10)||0,o=parseInt(null===(t=i.getBrowserVersion())||void 0===t?void 0:t.split(".")[0],10)||0,s=i.getOSName(!0);if(!n.safariIncognito&&navigator.cookieEnabled){try{n.openDatabase&&n.openDatabase(null,null,null,null),n.localStorage.setItem("test","1")}catch(e){this.BrowserModeDetector.browserMode="incognito"}if("unknown"===this.BrowserModeDetector.browserMode)if(n.localStorage.removeItem("test"),"ios"===s&&r>=14||"macos"===s&&o>=14||"ios"===s&&0===o)this.BrowserModeDetector.browserMode="normal";else{this.tryFillLocalStorage(5242880)?this.BrowserModeDetector.browserMode="incognito":this.BrowserModeDetector.browserMode="normal"}}else this.BrowserModeDetector.browserMode="incognito"},e}(),me=function(){function e(e){this.BrowserModeDetector=e}return e.prototype.detectBrowsingMode=function(){this.BrowserModeDetector.browserMode="normal"},e}(),ye=function(){function e(){}return e.get=function(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0},e.set=function(e,t,n){void 0===n&&(n={});var i=n.expires;if("number"==typeof i&&i){var r=new Date;r.setTime(r.getTime()+1e3*i),i=n.expires=r}i instanceof Date&&(n.expires=i.toUTCString()),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent);var o="".concat(e,"=").concat(t);for(var s in n)n[s]&&(o+="; ".concat(s),!0!==n[s]&&(o+="=".concat(n[s].split(";")[0])));document.cookie=o},e.delete=function(e){this.set(e,"",{expires:-1})},e}(),_e=((u={})[r.AMAZON_SILK]="amazon_silk",u[r.ANDROID_BROWSER]="android",u[r.BADA]="bada",u[r.BLACKBERRY]="blackberry",u[r.CHROME]="chrome",u[r.CHROMIUM]="chromium",u[r.ELECTRON]="electron",u[r.EPIPHANY]="epiphany",u[r.FIREFOX]="firefox",u[r.FOCUS]="focus",u[r.GENERIC]="generic",u[r.GOOGLEBOT]="googlebot",u[r.INTERNET_EXPLORER]="ie",u[r.K_MELEON]="k_meleon",u[r.MAXTHON]="maxthon",u[r.MICROSOFT_EDGE]="edge",u[r.MZ_BROWSER]="mz",u[r.NAVER_WHALE_BROWSER]="naver",u[r.OPERA]="opera",u[r.OPERA_COAST]="opera_coast",u[r.OPERA_TOUCH]="opera_touch",u[r.PHANTOMJS]="phantomjs",u[r.PUFFIN]="puffin",u[r.QUPZILLA]="qupzilla",u[r.SAFARI]="safari",u[r.SAILFISH]="sailfish",u[r.SAMSUNG_INTERNET_FOR_ANDROID]="samsung_internet",u[r.SEAMONKEY]="seamonkey",u[r.SLEIPNIR]="sleipnir",u[r.SWING]="swing",u[r.TIZEN]="tizen",u[r.UC_BROWSER]="uc",u[r.VIVALDI]="vivaldi",u[r.WEBOS_BROWSER]="webos",u[r.WECHAT]="wechat",u[r.YANDEX_BROWSER]="yandex",u[r.ROKU]="roku",u),Se=["chrome","yandex","firefox","samsung_internet","opera","opera_touch"];!function(e){e.ANDROID="android",e.IOS="ios"}(l||(l={})),function(e){e.HTTP="http",e.HTTPS="https"}(d||(d={}));var ke={android:{chrome:"com.android.chrome",yandex:"com.yandex.browser",opera:"com.opera.browser",firefox:"org.mozilla.firefox",samsung_internet:"com.sec.android.app.sbrowser"},ios:{chrome:{https:"googlechromes://",http:"googlechrome://"},yandex:{https:"yandexbrowser-open-url://https://",http:"yandexbrowser-open-url://http://"},opera_touch:{https:"touch-https://",http:"touch-http://"},firefox:{https:"firefox://open-url%3Furl%3Dhttps%3A%2F%2F",http:"firefox://open-url%3Furl%3Dhttp%3A%2F%2F"}}},Oe=function(e){return _e[e]},xe=function(){function e(e){this.proxyParams=["authApp","app_redirect_uri"],this.parser=fe.getParser(window.navigator.userAgent);var n=this.parser.getBrowserName(),i=e.display&&n!==r.INTERNET_EXPLORER?e.display:"page";this.config=t(t(t({},h),e.universalLink),{debug:!!e.debug,generateState:!!e.generateState,display:i}),e.utmProxyDisabled||(this.proxyParams=this.proxyParams.concat(["utm_source","utm_medium","utm_campaign","utm_term","utm_content"])),this.config.debug&&(w(["Инициализируем модуль UniversalLink"],"info"),w(["Параметры инициализации: ",this.config],"info"))}return e.prototype.isAllowedBrowser=function(e){return Se.includes(e)},e.prototype.getAdditionalRedirectParams=function(e,t,n){var i={};if(this.config.needAdditionalRedirect&&Object.prototype.hasOwnProperty.call(ke,e)&&Object.prototype.hasOwnProperty.call(ke[e],t))switch(e){case l.ANDROID:i.package=ke[e][t];break;case l.IOS:var r="";try{r=decodeURIComponent(n||"")}catch(e){w(["Ошибка декодирования redirect_uri",e],"error")}var o=r.includes("".concat(d.HTTPS,"://"))?d.HTTPS:d.HTTP;i.ext_redirect_uri="".concat(ke[e][t][o]).concat(r.replace(/^https?:\/\//,""))}return i},e.prototype.generateState=function(e){return void 0===e&&(e=43),O(e)},e.prototype.buildOidcParams=function(e){var n={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i))try{n[i]=decodeURIComponent(e[i])}catch(e){n[i]="",this.config.debug&&w(["Ошибка декодирования oidc параметра",e],"error")}e.scope&&e.scope.includes("+")&&(e.scope=e.scope.split("+").join(" "));var r=Oe(this.parser.getBrowserName()),o=this.parser.getOSName(!0),s=t({},this.getAdditionalRedirectParams(o,r,n.redirect_uri));s.display=this.config.display||"page";for(var a=b(),c=Object.keys(a),u=0;u<c.length;u+=1)this.proxyParams.includes(c[u])&&(s[c[u]]=a[c[u]]);if(this.config.generateState&&"popup"===this.config.display&&!function(){var e=b();return!(!e.code&&!e.error||!e.state)}()){var l=this.generateState();ye.set("sbid_state",l,{path:"/"}),s.state=l}return t(t({},n),s)},e.prototype.run=function(e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){var n,o,s,a,c,u,d,f,p,h,b,g;return i(this,(function(i){switch(i.label){case 0:return n=t(t({},this.config.params),e),[4,this.detect()];case 1:return o="incognito"===i.sent(),s=this.parser.getResult(),a=Oe(this.parser.getBrowserName()),c=this.parser.getOSName(!0),u=this.buildOidcParams(n),d=c===l.ANDROID&&this.isAllowedBrowser(a),f=c===l.IOS&&(a===_e[r.SAFARI]||this.isAllowedBrowser(a)&&this.config.needAdditionalRedirect),p=!o&&!s.app.name&&(f||d),h=v(this.config.deeplinkUrl,e),b=v(p?this.config.universalLinkUrl:this.config.baseUrl,e),g={isPrivate:o,isUniversalLink:p,app:s.app.name,isWebview:!!s.app.name,os:c,browser:a,link:b,deeplink:h,oidc:u},this.config.debug&&w(["Получены данные для формирования ссылки: ",g]),[2,Promise.resolve(g)]}}))}))},e.prototype.detect=function(){try{return(new pe).run()}catch(e){return Promise.resolve("normal")}},e}(),Ee={enable:!1,debug:!1,mode:"default",timeout:1500,baseUrl:o},Ae=function(e){var t=function(t){var n;try{n=JSON.parse(t.data)}catch(e){return}e(n,t)};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},Ie=function(e,t){!function(e,t,n){void 0===n&&(n="*"),t&&t.postMessage(JSON.stringify(e),n)}(e,t)},Le=function(){function e(e){this.isFastLoginIframeRegistered=!1,this.isFastLoginDataFetched=!1,this.iFrameName="sberid-iframe",this.isFastLoginIframeRegistered=!1,this.isFastLoginDataFetched=!1,this.config=t(t(t({},Ee),e.fastLogin),{debug:e.debug,baseUrl:e.baseUrl||o,oidcParams:e.oidc})}return e.prototype.removeLoadDataListener=function(){},e.prototype.authorization=function(e){return n(this,void 0,void 0,(function(){var t,n;return i(this,(function(i){switch(i.label){case 0:return(t=e||this.config.oidcParams)?(n=this.buildUrl(t),[4,this.createIFrame(n).catch((function(e){return e}))]):[2,new Promise((function(e,t){t({code:"error",error:"invalid_request",description:f.invalid_request})}))];case 1:return[2,i.sent()]}}))}))},e.prototype.buildUrl=function(e){var n=t({prompt:"none"},e);return v("".concat(this.config.baseUrl,"/CSAFront/oidc/authorizelow.do"),n)},e.prototype.createIFrame=function(e){return n(this,void 0,void 0,(function(){var t=this;return i(this,(function(n){return this.fastLoginIframe=function(e,t,n,i){void 0===t&&(t="sberid-iframe");var r=document.createElement("iframe");return r.setAttribute("src",e),r.setAttribute("frameborder","0"),r.setAttribute("name",t),r.setAttribute("id",t),r.width="0",r.height="0",r.style.display="none",r.style.position="absolute",r.style.left="-9999px","function"==typeof n&&(r.onload=n),"function"==typeof i&&(r.onerror=i),r}(e,this.iFrameName,(function(e){t.onFastLoginIframeCreateSuccess(e)}),(function(){throw t.destroyFastLogin(),{success:!1,error:{code:"error",error:"iframe_error",description:"Ошибка при создании iframe"}}})),document.body.append(this.fastLoginIframe),[2,new Promise((function(e,n){var i=setTimeout((function(){t.destroyFastLogin(),n({success:!1,error:{type:"timeout",description:"Ошибка при создании iframe"}})}),t.config.timeout),r=Ae((function(o){"iframe is registered"===o.type&&(clearTimeout(i),t.isFastLoginIframeRegistered=!0,t.loadFastLoginData().then((function(t){e(t)})).catch((function(e){n(e)})).finally((function(){t.destroyFastLogin()})),r())}))}))]}))}))},e.prototype.onFastLoginIframeCreateSuccess=function(e){this.config.debug&&w(["Iframe для быстрого входа создан",e])},e.prototype.loadFastLoginData=function(){return n(this,void 0,void 0,(function(){var e=this;return i(this,(function(t){switch(t.label){case 0:return this.isFastLoginIframeRegistered?[4,this.fetchFastLoginData()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2,new Promise((function(t,r){e.removeLoadDataListener=Ae((function(o){return n(e,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:switch(o.type){case"iframe is registered":return[3,1];case"success":return[3,3];case"error":return[3,4]}return[3,5];case 1:return[4,this.fetchFastLoginData()];case 2:return e.sent(),[3,6];case 3:return this.config.debug&&w(["Успешно получены данные при быстром входе",o.data],"success"),t(o.data),[3,6];case 4:return this.config.debug&&w(["Ошибка получения данных при быстром входе",o.data],"error"),r(o.data),[3,6];case 5:return[3,6];case 6:return[2]}}))}))}))}))]}}))}))},e.prototype.fetchFastLoginData=function(){var e;return n(this,void 0,void 0,(function(){return i(this,(function(t){return this.isFastLoginDataFetched||!this.fastLoginIframe||(Ie({type:"fetch data"},null===(e=this.fastLoginIframe)||void 0===e?void 0:e.contentWindow),this.isFastLoginDataFetched=!0),[2]}))}))},e.prototype.destroyFastLogin=function(){this.config.debug&&w(["Iframe для быстрого входа удален"]),this.fastLoginIframe&&this.fastLoginIframe.remove(),this.removeLoadDataListener&&this.removeLoadDataListener(),this.isFastLoginIframeRegistered=!1,this.isFastLoginDataFetched=!1},e}(),Ce=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var i,r,o;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=i;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,o[r]))return!1;for(r=i;0!=r--;){var s=o[r];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n};var Re=function(e,t){return n(void 0,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,(o=e,s=t,s=s||{},new Promise((function(e,t){var n=new XMLHttpRequest,i=[],r=[],a={},c=function(){return{ok:2==(n.status/100|0),statusText:n.statusText,status:n.status,url:n.responseURL,text:function(){return Promise.resolve(n.responseText)},json:function(){return Promise.resolve(n.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([n.response]))},clone:c,headers:{keys:function(){return i},entries:function(){return r},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var u in n.open(s.method||"get",o,!0),n.onload=function(){n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,n){i.push(t=t.toLowerCase()),r.push([t,n]),a[t]=a[t]?a[t]+","+n:n})),e(c())},n.onerror=t,n.withCredentials="include"==s.credentials,s.headers)n.setRequestHeader(u,s.headers[u]);n.send(s.body||null)}))).then((function(e){return n(void 0,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:if(!e.ok)return[2,{success:!1}];t=void 0,n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,e.json()];case 2:return t=n.sent(),[3,5];case 3:return n.sent(),[3,5];case 4:return[7];case 5:return[2,{success:!0,data:t}]}}))}))})).catch((function(){return{success:!1}}))];case 1:return[2,r.sent()]}var o,s}))}))},Te=function(e,t,r){return n(void 0,void 0,void 0,(function(){var n,o;return i(this,(function(i){return n=new AbortController,t.signal=n.signal,[2,Promise.race([Re(e,t),new Promise((function(t,i){o=setTimeout((function(){n.abort();var t={success:!1,error:{description:"Ошибка при выполнении запроса ".concat(e),code:"request_fail"}};i(t)}),r)}))]).finally((function(){clearTimeout(o)}))]}))}))},Me=function e(){var t=this;return this.cache={},this.set=function(e,n){var i={data:n};t.cache[e]=i},this.get=function(e){var n=t.cache[e];return new Promise(n?function(e){return e(n.data)}:function(e){return e(void 0)})},this.remove=function(e){delete t.cache[e]},this.all=function(){return Object.keys(t.cache)},e.instance?e.instance:(e.instance=this,this)},Ne=function(){function e(){if(this.config={baseUrl:o},this.cache=new Me,this.listeners=[],e.instance)throw new Error("Error: Instantiation failed: Use UserHelper.getInstance() instead of new.");e.instance=this}return e.getInstance=function(){return e.instance},e.prototype.setConfig=function(e){this.config=t(t({},this.config),e)},e.prototype.setListener=function(e){this.listeners.push(e)},e.prototype.callListeners=function(e){for(var t=0;t<this.listeners.length;t+=1)this.listeners[t].call(this,e)},e.prototype.getUser=function(e){return void 0===e&&(e=!0),n(this,void 0,void 0,(function(){var t,n,r;return i(this,(function(i){switch(i.label){case 0:return this.config.baseUrl&&this.config.clientId?(t="".concat(this.config.baseUrl,"/CSAFront/api/oidc/sbid?client_id=").concat(this.config.clientId),[4,this.cache.get("user")]):[2];case 1:return n=i.sent(),!e&&n?[2,n]:[4,Te(t,s,1e4)];case 2:return(r=i.sent()).success&&(n=r.data),n?(this.cache.set("user",n),this.callListeners(n),[2,n]):[2]}}))}))},e.prototype.resetUser=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.config.baseUrl&&this.config.clientId?(e="".concat(this.config.baseUrl,"/CSAFront/api/oidc/sbid/reset?client_id=").concat(this.config.clientId),[4,Te(e,s,1e4)]):[2,!1];case 1:return t.sent().success?(this.cache.remove("user"),this.callListeners(),[2,!0]):[2,!1]}}))}))},e.instance=new e,e}(),Be={default:{anonymous:"Войти по Сбер ID",personal:"Войти как {{userName}}"},resume:{anonymous:"Продолжить со Сбер ID",personal:"Продолжить как {{userName}}"},login:{anonymous:"Сбер ID",personal:"Войти как {{userName}}"},fill:{anonymous:"Заполнить со Сбер ID",personal:"Войти как {{userName}}"},custom:{anonymous:"Войти по Сбер ID",personal:"Войти как {{userName}}"}},Pe=function(){function e(e,n,i){var r,o,s,a,c,u,l,d,f=this;this.config={personalization:!!e.personalization,debug:!!e.debug,sa:!!(null===(r=e.sa)||void 0===r?void 0:r.enable),changeUser:!!e.changeUser,type:(null===(o=e.buttonProps)||void 0===o?void 0:o.type)||"default",loader:null===(a=null===(s=e.buttonProps)||void 0===s?void 0:s.loader)||void 0===a||a,logo:null===(u=null===(c=e.buttonProps)||void 0===c?void 0:c.logo)||void 0===u||u,size:(null===(l=e.buttonProps)||void 0===l?void 0:l.size)||"default"},this.container=n,this.text=t(t({},Be[this.config.type]),"custom"===this.config.type?null===(d=e.buttonProps)||void 0===d?void 0:d.custom:{}),this.userHelper=Ne.getInstance(),this.userHelper.setListener(this.handleUserChange.bind(this)),this.link=this.create(),i&&this.link.addEventListener("click",(function(e){i(e,f.link)})),this.container.appendChild(this.link),this.config.changeUser&&this.initChangeUser()}return e.prototype.initChangeUser=function(){var e=this;this.changeUserElement=this.link&&this.link.querySelector(".sbid-button-change-user")||void 0,this.changeUserElement&&(this.changeUserPopupElement=this.changeUserElement.querySelector(".sbid-button-change-user__popup")||void 0,this.changeUserElement.addEventListener("click",(function(t){if(e.changeUserElement){var n="none"===e.changeUserElement.dataset.stage;e.changeUserElement.dataset.stage=n?"popup":"none",n&&e.changeUserPopupElement&&m(e.changeUserPopupElement,(function(){e.changeUserElement&&(e.changeUserElement.dataset.stage="none")}))}t.preventDefault(),t.stopPropagation()})),this.changeUserPopupElement&&this.changeUserPopupElement.addEventListener("click",this.changeUser.bind(this)))},e.prototype.changeUser=function(e){return n(this,void 0,void 0,(function(){var t,n=this;return i(this,(function(i){switch(i.label){case 0:return _(),this.config.sa&&A({eventCategory:"Login",eventAction:"sberid_Change_User_Button_Click",eventType:"Click"}),this.config.debug&&w(["Сбрасываем информацию о пользователе"],"info"),[4,this.userHelper.resetUser()];case 1:return i.sent()?(this.config.debug&&w(["Данные о пользователе удалены"],"success"),this.config.sa&&A({eventCategory:"Login",eventAction:"sberid_Change_User_Result",eventType:"Result",description:"success"}),this.changeUserElement&&(this.changeUserElement.dataset.stage="none")):(this.config.debug&&w(["Ошибка при удалении данных о пользователе"],"error"),this.config.sa&&A({eventCategory:"Login",eventAction:"sberid_Change_User_Result",eventType:"Result",description:"fail"}),this.changeUserElement&&(this.changeUserElement.dataset.stage,(t=this.changeUserElement.querySelector(".sbid-button-change-user__error")||void 0)&&(t.innerHTML="Сервис временно недоступен",m(t,(function(){n.changeUserElement&&(n.changeUserElement.dataset.stage="none")}))))),S(),e.preventDefault(),e.stopPropagation(),[2]}}))}))},e.prototype.handleUserChange=function(e){Ce(e,this.user)||(this.user=e,this.setText())},e.prototype.getSize=function(){var e=document.createElement("div"),t=document.getElementsByTagName("body")[0],n=this.create();e.className="sbid-check-button-container",e.id="i-sbid-check-button-container",e.appendChild(n),t.appendChild(e);var i=n.getBoundingClientRect();return e.remove(),i},e.prototype.isEnoughSpaceFromPersonalization=function(){var e,t=this.getSize(),n=this.config.changeUser?24:0;return!(t.width+n>=(null===(e=this.container.getBoundingClientRect())||void 0===e?void 0:e.width))},e.prototype.create=function(){var e=document.createElement("a");return e.className="sbid-button sbid-button--".concat(this.config.size),e.id="i-sbid-button-".concat(O(6)),e.dataset.personalization="false",e.innerHTML="\n ".concat(this.config.logo?'<span class="sbid-button__logo"><svg style="display: block" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M13 0C16.0927 0 18.9337 1.08103 21.1657 2.88421L18.6371 4.74793C17.0315 3.64848 15.0899 3.00354 13 3.00354C7.48924 3.00354 3.00587 7.48999 3.00587 13.0013C3.00587 18.5126 7.48924 22.9965 13 22.9965C18.5134 22.9965 22.9968 18.5126 22.9968 13.0013C22.9968 12.9118 22.9941 12.8223 22.9924 12.7328L25.7912 10.6699C25.9289 11.4245 26 12.2055 26 13.0013C26 20.1807 20.1795 26 13 26C5.82135 26 0 20.1807 0 13.0013C0 5.81931 5.82135 0 13 0ZM23.2856 5.05241C23.9006 5.84651 24.4262 6.71169 24.8456 7.63565L13.0002 16.3673L8.05093 13.2628V9.52921L13.0002 12.6337L23.2856 5.05241Z" fill=":logoFill:"/></svg></span>':"",'\n <span class="sbid-button__text">').concat(this.getText().text,"</span>\n ").concat(this.config.changeUser?'<span class="sbid-button-change-user" data-stage="none"><svg width="4" height="18" viewBox="0 0 4 18" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="2" fill="white"/><circle cx="2" cy="9" r="2" fill="white"/><circle cx="2" cy="16" r="2" fill="white"/></svg><span class="sbid-button-change-user__popup">Сменить пользователя</span></span><span class="sbid-button-change-user__error"></span></span>':"","\n ").concat(this.config.loader?'<span class="sbid-button-loader"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve"><path opacity="0.2" fill="#fff" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946 s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634 c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/><path fill="#fff" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 C22.32,8.481,24.301,9.057,26.013,10.047z"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 20 20" to="360 20 20" dur="0.5s" repeatCount="indefinite"/></path></svg></span>':"","\n "),e},e.prototype.getText=function(){if(this.config.personalization&&this.user){var e=[];return this.user.firstname&&e.push(this.user.firstname),this.user.surname&&e.push(this.user.surname),{text:this.text.personal.replace("{{userName}}",e.join(" ")),personalization:!0}}return{text:this.text.anonymous,personalization:!1}},e.prototype.setText=function(){if(this.isEnoughSpaceFromPersonalization()&&this.link){var e=this.link.querySelector(".sbid-button__text"),t=this.getText();e&&(e.innerHTML=t.text),this.link.dataset.personalization=t.personalization.toString()}},e.prototype.disable=function(){var e;null===(e=this.link)||void 0===e||e.setAttribute("disabled","disabled")},e.prototype.enable=function(){var e;null===(e=this.link)||void 0===e||e.removeAttribute("disabled")},e.prototype.isDisabled=function(){var e;return null===(e=this.link)||void 0===e?void 0:e.hasAttribute("disabled")},e.prototype.setUrl=function(e){var t;null===(t=this.link)||void 0===t||t.setAttribute("href",e)},e.prototype.getButtonElement=function(){return this.link},e}(),De=function(n){function i(e,i,r){var o=t(t({},e),{buttonProps:{type:"resume"}});return n.call(this,o,i,r)||this}return function(t,n){function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}(i,n),i.prototype.isEnoughSpaceFromPersonalization=function(){return!0},i}(Pe),Ue={autoCloseDelay:90,autoClose:!0,enable:!1,animation:!0,sa:!1,position:"bottom-right",offset:{top:30,bottom:30,left:30,right:30},debug:!1,fastLogin:!1},je=function(e,t,n,i){return new Promise((function(r){var o=+new Date;n.style.opacity=e;var s=function(){n.style.opacity="".concat(+n.style.opacity+t*(+new Date-o)/i),o=+new Date,+n.style.opacity<1?requestAnimationFrame&&requestAnimationFrame(s)||setTimeout(s,16):r()};s()}))},Fe=je.bind(null,"0",1),We=je.bind(null,"1",-1),ze=function(){function e(n){var i,r,o;this.parser=fe.getParser(window.navigator.userAgent),this.onSuccessCallback=function(){},this.onErrorCallback=function(){},this.notification=document.createElement("div"),this.config=t(t(t({},Ue),n.notification),{position:e.getDefaultPosition(n.notification&&n.notification.position),fastLogin:!!(null===(i=n.fastLogin)||void 0===i?void 0:i.enable),sa:!!(null===(r=n.sa)||void 0===r?void 0:r.enable),debug:!!n.debug}),this.userHelper=Ne.getInstance(),this.userHelper.setConfig({baseUrl:n.baseUrl,clientId:n.oidc.client_id}),this.userHelper.setListener(this.handleUserChange.bind(this)),this.universalLinkDetect=new xe(n),this.fastLogin=new Le(n),this.config.sa&&"auto"===(null===(o=null==n?void 0:n.sa)||void 0===o?void 0:o.init)&&E(n),n.onSuccessCallback&&(this.onSuccessCallback=n.onSuccessCallback),n.onErrorCallback&&(this.onErrorCallback=n.onErrorCallback),this.create(n),this.setOIDCParams(n)}return e.prototype.handleUserChange=function(e){Ce(this.user,e)||(this.user=e,e||this.hide())},e.prototype.setOIDCParams=function(e){return n(this,void 0,void 0,(function(){var n,r,o,s;return i(this,(function(i){switch(i.label){case 0:return n=this.universalLinkDetect.buildOidcParams(e.oidc),r=Object.keys(n),o=r.includes("app_redirect_uri")||r.includes("authApp")||"false"===r.is_universal_link,!e.mweb2app||o?[3,2]:[4,this.universalLinkDetect.run(n)];case 1:retur