zmp-sdk
Version:
Zalo Mini App SDK
10 lines (9 loc) • 221 kB
JavaScript
/**
* @timeBuild 18-02-2025 10:49:06
* @license zmp-sdk
*
* Copyright @ 2025. Zalo Group.
*
* This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
*/
function e(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var t,n=1048576,r=window.zAppID,i=window.APP_ID,o="https://zalo.me/s",a="https://h5.zdn.vn/zapps",s="h5.zdn.vn",u="/zapps",c={ZOAUTH:"h5.zdn.vn_zoauth",ZACC_SESSION:"h5.zdn.vn_zacc_session",JS_TOKEN:"h5.zdn.vn_zlink3rd",ZOAUTH_VRF:"h5.zdn.vn_zoauth_vrf",DEVICE_ID:"h5.zdn.vn_deviceID",CONTEXT_ID:"h5.zdn.vn_contextID",CONTEXT_TYPE:"h5.zdn.vn_contextType",UTOKEN_ZPI:"h5.zdn.vn_utoken_zpi",GTOKEN_ZPI:"h5.zdn.vn_gtoken_zpi",ZPP_ZPI:"h5.zdn.vn_zpp_zpi",ZPT_ZPI:"h5.zdn.vn_zpt_zpi"},l={GET_USER_INFO:"https://graph.zalo.me/v2.0/me",GET_ACCESS_TOKEN:"https://h5.zalo.me/openapi/access_token",GET_ACCESS_TOKEN_V3:"https://oauth.zaloapp.com/v3/access_token",GET_LIST_USER_INFO:"https://graph.zalo.me/v2.0/me/friends/list",CREATE_ORDER:"https://payment-mini.zalo.me/api/order/create",GET_APP_INFO:"https://h5.zalo.me/apps/get-info",SEND_ACTION_LOG:"https://h5.zalo.me/log/async",CREATE_SHARE_LINK:"https://h5.zalo.me/openapi/create-sharelink",CHECK_INTERACT_OA:"https://h5.zalo.me/openapi/check-interact-oa",GET_AUTH_SETTING:"https://h5.zalo.me/apis/users/auth-settings"};!function(e){e.REQUEST="REQUEST",e.MODIFIED_REQUEST="MODIFIED_REQUEST",e.RESPONSE="RESPONSE",e.MODIFIED_RESPONSE="MODIFIED_RESPONSE",e.NOT_FOUND="NOT_FOUND"}(t||(t={}));var d,p,f,h,m,v,g,y,_,b,w,T,E,S,I,P,A,O,N,C,k,M,R,x=0,D=-2e3,U=-1400,L=-1500,j=-1401,Z=-1404,B=-1408,z=-1409,W=-2004,F=-2005,V=-2006,G=-2007,H="Success",K="Unknown error. Please try again later.",J="Request limit exceeded. Please try again later.",q="Request timeout. Please try again later.",Q="Please login (https://miniapp.zalo.me/docs/api/login) before to call this api",$="Login failed",Y="This API is not supported in this version of Zalo",X="User Authentication Required. Please grant User Authentication permission before requesting User Permission",ee="Unable to pick media",te="Unable to save image",ne="Unable to save video",re="Unable to save file",ie={SUCCESS:{code:x,message:H},UNKNOWN_ERROR:{code:D,message:K},UNAUTHORIZED:{code:j,message:Q},FORBIDDEN:{code:-1403,message:"You don't have permission to call this api"},CLIENT_NOT_SUPPORT:{code:Z,message:Y},DECODE_FAILED:{code:-2001,message:"Can not decode id. Please check your params again."},TIME_OUT:{code:B,message:q},USER_DENIED:{code:-2002,message:"User denied"},USER_CANCEL:{code:-2003,message:"User cancel"},DUPLICATE_REQUEST:{code:-1410,message:"Duplicate request. Please try again later."},DEVICE_NOT_SUPPORT:{code:-600,message:"This device does not support NFC"},SERVICE_NOT_READY:{code:-602,message:"NFC service is not ready. Please check in your setting"},UNREADABLE:{code:-603,message:"NFC tag is unreadable"},INVALID_MRZ:{code:-604,message:"Invalid MRZ data. Please try again later."},PROCESSING:{code:-605,message:"Processing NFC tag. Please wait a moment."},CANCEL:{code:-606,message:"User cancel"},SCAN_TIMEOUT:{code:-601,message:"NFC scan timeout. Please try again later."},MPDS_ACTION_INVALID:{code:-3e3,message:"Action name from input data does not match declared API actions"},MPDS_SOURCE_INVALID:{code:-3005,message:"This API not called from Mini App"},MPDS_APPID_INVALID:{code:-3006,message:"AppId from input data does not match the currently opened AppId"}},oe={addRating:{limit:1},authorize:{},isAllowedInteractWithOA:{},favoriteApp:{},followOA:{},getLocation:{},getPhoneNumber:{},getShareableLink:{},getSetting:{},getAppInfo:{},getUserInfo:{},interactOA:{},openProfilePicker:{},openShareSheet:{},unfollowOA:{},checkTransaction:{limit:5},createOrder:{limit:5},createOrderIAP:{limit:5},selectPaymentMethod:{},requestSendNotification:{}},ae={GET_DOWNLOADED_STICKER:{haveCallback:!0},OPEN_SHARE_STICKER:{},OPEN_PROFILE:{requireAccessToken:!0},OPEN_FEED_DETAIL:{},OPEN_FRIEND_RADA:{},OPEN_INAPP:{},OPEN_OUTAPP:{requireAccessToken:!0},OPEN_PAGE:{},OPEN_PHOTODETAIL:{},OPEN_GALARY:{},OPEN_GAMECENTER:{},OPEN_GAMENEWS:{},OPEN_TAB_CONTACT:{},OPEN_TAB_SOCIAL:{},OPEN_FRIENDSUGGEST:{},OPEN_GROUPLIST:{},OPEN_NEARBY:{},OPEN_ROOM:{},OPEN_STICKERSTORE:{},OPEN_CREATECHAT:{},COPY_LINK_CATESTICKER:{},REQUEST_BUY_STICKER:{},OPEN_CHAT:{requireAccessToken:!0},OPEN_TAB_CHAT:{},OPEN_CHATGROUP:{},OPEN_ADDFRIEND:{},OPEN_TAB_MORE:{},OPEN_POSTFEED:{requireAccessToken:!0},OPEN_LOGINDEVICES:{},OPEN_SENDSTICKER:{},REPORT_ABUSE:{haveCallback:!0},FOLLOW_OA:{haveCallback:!0,requireAccessToken:!0,errorList:{android:{"-400":{mapTo:ie.DUPLICATE_REQUEST}},iOS:{"-400":{mapTo:ie.DUPLICATE_REQUEST}}}},UNFOLLOW_OA:{haveCallback:!0,requireAccessToken:!0,errorList:{android:{"-400":{mapTo:ie.DUPLICATE_REQUEST}},iOS:{"-400":{mapTo:ie.DUPLICATE_REQUEST}}}},OPEN_GAMEDETAIL:{},OPEN_SHARESHEET:{haveCallback:!0,requireAccessToken:!0,errorList:{android:{"-101":{mapTo:ie.CLIENT_NOT_SUPPORT}},iOS:{"-101":{mapTo:ie.CLIENT_NOT_SUPPORT}}}},REQUEST_PERMISSION_CAMERA:{errorList:{android:{"-2":{mapTo:ie.USER_DENIED}},iOS:{"-2":{mapTo:ie.USER_DENIED}}}},CHANGE_TITLE_HEADER:{skipJump:!0},WEBVIEW_CLEARCACHE:{},WEBVIEW_CONFIRMCACHE:{},WEBVIEW_ISVISIBLE:{},WEBVIEW_NETWORKTYPE:{skipJump:!0},CHANGE_BUTTON_HEADER:{},CREATE_OPTIONS_MENU:{skipJump:!0,haveCallback:!0},CREATE_SHORTCUT:{requireAccessToken:!0},CHANGE_ACTIONBAR_LEFTBUTTON_TYPE:{skipJump:!0,haveCallback:!0},WINDOW_CLOSE:{skipJump:!0,haveCallback:!0},WEBVIEW_CHECKRESERROR:{},IAP_REQUESTPAYMENT:{haveCallback:!0},ZBROWSER_GETSTATS:{},ZBROWSER_JSBRIDGE:{skipJump:!0,haveCallback:!0},PROMPT_AUTHENTICATION:{},CHANGE_ACTIONBAR_COLOR:{skipJump:!0},PROMPT_AUTHENTICATION_CHECK_STATE:{},OPEN_APPSTORE:{},GET_LOCATION:{haveCallback:!0,errorList:{android:{"-1":{mapTo:ie.USER_DENIED},"-400":{mapTo:ie.DUPLICATE_REQUEST}},iOS:{"-1":{mapTo:ie.USER_DENIED},"-400":{mapTo:ie.DUPLICATE_REQUEST}}}},QUERY_LOCATION_HIDE:{haveCallback:!0},SHOW_TOAST:{haveCallback:!0,timeout:2},OPEN_APP:{},HIDE_KEYBOARD:{},OPEN_PHONE:{},OPEN_QR:{},OPEN_SMS:{},VIEW_MYQR:{haveCallback:!0,timeout:!0,requireAccessToken:!0},KEEP_SCREEN:{haveCallback:!0,timeout:2},CHANGE_AUTOROTATE:{skipJump:!0},CHECK_APP_INSTALLED:{},QUERY_SHOW:{},QUERY_HIDE:{},OPEN_INAPPRW:{},ZALORUN_GETTRACKINGSTATUS:{haveCallback:!0},ZALORUN_SETTRACKINGSTATUS:{haveCallback:!0},ZALORUN_GETDAYSTEP:{haveCallback:!0},ZALORUN_FORCESUBMITDATA:{haveCallback:!0},ZALORUN_SETWEIGHT:{haveCallback:!0},OPEN_PROFILE_EXT:{},DOWNLOAD_CATE:{haveCallback:!0},JUMP_LOGIN:{skipJump:!0,whiteList:!0},OPEN_ADTIMA_ADS_INTERSTITIAL:{},OPEN_ADTIMA_ADS:{},GET_ADIDCLIENT:{},SCAN_IBEACON:{},SAVE_VIDEO_GALLERY:{versionLive:{iOS:628},errorList:{android:{"-101":{mapTo:{code:V,message:ne},needMoreDetail:!0},"-102":{mapTo:{code:V,message:ne},needMoreDetail:!0}},iOS:{"-10":{mapTo:{code:V,message:ne},needMoreDetail:!0}}}},INTERACTIVE_VIBRATION:{},SAVE_IMAGE_GALLERY:{versionLive:{iOS:408},errorList:{android:{"-101":{mapTo:{code:F,message:te},needMoreDetail:!0},"-102":{mapTo:{code:F,message:te},needMoreDetail:!0}},iOS:{"-10":{mapTo:{code:F,message:te},needMoreDetail:!0}}}},OPEN_MP:{versionLive:{iOS:402}},CHANGE_ACTIONBAR:{haveCallback:!0,timeout:2,versionLive:{iOS:402},skipJump:!0},ZBROWSER_MPDS:{haveCallback:!0,timeout:2,versionLive:{iOS:402},errorList:{android:{"-100":{mapTo:ie.MPDS_ACTION_INVALID},"-101":{mapTo:ie.UNKNOWN_ERROR},"-105":{mapTo:ie.MPDS_SOURCE_INVALID},"-106":{mapTo:ie.MPDS_APPID_INVALID}},iOS:{"-10":{mapTo:ie.MPDS_ACTION_INVALID},"-101":{mapTo:ie.MPDS_APPID_INVALID},"-102":{mapTo:ie.UNKNOWN_ERROR}}}},ZBROWSER_MPDS_SYNC:{versionLive:{iOS:402},errorList:{android:{"-100":{mapTo:ie.MPDS_ACTION_INVALID},"-101":{mapTo:ie.UNKNOWN_ERROR},"-105":{mapTo:ie.MPDS_SOURCE_INVALID},"-106":{mapTo:ie.MPDS_APPID_INVALID}},iOS:{"-10":{mapTo:ie.MPDS_ACTION_INVALID},"-101":{mapTo:ie.MPDS_APPID_INVALID},"-102":{mapTo:ie.UNKNOWN_ERROR}}}},WEBVIEW_SET_RESULT:{versionLive:{iOS:416}},MP_GET_NUMBER:{versionLive:{iOS:416},errorList:{android:{"-1":{mapTo:ie.USER_DENIED},"-101":{mapTo:ie.USER_DENIED},"-400":{mapTo:ie.DUPLICATE_REQUEST}},iOS:{"-1":{mapTo:ie.USER_DENIED},"-10":{mapTo:ie.USER_DENIED},"-400":{mapTo:ie.DUPLICATE_REQUEST}}}},MP_OPEN_PROFILE_PICKER:{requireAccessToken:!0,versionLive:{iOS:432},errorList:{android:{"-101":{mapTo:ie.USER_CANCEL}},iOS:{"-101":{mapTo:ie.USER_CANCEL}}}},GET_SUPPORTED_ACTIONS:{whiteList:!0},MP_JOIN_WIFI:{haveCallback:!0,timeout:!0,versionLive:{android:0,iOS:0},havePermission:!1,whiteList:!1},PICK_MEDIA:{requireAccessToken:!0,versionLive:{iOS:440},errorList:{android:{"-101":{mapTo:ie.USER_CANCEL},999:{mapTo:{code:W,message:ee},needMoreDetail:!0}},iOS:{"-10":{mapTo:{code:W,message:ee}}}}},MP_CLOSE_LOADINGVIEW:{skipJump:!0},CHANGE_BOTTOMBAR:{haveCallback:!0,timeout:2,skipJump:!0},MA_MENU_MINIMIZE:{skipJump:!1,versionLive:{iOS:520}},MA_MENU_PERMISSION:{skipJump:!1,versionLive:{iOS:520}},MA_MENU_FAVORITES:{skipJump:!1,versionLive:{iOS:520}},MP_SEND_NOTIFICATION:{skipJump:!1,versionLive:{iOS:530},errorList:{android:{"-1":{mapTo:ie.USER_DENIED},"-400":{mapTo:ie.DUPLICATE_REQUEST}},iOS:{"-1":{mapTo:ie.USER_DENIED},"-400":{mapTo:ie.DUPLICATE_REQUEST}}}},MP_ADD_RATING:{skipJump:!1},MP_ADD_MYFAVORITES:{skipJump:!1},MP_INTERACT_OA:{skipJump:!1,errorList:{android:{"-400":{mapTo:ie.DUPLICATE_REQUEST}},iOS:{"-400":{mapTo:ie.DUPLICATE_REQUEST}}}},MP_USER_AUTHORIZE:{skipJump:!1,errorList:{android:{"-400":{mapTo:ie.DUPLICATE_REQUEST}},iOS:{"-400":{mapTo:ie.DUPLICATE_REQUEST}}}},MP_SELECT_PAYMENT_METHOD:{skipJump:!1},CHECK_NFC:{skipJump:!1,versionLive:{iOS:626},errorList:{all:{"-1":{mapTo:ie.UNKNOWN_ERROR},"-600":{mapTo:ie.DEVICE_NOT_SUPPORT},"-602":{mapTo:ie.SERVICE_NOT_READY}}}},SCAN_NFC:{skipJump:!1,haveCallback:!0,timeout:65,errorList:{all:{"-1":{mapTo:ie.UNKNOWN_ERROR},"-600":{mapTo:ie.DEVICE_NOT_SUPPORT},"-601":{mapTo:ie.SCAN_TIMEOUT},"-602":{mapTo:ie.SERVICE_NOT_READY},"-603":{mapTo:ie.UNREADABLE},"-604":{mapTo:ie.INVALID_MRZ},"-605":{mapTo:ie.PROCESSING},"-606":{mapTo:ie.CANCEL}}}},MP_CONFIRM_REQUEST_PAYMENT:{skipJump:!1},SAVE_FILE:{versionLive:{iOS:628},skipJump:!1,errorList:{android:{"-101":{mapTo:{code:G,message:re},needMoreDetail:!0},"-102":{mapTo:{code:G,message:re},needMoreDetail:!0}},iOS:{"-10":{mapTo:{code:G,message:re},needMoreDetail:!0}}}},MP_APP_LIFECYCLE_TRACKING:{skipJump:!1}},se={android:{"-4":ie.DECODE_FAILED,"-5":ie.CLIENT_NOT_SUPPORT,"-14":ie.TIME_OUT},iOS:{"-9":ie.DECODE_FAILED,"-5":ie.CLIENT_NOT_SUPPORT,"-14":ie.TIME_OUT}},ue={android:12100615,iOS:460,wp:0,unknown:0},ce=5*n,le="https://payment-mini.zalo.me/api/order/create",de="https://payment-mini.zalo.me/api/order/iap-create",pe="https://payment-mini.zalo.me/api/transaction",fe="https://payment-mini.zalo.me/api/order/purchase",he="DEFERRED",me="IMMEDIATE_AND_CHARGE_FULL_PRICE",ve={SHOW_BACK:0,HIDE_BACK:3,SHOW_HOME:1,HIDE_HOME:0},ge=5,ye=6,_e="#1843EF",be=0,we={"-12101":"Invalid params","-12102":"Session expire","-12103":"Not permission","-12104":"Not Authorize","-12105":"Unknown exception","-12106":"Cannot create order","-12107":"Transaction not found","-12108":"Cannot update order","-12109":"Cannot decode param","-12110":"Version not support","-12111":"Receipt expire","-12112":"Product not found","-12113":"Subscription other GW","-12114":"Product already subcription","-12115":"Not exist","-12116":"Already exist","-12117":"Not allow","-12118":"Not permit","-12119":"Internal error","-2":"Unable to pay","-6":"Unable to register","-7":"Registered account","-832":"Purchased by another account","-833":"Register for another account","-834":"Unable to register","-2010":"System is maintaining","-3999":"Not in Vietnam","-12129":"Purchased by another account",123:"An error has occurred"};function Te(e,t,n,r,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function Ee(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){Te(o,r,i,a,s,"next",e)}function s(e){Te(o,r,i,a,s,"throw",e)}a(void 0)}))}}function Se(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Ie(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function Pe(e,t){if(e){if("string"==typeof e)return Se(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Se(e,t):void 0}}function Ae(e){return function(e){if(Array.isArray(e))return Se(e)}(e)||Ie(e)||Pe(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oe(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function Ne(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];try{return e.apply(void 0,Ae(n))}catch(e){return"undefined"!=typeof console&&console.error&&console.error(e),null}}}function Ce(e){var t=new URL(window.location.href).searchParams.get("env");return{isMp:window.location.hostname.includes(s)&&("TESTING_LOCAL"==t||window.location.pathname.startsWith(u)),isMpWeb:window.location.hostname.includes("localhost")}}Ne.async=function(e){return Ee((function(){var t,n,r,i,o=arguments;return Oe(this,(function(a){switch(a.label){case 0:for(t=o.length,n=new Array(t),r=0;r<t;r++)n[r]=o[r];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,e.apply(void 0,Ae(n))];case 2:return[2,a.sent()];case 3:return i=a.sent(),"undefined"!=typeof console&&console.error&&console.error(i),[2,null];case 4:return[2]}}))}))},function(e){e.none="none",e.wifi="wifi",e.cellular="cellular",e.unknown="unknown"}(d||(d={})),function(e){e.wp="wp",e.android="android",e.iOS="iOS",e.unknown="unknown"}(p||(p={})),function(e){e.AppPaused="h5.event.paused",e.AppResumed="h5.event.resumed",e.NetworkChanged="h5.event.connection.changed",e.OnDataCallback="h5.event.webview.result",e.WebviewClosed="h5.event.webview.close",e.OpenApp="h5.event.open.mp",e.AppClose="h5.event.action.close",e.PaymentCallback="payment.callback",e.PaymentResult="action.payment.result",e.PaymentClose="action.payment.close",e.DownloadProgress="h5.event.webview.download.progress"}(f||(f={})),function(e){e.DOING="doing",e.DONE="done"}(h||(h={})),function(e){e[e.user=1]="user",e[e.oa=0]="oa",e[e.aliasOA=2]="aliasOA"}(m||(m={})),function(e){e[e.user=1]="user",e[e.oa=0]="oa"}(v||(v={})),function(e){e[e.image=1]="image",e[e.multi_image=2]="multi_image",e[e.link=4]="link",e[e.profile=5]="profile"}(g||(g={})),function(e){e[e.cccd=1]="cccd"}(y||(y={})),function(e){e[e.image=1]="image",e[e.gif=11]="gif",e[e.video=12]="video",e[e.link=4]="link",e[e.oa=5]="oa",e[e.zmp=20]="zmp",e[e.multi_image=21]="multi_image",e[e.zmp_deep_link=4]="zmp_deep_link",e[e.text=22]="text"}(_||(_={})),function(e){e[e.auto=1]="auto",e[e.portrait=2]="portrait",e[e.landscape=3]="landscape"}(b||(b={})),function(e){e[e.oneShot=0]="oneShot"}(w||(w={})),function(e){e[e.zcamera=3]="zcamera",e[e.zcamera_photo=1]="zcamera_photo",e[e.zcamera_video=2]="zcamera_video",e[e.zcamera_scan=7]="zcamera_scan",e[e.photo=4]="photo",e[e.video=5]="video",e[e.file=6]="file"}(T||(T={})),function(e){e.SUBSCRIPTION="SUBSCRIPTION",e.ONETIME="ONETIME"}(E||(E={})),function(e){e[e.UNKNOW=0]="UNKNOW",e[e.DEFERRED=1]="DEFERRED",e[e.IMMEDIATE_AND_CHARGE_FULL_PRICE=2]="IMMEDIATE_AND_CHARGE_FULL_PRICE"}(S||(S={})),function(e){e[e.normal=1]="normal",e[e.hidden=0]="hidden",e[e.transparent=2]="transparent"}(I||(I={})),function(e){e[e.show=1]="show",e[e.hide=0]="hide"}(P||(P={})),function(e){e[e.show=1]="show",e[e.hide=0]="hide"}(A||(A={})),function(e){e[e.left=0]="left",e[e.center=1]="center"}(O||(O={})),function(e){e.OnFrameCallback="h5.event.camera.frame",e.OnStartCallback="h5.event.camera.start",e.OnStopCallback="h5.event.camera.stop"}(N||(N={})),function(e){e.FRONT="user",e.BACK="environment"}(C||(C={})),function(e){e.WEBP="image/webp",e.PNG="image/png",e.JPEG="image/jpeg"}(k||(k={})),function(e){e.HIGH="high",e.NORMAL="normal",e.LOW="low"}(M||(M={})),function(e){e.VIDEO="video",e.AUDIO="audio"}(R||(R={}));var ke,Me=function(e){return e.isAndroid?p.android:e.isIOS?p.iOS:p.unknown};function Re(e){var t=e.split("zalo")[1];return t&&t.replace(" ","").split("/")[1]||""}function xe(){var e=function(){var e=Ne((function(){return window.navigator.userAgent.toLowerCase()}))();if(e){var t=function(e){return{isAndroid:/android/i.test(e)&&!/iemobile/.test(e),isIOS:/iphone|ios|ipad|ipod/.test(e)&&!/iemobile/.test(e),isMobile:/android|iphone|ios|ipad|ipod|iemobile/.test(e),isZalo:/zalo/.test(e)}}(e);return{appEnv:Ce(),platform:t,platformName:Me(t),zaloVersion:Re(e).trim()}}}();if(e)return e}var De=(null===(ke=xe())||void 0===ke?void 0:ke.appEnv)||{};function Ue(e){Ue.on&&Ue.engine(e)}Ue.on=!1,Ue.engine=function(e){var t=e.name,n=e.type,r=e.state,i=e.request,o=e.response,a=e.stage;console[n]([t,a,r,i,o].filter(Boolean).map((function(e){return"object"==typeof e?JSON.stringify(e):e})).join("; "))};var Le=function(e,n){var r,i={error:-1404,errorMessage:"".concat(e," is not found")};null==n||null===(r=n.fail)||void 0===r||r.call(n,i),Ue({stage:t.NOT_FOUND,type:"error",name:e,request:n,state:"fail",response:i})};function je(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ze(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){je(e,t,n[t])}))}return e}function Be(e,t){return function(e){if(Array.isArray(e))return e}(e)||Ie(e)||Pe(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ze(e){return e&&e.constructor===Symbol?"symbol":typeof e}function We(e){return"function"==typeof window.Debug?window.Debug(e):function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n]}}var Fe=Object.prototype.toString;var Ve="[object Null]",Ge="[object Undefined]";function He(e){return null==e?void 0===e?Ge:Ve:function(e){return Fe.call(e)}(e)}function Ke(e){return null!=e&&"object"==typeof e}var Je={isEmpty:function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length},isNull:function(e){return null===e},isUndefined:function(e){return void 0===e},isFunction:function(e){return"function"==typeof e},isObject:function(e){return null!==e&&("function"==typeof e||"object"==typeof e)},isString:function(e){return null!=e&&"string"==typeof e.valueOf()},isNumber:function(e){return"number"==typeof e||Ke(e)&&"[object Number]"==He(e)},isArray:function(e){return Array.isArray(e)},isRegExp:function(e){return Ke(e)&&"[object RegExp]"==He(e)},get:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,r=function(n){return String.prototype.split.call(t,n).filter(Boolean).reduce((function(e,t){return null!=e?e[t]:e}),e)},i=r(/[,[\]]+?/)||r(/[,[\].]+?/);return void 0===i||i===e?n:i},isPromise:function(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}};function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function $e(e){return $e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},$e(e)}function Ye(e){return $e(e)}function Xe(e,t,n){return Xe="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Ye(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n||e):i.value}},Xe(e,t,n)}function et(e,t,n){return Xe(e,t,n)}function tt(e,t){return tt=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},tt(e,t)}function nt(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&tt(e,t)}function rt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function it(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Ye(e);if(t){var i=Ye(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return function(e,t){return!t||"object"!==ze(t)&&"function"!=typeof t?rt(e):t}(this,n)}}var ot,at,st=(ot=function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||e,a),u=n?n+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,i,o,a){var s=n?n+e:e;if(!this._events[s])return!1;var u,c,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,i),!0;case 5:return l.fn.call(l.context,t,r,i,o),!0;case 6:return l.fn.call(l.context,t,r,i,o,a),!0}for(c=1,u=new Array(d-1);c<d;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var p,f=l.length;for(c=0;c<f;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),d){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,r);break;case 4:l[c].fn.call(l[c].context,t,r,i);break;default:if(!u)for(p=1,u=new Array(d-1);p<d;p++)u[p-1]=arguments[p];l[c].fn.apply(l[c].context,u)}}return!0},s.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var u=0,c=[],l=s.length;u<l;u++)(s[u].fn!==t||i&&!s[u].once||r&&s[u].context!==r)&&c.push(s[u]);c.length?this._events[o]=1===c.length?c[0]:c:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s},ot(at={exports:{}},at.exports),at.exports),ut="ACTION_CALLBACK";var ct=function(e){nt(n,e);var t=it(n);function n(){var e;return qe(this,n),(e=t.apply(this,arguments)).debug=We("zmp:event-emitter"),e}var r=n.prototype;return r.h5ConfirmHandleEvent=function(e,t,n){ZaloJavaScriptInterface.jsH5EventCallback(e,t,n||"")},r.on=function(e,t,r){var i=this;if(e===ut||e===f.PaymentCallback)return et(Ye(n.prototype),"on",this).call(this,e,t,r);this.debug("register ".concat(String(e),": ").concat(r));return et(Ye(n.prototype),"on",this).call(this,e,(function(n,o){i.h5ConfirmHandleEvent(n,e,r),t(o)}),r)},r.once=function(e,t,r){var i=this;if(e===ut)return et(Ye(n.prototype),"once",this).call(this,e,t,r);this.debug("register once ".concat(String(e),": ").concat(r));return et(Ye(n.prototype),"once",this).call(this,e,(function(n,o){i.h5ConfirmHandleEvent(n,e,r),t(o)}),r)},n.getInstance=function(){return n.instance||(n.instance=new n),n.instance},n}(st);function lt(e){ct.getInstance().emit(ut,e)}function dt(e){var t=[];for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(void 0===r)return;if(null===r)return void t.push(n);t.push(encodeURIComponent(n)+"="+encodeURIComponent(r))}return t.join("&")}window.onNativeMessage=function(e,t){return function(n){lt({serialId:e,actionName:t,result:n})}},window.zaloJSV2={zalo_h5_event_handler:function(e,t,n){var r=We("zmp:zalo_h5_event_handler");r("eventId: ".concat(e,", eventName: ").concat(t,", eventData: ").concat(n));var o=zt(n);r("stringToData",o);var a=function(e,t){try{if(e===f.OpenApp){var n=t.url,r=new URL(n),o=r.pathname.split("/zapps/".concat(i))[1];return{path:"".concat(o||"/").concat(r.search)}}return t}catch(e){return t}}(t,o);ct.getInstance().emit(t,e,a)}},window.zaloNative2JS={nativeCall:function(e,t,n){ct.getInstance().emit(f.PaymentCallback,e,t,n)}};var pt={encode:dt,decode:function(e,t){var n={};if(""===e)return n;for(var r=e.split("&"),i=0;i<r.length;i++){var o=r[i].split("=",2),a=decodeURIComponent(o[0]);if(t&&Object.prototype.hasOwnProperty.call(n,a))throw new URIError("Duplicate key: "+a);n[a]=2===o.length?decodeURIComponent(o[1]):null}return n},appendToUrl:function(e,t){return e+(-1!==e.indexOf("?")?"&":"?")+("string"==typeof t?t:dt(t))},getParameterByName:function(e,t){t||(t=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},getParamsAsObject:function(e){var t={};return e?(e.split("&").map((function(e){var n=e.split("=");n&&2==n.length&&(t[n[0]]=decodeURIComponent(n[1].replace(/\+/g," ")))})),t):t},toQueryString:function(e){if(!e)return"";if("object"!=(void 0===e||void 0===e?"undefined":ze(e)))return e;var t=Object.keys(e),n=[];return t.map((function(t){var r=e[t],i=[t,r="object"==(void 0===r||void 0===r?"undefined":ze(r))?JSON.stringify(r):encodeURIComponent(r)].join("=");n.push(i)})),n.join("&")}},ft={},ht=function(e,t,n){var r=t||"default";return function(){return(r in ft?ft[r](e,n):e).apply(this,arguments)}};ht.setWrapper=function(e){ft[arguments.length<=1||void 0===arguments[1]?"default":arguments[1]]=e};var mt={error:{code:1,error_subcode:1357046,message:"Received Invalid JSON reply.",type:"http"}};function vt(e){try{return null===e?mt:JSON.parse(e)}catch(e){return mt}}var gt,yt={execute:function(e,t,n,r){n.suppress_http_code=1;var i=pt.encode(n);"post"!=t&&(e=pt.appendToUrl(e,i),i="");var o=function(e,t){if(!self.XMLHttpRequest)return null;var n=new XMLHttpRequest,r=function(){};if(!("withCredentials"in n))return null;n.open(e,t,!0),n.setRequestHeader("Content-type","application/x-www-form-urlencoded");var i={send:function(e){n.send(e)}},o=ht((function(){o=r,"onload"in i&&i.onload(n)}),"entry","XMLHttpRequest:load"),a=ht((function(){a=r,"onerror"in i&&i.onerror(n)}),"entry","XMLHttpRequest:error");return n.onload=function(){o()},n.onerror=function(){a()},n.onreadystatechange=function(){4==n.readyState&&(200==n.status?o():a())},i}(t,e);return!!o&&(o.onload=function(e){r(vt(e.responseText))},o.onerror=function(e){e.responseText?r(vt(e.responseText)):r({error:{code:1,error_subcode:1357045,message:"unknown error (empty response)",status:e.status,type:"http"}})},o.send(i),!0)}},_t=(gt=Ee((function(e,t,n){var r,i,o,a;return Oe(this,(function(s){switch(s.label){case 0:return r={appId:e,versionStatus:t},Je.isUndefined(n)||(r.currentVersion=n),i=pt.appendToUrl(l.GET_APP_INFO,r),[4,fetch(i,{credentials:"include"})];case 1:return(o=s.sent()).ok?[4,o.json()]:[3,3];case 2:if((a=s.sent()).err<0||!a.data)throw new Error(a);return[2,{name:a.data.name,version:a.data.version,description:a.data.description,appUrl:a.data.appUrl,qrCodeUrl:a.data.qrCodeUrl,logoUrl:a.data.logoUrl,cateID:a.data.cateType}];case 3:throw new Error("Can't get app info")}}))})),function(e,t,n){return gt.apply(this,arguments)});function bt(e){try{var t=e.map((function(e){return{action:e.action,error:e.error,message:e.message,data:e.data}}));yt.execute(l.SEND_ACTION_LOG,"post",{appId:window.APP_ID,data:JSON.stringify(t)},(function(){}))}catch(e){}}var wt=function(e){return e.replace(/[A-Z]/g,(function(e){return"_".concat(e.toLowerCase())}))},Tt=function(){var e;return"android"===((null===(e=xe())||void 0===e?void 0:e.platformName)||"").toLowerCase()},Et=function(){var e=0;if(window.zaloVersionCode)e=window.zaloVersionCode;else{var t,n=Number((null===(t=xe())||void 0===t?void 0:t.zaloVersion)||"");if(n>=24112e3)e=n;else{var r,i=((null===(r=xe())||void 0===r?void 0:r.platformName)||"").toLowerCase();"android"===i?e=n%1e4:"ios"===i&&(e=n)}}return e},St=function(e,t){var n=Et();return Tt()&&n<e||function(){var e;return"ios"===((null===(e=xe())||void 0===e?void 0:e.platformName)||"").toLowerCase()}()&&n<t};function It(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}var Pt,At=function(){function e(t,n,r,i){qe(this,e),this.code=t,this.message=n,this.api=r,this.detail=i}var t=e.prototype;return t.toString=function(){return"api: ".concat(String(this.api),"; code: ").concat(this.code,"; message: ").concat(JSON.stringify(this.message))},t.toJSON=function(){return{code:this.code,message:this.message,api:this.api,detail:this.detail}},e}(),Ot=function(e,t){return It(e,At)?function(e,t){return e.api=t,e.toJSON()}(e,t):function(e,t){return It(e,Error)?new At(D,e.message,t).toJSON():Je.isEmpty(null==e?void 0:e.message)||Je.isEmpty(null==e?void 0:e.code)?new At(D,K,t,e).toJSON():new At(e.code,e.message,t,e.detail).toJSON()}(e,t)},Nt=(Pt=Ee((function(e){var t;return Oe(this,(function(n){switch(n.label){case 0:return t={headers:{"Content-Type":"application/x-www-form-urlencoded",authorization:"Bearer ".concat(e)}},[4,fetch(l.GET_AUTH_SETTING,Ze({method:"GET"},t))];case 1:return[4,n.sent().json()];case 2:return[2,n.sent()]}}))})),function(e){return Pt.apply(this,arguments)}),Ct=Ee((function(){return Oe(this,(function(e){return[2,new Promise(function(){var e=Ee((function(e,t){var n,r,i,o;return Oe(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,Lt.jumpAndGetToken()];case 1:return a.sent(),(r=null===(n=Lt.miniProgramConfig)||void 0===n?void 0:n.jwt)||t(new At(j,Q,"getSetting")),[4,Nt(r)];case 2:return(i=a.sent())&&0===i.err?e({authSetting:i.data}):t(new At(i.err,i.msg,"getSetting")),[3,4];case 3:return o=a.sent(),t(o),[3,4];case 4:return[2]}}))}));return function(t,n){return e.apply(this,arguments)}}())]}))})),kt=function(){var e,t,n,r=xe(),i={},o=ct.getInstance(),a=[],s=!1;return s||(t=function(e){var t=e.serialId,n=Wt(e.result),r=Ht(null==n?void 0:n.action),s=Je.isEmpty(null==n?void 0:n.error_code)?0:null==n?void 0:n.error_code,u=null==n?void 0:n.error_message,c=(null==n?void 0:n.data)||n;if(r&&0===s){var l=JSON.parse(null==n?void 0:n.data);s=Je.isEmpty(null==l?void 0:l.error_code)?0:null==l?void 0:l.error_code,u=null==l?void 0:l.error_message,c=(null==l?void 0:l.data)||l}var d={error_code:s,error_message:u,data:c,action:(null==n?void 0:n.action)||e.actionName};if(t&&i[t]){var p=i[t],h=p.callback,m=p.timeout,v=p.isMultiCallback,g=p.options,y=p.downloadListener;!function(e,t){var n=t||{},r=n.success,i=n.fail;0===e.error_code?Je.isFunction(r)&&r(e):Je.isFunction(i)&&i(e)}(d,h),!v&&delete i[t],m&&clearTimeout(m);var _={action:null==d?void 0:d.action,error:null==d?void 0:d.error_code,message:null==d?void 0:d.error_message,data:{}};try{if("action.open.inapp"===d.action||"action.open.outapp"===d.action){var b=new URL(null==g?void 0:g.url),w="".concat(b.protocol,"//").concat(b.host).concat(b.pathname);_.data={url:w}}if("action.follow.oa"===d.action||"action.unfollow.oa"===d.action){var T=null==g?void 0:g.uid;_.data={uid:T}}if("action.open.chat"===d.action){var E=null==g?void 0:g.uId,S=null==g?void 0:g.type;_.data={uid:E,openChatType:S}}(null==g?void 0:g.onProgress)&&y&&o.off(f.DownloadProgress,y)}catch(e){}a.push(_)}},ct.getInstance().on(ut,t),o.on(f.AppPaused,(function(){if(a.length>0){var e=a;a=[],bt(e)}})),e?clearInterval(e):e=setInterval((function(){if(a.length>0){var e=a;a=[],bt(e)}}),5e3),s=!0),n=Ee((function(e,t,n,a){var s,u,c,l,d,p,h,m,v,g,y,_,b,w,T,E,S,I,P,A,O,N,C;return Oe(this,(function(k){switch(k.label){case 0:return u=Math.floor(1e6*Math.random()),c="".concat(e,"_").concat(u),l=Qt(e),(null==a?void 0:a.actionName)&&a.actionName.length>0&&(l=null==a?void 0:a.actionName),d=(null==a?void 0:a.isMultiCallback)||!1,p=!1!==(null==a?void 0:a.timeout)&&((null==a?void 0:a.timeout)||!0),h=(null==a?void 0:a.haveCallback)||!1,m=(null==a?void 0:a.skipJump)||!1,v=(null==a?void 0:a.requireAccessToken)||!1,g=Kt(l),t&&n&&(i[c]={options:t,callback:n,isMultiCallback:d},p&&h&&(i[c].timeout=setTimeout((function(){return lt({serialId:c,result:{error_code:B,error_message:q,data:{timeout:p},action:e}}),null}),!0===p?8e3:1e3*p))),g?[4,Ct()]:[3,2];case 1:if(!1===(null==(_=k.sent())||null===(y=_.authSetting)||void 0===y?void 0:y["scope.userInfo"]))return lt({serialId:c,result:{error_code:j,error_message:X,data:{isMobile:null==r||null===(b=r.platform)||void 0===b?void 0:b.isMobile},action:e}}),[2];k.label=2;case 2:return w=Ht(l),!(null==r||null===(s=r.platform)||void 0===s?void 0:s.isMobile)||!e||Je.isUndefined(ZaloJavaScriptInterface)||r.platform.isIOS&&!Bt(e)||w&&!1===w.isSupported?(lt({serialId:c,result:{error_code:Z,error_message:Y,data:{isMobile:null==r||null===(T=r.platform)||void 0===T?void 0:T.isMobile},action:e}}),[2]):(E=Zt(t),m?[3,4]:[4,Lt.getJSAccessToken()]);case 3:return I=k.sent(),[3,5];case 4:I="",k.label=5;case 5:S=I,k.label=6;case 6:return k.trys.push([6,10,,11]),m||!v?[3,8]:[4,Lt.getAccessToken()];case 7:return A=k.sent(),[3,9];case 8:A="",k.label=9;case 9:return P=A,[3,11];case 10:return O=k.sent(),lt({serialId:c,result:{error_code:null==O?void 0:O.code,error_message:null==O?void 0:O.message,action:e}}),[2];case 11:try{t&&(null==t?void 0:t.onProgress)&&(N=function(e){!function(e,t){var n=e.progress;t&&t(n)}(e,null==t?void 0:t.onProgress)},i[c].downloadListener=N,o.on(f.DownloadProgress,N))}catch(e){}return C=r.platform.isIOS?window.onNativeMessage(c,l):'window.onNativeMessage("'.concat(c,'", "').concat(l,'")'),[2,ZaloJavaScriptInterface.jsCall(S,l,P,E,C)]}}))})),function(e,t,r,i){return n.apply(this,arguments)}}(),Mt={success:function(e,t){return{code:x,message:t||H,data:e||{}}},error:{failLimit:function(){return new At(z,J)},badRequest:function(e){return new At(U,e)},loginFailed:function(e){return new At(j,"".concat($,": ").concat(e))},loginRequired:function(){return new At(j,Q)},cannotGetShareInfo:function(){return new At(L,"Can not get app info to share")},createIAPOrderFailed:function(e){var t=Object.keys(we).find((function(t){return t===e.toString()}));return new At(e,t||K)},clientNotSupport:function(){return new At(Z,Y)}}},Rt=function(e){var t,n,r,i=null===(t=xe())||void 0===t?void 0:t.platformName,o=qt(e.action),a=ae[o],s=(null==a?void 0:a.skipJump)||!1,u=(null==a?void 0:a.errorList)||{};if("JUMP_LOGIN"===o)return new At(D,"Can not get auth code: ".concat(e.error_message));if(Lt.jumpStatus!==h.DONE&&!s)return new At(ie.UNAUTHORIZED.code,ie.UNAUTHORIZED.message);if("permission required!"===String(e.error_message).toLowerCase()||"no permission!"===String(e.error_message).toLowerCase())return new At(ie.FORBIDDEN.code,ie.FORBIDDEN.message);if(i&&(null===(n=se[i])||void 0===n?void 0:n[e.error_code]))return new At(se[i][e.error_code].code,se[i][e.error_code].message);var c=null==u||null===(r=u[i])||void 0===r?void 0:r[String(e.error_code)];if(c){var l,d,p,f=null===(l=c.mapTo)||void 0===l?void 0:l.message;if(null==c?void 0:c.needMoreDetail)f="".concat(null==c||null===(p=c.mapTo)||void 0===p?void 0:p.message,": ").concat(e.error_message);return new At(null===(d=c.mapTo)||void 0===d?void 0:d.code,f)}return new At(e.error_code,e.error_message)},xt=function(e,n,r,i){var o=function(e,n){function r(r){return function(i){var o=Je.isEmpty(n)?void 0:n[r];if(o)return Ue({stage:t.RESPONSE,type:"log",state:r,name:e,response:i}),o("fail"===r?Rt(i):null==i?void 0:i.data)}}return Je.isUndefined(e)&&(e=""),Object.assign({},{success:r("success"),fail:r("fail")})}(e,r),a=ae[e],s=(null==i?void 0:i.delay)||0;setTimeout((function(){kt(e,n,o,Ze({},i,a))}),s)},Dt=function(){var e=Ee((function(e){return Oe(this,(function(t){return[2,new Promise((function(t,n){xt("MP_USER_AUTHORIZE",{scopes:e,forceUpdate:!0},{success:function(e){Je.isEmpty(e)||t(e)},fail:function(e){n(e)}},{isMultiCallback:!1,timeout:!1})}))]}))}));return function(t){return e.apply(this,arguments)}}(),Ut=function(){function e(){qe(this,e),this._jumpStatus=void 0,this.WAITING_QUEUE=[],this.getAccessTokenCount=0,this._accessToken="",this._jsAccessToken="",this.refreshToken="",this._cookies=[],this.accessTokenExpiresIn=0,this.prevGetAccessTokenTimestamp=(new Date).getTime(),this.manualSetAccessToken=!1,this._miniProgramConfig={},this.retryLimitMap={}}var n,o,s,u=e.prototype;return u.initRetryLimit=function(e){var t=oe[e],n={lastCall:(new Date).getTime(),limit:t&&t.limit?t.limit:3,retry:0};return this.retryLimitMap[e]=n,n},u.resetRetryLimit=function(e){this.retryLimitMap[e].lastCall=(new Date).getTime(),this.retryLimitMap[e].retry=0},u.getRetryLimit=function(e){var t=this.retryLimitMap[e];return t&&t.lastCall&&t.retry||(t=this.initRetryLimit(e)),t},u.increaseRetryLimit=function(e){this.retryLimitMap[e].retry++},u.jump=function(){var e=this;return Ee((function(){return Oe(this,(function(n){return[2,new Promise((function(n,r){e._jumpStatus?e._jumpStatus===h.DONE?n(h.DONE):n(h.DOING):(e._jumpStatus=h.DOING,Ue({stage:t.REQUEST,type:"log",name:"jump"}),kt("JUMP_LOGIN",{},{success:function(t){var r=t.data;e._miniProgramConfig=(null==r?void 0:r.miniProgramConfig)||{};var i=(null==r?void 0:r.cookiesOAuthLogins)||[],o=i.find((function(e){return e.name===c.JS_TOKEN}));o&&(e._jsAccessToken=o.value,window.ZJSBridge.setJSToken&&window.ZJSBridge.setJSToken(o.value)),e._cookies=i;var a=e._cookies.find((function(e){return e.name===c.ZOAUTH}));(null==a?void 0:a.value)||bt([{action:"action.jump.login",error:-102,message:"no zoauth",data:{}}]),n(h.DONE)},fail:function(e){bt([{action:"action.jump.login",error:-101,message:e.message||"jump error",data:{}}]),r(e)}},{skipJump:!0}))}))]}))}))()},u.loginZaloV3=function(e,t,n){var r=this;return Ee((function(){var i;return Oe(this,(function(o){switch(o.label){case 0:return i="".concat(l.GET_ACCESS_TOKEN_V3,"?app_id=").concat(t,"&redirect_uri=").concat(a,"/").concat(e,"/&code=").concat(n,"&isSDK=true"),[4,fetch(i).then(function(){var e=Ee((function(e){var t,n,i;return Oe(this,(function(o){switch(o.label){case 0:return[4,e.json()];case 1:return t=o.sent(),n=null==t?void 0:t.access_token,r._accessToken=n,i=1e3*parseInt(t.expires_in),r.accessTokenExpiresIn=i,r.prevGetAccessTokenTimestamp=(new Date).getTime(),window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(r._accessToken||""),[2,n]}}))}));return function(t){return e.apply(this,arguments)}}())];case 1:return[2,o.sent()]}}))}))()},u.loginZaloV4=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",r=this;return Ee((function(){var i,o;return Oe(this,(function(a){switch(a.label){case 0:return(i=new URLSearchParams).append("app_id",e),i.append("code",t),i.append("code_verifier",n),Je.isNull(r.refreshToken)||0===r.refreshToken.length?i.append("grant_type","authorization_code"):(i.append("grant_type","refresh_token"),i.append("refresh_token",r.refreshToken||"")),o={headers:{"Content-Type":"application/x-www-form-urlencoded"}},[4,fetch(l.GET_ACCESS_TOKEN,Ze({method:"POST",body:i},o)).then(function(){var e=Ee((function(e){var t,n,i,o;return Oe(this,(function(a){switch(a.label){case 0:return[4,e.json()];case 1:return t=a.sent(),n=(null==t?void 0:t.access_token)||"",i=(null==t?void 0:t.refresh_token)||"",r.refreshToken=i,r._accessToken=n,o=1e3*parseInt(null==t?void 0:t.expires_in),r.accessTokenExpiresIn=o,r.prevGetAccessTokenTimestamp=(new Date).getTime(),window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(n),[2,n]}}))}));return function(t){return e.apply(this,arguments)}}())];case 1:return[2,a.sent()]}}))}))()},u.getAccessToken=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this;return Ee((function(){var n,o,a,s,u,l,d,p,f;function h(){return m.apply(this,arguments)}function m(){return(m=Ee((function(){return Oe(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){var t=setInterval((function(){(o.getAccessTokenCount<=1||o._accessToken)&&(e("done"),clearInterval(t))}),200)}))];case 1:return[2,e.sent()]}}))}))).apply(this,arguments)}return Oe(this,(function(m){switch(m.label){case 0:return n=(new Date).getTime()-t.prevGetAccessTokenTimestamp,(o=t).getAccessTokenCount++,t.getAccessTokenCount>1?[4,h()]:[3,2];case 1:m.sent(),m.label=2;case 2:return t.manualSetAccessToken?(o.getAccessTokenCount--,[2,Promise.resolve(t._accessToken)]):e?[4,t.verifyUserAuthorized()]:[3,4];case 3:return s=m.sent(),[3,5];case 4:s=!0,m.label=5;case 5:return a=s,t._accessToken.length>0&&n<t.accessTokenExpiresIn&&a?(o.getAccessTokenCount--,[2,Promise.resolve(t._accessToken)]):(t.accessToken="",[4,t.jumpAndGetToken(c.ZOAUTH)]);case 6:return u=m.sent(),[4,t.jumpAndGetToken(c.ZOAUTH_VRF)];case 7:if(l=m.sent(),d="zmp.getaccesstoken.fail",!a)throw o.getAccessTokenCount--,bt([{action:d,error:-104,message:"no user auth",data:{}}]),Mt.error.loginFailed("User Authentication Required");if(!u)return[3,15];m.label=8;case 8:return m.trys.push([8,13,,14]),l?[4,t.loginZaloV4(i,u,l)]:[3,10];case 9:return p=m.sent(),[3,12];case 10:return[4,t.loginZaloV3(i,r,u)];case 11:p=m.sent(),m.label=12;case 12:return[3,14];case 13:return f=m.sent(),p="",console.log("Can not get access token",f),bt([{action:d,error:-103,message:String(f)||"Can not get access token",data:{}}]),[3,14];case 14:return o.getAccessTokenCount--,p?[2,Promise.resolve(t._accessToken)]:(bt([{action:d,error:-101,message:"no accessToken",data:{}}]),[2,Promise.reject(Mt.error.loginFailed("Can't get accessToken. Please try again later."))]);case 15:throw o.getAccessTokenCount--,bt([{action:d,error:-102,message:"no oauth",data:{}}]),Mt.error.loginFailed("Zalo app has not been activated")}}))}))()},u.verifyUserAuthorized=function(){var e=this;return Ee((function(){var t,n,r,i,o,a;return Oe(this,(function(s){switch(s.label){case 0:return n=!0,[4,e.jumpAndGetToken()];case 1:if(s.sent(),!1!==(null===(t=e._miniProgramConfig)||void 0===t?void 0:t.userAuthorized))return[3,7];s.label=2;case 2:return s.trys.push([2,6,,7]),(r=Ht("action.mp.user.authorize"))&&r.isSupported?[4,Ct()]:[3,5];case 3:return!1!==(null==(o=s.sent())||null===(i=o.authSetting)||void 0===i?void 0:i["scope.userInfo"])?[3,5]:[4,Dt()];case 4:a=s.sent(),n=(null==a?void 0:a["scope.userInfo"])||!1,s.label=5;case 5:return[3,7];case 6:return s.sent(),n=!1,[3,7];case 7:return[2,n]}}))}))()},u.setAccessToken=function(e){this.manualSetAccessToken=!0,this._accessToken=e,window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(e)},u.getJSAccessToken=function(){var e=this;return Ee((function(){var t;return Oe(this,(function(n){switch(n.label){case 0:return e._jsAccessToken.length>0?[2,Promise.resolve(e._jsAccessToken)]:[4,e.jumpAndGetToken(c.JS_TOKEN)];case 1:return t=n.sent(),[2,Promise.resolve(t)]}}))}))()},u.getSync=function(e){var t;return null===(t=this._cookies.find((function(t){return t.name===e})))||void 0===t?void 0:t.value},u.jumpAndGetToken=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this;return new Promise(function(){var r=Ee((function(r){var i,o,a,s;return Oe(this,(function(u){switch(u.label){case 0:return!t&&n._cookies.length>0?Je.isString(e)?(i=n._cookies.find((function(t){return t.name===e})),[2,r(null==i?void 0:i.value)]):[2,r("")]:(t&&n._jumpStatus===h.DONE&&(n._jumpStatus=void 0),o={name:e,cb:function(e){return r(e)}},[4,n.jump()]);case 1:return(a=u.sent())===h.DONE?(n._jumpStatus=a,n.WAITING_QUEUE.length&&(n.WAITING_QUEUE.forEach((function(e){var t=n._cookies.find((function(t){return t.name===e.name}));e.cb(null==t?void 0:t.value)})),n.WAITING_QUEUE=[]),s=n._cookies.find((function(e){return e.name===o.name})),o.cb(null==s?void 0:s.value)):n.WAITING_QUEUE.push(o),[2]}}))}));return function(e){return r.apply(this,arguments)}}())},e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},n=e,(o=[{key:"jumpStatus",get:function(){return this._jumpStatus}},{key:"accessToken",set:function(e){this._accessToken=e,window.ZJSBridge.setZAccSession&&window.ZJSBridge.setZAccSession(e)}},{key:"miniProgramConfig",get:function(){return this._miniProgramConfig}}])&&Qe(n.prototype,o),s&&Qe(n,s),e}(),Lt=Ut.getInstance(),jt=We("zmp:utils:common"),Zt=function(e){if(Je.isObject(JSON)&&JSON.stringify)return JSON.stringify(e);if(void 0===e)return"undefined";if(null===e)return"null";try{if("string"==typeof e||null!==e.constructor.toString().match(/string/i))return'"'+e.replace(/"/g,'\\"')+'"'}catch(e){console.log(e)}var t;if(null!==Object.prototype.toString.call(e).match(/array/i)){t=[];for(var n=e.length,r=0;r<n;r++)t.push(Zt(e[r]));return"["+t.join(",")+"]"}if("object"==typeof e){for(var i in t=[],e)t.push('"'+i+'":'+Zt(e[i]));return"{"+t.join(",")+"}"}return e.toString()},Bt=function(e){var t,n,r=ae[e],i=(null===(t=xe())||void 0===t?void 0:t.zaloVersion)||0,o="versionLive"in r&&(null==r||null===(n=r.versionLive)||void 0===n?void 0:n.iOS)||0;return!!(Array.isArray(window.ignoreCheckSupport)&&window.ignoreCheckSupport.length>0&&window.ignoreCheckSupport.includes(e))||Number(i)>=o},zt=function(e){try{if(e){jt(e);var t=e.replace(/\\/g,"").replace(/'/g,"'");try{t=decodeURIComponent(atob(e))}catch(e){}var n=JSON.parse(t);return jt("formattedValue",t,n,void 0===n?"undefined":ze(n)),n}return null}catch(t){return jt("parse json error:",t),e}},Wt=function(e){if(Je.isObject(JSON)&&JSON.parse&&Je.isString(e)){var t=e.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\x00/g,"");return JSON.parse(t,(function(e,t){return t}))}return Je.isObject(e)?e:new Function("return "+e)()},Ft=function(e){for(var t=document.getElementsByTagName("meta"),n=0;n<t.length;n++)if(t[n].getAttribute("name")===e||t[n].getAttribute("property")===e)return t[n].getAttribute("content");return""},Vt=function(e){return btoa(encodeURIComponent(JSON.stringify(e)))};var Gt=function(e){return"hidden"===e?I.hidden:"transparent"===e?I.transparent:I.normal},Ht=function(e){if(void 0!==e){var t=Lt.miniProgramConfig;return((null==t?void 0:t.dynamicApis)||[]).find((function(t){return t.action===e&&!1===t.clientHandle}))}},Kt=function(e){if(void 0===e)return!1;var t=Lt.miniProgramConfig;return((null==t?void 0:t.requiredAuthenList)||[]).indexOf(e)>=0},Jt=function(){var e=Ee((function(){return Oe(this,(function(e){return[2,new Promise(function(){var e=Ee((function(e,t){var n;return Oe(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,Lt.jumpAndGetToken()];case 1:return t.sent(),n=Lt.miniProgramConfig,e(!0===(null==n?void 0:n.canUseAccessTokenByDefault)),[3,3];case 2:return t.sent(),e(!1),[3,3];case 3:return[2]}}))}));return function(t,n){return e.apply(this,arguments)}}())]}))}));return function(){return e.apply(this,arguments)}}(),qt=function(e){return e.replace("action.","").replace(/\./g,"_").toUpperCase()},Qt=function(e){return"action.".concat(e.replace(/\_/g,".").toLowerCase())};function $t(e,t,n,r){var i,o;!function(e,t){if(oe[e]){var n=Lt.getRetryLimit(e);n.lastCall&&(new Date).getTime()-n.lastCall>1e3&&Lt.resetRetryLimit(e);var r=n.limit||3;if(n.retry&&n.retry>=r)throw Ot(Mt.error.failLimit(),e);Lt.increaseRetryLimit(e)}}(e);var a=Array.isArray(n)&&n.length>0&&(null===(i=n[0])||void 0===i?void 0:i.success),s=Array.isArray(n)&&n.length>0&&(nu