turbolink-ai 1.1.7 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +1 -1
- package/package.json +1 -1
- package/dist/turbolink1.1.7.js +0 -1
package/dist/index.es.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&s(e,n,t[n]);if(o)for(var n of o(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),l=(e,t,n)=>new Promise(((o,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},s=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,s);a((n=n.apply(e,t)).next())}));let d="https://www.allapp.link";const u=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);z.appKey&&(i.Authorization="Bearer "+z.appKey),fetch(d+e,{method:t,headers:i,body:JSON.stringify(o)}).then((e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")})).then((e=>{r(e)})).catch((e=>{r(e)}))}));var p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function h(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})})),n}var g={exports:{}};var m={exports:{}};const y=h(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var w,v,b,_,S,x,C,E,k;function P(){return w||(w=1,m.exports=(e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==p&&p.crypto&&(n=p.crypto),!n)try{n=y}catch(e){}var o=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},r=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),i={},s=i.lib={},a=s.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,o=this.sigBytes,r=e.sigBytes;if(this.clamp(),o%4)for(var i=0;i<r;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[o+i>>>2]|=s<<24-(o+i)%4*8}else for(var a=0;a<r;a+=4)t[o+a>>>2]=n[a>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push((i>>>4).toString(16)),o.push((15&i).toString(16))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o+=2)n[o>>>3]|=parseInt(e.substr(o,2),16)<<24-o%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push(String.fromCharCode(i))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o++)n[o>>>2]|=(255&e.charCodeAt(o))<<24-o%4*8;return new c.init(n,t)}},f=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=f.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,o=this._data,r=o.words,i=o.sigBytes,s=this.blockSize,a=i/(4*s),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*l,i);if(l){for(var u=0;u<l;u+=s)this._doProcessBlock(r,u);n=r.splice(0,l),o.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=h.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new g.HMAC.init(e,n).finalize(t)}}});var g=i.algo={};return i}(Math),e)),m.exports;var e}const A=f(g.exports=(k=P(),b=(v=k).lib,_=b.WordArray,S=b.Hasher,x=v.algo,C=[],E=x.SHA1=S.extend({_doReset:function(){this._hash=new _.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,o=n[0],r=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)C[c]=0|e[t+c];else{var l=C[c-3]^C[c-8]^C[c-14]^C[c-16];C[c]=l<<1|l>>>31}var d=(o<<5|o>>>27)+a+C[c];d+=c<20?1518500249+(r&i|~r&s):c<40?1859775393+(r^i^s):c<60?(r&i|r&s|i&s)-1894007588:(r^i^s)-899497514,a=s,s=i,i=r<<30|r>>>2,r=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return t[o>>>5]|=128<<24-o%32,t[14+(o+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(o+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=S.clone.call(this);return e._hash=this._hash.clone(),e}}),v.SHA1=S._createHelper(E),v.HmacSHA1=S._createHmacHelper(E),k.SHA1)),I="tb_cookie_obj",O="tb_randomId",U="tb_load_url",L="tb_load_source_url",j="tb_ascribe_to_url",B="tb_source_ascribe_to";class T{constructor(e=!0){this.storage=e?localStorage:sessionStorage}set(e,t){this.storage.setItem(e,JSON.stringify(t))}get(e){const t=this.storage.getItem(e);if(t)return JSON.parse(t)}remove(e){return this.storage.removeItem(e)}clear(){this.storage.clear()}}const $=(e,t)=>{function n(e,t){return e<<t|e>>>32-t}function o(e,t){var n,o,r,i,s;return r=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(o=1073741824&t)?2147483648^s^r^i:n|o?1073741824&s?3221225472^s^r^i:1073741824^s^r^i:s^r^i}function r(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),c)),o(n(e,a),t)}function i(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),c)),o(n(e,a),t)}function s(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),c)),o(n(e,a),t)}function a(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),c)),o(n(e,a),t)}function c(e){var t,n="",o="";for(t=0;t<=3;t++)n+=(o="0"+(e>>>8*t&255).toString(16)).substr(o.length-2,2);return n}var l,d,u,p,f,h,g,m,y,w=Array();for(w=function(e){for(var t,n=e.length,o=n+8,r=16*((o-o%64)/64+1),i=Array(r-1),s=0,a=0;a<n;)s=a%4*8,i[t=(a-a%4)/4]=i[t]|e.charCodeAt(a)<<s,a++;return s=a%4*8,i[t=(a-a%4)/4]=i[t]|128<<s,i[r-2]=n<<3,i[r-1]=n>>>29,i}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t}(e)),h=1732584193,g=4023233417,m=2562383102,y=271733878,l=0;l<w.length;l+=16)d=h,u=g,p=m,f=y,h=r(h,g,m,y,w[l+0],7,3614090360),y=r(y,h,g,m,w[l+1],12,3905402710),m=r(m,y,h,g,w[l+2],17,606105819),g=r(g,m,y,h,w[l+3],22,3250441966),h=r(h,g,m,y,w[l+4],7,4118548399),y=r(y,h,g,m,w[l+5],12,1200080426),m=r(m,y,h,g,w[l+6],17,2821735955),g=r(g,m,y,h,w[l+7],22,4249261313),h=r(h,g,m,y,w[l+8],7,1770035416),y=r(y,h,g,m,w[l+9],12,2336552879),m=r(m,y,h,g,w[l+10],17,4294925233),g=r(g,m,y,h,w[l+11],22,2304563134),h=r(h,g,m,y,w[l+12],7,1804603682),y=r(y,h,g,m,w[l+13],12,4254626195),m=r(m,y,h,g,w[l+14],17,2792965006),h=i(h,g=r(g,m,y,h,w[l+15],22,1236535329),m,y,w[l+1],5,4129170786),y=i(y,h,g,m,w[l+6],9,3225465664),m=i(m,y,h,g,w[l+11],14,643717713),g=i(g,m,y,h,w[l+0],20,3921069994),h=i(h,g,m,y,w[l+5],5,3593408605),y=i(y,h,g,m,w[l+10],9,38016083),m=i(m,y,h,g,w[l+15],14,3634488961),g=i(g,m,y,h,w[l+4],20,3889429448),h=i(h,g,m,y,w[l+9],5,568446438),y=i(y,h,g,m,w[l+14],9,3275163606),m=i(m,y,h,g,w[l+3],14,4107603335),g=i(g,m,y,h,w[l+8],20,1163531501),h=i(h,g,m,y,w[l+13],5,2850285829),y=i(y,h,g,m,w[l+2],9,4243563512),m=i(m,y,h,g,w[l+7],14,1735328473),h=s(h,g=i(g,m,y,h,w[l+12],20,2368359562),m,y,w[l+5],4,4294588738),y=s(y,h,g,m,w[l+8],11,2272392833),m=s(m,y,h,g,w[l+11],16,1839030562),g=s(g,m,y,h,w[l+14],23,4259657740),h=s(h,g,m,y,w[l+1],4,2763975236),y=s(y,h,g,m,w[l+4],11,1272893353),m=s(m,y,h,g,w[l+7],16,4139469664),g=s(g,m,y,h,w[l+10],23,3200236656),h=s(h,g,m,y,w[l+13],4,681279174),y=s(y,h,g,m,w[l+0],11,3936430074),m=s(m,y,h,g,w[l+3],16,3572445317),g=s(g,m,y,h,w[l+6],23,76029189),h=s(h,g,m,y,w[l+9],4,3654602809),y=s(y,h,g,m,w[l+12],11,3873151461),m=s(m,y,h,g,w[l+15],16,530742520),h=a(h,g=s(g,m,y,h,w[l+2],23,3299628645),m,y,w[l+0],6,4096336452),y=a(y,h,g,m,w[l+7],10,1126891415),m=a(m,y,h,g,w[l+14],15,2878612391),g=a(g,m,y,h,w[l+5],21,4237533241),h=a(h,g,m,y,w[l+12],6,1700485571),y=a(y,h,g,m,w[l+3],10,2399980690),m=a(m,y,h,g,w[l+10],15,4293915773),g=a(g,m,y,h,w[l+1],21,2240044497),h=a(h,g,m,y,w[l+8],6,1873313359),y=a(y,h,g,m,w[l+15],10,4264355552),m=a(m,y,h,g,w[l+6],15,2734768916),g=a(g,m,y,h,w[l+13],21,1309151649),h=a(h,g,m,y,w[l+4],6,4149444226),y=a(y,h,g,m,w[l+11],10,3174756917),m=a(m,y,h,g,w[l+2],15,718787259),g=a(g,m,y,h,w[l+9],21,3951481745),h=o(h,d),g=o(g,u),m=o(m,p),y=o(y,f);return 32===t?(c(h)+c(g)+c(m)+c(y)).toLowerCase():(c(g)+c(m)).toLowerCase()},R=(e,t)=>l(void 0,null,(function*(){const n=t||function(){};try{const t=new T;let o=t.get(I);const r=o?JSON.parse(o):{},i=r?r[e]:null;if(""!==i&&i)n(i);else{const o=function(e){const t=new T(!0);let n=t.get(O);if(!n||""===n){const o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let r="";for(let t=0;t<e;t++){const e=Math.floor(Math.random()*o.length);r+=o.charAt(e)}n=r,t.set(O,n)}return n}(32),i=navigator.language,s=N(),a=K(),c=yield u({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(r[e]=d.cookie_id,t.set(I,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const N=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},K=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},M={SUCCESS:{code:200,message:"Success"},UNKNOWN:{code:9999,message:"Unknown"},LACK_APPKEY:{code:1001,message:"Missing appKey parameter"},LACK_APPSECRET:{code:1002,message:"Missing appSecret parameter"},LACK_PROJECTID:{code:1003,message:"Missing projectId parameter"},NOT_INIT:{code:1004,message:"Please call the init method first"},EMPTY_EVENT_NAME:{code:1005,message:"Event name cannot be empty"},INVALID_URL:{code:1006,message:"Invalid URL"},LACK_UID:{code:1007,message:"Missing uId parameter"}},D={name:"turbolink-ai",version:"1.1.7",description:"",main:"dist/index.es.js",module:"dist/index.es.js",type:"module",scripts:{test:'echo "Error: no test specified" && exit 1',build:"vite build"},author:"",license:"MIT",devDependencies:{"@babel/plugin-transform-modules-commonjs":"^7.23.3","crypto-js":"^4.2.0",eslint:"^8.53.0","rollup-plugin-terser":"^7.0.2",vite:"^4.5.0"},dependencies:{"javascript-obfuscator":"^4.1.0"}};let z={appKey:"",appSecret:"",projectId:""},H="",V="",W="",F=!1,Y=!0,J="";let X="";const G=e=>new Promise((t=>{Q("install").then((n=>{t(n),e&&e(n)}))})),Z=e=>new Promise((t=>{Q("open").then((n=>{t(n),e&&e(n)}))})),q=()=>!(null===H||""===H||" "===H||void 0===H),Q=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=z||{};if(""===o||!o||""===r||!r||""===i||!i)throw M.NOT_INIT;if(!e||""===e)throw M.EMPTY_EVENT_NAME;R(i,(o=>l(void 0,null,(function*(){var s,a;const c=N(),d=K(),p=(new Date).valueOf(),f=null==p?void 0:p.toString(),h=null==(s=A(`${i}_${f}_${p}_${r}`))?void 0:s.toString(),g=(()=>{let e="Android";try{const t=navigator.userAgent.toLowerCase();/android/.test(t)?e="Android":/iphone|ipad|ipod/.test(t)?e="iOS":/win/.test(t)?e="Windows":/mac/.test(t)?e="macOS":/linux/.test(t)&&(e="Linux")}catch(t){e="Android"}return e})(),m=yield l(void 0,null,(function*(){const e=navigator.userAgent.toLowerCase();let t="";try{if(/android/.test(e))if(navigator.userAgent.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.platformVersion}else t=e.match(/android\s([0-9.]+)/)[1];else/iphone|ipad|ipod/.test(e)?t=e.match(/os\s([\d_]+)/)[1].replace(/_/g,"."):/win/.test(e)?t=e.match(/windows\snt\s([\d.]+)/)[1]:/mac/.test(e)?t=e.match(/os x\s([\d_]+)/)[1].replace(/_/g,"."):/linux/.test(e)&&(t="Unknown")}catch(e){t="Unknown"}return t})),y=yield l(void 0,null,(function*(){const e=navigator.userAgent;let t="Windows";try{if(e.includes("iPhone"))t="iPhone";else if(e.includes("iPad"))t="iPad";else if(e.includes("Android"))if(e.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.model||"Windows"}else if(e.includes("Build")){const n=e.match(/Android.*; ?(.*(?= Build))/);n&&n.length>1&&(t=n[1])}else if(e.includes("wv")){const n=e.match(/Android.*; ?(.*(?= wv))/);if(n&&n.length>0){const e=n[0].split(";");e&&e.length>1&&(t=e[1])}}else{const n=e.match(/Android.*; ([^)]+)/);n&&n.length>1&&(t=n[1])}else e.includes("Mac")&&(t="Mac")}catch(e){t="Windows"}return t})),w=yield new Promise((e=>{try{const t=new RTCPeerConnection;t.createDataChannel(""),t.onicecandidate=function(n){if(n.candidate){const o=n.candidate.candidate,r=/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.exec(o),i=r?r[0]:null;e(i),t.close()}else e()},t.createOffer().then((e=>t.setLocalDescription(e))).catch((()=>{e()}))}catch(t){e()}})),v=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),b=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),_=(()=>{const e=navigator.userAgent;return-1!==e.indexOf("Firefox")?"Firefox":-1!==e.indexOf("Opera")||-1!==e.indexOf("OPR")?"Opera":-1!==e.indexOf("Trident")?"IE":-1!==e.indexOf("Edge")?"Edge":-1!==e.indexOf("Chrome")?"Chrome":-1!==e.indexOf("Safari")?"Safari":"unknown"})(),S=null==(a=(()=>{let e=0;try{const t=navigator.userAgent;-1!==t.indexOf("Firefox")?e=parseFloat(null==t?void 0:t.match(/Firefox\/([\d.]+)/)[1])||0:-1!==t.indexOf("Edge")?e=parseFloat(null==t?void 0:t.match(/Edge\/([\d.]+)/)[1])||0:-1!==t.indexOf("Chrome")?e=parseFloat(null==t?void 0:t.match(/Chrome\/([\d.]+)/)[1])||0:-1!==t.indexOf("Safari")?e=parseFloat(null==t?void 0:t.match(/Version\/([\d.]+)/)[1])||0:(-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident/"))&&(e=parseFloat((null==t?void 0:t.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1])||(null==t?void 0:t.match(/rv:([\d.]+)/)))||0)}catch(t){e=0}return e})())?void 0:a.toString(),x=(null==D?void 0:D.version)||"1.0.0",C=`${c}x${d}`,E=window.location.href,k=navigator.userAgent,P="UTC+"+(0-(new Date).getTimezoneOffset()/60),I=document.referrer,O=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="turbolink <canvas> 1.0";t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17);const o=e.toDataURL();return $(o,32)})(),U={web:{browser_name:_,browser_version:S,current_time:p,device_type:y,ip:w||"",language:b,os:g,screen_resolution:C,sdk_version:x,url:E,user_agent:k,time_zone:P,referer:I,canvas:O}};let L=[];t&&t.constructor===Array&&(L=t.map((e=>{const t={};return Object.keys(e).forEach((n=>{const o=e[n];t[n]="string"!=typeof o?String(o):o})),t})));const R={project:i,request_id:f,timestamp:p,msg_signature:h,event:e,user_data:{native_msg:"",os:g,os_version:m,device_model:y,device_id:o,user_id:null==H?void 0:H.toString(),country:v,language:b,screen_width:c,screen_height:d,ip:w||""},custom_data:L,ext_data:U},M=yield u({url:"/v2/event",params:R}),{code:z,data:V,msg:W}=M||{};if(200===z&&V){let e="";const t=V.link_data||[];V.blackbox&&""!==V.blackbox&&(X=V.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(Y&&""!==e){let t=ee(e);if(J&&""!==J){const e=encodeURIComponent(J);t=`${t}&loginUrl=${e}`}if(!q()){const t=new T(!1);t.set(j,e),t.set(B,"1")}setTimeout((()=>{window.location.href=t}),100)}n({code:z,message:W,data:V})}else n({code:z,message:W})}))))}catch(e){n(e)}})),ee=e=>{if(!e||""===e)return"";const t=H||"",n=navigator.language,o=V||n||"",r=Math.floor((new Date).getTime()/1e3),i="1.2.0",s=r%100,a="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(s,s+12),c=`${t}${W}${o}${r}${X}${i}web${z.appSecret}${a}`,l=$(c,32);return((e,t)=>{const n=new URL(e),o=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;o.has(t)?o.set(t,n):o.append(t,n)})),n.origin+n.pathname+"?"+o.toString()})(e,[{name:"user_id",value:t},{name:"lv",value:W},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:X},{name:"version",value:i},{name:"platform",value:"web"},{name:"token",value:l}])},te=e=>l(void 0,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==z?void 0:z.projectId},o=yield u({url:"/v2/campaign/sdk-info",params:n}),r=document.getElementById("turbolinkSdkBgImg"),{code:i,data:s}=o||{};if(200===i&&s){const{pc_bg:e}=s||{};r&&(r.src=e&&""!==e?e:t)}else r&&(r.src=t)}));class ne{}c(ne,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:c,loginUrl:l,jump:u=!0,dev:p=!1}=e||{};if(!t||""===t)throw M.LACK_APPKEY;if(!r||""===r)throw M.LACK_APPSECRET;if(!i||""===i)throw M.LACK_PROJECTID;p&&(e=>{e&&(d="https://test.allapp.link")})(p),s&&(H=s),a&&(V=a),c&&(W=c),l&&(J=l),Y=u,z=e||{};let f=(new T).get(O);if(F)return n(M.SUCCESS),void o(M.SUCCESS);if(null==f||" "===f||""===f)G().then((e=>{n(e),o(e)}));else{Z().then((e=>{n(e),o(e)}));const e=new T(!1),t=e.get(j),r=e.get(B);if(r&&"1"===r){let n=ee(t);if(e.remove(B),e.remove(j),J&&""!==J){n=`${n}&loginUrl=${encodeURIComponent(J)}`}window.location.replace(n&&n)}}F=!0}catch(e){n(e),o(e)}})))),c(ne,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:o,UNKNOWN:r}=M||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(H=t),n&&(W=n)}else H=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(ne,"install",G),c(ne,"register",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{uid:t,uId:r,lv:i}=e||{};if(!(t&&""!==t||r&&""!==r))throw M.LACK_UID;t&&(H=t),r&&(H=r),Q("register").then((e=>{const t=new T,r=t.get(U),i=t.get(L);if(i&&"1"===i){const e=ee(r);window.location.replace(e&&e),t.remove(L)}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ne,"open",Z),c(ne,"customEvent",((e,o)=>new Promise((r=>{const i=o||function(){};try{const{event:o,customData:s,backCamp:c}=e||{};if(!o||""===o)throw M.EMPTY_EVENT_NAME;Q(o,s).then((e=>{const o=(new T).get(U),s=ee(o),l=((e,o)=>t(e,n(o)))(a({},e),{campUrl:s});c&&s&&window.location.replace(s),r(l),i(l)}))}catch(e){r(e),i(e)}})))),c(ne,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},{url:i,newWindow:s=!1}=e||{};try{if(!z.appSecret||""===z.appSecret)throw M.LACK_APPSECRET;if(!i||""===i)throw M.INVALID_URL;let e=ee(i);if(J&&""!==J){e=`${e}&loginUrl=${encodeURIComponent(J)}`}const t=new T;t.set(U,i),t.set(L,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),Q("loadUrl")}catch(e){n(e),o(e)}})))),c(ne,"webLoadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},i=650,{url:s,maskColor:a="rgba(0, 0, 0, 0.8)",backgroundImage:c,backgroundHeight:l=738,backgroundWidth:d,bgLinkage:u=!1,width:p=300,height:f=i,radius:h=12,zIndex:g=3e3,clickEventCallback:m,bodyHidden:y=!0,jumpNewWindow:w=!1}=e||{};try{if(!z.appSecret||""===z.appSecret)throw M.LACK_APPSECRET;if(!s||""===s)throw M.INVALID_URL;const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=ee(s);if(v=`${v}&webIframe=1`,w&&(v=`${v}&jpN=1`),J&&""!==J){v=`${v}&loginUrl=${encodeURIComponent(J)}`}let b=document.getElementById("turbolinkSdkPopup");b&&b.remove();const _=document.createElement("div");_.id="turbolinkSdkPopup",_.style.position="fixed",_.style.zIndex=g,_.style.left="0",_.style.top="0",_.style.right="0",_.style.bottom="0",_.style.width="100%",_.style.height="100%",_.style.overflowX="hidden",_.style.overflowY="auto",_.style.backgroundColor=a;const S=document.createElement("div");S.style.minHeight="100%",S.style.display="-webkit-box",S.style.display="-ms-flexbox",S.style.display="-moz-box",S.style.display="flex",S.style.textAlign="center",S.style.justifyContent="center",S.style.alignItems="center";const x=document.createElement("div");x.style.margin="10vh auto",x.style.border="none",x.style.width=`${p}px`,x.style.height=`${f}px`,x.style.position="relative",x.style.borderRadius=`${h}px`,x.style.display="-webkit-box",x.style.display="-ms-flexbox",x.style.display="-moz-box",x.style.display="flex",x.style.textAlign="center",x.style.justifyContent="center",x.style.alignItems="center";const C=document.createElement("iframe");C.id="turbolinkSdkPopupIframe",C.width=`${p}px`,C.height=`${f}px`,C.style.border="none",C.style.borderRadius=`${h}px`,C.style.overflow="hidden",C.style.position="relative",C.style.zIndex="10",C.src=v;const E=document.createElement("div"),k=document.createElement("img");let P=l;u&&(P=f*(P/i)),E.style.height=`${P}px`,C.onload=()=>{E.style.position="absolute",E.style.fontSize="0px",E.style.zIndex="6",k.id="turbolinkSdkBgImg",c&&""!==c?k.src=c:te(t),k.style.width=d||"auto",k.style.height="100%",k.style.setProperty("max-width","none","important"),k.style.setProperty("max-height","none","important"),E.appendChild(k)};const A=document.createElement("div"),I=document.createElement("img");A.style.position="absolute",A.style.fontSize="0px",A.style.zIndex="100",A.style.top="-54px",A.style.right="-200px",I.src="https://i1.branchcn.com/web/sdk/img/campClose.png",I.style.width="40px",I.style.height="auto",A.appendChild(I);const O=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";n&&"turbolink"===n&&m(e.data)}};m&&(window.removeEventListener("message",O),window.addEventListener("message",O)),A.addEventListener("click",(()=>{_.remove(),y&&(document.body.style.overflow="auto"),m&&(m({type:"linkCloseListener",params:null}),window.removeEventListener("message",O))})),x.appendChild(E),x.appendChild(C),x.appendChild(A),S.appendChild(x),_.appendChild(S),document.body.appendChild(_),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})))),c(ne,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{document.getElementById("turbolinkSdkPopup").remove(),n(o),t(o)}catch(e){t(e),n(e)}})))),c(ne,"login",((e,t)=>new Promise((n=>{const o=t||function(){},{uid:r,uId:i,lv:s}=e||{};try{if(!(r&&""!==r||i&&""!==i))throw M.LACK_UID;r&&(H=r),i&&(H=i),Q("login").then((e=>{const t=new T,r=t.get(U),i=t.get(L);if(i&&"1"===i){const e=ee(r);window.location.replace(e&&e),t.remove(L)}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ne,"logout",(e=>new Promise((t=>{const n=e||function(){};(new T).remove(U),H=null;const{SUCCESS:o}=M||{};t(o),n(o),Q("logout")})))),c(ne,"getInitState",(()=>F)),c(ne,"getLoginState",q);export{ne as default};
|
|
1
|
+
var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&s(e,n,t[n]);if(o)for(var n of o(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),l=(e,t,n)=>new Promise(((o,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},s=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,s);a((n=n.apply(e,t)).next())}));let d="https://www.allapp.link";const u=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);H.appKey&&(i.Authorization="Bearer "+H.appKey),fetch(d+e,{method:t,headers:i,body:JSON.stringify(o)}).then((e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")})).then((e=>{r(e)})).catch((e=>{r(e)}))}));var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})})),n}var h={exports:{}};var m={exports:{}};const y=g(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var w,v,b,S,_,x,C,I,E;function P(){return w||(w=1,m.exports=(e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==f&&f.crypto&&(n=f.crypto),!n)try{n=y}catch(e){}var o=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},r=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),i={},s=i.lib={},a=s.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,o=this.sigBytes,r=e.sigBytes;if(this.clamp(),o%4)for(var i=0;i<r;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[o+i>>>2]|=s<<24-(o+i)%4*8}else for(var a=0;a<r;a+=4)t[o+a>>>2]=n[a>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push((i>>>4).toString(16)),o.push((15&i).toString(16))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o+=2)n[o>>>3]|=parseInt(e.substr(o,2),16)<<24-o%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push(String.fromCharCode(i))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o++)n[o>>>2]|=(255&e.charCodeAt(o))<<24-o%4*8;return new c.init(n,t)}},p=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},g=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,o=this._data,r=o.words,i=o.sigBytes,s=this.blockSize,a=i/(4*s),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*l,i);if(l){for(var u=0;u<l;u+=s)this._doProcessBlock(r,u);n=r.splice(0,l),o.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=g.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){g.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new h.HMAC.init(e,n).finalize(t)}}});var h=i.algo={};return i}(Math),e)),m.exports;var e}const A=p(h.exports=(E=P(),b=(v=E).lib,S=b.WordArray,_=b.Hasher,x=v.algo,C=[],I=x.SHA1=_.extend({_doReset:function(){this._hash=new S.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,o=n[0],r=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)C[c]=0|e[t+c];else{var l=C[c-3]^C[c-8]^C[c-14]^C[c-16];C[c]=l<<1|l>>>31}var d=(o<<5|o>>>27)+a+C[c];d+=c<20?1518500249+(r&i|~r&s):c<40?1859775393+(r^i^s):c<60?(r&i|r&s|i&s)-1894007588:(r^i^s)-899497514,a=s,s=i,i=r<<30|r>>>2,r=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return t[o>>>5]|=128<<24-o%32,t[14+(o+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(o+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=_.clone.call(this);return e._hash=this._hash.clone(),e}}),v.SHA1=_._createHelper(I),v.HmacSHA1=_._createHmacHelper(I),E.SHA1)),k="tb_cookie_obj",O="tb_randomId",U="tb_load_url",L="tb_load_source_url",j="tb_ascribe_to_url",B="tb_init_state",T="tb_blackbox";class ${constructor(e=!0){this.storage=e?localStorage:sessionStorage}set(e,t){this.storage.setItem(e,JSON.stringify(t))}get(e){const t=this.storage.getItem(e);if(t)return JSON.parse(t)}remove(e){return this.storage.removeItem(e)}clear(){this.storage.clear()}}const R=(e,t)=>{function n(e,t){return e<<t|e>>>32-t}function o(e,t){var n,o,r,i,s;return r=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(o=1073741824&t)?2147483648^s^r^i:n|o?1073741824&s?3221225472^s^r^i:1073741824^s^r^i:s^r^i}function r(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),c)),o(n(e,a),t)}function i(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),c)),o(n(e,a),t)}function s(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),c)),o(n(e,a),t)}function a(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),c)),o(n(e,a),t)}function c(e){var t,n="",o="";for(t=0;t<=3;t++)n+=(o="0"+(e>>>8*t&255).toString(16)).substr(o.length-2,2);return n}var l,d,u,f,p,g,h,m,y,w=Array();for(w=function(e){for(var t,n=e.length,o=n+8,r=16*((o-o%64)/64+1),i=Array(r-1),s=0,a=0;a<n;)s=a%4*8,i[t=(a-a%4)/4]=i[t]|e.charCodeAt(a)<<s,a++;return s=a%4*8,i[t=(a-a%4)/4]=i[t]|128<<s,i[r-2]=n<<3,i[r-1]=n>>>29,i}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t}(e)),g=1732584193,h=4023233417,m=2562383102,y=271733878,l=0;l<w.length;l+=16)d=g,u=h,f=m,p=y,g=r(g,h,m,y,w[l+0],7,3614090360),y=r(y,g,h,m,w[l+1],12,3905402710),m=r(m,y,g,h,w[l+2],17,606105819),h=r(h,m,y,g,w[l+3],22,3250441966),g=r(g,h,m,y,w[l+4],7,4118548399),y=r(y,g,h,m,w[l+5],12,1200080426),m=r(m,y,g,h,w[l+6],17,2821735955),h=r(h,m,y,g,w[l+7],22,4249261313),g=r(g,h,m,y,w[l+8],7,1770035416),y=r(y,g,h,m,w[l+9],12,2336552879),m=r(m,y,g,h,w[l+10],17,4294925233),h=r(h,m,y,g,w[l+11],22,2304563134),g=r(g,h,m,y,w[l+12],7,1804603682),y=r(y,g,h,m,w[l+13],12,4254626195),m=r(m,y,g,h,w[l+14],17,2792965006),g=i(g,h=r(h,m,y,g,w[l+15],22,1236535329),m,y,w[l+1],5,4129170786),y=i(y,g,h,m,w[l+6],9,3225465664),m=i(m,y,g,h,w[l+11],14,643717713),h=i(h,m,y,g,w[l+0],20,3921069994),g=i(g,h,m,y,w[l+5],5,3593408605),y=i(y,g,h,m,w[l+10],9,38016083),m=i(m,y,g,h,w[l+15],14,3634488961),h=i(h,m,y,g,w[l+4],20,3889429448),g=i(g,h,m,y,w[l+9],5,568446438),y=i(y,g,h,m,w[l+14],9,3275163606),m=i(m,y,g,h,w[l+3],14,4107603335),h=i(h,m,y,g,w[l+8],20,1163531501),g=i(g,h,m,y,w[l+13],5,2850285829),y=i(y,g,h,m,w[l+2],9,4243563512),m=i(m,y,g,h,w[l+7],14,1735328473),g=s(g,h=i(h,m,y,g,w[l+12],20,2368359562),m,y,w[l+5],4,4294588738),y=s(y,g,h,m,w[l+8],11,2272392833),m=s(m,y,g,h,w[l+11],16,1839030562),h=s(h,m,y,g,w[l+14],23,4259657740),g=s(g,h,m,y,w[l+1],4,2763975236),y=s(y,g,h,m,w[l+4],11,1272893353),m=s(m,y,g,h,w[l+7],16,4139469664),h=s(h,m,y,g,w[l+10],23,3200236656),g=s(g,h,m,y,w[l+13],4,681279174),y=s(y,g,h,m,w[l+0],11,3936430074),m=s(m,y,g,h,w[l+3],16,3572445317),h=s(h,m,y,g,w[l+6],23,76029189),g=s(g,h,m,y,w[l+9],4,3654602809),y=s(y,g,h,m,w[l+12],11,3873151461),m=s(m,y,g,h,w[l+15],16,530742520),g=a(g,h=s(h,m,y,g,w[l+2],23,3299628645),m,y,w[l+0],6,4096336452),y=a(y,g,h,m,w[l+7],10,1126891415),m=a(m,y,g,h,w[l+14],15,2878612391),h=a(h,m,y,g,w[l+5],21,4237533241),g=a(g,h,m,y,w[l+12],6,1700485571),y=a(y,g,h,m,w[l+3],10,2399980690),m=a(m,y,g,h,w[l+10],15,4293915773),h=a(h,m,y,g,w[l+1],21,2240044497),g=a(g,h,m,y,w[l+8],6,1873313359),y=a(y,g,h,m,w[l+15],10,4264355552),m=a(m,y,g,h,w[l+6],15,2734768916),h=a(h,m,y,g,w[l+13],21,1309151649),g=a(g,h,m,y,w[l+4],6,4149444226),y=a(y,g,h,m,w[l+11],10,3174756917),m=a(m,y,g,h,w[l+2],15,718787259),h=a(h,m,y,g,w[l+9],21,3951481745),g=o(g,d),h=o(h,u),m=o(m,f),y=o(y,p);return 32===t?(c(g)+c(h)+c(m)+c(y)).toLowerCase():(c(h)+c(m)).toLowerCase()},D=(e,t)=>l(void 0,null,(function*(){const n=t||function(){};try{const t=new $;let o=t.get(k);const r=o?JSON.parse(o):{},i=r?r[e]:null;if(""!==i&&i)n(i);else{const o=function(e){const t=new $(!0);let n=t.get(O);if(!n||""===n){const o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let r="";for(let t=0;t<e;t++){const e=Math.floor(Math.random()*o.length);r+=o.charAt(e)}n=r,t.set(O,n)}return n}(32),i=navigator.language,s=K(),a=M(),c=yield u({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(r[e]=d.cookie_id,t.set(k,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const K=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},M=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},N={SUCCESS:{code:200,message:"Success"},UNKNOWN:{code:9999,message:"Unknown"},LACK_APPKEY:{code:1001,message:"Missing appKey parameter"},LACK_APPSECRET:{code:1002,message:"Missing appSecret parameter"},LACK_PROJECTID:{code:1003,message:"Missing projectId parameter"},NOT_INIT:{code:1004,message:"Please call the init method first"},EMPTY_EVENT_NAME:{code:1005,message:"Event name cannot be empty"},INVALID_URL:{code:1006,message:"Invalid URL"},LACK_UID:{code:1007,message:"Missing uId parameter"},LACK_CODE:{code:1008,message:"Please enter the code"}},z={name:"turbolink-ai",version:"1.2.1",description:"",main:"dist/index.es.js",module:"dist/index.es.js",type:"module",scripts:{test:'echo "Error: no test specified" && exit 1',build:"vite build"},author:"",license:"MIT",devDependencies:{"@babel/plugin-transform-modules-commonjs":"^7.23.3","crypto-js":"^4.2.0",eslint:"^8.53.0","rollup-plugin-terser":"^7.0.2",vite:"^4.5.0"},dependencies:{"javascript-obfuscator":"^4.1.0"}};let H={appKey:"",appSecret:"",projectId:""},V="",W="",F="",Y=!0,J="";const X=e=>new Promise((t=>{ee("install").then((n=>{t(n),e&&e(n)}))})),G=e=>new Promise((t=>{ee("open").then((n=>{t(n),e&&e(n)}))})),Z=(e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=N||{},i=650,{url:s,maskColor:a="rgba(0, 0, 0, 0.8)",backgroundImage:c,backgroundHeight:l=738,backgroundWidth:d,bgLinkage:u=!1,width:f=300,height:p=i,radius:g=12,zIndex:h=3e3,clickEventCallback:m,bodyHidden:y=!0,jumpNewWindow:w=!1}=e||{};try{if(!H.appSecret||""===H.appSecret)throw N.LACK_APPSECRET;if(!s||""===s)throw N.INVALID_URL;const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=te(s);if(v=`${v}&webIframe=1`,w&&(v=`${v}&jpN=1`),J&&""!==J){v=`${v}&loginUrl=${encodeURIComponent(J)}`}let b=document.getElementById("turbolinkSdkPopup");b&&b.remove();const S=document.createElement("div");S.id="turbolinkSdkPopup",S.style.position="fixed",S.style.zIndex=h,S.style.left="0",S.style.top="0",S.style.right="0",S.style.bottom="0",S.style.width="100%",S.style.height="100%",S.style.overflowX="hidden",S.style.overflowY="auto",S.style.backgroundColor=a;const _=document.createElement("div");_.style.minHeight="100%",_.style.display="-webkit-box",_.style.display="-ms-flexbox",_.style.display="-moz-box",_.style.display="flex",_.style.textAlign="center",_.style.justifyContent="center",_.style.alignItems="center";const x=document.createElement("div");x.style.margin="10vh auto",x.style.border="none",x.style.width=`${f}px`,x.style.height=`${p}px`,x.style.position="relative",x.style.borderRadius=`${g}px`,x.style.display="-webkit-box",x.style.display="-ms-flexbox",x.style.display="-moz-box",x.style.display="flex",x.style.textAlign="center",x.style.justifyContent="center",x.style.alignItems="center";const C=document.createElement("iframe");C.id="turbolinkSdkPopupIframe",C.width=`${f}px`,C.height=`${p}px`,C.style.border="none",C.style.borderRadius=`${g}px`,C.style.overflow="hidden",C.style.position="relative",C.style.zIndex="10",C.src=v;const I=document.createElement("div"),E=document.createElement("img");let P=l;u&&(P=p*(P/i)),I.style.height=`${P}px`,C.onload=()=>{I.style.position="absolute",I.style.fontSize="0px",I.style.zIndex="6",E.id="turbolinkSdkBgImg",c&&""!==c?E.src=c:ne(t),E.style.width=d||"auto",E.style.height="100%",E.style.setProperty("max-width","none","important"),E.style.setProperty("max-height","none","important"),I.appendChild(E)};const A=document.createElement("div"),k=document.createElement("img");A.style.position="absolute",A.style.fontSize="0px",A.style.zIndex="100",A.style.top="-54px",A.style.right="-200px",k.src="https://i1.branchcn.com/web/sdk/img/campClose.png",k.style.width="40px",k.style.height="auto",A.appendChild(k);const O=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";n&&"turbolink"===n&&m(e.data)}};m&&(window.removeEventListener("message",O),window.addEventListener("message",O)),A.addEventListener("click",(()=>{S.remove(),y&&(document.body.style.overflow="auto"),m&&(m({type:"linkCloseListener",params:null}),window.removeEventListener("message",O))})),x.appendChild(I),x.appendChild(C),x.appendChild(A),_.appendChild(x),S.appendChild(_),document.body.appendChild(S),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})),q=()=>sessionStorage.getItem(B),Q=()=>!(null===V||""===V||" "===V||void 0===V),ee=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=H||{},{customData:s,nativeMsg:a=""}=t||{};if(""===o||!o||""===r||!r||""===i||!i)throw N.NOT_INIT;if(!e||""===e)throw N.EMPTY_EVENT_NAME;D(i,(t=>l(void 0,null,(function*(){var o,c;const d=K(),f=M(),p=(new Date).valueOf(),g=null==p?void 0:p.toString(),h=null==(o=A(`${i}_${g}_${p}_${r}`))?void 0:o.toString(),m=(()=>{let e="Android";try{const t=navigator.userAgent.toLowerCase();/android/.test(t)?e="Android":/iphone|ipad|ipod/.test(t)?e="iOS":/win/.test(t)?e="Windows":/mac/.test(t)?e="macOS":/linux/.test(t)&&(e="Linux")}catch(t){e="Android"}return e})(),y=yield l(void 0,null,(function*(){const e=navigator.userAgent.toLowerCase();let t="";try{if(/android/.test(e))if(navigator.userAgent.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.platformVersion}else t=e.match(/android\s([0-9.]+)/)[1];else/iphone|ipad|ipod/.test(e)?t=e.match(/os\s([\d_]+)/)[1].replace(/_/g,"."):/win/.test(e)?t=e.match(/windows\snt\s([\d.]+)/)[1]:/mac/.test(e)?t=e.match(/os x\s([\d_]+)/)[1].replace(/_/g,"."):/linux/.test(e)&&(t="Unknown")}catch(e){t="Unknown"}return t})),w=yield l(void 0,null,(function*(){const e=navigator.userAgent;let t="Windows";try{if(e.includes("iPhone"))t="iPhone";else if(e.includes("iPad"))t="iPad";else if(e.includes("Android"))if(e.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.model||"Windows"}else if(e.includes("Build")){const n=e.match(/Android.*; ?(.*(?= Build))/);n&&n.length>1&&(t=n[1])}else if(e.includes("wv")){const n=e.match(/Android.*; ?(.*(?= wv))/);if(n&&n.length>0){const e=n[0].split(";");e&&e.length>1&&(t=e[1])}}else{const n=e.match(/Android.*; ([^)]+)/);n&&n.length>1&&(t=n[1])}else e.includes("Mac")&&(t="Mac")}catch(e){t="Windows"}return t})),v=yield new Promise((e=>{try{const t=new RTCPeerConnection;t.createDataChannel(""),t.onicecandidate=function(n){if(n.candidate){const o=n.candidate.candidate,r=/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.exec(o),i=r?r[0]:null;e(i),t.close()}else e()},t.createOffer().then((e=>t.setLocalDescription(e))).catch((()=>{e()}))}catch(t){e()}})),b=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),S=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),_=(()=>{const e=navigator.userAgent;return-1!==e.indexOf("Firefox")?"Firefox":-1!==e.indexOf("Opera")||-1!==e.indexOf("OPR")?"Opera":-1!==e.indexOf("Trident")?"IE":-1!==e.indexOf("Edge")?"Edge":-1!==e.indexOf("Chrome")?"Chrome":-1!==e.indexOf("Safari")?"Safari":"unknown"})(),x=null==(c=(()=>{let e=0;try{const t=navigator.userAgent;-1!==t.indexOf("Firefox")?e=parseFloat(null==t?void 0:t.match(/Firefox\/([\d.]+)/)[1])||0:-1!==t.indexOf("Edge")?e=parseFloat(null==t?void 0:t.match(/Edge\/([\d.]+)/)[1])||0:-1!==t.indexOf("Chrome")?e=parseFloat(null==t?void 0:t.match(/Chrome\/([\d.]+)/)[1])||0:-1!==t.indexOf("Safari")?e=parseFloat(null==t?void 0:t.match(/Version\/([\d.]+)/)[1])||0:(-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident/"))&&(e=parseFloat((null==t?void 0:t.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1])||(null==t?void 0:t.match(/rv:([\d.]+)/)))||0)}catch(t){e=0}return e})())?void 0:c.toString(),C=(null==z?void 0:z.version)||"1.0.0",I=`${d}x${f}`,E=window.location.href,P=navigator.userAgent,k="UTC+"+(0-(new Date).getTimezoneOffset()/60),O=document.referrer,B=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="turbolink <canvas> 1.0";t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17);const o=e.toDataURL();return R(o,32)})(),$={web:{browser_name:_,browser_version:x,current_time:p,device_type:w,ip:v||"",language:S,os:m,screen_resolution:I,sdk_version:C,url:E,user_agent:P,time_zone:k,referer:O,canvas:B}};let D=[];s&&s.constructor===Array&&(D=s.map((e=>{const t={};return Object.keys(e).forEach((n=>{const o=e[n];t[n]="string"!=typeof o?String(o):o})),t})));const N={project:i,request_id:g,timestamp:p,msg_signature:h,event:e,user_data:{native_msg:a,os:m,os_version:y,device_model:w,device_id:t,user_id:null==V?void 0:V.toString(),country:b,language:S,screen_width:d,screen_height:f,ip:v||""},custom_data:D,ext_data:$},H=yield u({url:"/v2/event",params:N}),{code:W,data:F,msg:X}=H||{};if(200===W&&F){let e="";const t=F.link_data||[];F.blackbox&&""!==F.blackbox&&localStorage.setItem(T,F.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(Y&&""!==e)if(oe()){let t=te(e);if(J&&""!==J){const e=encodeURIComponent(J);t=`${t}&loginUrl=${e}`}Q()||(sessionStorage.setItem(j,t),sessionStorage.setItem(L,"1")),localStorage.setItem(U,e),setTimeout((()=>{window.location.href=t}),300)}else Z({url:e});n({code:W,message:X,data:F})}else n({code:W,message:X})}))))}catch(e){n(e)}})),te=e=>{if(!e||""===e)return"";const t=V||"",n=navigator.language,o=W||n||"",r=Math.floor((new Date).getTime()/1e3),i=localStorage.getItem(T),s="1.2.0",a=r%100,c="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(a,a+12),l=`${t}${F}${o}${r}${i}${s}web${H.appSecret}${c}`,d=R(l,32);return((e,t)=>{const n=new URL(e),o=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;o.has(t)?o.set(t,n):o.append(t,n)})),n.origin+n.pathname+"?"+o.toString()})(e,[{name:"user_id",value:t},{name:"lv",value:F},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:i},{name:"version",value:s},{name:"platform",value:"web"},{name:"token",value:d}])},ne=e=>l(void 0,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==H?void 0:H.projectId},o=yield u({url:"/v2/campaign/sdk-info",params:n}),r=document.getElementById("turbolinkSdkBgImg"),{code:i,data:s}=o||{};if(200===i&&s){const{pc_bg:e}=s||{};r&&(r.src=e&&""!==e?e:t)}else r&&(r.src=t)})),oe=()=>{const e=navigator.userAgent,t=["Android","iPhone","iPad","iPod","BlackBerry","Windows Phone"];for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return!0;return!1};class re{}c(re,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:c,loginUrl:l,jump:u=!0,dev:f=!1}=e||{};if(!t||""===t)throw N.LACK_APPKEY;if(!r||""===r)throw N.LACK_APPSECRET;if(!i||""===i)throw N.LACK_PROJECTID;f&&(e=>{e&&(d="https://test.allapp.link")})(f),s&&(V=s),a&&(W=a),c&&(F=c),l&&(J=l),Y=u,H=e||{};let p=(new $).get(O);if(q())return n(N.SUCCESS),void o(N.SUCCESS);null==p||" "===p||""===p?X().then((e=>{n(e),o(e)})):G().then((e=>{if(n(e),o(e),Q()&&oe()){const e=sessionStorage.getItem(j);if(e&&" "!==e){let t=te(e);if(sessionStorage.removeItem(j),sessionStorage.removeItem(L),J&&""!==J){t=`${t}&loginUrl=${encodeURIComponent(J)}`}window.location.replace(t&&t)}}})),sessionStorage.setItem(B,"1")}catch(e){n(e),o(e)}})))),c(re,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:o,UNKNOWN:r}=N||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(V=t),n&&(F=n)}else V=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(re,"install",X),c(re,"register",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{uid:t,uId:r,lv:i,toActivity:s=!0}=e||{};if(!(t&&""!==t||r&&""!==r))throw N.LACK_UID;t&&(V=t),r&&(V=r),ee("register").then((e=>{if(oe()){const e=localStorage.getItem(U),t=sessionStorage.getItem(L);if(e&&"1"===t&&s){sessionStorage.removeItem(L);const t=te(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(re,"open",G),c(re,"customEvent",((e,o)=>new Promise((r=>{const i=o||function(){};try{const{event:o,customData:s,backCamp:c}=e||{};if(!o||""===o)throw N.EMPTY_EVENT_NAME;ee(o,{customData:s}).then((e=>{const o=localStorage.getItem(U),s=te(o),l=((e,o)=>t(e,n(o)))(a({},e),{campUrl:s});c&&s&&setTimeout((()=>{window.location.replace(s)}),1e3),r(l),i(l)}))}catch(e){r(e),i(e)}})))),c(re,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=N||{},{url:i,newWindow:s=!1}=e||{};try{if(!H.appSecret||""===H.appSecret)throw N.LACK_APPSECRET;if(!i||""===i)throw N.INVALID_URL;let e=te(i);if(J&&""!==J){e=`${e}&loginUrl=${encodeURIComponent(J)}`}localStorage.setItem(U,i),Q()||sessionStorage.setItem(L,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),ee("loadUrl")}catch(e){n(e),o(e)}})))),c(re,"webLoadUrl",Z),c(re,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=N||{};try{document.getElementById("turbolinkSdkPopup").remove(),n(o),t(o)}catch(e){t(e),n(e)}})))),c(re,"login",((e,t)=>new Promise((n=>{const o=t||function(){},{uid:r,uId:i,lv:s,toActivity:a=!0}=e||{};try{if(!(r&&""!==r||i&&""!==i))throw N.LACK_UID;r&&(V=r),i&&(V=i),ee("login").then((e=>{if(oe()){const e=localStorage.getItem(U),t=sessionStorage.getItem(L);if(e&&"1"===t&&a){sessionStorage.removeItem(L);const t=te(e);window.location.replace(t&&t)}}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(re,"logout",(e=>new Promise((t=>{const n=e||function(){};localStorage.remove(U),sessionStorage.removeItem(L),V=null;const{SUCCESS:o}=N||{};t(o),n(o),ee("logout")})))),c(re,"getInitState",q),c(re,"getLoginState",Q),c(re,"codeSearch",((e,t)=>new Promise((n=>{const o=t||function(){};try{if(!e||" "===e)throw N.LACK_CODE;ee("code_search",{nativeMsg:e}).then((e=>{n(e),o(e)}))}catch(e){n(e),o(e)}}))));export{re as default};
|
package/package.json
CHANGED
package/dist/turbolink1.1.7.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Turbolink=t()}(this,(function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,s=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,a=(e,t)=>{for(var n in t||(t={}))r.call(t,n)&&s(e,n,t[n]);if(o)for(var n of o(t))i.call(t,n)&&s(e,n,t[n]);return e},c=(e,t,n)=>(s(e,"symbol"!=typeof t?t+"":t,n),n),l=(e,t,n)=>new Promise(((o,r)=>{var i=e=>{try{a(n.next(e))}catch(e){r(e)}},s=e=>{try{a(n.throw(e))}catch(e){r(e)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,s);a((n=n.apply(e,t)).next())}));let d="https://www.allapp.link";const u=({url:e,method:t="POST",headers:n,params:o})=>new Promise((r=>{const i=a({"Content-Type":"application/json;charset=utf-8"},n);z.appKey&&(i.Authorization="Bearer "+z.appKey),fetch(d+e,{method:t,headers:i,body:JSON.stringify(o)}).then((e=>{if(e.ok)return e.json();throw new Error("Network response was not ok.")})).then((e=>{r(e)})).catch((e=>{r(e)}))}));var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var p={exports:{}};var h={exports:{}};const g=function(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})})),n}(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var m,y,w,v,b,_,S,x,C;function E(){return m||(m=1,h.exports=(e=e||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==f&&f.crypto&&(n=f.crypto),!n)try{n=g}catch(e){}var o=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},r=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),i={},s=i.lib={},a=s.Base={extend:function(e){var t=r(this);return e&&t.mixIn(e),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=s.WordArray=a.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,o=this.sigBytes,r=e.sigBytes;if(this.clamp(),o%4)for(var i=0;i<r;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[o+i>>>2]|=s<<24-(o+i)%4*8}else for(var a=0;a<r;a+=4)t[o+a>>>2]=n[a>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=a.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(o());return new c.init(t,e)}}),l=i.enc={},d=l.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push((i>>>4).toString(16)),o.push((15&i).toString(16))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o+=2)n[o>>>3]|=parseInt(e.substr(o,2),16)<<24-o%8*4;return new c.init(n,t/2)}},u=l.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,o=[],r=0;r<n;r++){var i=t[r>>>2]>>>24-r%4*8&255;o.push(String.fromCharCode(i))}return o.join("")},parse:function(e){for(var t=e.length,n=[],o=0;o<t;o++)n[o>>>2]|=(255&e.charCodeAt(o))<<24-o%4*8;return new c.init(n,t)}},p=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=s.BufferedBlockAlgorithm=a.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,o=this._data,r=o.words,i=o.sigBytes,s=this.blockSize,a=i/(4*s),l=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*s,d=e.min(4*l,i);if(l){for(var u=0;u<l;u+=s)this._doProcessBlock(r,u);n=r.splice(0,l),o.sigBytes-=d}return new c.init(n,d)},clone:function(){var e=a.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=h.extend({cfg:a.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new m.HMAC.init(e,n).finalize(t)}}});var m=i.algo={};return i}(Math),e)),h.exports;var e}p.exports=(C=E(),w=(y=C).lib,v=w.WordArray,b=w.Hasher,_=y.algo,S=[],x=_.SHA1=b.extend({_doReset:function(){this._hash=new v.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var n=this._hash.words,o=n[0],r=n[1],i=n[2],s=n[3],a=n[4],c=0;c<80;c++){if(c<16)S[c]=0|e[t+c];else{var l=S[c-3]^S[c-8]^S[c-14]^S[c-16];S[c]=l<<1|l>>>31}var d=(o<<5|o>>>27)+a+S[c];d+=c<20?1518500249+(r&i|~r&s):c<40?1859775393+(r^i^s):c<60?(r&i|r&s|i&s)-1894007588:(r^i^s)-899497514,a=s,s=i,i=r<<30|r>>>2,r=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+r|0,n[2]=n[2]+i|0,n[3]=n[3]+s|0,n[4]=n[4]+a|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,o=8*e.sigBytes;return t[o>>>5]|=128<<24-o%32,t[14+(o+64>>>9<<4)]=Math.floor(n/4294967296),t[15+(o+64>>>9<<4)]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=b.clone.call(this);return e._hash=this._hash.clone(),e}}),y.SHA1=b._createHelper(x),y.HmacSHA1=b._createHmacHelper(x),C.SHA1);const k=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(p.exports),P="tb_cookie_obj",A="tb_randomId",I="tb_load_url",O="tb_load_source_url",U="tb_ascribe_to_url",L="tb_source_ascribe_to";class j{constructor(e=!0){this.storage=e?localStorage:sessionStorage}set(e,t){this.storage.setItem(e,JSON.stringify(t))}get(e){const t=this.storage.getItem(e);if(t)return JSON.parse(t)}remove(e){return this.storage.removeItem(e)}clear(){this.storage.clear()}}const T=(e,t)=>{function n(e,t){return e<<t|e>>>32-t}function o(e,t){var n,o,r,i,s;return r=2147483648&e,i=2147483648&t,s=(1073741823&e)+(1073741823&t),(n=1073741824&e)&(o=1073741824&t)?2147483648^s^r^i:n|o?1073741824&s?3221225472^s^r^i:1073741824^s^r^i:s^r^i}function r(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&t|~e&n}(t,r,i),s),c)),o(n(e,a),t)}function i(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e&n|t&~n}(t,r,i),s),c)),o(n(e,a),t)}function s(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return e^t^n}(t,r,i),s),c)),o(n(e,a),t)}function a(e,t,r,i,s,a,c){return e=o(e,o(o(function(e,t,n){return t^(e|~n)}(t,r,i),s),c)),o(n(e,a),t)}function c(e){var t,n="",o="";for(t=0;t<=3;t++)n+=(o="0"+(e>>>8*t&255).toString(16)).substr(o.length-2,2);return n}var l,d,u,f,p,h,g,m,y,w=Array();for(w=function(e){for(var t,n=e.length,o=n+8,r=16*((o-o%64)/64+1),i=Array(r-1),s=0,a=0;a<n;)s=a%4*8,i[t=(a-a%4)/4]=i[t]|e.charCodeAt(a)<<s,a++;return s=a%4*8,i[t=(a-a%4)/4]=i[t]|128<<s,i[r-2]=n<<3,i[r-1]=n>>>29,i}(e=function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var o=e.charCodeAt(n);o<128?t+=String.fromCharCode(o):o>127&&o<2048?(t+=String.fromCharCode(o>>6|192),t+=String.fromCharCode(63&o|128)):(t+=String.fromCharCode(o>>12|224),t+=String.fromCharCode(o>>6&63|128),t+=String.fromCharCode(63&o|128))}return t}(e)),h=1732584193,g=4023233417,m=2562383102,y=271733878,l=0;l<w.length;l+=16)d=h,u=g,f=m,p=y,h=r(h,g,m,y,w[l+0],7,3614090360),y=r(y,h,g,m,w[l+1],12,3905402710),m=r(m,y,h,g,w[l+2],17,606105819),g=r(g,m,y,h,w[l+3],22,3250441966),h=r(h,g,m,y,w[l+4],7,4118548399),y=r(y,h,g,m,w[l+5],12,1200080426),m=r(m,y,h,g,w[l+6],17,2821735955),g=r(g,m,y,h,w[l+7],22,4249261313),h=r(h,g,m,y,w[l+8],7,1770035416),y=r(y,h,g,m,w[l+9],12,2336552879),m=r(m,y,h,g,w[l+10],17,4294925233),g=r(g,m,y,h,w[l+11],22,2304563134),h=r(h,g,m,y,w[l+12],7,1804603682),y=r(y,h,g,m,w[l+13],12,4254626195),m=r(m,y,h,g,w[l+14],17,2792965006),h=i(h,g=r(g,m,y,h,w[l+15],22,1236535329),m,y,w[l+1],5,4129170786),y=i(y,h,g,m,w[l+6],9,3225465664),m=i(m,y,h,g,w[l+11],14,643717713),g=i(g,m,y,h,w[l+0],20,3921069994),h=i(h,g,m,y,w[l+5],5,3593408605),y=i(y,h,g,m,w[l+10],9,38016083),m=i(m,y,h,g,w[l+15],14,3634488961),g=i(g,m,y,h,w[l+4],20,3889429448),h=i(h,g,m,y,w[l+9],5,568446438),y=i(y,h,g,m,w[l+14],9,3275163606),m=i(m,y,h,g,w[l+3],14,4107603335),g=i(g,m,y,h,w[l+8],20,1163531501),h=i(h,g,m,y,w[l+13],5,2850285829),y=i(y,h,g,m,w[l+2],9,4243563512),m=i(m,y,h,g,w[l+7],14,1735328473),h=s(h,g=i(g,m,y,h,w[l+12],20,2368359562),m,y,w[l+5],4,4294588738),y=s(y,h,g,m,w[l+8],11,2272392833),m=s(m,y,h,g,w[l+11],16,1839030562),g=s(g,m,y,h,w[l+14],23,4259657740),h=s(h,g,m,y,w[l+1],4,2763975236),y=s(y,h,g,m,w[l+4],11,1272893353),m=s(m,y,h,g,w[l+7],16,4139469664),g=s(g,m,y,h,w[l+10],23,3200236656),h=s(h,g,m,y,w[l+13],4,681279174),y=s(y,h,g,m,w[l+0],11,3936430074),m=s(m,y,h,g,w[l+3],16,3572445317),g=s(g,m,y,h,w[l+6],23,76029189),h=s(h,g,m,y,w[l+9],4,3654602809),y=s(y,h,g,m,w[l+12],11,3873151461),m=s(m,y,h,g,w[l+15],16,530742520),h=a(h,g=s(g,m,y,h,w[l+2],23,3299628645),m,y,w[l+0],6,4096336452),y=a(y,h,g,m,w[l+7],10,1126891415),m=a(m,y,h,g,w[l+14],15,2878612391),g=a(g,m,y,h,w[l+5],21,4237533241),h=a(h,g,m,y,w[l+12],6,1700485571),y=a(y,h,g,m,w[l+3],10,2399980690),m=a(m,y,h,g,w[l+10],15,4293915773),g=a(g,m,y,h,w[l+1],21,2240044497),h=a(h,g,m,y,w[l+8],6,1873313359),y=a(y,h,g,m,w[l+15],10,4264355552),m=a(m,y,h,g,w[l+6],15,2734768916),g=a(g,m,y,h,w[l+13],21,1309151649),h=a(h,g,m,y,w[l+4],6,4149444226),y=a(y,h,g,m,w[l+11],10,3174756917),m=a(m,y,h,g,w[l+2],15,718787259),g=a(g,m,y,h,w[l+9],21,3951481745),h=o(h,d),g=o(g,u),m=o(m,f),y=o(y,p);return 32===t?(c(h)+c(g)+c(m)+c(y)).toLowerCase():(c(g)+c(m)).toLowerCase()},B=(e,t)=>l(this,null,(function*(){const n=t||function(){};try{const t=new j;let o=t.get(P);const r=o?JSON.parse(o):{},i=r?r[e]:null;if(""!==i&&i)n(i);else{const o=function(e){const t=new j(!0);let n=t.get(A);if(!n||""===n){const o="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";let r="";for(let t=0;t<e;t++){const e=Math.floor(Math.random()*o.length);r+=o.charAt(e)}n=r,t.set(A,n)}return n}(32),i=navigator.language,s=N(),a=K(),c=yield u({url:"/ecl/bs/check",params:{bfp:o,language:i,screen_width:s,screen_height:a}}),{code:l,data:d}=c||{};200===l&&d&&(r[e]=d.cookie_id,t.set(P,JSON.stringify(r))),n(d.cookie_id)}}catch(e){n("1")}}));const $=()=>l(this,null,(function*(){const e=navigator.userAgent.toLowerCase();let t="";try{if(/android/.test(e))if(navigator.userAgent.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.platformVersion}else t=e.match(/android\s([0-9.]+)/)[1];else/iphone|ipad|ipod/.test(e)?t=e.match(/os\s([\d_]+)/)[1].replace(/_/g,"."):/win/.test(e)?t=e.match(/windows\snt\s([\d.]+)/)[1]:/mac/.test(e)?t=e.match(/os x\s([\d_]+)/)[1].replace(/_/g,"."):/linux/.test(e)&&(t="Unknown")}catch(e){t="Unknown"}return t})),R=()=>l(this,null,(function*(){const e=navigator.userAgent;let t="Windows";try{if(e.includes("iPhone"))t="iPhone";else if(e.includes("iPad"))t="iPad";else if(e.includes("Android"))if(e.indexOf("(Linux; Android 10; K)")>-1&&navigator.userAgentData){const e=yield navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]);t=e&&e.model||"Windows"}else if(e.includes("Build")){const n=e.match(/Android.*; ?(.*(?= Build))/);n&&n.length>1&&(t=n[1])}else if(e.includes("wv")){const n=e.match(/Android.*; ?(.*(?= wv))/);if(n&&n.length>0){const e=n[0].split(";");e&&e.length>1&&(t=e[1])}}else{const n=e.match(/Android.*; ([^)]+)/);n&&n.length>1&&(t=n[1])}else e.includes("Mac")&&(t="Mac")}catch(e){t="Windows"}return t})),N=()=>{let e=0;try{e=window.screen.width}catch(t){e=0}return e},K=()=>{let e=0;try{e=window.screen.height}catch(t){e=0}return e},M={SUCCESS:{code:200,message:"Success"},UNKNOWN:{code:9999,message:"Unknown"},LACK_APPKEY:{code:1001,message:"Missing appKey parameter"},LACK_APPSECRET:{code:1002,message:"Missing appSecret parameter"},LACK_PROJECTID:{code:1003,message:"Missing projectId parameter"},NOT_INIT:{code:1004,message:"Please call the init method first"},EMPTY_EVENT_NAME:{code:1005,message:"Event name cannot be empty"},INVALID_URL:{code:1006,message:"Invalid URL"},LACK_UID:{code:1007,message:"Missing uId parameter"}},D={name:"turbolink-ai",version:"1.1.7",description:"",main:"dist/index.es.js",module:"dist/index.es.js",type:"module",scripts:{test:'echo "Error: no test specified" && exit 1',build:"vite build"},author:"",license:"MIT",devDependencies:{"@babel/plugin-transform-modules-commonjs":"^7.23.3","crypto-js":"^4.2.0",eslint:"^8.53.0","rollup-plugin-terser":"^7.0.2",vite:"^4.5.0"},dependencies:{"javascript-obfuscator":"^4.1.0"}};let z={appKey:"",appSecret:"",projectId:""},H="",V="",W="",F=!1,Y=!0,J="";let X="";const G=e=>new Promise((t=>{Q("install").then((n=>{t(n),e&&e(n)}))})),Z=e=>new Promise((t=>{Q("open").then((n=>{t(n),e&&e(n)}))})),q=()=>!(null===H||""===H||" "===H||void 0===H),Q=(e,t)=>new Promise((n=>{try{const{appKey:o,appSecret:r,projectId:i}=z||{};if(""===o||!o||""===r||!r||""===i||!i)throw M.NOT_INIT;if(!e||""===e)throw M.EMPTY_EVENT_NAME;B(i,(o=>l(this,null,(function*(){var s,a;const c=N(),l=K(),d=(new Date).valueOf(),f=null==d?void 0:d.toString(),p=null==(s=k(`${i}_${f}_${d}_${r}`))?void 0:s.toString(),h=(()=>{let e="Android";try{const t=navigator.userAgent.toLowerCase();/android/.test(t)?e="Android":/iphone|ipad|ipod/.test(t)?e="iOS":/win/.test(t)?e="Windows":/mac/.test(t)?e="macOS":/linux/.test(t)&&(e="Linux")}catch(t){e="Android"}return e})(),g=yield $(),m=yield R(),y=yield new Promise((e=>{try{const t=new RTCPeerConnection;t.createDataChannel(""),t.onicecandidate=function(n){if(n.candidate){const o=n.candidate.candidate,r=/(?:[0-9]{1,3}\.){3}[0-9]{1,3}/.exec(o),i=r?r[0]:null;e(i),t.close()}else e()},t.createOffer().then((e=>t.setLocalDescription(e))).catch((()=>{e()}))}catch(t){e()}})),w=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(3).toUpperCase()}catch(t){e="Unknown"}return e})(),v=(()=>{let e="Unknown";try{e=(navigator.language||navigator.userLanguage).substring(0,2).toLowerCase()}catch(t){e="Unknown"}return e})(),b=(()=>{const e=navigator.userAgent;return-1!==e.indexOf("Firefox")?"Firefox":-1!==e.indexOf("Opera")||-1!==e.indexOf("OPR")?"Opera":-1!==e.indexOf("Trident")?"IE":-1!==e.indexOf("Edge")?"Edge":-1!==e.indexOf("Chrome")?"Chrome":-1!==e.indexOf("Safari")?"Safari":"unknown"})(),_=null==(a=(()=>{let e=0;try{const t=navigator.userAgent;-1!==t.indexOf("Firefox")?e=parseFloat(null==t?void 0:t.match(/Firefox\/([\d.]+)/)[1])||0:-1!==t.indexOf("Edge")?e=parseFloat(null==t?void 0:t.match(/Edge\/([\d.]+)/)[1])||0:-1!==t.indexOf("Chrome")?e=parseFloat(null==t?void 0:t.match(/Chrome\/([\d.]+)/)[1])||0:-1!==t.indexOf("Safari")?e=parseFloat(null==t?void 0:t.match(/Version\/([\d.]+)/)[1])||0:(-1!==t.indexOf("MSIE")||-1!==t.indexOf("Trident/"))&&(e=parseFloat((null==t?void 0:t.match(/MSIE (\d+[.]\d+)|(?:Trident\/[\d.]+).*rv:([\d.]+)/)[1])||(null==t?void 0:t.match(/rv:([\d.]+)/)))||0)}catch(t){e=0}return e})())?void 0:a.toString(),S=(null==D?void 0:D.version)||"1.0.0",x=`${c}x${l}`,C=window.location.href,E=navigator.userAgent,P="UTC+"+(0-(new Date).getTimezoneOffset()/60),A=document.referrer,I=(()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="turbolink <canvas> 1.0";t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17);const o=e.toDataURL();return T(o,32)})(),O={web:{browser_name:b,browser_version:_,current_time:d,device_type:m,ip:y||"",language:v,os:h,screen_resolution:x,sdk_version:S,url:C,user_agent:E,time_zone:P,referer:A,canvas:I}};let B=[];t&&t.constructor===Array&&(B=t.map((e=>{const t={};return Object.keys(e).forEach((n=>{const o=e[n];t[n]="string"!=typeof o?String(o):o})),t})));const M={project:i,request_id:f,timestamp:d,msg_signature:p,event:e,user_data:{native_msg:"",os:h,os_version:g,device_model:m,device_id:o,user_id:null==H?void 0:H.toString(),country:w,language:v,screen_width:c,screen_height:l,ip:y||""},custom_data:B,ext_data:O},z=yield u({url:"/v2/event",params:M}),{code:V,data:W,msg:F}=z||{};if(200===V&&W){let e="";const t=W.link_data||[];W.blackbox&&""!==W.blackbox&&(X=W.blackbox||"");for(let n=0;n<t.length;n++)if("$campaign_reward_url"===t[n].key){e=decodeURIComponent(t[n].value||"");break}if(Y&&""!==e){let t=ee(e);if(J&&""!==J){const e=encodeURIComponent(J);t=`${t}&loginUrl=${e}`}if(!q()){const t=new j(!1);t.set(U,e),t.set(L,"1")}setTimeout((()=>{window.location.href=t}),100)}n({code:V,message:F,data:W})}else n({code:V,message:F})}))))}catch(e){n(e)}})),ee=e=>{if(!e||""===e)return"";const t=H||"",n=navigator.language,o=V||n||"",r=Math.floor((new Date).getTime()/1e3),i="1.2.0",s=r%100,a="5CfUxPK7avjguYtG8yAE4ud6n9s774zVVdKwSxPryzaKHSpS4Lgju4M7sLumdLuQWXpHC6peBp2afBwEBbYnENGbZWfkZ6n4s52D3Xye59bfeK4gS9nfjehK".substring(s,s+12),c=`${t}${W}${o}${r}${X}${i}web${z.appSecret}${a}`,l=T(c,32);return((e,t)=>{const n=new URL(e),o=n.searchParams;return t.forEach((e=>{const{name:t,value:n}=e;o.has(t)?o.set(t,n):o.append(t,n)})),n.origin+n.pathname+"?"+o.toString()})(e,[{name:"user_id",value:t},{name:"lv",value:W},{name:"lg",value:o},{name:"time",value:r},{name:"blackbox",value:X},{name:"version",value:i},{name:"platform",value:"web"},{name:"token",value:l}])},te=e=>l(this,null,(function*(){const t="https://i1.branchcn.com/web/sdk/img/campBg.png",n={campaign_id:e,project_id:null==z?void 0:z.projectId},o=yield u({url:"/v2/campaign/sdk-info",params:n}),r=document.getElementById("turbolinkSdkBgImg"),{code:i,data:s}=o||{};if(200===i&&s){const{pc_bg:e}=s||{};r&&(r.src=e&&""!==e?e:t)}else r&&(r.src=t)}));class ne{}return c(ne,"init",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{appKey:t,appSecret:r,projectId:i,uid:s,lang:a,lv:c,loginUrl:l,jump:u=!0,dev:f=!1}=e||{};if(!t||""===t)throw M.LACK_APPKEY;if(!r||""===r)throw M.LACK_APPSECRET;if(!i||""===i)throw M.LACK_PROJECTID;f&&(e=>{e&&(d="https://test.allapp.link")})(f),s&&(H=s),a&&(V=a),c&&(W=c),l&&(J=l),Y=u,z=e||{};let p=(new j).get(A);if(F)return n(M.SUCCESS),void o(M.SUCCESS);if(null==p||" "===p||""===p)G().then((e=>{n(e),o(e)}));else{Z().then((e=>{n(e),o(e)}));const e=new j(!1),t=e.get(U),r=e.get(L);if(r&&"1"===r){let n=ee(t);if(e.remove(L),e.remove(U),J&&""!==J){n=`${n}&loginUrl=${encodeURIComponent(J)}`}window.location.replace(n&&n)}}F=!0}catch(e){n(e),o(e)}})))),c(ne,"setIdentity",((e,t)=>new Promise((n=>{const{SUCCESS:o,UNKNOWN:r}=M||{};try{if("object"==typeof e&&null!==e){const{uid:t,lv:n}=e||{};t&&(H=t),n&&(W=n)}else H=e;n(o),t&&t(o)}catch(e){n(r),t&&t(r)}})))),c(ne,"install",G),c(ne,"register",((e,t)=>new Promise((n=>{const o=t||function(){};try{const{uid:t,uId:r,lv:i}=e||{};if(!(t&&""!==t||r&&""!==r))throw M.LACK_UID;t&&(H=t),r&&(H=r),Q("register").then((e=>{const t=new j,r=t.get(I),i=t.get(O);if(i&&"1"===i){const e=ee(r);window.location.replace(e&&e),t.remove(O)}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ne,"open",Z),c(ne,"customEvent",((e,o)=>new Promise((r=>{const i=o||function(){};try{const{event:o,customData:s,backCamp:c}=e||{};if(!o||""===o)throw M.EMPTY_EVENT_NAME;Q(o,s).then((e=>{const o=(new j).get(I),s=ee(o),l=((e,o)=>t(e,n(o)))(a({},e),{campUrl:s});c&&s&&window.location.replace(s),r(l),i(l)}))}catch(e){r(e),i(e)}})))),c(ne,"loadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},{url:i,newWindow:s=!1}=e||{};try{if(!z.appSecret||""===z.appSecret)throw M.LACK_APPSECRET;if(!i||""===i)throw M.INVALID_URL;let e=ee(i);if(J&&""!==J){e=`${e}&loginUrl=${encodeURIComponent(J)}`}const t=new j;t.set(I,i),t.set(O,"1"),!0===s||"true"===s?window.open(e,"_blank"):window.location.href=e,o(r),n(r),Q("loadUrl")}catch(e){n(e),o(e)}})))),c(ne,"webLoadUrl",((e,t)=>new Promise((n=>{const o=t||function(){},{SUCCESS:r}=M||{},i=650,{url:s,maskColor:a="rgba(0, 0, 0, 0.8)",backgroundImage:c,backgroundHeight:l=738,backgroundWidth:d,bgLinkage:u=!1,width:f=300,height:p=i,radius:h=12,zIndex:g=3e3,clickEventCallback:m,bodyHidden:y=!0,jumpNewWindow:w=!1}=e||{};try{if(!z.appSecret||""===z.appSecret)throw M.LACK_APPSECRET;if(!s||""===s)throw M.INVALID_URL;const e=new URL(s),t=new URLSearchParams(e.search).get("l");let v=ee(s);if(v=`${v}&webIframe=1`,w&&(v=`${v}&jpN=1`),J&&""!==J){v=`${v}&loginUrl=${encodeURIComponent(J)}`}let b=document.getElementById("turbolinkSdkPopup");b&&b.remove();const _=document.createElement("div");_.id="turbolinkSdkPopup",_.style.position="fixed",_.style.zIndex=g,_.style.left="0",_.style.top="0",_.style.right="0",_.style.bottom="0",_.style.width="100%",_.style.height="100%",_.style.overflowX="hidden",_.style.overflowY="auto",_.style.backgroundColor=a;const S=document.createElement("div");S.style.minHeight="100%",S.style.display="-webkit-box",S.style.display="-ms-flexbox",S.style.display="-moz-box",S.style.display="flex",S.style.textAlign="center",S.style.justifyContent="center",S.style.alignItems="center";const x=document.createElement("div");x.style.margin="10vh auto",x.style.border="none",x.style.width=`${f}px`,x.style.height=`${p}px`,x.style.position="relative",x.style.borderRadius=`${h}px`,x.style.display="-webkit-box",x.style.display="-ms-flexbox",x.style.display="-moz-box",x.style.display="flex",x.style.textAlign="center",x.style.justifyContent="center",x.style.alignItems="center";const C=document.createElement("iframe");C.id="turbolinkSdkPopupIframe",C.width=`${f}px`,C.height=`${p}px`,C.style.border="none",C.style.borderRadius=`${h}px`,C.style.overflow="hidden",C.style.position="relative",C.style.zIndex="10",C.src=v;const E=document.createElement("div"),k=document.createElement("img");let P=l;u&&(P=p*(P/i)),E.style.height=`${P}px`,C.onload=()=>{E.style.position="absolute",E.style.fontSize="0px",E.style.zIndex="6",k.id="turbolinkSdkBgImg",c&&""!==c?k.src=c:te(t),k.style.width=d||"auto",k.style.height="100%",k.style.setProperty("max-width","none","important"),k.style.setProperty("max-height","none","important"),E.appendChild(k)};const A=document.createElement("div"),I=document.createElement("img");A.style.position="absolute",A.style.fontSize="0px",A.style.zIndex="100",A.style.top="-54px",A.style.right="-200px",I.src="https://i1.branchcn.com/web/sdk/img/campClose.png",I.style.width="40px",I.style.height="auto",A.appendChild(I);const O=e=>{const t=(null==e?void 0:e.data)||{};if(t){const n=(null==t?void 0:t.source)||"";n&&"turbolink"===n&&m(e.data)}};m&&(window.removeEventListener("message",O),window.addEventListener("message",O)),A.addEventListener("click",(()=>{_.remove(),y&&(document.body.style.overflow="auto"),m&&(m({type:"linkCloseListener",params:null}),window.removeEventListener("message",O))})),x.appendChild(E),x.appendChild(C),x.appendChild(A),S.appendChild(x),_.appendChild(S),document.body.appendChild(_),y&&(document.body.style.overflow="hidden"),o(r),n(r)}catch(e){n(e),o(e)}})))),c(ne,"closeWebUrl",(e=>new Promise((t=>{const n=e||function(){},{SUCCESS:o}=M||{};try{document.getElementById("turbolinkSdkPopup").remove(),n(o),t(o)}catch(e){t(e),n(e)}})))),c(ne,"login",((e,t)=>new Promise((n=>{const o=t||function(){},{uid:r,uId:i,lv:s}=e||{};try{if(!(r&&""!==r||i&&""!==i))throw M.LACK_UID;r&&(H=r),i&&(H=i),Q("login").then((e=>{const t=new j,r=t.get(I),i=t.get(O);if(i&&"1"===i){const e=ee(r);window.location.replace(e&&e),t.remove(O)}n(e),o(e)}))}catch(e){n(e),o(e)}})))),c(ne,"logout",(e=>new Promise((t=>{const n=e||function(){};(new j).remove(I),H=null;const{SUCCESS:o}=M||{};t(o),n(o),Q("logout")})))),c(ne,"getInitState",(()=>F)),c(ne,"getLoginState",q),ne}));
|