qsh-webview-sdk 2.0.5 → 2.0.7
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/README.md +560 -89
- package/dist/index.d.ts +320 -136
- package/dist/qsh-webview-sdk.es.js +4155 -1638
- package/dist/qsh-webview-sdk.es.js.map +1 -1
- package/dist/qsh-webview-sdk.umd.js +1 -1
- package/dist/qsh-webview-sdk.umd.js.map +1 -1
- package/package.json +7 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(vt,dt){typeof exports=="object"&&typeof module!="undefined"?module.exports=dt():typeof define=="function"&&define.amd?define(dt):(vt=typeof globalThis!="undefined"?globalThis:vt||self,vt.qsh=dt())})(this,function(){"use strict";function vt(){return!!(typeof window!="undefined"&&window.__wxjs_environment==="miniprogram"||typeof window!="undefined"&&window.wx&&window.wx.miniProgram||/micromessenger/i.test(navigator.userAgent)&&/miniProgram/i.test(navigator.userAgent))}function dt(){return typeof window.plus!="undefined"}function Et(){return window.__dcloud_weex_postMessage||window.__dcloud_weex_}function Pt(){return window.__uniapp_x_postMessage||window.__uniapp_x_}function Kt(){return/uni-app/i.test(navigator.userAgent)}function Wt(){return/Html5Plus/i.test(navigator.userAgent)}function ve(){return Pt()?"uvue":Et()?"nvue":vt()?"weixin":dt()?"plus":"h5"}const $t={isWeixinMiniProgram:vt(),isAppPlus:dt(),isNvue:Et(),isUvue:Pt(),isUniApp:Kt(),isHtml5Plus:Wt(),type:ve()},Zt=/complete|loaded|interactive/;function de(){window.UniAppJSBridge=!0,document.dispatchEvent(new CustomEvent("UniAppJSBridgeReady",{bubbles:!0,cancelable:!0}))}function xe(u){return Kt()||Wt()?(window.__uniapp_x_postMessage||window.__uniapp_x_||window.__dcloud_weex_postMessage||window.__dcloud_weex_?document.addEventListener("DOMContentLoaded",u):window.plus&&Zt.test(document.readyState)?setTimeout(u,0):document.addEventListener("plusready",u),!0):!1}function ge(u){return window.wx&&window.wx.miniProgram?(window.WeixinJSBridge&&window.WeixinJSBridge.invoke?setTimeout(u,0):document.addEventListener("WeixinJSBridgeReady",u),!0):!1}function me(u){return xe(u)||ge(u)||(Zt.test(document.readyState)?setTimeout(u,0):document.addEventListener("DOMContentLoaded",u)),!0}function we(){return new Promise(u=>{window.UniAppJSBridge?u():document.addEventListener("UniAppJSBridgeReady",u,{once:!0})})}let Jt=!1;function Ct(){Jt||(Jt=!0,me(de))}let yt=[];function ye(){if(yt.length===0&&window.plus){const u=plus.webview.currentWebview();if(!u)throw new Error("plus.webview.currentWebview() is undefined");const h=u.parent(),A=h?h.id:u.id;yt.push(A)}return yt}function be(u,h){const A={options:{timestamp:+new Date},name:u,arg:h};if(u==="postMessage"){const y={data:h};return window.__uniapp_x_postMessage?window.__uniapp_x_postMessage(y):window.__uniapp_x_.postMessage(JSON.stringify(y))}const q={type:"WEB_INVOKE_APPSERVICE",args:{data:A,webviewIds:yt}};window.__uniapp_x_postMessage?window.__uniapp_x_postMessageToService(q):window.__uniapp_x_.postMessageToService(JSON.stringify(q))}function Te(u,h){const A={options:{timestamp:+new Date},name:u,arg:h};if(u==="postMessage"){const y={data:[h]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(y):window.__dcloud_weex_.postMessage(JSON.stringify(y))}const q={type:"WEB_INVOKE_APPSERVICE",args:{data:A,webviewIds:yt}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(q):window.__dcloud_weex_.postMessageToService(JSON.stringify(q))}function Fe(u,h){const A={options:{timestamp:+new Date},name:u,arg:h},q=ye();if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:A,webviewIds:q}},"__uniapp__service");else{const y=JSON.stringify(A),n=JSON.stringify(q);plus.webview.getLaunchWebview().evalJS(`UniPlusBridge.subscribeHandler("WEB_INVOKE_APPSERVICE",${y},${n});`)}}function Be(u,h){const A={options:{timestamp:+new Date},name:u,arg:h};window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:A,pageId:""},"*")}function st(u,h){Pt()?be(u,h):Et()?Te(u,h):dt()?Fe(u,h):Be(u,h)}function Ee(u={}){const{url:h}=u;if(window.wx&&window.wx.miniProgram)return window.wx.miniProgram.navigateTo({url:h});st("navigateTo",{url:encodeURI(h)})}function Pe(u={}){const{delta:h=1}=u;if(window.wx&&window.wx.miniProgram)return window.wx.miniProgram.navigateBack({delta:parseInt(h)});st("navigateBack",{delta:parseInt(h)})}function Se(u={}){const{url:h}=u;if(window.wx&&window.wx.miniProgram)return window.wx.miniProgram.switchTab({url:h});st("switchTab",{url:encodeURI(h)})}function Ie(u={}){const{url:h}=u;if(window.wx&&window.wx.miniProgram)return window.wx.miniProgram.reLaunch({url:h});st("reLaunch",{url:encodeURI(h)})}function De(u={}){const{url:h}=u;if(window.wx&&window.wx.miniProgram)return window.wx.miniProgram.redirectTo({url:h});st("redirectTo",{url:encodeURI(h)})}function Me(u={}){const{data:h={}}=u;if(window.wx&&window.wx.miniProgram)return window.wx.miniProgram.postMessage({data:h});st("postMessage",h)}function Re(u){if(window.wx&&window.wx.miniProgram&&window.wx.miniProgram.getEnv)return window.wx.miniProgram.getEnv(u);u({miniprogram:!0,weixin:!0})}var Gt=Object.freeze({__proto__:null,getEnv:Re,navigateBack:Pe,navigateTo:Ee,postMessage:Me,reLaunch:Ie,redirectTo:De,switchTab:Se});function qe(u={}){const{url:h}=u;st("navigateTo",{url:encodeURI(h)})}function Ae(u={}){const{delta:h=1}=u;st("navigateBack",{delta:parseInt(h)})}function _e(u={}){const{url:h}=u;st("switchTab",{url:encodeURI(h)})}function Oe(u={}){const{url:h}=u;st("reLaunch",{url:encodeURI(h)})}function Ce(u={}){const{url:h}=u;st("redirectTo",{url:encodeURI(h)})}function Ve(u={}){const{data:h={}}=u;st("postMessage",h)}function Le(u){const h={};let A=!1;Pt()?(h.uvue=!0,A=!0):Et()?(h.nvue=!0,A=!0):dt()&&(h.plus=!0,A=!0),A?h.app=!0:h.h5=!0,u(h)}var Yt=Object.freeze({__proto__:null,getEnv:Le,navigateBack:Ae,navigateTo:qe,postMessage:Ve,reLaunch:Oe,redirectTo:Ce,switchTab:_e});function bt(){return vt()?Gt:Yt}function Xt(u){return bt().navigateTo(u)}function kt(u){return bt().navigateBack(u)}function Qt(u){return bt().switchTab(u)}function jt(u){return bt().reLaunch(u)}function te(u){return bt().redirectTo(u)}function ee(){return vt()?Gt:Yt}function re(u={}){return ee().postMessage(u)}function ie(u){return ee().getEnv(u)}var Vt={exports:{}},St={exports:{}},He=St.exports,ne;function Ne(){return ne||(ne=1,function(u,h){(function(){var A,q=0xdeadbeefcafe,y=(q&16777215)==15715070;function n(t,e,r){t!=null&&(typeof t=="number"?this.fromNumber(t,e,r):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}function p(){return new n(null)}function $(t,e,r,i,a,l){for(;--l>=0;){var b=e*this[t++]+r[i]+a;a=Math.floor(b/67108864),r[i++]=b&67108863}return a}function K(t,e,r,i,a,l){for(var b=e&32767,E=e>>15;--l>=0;){var W=this[t]&32767,X=this[t++]>>15,ft=E*W+X*b;W=b*W+((ft&32767)<<15)+r[i]+(a&1073741823),a=(W>>>30)+(ft>>>15)+E*X+(a>>>30),r[i++]=W&1073741823}return a}function D(t,e,r,i,a,l){for(var b=e&16383,E=e>>14;--l>=0;){var W=this[t]&16383,X=this[t++]>>14,ft=E*W+X*b;W=b*W+((ft&16383)<<14)+r[i]+a,a=(W>>28)+(ft>>14)+E*X,r[i++]=W&268435455}return a}var N=typeof navigator!="undefined";N&&y&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=K,A=30):N&&y&&navigator.appName!="Netscape"?(n.prototype.am=$,A=26):(n.prototype.am=D,A=28),n.prototype.DB=A,n.prototype.DM=(1<<A)-1,n.prototype.DV=1<<A;var _=52;n.prototype.FV=Math.pow(2,_),n.prototype.F1=_-A,n.prototype.F2=2*A-_;var d="0123456789abcdefghijklmnopqrstuvwxyz",I=new Array,c,P;for(c=48,P=0;P<=9;++P)I[c++]=P;for(c=97,P=10;P<36;++P)I[c++]=P;for(c=65,P=10;P<36;++P)I[c++]=P;function g(t){return d.charAt(t)}function o(t,e){var r=I[t.charCodeAt(e)];return r==null?-1:r}function M(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function S(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}function s(t){var e=p();return e.fromInt(t),e}function x(t,e){var r;if(e==16)r=4;else if(e==8)r=3;else if(e==256)r=8;else if(e==2)r=1;else if(e==32)r=5;else if(e==4)r=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var i=t.length,a=!1,l=0;--i>=0;){var b=r==8?t[i]&255:o(t,i);if(b<0){t.charAt(i)=="-"&&(a=!0);continue}a=!1,l==0?this[this.t++]=b:l+r>this.DB?(this[this.t-1]|=(b&(1<<this.DB-l)-1)<<l,this[this.t++]=b>>this.DB-l):this[this.t-1]|=b<<l,l+=r,l>=this.DB&&(l-=this.DB)}r==8&&(t[0]&128)!=0&&(this.s=-1,l>0&&(this[this.t-1]|=(1<<this.DB-l)-1<<l)),this.clamp(),a&&n.ZERO.subTo(this,this)}function T(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}function f(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var r=(1<<e)-1,i,a=!1,l="",b=this.t,E=this.DB-b*this.DB%e;if(b-- >0)for(E<this.DB&&(i=this[b]>>E)>0&&(a=!0,l=g(i));b>=0;)E<e?(i=(this[b]&(1<<E)-1)<<e-E,i|=this[--b]>>(E+=this.DB-e)):(i=this[b]>>(E-=e)&r,E<=0&&(E+=this.DB,--b)),i>0&&(a=!0),a&&(l+=g(i));return a?l:"0"}function w(){var t=p();return n.ZERO.subTo(this,t),t}function v(){return this.s<0?this.negate():this}function m(t){var e=this.s-t.s;if(e!=0)return e;var r=this.t;if(e=r-t.t,e!=0)return this.s<0?-e:e;for(;--r>=0;)if((e=this[r]-t[r])!=0)return e;return 0}function B(t){var e=1,r;return(r=t>>>16)!=0&&(t=r,e+=16),(r=t>>8)!=0&&(t=r,e+=8),(r=t>>4)!=0&&(t=r,e+=4),(r=t>>2)!=0&&(t=r,e+=2),(r=t>>1)!=0&&(t=r,e+=1),e}function F(){return this.t<=0?0:this.DB*(this.t-1)+B(this[this.t-1]^this.s&this.DM)}function C(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}function R(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s}function O(t,e){var r=t%this.DB,i=this.DB-r,a=(1<<i)-1,l=Math.floor(t/this.DB),b=this.s<<r&this.DM,E;for(E=this.t-1;E>=0;--E)e[E+l+1]=this[E]>>i|b,b=(this[E]&a)<<r;for(E=l-1;E>=0;--E)e[E]=0;e[l]=b,e.t=this.t+l+1,e.s=this.s,e.clamp()}function U(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t){e.t=0;return}var i=t%this.DB,a=this.DB-i,l=(1<<i)-1;e[0]=this[r]>>i;for(var b=r+1;b<this.t;++b)e[b-r-1]|=(this[b]&l)<<a,e[b-r]=this[b]>>i;i>0&&(e[this.t-r-1]|=(this.s&l)<<a),e.t=this.t-r,e.clamp()}function H(t,e){for(var r=0,i=0,a=Math.min(t.t,this.t);r<a;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()}function V(t,e){var r=this.abs(),i=t.abs(),a=r.t;for(e.t=a+i.t;--a>=0;)e[a]=0;for(a=0;a<i.t;++a)e[a+r.t]=r.am(0,i[a],e,a,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&n.ZERO.subTo(e,e)}function L(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}function Z(t,e,r){var i=t.abs();if(!(i.t<=0)){var a=this.abs();if(a.t<i.t){e!=null&&e.fromInt(0),r!=null&&this.copyTo(r);return}r==null&&(r=p());var l=p(),b=this.s,E=t.s,W=this.DB-B(i[i.t-1]);W>0?(i.lShiftTo(W,l),a.lShiftTo(W,r)):(i.copyTo(l),a.copyTo(r));var X=l.t,ft=l[X-1];if(ft!=0){var ot=ft*(1<<this.F1)+(X>1?l[X-2]>>this.F2:0),pt=this.FV/ot,_t=(1<<this.F1)/ot,ct=1<<this.F2,lt=r.t,Ot=lt-X,xt=e==null?p():e;for(l.dlShiftTo(Ot,xt),r.compareTo(xt)>=0&&(r[r.t++]=1,r.subTo(xt,r)),n.ONE.dlShiftTo(X,xt),xt.subTo(l,l);l.t<X;)l[l.t++]=0;for(;--Ot>=0;){var zt=r[--lt]==ft?this.DM:Math.floor(r[lt]*pt+(r[lt-1]+ct)*_t);if((r[lt]+=l.am(0,zt,r,Ot,0,X))<zt)for(l.dlShiftTo(Ot,xt),r.subTo(xt,r);r[lt]<--zt;)r.subTo(xt,r)}e!=null&&(r.drShiftTo(X,e),b!=E&&n.ZERO.subTo(e,e)),r.t=X,r.clamp(),W>0&&r.rShiftTo(W,r),b<0&&n.ZERO.subTo(r,r)}}}function J(t){var e=p();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(n.ZERO)>0&&t.subTo(e,e),e}function z(t){this.m=t}function k(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function G(t){return t}function Q(t){t.divRemTo(this.m,null,t)}function tt(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function rt(t,e){t.squareTo(e),this.reduce(e)}z.prototype.convert=k,z.prototype.revert=G,z.prototype.reduce=Q,z.prototype.mulTo=tt,z.prototype.sqrTo=rt;function at(){if(this.t<1)return 0;var t=this[0];if((t&1)==0)return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function ut(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function Tt(t){var e=p();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(n.ZERO)>0&&this.m.subTo(e,e),e}function It(t){var e=p();return t.copyTo(e),this.reduce(e),e}function Dt(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=t[e]&32767,i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t[r]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function Mt(t,e){t.squareTo(e),this.reduce(e)}function Rt(t,e,r){t.multiplyTo(e,r),this.reduce(r)}ut.prototype.convert=Tt,ut.prototype.revert=It,ut.prototype.reduce=Dt,ut.prototype.mulTo=Rt,ut.prototype.sqrTo=Mt;function it(){return(this.t>0?this[0]&1:this.s)==0}function qt(t,e){if(t>4294967295||t<1)return n.ONE;var r=p(),i=p(),a=e.convert(this),l=B(t)-1;for(a.copyTo(r);--l>=0;)if(e.sqrTo(r,i),(t&1<<l)>0)e.mulTo(i,a,r);else{var b=r;r=i,i=b}return e.revert(r)}function Ft(t,e){var r;return t<256||e.isEven()?r=new z(e):r=new ut(e),this.exp(t,r)}n.prototype.copyTo=M,n.prototype.fromInt=S,n.prototype.fromString=x,n.prototype.clamp=T,n.prototype.dlShiftTo=C,n.prototype.drShiftTo=R,n.prototype.lShiftTo=O,n.prototype.rShiftTo=U,n.prototype.subTo=H,n.prototype.multiplyTo=V,n.prototype.squareTo=L,n.prototype.divRemTo=Z,n.prototype.invDigit=at,n.prototype.isEven=it,n.prototype.exp=qt,n.prototype.toString=f,n.prototype.negate=w,n.prototype.abs=v,n.prototype.compareTo=m,n.prototype.bitLength=F,n.prototype.mod=J,n.prototype.modPowInt=Ft,n.ZERO=s(0),n.ONE=s(1);function Lt(){var t=p();return this.copyTo(t),t}function wt(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}function ir(){return this.t==0?this.s:this[0]<<24>>24}function nr(){return this.t==0?this.s:this[0]<<16>>16}function or(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function sr(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function ar(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=s(r),a=p(),l=p(),b="";for(this.divRemTo(i,a,l);a.signum()>0;)b=(r+l.intValue()).toString(t).substr(1)+b,a.divRemTo(i,a,l);return l.intValue().toString(t)+b}function fr(t,e){this.fromInt(0),e==null&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),a=!1,l=0,b=0,E=0;E<t.length;++E){var W=o(t,E);if(W<0){t.charAt(E)=="-"&&this.signum()==0&&(a=!0);continue}b=e*b+W,++l>=r&&(this.dMultiply(i),this.dAddOffset(b,0),l=0,b=0)}l>0&&(this.dMultiply(Math.pow(e,l)),this.dAddOffset(b,0)),a&&n.ZERO.subTo(this,this)}function ur(t,e,r){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(n.ONE.shiftLeft(t-1),Ht,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(n.ONE.shiftLeft(t-1),this);else{var i=new Array,a=t&7;i.length=(t>>3)+1,e.nextBytes(i),a>0?i[0]&=(1<<a)-1:i[0]=0,this.fromString(i,256)}}function hr(){var t=this.t,e=new Array;e[0]=this.s;var r=this.DB-t*this.DB%8,i,a=0;if(t-- >0)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[a++]=i|this.s<<this.DB-r);t>=0;)r<8?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),(i&128)!=0&&(i|=-256),a==0&&(this.s&128)!=(i&128)&&++a,(a>0||i!=this.s)&&(e[a++]=i);return e}function cr(t){return this.compareTo(t)==0}function lr(t){return this.compareTo(t)<0?this:t}function pr(t){return this.compareTo(t)>0?this:t}function vr(t,e,r){var i,a,l=Math.min(t.t,this.t);for(i=0;i<l;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(a=t.s&this.DM,i=l;i<this.t;++i)r[i]=e(this[i],a);r.t=this.t}else{for(a=this.s&this.DM,i=l;i<t.t;++i)r[i]=e(a,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}function dr(t,e){return t&e}function xr(t){var e=p();return this.bitwiseTo(t,dr,e),e}function Ht(t,e){return t|e}function gr(t){var e=p();return this.bitwiseTo(t,Ht,e),e}function ae(t,e){return t^e}function mr(t){var e=p();return this.bitwiseTo(t,ae,e),e}function fe(t,e){return t&~e}function wr(t){var e=p();return this.bitwiseTo(t,fe,e),e}function yr(){for(var t=p(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}function br(t){var e=p();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function Tr(t){var e=p();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function Fr(t){if(t==0)return-1;var e=0;return(t&65535)==0&&(t>>=16,e+=16),(t&255)==0&&(t>>=8,e+=8),(t&15)==0&&(t>>=4,e+=4),(t&3)==0&&(t>>=2,e+=2),(t&1)==0&&++e,e}function Br(){for(var t=0;t<this.t;++t)if(this[t]!=0)return t*this.DB+Fr(this[t]);return this.s<0?this.t*this.DB:-1}function Er(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function Pr(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=Er(this[r]^e);return t}function Sr(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this[e]&1<<t%this.DB)!=0}function Ir(t,e){var r=n.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}function Dr(t){return this.changeBit(t,Ht)}function Mr(t){return this.changeBit(t,fe)}function Rr(t){return this.changeBit(t,ae)}function qr(t,e){for(var r=0,i=0,a=Math.min(t.t,this.t);r<a;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()}function Ar(t){var e=p();return this.addTo(t,e),e}function _r(t){var e=p();return this.subTo(t,e),e}function Or(t){var e=p();return this.multiplyTo(t,e),e}function Cr(){var t=p();return this.squareTo(t),t}function Vr(t){var e=p();return this.divRemTo(t,e,null),e}function Lr(t){var e=p();return this.divRemTo(t,null,e),e}function Hr(t){var e=p(),r=p();return this.divRemTo(t,e,r),new Array(e,r)}function Nr(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function Ur(t,e){if(t!=0){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function Bt(){}function ue(t){return t}function zr(t,e,r){t.multiplyTo(e,r)}function Kr(t,e){t.squareTo(e)}Bt.prototype.convert=ue,Bt.prototype.revert=ue,Bt.prototype.mulTo=zr,Bt.prototype.sqrTo=Kr;function Wr(t){return this.exp(t,new Bt)}function $r(t,e,r){var i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;var a;for(a=r.t-this.t;i<a;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(a=Math.min(t.t,e);i<a;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()}function Zr(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)}function gt(t){this.r2=p(),this.q3=p(),n.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function Jr(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=p();return t.copyTo(e),this.reduce(e),e}function Gr(t){return t}function Yr(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function Xr(t,e){t.squareTo(e),this.reduce(e)}function kr(t,e,r){t.multiplyTo(e,r),this.reduce(r)}gt.prototype.convert=Jr,gt.prototype.revert=Gr,gt.prototype.reduce=Yr,gt.prototype.mulTo=kr,gt.prototype.sqrTo=Xr;function Qr(t,e){var r=t.bitLength(),i,a=s(1),l;if(r<=0)return a;r<18?i=1:r<48?i=3:r<144?i=4:r<768?i=5:i=6,r<8?l=new z(e):e.isEven()?l=new gt(e):l=new ut(e);var b=new Array,E=3,W=i-1,X=(1<<i)-1;if(b[1]=l.convert(this),i>1){var ft=p();for(l.sqrTo(b[1],ft);E<=X;)b[E]=p(),l.mulTo(ft,b[E-2],b[E]),E+=2}var ot=t.t-1,pt,_t=!0,ct=p(),lt;for(r=B(t[ot])-1;ot>=0;){for(r>=W?pt=t[ot]>>r-W&X:(pt=(t[ot]&(1<<r+1)-1)<<W-r,ot>0&&(pt|=t[ot-1]>>this.DB+r-W)),E=i;(pt&1)==0;)pt>>=1,--E;if((r-=E)<0&&(r+=this.DB,--ot),_t)b[pt].copyTo(a),_t=!1;else{for(;E>1;)l.sqrTo(a,ct),l.sqrTo(ct,a),E-=2;E>0?l.sqrTo(a,ct):(lt=a,a=ct,ct=lt),l.mulTo(ct,b[pt],a)}for(;ot>=0&&(t[ot]&1<<r)==0;)l.sqrTo(a,ct),lt=a,a=ct,ct=lt,--r<0&&(r=this.DB-1,--ot)}return l.revert(a)}function jr(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var a=e.getLowestSetBit(),l=r.getLowestSetBit();if(l<0)return e;for(a<l&&(l=a),l>0&&(e.rShiftTo(l,e),r.rShiftTo(l,r));e.signum()>0;)(a=e.getLowestSetBit())>0&&e.rShiftTo(a,e),(a=r.getLowestSetBit())>0&&r.rShiftTo(a,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return l>0&&r.lShiftTo(l,r),r}function ti(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(e==0)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r}function ei(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return n.ZERO;for(var r=t.clone(),i=this.clone(),a=s(1),l=s(0),b=s(0),E=s(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),e?((!a.isEven()||!l.isEven())&&(a.addTo(this,a),l.subTo(t,l)),a.rShiftTo(1,a)):l.isEven()||l.subTo(t,l),l.rShiftTo(1,l);for(;i.isEven();)i.rShiftTo(1,i),e?((!b.isEven()||!E.isEven())&&(b.addTo(this,b),E.subTo(t,E)),b.rShiftTo(1,b)):E.isEven()||E.subTo(t,E),E.rShiftTo(1,E);r.compareTo(i)>=0?(r.subTo(i,r),e&&a.subTo(b,a),l.subTo(E,l)):(i.subTo(r,i),e&&b.subTo(a,b),E.subTo(l,E))}if(i.compareTo(n.ONE)!=0)return n.ZERO;if(E.compareTo(t)>=0)return E.subtract(t);if(E.signum()<0)E.addTo(t,E);else return E;return E.signum()<0?E.add(t):E}var et=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],ri=(1<<26)/et[et.length-1];function ii(t){var e,r=this.abs();if(r.t==1&&r[0]<=et[et.length-1]){for(e=0;e<et.length;++e)if(r[0]==et[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<et.length;){for(var i=et[e],a=e+1;a<et.length&&i<ri;)i*=et[a++];for(i=r.modInt(i);e<a;)if(i%et[e++]==0)return!1}return r.millerRabin(t)}function ni(t){var e=this.subtract(n.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);t=t+1>>1,t>et.length&&(t=et.length);for(var a=p(),l=0;l<t;++l){a.fromInt(et[Math.floor(Math.random()*et.length)]);var b=a.modPow(i,this);if(b.compareTo(n.ONE)!=0&&b.compareTo(e)!=0){for(var E=1;E++<r&&b.compareTo(e)!=0;)if(b=b.modPowInt(2,this),b.compareTo(n.ONE)==0)return!1;if(b.compareTo(e)!=0)return!1}}return!0}n.prototype.chunkSize=or,n.prototype.toRadix=ar,n.prototype.fromRadix=fr,n.prototype.fromNumber=ur,n.prototype.bitwiseTo=vr,n.prototype.changeBit=Ir,n.prototype.addTo=qr,n.prototype.dMultiply=Nr,n.prototype.dAddOffset=Ur,n.prototype.multiplyLowerTo=$r,n.prototype.multiplyUpperTo=Zr,n.prototype.modInt=ti,n.prototype.millerRabin=ni,n.prototype.clone=Lt,n.prototype.intValue=wt,n.prototype.byteValue=ir,n.prototype.shortValue=nr,n.prototype.signum=sr,n.prototype.toByteArray=hr,n.prototype.equals=cr,n.prototype.min=lr,n.prototype.max=pr,n.prototype.and=xr,n.prototype.or=gr,n.prototype.xor=mr,n.prototype.andNot=wr,n.prototype.not=yr,n.prototype.shiftLeft=br,n.prototype.shiftRight=Tr,n.prototype.getLowestSetBit=Br,n.prototype.bitCount=Pr,n.prototype.testBit=Sr,n.prototype.setBit=Dr,n.prototype.clearBit=Mr,n.prototype.flipBit=Rr,n.prototype.add=Ar,n.prototype.subtract=_r,n.prototype.multiply=Or,n.prototype.divide=Vr,n.prototype.remainder=Lr,n.prototype.divideAndRemainder=Hr,n.prototype.modPow=Qr,n.prototype.modInverse=ei,n.prototype.pow=Wr,n.prototype.gcd=jr,n.prototype.isProbablePrime=ii,n.prototype.square=Cr,n.prototype.Barrett=gt;var At,nt,Y;function oi(t){nt[Y++]^=t&255,nt[Y++]^=t>>8&255,nt[Y++]^=t>>16&255,nt[Y++]^=t>>24&255,Y>=Ut&&(Y-=Ut)}function he(){oi(new Date().getTime())}if(nt==null){nt=new Array,Y=0;var ht;if(typeof window!="undefined"&&window.crypto){if(window.crypto.getRandomValues){var ce=new Uint8Array(32);for(window.crypto.getRandomValues(ce),ht=0;ht<32;++ht)nt[Y++]=ce[ht]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var le=window.crypto.random(32);for(ht=0;ht<le.length;++ht)nt[Y++]=le.charCodeAt(ht)&255}}for(;Y<Ut;)ht=Math.floor(65536*Math.random()),nt[Y++]=ht>>>8,nt[Y++]=ht&255;Y=0,he()}function si(){if(At==null){for(he(),At=hi(),At.init(nt),Y=0;Y<nt.length;++Y)nt[Y]=0;Y=0}return At.next()}function ai(t){var e;for(e=0;e<t.length;++e)t[e]=si()}function pe(){}pe.prototype.nextBytes=ai;function Nt(){this.i=0,this.j=0,this.S=new Array}function fi(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0}function ui(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}Nt.prototype.init=fi,Nt.prototype.next=ui;function hi(){return new Nt}var Ut=256;u.exports={default:n,BigInteger:n,SecureRandom:pe}}).call(He)}(St)),St.exports}var oe;function Ue(){return oe||(oe=1,function(u){u.exports=function(h){var A={};function q(y){if(A[y])return A[y].exports;var n=A[y]={i:y,l:!1,exports:{}};return h[y].call(n.exports,n,n.exports,q),n.l=!0,n.exports}return q.m=h,q.c=A,q.d=function(y,n,p){q.o(y,n)||Object.defineProperty(y,n,{enumerable:!0,get:p})},q.r=function(y){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(y,"__esModule",{value:!0})},q.t=function(y,n){if(n&1&&(y=q(y)),n&8||n&4&&typeof y=="object"&&y&&y.__esModule)return y;var p=Object.create(null);if(q.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:y}),n&2&&typeof y!="string")for(var $ in y)q.d(p,$,function(K){return y[K]}.bind(null,$));return p},q.n=function(y){var n=y&&y.__esModule?function(){return y.default}:function(){return y};return q.d(n,"a",n),n},q.o=function(y,n){return Object.prototype.hasOwnProperty.call(y,n)},q.p="",q(q.s=2)}([function(h,A){h.exports=Ne()},function(h,A,q){var y=new Uint32Array(68),n=new Uint32Array(64);function p(g,o){var M=o&31;return g<<M|g>>>32-M}function $(g,o){for(var M=[],S=g.length-1;S>=0;S--)M[S]=(g[S]^o[S])&255;return M}function K(g){return g^p(g,9)^p(g,17)}function D(g){return g^p(g,15)^p(g,23)}function N(g){var o=g.length*8,M=o%512;M=M>=448?512-M%448-1:448-M-1;for(var S=new Array((M-7)/8),s=new Array(8),x=0,T=S.length;x<T;x++)S[x]=0;for(var f=0,w=s.length;f<w;f++)s[f]=0;o=o.toString(2);for(var v=7;v>=0;v--)if(o.length>8){var m=o.length-8;s[v]=parseInt(o.substr(m),2),o=o.substr(0,m)}else o.length>0&&(s[v]=parseInt(o,2),o="");for(var B=new Uint8Array([].concat(g,[128],S,s)),F=new DataView(B.buffer,0),C=B.length/64,R=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]),O=0;O<C;O++){y.fill(0),n.fill(0);for(var U=16*O,H=0;H<16;H++)y[H]=F.getUint32((U+H)*4,!1);for(var V=16;V<68;V++)y[V]=D(y[V-16]^y[V-9]^p(y[V-3],15))^p(y[V-13],7)^y[V-6];for(var L=0;L<64;L++)n[L]=y[L]^y[L+4];for(var Z=2043430169,J=2055708042,z=R[0],k=R[1],G=R[2],Q=R[3],tt=R[4],rt=R[5],at=R[6],ut=R[7],Tt=void 0,It=void 0,Dt=void 0,Mt=void 0,Rt=void 0,it=0;it<64;it++)Rt=it>=0&&it<=15?Z:J,Tt=p(p(z,12)+tt+p(Rt,it),7),It=Tt^p(z,12),Dt=(it>=0&&it<=15?z^k^G:z&k|z&G|k&G)+Q+It+n[it],Mt=(it>=0&&it<=15?tt^rt^at:tt&rt|~tt&at)+ut+Tt+y[it],Q=G,G=p(k,9),k=z,z=Dt,ut=at,at=p(rt,19),rt=tt,tt=K(Mt);R[0]^=z,R[1]^=k,R[2]^=G,R[3]^=Q,R[4]^=tt,R[5]^=rt,R[6]^=at,R[7]^=ut}for(var qt=[],Ft=0,Lt=R.length;Ft<Lt;Ft++){var wt=R[Ft];qt.push((wt&4278190080)>>>24,(wt&16711680)>>>16,(wt&65280)>>>8,wt&255)}return qt}for(var _=64,d=new Uint8Array(_),I=new Uint8Array(_),c=0;c<_;c++)d[c]=54,I[c]=92;function P(g,o){for(o.length>_&&(o=N(o));o.length<_;)o.push(0);var M=$(o,d),S=$(o,I),s=N([].concat(M,g));return N([].concat(S,s))}h.exports={sm3:N,hmac:P}},function(h,A,q){h.exports={sm2:q(3),sm3:q(7),sm4:q(8)}},function(h,A,q){var y=q(0),n=y.BigInteger,p=q(4),$=p.encodeDer,K=p.decodeDer,D=q(5),N=q(1).sm3,_=D.generateEcparam(),d=_.G,I=_.curve,c=_.n,P=0;function g(f,w){var v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;f=typeof f=="string"?D.hexToArray(D.utf8ToHex(f)):Array.prototype.slice.call(f),w=D.getGlobalCurve().decodePointHex(w);var m=D.generateKeyPairHex(),B=new n(m.privateKey,16),F=m.publicKey;F.length>128&&(F=F.substr(F.length-128));var C=w.multiply(B),R=D.hexToArray(D.leftPad(C.getX().toBigInteger().toRadix(16),64)),O=D.hexToArray(D.leftPad(C.getY().toBigInteger().toRadix(16),64)),U=D.arrayToHex(N([].concat(R,f,O))),H=1,V=0,L=[],Z=[].concat(R,O),J=function(){L=N([].concat(Z,[H>>24&255,H>>16&255,H>>8&255,H&255])),H++,V=0};J();for(var z=0,k=f.length;z<k;z++)V===L.length&&J(),f[z]^=L[V++]&255;var G=D.arrayToHex(f);return v===P?F+G+U:F+U+G}function o(f,w){var v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,m=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},B=m.output,F=B===void 0?"string":B;w=new n(w,16);var C=f.substr(128,64),R=f.substr(192);v===P&&(C=f.substr(f.length-64),R=f.substr(128,f.length-128-64));var O=D.hexToArray(R),U=D.getGlobalCurve().decodePointHex("04"+f.substr(0,128)),H=U.multiply(w),V=D.hexToArray(D.leftPad(H.getX().toBigInteger().toRadix(16),64)),L=D.hexToArray(D.leftPad(H.getY().toBigInteger().toRadix(16),64)),Z=1,J=0,z=[],k=[].concat(V,L),G=function(){z=N([].concat(k,[Z>>24&255,Z>>16&255,Z>>8&255,Z&255])),Z++,J=0};G();for(var Q=0,tt=O.length;Q<tt;Q++)J===z.length&&G(),O[Q]^=z[J++]&255;var rt=D.arrayToHex(N([].concat(V,O,L)));return rt===C.toLowerCase()?F==="array"?O:D.arrayToUtf8(O):F==="array"?[]:""}function M(f,w){var v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},m=v.pointPool,B=v.der,F=v.hash,C=v.publicKey,R=v.userId,O=typeof f=="string"?D.utf8ToHex(f):D.arrayToHex(f);F&&(C=C||x(w),O=s(O,C,R));var U=new n(w,16),H=new n(O,16),V=null,L=null,Z=null;do{do{var J=void 0;m&&m.length?J=m.pop():J=T(),V=J.k,L=H.add(J.x1).mod(c)}while(L.equals(n.ZERO)||L.add(V).equals(c));Z=U.add(n.ONE).modInverse(c).multiply(V.subtract(L.multiply(U))).mod(c)}while(Z.equals(n.ZERO));return B?$(L,Z):D.leftPad(L.toString(16),64)+D.leftPad(Z.toString(16),64)}function S(f,w,v){var m=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},B=m.der,F=m.hash,C=m.userId,R=typeof f=="string"?D.utf8ToHex(f):D.arrayToHex(f);F&&(R=s(R,v,C));var O=void 0,U=void 0;if(B){var H=K(w);O=H.r,U=H.s}else O=new n(w.substring(0,64),16),U=new n(w.substring(64),16);var V=I.decodePointHex(v),L=new n(R,16),Z=O.add(U).mod(c);if(Z.equals(n.ZERO))return!1;var J=d.multiply(U).add(V.multiply(Z)),z=L.add(J.getX().toBigInteger()).mod(c);return O.equals(z)}function s(f,w){var v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"1234567812345678";v=D.utf8ToHex(v);var m=D.leftPad(d.curve.a.toBigInteger().toRadix(16),64),B=D.leftPad(d.curve.b.toBigInteger().toRadix(16),64),F=D.leftPad(d.getX().toBigInteger().toRadix(16),64),C=D.leftPad(d.getY().toBigInteger().toRadix(16),64),R=void 0,O=void 0;if(w.length===128)R=w.substr(0,64),O=w.substr(64,64);else{var U=d.curve.decodePointHex(w);R=D.leftPad(U.getX().toBigInteger().toRadix(16),64),O=D.leftPad(U.getY().toBigInteger().toRadix(16),64)}var H=D.hexToArray(v+m+B+F+C+R+O),V=v.length*4;H.unshift(V&255),H.unshift(V>>8&255);var L=N(H);return D.arrayToHex(N(L.concat(D.hexToArray(f))))}function x(f){var w=d.multiply(new n(f,16)),v=D.leftPad(w.getX().toBigInteger().toString(16),64),m=D.leftPad(w.getY().toBigInteger().toString(16),64);return"04"+v+m}function T(){var f=D.generateKeyPairHex(),w=I.decodePointHex(f.publicKey);return f.k=new n(f.privateKey,16),f.x1=w.getX().toBigInteger(),f}h.exports={generateKeyPairHex:D.generateKeyPairHex,compressPublicKeyHex:D.compressPublicKeyHex,comparePublicKeyHex:D.comparePublicKeyHex,doEncrypt:g,doDecrypt:o,doSignature:M,doVerifySignature:S,getPublicKeyFromPrivateKey:x,getPoint:T,verifyPublicKey:D.verifyPublicKey}},function(h,A,q){function y(g,o){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o&&(typeof o=="object"||typeof o=="function")?o:g}function n(g,o){if(typeof o!="function"&&o!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof o);g.prototype=Object.create(o&&o.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),o&&(Object.setPrototypeOf?Object.setPrototypeOf(g,o):g.__proto__=o)}function p(g,o){if(!(g instanceof o))throw new TypeError("Cannot call a class as a function")}var $=q(0),K=$.BigInteger;function D(g){var o=g.toString(16);if(o[0]!=="-")o.length%2===1?o="0"+o:o.match(/^[0-7]/)||(o="00"+o);else{o=o.substr(1);var M=o.length;M%2===1?M+=1:o.match(/^[0-7]/)||(M+=2);for(var S="",s=0;s<M;s++)S+="f";S=new K(S,16),o=S.xor(g).add(K.ONE),o=o.toString(16).replace(/^-/,"")}return o}var N=function(){function g(){p(this,g),this.tlv=null,this.t="00",this.l="00",this.v=""}return g.prototype.getEncodedHex=function(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv},g.prototype.getLength=function(){var M=this.v.length/2,S=M.toString(16);if(S.length%2===1&&(S="0"+S),M<128)return S;var s=128+S.length/2;return s.toString(16)+S},g.prototype.getValue=function(){return""},g}(),_=function(g){n(o,g);function o(M){p(this,o);var S=y(this,g.call(this));return S.t="02",M&&(S.v=D(M)),S}return o.prototype.getValue=function(){return this.v},o}(N),d=function(g){n(o,g);function o(M){p(this,o);var S=y(this,g.call(this));return S.t="30",S.asn1Array=M,S}return o.prototype.getValue=function(){return this.v=this.asn1Array.map(function(S){return S.getEncodedHex()}).join(""),this.v},o}(N);function I(g,o){return+g[o+2]<8?1:+g.substr(o+2,2)&128}function c(g,o){var M=I(g,o),S=g.substr(o+2,M*2);if(!S)return-1;var s=+S[0]<8?new K(S,16):new K(S.substr(2),16);return s.intValue()}function P(g,o){var M=I(g,o);return o+(M+1)*2}h.exports={encodeDer:function(o,M){var S=new _(o),s=new _(M),x=new d([S,s]);return x.getEncodedHex()},decodeDer:function(o){var M=P(o,0),S=P(o,M),s=c(o,M),x=o.substr(S,s*2),T=S+x.length,f=P(o,T),w=c(o,T),v=o.substr(f,w*2),m=new K(x,16),B=new K(v,16);return{r:m,s:B}}}},function(h,A,q){var y=q(0),n=y.BigInteger,p=y.SecureRandom,$=q(6),K=$.ECCurveFp,D=new p,N=P(),_=N.curve,d=N.G,I=N.n;function c(){return _}function P(){var v=new n("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),m=new n("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),B=new n("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),F=new K(v,m,B),C="32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7",R="BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0",O=F.decodePointHex("04"+C+R),U=new n("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16);return{curve:F,G:O,n:U}}function g(v,m,B){var F=v?new n(v,m,B):new n(I.bitLength(),D),C=F.mod(I.subtract(n.ONE)).add(n.ONE),R=S(C.toString(16),64),O=d.multiply(C),U=S(O.getX().toBigInteger().toString(16),64),H=S(O.getY().toBigInteger().toString(16),64),V="04"+U+H;return{privateKey:R,publicKey:V}}function o(v){if(v.length!==130)throw new Error("Invalid public key to compress");var m=(v.length-2)/2,B=v.substr(2,m),F=new n(v.substr(m+2,m),16),C="03";return F.mod(new n("2")).equals(n.ZERO)&&(C="02"),C+B}function M(v){v=unescape(encodeURIComponent(v));for(var m=v.length,B=[],F=0;F<m;F++)B[F>>>2]|=(v.charCodeAt(F)&255)<<24-F%4*8;for(var C=[],R=0;R<m;R++){var O=B[R>>>2]>>>24-R%4*8&255;C.push((O>>>4).toString(16)),C.push((O&15).toString(16))}return C.join("")}function S(v,m){return v.length>=m?v:new Array(m-v.length+1).join("0")+v}function s(v){return v.map(function(m){return m=m.toString(16),m.length===1?"0"+m:m}).join("")}function x(v){for(var m=[],B=0,F=0;F<v.length*2;F+=2)m[F>>>3]|=parseInt(v[B],10)<<24-F%8*4,B++;try{for(var C=[],R=0;R<v.length;R++){var O=m[R>>>2]>>>24-R%4*8&255;C.push(String.fromCharCode(O))}return decodeURIComponent(escape(C.join("")))}catch(U){throw new Error("Malformed UTF-8 data")}}function T(v){var m=[],B=v.length;B%2!==0&&(v=S(v,B+1)),B=v.length;for(var F=0;F<B;F+=2)m.push(parseInt(v.substr(F,2),16));return m}function f(v){var m=_.decodePointHex(v);if(!m)return!1;var B=m.getX(),F=m.getY();return F.square().equals(B.multiply(B.square()).add(B.multiply(_.a)).add(_.b))}function w(v,m){var B=_.decodePointHex(v);if(!B)return!1;var F=_.decodePointHex(m);return F?B.equals(F):!1}h.exports={getGlobalCurve:c,generateEcparam:P,generateKeyPairHex:g,compressPublicKeyHex:o,utf8ToHex:M,leftPad:S,arrayToHex:s,arrayToUtf8:x,hexToArray:T,verifyPublicKey:f,comparePublicKeyHex:w}},function(h,A,q){function y(d,I){if(!(d instanceof I))throw new TypeError("Cannot call a class as a function")}var n=q(0),p=n.BigInteger,$=new p("2"),K=new p("3"),D=function(){function d(I,c){y(this,d),this.x=c,this.q=I}return d.prototype.equals=function(c){return c===this?!0:this.q.equals(c.q)&&this.x.equals(c.x)},d.prototype.toBigInteger=function(){return this.x},d.prototype.negate=function(){return new d(this.q,this.x.negate().mod(this.q))},d.prototype.add=function(c){return new d(this.q,this.x.add(c.toBigInteger()).mod(this.q))},d.prototype.subtract=function(c){return new d(this.q,this.x.subtract(c.toBigInteger()).mod(this.q))},d.prototype.multiply=function(c){return new d(this.q,this.x.multiply(c.toBigInteger()).mod(this.q))},d.prototype.divide=function(c){return new d(this.q,this.x.multiply(c.toBigInteger().modInverse(this.q)).mod(this.q))},d.prototype.square=function(){return new d(this.q,this.x.square().mod(this.q))},d}(),N=function(){function d(I,c,P,g){y(this,d),this.curve=I,this.x=c,this.y=P,this.z=g==null?p.ONE:g,this.zinv=null}return d.prototype.getX=function(){return this.zinv===null&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},d.prototype.getY=function(){return this.zinv===null&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},d.prototype.equals=function(c){if(c===this)return!0;if(this.isInfinity())return c.isInfinity();if(c.isInfinity())return this.isInfinity();var P=c.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(c.z)).mod(this.curve.q);if(!P.equals(p.ZERO))return!1;var g=c.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(c.z)).mod(this.curve.q);return g.equals(p.ZERO)},d.prototype.isInfinity=function(){return this.x===null&&this.y===null?!0:this.z.equals(p.ZERO)&&!this.y.toBigInteger().equals(p.ZERO)},d.prototype.negate=function(){return new d(this.curve,this.x,this.y.negate(),this.z)},d.prototype.add=function(c){if(this.isInfinity())return c;if(c.isInfinity())return this;var P=this.x.toBigInteger(),g=this.y.toBigInteger(),o=this.z,M=c.x.toBigInteger(),S=c.y.toBigInteger(),s=c.z,x=this.curve.q,T=P.multiply(s).mod(x),f=M.multiply(o).mod(x),w=T.subtract(f),v=g.multiply(s).mod(x),m=S.multiply(o).mod(x),B=v.subtract(m);if(p.ZERO.equals(w))return p.ZERO.equals(B)?this.twice():this.curve.infinity;var F=T.add(f),C=o.multiply(s).mod(x),R=w.square().mod(x),O=w.multiply(R).mod(x),U=C.multiply(B.square()).subtract(F.multiply(R)).mod(x),H=w.multiply(U).mod(x),V=B.multiply(R.multiply(T).subtract(U)).subtract(v.multiply(O)).mod(x),L=O.multiply(C).mod(x);return new d(this.curve,this.curve.fromBigInteger(H),this.curve.fromBigInteger(V),L)},d.prototype.twice=function(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;var c=this.x.toBigInteger(),P=this.y.toBigInteger(),g=this.z,o=this.curve.q,M=this.curve.a.toBigInteger(),S=c.square().multiply(K).add(M.multiply(g.square())).mod(o),s=P.shiftLeft(1).multiply(g).mod(o),x=P.square().mod(o),T=x.multiply(c).multiply(g).mod(o),f=s.square().mod(o),w=S.square().subtract(T.shiftLeft(3)).mod(o),v=s.multiply(w).mod(o),m=S.multiply(T.shiftLeft(2).subtract(w)).subtract(f.shiftLeft(1).multiply(x)).mod(o),B=s.multiply(f).mod(o);return new d(this.curve,this.curve.fromBigInteger(v),this.curve.fromBigInteger(m),B)},d.prototype.multiply=function(c){if(this.isInfinity())return this;if(!c.signum())return this.curve.infinity;for(var P=c.multiply(K),g=this.negate(),o=this,M=P.bitLength()-2;M>0;M--){o=o.twice();var S=P.testBit(M),s=c.testBit(M);S!==s&&(o=o.add(S?this:g))}return o},d}(),_=function(){function d(I,c,P){y(this,d),this.q=I,this.a=this.fromBigInteger(c),this.b=this.fromBigInteger(P),this.infinity=new N(this,null,null)}return d.prototype.equals=function(c){return c===this?!0:this.q.equals(c.q)&&this.a.equals(c.a)&&this.b.equals(c.b)},d.prototype.fromBigInteger=function(c){return new D(this.q,c)},d.prototype.decodePointHex=function(c){switch(parseInt(c.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var P=this.fromBigInteger(new p(c.substr(2),16)),g=this.fromBigInteger(P.multiply(P.square()).add(P.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new p("4")).add(p.ONE),this.q));return g.toBigInteger().mod($).equals(new p(c.substr(0,2),16).subtract($))||(g=g.negate()),new N(this,P,g);case 4:case 6:case 7:var o=(c.length-2)/2,M=c.substr(2,o),S=c.substr(o+2,o);return new N(this,this.fromBigInteger(new p(M,16)),this.fromBigInteger(new p(S,16)));default:return null}},d}();h.exports={ECPointFp:N,ECCurveFp:_}},function(h,A,q){var y=q(1),n=y.sm3,p=y.hmac;function $(_,d){return _.length>=d?_:new Array(d-_.length+1).join("0")+_}function K(_){return _.map(function(d){return d=d.toString(16),d.length===1?"0"+d:d}).join("")}function D(_){var d=[],I=_.length;I%2!==0&&(_=$(_,I+1)),I=_.length;for(var c=0;c<I;c+=2)d.push(parseInt(_.substr(c,2),16));return d}function N(_){for(var d=[],I=0,c=_.length;I<c;I++){var P=_.codePointAt(I);if(P<=127)d.push(P);else if(P<=2047)d.push(192|P>>>6),d.push(128|P&63);else if(P<=55295||P>=57344&&P<=65535)d.push(224|P>>>12),d.push(128|P>>>6&63),d.push(128|P&63);else if(P>=65536&&P<=1114111)I++,d.push(240|P>>>18&28),d.push(128|P>>>12&63),d.push(128|P>>>6&63),d.push(128|P&63);else throw d.push(P),new Error("input is not supported")}return d}h.exports=function(_,d){if(_=typeof _=="string"?N(_):Array.prototype.slice.call(_),d){var I=d.mode||"hmac";if(I!=="hmac")throw new Error("invalid mode");var c=d.key;if(!c)throw new Error("invalid key");return c=typeof c=="string"?D(c):Array.prototype.slice.call(c),K(p(_,c))}return K(n(_))}},function(h,A,q){var y=0,n=32,p=16,$=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],K=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function D(s){for(var x=[],T=0,f=s.length;T<f;T+=2)x.push(parseInt(s.substr(T,2),16));return x}function N(s){return s.map(function(x){return x=x.toString(16),x.length===1?"0"+x:x}).join("")}function _(s){for(var x=[],T=0,f=s.length;T<f;T++){var w=s.codePointAt(T);if(w<=127)x.push(w);else if(w<=2047)x.push(192|w>>>6),x.push(128|w&63);else if(w<=55295||w>=57344&&w<=65535)x.push(224|w>>>12),x.push(128|w>>>6&63),x.push(128|w&63);else if(w>=65536&&w<=1114111)T++,x.push(240|w>>>18&28),x.push(128|w>>>12&63),x.push(128|w>>>6&63),x.push(128|w&63);else throw x.push(w),new Error("input is not supported")}return x}function d(s){for(var x=[],T=0,f=s.length;T<f;T++)s[T]>=240&&s[T]<=247?(x.push(String.fromCodePoint(((s[T]&7)<<18)+((s[T+1]&63)<<12)+((s[T+2]&63)<<6)+(s[T+3]&63))),T+=3):s[T]>=224&&s[T]<=239?(x.push(String.fromCodePoint(((s[T]&15)<<12)+((s[T+1]&63)<<6)+(s[T+2]&63))),T+=2):s[T]>=192&&s[T]<=223?(x.push(String.fromCodePoint(((s[T]&31)<<6)+(s[T+1]&63))),T++):x.push(String.fromCodePoint(s[T]));return x.join("")}function I(s,x){var T=x&31;return s<<T|s>>>32-T}function c(s){return($[s>>>24&255]&255)<<24|($[s>>>16&255]&255)<<16|($[s>>>8&255]&255)<<8|$[s&255]&255}function P(s){return s^I(s,2)^I(s,10)^I(s,18)^I(s,24)}function g(s){return s^I(s,13)^I(s,23)}function o(s,x,T){for(var f=new Array(4),w=new Array(4),v=0;v<4;v++)w[0]=s[4*v]&255,w[1]=s[4*v+1]&255,w[2]=s[4*v+2]&255,w[3]=s[4*v+3]&255,f[v]=w[0]<<24|w[1]<<16|w[2]<<8|w[3];for(var m=0,B;m<32;m+=4)B=f[1]^f[2]^f[3]^T[m+0],f[0]^=P(c(B)),B=f[2]^f[3]^f[0]^T[m+1],f[1]^=P(c(B)),B=f[3]^f[0]^f[1]^T[m+2],f[2]^=P(c(B)),B=f[0]^f[1]^f[2]^T[m+3],f[3]^=P(c(B));for(var F=0;F<16;F+=4)x[F]=f[3-F/4]>>>24&255,x[F+1]=f[3-F/4]>>>16&255,x[F+2]=f[3-F/4]>>>8&255,x[F+3]=f[3-F/4]&255}function M(s,x,T){for(var f=new Array(4),w=new Array(4),v=0;v<4;v++)w[0]=s[0+4*v]&255,w[1]=s[1+4*v]&255,w[2]=s[2+4*v]&255,w[3]=s[3+4*v]&255,f[v]=w[0]<<24|w[1]<<16|w[2]<<8|w[3];f[0]^=2746333894,f[1]^=1453994832,f[2]^=1736282519,f[3]^=2993693404;for(var m=0,B;m<32;m+=4)B=f[1]^f[2]^f[3]^K[m+0],x[m+0]=f[0]^=g(c(B)),B=f[2]^f[3]^f[0]^K[m+1],x[m+1]=f[1]^=g(c(B)),B=f[3]^f[0]^f[1]^K[m+2],x[m+2]=f[2]^=g(c(B)),B=f[0]^f[1]^f[2]^K[m+3],x[m+3]=f[3]^=g(c(B));if(T===y)for(var F=0,C;F<16;F++)C=x[F],x[F]=x[31-F],x[31-F]=C}function S(s,x,T){var f=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},w=f.padding,v=w===void 0?"pkcs#7":w,m=f.mode,B=f.iv,F=B===void 0?[]:B,C=f.output,R=C===void 0?"string":C;if(m==="cbc"&&(typeof F=="string"&&(F=D(F)),F.length!==128/8))throw new Error("iv is invalid");if(typeof x=="string"&&(x=D(x)),x.length!==128/8)throw new Error("key is invalid");if(typeof s=="string"?T!==y?s=_(s):s=D(s):s=[].concat(s),(v==="pkcs#5"||v==="pkcs#7")&&T!==y)for(var O=p-s.length%p,U=0;U<O;U++)s.push(O);var H=new Array(n);M(x,H,T);for(var V=[],L=F,Z=s.length,J=0;Z>=p;){var z=s.slice(J,J+16),k=new Array(16);if(m==="cbc")for(var G=0;G<p;G++)T!==y&&(z[G]^=L[G]);o(z,k,H);for(var Q=0;Q<p;Q++)m==="cbc"&&T===y&&(k[Q]^=L[Q]),V[J+Q]=k[Q];m==="cbc"&&(T!==y?L=k:L=z),Z-=p,J+=p}if((v==="pkcs#5"||v==="pkcs#7")&&T===y){for(var tt=V.length,rt=V[tt-1],at=1;at<=rt;at++)if(V[tt-at]!==rt)throw new Error("padding is invalid");V.splice(tt-rt,rt)}return R!=="array"?T!==y?N(V):d(V):V}h.exports={encrypt:function(x,T,f){return S(x,T,1,f)},decrypt:function(x,T,f){return S(x,T,0,f)}}}])}(Vt)),Vt.exports}var j=Ue();const ze=u=>j.sm2.generateKeyPairHex(u),Ke=(u,h,A=1,q)=>j.sm2.doEncrypt(u,h,A,q),We=(u,h,A=1,q)=>j.sm2.doDecrypt(u,h,A,q),$e=(u,h,A)=>j.sm2.doSignature(u,h,A),Ze=(u,h,A,q)=>j.sm2.doVerifySignature(u,h,A,q),Je=u=>j.sm2.getPublicKeyFromPrivateKey(u),Ge=()=>j.sm2.getPoint(),Ye=u=>j.sm2.compressPublicKeyHex(u),Xe=(u,h)=>j.sm2.comparePublicKeyHex(u,h),ke=u=>j.sm2.verifyPublicKey(u),Qe=(u,h)=>j.sm3(u,h),je=(u,h,A)=>j.sm4.encrypt(u,h,A),tr=(u,h,A)=>j.sm4.decrypt(u,h,A),er={sm2:j.sm2,sm3:j.sm3,sm4:j.sm4};var rr={sm2GenerateKeyPair:ze,sm2Encrypt:Ke,sm2Decrypt:We,sm2Sign:$e,sm2Verify:Ze,sm2GetPublicKey:Je,sm2GetPoint:Ge,sm2CompressPublicKey:Ye,sm2ComparePublicKey:Xe,sm2VerifyPublicKey:ke,sm3Hash:Qe,sm4Encrypt:je,sm4Decrypt:tr,__raw__:er};typeof window!="undefined"&&(document.readyState==="complete"||document.readyState==="interactive"?setTimeout(()=>Ct(),0):document.addEventListener("DOMContentLoaded",()=>{Ct()}));const mt={navigateTo:Xt,navigateBack:kt,switchTab:Qt,reLaunch:jt,redirectTo:te,postMessage:re,getEnv:ie,crypto:rr,environment:$t,ready:we,init:Ct,webView:null};$t.isWeixinMiniProgram?mt.webView=window.wx&&window.wx.miniProgram:mt.webView={navigateTo:Xt,navigateBack:kt,switchTab:Qt,reLaunch:jt,redirectTo:te,postMessage:re,getEnv:ie};const se=typeof window.uni!="undefined"?window.uni:{};return Object.keys(se).forEach(u=>{mt.hasOwnProperty(u)||(mt[u]=se[u])}),typeof window!="undefined"&&(window.qsh=mt),mt});
|
|
1
|
+
(function(I,m){typeof exports=="object"&&typeof module!="undefined"?module.exports=m():typeof define=="function"&&define.amd?define(m):(I=typeof globalThis!="undefined"?globalThis:I||self,I.qsh=m())})(this,function(){"use strict";var In=Object.defineProperty,An=Object.defineProperties;var On=Object.getOwnPropertyDescriptors;var Nt=Object.getOwnPropertySymbols;var _n=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable;var ve=(I,m,g)=>m in I?In(I,m,{enumerable:!0,configurable:!0,writable:!0,value:g}):I[m]=g,p=(I,m)=>{for(var g in m||(m={}))_n.call(m,g)&&ve(I,g,m[g]);if(Nt)for(var g of Nt(m))Cn.call(m,g)&&ve(I,g,m[g]);return I},N=(I,m)=>An(I,On(m));var $=(I,m,g)=>ve(I,typeof m!="symbol"?m+"":m,g);var E=(I,m,g)=>new Promise((ee,j)=>{var te=v=>{try{q(g.next(v))}catch(ce){j(ce)}},re=v=>{try{q(g.throw(v))}catch(ce){j(ce)}},q=v=>v.done?ee(v.value):Promise.resolve(v.value).then(te,re);q((g=g.apply(I,m)).next())});function I(){return typeof window!="undefined"?window:void 0}function m(){return typeof navigator=="undefined"?"":navigator.userAgent||""}function g(){const t=I();if(!t)return!1;if(t.__wxjs_environment==="miniprogram"||t.wx&&t.wx.miniProgram)return!0;const e=m();return!!(e&&/micromessenger/i.test(e)&&/miniProgram/i.test(e))}function ee(){const t=I();return!!(t&&t.plus)}function j(){const t=I();return!!(t&&(t.__dcloud_weex_postMessage||t.__dcloud_weex_))}function te(){const t=I();return!!(t&&(t.__uniapp_x_postMessage||t.__uniapp_x_))}function re(){const t=m();return/uni-app/i.test(t)}function q(){const t=m();return/Html5Plus/i.test(t)}function v(){return re()||q()}function ce(){return te()?"uvue":j()?"nvue":g()?"weixin":ee()?"plus":v()?"webview":re()?"UniApp":"h5"}let pe=null;function Oe(t=!1){return pe&&!t||(pe={isWeixinMiniProgram:g(),isAppPlus:ee(),isNvue:j(),isUvue:te(),isUniApp:re(),isHtml5Plus:q(),isUniAppWebView:v(),type:ce()}),pe}const l=Oe(),B={PLATFORM_NOT_SUPPORTED:"PLATFORM_NOT_SUPPORTED",API_CALL_FAILED:"API_CALL_FAILED",BRIDGE_NOT_READY:"BRIDGE_NOT_READY",INVALID_PARAMETERS:"INVALID_PARAMETERS",NETWORK_ERROR:"NETWORK_ERROR"};class M extends Error{constructor(e,r,n={},i=null){super(r),this.name="QshError",this.type=e,this.context=n,this.originalError=i,this.timestamp=new Date().toISOString(),Error.captureStackTrace&&Error.captureStackTrace(this,M)}toJSON(){return{name:this.name,type:this.type,message:this.message,context:this.context,timestamp:this.timestamp,stack:this.stack}}}const C=class C{static setDebugMode(e){C.isDebugMode=e}static addErrorCallback(e){typeof e=="function"&&C.errorCallbacks.push(e)}static removeErrorCallback(e){const r=C.errorCallbacks.indexOf(e);r>-1&&C.errorCallbacks.splice(r,1)}static handleApiError(e,r={}){let n;return e instanceof M?n=e:e instanceof Error?n=new M(B.API_CALL_FAILED,e.message,r,e):n=new M(B.API_CALL_FAILED,String(e),r),C.logError(n),C.notifyCallbacks(n),n}static handlePlatformNotSupported(e,r){const n=new M(B.PLATFORM_NOT_SUPPORTED,`API "${r}" is not supported on platform "${e}"`,{platformType:e,apiName:r});return C.logError(n),C.notifyCallbacks(n),n}static handleBridgeNotReady(e){const r=new M(B.BRIDGE_NOT_READY,`Bridge is not ready when calling "${e}"`,{apiName:e});return C.logError(r),C.notifyCallbacks(r),r}static handleInvalidParameters(e,r,n,i){const a=new M(B.INVALID_PARAMETERS,`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,{apiName:e,paramName:r,expectedType:n,actualValue:i});return C.logError(a),C.notifyCallbacks(a),a}static safeExecute(e,r={}){try{return e()}catch(n){return C.handleApiError(n,r)}}static safeExecuteAsync(n){return E(this,arguments,function*(e,r={}){try{return yield e()}catch(i){return C.handleApiError(i,r)}})}static logError(e){if(typeof console!="undefined"){const r=`[QSH-SDK Error] ${e.type}: ${e.message}`;C.isDebugMode?console.error(r,{context:e.context,originalError:e.originalError,stack:e.stack,timestamp:e.timestamp}):console.error(r)}}static notifyCallbacks(e){C.errorCallbacks.forEach(r=>{try{r(e)}catch(n){typeof console!="undefined"&&console.error("[QSH-SDK] Error in error callback:",n)}})}static createErrorDecorator(e={}){return function(r,n,i){const a=i.value;return i.value=function(...h){return C.safeExecute(()=>a.apply(this,h),N(p({},e),{method:n,target:r.constructor.name}))},i}}};$(C,"isDebugMode",!1),$(C,"errorCallbacks",[]);let c=C;const L={UNINITIALIZED:"uninitialized",INITIALIZING:"initializing",READY:"ready",ERROR:"error"};class Rt{constructor(){this.state=L.UNINITIALIZED,this.readyPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.initializationError=null,this.handleBridgeReady=this.handleBridgeReady.bind(this),this.handleInitializationError=this.handleInitializationError.bind(this)}getState(){return this.state}isReady(){return this.state===L.READY}isInitializing(){return this.state===L.INITIALIZING}hasError(){return this.state===L.ERROR}getInitializationError(){return this.initializationError}waitForReady(){return this.isReady()?Promise.resolve():this.hasError()?Promise.reject(this.initializationError):(this.readyPromise||(this.readyPromise=new Promise((e,r)=>{this.isReady()?e():this.hasError()?r(this.initializationError):(this.readyCallbacks.push(e),this.errorCallbacks.push(r))})),this.readyPromise)}startInitialization(e){return E(this,null,function*(){if(this.state!==L.UNINITIALIZED)return this.waitForReady();this.state=L.INITIALIZING;try{yield e(),this.handleBridgeReady()}catch(r){throw this.handleInitializationError(r),r}return this.waitForReady()})}handleBridgeReady(){this.state===L.INITIALIZING&&(this.state=L.READY,this.readyCallbacks.forEach(e=>{try{e()}catch(r){c.handleApiError(r,{context:"StateManager.handleBridgeReady"})}}),this.readyCallbacks=[],this.errorCallbacks=[])}handleInitializationError(e){this.state=L.ERROR,this.initializationError=e,this.errorCallbacks.forEach(r=>{try{r(e)}catch(n){c.handleApiError(n,{context:"StateManager.handleInitializationError"})}}),this.readyCallbacks=[],this.errorCallbacks=[]}reset(){this.state=L.UNINITIALIZED,this.readyPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.initializationError=null}onStateChange(e,r){if(this.state===e)return setTimeout(()=>r(this.state),0),()=>{};const n=()=>{this.state===e&&r(this.state)};return e===L.READY?this.readyCallbacks.push(n):e===L.ERROR&&this.errorCallbacks.push(n),()=>{const i=this.readyCallbacks.indexOf(n);i>-1&&this.readyCallbacks.splice(i,1);const a=this.errorCallbacks.indexOf(n);a>-1&&this.errorCallbacks.splice(a,1)}}getStats(){return{state:this.state,readyCallbacksCount:this.readyCallbacks.length,errorCallbacksCount:this.errorCallbacks.length,hasReadyPromise:!!this.readyPromise,hasInitializationError:!!this.initializationError}}}const J=new Rt,xe=()=>J.waitForReady(),St=()=>J.isReady(),Tt=()=>J.getState(),w={ERROR:0,WARN:1,INFO:2,DEBUG:3,TRACE:4},ue={[w.ERROR]:"ERROR",[w.WARN]:"WARN",[w.INFO]:"INFO",[w.DEBUG]:"DEBUG",[w.TRACE]:"TRACE"},u=class u{static setLevel(e){e>=w.ERROR&&e<=w.TRACE&&(u.currentLevel=e,u.log(w.INFO,"Logger",`日志级别设置为: ${ue[e]}`))}static enableDevMode(){u.setLevel(w.DEBUG),u.log(w.INFO,"Logger","开发模式已启用")}static enableProdMode(){u.setLevel(w.WARN),u.log(w.INFO,"Logger","生产模式已启用")}static enableModule(e){u.enabledModules.add(e),u.log(w.INFO,"Logger",`模块日志已启用: ${e}`)}static disableModule(e){u.enabledModules.delete(e),u.log(w.INFO,"Logger",`模块日志已禁用: ${e}`)}static shouldLog(e,r){return e>u.currentLevel?!1:r&&u.enabledModules.size>0?u.enabledModules.has(r):!0}static log(e,r,n,...i){if(!u.shouldLog(e,r))return;const a=new Date().toISOString(),h=ue[e],f=r?`[${r}]`:"",d=`${u.prefix} ${f} ${n}`,O={timestamp:a,level:e,levelName:h,module:r,message:n,args:i};if(u.addToHistory(O),typeof u.reporter=="function")try{u.reporter(O)}catch(b){}u.outputToConsole(e,d,...i)}static addToHistory(e){u.logHistory.push(e),u.logHistory.length>u.maxHistorySize&&u.logHistory.shift()}static outputToConsole(e,r,...n){if(typeof console=="undefined")return;const i=n&&n.length>0;switch(e){case w.ERROR:i?console.error(r,...n):console.error(r);break;case w.WARN:i?console.warn(r,...n):console.warn(r);break;case w.INFO:i?console.info(r,...n):console.info(r);break;case w.DEBUG:case w.TRACE:i?console.log(r,...n):console.log(r);break}}static error(e,r,...n){u.log(w.ERROR,e,r,...n)}static warn(e,r,...n){u.log(w.WARN,e,r,...n)}static info(e,r,...n){u.log(w.INFO,e,r,...n)}static debug(e,r,...n){u.log(w.DEBUG,e,r,...n)}static trace(e,r,...n){u.log(w.TRACE,e,r,...n)}static getHistory(e){return e&&e>0?u.logHistory.slice(-e):[...u.logHistory]}static clearHistory(){u.logHistory=[],u.log(w.INFO,"Logger","日志历史已清空")}static getStats(){const e={currentLevel:u.currentLevel,currentLevelName:ue[u.currentLevel],enabledModules:Array.from(u.enabledModules),historySize:u.logHistory.length,maxHistorySize:u.maxHistorySize},r={};for(const n of Object.keys(ue))r[ue[n]]=0;return u.logHistory.forEach(n=>{r[n.levelName]++}),e.levelCounts=r,e}static exportToJSON(e){const r=u.getHistory(e),n=u.getStats();return JSON.stringify({exportTime:new Date().toISOString(),stats:n,logs:r},null,2)}static createModuleLogger(e){return{error:(r,...n)=>u.error(e,r,...n),warn:(r,...n)=>u.warn(e,r,...n),info:(r,...n)=>u.info(e,r,...n),debug:(r,...n)=>u.debug(e,r,...n),trace:(r,...n)=>u.trace(e,r,...n)}}static setReporter(e){u.reporter=typeof e=="function"?e:null}};$(u,"currentLevel",w.ERROR),$(u,"enabledModules",new Set),$(u,"logHistory",[]),$(u,"maxHistorySize",1e3),$(u,"prefix","[QSH-SDK]"),$(u,"reporter",null);let S=u;if(typeof window!="undefined"){const t=window.location&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname.includes("192.168.")),e=window.location&&(window.location.search.includes("debug=true")||window.location.search.includes("qsh_debug=1"));let r=!1;try{r=localStorage&&localStorage.getItem("qsh_debug")==="true"}catch(n){}(t||e||r)&&S.enableDevMode()}const y=S.createModuleLogger("Bridge"),_=S.createModuleLogger("Platform"),s=S.createModuleLogger("API"),x=S.createModuleLogger("State"),De=/complete|loaded|interactive/;function Pt(t){return re()||q()?(y.debug("检测到 APP 环境,开始初始化"),window.__uniapp_x_postMessage||window.__uniapp_x_||window.__dcloud_weex_postMessage||window.__dcloud_weex_?(y.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"),document.addEventListener("DOMContentLoaded",t)):window.plus&&De.test(document.readyState)?(y.debug("Plus 环境已就绪,立即初始化"),setTimeout(t,0)):(y.debug("Plus 环境,等待 plusready 事件"),document.addEventListener("plusready",t)),!0):!1}function Lt(t){return window.wx&&window.wx.miniProgram?(y.debug("检测到微信小程序环境,开始初始化"),window.WeixinJSBridge&&window.WeixinJSBridge.invoke?(y.debug("微信 JSBridge 已就绪,立即初始化"),setTimeout(t,0)):(y.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"),document.addEventListener("WeixinJSBridgeReady",t)),!0):!1}function Mt(t){return y.info("开始初始化 JSBridge"),Pt(t)?(y.info("使用 APP 环境初始化"),!0):Lt(t)?(y.info("使用微信小程序环境初始化"),!0):(y.debug("使用默认 H5 环境初始化"),De.test(document.readyState)?(y.debug("DOM 已就绪,立即初始化"),setTimeout(t,0)):(y.debug("DOM 未就绪,等待 DOMContentLoaded"),document.addEventListener("DOMContentLoaded",t)),!0)}function bt(){return J.waitForReady()}function Ue(){return J.startInitialization(()=>E(null,null,function*(){return new Promise((t,e)=>{const r=()=>{t()},n=i=>{const a=c.handleApiError(i,{context:"bridge initialization"});e(a)};try{Mt(()=>{r()})}catch(i){n(i)}})}))}const T={UNINITIALIZED:"uninitialized",CONFIGURING:"configuring",CONFIGURED:"configured",ERROR:"error"};class vt{constructor(){this.state=T.UNINITIALIZED,this.configPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.lastError=null,this.CONFIG_API_URL=this.getConfigApiUrl(),this.CLIENT_ID="bmfw-client",this.DEFAULT_JS_API_LIST=["chooseImage","uploadImage","previewImage","downloadImage","getLocalImgData","scanQRCode","getLocation","openLocation","updateAppMessageShareData","updateTimelineShareData"],this.handleConfigSuccess=this.handleConfigSuccess.bind(this),this.handleConfigError=this.handleConfigError.bind(this)}getConfigApiUrl(){return typeof window!="undefined"&&(window.location.hostname==="localhost"||window.location.hostname.includes("127.0.0.1")||window.location.hostname.includes("natappfree.cc")||window.location.port==="5174"),"https://unified-platform-service.xjy2.cn/api/wechat/mp/jssdk-sign"}getCurrentPageUrl(){if(typeof window=="undefined"||!window.location)throw new Error("无法获取当前页面URL");const e=window.location.href,r=e.indexOf("#");return r!==-1?e.substring(0,r):e}fetchWeixinConfig(){return E(this,null,function*(){const e=this.getCurrentPageUrl();if(this.isTestMode())return _.info("使用测试模式,返回模拟配置"),this.getMockConfig();const r=`${this.CONFIG_API_URL}?clientId=${this.CLIENT_ID}&url=${encodeURIComponent(e)}`;_.debug("请求微信配置",{url:r});try{const n=yield fetch(r);if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);const i=yield n.json();if(_.debug("微信配置响应",i),!i.success||i.code!==200)throw new Error(`配置获取失败: ${i.message||"未知错误"}`);const{data:a}=i;if(!a||!a.appId||!a.timestamp||!a.nonceStr||!a.signature)throw new Error("配置数据格式不正确,缺少必需字段");return a}catch(n){if(_.error("获取微信配置失败",n),this.shouldUseTestMode(n))return _.warn("网络请求失败,降级到测试模式"),this.getMockConfig();throw new M(B.NETWORK_ERROR,`获取微信配置失败: ${n.message}`,{url:r,originalError:n})}})}isTestMode(){if(typeof window=="undefined")return!1;if(new URLSearchParams(window.location.search).get("qsh_test")==="true")return!0;try{if(localStorage.getItem("qsh_test")==="true")return!0}catch(r){}return!1}shouldUseTestMode(e){const r=window.location.hostname==="localhost"||window.location.hostname.includes("natappfree.cc"),n=!window.wx||!window.wx.miniProgram,i=e.message.includes("CORS")||e.message.includes("Failed to fetch");return r&&n&&i}getMockConfig(){return{appId:"wx_test_app_id",timestamp:Math.floor(Date.now()/1e3).toString(),nonceStr:Math.random().toString(36).substring(2,15),signature:"test_signature_"+Math.random().toString(36).substring(2,10)}}executeWeixinConfig(e){if(this.isTestMode()||e.appId==="wx_test_app_id"){_.info("测试模式:模拟微信配置成功"),setTimeout(()=>{this.handleConfigSuccess()},100);return}if(!window.wx)throw new Error("微信JS-SDK未加载");const r={debug:!1,appId:e.appId,timestamp:parseInt(e.timestamp),nonceStr:e.nonceStr,signature:e.signature,jsApiList:this.DEFAULT_JS_API_LIST};_.info("执行微信配置",r),window.wx.ready(this.handleConfigSuccess),window.wx.error(this.handleConfigError),window.wx.config(r)}handleConfigSuccess(){_.info("微信配置成功"),this.state=T.CONFIGURED,this.readyCallbacks.forEach(e=>{try{e()}catch(r){c.handleApiError(r,{context:"WeixinConfigManager.handleConfigSuccess"})}}),this.readyCallbacks=[],this.errorCallbacks=[]}handleConfigError(e){const r=`微信配置验证失败: ${JSON.stringify(e)}`;_.error(r,e),this.state=T.ERROR,this.lastError=new M(B.API_CALL_FAILED,r,{weixinErrorResponse:e}),this.errorCallbacks.forEach(n=>{try{n(this.lastError)}catch(i){c.handleApiError(i,{context:"WeixinConfigManager.handleConfigError"})}}),this.readyCallbacks=[],this.errorCallbacks=[]}autoConfig(){return E(this,null,function*(){return this.state===T.CONFIGURED?Promise.resolve():this.state===T.ERROR?Promise.reject(this.lastError):this.configPromise?this.configPromise:(this.state=T.CONFIGURING,this.configPromise=this.performAutoConfig(),this.configPromise)})}performAutoConfig(){return E(this,null,function*(){return c.safeExecuteAsync(()=>E(this,null,function*(){if(typeof window=="undefined")throw new Error("非浏览器环境无法执行微信配置");if(!window.wx)throw new Error("微信JS-SDK未加载,无法执行配置");const e=yield this.fetchWeixinConfig();return this.executeWeixinConfig(e),new Promise((r,n)=>{if(this.state===T.CONFIGURED){r();return}if(this.state===T.ERROR){n(this.lastError);return}this.readyCallbacks.push(r),this.errorCallbacks.push(n)})}),{context:"WeixinConfigManager.performAutoConfig"})})}waitForReady(){return this.state===T.CONFIGURED?Promise.resolve():this.state===T.ERROR?Promise.reject(this.lastError):this.state===T.UNINITIALIZED?this.autoConfig():new Promise((e,r)=>{this.readyCallbacks.push(e),this.errorCallbacks.push(r)})}isReady(){return this.state===T.CONFIGURED}getState(){return this.state}getLastError(){return this.lastError}reset(){this.state=T.UNINITIALIZED,this.configPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.lastError=null,_.debug("微信配置管理器已重置")}getStats(){return{state:this.state,readyCallbacksCount:this.readyCallbacks.length,errorCallbacksCount:this.errorCallbacks.length,hasConfigPromise:!!this.configPromise,hasLastError:!!this.lastError,configApiUrl:this.CONFIG_API_URL,clientId:this.CLIENT_ID,jsApiList:this.DEFAULT_JS_API_LIST}}}const k=new vt;let ne=!1,_e=!1,me=!1;function xt(){if(typeof window=="undefined"||_e||ne||window.wx&&window.wx.miniProgram)return!1;const t=navigator.userAgent||"",e=/micromessenger/i.test(t),r=/miniProgram/i.test(t),n=typeof window.__wxjs_environment!="undefined"&&window.__wxjs_environment==="miniprogram";return e&&(r||n)}function Ce(){return E(this,null,function*(){if(me)return k.waitForReady();me=!0,_.info("开始自动配置微信JS-SDK");try{yield k.autoConfig(),_.info("微信JS-SDK自动配置完成")}catch(t){_.error("微信JS-SDK自动配置失败",t)}})}function Dt(){return xt()?document.getElementById("weixin-jssdk")?(ne=!1,_e=!0,me?k.waitForReady():Ce()):new Promise(t=>{ne=!0;try{const e=document.createElement("script");e.id="weixin-jssdk",e.type="text/javascript",e.async=!0,e.src="https://res.wx.qq.com/open/js/jweixin-1.6.2.js",e.onload=function(){return E(this,null,function*(){_e=!0,ne=!1,_.info("微信 JS-SDK 已自动加载");try{yield Ce()}catch(n){_.error("微信配置失败,将使用消息桥作为后备",n)}t()})},e.onerror=function(){ne=!1,_.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"),t()},(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(e)}catch(e){ne=!1,_.error("注入微信 JS-SDK 失败",e),t()}}):Promise.resolve()}function F(){return k.waitForReady()}function z(){return k.isReady()}function Ut(){return k.getState()}function We(){return k}function Wt(){return E(this,null,function*(){return _.info("手动重试微信配置"),k.reset(),me=!1,Ce()})}class $t{constructor(){this.plugins=new Map,this.installed=new Set,this.installOrder=[],s.debug("插件管理器已初始化")}register(e){return c.safeExecute(()=>{this.validatePlugin(e);const{name:r,version:n}=e;if(this.plugins.has(r)){const i=this.plugins.get(r);s.warn(`插件 ${r} 已注册(版本 ${i.version}),将被覆盖为版本 ${n}`)}return this.plugins.set(r,e),s.info(`插件已注册: ${r}@${n}`),this},{context:"PluginManager.register",pluginName:e==null?void 0:e.name})}validatePlugin(e){if(!e||typeof e!="object")throw new Error("插件必须是一个对象");if(!e.name||typeof e.name!="string")throw new Error("插件必须有 name 属性(字符串)");if(!e.version||typeof e.version!="string")throw new Error(`插件 ${e.name} 必须有 version 属性(字符串)`);if(!e.install||typeof e.install!="function")throw new Error(`插件 ${e.name} 必须实现 install 方法`);if(e.dependencies&&!Array.isArray(e.dependencies))throw new Error(`插件 ${e.name} 的 dependencies 必须是数组`)}install(e,r){return E(this,null,function*(){return c.safeExecute(()=>E(this,null,function*(){if(!this.plugins.has(e))throw new Error(`插件 ${e} 未注册`);if(this.installed.has(e)){s.debug(`插件 ${e} 已安装,跳过`);return}const n=this.plugins.get(e);if(n.dependencies&&n.dependencies.length>0){s.debug(`安装插件 ${e} 的依赖:`,n.dependencies);for(const i of n.dependencies)yield this.install(i,r)}s.info(`开始安装插件: ${e}@${n.version}`),yield n.install(r),this.installed.add(e),this.installOrder.push(e),s.info(`插件安装成功: ${e}@${n.version}`)}),{context:"PluginManager.install",pluginName:e})})}uninstall(e,r){return E(this,null,function*(){return c.safeExecute(()=>E(this,null,function*(){if(!this.installed.has(e)){s.debug(`插件 ${e} 未安装,跳过卸载`);return}const n=this.plugins.get(e);n.uninstall&&typeof n.uninstall=="function"&&(s.info(`开始卸载插件: ${e}`),yield n.uninstall(r)),this.installed.delete(e);const i=this.installOrder.indexOf(e);i>-1&&this.installOrder.splice(i,1),s.info(`插件已卸载: ${e}`)}),{context:"PluginManager.uninstall",pluginName:e})})}uninstallAll(e){return E(this,null,function*(){const r=[...this.installOrder].reverse();for(const n of r)yield this.uninstall(n,e)})}registerAll(e){if(!Array.isArray(e))throw new Error("plugins 必须是数组");return e.forEach(r=>this.register(r)),this}installAll(e,r){return E(this,null,function*(){if(!Array.isArray(e))throw new Error("names 必须是数组");for(const n of e)yield this.install(n,r)})}isRegistered(e){return this.plugins.has(e)}isInstalled(e){return this.installed.has(e)}getPlugin(e){return this.plugins.get(e)}getPluginList(){return Array.from(this.plugins.entries()).map(([e,r])=>({name:e,version:r.version,installed:this.installed.has(e),dependencies:r.dependencies||[]}))}getStats(){return{registered:this.plugins.size,installed:this.installed.size,plugins:this.getPluginList()}}clear(){this.plugins.clear(),this.installed.clear(),this.installOrder=[]}}const le=new $t;class Bt{constructor(){this.requestInterceptors=[],this.responseInterceptors=[],s.debug("拦截器链已初始化")}useRequest(e,r={}){if(typeof e!="function")throw new Error("拦截器必须是函数");const{priority:n=0}=r;return this.requestInterceptors.push({fn:e,priority:n}),this.requestInterceptors.sort((i,a)=>a.priority-i.priority),s.debug("请求拦截器已注册",{priority:n}),()=>{const i=this.requestInterceptors.findIndex(a=>a.fn===e);i>-1&&(this.requestInterceptors.splice(i,1),s.debug("请求拦截器已移除"))}}useResponse(e,r={}){if(typeof e!="function")throw new Error("拦截器必须是函数");const{priority:n=0}=r;return this.responseInterceptors.push({fn:e,priority:n}),this.responseInterceptors.sort((i,a)=>a.priority-i.priority),s.debug("响应拦截器已注册",{priority:n}),()=>{const i=this.responseInterceptors.findIndex(a=>a.fn===e);i>-1&&(this.responseInterceptors.splice(i,1),s.debug("响应拦截器已移除"))}}runRequest(e){return E(this,null,function*(){let r=p({},e);for(const{fn:n}of this.requestInterceptors){if(r.abort){s.debug("请求被中止",{apiName:r.apiName});break}try{const i=yield n(r);i&&(r=i)}catch(i){s.error("请求拦截器执行失败",i),r.abort=!0,r.error=i;break}}return r})}runResponse(e,r){return E(this,null,function*(){let n=e;for(const{fn:i}of this.responseInterceptors)try{const a=yield i(n,r);a!==void 0&&(n=a)}catch(a){s.error("响应拦截器执行失败",a)}return n})}clear(){this.requestInterceptors=[],this.responseInterceptors=[],s.debug("所有拦截器已清空")}getStats(){return{requestInterceptors:this.requestInterceptors.length,responseInterceptors:this.responseInterceptors.length}}}const H=new Bt,kt={request:t=>(t.startTime=Date.now(),s.debug(`[API 调用] ${t.apiName}`,{params:t.params}),t),response:(t,e)=>{const r=Date.now()-e.startTime;return s.debug(`[API 完成] ${e.apiName}`,{duration:`${r}ms`,success:t==null?void 0:t.success}),t}},K={metrics:new Map,request:t=>(t.perfStartTime=performance.now(),t),response:(t,e)=>{const r=performance.now()-e.perfStartTime;K.metrics.has(e.apiName)||K.metrics.set(e.apiName,{count:0,totalTime:0,minTime:1/0,maxTime:0,avgTime:0});const n=K.metrics.get(e.apiName);return n.count++,n.totalTime+=r,n.minTime=Math.min(n.minTime,r),n.maxTime=Math.max(n.maxTime,r),n.avgTime=n.totalTime/n.count,t},getReport:()=>{const t={};return K.metrics.forEach((e,r)=>{t[r]=p({},e)}),t},clearMetrics:()=>{K.metrics.clear()}};function Ft(t={}){const{maxRetries:e=3,retryDelay:r=1e3,shouldRetry:n=i=>!i.success}=t;return{response:(i,a)=>E(null,null,function*(){return a.retryCount||(a.retryCount=0),n(i)&&a.retryCount<e&&(a.retryCount++,s.warn(`API 调用失败,第 ${a.retryCount} 次重试: ${a.apiName}`),yield new Promise(h=>setTimeout(h,r)),i.shouldRetry=!0,i.retryContext=a),i})}}function zt(t={}){return{request:e=>{const r=t[e.apiName];if(r&&typeof r=="function"){const n=r(e.params);n&&(s.error(`参数验证失败: ${e.apiName}`,n),e.abort=!0,e.validationError=n)}return e}}}class Kt{constructor(){this.state={sdk:{status:"uninitialized",version:"2.0.5",error:null},platform:{type:l.type,isWeixinMiniProgram:l.isWeixinMiniProgram,isAppPlus:l.isAppPlus,isNvue:l.isNvue,isUvue:l.isUvue,features:{}},weixin:{configStatus:"pending",jsApiList:[],configError:null},network:{online:typeof navigator!="undefined"?navigator.onLine:!0,type:"unknown"},permissions:{camera:"prompt",location:"prompt",album:"prompt"},api:{}},this.listeners=new Map,this.wildcardListeners=new Set,this.initNetworkListener(),x.debug("状态仓库已初始化")}get(e){return e.split(".").reduce((n,i)=>n!=null?n[i]:void 0,this.state)}set(e,r){const n=e.split("."),i=n.pop(),a=n.reduce((f,d)=>((!f[d]||typeof f[d]!="object")&&(f[d]={}),f[d]),this.state),h=a[i];h!==r&&(a[i]=r,x.debug(`状态已更新: ${e}`,{oldValue:h,newValue:r}),this.notify(e,r,h))}batchUpdate(e){Object.entries(e).forEach(([r,n])=>{this.set(r,n)})}subscribe(e,r){if(typeof r!="function")throw new Error("listener 必须是函数");return e==="*"?(this.wildcardListeners.add(r),x.debug("添加通配符订阅者"),()=>{this.wildcardListeners.delete(r),x.debug("移除通配符订阅者")}):(this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(r),x.debug(`添加订阅者: ${e}`),()=>{const n=this.listeners.get(e);n&&(n.delete(r),n.size===0&&this.listeners.delete(e),x.debug(`移除订阅者: ${e}`))})}subscribeOnce(e,r){const n=this.subscribe(e,(i,a,h)=>{r(i,a,h),n()});return n}notify(e,r,n){const i=this.listeners.get(e);i&&i.forEach(h=>{try{h(r,n,e)}catch(f){x.error("订阅者执行失败",f)}});const a=e.split(".");for(let h=1;h<a.length;h++){const f=a.slice(0,h).join("."),d=this.listeners.get(f);if(d){const O=this.get(f);d.forEach(b=>{try{b(O,void 0,f)}catch(P){x.error("父路径订阅者执行失败",P)}})}}this.wildcardListeners.forEach(h=>{try{h(r,n,e)}catch(f){x.error("通配符订阅者执行失败",f)}})}initNetworkListener(){if(typeof window!="undefined"&&(window.addEventListener("online",()=>{this.set("network.online",!0)}),window.addEventListener("offline",()=>{this.set("network.online",!1)}),navigator.connection)){const e=navigator.connection,r=()=>{this.set("network.type",e.effectiveType||"unknown")};e.addEventListener("change",r),r()}}setApiLoading(e,r=!0){const n=`api.${e}`,i=this.get(n)||{};this.set(n,N(p({},i),{loading:r,lastCall:r?Date.now():i.lastCall}))}setApiResult(e,r){const n=`api.${e}`,i=this.get(n)||{};this.set(n,N(p({},i),{loading:!1,lastResult:r,lastCallEnd:Date.now()}))}getSnapshot(){return JSON.parse(JSON.stringify(this.state))}reset(){const{platform:e}=this.state;this.state={sdk:{status:"uninitialized",version:"2.0.5",error:null},platform:e,weixin:{configStatus:"pending",jsApiList:[],configError:null},network:{online:typeof navigator!="undefined"?navigator.onLine:!0,type:"unknown"},permissions:{camera:"prompt",location:"prompt",album:"prompt"},api:{}},x.debug("状态已重置")}getStats(){return{listeners:this.listeners.size,wildcardListeners:this.wildcardListeners.size,apiStates:Object.keys(this.state.api).length}}}const U=new Kt,o={SDK_NOT_READY:"E_SDK_001",SDK_INIT_FAILED:"E_SDK_002",SDK_CONFIG_FAILED:"E_SDK_003",PLATFORM_NOT_SUPPORTED:"E_SDK_004",NETWORK_ERROR:"E_NET_001",NETWORK_TIMEOUT:"E_NET_002",NETWORK_OFFLINE:"E_NET_003",IMAGE_CANCELLED:"E_IMG_001",IMAGE_NO_PERMISSION:"E_IMG_002",IMAGE_SIZE_EXCEED:"E_IMG_003",IMAGE_COUNT_EXCEED:"E_IMG_004",IMAGE_FORMAT_ERROR:"E_IMG_005",IMAGE_CONFIG_NOT_READY:"E_IMG_006",LOCATION_CANCELLED:"E_LOC_001",LOCATION_NO_PERMISSION:"E_LOC_002",LOCATION_UNAVAILABLE:"E_LOC_003",LOCATION_TIMEOUT:"E_LOC_004",SCAN_CANCELLED:"E_SCAN_001",SCAN_NO_PERMISSION:"E_SCAN_002",SCAN_INVALID_CODE:"E_SCAN_003",SCAN_CONFIG_NOT_READY:"E_SCAN_004",PERMISSION_DENIED:"E_PERM_001",PERMISSION_CAMERA:"E_PERM_002",PERMISSION_LOCATION:"E_PERM_003",PERMISSION_ALBUM:"E_PERM_004",PERMISSION_MICROPHONE:"E_PERM_005",PARAM_INVALID:"E_PARAM_001",PARAM_MISSING:"E_PARAM_002",PARAM_TYPE_ERROR:"E_PARAM_003",API_TIMEOUT:"E_TIMEOUT_001",UNKNOWN_ERROR:"E_UNKNOWN_999"},Ne={[o.SDK_NOT_READY]:"SDK 未就绪",[o.SDK_INIT_FAILED]:"SDK 初始化失败",[o.SDK_CONFIG_FAILED]:"SDK 配置失败",[o.PLATFORM_NOT_SUPPORTED]:"当前平台不支持此功能",[o.NETWORK_ERROR]:"网络错误",[o.NETWORK_TIMEOUT]:"网络超时",[o.NETWORK_OFFLINE]:"网络已断开",[o.IMAGE_CANCELLED]:"用户取消选择图片",[o.IMAGE_NO_PERMISSION]:"无相机/相册权限",[o.IMAGE_SIZE_EXCEED]:"图片大小超出限制",[o.IMAGE_COUNT_EXCEED]:"图片数量超出限制",[o.IMAGE_FORMAT_ERROR]:"图片格式不支持",[o.IMAGE_CONFIG_NOT_READY]:"微信配置未完成",[o.LOCATION_CANCELLED]:"用户取消定位",[o.LOCATION_NO_PERMISSION]:"无定位权限",[o.LOCATION_UNAVAILABLE]:"定位服务不可用",[o.LOCATION_TIMEOUT]:"定位超时",[o.SCAN_CANCELLED]:"用户取消扫码",[o.SCAN_NO_PERMISSION]:"无相机权限",[o.SCAN_INVALID_CODE]:"无效的二维码/条形码",[o.SCAN_CONFIG_NOT_READY]:"微信配置未完成",[o.PERMISSION_DENIED]:"权限被拒绝",[o.PERMISSION_CAMERA]:"无相机权限",[o.PERMISSION_LOCATION]:"无定位权限",[o.PERMISSION_ALBUM]:"无相册权限",[o.PERMISSION_MICROPHONE]:"无麦克风权限",[o.PARAM_INVALID]:"参数无效",[o.PARAM_MISSING]:"缺少必需参数",[o.PARAM_TYPE_ERROR]:"参数类型错误",[o.API_TIMEOUT]:"API 调用超时",[o.UNKNOWN_ERROR]:"未知错误"},D={USER_CANCEL:"user_cancel",PERMISSION:"permission",NETWORK:"network",PARAM:"param",SYSTEM:"system",CONFIG:"config",UNKNOWN:"unknown"},Gt={"IMAGE/USER_CANCEL":o.IMAGE_CANCELLED,"IMAGE/PERMISSION_DENIED":o.IMAGE_NO_PERMISSION,"COMMON/UNKNOWN":o.UNKNOWN_ERROR,"COMMON/CONFIG_NOT_READY":o.IMAGE_CONFIG_NOT_READY,"COMMON/PLATFORM_NOT_SUPPORTED":o.PLATFORM_NOT_SUPPORTED},$e={weixin:{patterns:[{pattern:/cancel/i,code:o.IMAGE_CANCELLED},{pattern:/permission|auth\s*deny/i,code:o.IMAGE_NO_PERMISSION},{pattern:/config/i,code:o.IMAGE_CONFIG_NOT_READY},{pattern:/timeout/i,code:o.API_TIMEOUT},{pattern:/network/i,code:o.NETWORK_ERROR}],default:o.UNKNOWN_ERROR},uniapp:{patterns:[{pattern:/cancel/i,code:o.IMAGE_CANCELLED},{pattern:/permission|denied/i,code:o.IMAGE_NO_PERMISSION},{pattern:/timeout/i,code:o.API_TIMEOUT},{pattern:/network/i,code:o.NETWORK_ERROR},{pattern:/not_in_container/i,code:o.PLATFORM_NOT_SUPPORTED}],default:o.UNKNOWN_ERROR}},Be={chooseImage:{"fail cancel":o.IMAGE_CANCELLED,"fail auth deny":o.IMAGE_NO_PERMISSION,"fail No Permission":o.IMAGE_NO_PERMISSION,NOT_IN_CONTAINER:o.PLATFORM_NOT_SUPPORTED},scanCode:{"fail cancel":o.SCAN_CANCELLED,"fail auth deny":o.SCAN_NO_PERMISSION,"fail No Permission":o.SCAN_NO_PERMISSION,NOT_IN_CONTAINER:o.PLATFORM_NOT_SUPPORTED}};function ke(t){return t?t.includes("CANCEL")?D.USER_CANCEL:t.includes("PERM")||t.includes("PERMISSION")?D.PERMISSION:t.includes("NET")||t.includes("NETWORK")?D.NETWORK:t.includes("PARAM")?D.PARAM:t.includes("CONFIG")?D.CONFIG:t.includes("SDK")||t.includes("PLATFORM")?D.SYSTEM:D.UNKNOWN:D.UNKNOWN}function Vt(t){return t.includes("NET_")||t.includes("TIMEOUT")||t===o.NETWORK_ERROR||t===o.NETWORK_TIMEOUT||t===o.API_TIMEOUT}function jt(t){return t.includes("CANCEL")||ke(t)===D.USER_CANCEL}function ie(t){return Ne[t]||Ne[o.UNKNOWN_ERROR]}class W extends Error{constructor(e,r,n={}){super(r),this.name="StandardError",this.code=e,this.message=r||ie(e),this.platform=n.platform||l.type,this.apiName=n.apiName,this.category=n.category||ke(e),this.retriable=n.retriable!==void 0?n.retriable:Vt(e),this.originalError=n.originalError,this.details=n.details||{},this.timestamp=Date.now()}isRetriable(){return this.retriable}isUserAction(){return jt(this.code)}toJSON(){return p({code:this.code,message:this.message,platform:this.platform,apiName:this.apiName,category:this.category,retriable:this.retriable,timestamp:this.timestamp,details:this.details},process.env.NODE_ENV!=="production"&&this.originalError?{originalError:this.originalError}:{})}}function Fe(t,e={}){if(t instanceof W)return t;const{apiName:r,platform:n=l.type}=e;return t&&typeof t.code=="string"&&t.code.includes("/")?qt(t,{apiName:r,platform:n}):t&&(t.errMsg||t.message)?Jt(t,{apiName:r,platform:n}):typeof t=="string"?new W(o.UNKNOWN_ERROR,t,{apiName:r,platform:n,originalError:t}):new W(o.UNKNOWN_ERROR,"未知错误",{apiName:r,platform:n,originalError:t,details:{errorType:typeof t}})}function qt(t,e){const{apiName:r,platform:n}=e,i=t.code,a=Gt[i]||o.UNKNOWN_ERROR;return s.debug("转换旧版错误码",{legacy:i,new:a}),new W(a,t.message||ie(a),{apiName:r,platform:t.platform||n,originalError:t,details:p({legacyCode:i,legacyVersion:t.version},t.details)})}function Jt(t,e){const{apiName:r,platform:n}=e,i=(t.errMsg||t.message||"").toLowerCase();if(r&&Be[r]){const f=Be[r];for(const[d,O]of Object.entries(f))if(i.includes(d.toLowerCase()))return new W(O,ie(O),{apiName:r,platform:n,originalError:t})}const a=$e[n]||$e.uniapp;for(const{pattern:f,code:d}of a.patterns)if(f.test(i))return new W(d,ie(d),{apiName:r,platform:n,originalError:t});const h=a.default||o.UNKNOWN_ERROR;return new W(h,t.errMsg||t.message||ie(h),{apiName:r,platform:n,originalError:t})}const ze={response:(t,e)=>{if(!t.success&&t.error){const r=Fe(t.error,{apiName:e.apiName,platform:l.type});t.error=r.toJSON(),t.errorCode=r.code,t.errorCategory=r.category,t.retriable=r.isRetriable(),s.debug("错误已标准化",{api:e.apiName,code:r.code,category:r.category})}return t}};function Ht(t,e={}){return new W(t,ie(t),e)}function Yt(t){return t instanceof W}function Xt(t,e,r){return e?Promise.race([t(),new Promise((n,i)=>setTimeout(()=>i(new Error(`Init task timeout: ${r}`)),e))]):t()}function Zt(){return E(this,arguments,function*(t=[],e={}){for(const r of t){const n=(r==null?void 0:r.name)||"anonymous-task",i=(r==null?void 0:r.run)||r;if(typeof i=="function")try{yield Xt(()=>Promise.resolve().then(()=>i()),r.timeoutMs,n),typeof r.onSuccess=="function"&&r.onSuccess()}catch(a){if(typeof r.onError=="function"&&r.onError(a),typeof e.onError=="function")e.onError(a,r);else throw a}}})}class Ke{constructor(e){this.name=e}processNavigationOptions(e={}){const{url:r,delta:n=1}=e,i=r&&encodeURI(r),a=parseInt(n)||1;return N(p({},e),{url:i,delta:a})}processMessageOptions(e={}){const{data:r={}}=e;return{data:r}}navigateTo(e){const r=this.processNavigationOptions(e);return this.performNavigation("navigateTo",r)}navigateBack(e={}){const r=this.processNavigationOptions(e);return this.performNavigation("navigateBack",r)}switchTab(e){const r=this.processNavigationOptions(e);return this.performNavigation("switchTab",r)}reLaunch(e){const r=this.processNavigationOptions(e);return this.performNavigation("reLaunch",r)}redirectTo(e){const r=this.processNavigationOptions(e);return this.performNavigation("redirectTo",r)}postMessage(e={}){const r=this.processMessageOptions(e);return this.performPostMessage(r)}getEnv(e){return this.performGetEnv(e)}performNavigation(e,r){throw new Error(`${this.name} platform must implement performNavigation method`)}performPostMessage(e){throw new Error(`${this.name} platform must implement performPostMessage method`)}performGetEnv(e){throw new Error(`${this.name} platform must implement performGetEnv method`)}}let fe=[];function Qt(){if(fe.length===0&&window.plus){const t=plus.webview.currentWebview();if(!t)throw new Error("plus.webview.currentWebview() is undefined");const e=t.parent(),r=e?e.id:t.id;fe.push(r)}return fe}function er(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};if(t==="postMessage"){const i={data:e};return window.__uniapp_x_postMessage?window.__uniapp_x_postMessage(i):window.__uniapp_x_.postMessage(JSON.stringify(i))}const n={type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:fe}};window.__uniapp_x_postMessage?window.__uniapp_x_postMessageToService(n):window.__uniapp_x_.postMessageToService(JSON.stringify(n))}function tr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};if(t==="postMessage"){const i={data:[e]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(i):window.__dcloud_weex_.postMessage(JSON.stringify(i))}const n={type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:fe}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(n):window.__dcloud_weex_.postMessageToService(JSON.stringify(n))}function rr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e},n=Qt();if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:n}},"__uniapp__service");else{const i=JSON.stringify(r),a=JSON.stringify(n);plus.webview.getLaunchWebview().evalJS(`UniPlusBridge.subscribeHandler("WEB_INVOKE_APPSERVICE",${i},${a});`)}}function nr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:r,pageId:""},"*")}function de(t,e){te()?er(t,e):j()?tr(t,e):ee()?rr(t,e):nr(t,e)}class Ge extends Ke{constructor(){super("weixin")}isWeixinApiAvailable(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram}performNavigation(e,r){return c.safeExecute(()=>{const{url:n,delta:i}=r;if(_.debug(`微信平台执行导航操作: ${e}`,r),this.isWeixinApiAvailable()){const h=window.wx.miniProgram[e];if(typeof h=="function"){_.debug(`使用微信原生 API: wx.miniProgram.${e}`);const f=e==="navigateBack"?{delta:i}:{url:n};return h.call(window.wx.miniProgram,f)}}_.debug(`使用消息桥接执行: ${e}`),de(e,e==="navigateBack"?{delta:i}:{url:n})},{platform:this.name,method:"performNavigation",navigationType:e,options:r})}performPostMessage(e){return c.safeExecute(()=>{const{data:r}=e;if(this.isWeixinApiAvailable())return window.wx.miniProgram.postMessage({data:r});de("postMessage",r)},{platform:this.name,method:"performPostMessage",options:e})}performGetEnv(e){return c.safeExecute(()=>{if(!e||typeof e!="function")throw new Error("Callback function is required for getEnv");if(this.isWeixinApiAvailable()&&window.wx.miniProgram.getEnv)return window.wx.miniProgram.getEnv(e);e({miniprogram:!0,weixin:!0})},{platform:this.name,method:"performGetEnv"})}}const Y=new Ge;var Ve=Object.freeze({__proto__:null,WeixinPlatform:Ge,getEnv:t=>Y.getEnv(t),navigateBack:t=>Y.navigateBack(t),navigateTo:t=>Y.navigateTo(t),postMessage:t=>Y.postMessage(t),reLaunch:t=>Y.reLaunch(t),redirectTo:t=>Y.redirectTo(t),switchTab:t=>Y.switchTab(t)});class je extends Ke{constructor(){super("app")}performNavigation(e,r){return c.safeExecute(()=>{const{url:n,delta:i}=r;de(e,e==="navigateBack"?{delta:i}:{url:n})},{platform:this.name,method:"performNavigation",navigationType:e,options:r})}performPostMessage(e){return c.safeExecute(()=>{const{data:r}=e;de("postMessage",r)},{platform:this.name,method:"performPostMessage",options:e})}performGetEnv(e){return c.safeExecute(()=>{if(!e||typeof e!="function")throw new Error("Callback function is required for getEnv");const r={};let n=!1;te()?(r.uvue=!0,n=!0):j()?(r.nvue=!0,n=!0):ee()&&(r.plus=!0,n=!0),n?r.app=!0:r.h5=!0,e(r)},{platform:this.name,method:"performGetEnv"})}}const X=new je;var qe=Object.freeze({__proto__:null,AppPlatform:je,getEnv:t=>X.getEnv(t),navigateBack:t=>X.navigateBack(t),navigateTo:t=>X.navigateTo(t),postMessage:t=>X.postMessage(t),reLaunch:t=>X.reLaunch(t),redirectTo:t=>X.redirectTo(t),switchTab:t=>X.switchTab(t)});function ge(){return g()?Ve:qe}function ir(t){return ge().navigateTo(t)}function sr(t){return ge().navigateBack(t)}function ar(t){return ge().switchTab(t)}function or(t){return ge().reLaunch(t)}function cr(t){return ge().redirectTo(t)}function Je(){return g()?Ve:qe}function ur(t={}){return Je().postMessage(t)}function lr(t){return Je().getEnv(t)}function fr(t){return t&&typeof t=="object"&&t.__v_raw?t.__v_raw:t}function dr(){return"qsh_callback_"+Date.now()+"_"+Math.random().toString(36).substring(2,9)}class gr{constructor(){this.callbacks=new Map,this.timeouts=new Map,this.persistentCallbacksByApi=new Map,this.defaultTimeout=3e4,typeof window!="undefined"&&(window.qshWebviewCallbacks||(window.qshWebviewCallbacks={})),y.debug("WebView 桥接器已初始化")}callApi(i){return E(this,arguments,function*(e,r={},n={}){return c.safeExecute(()=>E(this,null,function*(){var O;if(typeof window!="undefined"&&window===window.parent&&!window.plus&&!window.__uniapp_x_postMessage&&!window.__uniapp_x_&&!window.__dcloud_weex_postMessage&&!window.__dcloud_weex_){const b=new M(B.PLATFORM_NOT_SUPPORTED,"当前不在宿主 WebView 容器中,无法发送消息");n&&typeof n.fail=="function"&&n.fail({errMsg:b.message,code:"NOT_IN_CONTAINER"}),n&&typeof n.complete=="function"&&n.complete({success:!1,error:{errMsg:b.message}});return}const h={apiName:e,params:r,callbacks:n,timestamp:Date.now(),abort:!1,metadata:{}};U.setApiLoading(e,!0);const f=yield H.runRequest(h);if(f.abort){y.warn("API 调用被拦截器中止",{api:e}),U.setApiLoading(e,!1),n.fail&&n.fail({errMsg:((O=f.error)==null?void 0:O.message)||"API 调用被中止",code:"INTERCEPTED"}),n.complete&&n.complete({success:!1});return}const d=dr();if(n.success||n.fail||n.complete){if(this.callbacks.set(d,N(p({},n),{context:f})),window.qshWebviewCallbacks[d]=be=>{this.handleCallback(d,be)},r.isPersistent&&(this.persistentCallbacksByApi.has(e)||this.persistentCallbacksByApi.set(e,new Set),this.persistentCallbacksByApi.get(e).add(d)),r.isPersistent||r.disableTimeout)y.info(`API ${e} 禁用超时清理,将等待回调返回后清理`,{callbackId:d,isPersistent:r.isPersistent,disableTimeout:r.disableTimeout});else{const be=setTimeout(()=>{y.warn("API 调用超时,自动清理回调",{api:e,callbackId:d}),n.fail&&n.fail({errMsg:`API ${e} 调用超时`,code:"TIMEOUT"}),this.cleanupCallback(d)},r.timeout||this.defaultTimeout);this.timeouts.set(d,be)}const P={type:"qsh_api_call",api:e,params:f.params,callbackId:d,timestamp:Date.now()};y.info("发送 API 调用消息",{api:e,callbackId:d,hasSuccess:!!n.success,hasFail:!!n.fail}),console.log("message:",JSON.stringify(fr(P),null,2)),de("postMessage",P)}}),{context:"WebViewBridge.callApi",api:e})})}handleCallback(e,r){return E(this,null,function*(){return c.safeExecute(()=>E(this,null,function*(){var b,P;const n=this.callbacks.get(e);if(!n){y.warn("未找到回调函数",{callbackId:e});return}const{success:i,fail:a,complete:h,context:f}=n;y.debug("处理回调",{callbackId:e,result:r});const d=yield H.runResponse(r,f);f&&U.setApiResult(f.apiName,d),d.success&&i?i(d.data):!d.success&&a&&a(d.error||{errMsg:"操作失败"}),h&&h(d),((P=(b=n.context)==null?void 0:b.params)==null?void 0:P.isPersistent)?y.debug("持久监听API:保留回调",{callbackId:e}):(this.cleanupCallback(e),y.debug("回调执行完成,已清理",{callbackId:e}))}),{context:"WebViewBridge.handleCallback",callbackId:e})})}cleanupCallback(e){const r=this.timeouts.get(e);if(r&&(clearTimeout(r),this.timeouts.delete(e)),this.callbacks.delete(e),typeof window!="undefined"&&window.qshWebviewCallbacks&&delete window.qshWebviewCallbacks[e],this.persistentCallbacksByApi&&this.persistentCallbacksByApi.size>0){const n=[];this.persistentCallbacksByApi.forEach((i,a)=>{i.has(e)&&(i.delete(e),i.size===0&&n.push(a))}),n.forEach(i=>this.persistentCallbacksByApi.delete(i))}}clearCallbacks(){y.debug("清理所有回调",{count:this.callbacks.size}),this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts.clear(),this.callbacks.clear(),this.persistentCallbacksByApi&&this.persistentCallbacksByApi.clear(),typeof window!="undefined"&&window.qshWebviewCallbacks&&Object.keys(window.qshWebviewCallbacks).forEach(e=>{e.startsWith("qsh_callback_")&&delete window.qshWebviewCallbacks[e]})}cleanupPersistentCallbacksByApi(e){const r=this.persistentCallbacksByApi.get(e);if(!r||r.size===0)return 0;const n=Array.from(r);return n.forEach(i=>this.cleanupCallback(i)),this.persistentCallbacksByApi.delete(e),y.info("已清理持久回调",{api:e,count:n.length}),n.length}getStatus(){return{isSupported:typeof window!="undefined"&&window.uni&&typeof window.uni.postMessage=="function",activeCallbacks:this.callbacks.size,globalCallbacksCount:typeof window!="undefined"&&window.qshWebviewCallbacks?Object.keys(window.qshWebviewCallbacks).length:0}}}const He=new gr,R=(t,e,r)=>He.callApi(t,e,r),se=t=>He.cleanupPersistentCallbacksByApi(t),we={ALBUM:"album",CAMERA:"camera"},Ee={ORIGINAL:"original",COMPRESSED:"compressed"},hr={count:9,sizeType:[Ee.ORIGINAL,Ee.COMPRESSED],sourceType:[we.ALBUM,we.CAMERA]};function pr(t={}){const e=p(p({},hr),t);return Array.isArray(e.sizeType)||(e.sizeType=[e.sizeType].filter(Boolean)),Array.isArray(e.sourceType)||(e.sourceType=[e.sourceType].filter(Boolean)),e.count=Math.max(1,Math.min(9,parseInt(e.count)||1)),e.sizeType.length===0&&(e.sizeType=[Ee.COMPRESSED]),e.sourceType.length===0&&(e.sourceType=[we.ALBUM]),e}function Ye(){return["weixin","webview","UniApp","plus","nvue","uvue"].includes(l.type)}function Xe(t){return c.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!z()){s.info("等待微信配置完成"),F().then(()=>Xe(t)).catch(r=>{var n;s.error("微信配置失败",r),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}s.debug("调用微信图片选择",t),window.wx.chooseImage({count:t.count,sizeType:t.sizeType,sourceType:t.sourceType,success:r=>{var n,i;s.info("微信图片选择成功",{count:((n=r.localIds)==null?void 0:n.length)||0}),(i=t.success)==null||i.call(t,r)},fail:r=>{var n;s.error("微信图片选择失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"chooseImageInWeixin",platform:"weixin"})}function mr(t){return c.safeExecute(()=>{s.debug("通过 WebView 桥接调用图片选择",t),R("chooseImage",N(p({},t),{disableTimeout:!0}),{success:e=>{var r,n;s.info("UniApp 图片选择成功",{count:((r=e==null?void 0:e.tempFilePaths)==null?void 0:r.length)||0}),(n=t.success)==null||n.call(t,e)},fail:e=>{var r;s.error("UniApp 图片选择失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"chooseImageInUniApp",platform:"uniapp"})}function wr(t={}){return c.safeExecute(()=>{var r;if(!Ye()){const n={errMsg:`当前环境 (${l.type}) 不支持图片选择功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持图片选择",{platform:l.type}),(r=t.fail)==null||r.call(t,n);return}const e=pr(t);s.info("开始选择图片",{platform:l.type,count:e.count,sizeType:e.sizeType,sourceType:e.sourceType}),g()?Xe(e):mr(e)},{context:"chooseImage",options:t})}function Er(){return{supported:Ye(),environment:l.type,implementation:g()?"weixin":"webview",features:{multipleSelection:!0,sizeTypeSelection:!0,sourceTypeSelection:!0,asyncSupport:!0}}}const Z={QR_CODE:"qrCode",BAR_CODE:"barCode",DATA_MATRIX:"datamatrix",PDF417:"pdf417"},yr={onlyFromCamera:!0,scanType:[Z.QR_CODE,Z.BAR_CODE]};function Ir(t={}){const e=p(p({},yr),t);return Array.isArray(e.scanType)||(e.scanType=[e.scanType].filter(Boolean)),e.scanType.length===0&&(e.scanType=[Z.QR_CODE,Z.BAR_CODE]),e.onlyFromCamera=!!e.onlyFromCamera,e}function Ze(){return["weixin","webview","UniApp","plus","nvue","uvue"].includes(l.type)}function Qe(t){return c.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!z()){s.info("等待微信配置完成"),F().then(()=>Qe(t)).catch(r=>{var n;s.error("微信配置失败",r),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}s.debug("调用微信扫码",t),window.wx.scanQRCode({needResult:1,scanType:t.scanType,success:r=>{var i;s.info("微信扫码成功",{result:r.resultStr});const n={result:r.resultStr,scanType:Ar(r.resultStr),charSet:"utf-8",errMsg:"scanCode:ok"};(i=t.success)==null||i.call(t,n)},fail:r=>{var n;s.error("微信扫码失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"scanCodeInWeixin",platform:"weixin"})}function Ar(t){return t?t.length>50||/[^\d]/.test(t)?Z.QR_CODE:Z.BAR_CODE:"unknown"}function Or(t){return c.safeExecute(()=>{s.debug("通过 WebView 桥接调用扫码",t),R("scanCode",N(p({},t),{disableTimeout:!0}),{success:e=>{var r;s.info("UniApp 扫码成功",{result:e==null?void 0:e.result,scanType:e==null?void 0:e.scanType}),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("UniApp 扫码失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"scanCodeInUniApp",platform:"uniapp"})}function _r(t={}){return c.safeExecute(()=>{var r;if(!Ze()){const n={errMsg:`当前环境 (${l.type}) 不支持扫码功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持扫码",{platform:l.type}),(r=t.fail)==null||r.call(t,n);return}const e=Ir(t);s.info("开始扫码",{platform:l.type,onlyFromCamera:e.onlyFromCamera,scanType:e.scanType}),g()?Qe(e):Or(e)},{context:"scanCode",options:t})}function Cr(){return{supported:Ze(),environment:l.type,implementation:g()?"weixin":"webview",features:{onlyFromCamera:!0,scanTypeSelection:!0,multipleTypes:!0,asyncSupport:!0}}}const ae={WGS84:"wgs84",GCJ02:"gcj02",BD09:"bd09"},Nr={type:ae.WGS84,altitude:!1},Rr={scale:18};function Sr(t={}){const e=p(p({},Nr),t);return Object.values(ae).includes(e.type)||(e.type=ae.WGS84),e.altitude=!!e.altitude,e}function Tr(t={}){const e=p({},t);return Object.values(ae).includes(e.type)||(e.type=ae.WGS84),e.needFullAccuracy=!!e.needFullAccuracy,e}function Pr(t={}){const e=p(p({},Rr),t);if(e.latitude===void 0||e.latitude===null)throw{errMsg:"缺少必需参数:latitude(纬度)",code:"PARAM_MISSING"};if(typeof e.latitude!="number")throw{errMsg:`latitude 参数类型错误:期望 number,实际 ${typeof e.latitude}`,code:"PARAM_TYPE_ERROR",details:{param:"latitude",expected:"number",actual:typeof e.latitude,value:e.latitude}};if(e.latitude<-90||e.latitude>90)throw{errMsg:`latitude 超出范围:有效范围 -90 ~ 90,实际值 ${e.latitude}`,code:"PARAM_INVALID",details:{param:"latitude",value:e.latitude,validRange:"-90 ~ 90"}};if(e.longitude===void 0||e.longitude===null)throw{errMsg:"缺少必需参数:longitude(经度)",code:"PARAM_MISSING"};if(typeof e.longitude!="number")throw{errMsg:`longitude 参数类型错误:期望 number,实际 ${typeof e.longitude}`,code:"PARAM_TYPE_ERROR",details:{param:"longitude",expected:"number",actual:typeof e.longitude,value:e.longitude}};if(e.longitude<-180||e.longitude>180)throw{errMsg:`longitude 超出范围:有效范围 -180 ~ 180,实际值 ${e.longitude}`,code:"PARAM_INVALID",details:{param:"longitude",value:e.longitude,validRange:"-180 ~ 180"}};if(e.scale!==void 0&&e.scale!==null){const r=Number(e.scale);isNaN(r)?(s.warn("scale 参数无效,使用默认值 18",{scale:e.scale}),e.scale=18):e.scale=Math.max(1,Math.min(28,Math.floor(r)))}return e}function Re(){return["weixin","webview","UniApp","plus","nvue","uvue"].includes(l.type)}function et(t){return c.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!z()){s.info("等待微信配置完成"),F().then(()=>et(t)).catch(r=>{var n;s.error("微信配置失败",r),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}s.debug("调用微信定位",t),window.wx.getLocation({type:t.type,success:r=>{var n;s.info("微信定位成功",{latitude:r.latitude,longitude:r.longitude}),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;s.error("微信定位失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"getLocationInWeixin",platform:"weixin"})}function tt(t){return c.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!z()){s.info("等待微信配置完成"),F().then(()=>tt(t)).catch(r=>{var n;s.error("微信配置失败",r),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}s.debug("调用微信查看位置",t),window.wx.openLocation({latitude:t.latitude,longitude:t.longitude,name:t.name||"",address:t.address||"",scale:t.scale||18,infoUrl:t.infoUrl||"",success:r=>{var n;s.info("微信查看位置成功"),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;s.error("微信查看位置失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"openLocationInWeixin",platform:"weixin"})}function Lr(t){return c.safeExecute(()=>{s.debug("通过 WebView 桥接调用获取位置",t),R("getLocation",t,{success:e=>{var r;s.info("UniApp 获取位置成功",{latitude:e==null?void 0:e.latitude,longitude:e==null?void 0:e.longitude}),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("UniApp 获取位置失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"getLocationInUniApp",platform:"uniapp"})}function Mr(t){return c.safeExecute(()=>{s.debug("通过 WebView 桥接调用查看位置",t),R("openLocation",t,{success:e=>{var r;s.info("UniApp 查看位置成功"),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("UniApp 查看位置失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"openLocationInUniApp",platform:"uniapp"})}function br(t={}){return c.safeExecute(()=>{var r;if(!Re()){const n={errMsg:`当前环境 (${l.type}) 不支持定位功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持定位",{platform:l.type}),(r=t.fail)==null||r.call(t,n);return}const e=Sr(t);s.info("开始获取位置",{platform:l.type,type:e.type,altitude:e.altitude}),g()?et(e):Lr(e)},{context:"getLocation",options:t})}function vr(t={}){return c.safeExecute(()=>{var r,n,i;if(!Re()){const a={errMsg:`当前环境 (${l.type}) 不支持查看位置功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持查看位置",{platform:l.type}),(r=t.fail)==null||r.call(t,a);return}let e;try{e=Pr(t)}catch(a){s.error("参数验证失败",a),(n=t.fail)==null||n.call(t,a),(i=t.complete)==null||i.call(t);return}s.info("开始查看位置",{platform:l.type,latitude:e.latitude,longitude:e.longitude,name:e.name}),g()?tt(e):Mr(e)},{context:"openLocation",options:t})}function xr(){const t=g();return{supported:Re(),environment:l.type,implementation:t?"weixin":"webview",features:{getLocation:!0,openLocation:!0,coordinateTypes:!0,altitudeSupport:!0,asyncSupport:!0,onLocationChange:!t}}}const G=new Set,V=new Set;function rt(t,e,r){t.forEach(n=>{if(typeof n=="function"){c.safeExecute(()=>n(e),{context:r});return}s.warn("监听回调不是函数,已跳过",{type:typeof n})})}function Dr(t={}){return c.safeExecute(()=>{var r,n;if(g()){const i={errMsg:`当前环境 (${l.type}) 不支持该接口`,code:"PLATFORM_NOT_SUPPORTED"};s.error("当前环境不支持此接口",{platform:l.type}),(r=t.fail)==null||r.call(t,i),(n=t.complete)==null||n.call(t,i);return}const e=Tr(t);s.info("正在开启定位监听"),R("startLocationUpdate",{type:e.type,needFullAccuracy:e.needFullAccuracy},{success:i=>{var a;s.info("定位监听已启动"),(a=t.success)==null||a.call(t,i)},fail:i=>{var a;return(a=t.fail)==null?void 0:a.call(t,i)},complete:t.complete})},{context:"startLocationUpdate"})}function Ur(t={}){return c.safeExecute(()=>{var e,r;if(g()){const n={errMsg:`当前环境 (${l.type}) 不支持该接口`,code:"PLATFORM_NOT_SUPPORTED"};s.error("当前环境不支持此接口",{platform:l.type}),(e=t.fail)==null||e.call(t,n),(r=t.complete)==null||r.call(t,n);return}s.info("正在停止定位监听"),R("stopLocationUpdate",t,{success:n=>{var i;s.info("定位监听已停止"),(i=t.success)==null||i.call(t,n)},fail:n=>{var i;return(i=t.fail)==null?void 0:i.call(t,n)},complete:t.complete})},{context:"stopLocationUpdate"})}function Wr(t){return c.safeExecute(()=>{if(g()){s.warn("当前环境不支持此接口",{platform:l.type});return}if(typeof t!="function")throw s.error("onLocationChange 回调不是函数",{type:typeof t}),{errMsg:"onLocationChange 回调必须是函数",code:"INVALID_CALLBACK"};const e=G.size>0;G.add(t),e||(s.debug("注册实时位置变化监听器"),R("onLocationChange",{isPersistent:!0},{success:r=>{s.debug("收到实时位置推送",r),rt(G,r,"onLocationChange")},fail:r=>{s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误",r),G.delete(t),G.size===0&&se("onLocationChange")}}))},{context:"onLocationChange"})}function $r(t){return c.safeExecute(()=>{if(g()){s.warn("当前环境不支持此接口",{platform:l.type});return}if(t&&typeof t!="function")throw s.error("offLocationChange 回调不是函数",{type:typeof t}),{errMsg:"offLocationChange 回调必须是函数",code:"INVALID_CALLBACK"};t?G.delete(t):G.clear(),!(G.size>0)&&(s.info("移除位置变化监听器"),R("offLocationChange",{},{success:()=>{s.info("位置变化监听已移除"),se("onLocationChange")},fail:e=>{s.error("移除位置变化监听失败",e),se("onLocationChange")}}))},{context:"offLocationChange"})}function Br(t){return c.safeExecute(()=>{if(g()){s.warn("当前环境不支持此接口",{platform:l.type});return}if(typeof t!="function")throw s.error("onLocationChangeError 回调不是函数",{type:typeof t}),{errMsg:"onLocationChangeError 回调必须是函数",code:"INVALID_CALLBACK"};const e=V.size>0;V.add(t),e||(s.debug("注册位置更新错误监听器"),R("onLocationChangeError",{isPersistent:!0},{success:r=>{s.warn("持续定位发生异常",r),rt(V,r,"onLocationChangeError")},fail:r=>{s.warn("位置更新错误监听注册失败",r),V.delete(t),V.size===0&&se("onLocationChangeError")}}))},{context:"onLocationChangeError"})}function kr(t){return c.safeExecute(()=>{if(g()){s.warn("当前环境不支持此接口",{platform:l.type});return}if(t&&typeof t!="function")throw s.error("offLocationChangeError 回调不是函数",{type:typeof t}),{errMsg:"offLocationChangeError 回调必须是函数",code:"INVALID_CALLBACK"};t?V.delete(t):V.clear(),!(V.size>0)&&(s.info("移除定位错误监听器"),R("offLocationChangeError",{},{success:()=>{s.info("定位错误监听已移除"),se("onLocationChangeError")},fail:e=>{s.error("移除定位错误监听失败",e),se("onLocationChangeError")}}))},{context:"offLocationChangeError"})}const Fr={latitude:null,longitude:null};function zr(t={}){const e=p(p({},Fr),t);return e.latitude!==null&&e.latitude!==void 0&&(typeof e.latitude!="number"?(s.warn("latitude 参数类型错误,已忽略",{latitude:e.latitude}),e.latitude=null):(e.latitude<-90||e.latitude>90)&&(s.warn("latitude 超出范围,已忽略",{latitude:e.latitude}),e.latitude=null)),e.longitude!==null&&e.longitude!==void 0&&(typeof e.longitude!="number"?(s.warn("longitude 参数类型错误,已忽略",{longitude:e.longitude}),e.longitude=null):(e.longitude<-180||e.longitude>180)&&(s.warn("longitude 超出范围,已忽略",{longitude:e.longitude}),e.longitude=null)),e}function nt(){return["weixin","webview","UniApp","plus","nvue","uvue"].includes(l.type)}function it(t){return c.safeExecute(()=>{var n;if(!window.wx){const i={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(n=t.fail)==null||n.call(t,i);return}if(!z()){s.info("等待微信配置完成"),F().then(()=>it(t)).catch(i=>{var a;s.error("微信配置失败",i),(a=t.fail)==null||a.call(t,{errMsg:`微信配置失败: ${i.message}`})});return}s.debug("调用微信位置选择",t);const e={success:i=>{var h;s.info("微信位置选择成功",{name:i.name,address:i.address,latitude:i.latitude,longitude:i.longitude});const a={name:i.name,address:i.address,latitude:i.latitude,longitude:i.longitude,errMsg:"chooseLocation:ok"};(h=t.success)==null||h.call(t,a)},fail:i=>{var a;s.error("微信位置选择失败",i),(a=t.fail)==null||a.call(t,i)},complete:t.complete},r={};t.latitude!==null&&t.latitude!==void 0&&(r.latitude=t.latitude),t.longitude!==null&&t.longitude!==void 0&&(r.longitude=t.longitude),window.wx.chooseLocation(N(p({},r),{success:e.success,fail:e.fail,complete:e.complete}))},{context:"chooseLocationInWeixin",platform:"weixin"})}function Kr(t){return c.safeExecute(()=>{s.debug("通过 WebView 桥接调用位置选择",t);const e={disableTimeout:!0,success:r=>{var n;s.info("UniApp 位置选择成功",{name:r==null?void 0:r.name,address:r==null?void 0:r.address,latitude:r==null?void 0:r.latitude,longitude:r==null?void 0:r.longitude}),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;s.error("UniApp 位置选择失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete};t.latitude!==null&&t.latitude!==void 0&&(e.latitude=t.latitude),t.longitude!==null&&t.longitude!==void 0&&(e.longitude=t.longitude),R("chooseLocation",e,{success:r=>{e.success(r)},fail:r=>{e.fail(r)},complete:e.complete})},{context:"chooseLocationInUniApp",platform:"uniapp"})}function Gr(t={}){return c.safeExecute(()=>{var r;if(!nt()){const n={errMsg:`当前环境 (${l.type}) 不支持位置选择功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持位置选择",{platform:l.type}),(r=t.fail)==null||r.call(t,n);return}const e=zr(t);s.info("开始选择位置",{platform:l.type,latitude:e.latitude,longitude:e.longitude}),g()?it(e):Kr(e)},{context:"chooseLocation",options:t})}function Vr(){return{supported:nt(),environment:l.type,implementation:g()?"weixin":"webview",features:{chooseLocation:!0,centerPoint:!0,asyncSupport:!0}}}const st=new Map;function jr(t,e={}){st.set(t,e)}function qr(t,e){const r=st.get(t);if(r)return r[e]||r.default}const Jr={0:"WXSceneSession",1:"WXSceneTimeline"},Hr={0:"图文/网页",1:"纯文字",2:"纯图片",3:"音乐",4:"视频",5:"小程序"};function at(t={}){return c.safeExecute(()=>{var n,i;if(typeof window=="undefined"||!window.wx){const a={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};return(n=t.fail)==null||n.call(t,a),Promise.reject(a)}if(!z())return s.info("等待微信配置完成"),F().then(()=>at(t));const e=ot(t);if(!e.success){const a={errMsg:e.message||"参数校验失败",code:"INVALID_PARAMS"};return(i=t.fail)==null||i.call(t,a),Promise.reject(a)}const r=e.params;return s.debug("调用微信分享",r),new Promise((a,h)=>{window.wx[r.scene](N(p({},r),{success:()=>{var d;const f={errMsg:"weixinShare:ok"};(d=t.success)==null||d.call(t,f),a(f)},fail:f=>{var O;const d={errMsg:(f==null?void 0:f.errMsg)||"weixinShare:fail",details:f};s.error("微信分享失败",d),(O=t.fail)==null||O.call(t,d),h(d)},complete:t.complete}))})},{context:"toShareInWeixin",platform:"weixin"})}function ot(t={}){const e=p({},t),r={scene:e.scene===1?"updateTimelineShareData":"updateAppMessageShareData"};return s.info("格式化微信参数",e),Object.prototype.hasOwnProperty.call(e,"title")?Object.prototype.hasOwnProperty.call(e,"imageUrl")?Object.prototype.hasOwnProperty.call(e,"path")?Object.prototype.hasOwnProperty.call(e,"summary")?(r.title=e.title,r.imgUrl=e.imageUrl,r.link=e.path,r.desc=e.summary,{params:r,success:!0}):{message:"参数字段summary值缺少!",success:!1}:{message:"参数字段path值缺少!",success:!1}:{message:"参数字段imageUrl值缺少!",success:!1}:{message:"参数字段title值缺少!",success:!1}}function oe(t={}){return c.safeExecute(()=>(s.debug("通过 WebView 桥接调用微信分享",t),new Promise((e,r)=>{R("toShareData",t,{success:n=>{var i;(i=t.success)==null||i.call(t,n),e(n)},fail:n=>{var i;s.error("UniApp 微信分享失败",n),(i=t.fail)==null||i.call(t,n),r(n)},complete:t.complete})})),{context:"toShareInUniApp",platform:"uniapp"})}function Yr(t={}){const e=p({},t),r={provider:"weixin",scene:"WXSceneSession"};if(s.info("格式化 UniApp 参数",e),[0,1].some(n=>parseInt(n)===parseInt(e.scene))?r.scene=Jr[e.scene]:r.scene="WXSceneSession",Object.prototype.hasOwnProperty.call(e,"type")){const n=Number(e.type);if(Object.keys(Hr).some(a=>parseInt(a)===n)){if(r.type=n,[0].includes(n))if(Object.prototype.hasOwnProperty.call(e,"path"))r.href=e.path;else return{message:"参数字段path值缺少!",success:!1};if([0,1].includes(n))if(Object.prototype.hasOwnProperty.call(e,"summary"))r.summary=e.summary;else return{message:"参数字段summary值缺少!",success:!1};if([0,2,5].includes(n))if(Object.prototype.hasOwnProperty.call(e,"imageUrl"))r.imageUrl=e.imageUrl;else return{message:"参数字段imageUrl值缺少!",success:!1};[5].includes(n)&&Object.prototype.hasOwnProperty.call(e,"miniProgram")&&p({},e.miniProgram),Object.prototype.hasOwnProperty.call(e,"title")&&(r.title=e.title),Object.prototype.hasOwnProperty.call(e,"success")&&(r.success=e.success),Object.prototype.hasOwnProperty.call(e,"fail")&&(r.fail=e.fail),Object.prototype.hasOwnProperty.call(e,"complete")&&(r.complete=e.complete)}else return{message:"参数字段type值有误!",success:!1}}else return{message:"参数字段type缺少!",success:!1};return{params:r,success:!0}}const ct="share.toShare";jr(ct,{weixin:at,webview:oe,plus:oe,nvue:oe,uvue:oe,UniApp:oe,h5:oe,default:void 0});function Xr(t={}){return c.safeExecute(()=>{var a,h;const e=Oe(),r=qr(ct,e.type);if(typeof r!="function"){const f={errMsg:`当前环境 (${e.type}) 不支持微信分享功能`,code:"PLATFORM_NOT_SUPPORTED"};return s.error("平台不支持微信分享",{platform:e.type}),(a=t.fail)==null||a.call(t,f),Promise.reject(f)}const n=g()?ot(t):Yr(t);if(!n.success){const f={errMsg:n.message||"参数校验失败",code:"INVALID_PARAMS"};return(h=t.fail)==null||h.call(t,f),Promise.reject(f)}const i=n.params;return s.info("开始微信分享",{platform:e.type,type:i==null?void 0:i.type}),r(i)},{context:"toShare",options:t})}const Zr={OFF:"off",ON:"on",UNAVAILABLE:"unavailable",UNAUTHORIZED:"unauthorized"},Qr={allowDuplicatesKey:!1,services:[]};function ye(t={}){return p(p({},Qr),t)}function he(){return["weixin","webview","UniApp","plus","nvue","uvue"].includes(l.type)}function en(t){return c.safeExecute(()=>E(null,null,function*(){var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}z()||(s.info("等待微信配置完成"),yield F()),wx.openBluetoothAdapter({success:()=>{s.info("微信蓝牙适配器已打开"),ut(t)},fail:r=>{var n;s.error("蓝牙适配器打开失败",r),(n=t.fail)==null||n.call(t,r)}})}),{context:"openBluetoothAdapterInWeixin"})}function tn(t){return c.safeExecute(()=>{s.debug("通过 WebView 桥接调用蓝牙功能",t),R("bluetooth",t,{success:e=>{var r;s.info("UniApp 蓝牙调用成功",e),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("UniApp 蓝牙调用失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"bluetoothInUniApp"})}function rn(t){return c.safeExecute(()=>{var e;s.debug("通过 WebView 桥接调用蓝牙设备搜索功能",t),R("bluetoothDevicesDiscovery",{action:"startBluetoothDevicesDiscovery",params:{services:t.services||[],allowDuplicatesKey:(e=t.allowDuplicatesKey)!=null?e:!1}},{success:r=>{var n;console.log("[Bluetooth] 设备开启搜索成功:",r),s.info("UniApp 蓝牙设备开启搜索成功",r),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;console.error("[Bluetooth] 设备开启搜索失败:",r),s.error("UniApp 蓝牙设备开启搜索失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"startBluetoothDevicesDiscoveryInUniApp"})}const Ie=new Set;function nn(t,e={}){return c.safeExecute(()=>{var r;return Ie.add(t),Ie.size===1&&R("onBluetoothDeviceFound",{action:"onBluetoothDeviceFound",isPersistent:!0,params:{services:e.services||[],allowDuplicatesKey:(r=e.allowDuplicatesKey)!=null?r:!1}},{success:n=>{Ie.forEach(i=>{typeof i=="function"?c.safeExecute(()=>i(n),{context:"BluetoothDeviceCallback"}):console.warn("[BluetoothDeviceCallback] 不是函数:",i)})},fail:n=>{var i;console.error("[Bluetooth] 搜索失败:",n),(i=e.fail)==null||i.call(e,n)},complete:e.complete}),()=>Ie.delete(t)},{context:"qsh_onBluetoothDeviceFound"})}function sn(t){return c.safeExecute(()=>{var e;s.debug("通过 WebView 桥接调用蓝牙连接功能",t),R("bluetoothConnection",{action:"createBLEConnection",params:{deviceId:t.deviceId,name:t.name,autoConnect:(e=t.autoConnect)!=null?e:!1}},{success:r=>{var n;console.log("[Bluetooth] 蓝牙连接成功:",r),s.info("UniApp 蓝牙连接成功",r),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;console.error("[Bluetooth] 蓝牙连接失败:",r),s.error("UniApp 蓝牙连接失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"createBLEConnectionInUniApp"})}function an(t={}){return c.safeExecute(()=>{var r;if(!he()){const n={errMsg:`当前环境 (${l.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持蓝牙",{platform:l.type}),(r=t.fail)==null||r.call(t,n);return}const e=ye(t);s.info("开始蓝牙操作",{platform:l.type,services:e.services,allowDuplicatesKey:e.allowDuplicatesKey}),g()?en(e):tn(e)},{context:"openBluetoothAdapter",options:t})}function on(t={}){return c.safeExecute(()=>{var r,n;if(!he()){const i={errMsg:`当前环境 (${l.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持蓝牙",{platform:l.type}),(r=t.fail)==null||r.call(t,i),(n=t.complete)==null||n.call(t,i);return}const e=ye(t);s.info("开始搜索蓝牙设备",{platform:l.type,services:e.services,allowDuplicatesKey:e.allowDuplicatesKey}),g()?startBluetoothDevicesDiscoveryInWeixin(e):rn(e)},{context:"startBluetoothDevicesDiscovery",options:t})}function ut(t,e={}){return c.safeExecute(()=>{var n,i;if(!he()){const a={errMsg:`当前环境 (${l.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持蓝牙",{platform:l.type}),(n=e.fail)==null||n.call(e,a),(i=e.complete)==null||i.call(e,a);return}const r=ye(e);s.info("注册蓝牙设备发现监听",{platform:l.type}),g()?onBluetoothDeviceFoundInWeixin(r):nn(t,r)},{context:"onBluetoothDeviceFound",options:e})}function cn(t={}){return c.safeExecute(()=>{var a,h,f,d;if(!he()){const O={errMsg:`当前环境 (${l.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持蓝牙连接",{platform:l.type}),(a=t.fail)==null||a.call(t,O),(h=t.complete)==null||h.call(t,O);return}const e=ye(t),{name:r,deviceId:n,autoConnect:i=!1}=e;if(!n){const O={errMsg:"缺少 deviceId 参数",code:"INVALID_PARAMS"};(f=t.fail)==null||f.call(t,O),(d=t.complete)==null||d.call(t,O);return}s.info("创建蓝牙连接",{deviceId:n,autoConnect:i,platform:l.type}),g()?uni.createBLEConnection({deviceId:n,autoConnect:i,success:t.success,fail:t.fail,complete:t.complete}):sn(e)},{context:"createBLEConnection",options:t})}function un(){return{supported:he(),environment:l.type,implementation:g()?"weixin":"webview",features:{discovery:!0,connect:!0,readWrite:!0,notify:!0,asyncSupport:!0}}}const lt=Oe();H.useResponse(ze.response,{priority:1e3});let ft=!1;function dt(){if(ft)return;ft=!0,Zt([{name:"load-weixin-sdk",run:Dt,timeoutMs:8e3},{name:"init-bridge",run:Ue,timeoutMs:8e3}],{onError:(e,r)=>{console.error(`[QSH-SDK] 初始化失败(${(r==null?void 0:r.name)||"unknown"}):`,e)}})}typeof window!="undefined"&&(document.readyState==="complete"||document.readyState==="interactive"?setTimeout(dt,0):document.addEventListener("DOMContentLoaded",dt));function A(t,{apiName:e}={}){return function(r={},...n){const i=r&&typeof r=="object"&&(typeof r.success=="function"||typeof r.fail=="function"||typeof r.complete=="function"),a=r&&typeof r=="object"?r:{},h=()=>i?t(a,...n):new Promise((d,O)=>{const b=N(p({},a),{success:P=>{typeof a.success=="function"&&a.success(P),d(P)},fail:P=>{typeof a.fail=="function"&&a.fail(P),O(P)},complete:a.complete});t(b,...n)});return(typeof window=="undefined"?Promise.resolve():xe()).then(()=>h()).catch(d=>{throw console.error(`[QSH-SDK] ${e||"API"} call failed:`,d),d})}}function Ae(t){return typeof t=="function"?{success:t}:t&&typeof t=="object"?t:{}}const gt=A(ir),ht=A(sr),pt=A(ar),mt=A(or),wt=A(cr),Et=A(ur);function yt(t){const e=()=>lr(t);return(typeof window=="undefined"?Promise.resolve():xe()).then(()=>e())}const Se=A(wr);function ln(t={}){return new Promise((e,r)=>{Se(N(p({},t),{success:e,fail:r}))})}const Te=A(_r);function fn(t={}){return new Promise((e,r)=>{Te(N(p({},t),{success:e,fail:r}))})}const dn=A(Xr),Pe=A(br);function gn(t={}){return new Promise((e,r)=>{Pe(N(p({},t),{success:e,fail:r}))})}const Le=A(vr);function hn(t={}){return new Promise((e,r)=>{Le(N(p({},t),{success:e,fail:r}))})}const Me=A(Gr);function pn(t={}){return new Promise((e,r)=>{Me(N(p({},t),{success:e,fail:r}))})}const It=A(an);function mn(t={}){return new Promise((e,r)=>{It(N(p({},t),{success:e,fail:r}))})}const At=A(on);function wn(t={}){return new Promise((e,r)=>{At(N(p({},t),{success:e,fail:r}))})}const Ot=A(ut);function En(t={}){return new Promise((e,r)=>{Ot(N(p({},t),{success:e,fail:r}))})}const _t=A(cn);function yn(t={}){return new Promise((e,r)=>{_t(N(p({},t),{success:e,fail:r}))})}const Q={navigateTo:gt,navigateBack:ht,switchTab:pt,reLaunch:mt,redirectTo:wt,postMessage:Et,getEnv:yt,chooseImage:Se,chooseImageAsync:ln,scanCode:Te,scanCodeAsync:fn,getLocation:Pe,getLocationAsync:gn,openLocation:Le,openLocationAsync:hn,chooseLocation:Me,chooseLocationAsync:pn,onLocationChange:t=>A((e={})=>Wr(e.success),{apiName:"onLocationChange"})(Ae(t)),offLocationChange:t=>A((e={})=>$r(e.success),{apiName:"offLocationChange"})(Ae(t)),onLocationChangeError:t=>A((e={})=>Br(e.success),{apiName:"onLocationChangeError"})(Ae(t)),offLocationChangeError:t=>A((e={})=>kr(e.success),{apiName:"offLocationChangeError"})(Ae(t)),startLocationUpdate:A(Dr,{apiName:"startLocationUpdate"}),stopLocationUpdate:A(Ur,{apiName:"stopLocationUpdate"}),environment:lt,ready:bt,init:Ue,isReady:St,getState:Tt,weixin:{waitForConfig:F,isConfigReady:z,getConfigState:Ut,retryConfig:Wt},webView:null,ImageSourceTypes:we,ImageSizeTypes:Ee,getImageCapabilities:Er,ScanTypes:Z,getScanCapabilities:Cr,CoordinateTypes:ae,getLocationCapabilities:xr,getChooseLocationCapabilities:Vr,openBluetoothAdapter:It,openBluetoothAdapterAsync:mn,startBluetoothDevicesDiscovery:At,startBluetoothDevicesDiscoveryAsync:wn,onBluetoothDeviceFound:Ot,onBluetoothDeviceFoundAsync:En,createBLEConnection:_t,createBLEConnectionAsync:yn,BluetoothStates:Zr,toShare:dn,getBluetoothCapabilities:un,plugins:{manager:le,register:t=>le.register(t),install:t=>le.install(t,Q),list:()=>le.getPluginList()},interceptors:{chain:H,useRequest:(t,e)=>H.useRequest(t,e),useResponse:(t,e)=>H.useResponse(t,e),builtin:{logging:kt,performance:K,createRetry:Ft,createValidation:zt,errorNormalizer:ze}},metrics:{getPerformanceReport:()=>K.getReport(),clearPerformanceMetrics:()=>K.clearMetrics()},errors:{codes:o,messages:Ne,categories:D,normalize:Fe,create:Ht,isStandard:Yt},store:{instance:U,get:t=>U.get(t),set:(t,e)=>U.set(t,e),subscribe:(t,e)=>U.subscribe(t,e),getSnapshot:()=>U.getSnapshot()},debug:{logger:S,setLogReporter:t=>S.setReporter(t),errorHandler:c,stateManager:J,enableDevMode:()=>S.enableDevMode(),getLogs:t=>S.getHistory(t),getStats:()=>({logger:S.getStats(),state:J.getStats(),weixinConfig:We().getStats(),plugins:le.getStats(),interceptors:H.getStats(),store:U.getStats()}),getWeixinConfigManager:We,exportDebugInfo:()=>S.exportToJSON()}};lt.isWeixinMiniProgram?Q.webView=window.wx&&window.wx.miniProgram:Q.webView={navigateTo:gt,navigateBack:ht,switchTab:pt,reLaunch:mt,redirectTo:wt,postMessage:Et,getEnv:yt,chooseImage:Se,scanCode:Te,getLocation:Pe,openLocation:Le,chooseLocation:Me};const Ct=typeof window.uni!="undefined"?window.uni:{};return Object.keys(Ct).forEach(t=>{Q.hasOwnProperty(t)||(Q[t]=Ct[t])}),typeof window!="undefined"&&(window.qsh=Q),Q});
|
|
2
2
|
//# sourceMappingURL=qsh-webview-sdk.umd.js.map
|