Files
ruo-shan-cloud-pharmacy/miniprogram/package-live/volc-mini-sdk/lib/tea.js
T
陈誉午 994b267f5c feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡
- 药品百科: 搜索 + 分类筛选 + 20种药品静态数据
- 惠教中心: 4条药品使用指南课程
- 我的: 家庭成员信息管理
- 自定义TabBar + navigation-bar组件
- SVG药品分类插图
2026-07-29 11:20:52 +08:00

1 line
30 KiB
JavaScript

"use strict";function _typeof(e){return _typeof="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},_typeof(e)}!function(e,t){"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).$$LOGSDK=t()}(void 0,function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function n(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function s(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=r(e)););return e}function a(){return a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var i=s(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},a.apply(this,arguments)}function u(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(e);!(s=(i=n.next()).done)&&(o.push(i.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e,t)||h(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 c(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h(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 h(e,t){if(e){if("string"==typeof e)return f(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(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?f(e,t):void 0}}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function l(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}var p,d,v=void 0;p={cn:"https://mcs.zijieapi.com",va:"https://maliva-mcs.byteoversea.com",sg:"https://sgali-mcs.byteoversea.com"},d="cn";var m,y={appOnShow:"app_launch",appOnHide:"app_terminate",appOnError:"on_error",pageOnShow:"predefine_pageview",pageOnHide:"predefine_pageview_hide",pageOnShareAppMessage:"on_share"},_=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],g=["__profile_set","__profile_set_once","__profile_increment","__profile_unset","__profile_append"],b=function(e){return null!=e&&"[object Object]"==Object.prototype.toString.call(e)},k=function(e){return"function"==typeof e},w=function(e){return"number"==typeof e&&!isNaN(e)},O=function(){return+new Date},P=function(){function t(n){e(this,t),this.sdk=n,this.env=this.init()}return n(t,[{key:"init",value:function(){return{user:{web_id:v,user_unique_id:v,user_id:v,user_type:v,user_is_auth:v,user_is_login:v,ip_addr_id:v,device_id:v},header:{app_id:v,app_name:v,app_install_id:v,install_id:v,app_package:v,app_channel:v,app_version:v,os_name:v,os_version:v,device_model:v,device_brand:v,traffic_type:v,client_ip:v,os_api:v,access:v,language:v,app_language:v,creative_id:v,ad_id:v,campaign_id:v,ab_client:v,ab_version:v,platform:v,sdk_version:v,sdk_lib:v,app_region:v,region:v,province:v,city:v,timezone:v,tz_offset:v,tz_name:v,sim_region:v,carrier:v,resolution:v,screen_width:v,screen_height:v,browser:v,browser_version:v,referrer:v,referrer_host:v,utm_source:v,utm_medium:v,utm_campaign:v,utm_term:v,utm_content:v,custom:{},ab_sdk_version:v,_sdk_version:v,_sdk_name:v}}}},{key:"set",value:function(e){var t=this;this.sdk.emit(this.sdk.types.EnvTransform,e),Object.keys(e).forEach(function(n){if("evtParams"===n)t.evtParams=Object.assign(Object.assign({},t.evtParams||{}),e.evtParams||{});else if("_staging_flag"===n)t.evtParams=Object.assign(Object.assign({},t.evtParams||{}),{_staging_flag:e._staging_flag});else{var i=n,r=e[n];if(null===r)return!1;var o="";if(i.indexOf(".")>-1){var s=u(i.split("."),2);o=s[0],i=s[1]}"os_version"!==i&&"mp_platform"!==i||(r="".concat(r)),o?("headers"===o&&(o="header"),"user"===o||"header"===o?t.env[o][i]=r:t.env.header.custom[i]=r):t.env.user.hasOwnProperty(i)?["user_type","ip_addr_id"].indexOf(i)>-1?t.env.user[i]=Number(r):["user_id","web_id","user_unique_id"].indexOf(i)>-1?t.env.user[i]=String(r):["user_is_auth","user_is_login"].indexOf(i)>-1?t.env.user[i]=Boolean(r):["device_id"].indexOf(i)>-1&&(t.env.user[i]=r):t.env.header.hasOwnProperty(i)?t.env.header[i]=r:t.env.header.custom[i]=r}})}},{key:"get",value:function(e){return e&&"env"!==e?"evtParams"===e?Object.assign({},this[e]):this.env.hasOwnProperty(e)?this.clone(this.env[e]):this.env.user.hasOwnProperty(e)?this.clone(this.env.user[e]):this.env.header.hasOwnProperty(e)?this.clone(this.env.header[e]):this.env.header.custom.hasOwnProperty(e)?this.clone(this.env.header.custom[e]):void 0:this.clone(this.env)}},{key:"compose",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this.env,i=n.user,r=n.header,o=this.evtParams,s=e.map(function(e){return e.event&&!t.includes(e.event)&&o&&Object.keys(o).forEach(function(t){void 0===e.params[t]&&(e.params[t]=o[t])}),e.params=JSON.stringify(e.params),e});return this.clone({events:s,user:i,header:r})}},{key:"merge",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=this.compose(e,t);return n.local_time=Math.floor(O()/1e3),[n]}},{key:"clone",value:function(e){return b(e)?JSON.parse(JSON.stringify(e)):e}}]),t}(),C=function(){function t(){e(this,t),this.domains=p,this.init()}return n(t,[{key:"init",value:function(){this.option={caller:"",log:!1,channel:d,report_channel:d,channel_domain:"",report_url:"",auto_report:!1,auto_profile:!1,profile_channel:"cn",enable_profile:!1,enable_ab_test:!1,ab_channel_domain:"",clear_ab_cache_on_user_change:!0,enable_et_test:!1,event_verify_url:"",enable_buffer:!1,buffer_interval:5e3,buffer_number:5,enable_storage_only:!1,enable_filter_list:!1,enable_third:!1,enable_filter_crawler:!1,request_timeout:0,enable_initiative_launch:!1,enable_custom_webid:!1,disable_sdk_monitor:!1},this.cloneOption=Object.assign({},this.option),this.initDomain()}},{key:"initDomain",value:function(){if(this.option.channel_domain)this.domain=this.option.channel_domain;else{var e=this.option.report_channel;Object.keys(this.domains).includes(e)||(e=d),this.domain=this.domains[e]}}},{key:"set",value:function(e){var t=this;b(e)&&Object.keys(e).forEach(function(n){t.option.hasOwnProperty(n)&&("channel"===n||"report_channel"===n?(t.option.report_channel=t.option.channel=e[n]?e[n]:t.cloneOption[n],t.initDomain()):(t.option[n]=void 0===e[n]?t.cloneOption[n]:e[n],"channel_domain"===n&&t.initDomain()))})}},{key:"get",value:function(e){return e?this.hasOwnProperty(e)?this[e]:this.option.hasOwnProperty(e)?this.option[e]:void 0:Object.assign({},this.option)}}]),t}(),A=function(){function t(){e(this,t),this.hooks={}}return n(t,[{key:"on",value:function(e,t){e&&t&&"function"==typeof t&&(this.hooks[e]||(this.hooks[e]=[]),this.hooks[e].push(t))}},{key:"once",value:function(e,t){var n=this;e&&t&&"function"==typeof t&&this.on(e,function i(r){t(r),n.off(e,i)})}},{key:"off",value:function(e,t){if(e&&this.hooks[e]&&this.hooks[e].length)if(t){var n=this.hooks[e].indexOf(t);-1!==n&&this.hooks[e].splice(n,1)}else this.hooks[e]=[]}},{key:"emit",value:function(e,t){e&&this.hooks[e]&&this.hooks[e].length&&c(this.hooks[e]).forEach(function(e){try{e(t)}catch(e){}})}}]),t}(),S=function(){function t(n){e(this,t),this.ready=!1,this.sdk=n}return n(t,[{key:"setLog",value:function(e){e&&k(e.log)&&(this._log=e)}},{key:"setRequest",value:function(e){if(k(e)){var t=e(this.sdk);k(t)&&(this._request=t)}}},{key:"setStorage",value:function(e){b(e)&&k(e.get)&&k(e.set)&&k(e.remove)&&(this._storage=e)}},{key:"check",value:function(){this._request&&this._storage&&(this.ready=!0)}},{key:"log",value:function(){if(this._log)try{var e;this.sdk.option.get("log")&&(e=this._log).log.apply(e,arguments)}catch(e){}}},{key:"request",value:function(e){var t;if(!this.ready)return Promise.reject();try{return null===(t=this._request)||void 0===t?void 0:t.call(this,e)}catch(e){}}},{key:"get",value:function(e){return this.ready?this._storage.get(e):Promise.reject(null)}},{key:"set",value:function(e,t){return this.ready?this._storage.set(e,t):Promise.reject(!1)}},{key:"remove",value:function(e){return this.ready?this._storage.remove(e):Promise.reject(!1)}}]),t}();!function(e){e.Init="$init",e.Config="$config",e.Send="$send",e.Ready="$ready",e.TokenComplete="$token-complete",e.TokenStorage="$token-storage",e.TokenFetch="$token-fetch",e.TokenGet="$token-get",e.LaunchComplete="$launch-complete",e.ConfigUuid="$config-uuid",e.ConfigWebId="$config-webid",e.ConfigTransform="$config-transform",e.UuidChangeBefore="$uuid-change-before",e.UuidChangeAfter="$uuid-change-after",e.EnvTransform="$env-transform",e.Event="$event",e.Report="$report",e.AppOpen="$app-open",e.AppClose="$app-close",e.AppShowStart="$app-show-start",e.AppShow="$app-show",e.AppHide="$app-hide",e.AppError="$app-error",e.AppShare="$app-share",e.AppOnShare="$app-on-share",e.PageShow="$page-show",e.PageHide="$page-hide",e.PageShare="$page-share",e.SubmitBefore="$submit-before",e.SubmitAfter="$submit-after",e.SubmitError="$submit-error",e.FilterCrawler="$filter-crawler",e.LaunchInfo="$launch-info",e.AbVar="$ab-var",e.AbAllVars="$ab-all-vars",e.AbExternalVersion="$ab-external-version",e.AbVersionChangeOn="$ab-version-change-on",e.AbVersionChangeOff="$ab-version-change-off",e.AbRefresh="$ab-refresh",e.AbFetchAfter="$ab-fetch-After",e.ProfileSet="$profile-set",e.ProfileSetOnce="$profile-set-once",e.ProfileUnset="$profile-unset",e.ProfileIncrement="$profile-increment",e.ProfileAppend="$profile-append",e.ProfileClear="$profile-clear",e.ProfileSubmitAfter="$profile-submit-after",e.ProfileSubmitError="$profile-submit-error",e.TransformInfo="$transform-info"}(m||(m={}));var I=m,x=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},U=function(){function t(){e(this,t),this.types=I,this.EventType=y,this.ProfileType=g,this.UtmType=_,this.SdkHook=I,this.inited=!1,this.sended=!1,this.pluginInstances=[],this.data=new Map,this.ready=!1,this.sessionId="",this.env=new P(this),this.option=new C,this.hook=new A,t.instances.push(this);try{this.adapter=new S(this),this.adapter.setLog(t._log),this.adapter.setRequest(t._request),this.adapter.setStorage(t._storage),this.adapter.check(),t.plugins.reduce(function(e,t){var n=t.plugin;return e.push(new n),e},this.pluginInstances)}catch(e){}}return n(t,[{key:"on",value:function(e,t){var n;null===(n=this.hook)||void 0===n||n.on(e,t)}},{key:"once",value:function(e,t){var n;null===(n=this.hook)||void 0===n||n.once(e,t)}},{key:"off",value:function(e,t){var n;!t&&this.types[e]||null===(n=this.hook)||void 0===n||n.off(e,t)}},{key:"emit",value:function(e,t){var n;this.adapter.log("emit ".concat(e),t||""),null===(n=this.hook)||void 0===n||n.emit(e,t)}},{key:"appId",get:function(){return this._appId}},{key:"checkUsePlugin",value:function(e){return!!t.plugins.find(function(t){return t.name===e})}},{key:"init",value:function(e){var t=this;if(!this.inited&&b(e)){var n=e.app_id,i=e.log,r=l(e,["app_id","log"]);if(void 0!==i&&this.option.set({log:i}),w(n)&&n>0){this._appId=n,this.option.set(r),this.env.set({app_id:n}),Promise.all([new Promise(function(e){t.once(I.TokenComplete,function(){e(!0)})}),new Promise(function(e){t.checkUsePlugin("official:auto")?t.on(I.LaunchComplete,function(){e(!0)}):e(!0)}),new Promise(function(e){t.sended?e(!0):t.once(I.Send,function(){e(!0)})})]).then(function(){t.ready=!0,t.emit(I.Ready)});var o=this.option.get();this.pluginInstances.forEach(function(e){e.apply(t,o)}),this.get("is-crawler")||(this.inited=!0,this.emit(I.Init),this.sessionId=x(),this.on(I.AppShowStart,function(){t.sessionId=x()}))}else this.adapter.log("app_id invalid")}}},{key:"config",value:function(e){if(this.inited&&b(e)){this.emit(I.Config,e);var t=e.web_id,n=e.user_unique_id,i=l(e,["web_id","user_unique_id"]);void 0!==t&&this.emit(I.ConfigWebId,t),void 0!==n&&this.emit(I.ConfigUuid,n),this.env.set(i)}}},{key:"send",value:function(){this.inited&&!this.sended&&(this.sended=!0,this.emit(I.Send))}},{key:"event",value:function(e,t){var n=this;if(!this.get("is-crawler"))if(Array.isArray(e)){var i=O(),r=[];e.forEach(function(e){var t,o,s;if(Array.isArray(e)){var a=u(e,3);t=a[0],o=a[1],s=a[2]}else b(e)&&(t=e.event,o=e.params,s=e.local_time_ms);t&&((!w(s)||s<0||s>i)&&(s=i),r.push(n.createEvent({event:t,params:o,time:s})))}),r.length>0&&this.emit(I.Event,r)}else this.emit(I.Event,this.createEvent({event:e,params:t}))}},{key:"createEvent",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=Object.assign({event:e.event,params:e.params||{},local_time_ms:e.time||O()},this.sessionId?{session_id:this.sessionId}:{});if(!t)return n;var i="",r=this.get("ab_sdk_version");r&&(i+=r);var o=this.get("ab_sdk_version_external");return o&&(i?i+=","+o:i=o),Object.assign(Object.assign({},n),i?{ab_sdk_version:i}:{})}},{key:"set",value:function(e,t){this.data.set(e,t)}},{key:"get",value:function(e){return this.data.get(e)}},{key:"getKey",value:function(e){var t=this.appId;if("ab_version"===e||"ab_version_external"===e)return"__tea_sdk_".concat(e,"_").concat(t);var n={token:"tokens",report:"reports",event:"events",utm:"utm",first:"first",compensate:"compensate"};return n[e]?"__tea_cache_".concat(n[e],"_").concat(t):void 0}},{key:"getUrl",value:function(e){var t=this.option,n=this.env,i=n.get("_sdk_version"),r=(n.get("_sdk_name")||"").replace(/@.+\//,""),o="".concat(t.get("domain")).concat(e,"?sdk_version=").concat(i,"&sdk_name=").concat(r),s=t.get("caller");return s?"".concat(o,"&app_id=").concat(this.appId,"&caller=").concat(s):o}},{key:"getToken",value:function(e){var t=this;if(!e)return new Promise(function(e){t.emit(I.TokenGet,{callback:function(t){e(t)}})});this.emit(I.TokenGet,{callback:e})}},{key:"getConfig",value:function(e){return this.env.get(e||"header")}},{key:"stash",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="stash";this.set(n,[].concat(c(this.get(n)||[]),[this.createEvent({event:e,params:t})]))}},{key:"commit",value:function(){var e="stash",t=this.get(e)||[];t.length>0&&(this.event(t),this.set(e,[]))}},{key:"getVar",value:function(e,t,n){var i=this;if(!n)return new Promise(function(n){i.emit(I.AbVar,{name:e,defaultValue:t,callback:function(e){n(e)}})});this.emit(I.AbVar,{name:e,defaultValue:t,callback:n})}},{key:"getAllVars",value:function(e){var t=this;if(!e)return new Promise(function(e){t.emit(I.AbAllVars,function(t){e(t)})});this.emit(I.AbAllVars,e)}},{key:"getAbSdkVersion",value:function(){var e=this.get("ab_versions")||[];return e.length>0?e[e.length-1].ab:""}},{key:"onAbSdkVersionChange",value:function(e){var t=this;return this.emit(I.AbVersionChangeOn,e),function(){t.emit(I.AbVersionChangeOff,e)}}},{key:"offAbSdkVersionChange",value:function(e){this.emit(I.AbVersionChangeOff,e)}},{key:"setExternalAbVersion",value:function(e){this.emit(I.AbExternalVersion,"string"==typeof e&&e?"".concat(e).trim():null)}},{key:"getAbConfig",value:function(e,t){var n=this;if(!t)return new Promise(function(t){n.emit(I.AbRefresh,{params:e,callback:function(e){t(e)}})});this.emit(I.AbRefresh,{params:e,callback:t})}},{key:"profileSet",value:function(e){this.emit(I.ProfileSet,e)}},{key:"profileSetOnce",value:function(e){this.emit(I.ProfileSetOnce,e)}},{key:"profileUnset",value:function(e){this.emit(I.ProfileUnset,e)}},{key:"profileIncrement",value:function(e){this.emit(I.ProfileIncrement,e)}},{key:"profileAppend",value:function(e){this.emit(I.ProfileAppend,e)}},{key:"autoInitializationRangers",value:function(e){var t=e.onTokenReady,n=l(e,["onTokenReady"]);return this.init(Object.assign(Object.assign({},n),{log:!1,enable_third:!0})),this.send(),this.getToken().then(function(e){var n=e.web_id;try{if("function"==typeof t)return void t("".concat(n))}catch(e){}return"".concat(n)})}}],[{key:"useAdapterLog",value:function(e){t._log=e}},{key:"useAdapterRequest",value:function(e){t._request=e}},{key:"useAdapterStorage",value:function(e){t._storage=e}},{key:"usePlugin",value:function(e,n){var i=n||e.pluginName;if(i){for(var r=!1,o=0,s=t.plugins.length;o<s;o++)if(t.plugins[o].name===i){t.plugins[o].plugin=e,r=!0;break}r||t.plugins.push({name:i,plugin:e})}else t.plugins.push({plugin:e});if("function"==typeof e.init)try{e.init(t)}catch(e){}}}]),t}();U.plugins=[],U.instances=[];var j,q="3.0.0",$=function(){function t(){e(this,t)}return n(t,[{key:"apply",value:function(e,t){e.env.set({sdk_version:q,_sdk_version:q,_sdk_name:"@dp/tea-sdk-common"})}}]),t}();$.pluginName="official:info",function(e){e.Default="default",e.Custom="custom"}(j||(j={}));var T=function(){function t(n,i){e(this,t),this.wrap=n,this.sdk=i,this.url="/webid/"}return n(t,[{key:"storageNoData",value:function(){this.fetch()}},{key:"storageHasData",value:function(e){return this.wrap.dataComplete(e)}},{key:"fetch",value:function(){var e=this,t=this.sdk,n=t.adapter,i=t.appId;n.request({url:this.sdk.getUrl("".concat(this.url)),method:"POST",data:{app_id:i,url:"-",user_agent:"-",referer:"-",user_unique_id:""}}).then(function(t){try{var i=t.data,r=(i=void 0===i?{}:i).e,o=void 0===r?-1e4:r,s=i.web_id,a=void 0===s?"":s;if(0===o)return void e.fetchComplete(a);n.log("parse web_id error",o)}catch(e){n.log("parse web_id error",e)}e.fetchComplete()}).catch(function(t){e.fetchComplete(),n.log("fetch web_id error",t)})}},{key:"fetchComplete",value:function(e){e&&this.wrap.webIdComplete(e)}},{key:"storageComplete",value:function(e){if(e)try{if(e[this.wrap.typeKey]===j.Default){var t=this.storageHasData(e);this.wrap.complete(t)}else this.storageNoData()}catch(e){}else this.storageNoData()}}]),t}(),E=function(){function t(n,i){var r=this;e(this,t),this.wrap=n,this.sdk=i,this.sdk.on(this.sdk.types.ConfigWebId,function(e){e="".concat(e),r.wrap.tokenComplete?r.waitComplete(e):r.waitResolve?r.waitResolve(e):r.tmpWebId=e})}return n(t,[{key:"storageNoData",value:function(){this.wait()}},{key:"storageHasData",value:function(e){return this.wrap.dataComplete(e,this.tmpWebId)}},{key:"wait",value:function(){var e=this;new Promise(function(t){void 0!==e.tmpWebId?(t(e.tmpWebId),e.tmpWebId=void 0):e.waitResolve=t}).then(function(t){e.waitComplete(t)})}},{key:"waitComplete",value:function(e){this.wrap.webIdComplete(e)}},{key:"storageComplete",value:function(e){if(e)try{if(e[this.wrap.typeKey]===j.Custom){var t=this.storageHasData(e);this.wrap.complete(t)}else this.storageNoData()}catch(e){}else this.storageNoData()}}]),t}(),R=function(){function t(){e(this,t),this.tokenComplete=!1,this.tobid="",this.tobidUrl="/tobid/",this.tobidKey="",this.isCustom=!1,this.typeKey="_type_"}return n(t,[{key:"apply",value:function(e,t){var n=this;this.sdk=e,this.options=t,this.key=this.sdk.getKey("token"),this.tobidKey="diss".split("").reverse().join(""),this.options.enable_custom_webid?(this.isCustom=!0,this.token=new E(this,this.sdk)):(this.isCustom=!1,this.token=new T(this,this.sdk));var i=this.sdk.types;this.sdk.on(i.ConfigUuid,function(e){n.setUserUniqueId(e)}),this.sdk.on(i.TokenGet,function(e){var t=e.callback,r=function(){n.fetchTobid().then(function(){var e=n.sdk.env.get("user"),i=Object.assign(Object.assign({},e),{web_id:n.webId,user_unique_id:n.userUniqueId});i[n.tobidKey]=n.tobid,"function"==typeof t&&t(i)})};n.sdk.ready?r():n.sdk.once(i.Ready,function(){r()})}),this.storage()}},{key:"storage",value:function(){var e=this,t=this.sdk.adapter;t.get(this.key).then(function(n){b(n)&&n.web_id?(n[e.typeKey]&&!n[e.tobidKey]&&n.user_unique_id||(n={web_id:n.web_id,user_unique_id:n.user_unique_id||n.web_id},t.set(e.key,n)),e.storageComplete(n)):e.storageComplete(null)}).catch(function(n){e.storageComplete(null),t.log("get token error",n)})}},{key:"storageComplete",value:function(e){this.token.storageComplete(e)}},{key:"dataComplete",value:function(e,t){var n=e.web_id;void 0!==t&&t!==n&&(n=t),this.webId=n;var i=e.web_id===e.user_unique_id?n:e.user_unique_id;return void 0!==this.tmpUserUniqueId&&this.tmpUserUniqueId!==i&&(i=this.tmpUserUniqueId?this.tmpUserUniqueId:n,this.tmpUserUniqueId=void 0),this.userUniqueId=i,n!==e.web_id||i!==e.user_unique_id}},{key:"webIdComplete",value:function(e){this.webId=e,this.tmpUserUniqueId?(this.userUniqueId=this.tmpUserUniqueId,this.tmpUserUniqueId=void 0):this.userUniqueId=e,this.complete(!0)}},{key:"complete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.sdk.types,n=i({web_id:this.webId,user_unique_id:this.userUniqueId},this.typeKey,this.isCustom?j.Custom:j.Default);this.sdk.env.set(n),e&&this.sdk.adapter.set(this.key,n),this.tokenComplete=!0,this.sdk.emit(t.TokenComplete)}},{key:"setUserUniqueId",value:function(e){var t=this.sdk,n=t.adapter,r=t.env,o=t.types;if(this.tokenComplete){if(this.userUniqueId===e)return;this.sdk.emit(o.UuidChangeBefore),this.userUniqueId=e||this.webId,r.set({user_unique_id:this.userUniqueId});var s=i({web_id:this.webId,user_unique_id:this.userUniqueId},this.typeKey,this.isCustom?j.Custom:j.Default);n.set(this.key,s),this.sdk.emit(o.UuidChangeAfter)}else this.tmpUserUniqueId=e}},{key:"fetchTobid",value:function(){var e=this,t=this.sdk,n=t.adapter,i=t.appId;return n.request({url:this.sdk.getUrl("".concat(this.tobidUrl)),method:"POST",data:{app_id:i,web_id:this.webId,user_unique_id:this.userUniqueId}}).then(function(t){try{var n=t.data,i=(n=void 0===n?{}:n).e,r=void 0===i?-1e4:i,o=n.tobid,s=void 0===o?"":o;if(0===r)return void(e.tobid=s)}catch(e){}}).catch(function(e){n.log("fetch tobid error",e)})}}]),t}();R.pluginName="official:token";var D=function(){function t(){e(this,t),this.url="/list/",this.cache=[]}return n(t,[{key:"apply",value:function(e,t){var n=this;this.sdk=e,this.options=t,this.key=this.sdk.getKey("report"),this.reportUrl=this.sdk.getUrl("".concat(this.url)),this.sdk.set("report_url",this.reportUrl);var i=this.sdk.types;this.sdk.on(i.Report,function(e){Array.isArray(e)||(e=[e]),n.sdk.ready?n.report(e):e.forEach(function(e){return n.cache.push(e)})}),this.sdk.on(i.Ready,function(){n.cache.length>0&&(n.report(c(n.cache)),n.cache.length=0)});var r=this.sdk.adapter;this.sdk.on(i.AppOpen,function(){r.get(n.key).then(function(){})}),this.sdk.on(i.AppClose,function(){n.cache.length>0&&(r.set(n.key,c(n.cache)),n.cache.length=0)})}},{key:"report",value:function(e){this.submit(e)}},{key:"submit",value:function(e){var t=this,n=this.sdk.types;this.sdk.emit(n.SubmitBefore,e),this.sdk.adapter.request({url:this.reportUrl,method:"POST",data:e}).then(function(i){t.sdk.emit(n.SubmitAfter,{isError:!1,response:i,event:e})}).catch(function(i){t.sdk.emit(n.SubmitAfter,{isError:!0,error:i,event:e}),t.sdk.emit(n.SubmitError,{event:e})})}}]),t}();D.pluginName="official:report";var N=function(){function t(){e(this,t),this.buffer=[],this.timer=0,this.unReadyCache=[]}return n(t,[{key:"apply",value:function(e,t){var n,i,r=this;this.sdk=e,this.options=t,this.enable=!!this.options.enable_buffer;var o=!0===this.options.enable_storage||!1===this.options.disable_storage;if(o&&(this.enable=!0),this.enable){this.interval=this.options.buffer_interval,this.number=this.options.buffer_number,o&&((null===(n=this.options)||void 0===n?void 0:n.report_interval)>0&&(this.interval=this.options.report_interval),(null===(i=this.options)||void 0===i?void 0:i.max_batch_event)>0&&(this.number=this.options.max_batch_event));try{this.interval=Number(this.interval),this.number=Number(this.number)}catch(e){}}this.sdk.set("enable_storage",this.enable);var s=this.sdk.types;this.sdk.on(s.Event,function(e){r.sdk.ready?r.process(Array.isArray(e)?e:[e]):r.unReadyCache=[].concat(c(r.unReadyCache),c(Array.isArray(e)?e:[e]))}),this.sdk.on(s.Ready,function(){r.unReadyCache.length>0&&(r.process(r.unReadyCache),r.unReadyCache=[])}),this.sdk.on(s.AppClose,function(){r.buffer.length>0&&(r.report(r.buffer),r.buffer.length=0)})}},{key:"process",value:function(e){var t=this.sdk.env.compose(e);this.enable?(this.buffer=[].concat(c(this.buffer),[t]),this.refresh()):this.report(t)}},{key:"refresh",value:function(){var e=this;this.timer&&clearTimeout(this.timer),this.buffer.length>=this.number?(this.report(c(this.buffer)),this.buffer.length=0):this.timer=setTimeout(function(){e.report(c(e.buffer)),e.buffer.length=0},this.interval)}},{key:"report",value:function(e){this.sdk.emit(this.sdk.types.Report,e)}}]),t}();N.pluginName="official:buffer";var V=function(){function t(){e(this,t)}return n(t,[{key:"apply",value:function(e,t){var n=this;this.sdk=e,this.options=t;var i=this.sdk,r=i.types,o=i.env,s=function(){try{var e=(new Date).getTimezoneOffset();return{timezone:Math.floor(Math.abs(e)/60),offset:60*e}}catch(e){return{timezone:8,offset:-28800}}}();o.set({timezone:s.timezone,tz_offset:s.offset}),this.sdk.on(r.ConfigTransform,function(e){if(void 0!==e.gender&&([1,2,"1","2"].includes(e.gender)?e.gender=e.gender<2?"male":"female":delete e.gender),n.options.enable_profile){var t={};["nick_name","gender","avatar_url"].forEach(function(n){void 0!==e[n]&&(t[n]=e[n],delete e[n])}),n.sdk.emit(r.ProfileSet,t)}}),this.sdk.on(r.EnvTransform,function(e){if(n.options.enable_profile){var t={};["$mp_from_uuid"].forEach(function(n){void 0!==e[n]&&(t[n]=e[n],delete e[n])}),Object.keys(t).length>0&&n.sdk.emit(r.ProfileSetOnce,t)}})}}]),t}();V.pluginName="official:transform",U.usePlugin($),U.usePlugin(R),U.usePlugin(D),U.usePlugin(N),U.usePlugin(V);var K=console,z=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function(n){return function(i){var r=i.timeout||n.option.get("request_timeout"),o="number"==typeof r&&r>0;return new Promise(function(n,s){var a=e.request(Object.assign(Object.assign(Object.assign({},i),o&&!t?{timeout:r}:{}),{dataType:i.dataType||"json",success:function(e){n(e)},fail:function(e){s(e)}}));o&&t&&setTimeout(function(){try{a&&a.abort()}catch(e){}},r)})}}}(wx),H=new(function(){function t(n){e(this,t),this.target=n}return n(t,[{key:"get",value:function(e){var t=this;return new Promise(function(n,i){try{n(t.target.getStorageSync(e))}catch(e){i(e)}})}},{key:"set",value:function(e,t){var n=this;return new Promise(function(i,r){try{n.target.setStorageSync(e,t),i(!0)}catch(e){r(!1)}})}},{key:"remove",value:function(e){var t=this;return new Promise(function(n,i){try{t.target.removeStorageSync(e),n(!0)}catch(e){i(!1)}})}}]),t}())(wx),M=function(){function t(){e(this,t)}return n(t,[{key:"apply",value:function(e,t){var n=this;this.sdk=e,this.options=t,this.boost();var i=this.sdk.types;this.getInfo(),this.sdk.on(i.AppOpen,function(){n.getInfo()})}},{key:"boost",value:function(){}},{key:"getInfo",value:function(){var e=this,t=this.sdk,n=t.target,i=t.env;n&&(n.getSystemInfo&&n.getSystemInfo({success:function(t){var n=Math.ceil(t.screenWidth),r=Math.ceil(t.screenHeight),o={device_brand:t.brand,device_model:t.model,os_version:t.system,os_name:t.platform,platform:t.platform,resolution:"".concat(n,"x").concat(r),screen_width:n,screen_height:r};e.overlap(t,o),i.set(o)}}),n.getNetworkType&&n.getNetworkType({success:function(e){var t={access:e.networkType};i.set(t)}}))}},{key:"overlap",value:function(e,t){t.language=e.language,t.mp_platform_app_version=e.version,t.mp_platform_basic_version=e.SDKVersion}}]),t}();M.pluginName="official:device";var W=function(t){!function(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t)}(s,t);var i=function(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,i=r(e);if(t){var o=r(this).constructor;n=Reflect.construct(i,arguments,o)}else n=i.apply(this,arguments);return function(e,t){if(t&&("object"==_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,n)}}(s);function s(){return e(this,s),i.apply(this,arguments)}return n(s,[{key:"boost",value:function(){a(r(s.prototype),"boost",this).call(this),this.sdk.target=wx,this.sdk.targetEnvConfig="undefined"!=typeof __wxConfig?__wxConfig:null,this.sdk.env.set({sdk_lib:"mp_common",custom_platform:"miniProduct",mp_platform:0})}},{key:"overlap",value:function(e,t){a(r(s.prototype),"overlap",this).call(this,e,t)}}],[{key:"init",value:function(e){e.platform=wx}}]),s}(M);return U.useAdapterLog(K),U.useAdapterRequest(z),U.useAdapterStorage(H),U.usePlugin(W),U});