@vkontakte/superappkit
Advanced tools
Comparing version 1.15.0-beta.1.0 to 1.15.0-beta.2.0
@@ -18,1 +18,2 @@ import { FrameSettings } from '#/common/types'; | ||
export declare function makeFrame(src?: string, frameSettings?: FrameSettings): HTMLIFrameElement; | ||
export declare function makeModalFrame(src?: string): HTMLIFrameElement; |
@@ -7,2 +7,10 @@ export declare enum DataPolicyEventsSDK { | ||
} | ||
export declare enum PolicyAgreementsEventsSDK { | ||
SHOW_POLICY_AGREEMENTS = "VKSDKOneTapAuthPolicyAgreementsShow", | ||
HIDE_POLICY_AGREEMENTS = "VKSDKOneTapAuthPolicyAgreementsHide", | ||
ACCEPT_POLICY_AGREEMENTS = "VKSDKOneTapAuthPolicyAgreementsAccept", | ||
DECLINE_POLICY_AGREEMENTS = "VKSDKOneTapAuthPolicyAgreementsDecline", | ||
POLICY_AGREEMENTS_ERROR = "VKSDKOneTapAuthPolicyAgreementsError", | ||
SHOW_DATA_POLICY = "VKSDKOneTapAuthPolicyAgreementsShowDataPolicy" | ||
} | ||
export declare enum AuthCaptchaEventsSDK { | ||
@@ -29,3 +37,5 @@ CAPTCHA_SUCCESS = "VKSDKAuthCaptchaSuccess", | ||
SHOW_LOGIN = "VKSDKButtonOneTapAuthShowLogin", | ||
SHOW_LOGIN_OPTIONS = "VKSDKButtonOneTapAuthShowLoginOptions" | ||
SHOW_LOGIN_OPTIONS = "VKSDKButtonOneTapAuthShowLoginOptions", | ||
SHOW_AGREEMENTS_DIALOG = "VKSDKButtonOneTapAuthShowAgreementsDialog", | ||
START_AUTHORIZE = "VKSDKButtonOneTapAuthStartAuthorize" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { AuthButtonParams, AuthButtonType, ButtonOneTapAuthParams, RedirectAuthParams, UserVisibleAuthParams, VKAuthSuccessResult, VKDataPolicyResult, VKOneTapAuthResult, VKOneTapAuthButtonResult, VKUserVisibleAuthResult } from './types'; | ||
import { AuthButtonParams, AuthButtonType, ButtonOneTapAuthParams, RedirectAuthParams, UserVisibleAuthParams, VKAuthSuccessResult, VKDataPolicyResult, VKOneTapAuthButtonResult, VKOneTapAuthResult, VKUserVisibleAuthResult } from './types'; | ||
declare class Connect { | ||
@@ -10,2 +10,3 @@ private readonly flags; | ||
readonly userDataPolicy: (uuid: string) => VKDataPolicyResult; | ||
private readonly userPolicyAgreements; | ||
private readonly captcha; | ||
@@ -12,0 +13,0 @@ readonly userVisibleAuth: (params?: UserVisibleAuthParams | undefined) => Promise<VKUserVisibleAuthResult>; |
@@ -1,2 +0,2 @@ | ||
import { AuthCaptchaEventsSDK, ButtonOneTapAuthEventsSDK, DataPolicyEventsSDK, FloatingOneTapAuthEventsSDK, OneTapAuthEventsSDK } from '#/connect/events'; | ||
import { AuthCaptchaEventsSDK, ButtonOneTapAuthEventsSDK, DataPolicyEventsSDK, FloatingOneTapAuthEventsSDK, OneTapAuthEventsSDK, PolicyAgreementsEventsSDK } from '#/connect/events'; | ||
import { URLParams } from '#/common/utils'; | ||
@@ -33,3 +33,3 @@ export declare type VKSilentAuthPayload = { | ||
export declare type VKUserVisibleAuthResult = VKAuthSuccessResult | VKOAuthCallback; | ||
export declare type BridgeEvents = OneTapAuthEventsSDK | FloatingOneTapAuthEventsSDK | ButtonOneTapAuthEventsSDK | DataPolicyEventsSDK | AuthCaptchaEventsSDK; | ||
export declare type BridgeEvents = OneTapAuthEventsSDK | FloatingOneTapAuthEventsSDK | ButtonOneTapAuthEventsSDK | DataPolicyEventsSDK | AuthCaptchaEventsSDK | PolicyAgreementsEventsSDK; | ||
export declare type RedirectAuthParams = { | ||
@@ -60,2 +60,7 @@ url: string; | ||
}; | ||
export declare type VKDataPolicyAgreementsResult = { | ||
show: () => Promise<any>; | ||
hide: () => void; | ||
destroy: () => void; | ||
}; | ||
export declare type VKAuthCaptchaResult = { | ||
@@ -94,4 +99,5 @@ show: () => Promise<any>; | ||
export declare type ButtonOneTapAuthOptions = { | ||
showAgreements?: number; | ||
showAlternativeLogin?: number; | ||
showAgreements?: boolean | number; | ||
showAlternativeLogin?: boolean | number; | ||
showAgreementsDialog?: boolean | number; | ||
displayMode?: ButtonOneTapAuthDisplayModes; | ||
@@ -113,7 +119,3 @@ }; | ||
} | ||
export interface InviteLinkParams { | ||
name: '__sferum_invite_link'; | ||
link: string; | ||
} | ||
export declare type AuthAction = ExtendTokenParams | InviteLinkParams; | ||
export declare type AuthAction = ExtendTokenParams; | ||
export declare type AdaptivitySwitchObserver = { | ||
@@ -120,0 +122,0 @@ destroy: () => void; |
@@ -1,1 +0,1 @@ | ||
"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(n){return n&&"object"===e(n)&&"default"in n?n.default:n}Object.defineProperty(exports,"__esModule",{value:!0});var t=n(require("@babel/runtime/helpers/typeof"));require("@babel/runtime/helpers/toConsumableArray");var o=n(require("@babel/runtime/helpers/defineProperty"));function i(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function a(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?a(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass");var c,p="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",u=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=p[64*Math.random()|0];return n},d=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand"];!function(e){e[e.UNKNOWN=1]="UNKNOWN",e[e.MISSING_PARAM=2]="MISSING_PARAM",e[e.CONNECTION_LOST=3]="CONNECTION_LOST",e[e.USER_DENIED=4]="USER_DENIED",e[e.INVALID_PARAMS=5]="INVALID_PARAMS",e[e.CUSTOM=6]="CUSTOM",e[e.CONNECT_WINDOW_CLOSED=7]="CONNECT_WINDOW_CLOSED",e[e.CONNECT_WINDOW_NOT_OPENED=8]="CONNECT_WINDOW_NOT_OPENED",e[e.CONNECT_DOMAIN_NOT_ALLOWED=9]="CONNECT_DOMAIN_NOT_ALLOWED",e[e.CONNECT_UNKNOWN_SDK_MESSAGE=10]="CONNECT_UNKNOWN_SDK_MESSAGE",e[e.OLD_MISSING_PARAM=100]="OLD_MISSING_PARAM"}(c||(c={}));var l=function(){return"No params passed for load app!"},h=function(){return"Connect window was closed."},f=function(){return"Connect window was not opened."},m=function(e){return'URL domain "'.concat(e,'" is not allowed.')},A=function(e){return"This SDK message is unknown: ".concat(e)},v=!("undefined"==typeof window||!window.document||!window.document.createElement),g=v&&!!window.addEventListener,_=function(){};if(g)try{var y=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",_,y),window.removeEventListener("test",_,y)}catch(e){}!function(){if(!v)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function O(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function E(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?O(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var w={parse:function(e){if("string"!=typeof e)return{};if(!(e=e.trim().replace(/^[?#&]/,"")))return{};var n=/\?(.+)$/gi.exec(e);return(n?n[1]:e).split("&").reduce((function(e,n){var t=n.split("=");return t[1]&&(e[t[0]]=decodeURIComponent(t[1])),e}),{})},stringify:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==t(e)||null===e)return"";n=E({encode:!0},n);var o=function(e){return n.encode?encodeURIComponent(e):String(e)};return Object.keys(e).reduce((function(t,i){var r=e[i];return void 0===r?t:null===r?(n.skipNull||t.push([o(i),""].join("=")),t):Array.isArray(r)?(r.map((function(e){t.push("".concat(o(i),"[]=").concat(o(e)))})).join(),t):(t.push([o(i),o(r)].join("=")),t)}),[]).join("&")}};function T(e){return w.stringify(e)}function P(e){return Object.keys(e).filter((function(e){return d.includes(e)}))}function b(e){var n;return Boolean(null===(n=P(e))||void 0===n?void 0:n.length)}function S(e){var n=function(e){return P(e).reduce((function(n,t){return n[t]=e[t],n}),{})}(e);return btoa(JSON.stringify(n))}function D(e,n){var t,o=document.createElement("iframe");for(var i in e&&(o.src=e),o.style.cssText=null!==(t=null==n?void 0:n.cssText)&&void 0!==t?t:"",o.width="100%",o.height="100%",o.style.border="none",null==n?void 0:n.properties){var r;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(r=n.properties[i])&&void 0!==r?r:""}return o}function N(e){return e=e||Object.create(null),{on:function(n,t){(e[n]||(e[n]=[])).push(t)},off:function(n,t){e[n]&&e[n].splice(e[n].indexOf(t)>>>0,1)},emit:function(n,t){(e[n]||[]).slice().map((function(e){e(t)})),(e["*"]||[]).slice().map((function(e){e(n,t)}))}}}var C={appId:0,superAppToken:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},I={},k={events:N(),init:function(e){if(!e.appId)throw new Error("appId required");C.appId=e.appId,C.superAppToken=e.superAppToken||"",C.loginDomain=e.loginDomain||"login.vk.com",C.oauthDomain=e.oauthDomain||"oauth.vk.com",C.connectDomain=e.connectDomain||"connect.vk.com",C.appSettings=e.appSettings,C._debug=!!e._debug},get:function(){return C},setSuperAppToken:function(e){C.superAppToken=e,k.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){I.superAppToken=e},_requestSuperAppToken:function(){var e;I.superAppToken&&(e=I.superAppToken()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){I.auth=e},_requestAuth:function(){var e;I.auth&&(e=I.auth()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){I.openApp=e},_openApp:function(e){I.openApp&&I.openApp(e.app)}},M=["extend_token","__sferum_invite_link"];function L(e){return e&&M.includes(e.name)?btoa(JSON.stringify(e)):""}var K;function R(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=k.get(),o=t.appId,i=t.connectDomain,r=t.appSettings,a=s({app_id:o,response_type:"silent_token",v:"0.0.2"},e);r&&b(r)&&(a.app_settings=S(r));var c=T(a);return"https://".concat(i,"/").concat(n,"?").concat(c)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(K||(K={}));var U=[K.Default,K.NamePhone,K.PhoneName];var x,H,V,W,j,F=function e(n){var t=this;i(this,e),r(this,"handler",(function(){return{}})),r(this,"config",void 0),r(this,"destroy",(function(){delete t.config,window.removeEventListener("message",t.handleMessage)})),r(this,"onMessage",(function(e){t.handler=e})),r(this,"sendMessage",(function(e){t.config.iframe.contentWindow.postMessage(s({type:"vk-sak-sdk"},e),t.config.origin)})),r(this,"handleMessage",(function(e){t.config.origin&&e.origin===t.config.origin&&e.source===t.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&t.handler(e.data)})),this.config=n,window.addEventListener("message",this.handleMessage)};!function(e){e.SHOW_DATA_POLICY="VKSDKOneTapAuthConnectDataPolicy",e.HIDE_DATA_POLICY="VKSDKOneTapAuthDataPolicyClose",e.DATA_POLICY_RESULT="VKSDKOneTapAuthDataPolicyResult",e.SHOW_CAPTCHA="VKSDKOneTapAuthDataPolicyShowCaptcha"}(x||(x={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(H||(H={})),function(e){e.PHONE_VALIDATION_NEEDED="VKSDKOneTapAuthPhoneValidationNeeded",e.FULL_AUTH_NEEDED="VKSDKOneTapAuthFullAuthNeeded",e.AUTH_DATA_LOADED="VKSDKOneTapAuthDataLoaded",e.NOT_AUTHORIZED="VKSDKOneTapAuthNotAuthorized",e.LOGIN_SUCCESS="VKSDKOneTapAuthLoginSuccess",e.RESIZE_FRAME="VKSDKOneTapResizeFrame",e.SHOW_CAPTCHA="VKSDKOneTapShowCaptcha",e.VALIDATE_CAPTCHA="VKSDKOneTapValidateCaptcha"}(V||(V={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(W||(W={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions"}(j||(j={}));var G,z,q,Y=new function e(){var n=this;i(this,e),r(this,"flags",null),r(this,"silentAuth",(function(){var e=k.get(),n=e.loginDomain,t=e.appId,o=u(),i="https://".concat(n,"/?act=connect&app_id=").concat(t,"&response_type=").concat("silent_token","&uuid=").concat(o,"&v=").concat("0.0.2"),r=new XMLHttpRequest;return r.open("GET",i,!0),r.responseType="json",r.withCredentials=!0,new Promise((function(e,n){r.onload=function(){r.response?e({provider:"vk",payload:r.response}):n()},r.onerror=function(){n()},r.send()}))})),r(this,"oneTapAuth",(function(e,t){if(console.warn("Connect.oneTapAuth method is deprecated. Use Connect.floatingOneTapAuth and Connect.buttonOneTapAuth methods."),!["floating","button"].includes(e))return null;switch(e){case"button":return n.buttonOneTapAuth(t);case"floating":return n.floatingOneTapAuth(t);default:return null}})),r(this,"floatingOneTapAuth",(function(e){var t,o,i=function(){var e,n=window.innerWidth,t=n<=768;return{destroy:function(){return window.removeEventListener("resize",e)},isAdaptive:function(){return t},observe:function(o){e=function(){var e=window.innerWidth;n>768&&e<=768?o(t=!0):n<=768&&e>768&&o(t=!1),n=e},window.addEventListener("resize",e)}}}(),r=(t=i.isAdaptive(),o=t?"314px":"334px",{pageUrl:"floating_one_tap_auth",pageUrlParams:{adaptive:t?1:0},frameStyles:t?"\n display: none;\n position: fixed;\n bottom: 0;\n right: 0;\n max-width: 100%;\n width: 100%;\n height: ".concat(o,";\n "):"\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n max-width: 400px;\n width: 100%;\n height: ".concat(o,";\n ")});if(!r)throw new Error("options were not set");var a=u(),c=D(R(s({origin:location.protocol+"//"+location.host,uuid:a},r.pageUrlParams),r.pageUrl),{cssText:r.frameStyles}),p=new F({iframe:c,origin:"https://"+k.get().connectDomain});i.observe((function(e){p.sendMessage({handler:W.ADAPTIVITY_CHANGE,params:{uuid:a,is_adaptive:e}}),e?(c.style.maxWidth="100%",c.style.top="auto",c.style.bottom="0"):(c.style.maxWidth="400px",c.style.top="0",c.style.bottom="auto"),c.style.display="none"})),document.body.appendChild(c);var d=function(){p.sendMessage({handler:V.RESIZE_FRAME,params:{uuid:a}})};window.addEventListener("resize",d);var l=function(){c&&(c.remove(),c=null),window.removeEventListener("resize",d),i&&i.destroy(),p.destroy()},h=new Promise((function(t){p.onMessage((function(o){if(o.params.uuid===a)switch(o.handler){case V.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:a,error:"not_authorized"}}),l(),t(o.handler);break;case V.RESIZE_FRAME:c.style.height="".concat(o.params.height,"px");break;case W.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:a}}),l();break;case W.ADAPTIVITY_CHANGED:c.style.display="block";break;case V.AUTH_DATA_LOADED:c.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,p,e)}}))}));return{getFrame:function(){return c},destroy:l,authReadyPromise:h}})),r(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){var o,i;n.display=e.displayMode&&U.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=null!==(o=e.showAgreements)&&void 0!==o?o:0,n.show_alternative_login=null!==(i=e.showAlternativeLogin)&&void 0!==i?i:0;t+=n.show_alternative_login?56:0,t+=n.show_agreements?80:0}return{pageUrl:"button_one_tap_auth",pageUrlParams:n,frameStyles:"\n height: ".concat(t,"px;\n ")}}(e.options);if(!t)throw new Error("options were not set");var o=u(),i=D(R(s({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),r=e.container;r&&r.appendChild(i);var a=new F({iframe:i,origin:"https://"+k.get().connectDomain}),c=function(){a.sendMessage({handler:V.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",c);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",c),a.destroy()},authReadyPromise:new Promise((function(t){a.onMessage((function(r){if(r.params.uuid===o)switch(r.handler){case V.RESIZE_FRAME:i.style.height="".concat(r.params.height,"px");break;case V.NOT_AUTHORIZED:t(r.handler);break;case j.SHOW_LOGIN:case j.SHOW_LOGIN_OPTIONS:e.callback({type:r.handler,payload:{uuid:o}});break;case V.AUTH_DATA_LOADED:t(r.handler);default:n.handleOneTapEvents(r,a,e)}}))}))}})),r(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case V.AUTH_DATA_LOADED:t.sendMessage({handler:V.RESIZE_FRAME,params:{uuid:i}});break;case V.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:s({uuid:i},e.params)});break;case V.SHOW_CAPTCHA:var r=n.captcha(i,{captcha_sid:e.params.captcha_sid,captcha_img:e.params.captcha_img});r.show().then((function(e){t.sendMessage({handler:H.CAPTCHA_SUCCESS,params:s({uuid:i},e)})})).catch((function(){t.sendMessage({handler:H.CAPTCHA_FAIL,params:{uuid:i}}),r.destroy()}));break;case x.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:x.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:x.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case V.FULL_AUTH_NEEDED:case V.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),r(this,"userDataPolicy",(function(e){var t=R({origin:location.protocol+"//"+location.host,uuid:e},"user_data_policy"),o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),r=D(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(r);var a=new F({iframe:r,origin:"https://"+k.get().connectDomain}),c=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){a.onMessage((function(i){switch(i.handler){case x.HIDE_DATA_POLICY:c(),t();break;case x.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){a.sendMessage({handler:H.CAPTCHA_SUCCESS,params:s({uuid:e},n)}),r.style.display="block"})).catch((function(){a.sendMessage({handler:H.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),a.destroy()}}})),r(this,"captcha",(function(e,n){var t=R(s({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=D(t,{cssText:"\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n ")});document.body.appendChild(i);var r=new F({iframe:i,origin:"https://"+k.get().connectDomain}),a=function(){document.body.removeChild(i),r.destroy()};return{show:function(){return i.style.display="block",new Promise((function(e,n){r.onMessage((function(t){switch(t.handler){case H.CAPTCHA_SUCCESS:e(t.params),a();break;default:n(),a()}}))}))},destroy:a}})),r(this,"userVisibleAuth",(function(e){var t=u(),o={origin:location.protocol+"//"+location.host,uuid:t};(null==e?void 0:e.screen)&&(o.screen=e.screen);var i=L(null==e?void 0:e.action);i&&(o.action=i);var r=R(o);n.flags&&(r="".concat(r,"#").concat(T(n.flags)));var a=screen.height/2-280,s=screen.width/2-410,p=window.open(r,"_blank","top=".concat(a,",left=").concat(s,",width=").concat(820,",height=").concat(560,",location"));if(!p){var d={code:c.CONNECT_WINDOW_NOT_OPENED,reason:f()};return Promise.reject(d)}return new Promise((function(e,n){var o=setInterval((function(){if(!p||p.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:c.CONNECT_WINDOW_CLOSED,reason:h()};n(e)}}),1e3);function i(r){if(r.source===p&&p)if(window.removeEventListener("message",i),clearInterval(o),".vk.com"===r.origin.slice(r.origin.length-".vk.com".length))if(r.data.action==="vk_connect_response"+t){var a=r.data.payload;p.close(),e({provider:"vk",payload:a})}else if(r.data.action==="oauth_callback"+t)e({provider:r.data.payload.name}),p.close();else{p.close();var s={code:c.CONNECT_UNKNOWN_SDK_MESSAGE,reason:A(JSON.stringify(r.data))};n(s)}else{p.close();var u={code:c.CONNECT_DOMAIN_NOT_ALLOWED,reason:m(r.origin)};n(u)}}window.addEventListener("message",i)}))})),r(this,"redirectAuth",(function(e){var n=u(),t={redirect_uri:e.url,uuid:n};(null==e?void 0:e.state)&&(t.redirect_state=e.state),(null==e?void 0:e.screen)&&(t.screen=e.screen);var o=L(null==e?void 0:e.action);o&&(t.action=o);var i=R(t);location.assign(i)}))};!function(e){e.APP_CLOSE="VKWebAppClose",e.APP_READY="VKSDKMiniAppReady",e.RESIZE="VKSDKMiniAppResize",e.APP_INIT_CONFIG="VKSDKMiniAppInitConfig",e.OPEN_APP="VKWebAppOpenApp",e.OPEN_PAY_FORM="VKWebAppOpenPayForm",e.ACTION_DONE="VKWebAppActionDone"}(G||(G={})),(z=exports.MiniAppEvents||(exports.MiniAppEvents={})).OPEN="open",z.HIDE="hide",z.CLOSE="close",z.SHOW="show",z.MESSAGE="message",z.CREATE_APP="createapp",function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp"}(q||(q={}));var Z;!function(e){e.INIT="ConnectProfileInit"}(Z||(Z={}));var J={OneTapAuthEventsSDK:V,FloatingOneTapAuthEventsSDK:W,ButtonOneTapAuthEventsSDK:j,DataPolicyEventsSDK:x,AuthCaptchaEventsSDK:H};exports.Config=k,exports.Connect=Y,exports.ConnectEvents=J,exports.MiniApp=function e(n){var t=this;i(this,e),r(this,"events",void 0),r(this,"iframe",void 0),r(this,"bridge",void 0),r(this,"loading",void 0),r(this,"readyPromiseResolve",null),r(this,"readyPromise",null),r(this,"bodyOverflowValue",""),r(this,"params",void 0),r(this,"child",null),r(this,"open",(function(e,n){return t.loading?(t.iframe.src=t.getMiniAppUrl(e,n),t.loading=new Promise((function(e){t.iframe.onload=function(){t.iframe.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e}))):t.preload(e,n).catch(console.error),t.iframe.style.display="block",t.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",t.loading.then(t.handleResize).catch(console.error),t.events.emit(exports.MiniAppEvents.OPEN),t.readyPromise})),r(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.HIDE)})),r(this,"close",(function(){window.document.body.style.overflowX="",k.events.off("superAppToken",t.onSuperAppToken),t.iframe&&t.iframe.remove(),t.bridge&&t.bridge.destroy(),delete t.iframe,delete t.bridge,window.removeEventListener("resize",t.handleResize),t.events.emit(exports.MiniAppEvents.CLOSE)})),r(this,"show",(function(){if(!t.loading)throw new Error('App is not loaded, use "open" or "preload" methods');t.iframe.style.display="block",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.SHOW)})),r(this,"preload",(function(e,n){var o=document.createElement("iframe"),i=window.innerHeight,r=isFinite(t.params.zIndex)?t.params.zIndex:999999;return o.src=t.getMiniAppUrl(e,n),o.style.cssText="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(i,"px;\n min-height: ").concat(i,"px;\n border: none;\n z-index: ").concat(r,";\n "),t.iframe=o,document.body.appendChild(t.iframe),k.events.on("superAppToken",t.onSuperAppToken),t.bridge=new F({iframe:t.iframe,origin:"https://"+k.get().connectDomain}),t.bridge.onMessage(t.handleMessage),window.addEventListener("resize",t.handleResize),t.loading=new Promise((function(e){o.onload=function(){o.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e})),t.loading})),r(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),r(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:q.SUPERAPP_TOKEN,params:{result:e}})})),r(this,"handleMessage",(function(e){switch(e.handler){case G.APP_CLOSE:t.hide();break;case G.APP_READY:t.resolveReadyPromise(),t.handleUpdateConfig();break;case G.OPEN_APP:t.openMiniapp(e.params);break;case G.OPEN_PAY_FORM:t.openPayForm(e.params);break;case q.SUPERAPP_TOKEN:k._requestSuperAppToken();break;case q.AUTH_NEEDED:k._requestAuth();break;default:t.events.emit(exports.MiniAppEvents.MESSAGE,e)}})),r(this,"handleResize",(function(){if(t.iframe){var e=innerWidth,n=innerHeight;t.iframe.style.height="".concat(n,"px"),t.iframe.style.minHeight="".concat(n,"px"),t.bridge.sendMessage({handler:G.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),r(this,"handleUpdateConfig",(function(){t.bridge.sendMessage({handler:G.APP_INIT_CONFIG,params:{fullMode:t.params.fullMode}})})),r(this,"getMiniAppUrl",(function(e,n){var o=k.get(),i=o.connectDomain,r=o.appId,a=o.superAppToken,s=o._debug,c=T({app:t.params.app,host_app_id:r,debug:s?"1":"",localhost:s?"1":"",superapp_token:a,app_query:e?JSON.stringify(e):"",app_hash:n||""});return"https://".concat(i,"/mini_app?").concat(c)})),r(this,"resolveReadyPromise",(function(){t.readyPromise&&t.readyPromiseResolve&&(t.readyPromiseResolve(),t.readyPromise=null,t.readyPromiseResolve=null)})),r(this,"openMiniapp",(function(n){t.child=new e({app:n.app_id}),t.events.emit(exports.MiniAppEvents.CREATE_APP,{app:t.child,location:n.location})})),r(this,"openPayForm",(function(n){var o=s({},n.params);o.data&&(o.data=JSON.stringify(o.data));var i=s({},o,{app_id:n.app_id,action:n.action}),r=new e({app:6217559});r.open(i).then((function(){return t.hide()})).catch(console.error),r.events.on(exports.MiniAppEvents.MESSAGE,(function(e){t.handleVKPayFormMessage(e),r.close(),t.show()})),r.events.on(exports.MiniAppEvents.HIDE,(function(){r.close(),t.close()}))})),r(this,"handleVKPayFormMessage",(function(e){e.handler===G.ACTION_DONE&&t.sendMessage(e)})),this.params=s({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=N()},exports.Profile=function e(){var n=this;i(this,e),r(this,"iframe",void 0),r(this,"config",void 0),r(this,"bridge",void 0),r(this,"iframeLoadPromise",void 0),r(this,"load",(function(e){if(!e.container)throw new Error("container is null");if(!e)throw new Error(l());return n.iframe||n.preload(e),n.iframeLoadPromise})),r(this,"remove",(function(){n.iframe&&n.iframe.parentNode&&n.iframe.parentNode.removeChild(n.iframe),n.destroy()})),r(this,"preload",(function(e){n.config=e;var t=document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.minHeight="100%",e.container.appendChild(t),n.setup(t)})),r(this,"setup",(function(e){k.events.on("superAppToken",n.onSuperAppToken),e.src=n.getProfileUrl(),n.iframe=e,n.iframeLoadPromise=new Promise((function(n){e.onload=function(){return n(e)}})),n.bridge=new F({iframe:n.iframe,origin:"https://"+k.get().connectDomain}),n.bridge.onMessage(n.handleMessage)})),r(this,"destroy",(function(){k.events.off("superAppToken",n.onSuperAppToken),n.bridge.destroy(),delete n.iframe,delete n.iframeLoadPromise,delete n.bridge})),r(this,"onSuperAppToken",(function(e){if(e&&n.iframe){var t=n.iframe;n.destroy(),n.setup(t)}})),r(this,"handleMessage",(function(e){switch(e.handler){case Z.INIT:n.handleInitApp().catch(console.error);break;case q.SUPERAPP_TOKEN:k._requestSuperAppToken();break;case q.AUTH_NEEDED:k._requestAuth();break;case q.OPEN_APP:k._openApp(e.params)}})),r(this,"handleInitApp",(function(){return Promise.resolve()})),r(this,"getProfileUrl",(function(){var e=k.get(),t=e.connectDomain,o=e.appId,i=e.superAppToken,r=e._debug,a=n.config.widgets,s=T({host_app_id:o,debug:r?"1":"",localhost:r?"1":"",superapp_token:i,widgets:a?a.join(","):""});return"https://".concat(t,"/super_profile?").concat(s)}))}; | ||
"use strict";function e(n){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(n)}function n(n){return n&&"object"===e(n)&&"default"in n?n.default:n}Object.defineProperty(exports,"__esModule",{value:!0});var t=n(require("@babel/runtime/helpers/typeof"));require("@babel/runtime/helpers/toConsumableArray");var o=n(require("@babel/runtime/helpers/defineProperty"));function i(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function s(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?r(Object(t),!0).forEach((function(n){a(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):r(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}require("@babel/runtime/helpers/classCallCheck"),require("@babel/runtime/helpers/createClass");var c,p="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",u=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=p[64*Math.random()|0];return n},d=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand"];!function(e){e[e.UNKNOWN=1]="UNKNOWN",e[e.MISSING_PARAM=2]="MISSING_PARAM",e[e.CONNECTION_LOST=3]="CONNECTION_LOST",e[e.USER_DENIED=4]="USER_DENIED",e[e.INVALID_PARAMS=5]="INVALID_PARAMS",e[e.CUSTOM=6]="CUSTOM",e[e.CONNECT_WINDOW_CLOSED=7]="CONNECT_WINDOW_CLOSED",e[e.CONNECT_WINDOW_NOT_OPENED=8]="CONNECT_WINDOW_NOT_OPENED",e[e.CONNECT_DOMAIN_NOT_ALLOWED=9]="CONNECT_DOMAIN_NOT_ALLOWED",e[e.CONNECT_UNKNOWN_SDK_MESSAGE=10]="CONNECT_UNKNOWN_SDK_MESSAGE",e[e.OLD_MISSING_PARAM=100]="OLD_MISSING_PARAM"}(c||(c={}));var l=function(){return"No params passed for load app!"},h=function(){return"Connect window was closed."},f=function(){return"Connect window was not opened."},A=function(e){return'URL domain "'.concat(e,'" is not allowed.')},m=function(e){return"This SDK message is unknown: ".concat(e)},g=!("undefined"==typeof window||!window.document||!window.document.createElement),E=g&&!!window.addEventListener,_=function(){};if(E)try{var v=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",_,v),window.removeEventListener("test",_,v)}catch(e){}!function(){if(!g)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function O(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function y(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?O(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):O(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var T={parse:function(e){if("string"!=typeof e)return{};if(!(e=e.trim().replace(/^[?#&]/,"")))return{};var n=/\?(.+)$/gi.exec(e);return(n?n[1]:e).split("&").reduce((function(e,n){var t=n.split("=");return t[1]&&(e[t[0]]=decodeURIComponent(t[1])),e}),{})},stringify:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==t(e)||null===e)return"";n=y({encode:!0},n);var o=function(e){return n.encode?encodeURIComponent(e):String(e)};return Object.keys(e).reduce((function(t,i){var a=e[i];return void 0===a?t:null===a?(n.skipNull||t.push([o(i),""].join("=")),t):Array.isArray(a)?(a.map((function(e){t.push("".concat(o(i),"[]=").concat(o(e)))})).join(),t):(t.push([o(i),o(a)].join("=")),t)}),[]).join("&")}};function S(e){return T.stringify(e)}function w(e){return Object.keys(e).filter((function(e){return d.includes(e)}))}function P(e){var n;return Boolean(null===(n=w(e))||void 0===n?void 0:n.length)}function D(e){var n=function(e){return w(e).reduce((function(n,t){return n[t]=e[t],n}),{})}(e);return btoa(JSON.stringify(n))}function b(e,n){var t,o=document.createElement("iframe");for(var i in e&&(o.src=e),o.style.cssText=null!==(t=null==n?void 0:n.cssText)&&void 0!==t?t:"",o.width="100%",o.height="100%",o.style.border="none",null==n?void 0:n.properties){var a;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(a=n.properties[i])&&void 0!==a?a:""}return o}function C(e){return e=e||Object.create(null),{on:function(n,t){(e[n]||(e[n]=[])).push(t)},off:function(n,t){e[n]&&e[n].splice(e[n].indexOf(t)>>>0,1)},emit:function(n,t){(e[n]||[]).slice().map((function(e){e(t)})),(e["*"]||[]).slice().map((function(e){e(n,t)}))}}}var N={appId:0,superAppToken:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},I={},k={events:C(),init:function(e){if(!e.appId)throw new Error("appId required");N.appId=e.appId,N.superAppToken=e.superAppToken||"",N.loginDomain=e.loginDomain||"login.vk.com",N.oauthDomain=e.oauthDomain||"oauth.vk.com",N.connectDomain=e.connectDomain||"connect.vk.com",N.appSettings=e.appSettings,N._debug=!!e._debug},get:function(){return N},setSuperAppToken:function(e){N.superAppToken=e,k.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){I.superAppToken=e},_requestSuperAppToken:function(){var e;I.superAppToken&&(e=I.superAppToken()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){I.auth=e},_requestAuth:function(){var e;I.auth&&(e=I.auth()),e&&e.then((function(e){return k.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){I.openApp=e},_openApp:function(e){I.openApp&&I.openApp(e.app)}},M=["extend_token"];function L(e){return e&&M.includes(e.name)?btoa(JSON.stringify(e)):""}var K;function R(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=k.get(),o=t.appId,i=t.connectDomain,a=t.appSettings,r=s({app_id:o,response_type:"silent_token",v:"0.0.2"},e);a&&P(a)&&(r.app_settings=D(a));var c=S(r);return"https://".concat(i,"/").concat(n,"?").concat(c)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(K||(K={}));var H=[K.Default,K.NamePhone,K.PhoneName];function x(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}var U,V,W,G,j,F,Y=function e(n){var t=this;i(this,e),a(this,"handler",(function(){return{}})),a(this,"config",void 0),a(this,"destroy",(function(){delete t.config,window.removeEventListener("message",t.handleMessage)})),a(this,"onMessage",(function(e){t.handler=e})),a(this,"sendMessage",(function(e){t.config.iframe.contentWindow.postMessage(s({type:"vk-sak-sdk"},e),t.config.origin)})),a(this,"handleMessage",(function(e){t.config.origin&&e.origin===t.config.origin&&e.source===t.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&t.handler(e.data)})),this.config=n,window.addEventListener("message",this.handleMessage)};!function(e){e.SHOW_DATA_POLICY="VKSDKOneTapAuthConnectDataPolicy",e.HIDE_DATA_POLICY="VKSDKOneTapAuthDataPolicyClose",e.DATA_POLICY_RESULT="VKSDKOneTapAuthDataPolicyResult",e.SHOW_CAPTCHA="VKSDKOneTapAuthDataPolicyShowCaptcha"}(U||(U={})),function(e){e.SHOW_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsShow",e.HIDE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsHide",e.ACCEPT_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsAccept",e.DECLINE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsDecline",e.POLICY_AGREEMENTS_ERROR="VKSDKOneTapAuthPolicyAgreementsError",e.SHOW_DATA_POLICY="VKSDKOneTapAuthPolicyAgreementsShowDataPolicy"}(V||(V={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(W||(W={})),function(e){e.PHONE_VALIDATION_NEEDED="VKSDKOneTapAuthPhoneValidationNeeded",e.FULL_AUTH_NEEDED="VKSDKOneTapAuthFullAuthNeeded",e.AUTH_DATA_LOADED="VKSDKOneTapAuthDataLoaded",e.NOT_AUTHORIZED="VKSDKOneTapAuthNotAuthorized",e.LOGIN_SUCCESS="VKSDKOneTapAuthLoginSuccess",e.RESIZE_FRAME="VKSDKOneTapResizeFrame",e.SHOW_CAPTCHA="VKSDKOneTapShowCaptcha",e.VALIDATE_CAPTCHA="VKSDKOneTapValidateCaptcha"}(G||(G={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(j||(j={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions",e.SHOW_AGREEMENTS_DIALOG="VKSDKButtonOneTapAuthShowAgreementsDialog",e.START_AUTHORIZE="VKSDKButtonOneTapAuthStartAuthorize"}(F||(F={}));var z,q,Z,B=new function e(){var n=this;i(this,e),a(this,"flags",null),a(this,"silentAuth",(function(){var e=k.get(),n=e.loginDomain,t=e.appId,o=u(),i="https://".concat(n,"/?act=connect&app_id=").concat(t,"&response_type=").concat("silent_token","&uuid=").concat(o,"&v=").concat("0.0.2"),a=new XMLHttpRequest;return a.open("GET",i,!0),a.responseType="json",a.withCredentials=!0,new Promise((function(e,n){a.onload=function(){a.response?e({provider:"vk",payload:a.response}):n()},a.onerror=function(){n()},a.send()}))})),a(this,"oneTapAuth",(function(e,t){if(console.warn("Connect.oneTapAuth method is deprecated. Use Connect.floatingOneTapAuth and Connect.buttonOneTapAuth methods."),!["floating","button"].includes(e))return null;switch(e){case"button":return n.buttonOneTapAuth(t);case"floating":return n.floatingOneTapAuth(t);default:return null}})),a(this,"floatingOneTapAuth",(function(e){var t,o,i=function(){var e,n=window.innerWidth,t=n<=768;return{destroy:function(){return window.removeEventListener("resize",e)},isAdaptive:function(){return t},observe:function(o){e=function(){var e=window.innerWidth;n>768&&e<=768?o(t=!0):n<=768&&e>768&&o(t=!1),n=e},window.addEventListener("resize",e)}}}(),a=(t=i.isAdaptive(),o=t?"314px":"334px",{pageUrl:"floating_one_tap_auth",pageUrlParams:{adaptive:t?1:0},frameStyles:t?"\n display: none;\n position: fixed;\n bottom: 0;\n right: 0;\n max-width: 100%;\n width: 100%;\n height: ".concat(o,";\n "):"\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n max-width: 400px;\n width: 100%;\n height: ".concat(o,";\n ")});if(!a)throw new Error("options were not set");var r=u(),c=b(R(s({origin:location.protocol+"//"+location.host,uuid:r},a.pageUrlParams),a.pageUrl),{cssText:a.frameStyles}),p=new Y({iframe:c,origin:"https://"+k.get().connectDomain});i.observe((function(e){p.sendMessage({handler:j.ADAPTIVITY_CHANGE,params:{uuid:r,is_adaptive:e}}),e?(c.style.maxWidth="100%",c.style.top="auto",c.style.bottom="0"):(c.style.maxWidth="400px",c.style.top="0",c.style.bottom="auto"),c.style.display="none"})),document.body.appendChild(c);var d=function(){p.sendMessage({handler:G.RESIZE_FRAME,params:{uuid:r}})};window.addEventListener("resize",d);var l=function(){c&&(c.remove(),c=null),window.removeEventListener("resize",d),i&&i.destroy(),p.destroy()},h=new Promise((function(t){p.onMessage((function(o){if(o.params.uuid===r)switch(o.handler){case G.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:r,error:"not_authorized"}}),l(),t(o.handler);break;case G.RESIZE_FRAME:c.style.height="".concat(o.params.height,"px");break;case j.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:r}}),l();break;case j.ADAPTIVITY_CHANGED:c.style.display="block";break;case G.AUTH_DATA_LOADED:c.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,p,e)}}))}));return{getFrame:function(){return c},destroy:l,authReadyPromise:h}})),a(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){n.display=e.displayMode&&H.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=x(e.showAgreements,0),n.show_alternative_login=x(e.showAlternativeLogin,0),n.show_agreements_dialog=x(e.showAgreementsDialog,1);t+=n.show_alternative_login?56:0,t+=n.show_agreements?80:0}return{pageUrl:"button_one_tap_auth",pageUrlParams:n,frameStyles:"\n height: ".concat(t,"px;\n ")}}(e.options);if(!t)throw new Error("options were not set");var o=u(),i=b(R(s({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),a=e.container;a&&a.appendChild(i);var r=new Y({iframe:i,origin:"https://"+k.get().connectDomain}),c=function(){r.sendMessage({handler:G.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",c);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",c),r.destroy()},authReadyPromise:new Promise((function(t){r.onMessage((function(a){if(a.params.uuid===o)switch(a.handler){case G.RESIZE_FRAME:i.style.height="".concat(a.params.height,"px");break;case G.NOT_AUTHORIZED:t(a.handler);break;case F.SHOW_LOGIN:case F.SHOW_LOGIN_OPTIONS:e.callback({type:a.handler,payload:{uuid:o}});break;case F.SHOW_AGREEMENTS_DIALOG:n.userPolicyAgreements(o).show().then((function(e){e&&e.accepted&&r.sendMessage({handler:F.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){r.sendMessage({handler:V.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case G.AUTH_DATA_LOADED:t(a.handler);default:n.handleOneTapEvents(a,r,e)}}))}))}})),a(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case G.AUTH_DATA_LOADED:t.sendMessage({handler:G.RESIZE_FRAME,params:{uuid:i}});break;case G.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:s({uuid:i},e.params)});break;case G.SHOW_CAPTCHA:var a=n.captcha(i,{captcha_sid:e.params.captcha_sid,captcha_img:e.params.captcha_img});a.show().then((function(e){t.sendMessage({handler:W.CAPTCHA_SUCCESS,params:s({uuid:i},e)})})).catch((function(){t.sendMessage({handler:W.CAPTCHA_FAIL,params:{uuid:i}}),a.destroy()}));break;case U.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:U.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:U.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case G.FULL_AUTH_NEEDED:case G.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),a(this,"userDataPolicy",(function(e){var t=R({origin:location.protocol+"//"+location.host,uuid:e},"user_data_policy"),o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),a=b(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(a);var r=new Y({iframe:a,origin:"https://"+k.get().connectDomain}),c=function(){a.style.display="none"};return{show:function(){return a.style.display="block",new Promise((function(t,o){r.onMessage((function(i){switch(i.handler){case U.HIDE_DATA_POLICY:c(),t();break;case U.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){r.sendMessage({handler:W.CAPTCHA_SUCCESS,params:s({uuid:e},n)}),a.style.display="block"})).catch((function(){r.sendMessage({handler:W.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(a),r.destroy()}}})),a(this,"userPolicyAgreements",(function(e){var t,o,i,a=R({origin:location.protocol+"//"+location.host,uuid:e},"user_policy_agreements"),r=(t=a,o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),b(t,{properties:{height:"".concat(o,"px")},cssText:i}));document.body.appendChild(r);var s=new Y({iframe:r,origin:"https://"+k.get().connectDomain}),c=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){s.onMessage((function(i){switch(i.handler){case V.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case V.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case V.SHOW_DATA_POLICY:c();var a=function(){r.style.display="block"};n.userDataPolicy(e).show().then(a).catch(a);break;case V.POLICY_AGREEMENTS_ERROR:case V.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),s.destroy()}}})),a(this,"captcha",(function(e,n){var t=R(s({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=b(t,{cssText:"\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n ")});document.body.appendChild(i);var a=new Y({iframe:i,origin:"https://"+k.get().connectDomain}),r=function(){document.body.removeChild(i),a.destroy()};return{show:function(){return i.style.display="block",new Promise((function(e,n){a.onMessage((function(t){switch(t.handler){case W.CAPTCHA_SUCCESS:e(t.params),r();break;default:n(),r()}}))}))},destroy:r}})),a(this,"userVisibleAuth",(function(e){var t=u(),o={origin:location.protocol+"//"+location.host,uuid:t};(null==e?void 0:e.screen)&&(o.screen=e.screen);var i=L(null==e?void 0:e.action);i&&(o.action=i);var a=R(o);n.flags&&(a="".concat(a,"#").concat(S(n.flags)));var r=screen.height/2-280,s=screen.width/2-410,p=window.open(a,"_blank","top=".concat(r,",left=").concat(s,",width=").concat(820,",height=").concat(560,",location"));if(!p){var d={code:c.CONNECT_WINDOW_NOT_OPENED,reason:f()};return Promise.reject(d)}return new Promise((function(e,n){var o=setInterval((function(){if(!p||p.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:c.CONNECT_WINDOW_CLOSED,reason:h()};n(e)}}),1e3);function i(a){if(a.source===p&&p)if(window.removeEventListener("message",i),clearInterval(o),".vk.com"===a.origin.slice(a.origin.length-".vk.com".length))if(a.data.action==="vk_connect_response"+t){var r=a.data.payload;p.close(),e({provider:"vk",payload:r})}else if(a.data.action==="oauth_callback"+t)e({provider:a.data.payload.name}),p.close();else{p.close();var s={code:c.CONNECT_UNKNOWN_SDK_MESSAGE,reason:m(JSON.stringify(a.data))};n(s)}else{p.close();var u={code:c.CONNECT_DOMAIN_NOT_ALLOWED,reason:A(a.origin)};n(u)}}window.addEventListener("message",i)}))})),a(this,"redirectAuth",(function(e){var n=u(),t={redirect_uri:e.url,uuid:n};(null==e?void 0:e.state)&&(t.redirect_state=e.state),(null==e?void 0:e.screen)&&(t.screen=e.screen);var o=L(null==e?void 0:e.action);o&&(t.action=o);var i=R(t);location.assign(i)}))};!function(e){e.APP_CLOSE="VKWebAppClose",e.APP_READY="VKSDKMiniAppReady",e.RESIZE="VKSDKMiniAppResize",e.APP_INIT_CONFIG="VKSDKMiniAppInitConfig",e.OPEN_APP="VKWebAppOpenApp",e.OPEN_PAY_FORM="VKWebAppOpenPayForm",e.ACTION_DONE="VKWebAppActionDone"}(z||(z={})),(q=exports.MiniAppEvents||(exports.MiniAppEvents={})).OPEN="open",q.HIDE="hide",q.CLOSE="close",q.SHOW="show",q.MESSAGE="message",q.CREATE_APP="createapp",function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp"}(Z||(Z={}));var J;!function(e){e.INIT="ConnectProfileInit"}(J||(J={}));var X={OneTapAuthEventsSDK:G,FloatingOneTapAuthEventsSDK:j,ButtonOneTapAuthEventsSDK:F,DataPolicyEventsSDK:U,AuthCaptchaEventsSDK:W};exports.Config=k,exports.Connect=B,exports.ConnectEvents=X,exports.MiniApp=function e(n){var t=this;i(this,e),a(this,"events",void 0),a(this,"iframe",void 0),a(this,"bridge",void 0),a(this,"loading",void 0),a(this,"readyPromiseResolve",null),a(this,"readyPromise",null),a(this,"bodyOverflowValue",""),a(this,"params",void 0),a(this,"child",null),a(this,"open",(function(e,n){return t.loading?(t.iframe.src=t.getMiniAppUrl(e,n),t.loading=new Promise((function(e){t.iframe.onload=function(){t.iframe.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e}))):t.preload(e,n).catch(console.error),t.iframe.style.display="block",t.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",t.loading.then(t.handleResize).catch(console.error),t.events.emit(exports.MiniAppEvents.OPEN),t.readyPromise})),a(this,"hide",(function(){t.iframe.style.display="none",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.HIDE)})),a(this,"close",(function(){window.document.body.style.overflowX="",k.events.off("superAppToken",t.onSuperAppToken),t.iframe&&t.iframe.remove(),t.bridge&&t.bridge.destroy(),delete t.iframe,delete t.bridge,window.removeEventListener("resize",t.handleResize),t.events.emit(exports.MiniAppEvents.CLOSE)})),a(this,"show",(function(){if(!t.loading)throw new Error('App is not loaded, use "open" or "preload" methods');t.iframe.style.display="block",window.document.body.style.overflow=t.bodyOverflowValue,t.events.emit(exports.MiniAppEvents.SHOW)})),a(this,"preload",(function(e,n){var o=document.createElement("iframe"),i=window.innerHeight,a=isFinite(t.params.zIndex)?t.params.zIndex:999999;return o.src=t.getMiniAppUrl(e,n),o.style.cssText="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(i,"px;\n min-height: ").concat(i,"px;\n border: none;\n z-index: ").concat(a,";\n "),t.iframe=o,document.body.appendChild(t.iframe),k.events.on("superAppToken",t.onSuperAppToken),t.bridge=new Y({iframe:t.iframe,origin:"https://"+k.get().connectDomain}),t.bridge.onMessage(t.handleMessage),window.addEventListener("resize",t.handleResize),t.loading=new Promise((function(e){o.onload=function(){o.onload=null,e()}})),t.readyPromise=new Promise((function(e){return t.readyPromiseResolve=e})),t.loading})),a(this,"sendMessage",(function(e){t.bridge.sendMessage(e)})),a(this,"onSuperAppToken",(function(e){t.bridge.sendMessage({handler:Z.SUPERAPP_TOKEN,params:{result:e}})})),a(this,"handleMessage",(function(e){switch(e.handler){case z.APP_CLOSE:t.hide();break;case z.APP_READY:t.resolveReadyPromise(),t.handleUpdateConfig();break;case z.OPEN_APP:t.openMiniapp(e.params);break;case z.OPEN_PAY_FORM:t.openPayForm(e.params);break;case Z.SUPERAPP_TOKEN:k._requestSuperAppToken();break;case Z.AUTH_NEEDED:k._requestAuth();break;default:t.events.emit(exports.MiniAppEvents.MESSAGE,e)}})),a(this,"handleResize",(function(){if(t.iframe){var e=innerWidth,n=innerHeight;t.iframe.style.height="".concat(n,"px"),t.iframe.style.minHeight="".concat(n,"px"),t.bridge.sendMessage({handler:z.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),a(this,"handleUpdateConfig",(function(){t.bridge.sendMessage({handler:z.APP_INIT_CONFIG,params:{fullMode:t.params.fullMode}})})),a(this,"getMiniAppUrl",(function(e,n){var o=k.get(),i=o.connectDomain,a=o.appId,r=o.superAppToken,s=o._debug,c=S({app:t.params.app,host_app_id:a,debug:s?"1":"",localhost:s?"1":"",superapp_token:r,app_query:e?JSON.stringify(e):"",app_hash:n||""});return"https://".concat(i,"/mini_app?").concat(c)})),a(this,"resolveReadyPromise",(function(){t.readyPromise&&t.readyPromiseResolve&&(t.readyPromiseResolve(),t.readyPromise=null,t.readyPromiseResolve=null)})),a(this,"openMiniapp",(function(n){t.child=new e({app:n.app_id}),t.events.emit(exports.MiniAppEvents.CREATE_APP,{app:t.child,location:n.location})})),a(this,"openPayForm",(function(n){var o=s({},n.params);o.data&&(o.data=JSON.stringify(o.data));var i=s({},o,{app_id:n.app_id,action:n.action}),a=new e({app:6217559});a.open(i).then((function(){return t.hide()})).catch(console.error),a.events.on(exports.MiniAppEvents.MESSAGE,(function(e){t.handleVKPayFormMessage(e),a.close(),t.show()})),a.events.on(exports.MiniAppEvents.HIDE,(function(){a.close(),t.close()}))})),a(this,"handleVKPayFormMessage",(function(e){e.handler===z.ACTION_DONE&&t.sendMessage(e)})),this.params=s({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=C()},exports.Profile=function e(){var n=this;i(this,e),a(this,"iframe",void 0),a(this,"config",void 0),a(this,"bridge",void 0),a(this,"iframeLoadPromise",void 0),a(this,"load",(function(e){if(!e.container)throw new Error("container is null");if(!e)throw new Error(l());return n.iframe||n.preload(e),n.iframeLoadPromise})),a(this,"remove",(function(){n.iframe&&n.iframe.parentNode&&n.iframe.parentNode.removeChild(n.iframe),n.destroy()})),a(this,"preload",(function(e){n.config=e;var t=document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.minHeight="100%",e.container.appendChild(t),n.setup(t)})),a(this,"setup",(function(e){k.events.on("superAppToken",n.onSuperAppToken),e.src=n.getProfileUrl(),n.iframe=e,n.iframeLoadPromise=new Promise((function(n){e.onload=function(){return n(e)}})),n.bridge=new Y({iframe:n.iframe,origin:"https://"+k.get().connectDomain}),n.bridge.onMessage(n.handleMessage)})),a(this,"destroy",(function(){k.events.off("superAppToken",n.onSuperAppToken),n.bridge.destroy(),delete n.iframe,delete n.iframeLoadPromise,delete n.bridge})),a(this,"onSuperAppToken",(function(e){if(e&&n.iframe){var t=n.iframe;n.destroy(),n.setup(t)}})),a(this,"handleMessage",(function(e){switch(e.handler){case J.INIT:n.handleInitApp().catch(console.error);break;case Z.SUPERAPP_TOKEN:k._requestSuperAppToken();break;case Z.AUTH_NEEDED:k._requestAuth();break;case Z.OPEN_APP:k._openApp(e.params)}})),a(this,"handleInitApp",(function(){return Promise.resolve()})),a(this,"getProfileUrl",(function(){var e=k.get(),t=e.connectDomain,o=e.appId,i=e.superAppToken,a=e._debug,r=n.config.widgets,s=S({host_app_id:o,debug:a?"1":"",localhost:a?"1":"",superapp_token:i,widgets:r?r.join(","):""});return"https://".concat(t,"/super_profile?").concat(s)}))}; |
@@ -1,1 +0,1 @@ | ||
import e from"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/defineProperty";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";function t(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function a(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?i(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var r,s="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",c=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=s[64*Math.random()|0];return n},p=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand"];!function(e){e[e.UNKNOWN=1]="UNKNOWN",e[e.MISSING_PARAM=2]="MISSING_PARAM",e[e.CONNECTION_LOST=3]="CONNECTION_LOST",e[e.USER_DENIED=4]="USER_DENIED",e[e.INVALID_PARAMS=5]="INVALID_PARAMS",e[e.CUSTOM=6]="CUSTOM",e[e.CONNECT_WINDOW_CLOSED=7]="CONNECT_WINDOW_CLOSED",e[e.CONNECT_WINDOW_NOT_OPENED=8]="CONNECT_WINDOW_NOT_OPENED",e[e.CONNECT_DOMAIN_NOT_ALLOWED=9]="CONNECT_DOMAIN_NOT_ALLOWED",e[e.CONNECT_UNKNOWN_SDK_MESSAGE=10]="CONNECT_UNKNOWN_SDK_MESSAGE",e[e.OLD_MISSING_PARAM=100]="OLD_MISSING_PARAM"}(r||(r={}));var d=function(){return"No params passed for load app!"},u=function(){return"Connect window was closed."},l=function(){return"Connect window was not opened."},h=function(e){return'URL domain "'.concat(e,'" is not allowed.')},f=function(e){return"This SDK message is unknown: ".concat(e)},m=!("undefined"==typeof window||!window.document||!window.document.createElement),A=m&&!!window.addEventListener,g=function(){};if(A)try{var v=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",g,v),window.removeEventListener("test",g,v)}catch(e){}!function(){if(!m)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function _(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function O(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?_(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):_(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}var y={parse:function(e){if("string"!=typeof e)return{};if(!(e=e.trim().replace(/^[?#&]/,"")))return{};var n=/\?(.+)$/gi.exec(e);return(n?n[1]:e).split("&").reduce((function(e,n){var t=n.split("=");return t[1]&&(e[t[0]]=decodeURIComponent(t[1])),e}),{})},stringify:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==e(n)||null===n)return"";t=O({encode:!0},t);var o=function(e){return t.encode?encodeURIComponent(e):String(e)};return Object.keys(n).reduce((function(e,i){var a=n[i];return void 0===a?e:null===a?(t.skipNull||e.push([o(i),""].join("=")),e):Array.isArray(a)?(a.map((function(n){e.push("".concat(o(i),"[]=").concat(o(n)))})).join(),e):(e.push([o(i),o(a)].join("=")),e)}),[]).join("&")}};function E(e){return y.stringify(e)}function w(e){return Object.keys(e).filter((function(e){return p.includes(e)}))}function T(e){var n;return Boolean(null===(n=w(e))||void 0===n?void 0:n.length)}function P(e){var n=function(e){return w(e).reduce((function(n,t){return n[t]=e[t],n}),{})}(e);return btoa(JSON.stringify(n))}function S(e,n){var t,o=document.createElement("iframe");for(var i in e&&(o.src=e),o.style.cssText=null!==(t=null==n?void 0:n.cssText)&&void 0!==t?t:"",o.width="100%",o.height="100%",o.style.border="none",null==n?void 0:n.properties){var a;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(a=n.properties[i])&&void 0!==a?a:""}return o}function D(e){return e=e||Object.create(null),{on:function(n,t){(e[n]||(e[n]=[])).push(t)},off:function(n,t){e[n]&&e[n].splice(e[n].indexOf(t)>>>0,1)},emit:function(n,t){(e[n]||[]).slice().map((function(e){e(t)})),(e["*"]||[]).slice().map((function(e){e(n,t)}))}}}var b={appId:0,superAppToken:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},N={},C={events:D(),init:function(e){if(!e.appId)throw new Error("appId required");b.appId=e.appId,b.superAppToken=e.superAppToken||"",b.loginDomain=e.loginDomain||"login.vk.com",b.oauthDomain=e.oauthDomain||"oauth.vk.com",b.connectDomain=e.connectDomain||"connect.vk.com",b.appSettings=e.appSettings,b._debug=!!e._debug},get:function(){return b},setSuperAppToken:function(e){b.superAppToken=e,C.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){N.superAppToken=e},_requestSuperAppToken:function(){var e;N.superAppToken&&(e=N.superAppToken()),e&&e.then((function(e){return C.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){N.auth=e},_requestAuth:function(){var e;N.auth&&(e=N.auth()),e&&e.then((function(e){return C.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){N.openApp=e},_openApp:function(e){N.openApp&&N.openApp(e.app)}},I=["extend_token","__sferum_invite_link"];function k(e){return e&&I.includes(e.name)?btoa(JSON.stringify(e)):""}var L;function M(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=C.get(),o=t.appId,i=t.connectDomain,r=t.appSettings,s=a({app_id:o,response_type:"silent_token",v:"0.0.2"},e);r&&T(r)&&(s.app_settings=P(r));var c=E(s);return"https://".concat(i,"/").concat(n,"?").concat(c)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(L||(L={}));var K=[L.Default,L.NamePhone,L.PhoneName];var R,U,H,V,W,x=function e(n){var i=this;t(this,e),o(this,"handler",(function(){return{}})),o(this,"config",void 0),o(this,"destroy",(function(){delete i.config,window.removeEventListener("message",i.handleMessage)})),o(this,"onMessage",(function(e){i.handler=e})),o(this,"sendMessage",(function(e){i.config.iframe.contentWindow.postMessage(a({type:"vk-sak-sdk"},e),i.config.origin)})),o(this,"handleMessage",(function(e){i.config.origin&&e.origin===i.config.origin&&e.source===i.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&i.handler(e.data)})),this.config=n,window.addEventListener("message",this.handleMessage)};!function(e){e.SHOW_DATA_POLICY="VKSDKOneTapAuthConnectDataPolicy",e.HIDE_DATA_POLICY="VKSDKOneTapAuthDataPolicyClose",e.DATA_POLICY_RESULT="VKSDKOneTapAuthDataPolicyResult",e.SHOW_CAPTCHA="VKSDKOneTapAuthDataPolicyShowCaptcha"}(R||(R={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(U||(U={})),function(e){e.PHONE_VALIDATION_NEEDED="VKSDKOneTapAuthPhoneValidationNeeded",e.FULL_AUTH_NEEDED="VKSDKOneTapAuthFullAuthNeeded",e.AUTH_DATA_LOADED="VKSDKOneTapAuthDataLoaded",e.NOT_AUTHORIZED="VKSDKOneTapAuthNotAuthorized",e.LOGIN_SUCCESS="VKSDKOneTapAuthLoginSuccess",e.RESIZE_FRAME="VKSDKOneTapResizeFrame",e.SHOW_CAPTCHA="VKSDKOneTapShowCaptcha",e.VALIDATE_CAPTCHA="VKSDKOneTapValidateCaptcha"}(H||(H={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(V||(V={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions"}(W||(W={}));var j,F,G,z=new function e(){var n=this;t(this,e),o(this,"flags",null),o(this,"silentAuth",(function(){var e=C.get(),n=e.loginDomain,t=e.appId,o=c(),i="https://".concat(n,"/?act=connect&app_id=").concat(t,"&response_type=").concat("silent_token","&uuid=").concat(o,"&v=").concat("0.0.2"),a=new XMLHttpRequest;return a.open("GET",i,!0),a.responseType="json",a.withCredentials=!0,new Promise((function(e,n){a.onload=function(){a.response?e({provider:"vk",payload:a.response}):n()},a.onerror=function(){n()},a.send()}))})),o(this,"oneTapAuth",(function(e,t){if(console.warn("Connect.oneTapAuth method is deprecated. Use Connect.floatingOneTapAuth and Connect.buttonOneTapAuth methods."),!["floating","button"].includes(e))return null;switch(e){case"button":return n.buttonOneTapAuth(t);case"floating":return n.floatingOneTapAuth(t);default:return null}})),o(this,"floatingOneTapAuth",(function(e){var t,o,i=function(){var e,n=window.innerWidth,t=n<=768;return{destroy:function(){return window.removeEventListener("resize",e)},isAdaptive:function(){return t},observe:function(o){e=function(){var e=window.innerWidth;n>768&&e<=768?o(t=!0):n<=768&&e>768&&o(t=!1),n=e},window.addEventListener("resize",e)}}}(),r=(t=i.isAdaptive(),o=t?"314px":"334px",{pageUrl:"floating_one_tap_auth",pageUrlParams:{adaptive:t?1:0},frameStyles:t?"\n display: none;\n position: fixed;\n bottom: 0;\n right: 0;\n max-width: 100%;\n width: 100%;\n height: ".concat(o,";\n "):"\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n max-width: 400px;\n width: 100%;\n height: ".concat(o,";\n ")});if(!r)throw new Error("options were not set");var s=c(),p=S(M(a({origin:location.protocol+"//"+location.host,uuid:s},r.pageUrlParams),r.pageUrl),{cssText:r.frameStyles}),d=new x({iframe:p,origin:"https://"+C.get().connectDomain});i.observe((function(e){d.sendMessage({handler:V.ADAPTIVITY_CHANGE,params:{uuid:s,is_adaptive:e}}),e?(p.style.maxWidth="100%",p.style.top="auto",p.style.bottom="0"):(p.style.maxWidth="400px",p.style.top="0",p.style.bottom="auto"),p.style.display="none"})),document.body.appendChild(p);var u=function(){d.sendMessage({handler:H.RESIZE_FRAME,params:{uuid:s}})};window.addEventListener("resize",u);var l=function(){p&&(p.remove(),p=null),window.removeEventListener("resize",u),i&&i.destroy(),d.destroy()},h=new Promise((function(t){d.onMessage((function(o){if(o.params.uuid===s)switch(o.handler){case H.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:s,error:"not_authorized"}}),l(),t(o.handler);break;case H.RESIZE_FRAME:p.style.height="".concat(o.params.height,"px");break;case V.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:s}}),l();break;case V.ADAPTIVITY_CHANGED:p.style.display="block";break;case H.AUTH_DATA_LOADED:p.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,d,e)}}))}));return{getFrame:function(){return p},destroy:l,authReadyPromise:h}})),o(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){var o,i;n.display=e.displayMode&&K.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=null!==(o=e.showAgreements)&&void 0!==o?o:0,n.show_alternative_login=null!==(i=e.showAlternativeLogin)&&void 0!==i?i:0;t+=n.show_alternative_login?56:0,t+=n.show_agreements?80:0}return{pageUrl:"button_one_tap_auth",pageUrlParams:n,frameStyles:"\n height: ".concat(t,"px;\n ")}}(e.options);if(!t)throw new Error("options were not set");var o=c(),i=S(M(a({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),r=e.container;r&&r.appendChild(i);var s=new x({iframe:i,origin:"https://"+C.get().connectDomain}),p=function(){s.sendMessage({handler:H.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",p);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",p),s.destroy()},authReadyPromise:new Promise((function(t){s.onMessage((function(a){if(a.params.uuid===o)switch(a.handler){case H.RESIZE_FRAME:i.style.height="".concat(a.params.height,"px");break;case H.NOT_AUTHORIZED:t(a.handler);break;case W.SHOW_LOGIN:case W.SHOW_LOGIN_OPTIONS:e.callback({type:a.handler,payload:{uuid:o}});break;case H.AUTH_DATA_LOADED:t(a.handler);default:n.handleOneTapEvents(a,s,e)}}))}))}})),o(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case H.AUTH_DATA_LOADED:t.sendMessage({handler:H.RESIZE_FRAME,params:{uuid:i}});break;case H.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:a({uuid:i},e.params)});break;case H.SHOW_CAPTCHA:var r=n.captcha(i,{captcha_sid:e.params.captcha_sid,captcha_img:e.params.captcha_img});r.show().then((function(e){t.sendMessage({handler:U.CAPTCHA_SUCCESS,params:a({uuid:i},e)})})).catch((function(){t.sendMessage({handler:U.CAPTCHA_FAIL,params:{uuid:i}}),r.destroy()}));break;case R.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:R.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:R.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case H.FULL_AUTH_NEEDED:case H.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),o(this,"userDataPolicy",(function(e){var t=M({origin:location.protocol+"//"+location.host,uuid:e},"user_data_policy"),o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),r=S(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(r);var s=new x({iframe:r,origin:"https://"+C.get().connectDomain}),c=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){s.onMessage((function(i){switch(i.handler){case R.HIDE_DATA_POLICY:c(),t();break;case R.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){s.sendMessage({handler:U.CAPTCHA_SUCCESS,params:a({uuid:e},n)}),r.style.display="block"})).catch((function(){s.sendMessage({handler:U.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),s.destroy()}}})),o(this,"captcha",(function(e,n){var t=M(a({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=S(t,{cssText:"\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n ")});document.body.appendChild(i);var r=new x({iframe:i,origin:"https://"+C.get().connectDomain}),s=function(){document.body.removeChild(i),r.destroy()};return{show:function(){return i.style.display="block",new Promise((function(e,n){r.onMessage((function(t){switch(t.handler){case U.CAPTCHA_SUCCESS:e(t.params),s();break;default:n(),s()}}))}))},destroy:s}})),o(this,"userVisibleAuth",(function(e){var t=c(),o={origin:location.protocol+"//"+location.host,uuid:t};(null==e?void 0:e.screen)&&(o.screen=e.screen);var i=k(null==e?void 0:e.action);i&&(o.action=i);var a=M(o);n.flags&&(a="".concat(a,"#").concat(E(n.flags)));var s=screen.height/2-280,p=screen.width/2-410,d=window.open(a,"_blank","top=".concat(s,",left=").concat(p,",width=").concat(820,",height=").concat(560,",location"));if(!d){var m={code:r.CONNECT_WINDOW_NOT_OPENED,reason:l()};return Promise.reject(m)}return new Promise((function(e,n){var o=setInterval((function(){if(!d||d.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:r.CONNECT_WINDOW_CLOSED,reason:u()};n(e)}}),1e3);function i(a){if(a.source===d&&d)if(window.removeEventListener("message",i),clearInterval(o),".vk.com"===a.origin.slice(a.origin.length-".vk.com".length))if(a.data.action==="vk_connect_response"+t){var s=a.data.payload;d.close(),e({provider:"vk",payload:s})}else if(a.data.action==="oauth_callback"+t)e({provider:a.data.payload.name}),d.close();else{d.close();var c={code:r.CONNECT_UNKNOWN_SDK_MESSAGE,reason:f(JSON.stringify(a.data))};n(c)}else{d.close();var p={code:r.CONNECT_DOMAIN_NOT_ALLOWED,reason:h(a.origin)};n(p)}}window.addEventListener("message",i)}))})),o(this,"redirectAuth",(function(e){var n=c(),t={redirect_uri:e.url,uuid:n};(null==e?void 0:e.state)&&(t.redirect_state=e.state),(null==e?void 0:e.screen)&&(t.screen=e.screen);var o=k(null==e?void 0:e.action);o&&(t.action=o);var i=M(t);location.assign(i)}))};!function(e){e.APP_CLOSE="VKWebAppClose",e.APP_READY="VKSDKMiniAppReady",e.RESIZE="VKSDKMiniAppResize",e.APP_INIT_CONFIG="VKSDKMiniAppInitConfig",e.OPEN_APP="VKWebAppOpenApp",e.OPEN_PAY_FORM="VKWebAppOpenPayForm",e.ACTION_DONE="VKWebAppActionDone"}(j||(j={})),function(e){e.OPEN="open",e.HIDE="hide",e.CLOSE="close",e.SHOW="show",e.MESSAGE="message",e.CREATE_APP="createapp"}(F||(F={})),function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp"}(G||(G={}));var Y,Z=function e(n){var i=this;t(this,e),o(this,"events",void 0),o(this,"iframe",void 0),o(this,"bridge",void 0),o(this,"loading",void 0),o(this,"readyPromiseResolve",null),o(this,"readyPromise",null),o(this,"bodyOverflowValue",""),o(this,"params",void 0),o(this,"child",null),o(this,"open",(function(e,n){return i.loading?(i.iframe.src=i.getMiniAppUrl(e,n),i.loading=new Promise((function(e){i.iframe.onload=function(){i.iframe.onload=null,e()}})),i.readyPromise=new Promise((function(e){return i.readyPromiseResolve=e}))):i.preload(e,n).catch(console.error),i.iframe.style.display="block",i.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",i.loading.then(i.handleResize).catch(console.error),i.events.emit(F.OPEN),i.readyPromise})),o(this,"hide",(function(){i.iframe.style.display="none",window.document.body.style.overflow=i.bodyOverflowValue,i.events.emit(F.HIDE)})),o(this,"close",(function(){window.document.body.style.overflowX="",C.events.off("superAppToken",i.onSuperAppToken),i.iframe&&i.iframe.remove(),i.bridge&&i.bridge.destroy(),delete i.iframe,delete i.bridge,window.removeEventListener("resize",i.handleResize),i.events.emit(F.CLOSE)})),o(this,"show",(function(){if(!i.loading)throw new Error('App is not loaded, use "open" or "preload" methods');i.iframe.style.display="block",window.document.body.style.overflow=i.bodyOverflowValue,i.events.emit(F.SHOW)})),o(this,"preload",(function(e,n){var t=document.createElement("iframe"),o=window.innerHeight,a=isFinite(i.params.zIndex)?i.params.zIndex:999999;return t.src=i.getMiniAppUrl(e,n),t.style.cssText="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: ").concat(a,";\n "),i.iframe=t,document.body.appendChild(i.iframe),C.events.on("superAppToken",i.onSuperAppToken),i.bridge=new x({iframe:i.iframe,origin:"https://"+C.get().connectDomain}),i.bridge.onMessage(i.handleMessage),window.addEventListener("resize",i.handleResize),i.loading=new Promise((function(e){t.onload=function(){t.onload=null,e()}})),i.readyPromise=new Promise((function(e){return i.readyPromiseResolve=e})),i.loading})),o(this,"sendMessage",(function(e){i.bridge.sendMessage(e)})),o(this,"onSuperAppToken",(function(e){i.bridge.sendMessage({handler:G.SUPERAPP_TOKEN,params:{result:e}})})),o(this,"handleMessage",(function(e){switch(e.handler){case j.APP_CLOSE:i.hide();break;case j.APP_READY:i.resolveReadyPromise(),i.handleUpdateConfig();break;case j.OPEN_APP:i.openMiniapp(e.params);break;case j.OPEN_PAY_FORM:i.openPayForm(e.params);break;case G.SUPERAPP_TOKEN:C._requestSuperAppToken();break;case G.AUTH_NEEDED:C._requestAuth();break;default:i.events.emit(F.MESSAGE,e)}})),o(this,"handleResize",(function(){if(i.iframe){var e=innerWidth,n=innerHeight;i.iframe.style.height="".concat(n,"px"),i.iframe.style.minHeight="".concat(n,"px"),i.bridge.sendMessage({handler:j.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),o(this,"handleUpdateConfig",(function(){i.bridge.sendMessage({handler:j.APP_INIT_CONFIG,params:{fullMode:i.params.fullMode}})})),o(this,"getMiniAppUrl",(function(e,n){var t=C.get(),o=t.connectDomain,a=t.appId,r=t.superAppToken,s=t._debug,c=E({app:i.params.app,host_app_id:a,debug:s?"1":"",localhost:s?"1":"",superapp_token:r,app_query:e?JSON.stringify(e):"",app_hash:n||""});return"https://".concat(o,"/mini_app?").concat(c)})),o(this,"resolveReadyPromise",(function(){i.readyPromise&&i.readyPromiseResolve&&(i.readyPromiseResolve(),i.readyPromise=null,i.readyPromiseResolve=null)})),o(this,"openMiniapp",(function(n){i.child=new e({app:n.app_id}),i.events.emit(F.CREATE_APP,{app:i.child,location:n.location})})),o(this,"openPayForm",(function(n){var t=a({},n.params);t.data&&(t.data=JSON.stringify(t.data));var o=a({},t,{app_id:n.app_id,action:n.action}),r=new e({app:6217559});r.open(o).then((function(){return i.hide()})).catch(console.error),r.events.on(F.MESSAGE,(function(e){i.handleVKPayFormMessage(e),r.close(),i.show()})),r.events.on(F.HIDE,(function(){r.close(),i.close()}))})),o(this,"handleVKPayFormMessage",(function(e){e.handler===j.ACTION_DONE&&i.sendMessage(e)})),this.params=a({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=D()};!function(e){e.INIT="ConnectProfileInit"}(Y||(Y={}));var q=function e(){var n=this;t(this,e),o(this,"iframe",void 0),o(this,"config",void 0),o(this,"bridge",void 0),o(this,"iframeLoadPromise",void 0),o(this,"load",(function(e){if(!e.container)throw new Error("container is null");if(!e)throw new Error(d());return n.iframe||n.preload(e),n.iframeLoadPromise})),o(this,"remove",(function(){n.iframe&&n.iframe.parentNode&&n.iframe.parentNode.removeChild(n.iframe),n.destroy()})),o(this,"preload",(function(e){n.config=e;var t=document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.minHeight="100%",e.container.appendChild(t),n.setup(t)})),o(this,"setup",(function(e){C.events.on("superAppToken",n.onSuperAppToken),e.src=n.getProfileUrl(),n.iframe=e,n.iframeLoadPromise=new Promise((function(n){e.onload=function(){return n(e)}})),n.bridge=new x({iframe:n.iframe,origin:"https://"+C.get().connectDomain}),n.bridge.onMessage(n.handleMessage)})),o(this,"destroy",(function(){C.events.off("superAppToken",n.onSuperAppToken),n.bridge.destroy(),delete n.iframe,delete n.iframeLoadPromise,delete n.bridge})),o(this,"onSuperAppToken",(function(e){if(e&&n.iframe){var t=n.iframe;n.destroy(),n.setup(t)}})),o(this,"handleMessage",(function(e){switch(e.handler){case Y.INIT:n.handleInitApp().catch(console.error);break;case G.SUPERAPP_TOKEN:C._requestSuperAppToken();break;case G.AUTH_NEEDED:C._requestAuth();break;case G.OPEN_APP:C._openApp(e.params)}})),o(this,"handleInitApp",(function(){return Promise.resolve()})),o(this,"getProfileUrl",(function(){var e=C.get(),t=e.connectDomain,o=e.appId,i=e.superAppToken,a=e._debug,r=n.config.widgets,s=E({host_app_id:o,debug:a?"1":"",localhost:a?"1":"",superapp_token:i,widgets:r?r.join(","):""});return"https://".concat(t,"/super_profile?").concat(s)}))},J={OneTapAuthEventsSDK:H,FloatingOneTapAuthEventsSDK:V,ButtonOneTapAuthEventsSDK:W,DataPolicyEventsSDK:R,AuthCaptchaEventsSDK:U};export{C as Config,z as Connect,J as ConnectEvents,Z as MiniApp,F as MiniAppEvents,q as Profile}; | ||
import e from"@babel/runtime/helpers/typeof";import"@babel/runtime/helpers/toConsumableArray";import n from"@babel/runtime/helpers/defineProperty";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";function t(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function a(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?i(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}var r,s="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",c=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:21,n="",t=e;t--;)n+=s[64*Math.random()|0];return n},p=["agreements","promo","vkc_behavior","vkc_auth_action","vkc_brand"];!function(e){e[e.UNKNOWN=1]="UNKNOWN",e[e.MISSING_PARAM=2]="MISSING_PARAM",e[e.CONNECTION_LOST=3]="CONNECTION_LOST",e[e.USER_DENIED=4]="USER_DENIED",e[e.INVALID_PARAMS=5]="INVALID_PARAMS",e[e.CUSTOM=6]="CUSTOM",e[e.CONNECT_WINDOW_CLOSED=7]="CONNECT_WINDOW_CLOSED",e[e.CONNECT_WINDOW_NOT_OPENED=8]="CONNECT_WINDOW_NOT_OPENED",e[e.CONNECT_DOMAIN_NOT_ALLOWED=9]="CONNECT_DOMAIN_NOT_ALLOWED",e[e.CONNECT_UNKNOWN_SDK_MESSAGE=10]="CONNECT_UNKNOWN_SDK_MESSAGE",e[e.OLD_MISSING_PARAM=100]="OLD_MISSING_PARAM"}(r||(r={}));var d=function(){return"No params passed for load app!"},u=function(){return"Connect window was closed."},l=function(){return"Connect window was not opened."},h=function(e){return'URL domain "'.concat(e,'" is not allowed.')},f=function(e){return"This SDK message is unknown: ".concat(e)},m=!("undefined"==typeof window||!window.document||!window.document.createElement),A=m&&!!window.addEventListener,g=function(){};if(A)try{var _=Object.defineProperty({},"passive",{get:function(){!0}});window.addEventListener("test",g,_),window.removeEventListener("test",g,_)}catch(e){}!function(){if(!m)return!1;var e=!1;try{document.createElement("div").scrollTo({top:0,get behavior(){return e=!0,"smooth"}})}catch(e){}}();function E(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,o)}return t}function O(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?E(Object(o),!0).forEach((function(t){n(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):E(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}var v={parse:function(e){if("string"!=typeof e)return{};if(!(e=e.trim().replace(/^[?#&]/,"")))return{};var n=/\?(.+)$/gi.exec(e);return(n?n[1]:e).split("&").reduce((function(e,n){var t=n.split("=");return t[1]&&(e[t[0]]=decodeURIComponent(t[1])),e}),{})},stringify:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==e(n)||null===n)return"";t=O({encode:!0},t);var o=function(e){return t.encode?encodeURIComponent(e):String(e)};return Object.keys(n).reduce((function(e,i){var a=n[i];return void 0===a?e:null===a?(t.skipNull||e.push([o(i),""].join("=")),e):Array.isArray(a)?(a.map((function(n){e.push("".concat(o(i),"[]=").concat(o(n)))})).join(),e):(e.push([o(i),o(a)].join("=")),e)}),[]).join("&")}};function y(e){return v.stringify(e)}function T(e){return Object.keys(e).filter((function(e){return p.includes(e)}))}function w(e){var n;return Boolean(null===(n=T(e))||void 0===n?void 0:n.length)}function S(e){var n=function(e){return T(e).reduce((function(n,t){return n[t]=e[t],n}),{})}(e);return btoa(JSON.stringify(n))}function P(e,n){var t,o=document.createElement("iframe");for(var i in e&&(o.src=e),o.style.cssText=null!==(t=null==n?void 0:n.cssText)&&void 0!==t?t:"",o.width="100%",o.height="100%",o.style.border="none",null==n?void 0:n.properties){var a;if(n&&n.properties.hasOwnProperty(i))o[i]=null!==(a=n.properties[i])&&void 0!==a?a:""}return o}function D(e){return e=e||Object.create(null),{on:function(n,t){(e[n]||(e[n]=[])).push(t)},off:function(n,t){e[n]&&e[n].splice(e[n].indexOf(t)>>>0,1)},emit:function(n,t){(e[n]||[]).slice().map((function(e){e(t)})),(e["*"]||[]).slice().map((function(e){e(n,t)}))}}}var b={appId:0,superAppToken:"",loginDomain:"login.vk.com",oauthDomain:"oauth.vk.com",connectDomain:"connect.vk.com",_debug:!1},C={},N={events:D(),init:function(e){if(!e.appId)throw new Error("appId required");b.appId=e.appId,b.superAppToken=e.superAppToken||"",b.loginDomain=e.loginDomain||"login.vk.com",b.oauthDomain=e.oauthDomain||"oauth.vk.com",b.connectDomain=e.connectDomain||"connect.vk.com",b.appSettings=e.appSettings,b._debug=!!e._debug},get:function(){return b},setSuperAppToken:function(e){b.superAppToken=e,N.events.emit("superAppToken",e)},onRequestSuperAppToken:function(e){C.superAppToken=e},_requestSuperAppToken:function(){var e;C.superAppToken&&(e=C.superAppToken()),e&&e.then((function(e){return N.setSuperAppToken(e)})).catch(console.error)},onAuth:function(e){C.auth=e},_requestAuth:function(){var e;C.auth&&(e=C.auth()),e&&e.then((function(e){return N.setSuperAppToken(e)})).catch(console.error)},onOpenApp:function(e){C.openApp=e},_openApp:function(e){C.openApp&&C.openApp(e.app)}},I=["extend_token"];function k(e){return e&&I.includes(e.name)?btoa(JSON.stringify(e)):""}var L;function M(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"auth",t=N.get(),o=t.appId,i=t.connectDomain,r=t.appSettings,s=a({app_id:o,response_type:"silent_token",v:"0.0.2"},e);r&&w(r)&&(s.app_settings=S(r));var c=y(s);return"https://".concat(i,"/").concat(n,"?").concat(c)}!function(e){e.Default="default",e.NamePhone="name_phone",e.PhoneName="phone_name"}(L||(L={}));var K=[L.Default,L.NamePhone,L.PhoneName];function R(e,n){return void 0===e?n:"number"!=typeof e?e?1:0:e}var H,U,V,W,x,G,j=function e(n){var i=this;t(this,e),o(this,"handler",(function(){return{}})),o(this,"config",void 0),o(this,"destroy",(function(){delete i.config,window.removeEventListener("message",i.handleMessage)})),o(this,"onMessage",(function(e){i.handler=e})),o(this,"sendMessage",(function(e){i.config.iframe.contentWindow.postMessage(a({type:"vk-sak-sdk"},e),i.config.origin)})),o(this,"handleMessage",(function(e){i.config.origin&&e.origin===i.config.origin&&e.source===i.config.iframe.contentWindow&&e.data&&"vk-sak-sdk"===e.data.type&&i.handler(e.data)})),this.config=n,window.addEventListener("message",this.handleMessage)};!function(e){e.SHOW_DATA_POLICY="VKSDKOneTapAuthConnectDataPolicy",e.HIDE_DATA_POLICY="VKSDKOneTapAuthDataPolicyClose",e.DATA_POLICY_RESULT="VKSDKOneTapAuthDataPolicyResult",e.SHOW_CAPTCHA="VKSDKOneTapAuthDataPolicyShowCaptcha"}(H||(H={})),function(e){e.SHOW_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsShow",e.HIDE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsHide",e.ACCEPT_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsAccept",e.DECLINE_POLICY_AGREEMENTS="VKSDKOneTapAuthPolicyAgreementsDecline",e.POLICY_AGREEMENTS_ERROR="VKSDKOneTapAuthPolicyAgreementsError",e.SHOW_DATA_POLICY="VKSDKOneTapAuthPolicyAgreementsShowDataPolicy"}(U||(U={})),function(e){e.CAPTCHA_SUCCESS="VKSDKAuthCaptchaSuccess",e.CAPTCHA_FAIL="VKSDKAuthCaptchaFail"}(V||(V={})),function(e){e.PHONE_VALIDATION_NEEDED="VKSDKOneTapAuthPhoneValidationNeeded",e.FULL_AUTH_NEEDED="VKSDKOneTapAuthFullAuthNeeded",e.AUTH_DATA_LOADED="VKSDKOneTapAuthDataLoaded",e.NOT_AUTHORIZED="VKSDKOneTapAuthNotAuthorized",e.LOGIN_SUCCESS="VKSDKOneTapAuthLoginSuccess",e.RESIZE_FRAME="VKSDKOneTapResizeFrame",e.SHOW_CAPTCHA="VKSDKOneTapShowCaptcha",e.VALIDATE_CAPTCHA="VKSDKOneTapValidateCaptcha"}(W||(W={})),function(e){e.CLOSE_AUTH="VKSDKOneTapAuthClose",e.ADAPTIVITY_CHANGE="VKSDKFloatingOneTapAdaptivityChange",e.ADAPTIVITY_CHANGED="VKSDKFloatingOneTapAdaptivityChanged"}(x||(x={})),function(e){e.SHOW_LOGIN="VKSDKButtonOneTapAuthShowLogin",e.SHOW_LOGIN_OPTIONS="VKSDKButtonOneTapAuthShowLoginOptions",e.SHOW_AGREEMENTS_DIALOG="VKSDKButtonOneTapAuthShowAgreementsDialog",e.START_AUTHORIZE="VKSDKButtonOneTapAuthStartAuthorize"}(G||(G={}));var F,Y,z,Z=new function e(){var n=this;t(this,e),o(this,"flags",null),o(this,"silentAuth",(function(){var e=N.get(),n=e.loginDomain,t=e.appId,o=c(),i="https://".concat(n,"/?act=connect&app_id=").concat(t,"&response_type=").concat("silent_token","&uuid=").concat(o,"&v=").concat("0.0.2"),a=new XMLHttpRequest;return a.open("GET",i,!0),a.responseType="json",a.withCredentials=!0,new Promise((function(e,n){a.onload=function(){a.response?e({provider:"vk",payload:a.response}):n()},a.onerror=function(){n()},a.send()}))})),o(this,"oneTapAuth",(function(e,t){if(console.warn("Connect.oneTapAuth method is deprecated. Use Connect.floatingOneTapAuth and Connect.buttonOneTapAuth methods."),!["floating","button"].includes(e))return null;switch(e){case"button":return n.buttonOneTapAuth(t);case"floating":return n.floatingOneTapAuth(t);default:return null}})),o(this,"floatingOneTapAuth",(function(e){var t,o,i=function(){var e,n=window.innerWidth,t=n<=768;return{destroy:function(){return window.removeEventListener("resize",e)},isAdaptive:function(){return t},observe:function(o){e=function(){var e=window.innerWidth;n>768&&e<=768?o(t=!0):n<=768&&e>768&&o(t=!1),n=e},window.addEventListener("resize",e)}}}(),r=(t=i.isAdaptive(),o=t?"314px":"334px",{pageUrl:"floating_one_tap_auth",pageUrlParams:{adaptive:t?1:0},frameStyles:t?"\n display: none;\n position: fixed;\n bottom: 0;\n right: 0;\n max-width: 100%;\n width: 100%;\n height: ".concat(o,";\n "):"\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n max-width: 400px;\n width: 100%;\n height: ".concat(o,";\n ")});if(!r)throw new Error("options were not set");var s=c(),p=P(M(a({origin:location.protocol+"//"+location.host,uuid:s},r.pageUrlParams),r.pageUrl),{cssText:r.frameStyles}),d=new j({iframe:p,origin:"https://"+N.get().connectDomain});i.observe((function(e){d.sendMessage({handler:x.ADAPTIVITY_CHANGE,params:{uuid:s,is_adaptive:e}}),e?(p.style.maxWidth="100%",p.style.top="auto",p.style.bottom="0"):(p.style.maxWidth="400px",p.style.top="0",p.style.bottom="auto"),p.style.display="none"})),document.body.appendChild(p);var u=function(){d.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:s}})};window.addEventListener("resize",u);var l=function(){p&&(p.remove(),p=null),window.removeEventListener("resize",u),i&&i.destroy(),d.destroy()},h=new Promise((function(t){d.onMessage((function(o){if(o.params.uuid===s)switch(o.handler){case W.NOT_AUTHORIZED:e.callback({type:o.handler,payload:{uuid:s,error:"not_authorized"}}),l(),t(o.handler);break;case W.RESIZE_FRAME:p.style.height="".concat(o.params.height,"px");break;case x.CLOSE_AUTH:e.callback({type:o.handler,payload:{uuid:s}}),l();break;case x.ADAPTIVITY_CHANGED:p.style.display="block";break;case W.AUTH_DATA_LOADED:p.style.display="block",t(o.handler);default:n.handleOneTapEvents(o,d,e)}}))}));return{getFrame:function(){return p},destroy:l,authReadyPromise:h}})),o(this,"buttonOneTapAuth",(function(e){var t=function(e){var n={},t=44;if(e){n.display=e.displayMode&&K.includes(e.displayMode)?e.displayMode:"default",n.show_agreements=R(e.showAgreements,0),n.show_alternative_login=R(e.showAlternativeLogin,0),n.show_agreements_dialog=R(e.showAgreementsDialog,1);t+=n.show_alternative_login?56:0,t+=n.show_agreements?80:0}return{pageUrl:"button_one_tap_auth",pageUrlParams:n,frameStyles:"\n height: ".concat(t,"px;\n ")}}(e.options);if(!t)throw new Error("options were not set");var o=c(),i=P(M(a({origin:location.protocol+"//"+location.host,uuid:o},t.pageUrlParams),t.pageUrl),{cssText:t.frameStyles}),r=e.container;r&&r.appendChild(i);var s=new j({iframe:i,origin:"https://"+N.get().connectDomain}),p=function(){s.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:o}})};window.addEventListener("resize",p);return{getFrame:function(){return i},destroy:function(){i&&(i.remove(),i=null),window.removeEventListener("resize",p),s.destroy()},authReadyPromise:new Promise((function(t){s.onMessage((function(a){if(a.params.uuid===o)switch(a.handler){case W.RESIZE_FRAME:i.style.height="".concat(a.params.height,"px");break;case W.NOT_AUTHORIZED:t(a.handler);break;case G.SHOW_LOGIN:case G.SHOW_LOGIN_OPTIONS:e.callback({type:a.handler,payload:{uuid:o}});break;case G.SHOW_AGREEMENTS_DIALOG:n.userPolicyAgreements(o).show().then((function(e){e&&e.accepted&&s.sendMessage({handler:G.START_AUTHORIZE,params:{uuid:o}})})).catch((function(){s.sendMessage({handler:U.DECLINE_POLICY_AGREEMENTS,params:{uuid:o}})}));break;case W.AUTH_DATA_LOADED:t(a.handler);default:n.handleOneTapEvents(a,s,e)}}))}))}})),o(this,"handleOneTapEvents",(function(e,t,o){var i=e.params.uuid;switch(e.handler){case W.AUTH_DATA_LOADED:t.sendMessage({handler:W.RESIZE_FRAME,params:{uuid:i}});break;case W.LOGIN_SUCCESS:o.callback({type:e.handler,provider:"vk",payload:a({uuid:i},e.params)});break;case W.SHOW_CAPTCHA:var r=n.captcha(i,{captcha_sid:e.params.captcha_sid,captcha_img:e.params.captcha_img});r.show().then((function(e){t.sendMessage({handler:V.CAPTCHA_SUCCESS,params:a({uuid:i},e)})})).catch((function(){t.sendMessage({handler:V.CAPTCHA_FAIL,params:{uuid:i}}),r.destroy()}));break;case H.SHOW_DATA_POLICY:n.userDataPolicy(i).show().then((function(){o.callback({type:H.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!0}})})).catch((function(){o.callback({type:H.DATA_POLICY_RESULT,payload:{uuid:i,policyAccepted:!1}})}));break;case W.FULL_AUTH_NEEDED:case W.PHONE_VALIDATION_NEEDED:o.callback({type:e.handler,payload:{uuid:i}})}})),o(this,"userDataPolicy",(function(e){var t=M({origin:location.protocol+"//"+location.host,uuid:e},"user_data_policy"),o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),r=P(t,{properties:{height:"".concat(o,"px")},cssText:i});document.body.appendChild(r);var s=new j({iframe:r,origin:"https://"+N.get().connectDomain}),c=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){s.onMessage((function(i){switch(i.handler){case H.HIDE_DATA_POLICY:c(),t();break;case H.SHOW_CAPTCHA:var p=n.captcha(e,{captcha_sid:i.params.captcha_sid,captcha_img:i.params.captcha_img});p.show().then((function(n){s.sendMessage({handler:V.CAPTCHA_SUCCESS,params:a({uuid:e},n)}),r.style.display="block"})).catch((function(){s.sendMessage({handler:V.CAPTCHA_FAIL,params:{uuid:e}}),p.destroy()})),c();break;default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),s.destroy()}}})),o(this,"userPolicyAgreements",(function(e){var t,o,i,a=M({origin:location.protocol+"//"+location.host,uuid:e},"user_policy_agreements"),r=(t=a,o=window.innerHeight,i="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n "),P(t,{properties:{height:"".concat(o,"px")},cssText:i}));document.body.appendChild(r);var s=new j({iframe:r,origin:"https://"+N.get().connectDomain}),c=function(){r.style.display="none"};return{show:function(){return r.style.display="block",new Promise((function(t,o){s.onMessage((function(i){switch(i.handler){case U.ACCEPT_POLICY_AGREEMENTS:c(),t({accepted:!0});break;case U.DECLINE_POLICY_AGREEMENTS:c(),t({accepted:!1});break;case U.SHOW_DATA_POLICY:c();var a=function(){r.style.display="block"};n.userDataPolicy(e).show().then(a).catch(a);break;case U.POLICY_AGREEMENTS_ERROR:case U.HIDE_POLICY_AGREEMENTS:default:c(),o()}}))}))},hide:c,destroy:function(){document.body.removeChild(r),s.destroy()}}})),o(this,"captcha",(function(e,n){var t=M(a({origin:location.protocol+"//"+location.host,uuid:e},n),"auth_captcha"),o=window.innerHeight,i=P(t,{cssText:"\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: 99999;\n ")});document.body.appendChild(i);var r=new j({iframe:i,origin:"https://"+N.get().connectDomain}),s=function(){document.body.removeChild(i),r.destroy()};return{show:function(){return i.style.display="block",new Promise((function(e,n){r.onMessage((function(t){switch(t.handler){case V.CAPTCHA_SUCCESS:e(t.params),s();break;default:n(),s()}}))}))},destroy:s}})),o(this,"userVisibleAuth",(function(e){var t=c(),o={origin:location.protocol+"//"+location.host,uuid:t};(null==e?void 0:e.screen)&&(o.screen=e.screen);var i=k(null==e?void 0:e.action);i&&(o.action=i);var a=M(o);n.flags&&(a="".concat(a,"#").concat(y(n.flags)));var s=screen.height/2-280,p=screen.width/2-410,d=window.open(a,"_blank","top=".concat(s,",left=").concat(p,",width=").concat(820,",height=").concat(560,",location"));if(!d){var m={code:r.CONNECT_WINDOW_NOT_OPENED,reason:l()};return Promise.reject(m)}return new Promise((function(e,n){var o=setInterval((function(){if(!d||d.closed){window.removeEventListener("message",i),clearInterval(o);var e={code:r.CONNECT_WINDOW_CLOSED,reason:u()};n(e)}}),1e3);function i(a){if(a.source===d&&d)if(window.removeEventListener("message",i),clearInterval(o),".vk.com"===a.origin.slice(a.origin.length-".vk.com".length))if(a.data.action==="vk_connect_response"+t){var s=a.data.payload;d.close(),e({provider:"vk",payload:s})}else if(a.data.action==="oauth_callback"+t)e({provider:a.data.payload.name}),d.close();else{d.close();var c={code:r.CONNECT_UNKNOWN_SDK_MESSAGE,reason:f(JSON.stringify(a.data))};n(c)}else{d.close();var p={code:r.CONNECT_DOMAIN_NOT_ALLOWED,reason:h(a.origin)};n(p)}}window.addEventListener("message",i)}))})),o(this,"redirectAuth",(function(e){var n=c(),t={redirect_uri:e.url,uuid:n};(null==e?void 0:e.state)&&(t.redirect_state=e.state),(null==e?void 0:e.screen)&&(t.screen=e.screen);var o=k(null==e?void 0:e.action);o&&(t.action=o);var i=M(t);location.assign(i)}))};!function(e){e.APP_CLOSE="VKWebAppClose",e.APP_READY="VKSDKMiniAppReady",e.RESIZE="VKSDKMiniAppResize",e.APP_INIT_CONFIG="VKSDKMiniAppInitConfig",e.OPEN_APP="VKWebAppOpenApp",e.OPEN_PAY_FORM="VKWebAppOpenPayForm",e.ACTION_DONE="VKWebAppActionDone"}(F||(F={})),function(e){e.OPEN="open",e.HIDE="hide",e.CLOSE="close",e.SHOW="show",e.MESSAGE="message",e.CREATE_APP="createapp"}(Y||(Y={})),function(e){e.SUPERAPP_TOKEN="VKSDKGeneralSuperAppToken",e.AUTH_NEEDED="VKSDKGeneralAuthNeeded",e.OPEN_APP="VKSDKGeneralOpenApp"}(z||(z={}));var q,B=function e(n){var i=this;t(this,e),o(this,"events",void 0),o(this,"iframe",void 0),o(this,"bridge",void 0),o(this,"loading",void 0),o(this,"readyPromiseResolve",null),o(this,"readyPromise",null),o(this,"bodyOverflowValue",""),o(this,"params",void 0),o(this,"child",null),o(this,"open",(function(e,n){return i.loading?(i.iframe.src=i.getMiniAppUrl(e,n),i.loading=new Promise((function(e){i.iframe.onload=function(){i.iframe.onload=null,e()}})),i.readyPromise=new Promise((function(e){return i.readyPromiseResolve=e}))):i.preload(e,n).catch(console.error),i.iframe.style.display="block",i.bodyOverflowValue=window.document.body.style.overflow,window.document.body.style.overflow="hidden",i.loading.then(i.handleResize).catch(console.error),i.events.emit(Y.OPEN),i.readyPromise})),o(this,"hide",(function(){i.iframe.style.display="none",window.document.body.style.overflow=i.bodyOverflowValue,i.events.emit(Y.HIDE)})),o(this,"close",(function(){window.document.body.style.overflowX="",N.events.off("superAppToken",i.onSuperAppToken),i.iframe&&i.iframe.remove(),i.bridge&&i.bridge.destroy(),delete i.iframe,delete i.bridge,window.removeEventListener("resize",i.handleResize),i.events.emit(Y.CLOSE)})),o(this,"show",(function(){if(!i.loading)throw new Error('App is not loaded, use "open" or "preload" methods');i.iframe.style.display="block",window.document.body.style.overflow=i.bodyOverflowValue,i.events.emit(Y.SHOW)})),o(this,"preload",(function(e,n){var t=document.createElement("iframe"),o=window.innerHeight,a=isFinite(i.params.zIndex)?i.params.zIndex:999999;return t.src=i.getMiniAppUrl(e,n),t.style.cssText="\n display: none;\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: ".concat(o,"px;\n min-height: ").concat(o,"px;\n border: none;\n z-index: ").concat(a,";\n "),i.iframe=t,document.body.appendChild(i.iframe),N.events.on("superAppToken",i.onSuperAppToken),i.bridge=new j({iframe:i.iframe,origin:"https://"+N.get().connectDomain}),i.bridge.onMessage(i.handleMessage),window.addEventListener("resize",i.handleResize),i.loading=new Promise((function(e){t.onload=function(){t.onload=null,e()}})),i.readyPromise=new Promise((function(e){return i.readyPromiseResolve=e})),i.loading})),o(this,"sendMessage",(function(e){i.bridge.sendMessage(e)})),o(this,"onSuperAppToken",(function(e){i.bridge.sendMessage({handler:z.SUPERAPP_TOKEN,params:{result:e}})})),o(this,"handleMessage",(function(e){switch(e.handler){case F.APP_CLOSE:i.hide();break;case F.APP_READY:i.resolveReadyPromise(),i.handleUpdateConfig();break;case F.OPEN_APP:i.openMiniapp(e.params);break;case F.OPEN_PAY_FORM:i.openPayForm(e.params);break;case z.SUPERAPP_TOKEN:N._requestSuperAppToken();break;case z.AUTH_NEEDED:N._requestAuth();break;default:i.events.emit(Y.MESSAGE,e)}})),o(this,"handleResize",(function(){if(i.iframe){var e=innerWidth,n=innerHeight;i.iframe.style.height="".concat(n,"px"),i.iframe.style.minHeight="".concat(n,"px"),i.bridge.sendMessage({handler:F.RESIZE,params:{viewport_width:e,viewport_height:n}})}})),o(this,"handleUpdateConfig",(function(){i.bridge.sendMessage({handler:F.APP_INIT_CONFIG,params:{fullMode:i.params.fullMode}})})),o(this,"getMiniAppUrl",(function(e,n){var t=N.get(),o=t.connectDomain,a=t.appId,r=t.superAppToken,s=t._debug,c=y({app:i.params.app,host_app_id:a,debug:s?"1":"",localhost:s?"1":"",superapp_token:r,app_query:e?JSON.stringify(e):"",app_hash:n||""});return"https://".concat(o,"/mini_app?").concat(c)})),o(this,"resolveReadyPromise",(function(){i.readyPromise&&i.readyPromiseResolve&&(i.readyPromiseResolve(),i.readyPromise=null,i.readyPromiseResolve=null)})),o(this,"openMiniapp",(function(n){i.child=new e({app:n.app_id}),i.events.emit(Y.CREATE_APP,{app:i.child,location:n.location})})),o(this,"openPayForm",(function(n){var t=a({},n.params);t.data&&(t.data=JSON.stringify(t.data));var o=a({},t,{app_id:n.app_id,action:n.action}),r=new e({app:6217559});r.open(o).then((function(){return i.hide()})).catch(console.error),r.events.on(Y.MESSAGE,(function(e){i.handleVKPayFormMessage(e),r.close(),i.show()})),r.events.on(Y.HIDE,(function(){r.close(),i.close()}))})),o(this,"handleVKPayFormMessage",(function(e){e.handler===F.ACTION_DONE&&i.sendMessage(e)})),this.params=a({},n,{app:"number"==typeof n.app?"app".concat(n.app):n.app}),this.events=D()};!function(e){e.INIT="ConnectProfileInit"}(q||(q={}));var J=function e(){var n=this;t(this,e),o(this,"iframe",void 0),o(this,"config",void 0),o(this,"bridge",void 0),o(this,"iframeLoadPromise",void 0),o(this,"load",(function(e){if(!e.container)throw new Error("container is null");if(!e)throw new Error(d());return n.iframe||n.preload(e),n.iframeLoadPromise})),o(this,"remove",(function(){n.iframe&&n.iframe.parentNode&&n.iframe.parentNode.removeChild(n.iframe),n.destroy()})),o(this,"preload",(function(e){n.config=e;var t=document.createElement("iframe");t.style.border="none",t.style.width="100%",t.style.height="100%",t.style.minHeight="100%",e.container.appendChild(t),n.setup(t)})),o(this,"setup",(function(e){N.events.on("superAppToken",n.onSuperAppToken),e.src=n.getProfileUrl(),n.iframe=e,n.iframeLoadPromise=new Promise((function(n){e.onload=function(){return n(e)}})),n.bridge=new j({iframe:n.iframe,origin:"https://"+N.get().connectDomain}),n.bridge.onMessage(n.handleMessage)})),o(this,"destroy",(function(){N.events.off("superAppToken",n.onSuperAppToken),n.bridge.destroy(),delete n.iframe,delete n.iframeLoadPromise,delete n.bridge})),o(this,"onSuperAppToken",(function(e){if(e&&n.iframe){var t=n.iframe;n.destroy(),n.setup(t)}})),o(this,"handleMessage",(function(e){switch(e.handler){case q.INIT:n.handleInitApp().catch(console.error);break;case z.SUPERAPP_TOKEN:N._requestSuperAppToken();break;case z.AUTH_NEEDED:N._requestAuth();break;case z.OPEN_APP:N._openApp(e.params)}})),o(this,"handleInitApp",(function(){return Promise.resolve()})),o(this,"getProfileUrl",(function(){var e=N.get(),t=e.connectDomain,o=e.appId,i=e.superAppToken,a=e._debug,r=n.config.widgets,s=y({host_app_id:o,debug:a?"1":"",localhost:a?"1":"",superapp_token:i,widgets:r?r.join(","):""});return"https://".concat(t,"/super_profile?").concat(s)}))},X={OneTapAuthEventsSDK:W,FloatingOneTapAuthEventsSDK:x,ButtonOneTapAuthEventsSDK:G,DataPolicyEventsSDK:H,AuthCaptchaEventsSDK:V};export{N as Config,Z as Connect,X as ConnectEvents,B as MiniApp,Y as MiniAppEvents,J as Profile}; |
{ | ||
"name": "@vkontakte/superappkit", | ||
"version": "1.15.0-beta.1.0", | ||
"version": "1.15.0-beta.2.0", | ||
"description": "VK SuperAppKit", | ||
@@ -5,0 +5,0 @@ "main": "dist/index-cjs.js", |
69849
606