@cloudbase/wx-cloud-client-sdk 1.8.3 → 1.8.5
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 +207 -36
- package/lib/auth/index.d.ts +3 -1
- package/lib/index.d.ts +2 -0
- package/lib/types/index.d.ts +2 -2
- package/lib/wxCloudClientSDK.cjs.js +9 -1
- package/lib/wxCloudClientSDK.esm.js +9 -1
- package/lib/wxCloudClientSDK.umd.js +9 -1
- package/package.json +3 -2
|
@@ -1 +1,9 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).wxCloudClientSDK={})}(this,function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t,r,n){return new(r||(r=Promise))(function(t,o){function i(e){try{s(n.next(e))}catch(e){o(e)}}function a(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r(function(e){e(n)})).then(i,a)}s((n=n.apply(e,[])).next())})}function i(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var a=function(e){function t(t,r){var n=e.call(this,t)||this;return n.name="WxCloudSDKError",n.code=null==r?void 0:r.code,n.requestId=null==r?void 0:r.requestId,n.originError=null==r?void 0:r.originError,n}return r(t,e),t}(Error);function s(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function u(){try{var e=s();if(!e)return;return"undefined"==typeof wx?s().location.href:e.__wxRoute}catch(e){}}var c=function(e){return o(void 0,0,void 0,function(){var t,r,n,o;return i(this,function(i){switch(i.label){case 0:if(!(null===(n=null==e?void 0:e.auth)||void 0===n?void 0:n.getSession))return[2,""];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.auth.getSession()];case 2:return t=i.sent().data,[2,(null===(o=t.session)||void 0===o?void 0:o.access_token)||""];case 3:return r=i.sent(),console.log("[WxCloudSDKError] getAccessToken failed",r),[2,""];case 4:return[2]}})})},l=function(e){var t=e.dataSourceName,r=e.methodName,l=e.params,h=e.realMethodName,f=e.callFunction,d=e.envType,p=void 0===d?"prod":d,v=e.mode,y=e.cloud;return o(void 0,0,void 0,function(){var e,o,d,m,g,b,w;return i(this,function(i){switch(i.label){case 0:return e={data:{},requestId:""},[4,c(y)];case 1:o=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,f({name:"lowcode-datasource",data:n({dataSourceName:t,methodName:r,params:l,userAgent:(S=s(),(null==S?void 0:S.navigator)?S.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(e){e&&(P=["brand","model","version","system","platform","SDKVersion","language"].map(function(t){return"".concat(t,": ").concat(e[t])}).join(", "))}}),P):void 0),referrer:u(),"x-sdk-version":"1.8.3",envType:p,mode:v},o?{access_token:o}:{})})];case 3:if(d=i.sent(),m=(null===(b=null==d?void 0:d.result)||void 0===b?void 0:b.requestId)||(null==d?void 0:d.requestId)||(null==d?void 0:d.requestID),null==d?void 0:d.result.code)throw new a("【错误】".concat(null==d?void 0:d.result.message,"\n【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(h,"\n【错误码】").concat(null==d?void 0:d.result.code,"\n【请求ID】").concat(m||"N/A"),{code:null==d?void 0:d.result.code,requestId:m});return e.data=(null===(w=null==d?void 0:d.result)||void 0===w?void 0:w.data)||{},e.requestId=m,[3,5];case 4:throw"WxCloudSDKError"===(g=i.sent()).name?g:(console.log(g),new a("【错误】".concat(g.message,"\n 【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(h,"\n 【请求ID】N/A"),{code:"UnknownError",originError:g}));case 5:return[2,e]}var P,S})})},h=function(e){var t=e.sql,r=e.params,n=e.config,a=e.callFunction,s=e.unsafe,u=void 0!==s&&s,c=e.cloud;return o(void 0,0,void 0,function(){return i(this,function(e){return[2,l({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:t,config:n,parameter:u?"":Object.entries(r||{}).reduce(function(e,t){var r=t[0],n=t[1];if(void 0!==n){var o="OBJECT";switch(typeof n){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(n)?"ARRAY":"OBJECT"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e},[])||[]}},callFunction:a,mode:"sdk",cloud:c})]})})},f=function(e,t){return{$runSQL:function(r,a,s){return o(this,0,void 0,function(){return i(this,function(o){switch(o.label){case 0:return[4,h({sql:r,params:a,config:n(n({},s),{preparedStatements:!0}),callFunction:e,cloud:t})];case 1:return[2,o.sent()]}})})},$runSQLRaw:function(r,a){return o(this,0,void 0,function(){return i(this,function(o){switch(o.label){case 0:return[4,h({sql:r,params:[],config:n(n({},a),{preparedStatements:!1}),callFunction:e,cloud:t})];case 1:return[2,o.sent()]}})})}}},d={filter:{where:{}},select:{$master:!0}};function p(e){return{getUrl:function(t){return"".concat(t,"/").concat(e)},method:"post"}}var v={get:n(n({},p("get")),{defaultParams:n({},d)}),list:n(n({},p("list")),{defaultParams:n({},d)}),create:p("create"),createMany:p("createMany"),update:n(n({},p("update")),{method:"put"}),updateMany:n(n({},p("updateMany")),{method:"put"}),upsert:p("upsert"),delete:p("delete"),deleteMany:p("deleteMany")},y="Unknown error occurred",m="NotSupported",g=function(e,t,r,n){var o=f(e,null==n?void 0:n.cloud);return new Proxy({},{get:function(e,i){if("string"==typeof i)return Object.prototype.hasOwnProperty.call(o,i)?o[i]:w(r,i,t,n)}})},b=function(e,t,r,n,o){return new a("【错误】".concat(e,"\n【操作】调用 models.").concat(t,".").concat(r,"\n【错误码】").concat(n,"\n【请求ID】").concat(o),{code:n,requestId:o})},w=function(e,t,r,s){var u=new Proxy({},{get:function(u,c){if("runSQLTemplate"!==c){var l=v[c];if(!l){var h=new Error("不支持的操作: ".concat(c));throw new a(h.message||y,{originError:h,code:m,requestId:"N/A"})}return function(n){return void 0===n&&(n={}),o(void 0,0,void 0,function(){var o,s,u,h,f,d,p,v,m,g;return i(this,function(i){switch(i.label){case 0:o=l.getUrl,s=l.method,u=l.defaultParams,h=void 0===u?{}:u,f=Object.assign({},h,n),d="pre"===f.envType?"pre":"prod",p=[e,d,o(t)].join("/"),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r({url:p,body:JSON.stringify(f),method:s})];case 2:if((v=i.sent()).code)throw b(null==v?void 0:v.message,t,c,null==v?void 0:v.code,null==v?void 0:v.requestId);return"get"===c&&Object.assign(v,{data:null!==(g=v.data.record)&&void 0!==g?g:v.data}),[2,v];case 3:throw m=i.sent(),new a((null==m?void 0:m.message)||y,{originError:m});case 4:return[2]}})})}}if(!(null==s?void 0:s.sqlBaseUrl)){h=new Error("不支持的操作: ".concat(c));throw new a(h.message||y,{originError:h,code:m,requestId:"N/A"})}return function(e){return o(void 0,0,void 0,function(){var o,u,l,h,f,d,p,v,m,g,w,P,S,O,j,k;return i(this,function(i){switch(i.label){case 0:o=e.params,u=e.templateName,l=e.envType,h="pre"===l?"pre":"prod",f=[s.sqlBaseUrl,h,u,"run"].join("/"),d=Object.entries(o||{}).reduce(function(e,t){var r=t[0],n=t[1];if(void 0!==n){var o="OBJECT";switch(typeof n){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(n)?"ARRAY":"OBJECT"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e},[]),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r({url:f,body:JSON.stringify({parameter:d}),method:"POST"})];case 2:if(p=i.sent(),null===(m=null==p?void 0:p.Response)||void 0===m?void 0:m.Error)throw b(null===(w=null===(g=null==p?void 0:p.Response)||void 0===g?void 0:g.Error)||void 0===w?void 0:w.Message,t,c,null===(S=null===(P=null==p?void 0:p.Response)||void 0===P?void 0:P.Error)||void 0===S?void 0:S.Code,null===(O=null==p?void 0:p.Response)||void 0===O?void 0:O.RequestId);return[2,n(n({},null!==(j=null==p?void 0:p.Response)&&void 0!==j?j:{}),{data:null===(k=null==p?void 0:p.Response)||void 0===k?void 0:k.Data})];case 3:throw v=i.sent(),new a((null==v?void 0:v.message)||y,{originError:v});case 4:return[2]}})})}}});return u},P={create:{methodName:"wedaCreateV2"},createMany:{methodName:"wedaBatchCreateV2"},update:{methodName:"wedaUpdateV2"},upsert:{methodName:"wedaUpsertV2"},updateMany:{methodName:"wedaBatchUpdateV2"},delete:{methodName:"wedaDeleteV2"},deleteMany:{methodName:"wedaBatchDeleteV2"},get:{methodName:"wedaGetItemV2",defaultParams:{filter:{where:{}},select:{$master:!0}}},list:{methodName:"wedaGetRecordsV2",defaultParams:{filter:{where:{}},select:{$master:!0}}}},S=function(e,t){var r=f(e,t);return new Proxy({},{get:function(s,u){if("string"==typeof u)return Object.prototype.hasOwnProperty.call(r,u)?r[u]:function(e,t,r){return new Proxy({},{get:function(s,u){var c=P[u];if(!c){var h=new Error("不支持的操作: ".concat(u));throw new a(h.message||"Unknown error occurred",{originError:h,code:"NotSupported",requestId:"N/A"})}return function(a){return o(void 0,0,void 0,function(){var o,s,h,f,d;return i(this,function(i){switch(i.label){case 0:return o=n(n({},c.defaultParams||{}),a||{}),[4,l({callFunction:t,dataSourceName:e,methodName:c.methodName,realMethodName:u,params:o,envType:null==a?void 0:a.envType,cloud:r})];case 1:return s=i.sent(),h={data:{}},f=c.responseKey,h.data=f?null===(d=null==s?void 0:s.data)||void 0===d?void 0:d[f]:null==s?void 0:s.data,[2,h]}})})}}})}(u,e,t)}})},O=function(){function e(e){var t=this;this.map=new Map,e&&(e instanceof Headers?e.forEach(function(e,r){t.append(r,e)}):Array.isArray(e)?e.forEach(function(e){var r=e[0],n=e[1];t.append(r,n)}):"object"==typeof e&&Object.keys(e).forEach(function(r){t.append(r,e[r])}))}return e.prototype.append=function(e,t){var r=e.toLowerCase(),n=this.map.get(r);n?this.map.set(r,"".concat(n,", ").concat(t)):this.map.set(r,String(t))},e.prototype.delete=function(e){this.map.delete(e.toLowerCase())},e.prototype.forEach=function(e,t){var r=this;this.map.forEach(function(n,o){e.call(t,n,o,r)})},e.prototype.get=function(e){return this.map.get(e.toLowerCase())||null},e.prototype.has=function(e){return this.map.has(e.toLowerCase())},e.prototype.set=function(e,t){this.map.set(e.toLowerCase(),String(t))},e.prototype.entries=function(){return this.map.entries()},e.prototype.keys=function(){return this.map.keys()},e.prototype.values=function(){return this.map.values()},e.prototype.getSetCookie=function(){var e=[];return this.map.forEach(function(t,r){"set-cookie"===r&&e.push(t)}),e},e.prototype.toJSON=function(){var e={};return this.map.forEach(function(t,r){e[r]=t}),e},e.prototype[Symbol.iterator]=function(){return this.entries()},e}();"object"!=typeof globalThis||globalThis.Headers||(globalThis.Headers=O);var j="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function k(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var A,E,T=function(e){try{return!!e()}catch(e){return!0}},R=!T(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}),U=R,x=Function.prototype,q=x.call,C=U&&x.bind.bind(q,q),L=U?C:function(e){return function(){return q.apply(e,arguments)}},I=L,N=I({}.toString),B=I("".slice),F=function(e){return B(N(e),8,-1)},H=T,M=F,_=Object,z=L("".split),D=H(function(){return!_("z").propertyIsEnumerable(0)})?function(e){return"String"===M(e)?z(e,""):_(e)}:_,G=function(e){return null==e},J=G,$=TypeError,V=function(e){if(J(e))throw new $("Can't call method on "+e);return e},K=D,Q=V,W=function(e){return K(Q(e))},Y={},X=function(e){return e&&e.Math===Math&&e},Z=X("object"==typeof globalThis&&globalThis)||X("object"==typeof window&&window)||X("object"==typeof self&&self)||X("object"==typeof j&&j)||X("object"==typeof j&&j)||function(){return this}()||Function("return this")(),ee="object"==typeof document&&document.all,te=void 0===ee&&void 0!==ee?function(e){return"function"==typeof e||e===ee}:function(e){return"function"==typeof e},re=te,ne=Z.WeakMap,oe=re(ne)&&/native code/.test(String(ne)),ie=te,ae=function(e){return"object"==typeof e?null!==e:ie(e)},se=!T(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),ue={},ce=ae,le=Z.document,he=ce(le)&&ce(le.createElement),fe=function(e){return he?le.createElement(e):{}},de=fe,pe=!se&&!T(function(){return 7!==Object.defineProperty(de("div"),"a",{get:function(){return 7}}).a}),ve=se&&T(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),ye=ae,me=String,ge=TypeError,be=function(e){if(ye(e))return e;throw new ge(me(e)+" is not an object")},we=R,Pe=Function.prototype.call,Se=we?Pe.bind(Pe):function(){return Pe.apply(Pe,arguments)},Oe={},je=Oe,ke=Z,Ae=te,Ee=function(e){return Ae(e)?e:void 0},Te=function(e,t){return arguments.length<2?Ee(je[e])||Ee(ke[e]):je[e]&&je[e][t]||ke[e]&&ke[e][t]},Re=L({}.isPrototypeOf),Ue=Z.navigator,xe=Ue&&Ue.userAgent,qe=Z,Ce=xe?String(xe):"",Le=qe.process,Ie=qe.Deno,Ne=Le&&Le.versions||Ie&&Ie.version,Be=Ne&&Ne.v8;Be&&(E=(A=Be.split("."))[0]>0&&A[0]<4?1:+(A[0]+A[1])),!E&&Ce&&(!(A=Ce.match(/Edge\/(\d+)/))||A[1]>=74)&&(A=Ce.match(/Chrome\/(\d+)/))&&(E=+A[1]);var Fe=E,He=T,Me=Z.String,_e=!!Object.getOwnPropertySymbols&&!He(function(){var e=Symbol("symbol detection");return!Me(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Fe&&Fe<41}),ze=_e&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,De=Te,Ge=te,Je=Re,$e=Object,Ve=ze?function(e){return"symbol"==typeof e}:function(e){var t=De("Symbol");return Ge(t)&&Je(t.prototype,$e(e))},Ke=String,Qe=function(e){try{return Ke(e)}catch(e){return"Object"}},We=te,Ye=Qe,Xe=TypeError,Ze=function(e){if(We(e))return e;throw new Xe(Ye(e)+" is not a function")},et=Ze,tt=G,rt=function(e,t){var r=e[t];return tt(r)?void 0:et(r)},nt=Se,ot=te,it=ae,at=TypeError,st={exports:{}},ut=Z,ct=Object.defineProperty,lt=Z,ht=function(e,t){try{ct(ut,e,{value:t,configurable:!0,writable:!0})}catch(r){ut[e]=t}return t},ft="__core-js_shared__",dt=st.exports=lt[ft]||ht(ft,{});(dt.versions||(dt.versions=[])).push({version:"3.45.0",mode:"pure",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.45.0/LICENSE",source:"https://github.com/zloirock/core-js"});var pt=st.exports,vt=pt,yt=function(e,t){return vt[e]||(vt[e]=t||{})},mt=V,gt=Object,bt=function(e){return gt(mt(e))},wt=bt,Pt=L({}.hasOwnProperty),St=Object.hasOwn||function(e,t){return Pt(wt(e),t)},Ot=L,jt=0,kt=Math.random(),At=Ot(1.1.toString),Et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+At(++jt+kt,36)},Tt=yt,Rt=St,Ut=Et,xt=_e,qt=ze,Ct=Z.Symbol,Lt=Tt("wks"),It=qt?Ct.for||Ct:Ct&&Ct.withoutSetter||Ut,Nt=function(e){return Rt(Lt,e)||(Lt[e]=xt&&Rt(Ct,e)?Ct[e]:It("Symbol."+e)),Lt[e]},Bt=Se,Ft=ae,Ht=Ve,Mt=rt,_t=function(e,t){var r,n;if("string"===t&&ot(r=e.toString)&&!it(n=nt(r,e)))return n;if(ot(r=e.valueOf)&&!it(n=nt(r,e)))return n;if("string"!==t&&ot(r=e.toString)&&!it(n=nt(r,e)))return n;throw new at("Can't convert object to primitive value")},zt=TypeError,Dt=Nt("toPrimitive"),Gt=function(e,t){if(!Ft(e)||Ht(e))return e;var r,n=Mt(e,Dt);if(n){if(void 0===t&&(t="default"),r=Bt(n,e,t),!Ft(r)||Ht(r))return r;throw new zt("Can't convert object to primitive value")}return void 0===t&&(t="number"),_t(e,t)},Jt=Ve,$t=function(e){var t=Gt(e,"string");return Jt(t)?t:t+""},Vt=se,Kt=pe,Qt=ve,Wt=be,Yt=$t,Xt=TypeError,Zt=Object.defineProperty,er=Object.getOwnPropertyDescriptor,tr="enumerable",rr="configurable",nr="writable";ue.f=Vt?Qt?function(e,t,r){if(Wt(e),t=Yt(t),Wt(r),"function"==typeof e&&"prototype"===t&&"value"in r&&nr in r&&!r[nr]){var n=er(e,t);n&&n[nr]&&(e[t]=r.value,r={configurable:rr in r?r[rr]:n[rr],enumerable:tr in r?r[tr]:n[tr],writable:!1})}return Zt(e,t,r)}:Zt:function(e,t,r){if(Wt(e),t=Yt(t),Wt(r),Kt)try{return Zt(e,t,r)}catch(e){}if("get"in r||"set"in r)throw new Xt("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var or,ir,ar,sr=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},ur=ue,cr=sr,lr=se?function(e,t,r){return ur.f(e,t,cr(1,r))}:function(e,t,r){return e[t]=r,e},hr=Et,fr=yt("keys"),dr=function(e){return fr[e]||(fr[e]=hr(e))},pr={},vr=oe,yr=Z,mr=ae,gr=lr,br=St,wr=pt,Pr=dr,Sr=pr,Or="Object already initialized",jr=yr.TypeError,kr=yr.WeakMap;if(vr||wr.state){var Ar=wr.state||(wr.state=new kr);Ar.get=Ar.get,Ar.has=Ar.has,Ar.set=Ar.set,or=function(e,t){if(Ar.has(e))throw new jr(Or);return t.facade=e,Ar.set(e,t),t},ir=function(e){return Ar.get(e)||{}},ar=function(e){return Ar.has(e)}}else{var Er=Pr("state");Sr[Er]=!0,or=function(e,t){if(br(e,Er))throw new jr(Or);return t.facade=e,gr(e,Er,t),t},ir=function(e){return br(e,Er)?e[Er]:{}},ar=function(e){return br(e,Er)}}var Tr={set:or,get:ir,has:ar,enforce:function(e){return ar(e)?ir(e):or(e,{})},getterFor:function(e){return function(t){var r;if(!mr(t)||(r=ir(t)).type!==e)throw new jr("Incompatible receiver, "+e+" required");return r}}},Rr=R,Ur=Function.prototype,xr=Ur.apply,qr=Ur.call,Cr="object"==typeof Reflect&&Reflect.apply||(Rr?qr.bind(xr):function(){return qr.apply(xr,arguments)}),Lr=F,Ir=L,Nr=function(e){if("Function"===Lr(e))return Ir(e)},Br={},Fr={},Hr={}.propertyIsEnumerable,Mr=Object.getOwnPropertyDescriptor,_r=Mr&&!Hr.call({1:2},1);Fr.f=_r?function(e){var t=Mr(this,e);return!!t&&t.enumerable}:Hr;var zr=se,Dr=Se,Gr=Fr,Jr=sr,$r=W,Vr=$t,Kr=St,Qr=pe,Wr=Object.getOwnPropertyDescriptor;Br.f=zr?Wr:function(e,t){if(e=$r(e),t=Vr(t),Qr)try{return Wr(e,t)}catch(e){}if(Kr(e,t))return Jr(!Dr(Gr.f,e,t),e[t])};var Yr=T,Xr=te,Zr=/#|\.prototype\./,en=function(e,t){var r=rn[tn(e)];return r===on||r!==nn&&(Xr(t)?Yr(t):!!t)},tn=en.normalize=function(e){return String(e).replace(Zr,".").toLowerCase()},rn=en.data={},nn=en.NATIVE="N",on=en.POLYFILL="P",an=en,sn=Ze,un=R,cn=Nr(Nr.bind),ln=function(e,t){return sn(e),void 0===t?e:un?cn(e,t):function(){return e.apply(t,arguments)}},hn=Z,fn=Cr,dn=Nr,pn=te,vn=Br.f,yn=an,mn=Oe,gn=ln,bn=lr,wn=St,Pn=function(e){var t=function(r,n,o){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,o)}return fn(e,this,arguments)};return t.prototype=e.prototype,t},Sn=function(e,t){var r,n,o,i,a,s,u,c,l,h=e.target,f=e.global,d=e.stat,p=e.proto,v=f?hn:d?hn[h]:hn[h]&&hn[h].prototype,y=f?mn:mn[h]||bn(mn,h,{})[h],m=y.prototype;for(i in t)n=!(r=yn(f?i:h+(d?".":"#")+i,e.forced))&&v&&wn(v,i),s=y[i],n&&(u=e.dontCallGetSet?(l=vn(v,i))&&l.value:v[i]),a=n&&u?u:t[i],(r||p||typeof s!=typeof a)&&(c=e.bind&&n?gn(a,hn):e.wrap&&n?Pn(a):p&&pn(a)?dn(a):a,(e.sham||a&&a.sham||s&&s.sham)&&bn(c,"sham",!0),bn(y,i,c),p&&(wn(mn,o=h+"Prototype")||bn(mn,o,{}),bn(mn[o],i,a),e.real&&m&&(r||!m[i])&&bn(m,i,a)))},On=se,jn=St,kn=Function.prototype,An=On&&Object.getOwnPropertyDescriptor,En=jn(kn,"name"),Tn={EXISTS:En,PROPER:En&&"something"===function(){}.name,CONFIGURABLE:En&&(!On||On&&An(kn,"name").configurable)},Rn={},Un=Math.ceil,xn=Math.floor,qn=Math.trunc||function(e){var t=+e;return(t>0?xn:Un)(t)},Cn=function(e){var t=+e;return t!=t||0===t?0:qn(t)},Ln=Cn,In=Math.max,Nn=Math.min,Bn=function(e,t){var r=Ln(e);return r<0?In(r+t,0):Nn(r,t)},Fn=Cn,Hn=Math.min,Mn=function(e){var t=Fn(e);return t>0?Hn(t,9007199254740991):0},_n=function(e){return Mn(e.length)},zn=W,Dn=Bn,Gn=_n,Jn=function(e){return function(t,r,n){var o=zn(t),i=Gn(o);if(0===i)return!e&&-1;var a,s=Dn(n,i);if(e&&r!=r){for(;i>s;)if((a=o[s++])!=a)return!0}else for(;i>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},$n={includes:Jn(!0),indexOf:Jn(!1)},Vn=St,Kn=W,Qn=$n.indexOf,Wn=pr,Yn=L([].push),Xn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Zn=function(e,t){var r,n=Kn(e),o=0,i=[];for(r in n)!Vn(Wn,r)&&Vn(n,r)&&Yn(i,r);for(;t.length>o;)Vn(n,r=t[o++])&&(~Qn(i,r)||Yn(i,r));return i},eo=Xn,to=Object.keys||function(e){return Zn(e,eo)},ro=se,no=ve,oo=ue,io=be,ao=W,so=to;Rn.f=ro&&!no?Object.defineProperties:function(e,t){io(e);for(var r,n=ao(t),o=so(t),i=o.length,a=0;i>a;)oo.f(e,r=o[a++],n[r]);return e};var uo,co=Te("document","documentElement"),lo=be,ho=Rn,fo=Xn,po=pr,vo=co,yo=fe,mo="prototype",go="script",bo=dr("IE_PROTO"),wo=function(){},Po=function(e){return"<"+go+">"+e+"</"+go+">"},So=function(e){e.write(Po("")),e.close();var t=e.parentWindow.Object;return e=null,t},Oo=function(){try{uo=new ActiveXObject("htmlfile")}catch(e){}var e,t,r;Oo="undefined"!=typeof document?document.domain&&uo?So(uo):(t=yo("iframe"),r="java"+go+":",t.style.display="none",vo.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(Po("document.F=Object")),e.close(),e.F):So(uo);for(var n=fo.length;n--;)delete Oo[mo][fo[n]];return Oo()};po[bo]=!0;var jo,ko,Ao,Eo=Object.create||function(e,t){var r;return null!==e?(wo[mo]=lo(e),r=new wo,wo[mo]=null,r[bo]=e):r=Oo(),void 0===t?r:ho.f(r,t)},To=!T(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),Ro=St,Uo=te,xo=bt,qo=To,Co=dr("IE_PROTO"),Lo=Object,Io=Lo.prototype,No=qo?Lo.getPrototypeOf:function(e){var t=xo(e);if(Ro(t,Co))return t[Co];var r=t.constructor;return Uo(r)&&t instanceof r?r.prototype:t instanceof Lo?Io:null},Bo=lr,Fo=function(e,t,r,n){return n&&n.enumerable?e[t]=r:Bo(e,t,r),e},Ho=T,Mo=te,_o=ae,zo=Eo,Do=No,Go=Fo,Jo=Nt("iterator"),$o=!1;[].keys&&("next"in(Ao=[].keys())?(ko=Do(Do(Ao)))!==Object.prototype&&(jo=ko):$o=!0);var Vo=!_o(jo)||Ho(function(){var e={};return jo[Jo].call(e)!==e});Mo((jo=Vo?{}:zo(jo))[Jo])||Go(jo,Jo,function(){return this});var Ko={IteratorPrototype:jo,BUGGY_SAFARI_ITERATORS:$o},Qo={};Qo[Nt("toStringTag")]="z";var Wo="[object z]"===String(Qo),Yo=Wo,Xo=te,Zo=F,ei=Nt("toStringTag"),ti=Object,ri="Arguments"===Zo(function(){return arguments}()),ni=Yo?Zo:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(e){}}(t=ti(e),ei))?r:ri?Zo(t):"Object"===(n=Zo(t))&&Xo(t.callee)?"Arguments":n},oi=ni,ii=Wo?{}.toString:function(){return"[object "+oi(this)+"]"},ai=Wo,si=ue.f,ui=lr,ci=St,li=ii,hi=Nt("toStringTag"),fi=function(e,t,r,n){var o=r?e:e&&e.prototype;o&&(ci(o,hi)||si(o,hi,{configurable:!0,value:t}),n&&!ai&&ui(o,"toString",li))},di=Ko.IteratorPrototype,pi=Eo,vi=sr,yi=fi,mi=Y,gi=function(){return this},bi=function(e,t,r,n){var o=t+" Iterator";return e.prototype=pi(di,{next:vi(+!n,r)}),yi(e,o,!1,!0),mi[o]=gi,e},wi=Sn,Pi=Se,Si=Tn,Oi=bi,ji=No,ki=fi,Ai=Fo,Ei=Y,Ti=Ko,Ri=Si.PROPER,Ui=Ti.BUGGY_SAFARI_ITERATORS,xi=Nt("iterator"),qi="keys",Ci="values",Li="entries",Ii=function(){return this},Ni=function(e,t,r,n,o,i,a){Oi(r,t,n);var s,u,c,l=function(e){if(e===o&&v)return v;if(!Ui&&e&&e in d)return d[e];switch(e){case qi:case Ci:case Li:return function(){return new r(this,e)}}return function(){return new r(this)}},h=t+" Iterator",f=!1,d=e.prototype,p=d[xi]||d["@@iterator"]||o&&d[o],v=!Ui&&p||l(o),y="Array"===t&&d.entries||p;if(y&&(s=ji(y.call(new e)))!==Object.prototype&&s.next&&(ki(s,h,!0,!0),Ei[h]=Ii),Ri&&o===Ci&&p&&p.name!==Ci&&(f=!0,v=function(){return Pi(p,this)}),o)if(u={values:l(Ci),keys:i?v:l(qi),entries:l(Li)},a)for(c in u)(Ui||f||!(c in d))&&Ai(d,c,u[c]);else wi({target:t,proto:!0,forced:Ui||f},u);return a&&d[xi]!==v&&Ai(d,xi,v,{name:o}),Ei[t]=v,u},Bi=function(e,t){return{value:e,done:t}},Fi=W,Hi=Y,Mi=Tr;ue.f;var _i=Ni,zi=Bi,Di="Array Iterator",Gi=Mi.set,Ji=Mi.getterFor(Di);_i(Array,"Array",function(e,t){Gi(this,{type:Di,target:Fi(e),index:0,kind:t})},function(){var e=Ji(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,zi(void 0,!0);switch(e.kind){case"keys":return zi(r,!1);case"values":return zi(t[r],!1)}return zi([r,t[r]],!1)},"values"),Hi.Arguments=Hi.Array;var $i=Sn,Vi=L,Ki=Bn,Qi=RangeError,Wi=String.fromCharCode,Yi=String.fromCodePoint,Xi=Vi([].join);$i({target:"String",stat:!0,arity:1,forced:!!Yi&&1!==Yi.length},{fromCodePoint:function(e){for(var t,r=[],n=arguments.length,o=0;n>o;){if(t=+arguments[o++],Ki(t,1114111)!==t)throw new Qi(t+" is not a valid code point");r[o]=t<65536?Wi(t):Wi(55296+((t-=65536)>>10),t%1024+56320)}return Xi(r,"")}});var Zi=Z,ea=se,ta=Object.getOwnPropertyDescriptor,ra=T,na=!0,oa=Nt("iterator"),ia=!ra(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",t.forEach(function(e,r){t.delete("b"),n+=r+e}),r.delete("a",2),r.delete("b",void 0),!e.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b")||!t.size&&na||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[oa]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==n||"x"!==new URL("https://x",void 0).host}),aa=ue,sa=function(e,t,r){return aa.f(e,t,r)},ua=Fo,ca=Re,la=TypeError,ha=function(e,t){if(ca(t,e))return e;throw new la("Incorrect invocation")},fa=ni,da=String,pa=function(e){if("Symbol"===fa(e))throw new TypeError("Cannot convert a Symbol value to a string");return da(e)},va=ni,ya=rt,ma=G,ga=Y,ba=Nt("iterator"),wa=function(e){if(!ma(e))return ya(e,ba)||ya(e,"@@iterator")||ga[va(e)]},Pa=Se,Sa=Ze,Oa=be,ja=Qe,ka=wa,Aa=TypeError,Ea=function(e,t){var r=arguments.length<2?ka(e):t;if(Sa(r))return Oa(Pa(r,e));throw new Aa(ja(e)+" is not iterable")},Ta=TypeError,Ra=function(e,t){if(e<t)throw new Ta("Not enough arguments");return e},Ua=L([].slice),xa=Ua,qa=Math.floor,Ca=function(e,t){var r=e.length;if(r<8)for(var n,o,i=1;i<r;){for(o=i,n=e[i];o&&t(e[o-1],n)>0;)e[o]=e[--o];o!==i++&&(e[o]=n)}else for(var a=qa(r/2),s=Ca(xa(e,0,a),t),u=Ca(xa(e,a),t),c=s.length,l=u.length,h=0,f=0;h<c||f<l;)e[h+f]=h<c&&f<l?t(s[h],u[f])<=0?s[h++]:u[f++]:h<c?s[h++]:u[f++];return e},La=Sn,Ia=Z,Na=function(e){if(!ea)return Zi[e];var t=ta(Zi,e);return t&&t.value},Ba=Te,Fa=Se,Ha=L,Ma=se,_a=ia,za=Fo,Da=sa,Ga=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:ua(e,n,t[n],r);return e},Ja=fi,$a=bi,Va=Tr,Ka=ha,Qa=te,Wa=St,Ya=ln,Xa=ni,Za=be,es=ae,ts=pa,rs=Eo,ns=sr,os=Ea,is=wa,as=Bi,ss=Ra,us=Ca,cs=Nt("iterator"),ls="URLSearchParams",hs=ls+"Iterator",fs=Va.set,ds=Va.getterFor(ls),ps=Va.getterFor(hs),vs=Na("fetch"),ys=Na("Request"),ms=Na("Headers"),gs=ys&&ys.prototype,bs=ms&&ms.prototype,ws=Ia.TypeError,Ps=Ia.encodeURIComponent,Ss=String.fromCharCode,Os=Ba("String","fromCodePoint"),js=parseInt,ks=Ha("".charAt),As=Ha([].join),Es=Ha([].push),Ts=Ha("".replace),Rs=Ha([].shift),Us=Ha([].splice),xs=Ha("".split),qs=Ha("".slice),Cs=Ha(/./.exec),Ls=/\+/g,Is=/^[0-9a-f]+$/i,Ns=function(e,t){var r=qs(e,t,t+2);return Cs(Is,r)?js(r,16):NaN},Bs=function(e){for(var t=0,r=128;r>0&&0!==(e&r);r>>=1)t++;return t},Fs=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},Hs=function(e){for(var t=(e=Ts(e,Ls," ")).length,r="",n=0;n<t;){var o=ks(e,n);if("%"===o){if("%"===ks(e,n+1)||n+3>t){r+="%",n++;continue}var i=Ns(e,n+1);if(i!=i){r+=o,n++;continue}n+=2;var a=Bs(i);if(0===a)o=Ss(i);else{if(1===a||a>4){r+="�",n++;continue}for(var s=[i],u=1;u<a&&!(++n+3>t||"%"!==ks(e,n));){var c=Ns(e,n+1);if(c!=c){n+=3;break}if(c>191||c<128)break;Es(s,c),n+=2,u++}if(s.length!==a){r+="�";continue}var l=Fs(s);null===l?r+="�":o=Os(l)}}r+=o,n++}return r},Ms=/[!'()~]|%20/g,_s={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},zs=function(e){return _s[e]},Ds=function(e){return Ts(Ps(e),Ms,zs)},Gs=$a(function(e,t){fs(this,{type:hs,target:ds(e).entries,index:0,kind:t})},ls,function(){var e=ps(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,as(void 0,!0);var n=t[r];switch(e.kind){case"keys":return as(n.key,!1);case"values":return as(n.value,!1)}return as([n.key,n.value],!1)},!0),Js=function(e){this.entries=[],this.url=null,void 0!==e&&(es(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===ks(e,0)?qs(e,1):e:ts(e)))};Js.prototype={type:ls,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,o,i,a,s,u=this.entries,c=is(e);if(c)for(r=(t=os(e,c)).next;!(n=Fa(r,t)).done;){if(i=(o=os(Za(n.value))).next,(a=Fa(i,o)).done||(s=Fa(i,o)).done||!Fa(i,o).done)throw new ws("Expected sequence with length 2");Es(u,{key:ts(a.value),value:ts(s.value)})}else for(var l in e)Wa(e,l)&&Es(u,{key:l,value:ts(e[l])})},parseQuery:function(e){if(e)for(var t,r,n=this.entries,o=xs(e,"&"),i=0;i<o.length;)(t=o[i++]).length&&(r=xs(t,"="),Es(n,{key:Hs(Rs(r)),value:Hs(As(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],Es(r,Ds(e.key)+"="+Ds(e.value));return As(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var $s=function(){Ka(this,Vs);var e=fs(this,new Js(arguments.length>0?arguments[0]:void 0));Ma||(this.size=e.entries.length)},Vs=$s.prototype;if(Ga(Vs,{append:function(e,t){var r=ds(this);ss(arguments.length,2),Es(r.entries,{key:ts(e),value:ts(t)}),Ma||this.length++,r.updateURL()},delete:function(e){for(var t=ds(this),r=ss(arguments.length,1),n=t.entries,o=ts(e),i=r<2?void 0:arguments[1],a=void 0===i?i:ts(i),s=0;s<n.length;){var u=n[s];if(u.key!==o||void 0!==a&&u.value!==a)s++;else if(Us(n,s,1),void 0!==a)break}Ma||(this.size=n.length),t.updateURL()},get:function(e){var t=ds(this).entries;ss(arguments.length,1);for(var r=ts(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){var t=ds(this).entries;ss(arguments.length,1);for(var r=ts(e),n=[],o=0;o<t.length;o++)t[o].key===r&&Es(n,t[o].value);return n},has:function(e){for(var t=ds(this).entries,r=ss(arguments.length,1),n=ts(e),o=r<2?void 0:arguments[1],i=void 0===o?o:ts(o),a=0;a<t.length;){var s=t[a++];if(s.key===n&&(void 0===i||s.value===i))return!0}return!1},set:function(e,t){var r=ds(this);ss(arguments.length,1);for(var n,o=r.entries,i=!1,a=ts(e),s=ts(t),u=0;u<o.length;u++)(n=o[u]).key===a&&(i?Us(o,u--,1):(i=!0,n.value=s));i||Es(o,{key:a,value:s}),Ma||(this.size=o.length),r.updateURL()},sort:function(){var e=ds(this);us(e.entries,function(e,t){return e.key>t.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,r=ds(this).entries,n=Ya(e,arguments.length>1?arguments[1]:void 0),o=0;o<r.length;)n((t=r[o++]).value,t.key,this)},keys:function(){return new Gs(this,"keys")},values:function(){return new Gs(this,"values")},entries:function(){return new Gs(this,"entries")}},{enumerable:!0}),za(Vs,cs,Vs.entries,{name:"entries"}),za(Vs,"toString",function(){return ds(this).serialize()},{enumerable:!0}),Ma&&Da(Vs,"size",{get:function(){return ds(this).entries.length},configurable:!0,enumerable:!0}),Ja($s,ls),La({global:!0,constructor:!0,forced:!_a},{URLSearchParams:$s}),!_a&&Qa(ms)){var Ks=Ha(bs.has),Qs=Ha(bs.set),Ws=function(e){if(es(e)){var t,r=e.body;if(Xa(r)===ls)return t=e.headers?new ms(e.headers):new ms,Ks(t,"content-type")||Qs(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),rs(e,{body:ns(0,ts(r)),headers:ns(0,t)})}return e};if(Qa(vs)&&La({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return vs(e,arguments.length>1?Ws(arguments[1]):{})}}),Qa(ys)){var Ys=function(e){return Ka(this,gs),new ys(e,arguments.length>1?Ws(arguments[1]):{})};gs.constructor=Ys,Ys.prototype=gs,La({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Ys})}}var Xs={URLSearchParams:$s,getState:ds},Zs=L,eu=Cn,tu=pa,ru=V,nu=Zs("".charAt),ou=Zs("".charCodeAt),iu=Zs("".slice),au=function(e){return function(t,r){var n,o,i=tu(ru(t)),a=eu(r),s=i.length;return a<0||a>=s?e?"":void 0:(n=ou(i,a))<55296||n>56319||a+1===s||(o=ou(i,a+1))<56320||o>57343?e?nu(i,a):n:e?iu(i,a,a+2):o-56320+(n-55296<<10)+65536}},su={codeAt:au(!1),charAt:au(!0)},uu=su.charAt,cu=pa,lu=Tr,hu=Ni,fu=Bi,du="String Iterator",pu=lu.set,vu=lu.getterFor(du);hu(String,"String",function(e){pu(this,{type:du,string:cu(e),index:0})},function(){var e,t=vu(this),r=t.string,n=t.index;return n>=r.length?fu(void 0,!0):(e=uu(r,n),t.index+=e.length,fu(e,!1))});var yu={};yu.f=Object.getOwnPropertySymbols;var mu=se,gu=L,bu=Se,wu=T,Pu=to,Su=yu,Ou=Fr,ju=bt,ku=D,Au=Object.assign,Eu=Object.defineProperty,Tu=gu([].concat),Ru=!Au||wu(function(){if(mu&&1!==Au({b:1},Au(Eu({},"a",{enumerable:!0,get:function(){Eu(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach(function(e){t[e]=e}),7!==Au({},e)[r]||Pu(Au({},t)).join("")!==n})?function(e,t){for(var r=ju(e),n=arguments.length,o=1,i=Su.f,a=Ou.f;n>o;)for(var s,u=ku(arguments[o++]),c=i?Tu(Pu(u),i(u)):Pu(u),l=c.length,h=0;l>h;)s=c[h++],mu&&!bu(a,u,s)||(r[s]=u[s]);return r}:Au,Uu=Se,xu=be,qu=rt,Cu=be,Lu=function(e,t,r){var n,o;xu(e);try{if(!(n=qu(e,"return"))){if("throw"===t)throw r;return r}n=Uu(n,e)}catch(e){o=!0,n=e}if("throw"===t)throw r;if(o)throw n;return xu(n),r},Iu=Y,Nu=Nt("iterator"),Bu=Array.prototype,Fu=te,Hu=pt,Mu=L(Function.toString);Fu(Hu.inspectSource)||(Hu.inspectSource=function(e){return Mu(e)});var _u=Hu.inspectSource,zu=L,Du=T,Gu=te,Ju=ni,$u=_u,Vu=function(){},Ku=Te("Reflect","construct"),Qu=/^\s*(?:class|function)\b/,Wu=zu(Qu.exec),Yu=!Qu.test(Vu),Xu=function(e){if(!Gu(e))return!1;try{return Ku(Vu,[],e),!0}catch(e){return!1}},Zu=function(e){if(!Gu(e))return!1;switch(Ju(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Yu||!!Wu(Qu,$u(e))}catch(e){return!0}};Zu.sham=!0;var ec,tc=!Ku||Du(function(){var e;return Xu(Xu.call)||!Xu(Object)||!Xu(function(){e=!0})||e})?Zu:Xu,rc=se,nc=ue,oc=sr,ic=ln,ac=Se,sc=bt,uc=function(e,t,r,n){try{return n?t(Cu(r)[0],r[1]):t(r)}catch(t){Lu(e,"throw",t)}},cc=function(e){return void 0!==e&&(Iu.Array===e||Bu[Nu]===e)},lc=tc,hc=_n,fc=function(e,t,r){rc?nc.f(e,t,oc(0,r)):e[t]=r},dc=Ea,pc=wa,vc=Array,yc=L,mc=2147483647,gc=/[^\0-\u007E]/,bc=/[.\u3002\uFF0E\uFF61]/g,wc="Overflow: input needs wider integers to process",Pc=RangeError,Sc=yc(bc.exec),Oc=Math.floor,jc=String.fromCharCode,kc=yc("".charCodeAt),Ac=yc([].join),Ec=yc([].push),Tc=yc("".replace),Rc=yc("".split),Uc=yc("".toLowerCase),xc=function(e){return e+22+75*(e<26)},qc=function(e,t,r){var n=0;for(e=r?Oc(e/700):e>>1,e+=Oc(e/t);e>455;)e=Oc(e/35),n+=36;return Oc(n+36*e/(e+38))},Cc=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var o=kc(e,r++);if(o>=55296&&o<=56319&&r<n){var i=kc(e,r++);56320==(64512&i)?Ec(t,((1023&o)<<10)+(1023&i)+65536):(Ec(t,o),r--)}else Ec(t,o)}return t}(e);var r,n,o=e.length,i=128,a=0,s=72;for(r=0;r<e.length;r++)(n=e[r])<128&&Ec(t,jc(n));var u=t.length,c=u;for(u&&Ec(t,"-");c<o;){var l=mc;for(r=0;r<e.length;r++)(n=e[r])>=i&&n<l&&(l=n);var h=c+1;if(l-i>Oc((mc-a)/h))throw new Pc(wc);for(a+=(l-i)*h,i=l,r=0;r<e.length;r++){if((n=e[r])<i&&++a>mc)throw new Pc(wc);if(n===i){for(var f=a,d=36;;){var p=d<=s?1:d>=s+26?26:d-s;if(f<p)break;var v=f-p,y=36-p;Ec(t,jc(xc(p+v%y))),f=Oc(v/y),d+=36}Ec(t,jc(xc(f))),s=qc(a,h,c===u),a=0,c++}}a++,i++}return Ac(t,"")},Lc=Sn,Ic=se,Nc=ia,Bc=Z,Fc=ln,Hc=L,Mc=Fo,_c=sa,zc=ha,Dc=St,Gc=Ru,Jc=function(e){var t=sc(e),r=lc(this),n=arguments.length,o=n>1?arguments[1]:void 0,i=void 0!==o;i&&(o=ic(o,n>2?arguments[2]:void 0));var a,s,u,c,l,h,f=pc(t),d=0;if(!f||this===vc&&cc(f))for(a=hc(t),s=r?new this(a):vc(a);a>d;d++)h=i?o(t[d],d):t[d],fc(s,d,h);else for(s=r?new this:[],l=(c=dc(t,f)).next;!(u=ac(l,c)).done;d++)h=i?uc(c,o,[u.value,d],!0):u.value,fc(s,d,h);return s.length=d,s},$c=Ua,Vc=su.codeAt,Kc=function(e){var t,r,n=[],o=Rc(Tc(Uc(e),bc,"."),".");for(t=0;t<o.length;t++)r=o[t],Ec(n,Sc(gc,r)?"xn--"+Cc(r):r);return Ac(n,".")},Qc=pa,Wc=fi,Yc=Ra,Xc=Xs,Zc=Tr,el=Zc.set,tl=Zc.getterFor("URL"),rl=Xc.URLSearchParams,nl=Xc.getState,ol=Bc.URL,il=Bc.TypeError,al=Bc.parseInt,sl=Math.floor,ul=Math.pow,cl=Hc("".charAt),ll=Hc(/./.exec),hl=Hc([].join),fl=Hc(1.1.toString),dl=Hc([].pop),pl=Hc([].push),vl=Hc("".replace),yl=Hc([].shift),ml=Hc("".split),gl=Hc("".slice),bl=Hc("".toLowerCase),wl=Hc([].unshift),Pl="Invalid scheme",Sl="Invalid host",Ol="Invalid port",jl=/[a-z]/i,kl=/[\d+-.a-z]/i,Al=/\d/,El=/^0x/i,Tl=/^[0-7]+$/,Rl=/^\d+$/,Ul=/^[\da-f]+$/i,xl=/[\0\t\n\r #%/:<>?@[\\\]^|]/,ql=/[\0\t\n\r #/:<>?@[\\\]^|]/,Cl=/^[\u0000-\u0020]+/,Ll=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,Il=/[\t\n\r]/g,Nl=function(e){var t,r,n,o;if("number"==typeof e){for(t=[],r=0;r<4;r++)wl(t,e%256),e=sl(e/256);return hl(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,o=0,i=0;i<8;i++)0!==e[i]?(o>r&&(t=n,r=o),n=null,o=0):(null===n&&(n=i),++o);return o>r?n:t}(e),r=0;r<8;r++)o&&0===e[r]||(o&&(o=!1),n===r?(t+=r?":":"::",o=!0):(t+=fl(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},Bl={},Fl=Gc({},Bl,{" ":1,'"':1,"<":1,">":1,"`":1}),Hl=Gc({},Fl,{"#":1,"?":1,"{":1,"}":1}),Ml=Gc({},Hl,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),_l=function(e,t){var r=Vc(e,0);return r>32&&r<127&&!Dc(t,e)?e:encodeURIComponent(e)},zl={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Dl=function(e,t){var r;return 2===e.length&&ll(jl,cl(e,0))&&(":"===(r=cl(e,1))||!t&&"|"===r)},Gl=function(e){var t;return e.length>1&&Dl(gl(e,0,2))&&(2===e.length||"/"===(t=cl(e,2))||"\\"===t||"?"===t||"#"===t)},Jl=function(e){return"."===e||"%2e"===bl(e)},$l=function(e){return".."===(e=bl(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},Vl={},Kl={},Ql={},Wl={},Yl={},Xl={},Zl={},eh={},th={},rh={},nh={},oh={},ih={},ah={},sh={},uh={},ch={},lh={},hh={},fh={},dh={},ph=function(e,t,r){var n,o,i,a=Qc(e);if(t){if(o=this.parse(a))throw new il(o);this.searchParams=null}else{if(void 0!==r&&(n=new ph(r,!0)),o=this.parse(a,null,n))throw new il(o);(i=nl(new rl)).bindURL(this),this.searchParams=i}};ph.prototype={type:"URL",parse:function(e,t,r){var n,o,i,a,s=this,u=t||Vl,c=0,l="",h=!1,f=!1,d=!1;for(e=Qc(e),t||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,e=vl(e,Cl,""),e=vl(e,Ll,"$1")),e=vl(e,Il,""),n=Jc(e);c<=n.length;){switch(o=n[c],u){case Vl:if(!o||!ll(jl,o)){if(t)return Pl;u=Ql;continue}l+=bl(o),u=Kl;break;case Kl:if(o&&(ll(kl,o)||"+"===o||"-"===o||"."===o))l+=bl(o);else{if(":"!==o){if(t)return Pl;l="",u=Ql,c=0;continue}if(t&&(s.isSpecial()!==Dc(zl,l)||"file"===l&&(s.includesCredentials()||null!==s.port)||"file"===s.scheme&&!s.host))return;if(s.scheme=l,t)return void(s.isSpecial()&&zl[s.scheme]===s.port&&(s.port=null));l="","file"===s.scheme?u=ah:s.isSpecial()&&r&&r.scheme===s.scheme?u=Wl:s.isSpecial()?u=eh:"/"===n[c+1]?(u=Yl,c++):(s.cannotBeABaseURL=!0,pl(s.path,""),u=hh)}break;case Ql:if(!r||r.cannotBeABaseURL&&"#"!==o)return Pl;if(r.cannotBeABaseURL&&"#"===o){s.scheme=r.scheme,s.path=$c(r.path),s.query=r.query,s.fragment="",s.cannotBeABaseURL=!0,u=dh;break}u="file"===r.scheme?ah:Xl;continue;case Wl:if("/"!==o||"/"!==n[c+1]){u=Xl;continue}u=th,c++;break;case Yl:if("/"===o){u=rh;break}u=lh;continue;case Xl:if(s.scheme=r.scheme,o===ec)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=$c(r.path),s.query=r.query;else if("/"===o||"\\"===o&&s.isSpecial())u=Zl;else if("?"===o)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=$c(r.path),s.query="",u=fh;else{if("#"!==o){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=$c(r.path),s.path.length--,u=lh;continue}s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=$c(r.path),s.query=r.query,s.fragment="",u=dh}break;case Zl:if(!s.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,u=lh;continue}u=rh}else u=th;break;case eh:if(u=th,"/"!==o||"/"!==cl(l,c+1))continue;c++;break;case th:if("/"!==o&&"\\"!==o){u=rh;continue}break;case rh:if("@"===o){h&&(l="%40"+l),h=!0,i=Jc(l);for(var p=0;p<i.length;p++){var v=i[p];if(":"!==v||d){var y=_l(v,Ml);d?s.password+=y:s.username+=y}else d=!0}l=""}else if(o===ec||"/"===o||"?"===o||"#"===o||"\\"===o&&s.isSpecial()){if(h&&""===l)return"Invalid authority";c-=Jc(l).length+1,l="",u=nh}else l+=o;break;case nh:case oh:if(t&&"file"===s.scheme){u=uh;continue}if(":"!==o||f){if(o===ec||"/"===o||"?"===o||"#"===o||"\\"===o&&s.isSpecial()){if(s.isSpecial()&&""===l)return Sl;if(t&&""===l&&(s.includesCredentials()||null!==s.port))return;if(a=s.parseHost(l))return a;if(l="",u=ch,t)return;continue}"["===o?f=!0:"]"===o&&(f=!1),l+=o}else{if(""===l)return Sl;if(a=s.parseHost(l))return a;if(l="",u=ih,t===oh)return}break;case ih:if(!ll(Al,o)){if(o===ec||"/"===o||"?"===o||"#"===o||"\\"===o&&s.isSpecial()||t){if(""!==l){var m=al(l,10);if(m>65535)return Ol;s.port=s.isSpecial()&&m===zl[s.scheme]?null:m,l=""}if(t)return;u=ch;continue}return Ol}l+=o;break;case ah:if(s.scheme="file","/"===o||"\\"===o)u=sh;else{if(!r||"file"!==r.scheme){u=lh;continue}switch(o){case ec:s.host=r.host,s.path=$c(r.path),s.query=r.query;break;case"?":s.host=r.host,s.path=$c(r.path),s.query="",u=fh;break;case"#":s.host=r.host,s.path=$c(r.path),s.query=r.query,s.fragment="",u=dh;break;default:Gl(hl($c(n,c),""))||(s.host=r.host,s.path=$c(r.path),s.shortenPath()),u=lh;continue}}break;case sh:if("/"===o||"\\"===o){u=uh;break}r&&"file"===r.scheme&&!Gl(hl($c(n,c),""))&&(Dl(r.path[0],!0)?pl(s.path,r.path[0]):s.host=r.host),u=lh;continue;case uh:if(o===ec||"/"===o||"\\"===o||"?"===o||"#"===o){if(!t&&Dl(l))u=lh;else if(""===l){if(s.host="",t)return;u=ch}else{if(a=s.parseHost(l))return a;if("localhost"===s.host&&(s.host=""),t)return;l="",u=ch}continue}l+=o;break;case ch:if(s.isSpecial()){if(u=lh,"/"!==o&&"\\"!==o)continue}else if(t||"?"!==o)if(t||"#"!==o){if(o!==ec&&(u=lh,"/"!==o))continue}else s.fragment="",u=dh;else s.query="",u=fh;break;case lh:if(o===ec||"/"===o||"\\"===o&&s.isSpecial()||!t&&("?"===o||"#"===o)){if($l(l)?(s.shortenPath(),"/"===o||"\\"===o&&s.isSpecial()||pl(s.path,"")):Jl(l)?"/"===o||"\\"===o&&s.isSpecial()||pl(s.path,""):("file"===s.scheme&&!s.path.length&&Dl(l)&&(s.host&&(s.host=""),l=cl(l,0)+":"),pl(s.path,l)),l="","file"===s.scheme&&(o===ec||"?"===o||"#"===o))for(;s.path.length>1&&""===s.path[0];)yl(s.path);"?"===o?(s.query="",u=fh):"#"===o&&(s.fragment="",u=dh)}else l+=_l(o,Hl);break;case hh:"?"===o?(s.query="",u=fh):"#"===o?(s.fragment="",u=dh):o!==ec&&(s.path[0]+=_l(o,Bl));break;case fh:t||"#"!==o?o!==ec&&("'"===o&&s.isSpecial()?s.query+="%27":s.query+="#"===o?"%23":_l(o,Bl)):(s.fragment="",u=dh);break;case dh:o!==ec&&(s.fragment+=_l(o,Fl))}c++}},parseHost:function(e){var t,r,n;if("["===cl(e,0)){if("]"!==cl(e,e.length-1))return Sl;if(t=function(e){var t,r,n,o,i,a,s,u=[0,0,0,0,0,0,0,0],c=0,l=null,h=0,f=function(){return cl(e,h)};if(":"===f()){if(":"!==cl(e,1))return;h+=2,l=++c}for(;f();){if(8===c)return;if(":"!==f()){for(t=r=0;r<4&&ll(Ul,f());)t=16*t+al(f(),16),h++,r++;if("."===f()){if(0===r)return;if(h-=r,c>6)return;for(n=0;f();){if(o=null,n>0){if(!("."===f()&&n<4))return;h++}if(!ll(Al,f()))return;for(;ll(Al,f());){if(i=al(f(),10),null===o)o=i;else{if(0===o)return;o=10*o+i}if(o>255)return;h++}u[c]=256*u[c]+o,2!==++n&&4!==n||c++}if(4!==n)return;break}if(":"===f()){if(h++,!f())return}else if(f())return;u[c++]=t}else{if(null!==l)return;h++,l=++c}}if(null!==l)for(a=c-l,c=7;0!==c&&a>0;)s=u[c],u[c--]=u[l+a-1],u[l+--a]=s;else if(8!==c)return;return u}(gl(e,1,-1)),!t)return Sl;this.host=t}else if(this.isSpecial()){if(e=Kc(e),ll(xl,e))return Sl;if(t=function(e){var t,r,n,o,i,a,s,u=ml(e,".");if(u.length&&""===u[u.length-1]&&u.length--,(t=u.length)>4)return e;for(r=[],n=0;n<t;n++){if(""===(o=u[n]))return e;if(i=10,o.length>1&&"0"===cl(o,0)&&(i=ll(El,o)?16:8,o=gl(o,8===i?1:2)),""===o)a=0;else{if(!ll(10===i?Rl:8===i?Tl:Ul,o))return e;a=al(o,i)}pl(r,a)}for(n=0;n<t;n++)if(a=r[n],n===t-1){if(a>=ul(256,5-t))return null}else if(a>255)return null;for(s=dl(r),n=0;n<r.length;n++)s+=r[n]*ul(256,3-n);return s}(e),null===t)return Sl;this.host=t}else{if(ll(ql,e))return Sl;for(t="",r=Jc(e),n=0;n<r.length;n++)t+=_l(r[n],Bl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return Dc(zl,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&Dl(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,o=e.host,i=e.port,a=e.path,s=e.query,u=e.fragment,c=t+":";return null!==o?(c+="//",e.includesCredentials()&&(c+=r+(n?":"+n:"")+"@"),c+=Nl(o),null!==i&&(c+=":"+i)):"file"===t&&(c+="//"),c+=e.cannotBeABaseURL?a[0]:a.length?"/"+hl(a,"/"):"",null!==s&&(c+="?"+s),null!==u&&(c+="#"+u),c},setHref:function(e){var t=this.parse(e);if(t)throw new il(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new vh(e.path[0]).origin}catch(e){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+Nl(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Qc(e)+":",Vl)},getUsername:function(){return this.username},setUsername:function(e){var t=Jc(Qc(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=_l(t[r],Ml)}},getPassword:function(){return this.password},setPassword:function(e){var t=Jc(Qc(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=_l(t[r],Ml)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?Nl(e):Nl(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,nh)},getHostname:function(){var e=this.host;return null===e?"":Nl(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,oh)},getPort:function(){var e=this.port;return null===e?"":Qc(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=Qc(e))?this.port=null:this.parse(e,ih))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+hl(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,ch))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=Qc(e))?this.query=null:("?"===cl(e,0)&&(e=gl(e,1)),this.query="",this.parse(e,fh)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=Qc(e))?("#"===cl(e,0)&&(e=gl(e,1)),this.fragment="",this.parse(e,dh)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var vh=function(e){var t=zc(this,yh),r=Yc(arguments.length,1)>1?arguments[1]:void 0,n=el(t,new ph(e,!1,r));Ic||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},yh=vh.prototype,mh=function(e,t){return{get:function(){return tl(this)[e]()},set:t&&function(e){return tl(this)[t](e)},configurable:!0,enumerable:!0}};if(Ic&&(_c(yh,"href",mh("serialize","setHref")),_c(yh,"origin",mh("getOrigin")),_c(yh,"protocol",mh("getProtocol","setProtocol")),_c(yh,"username",mh("getUsername","setUsername")),_c(yh,"password",mh("getPassword","setPassword")),_c(yh,"host",mh("getHost","setHost")),_c(yh,"hostname",mh("getHostname","setHostname")),_c(yh,"port",mh("getPort","setPort")),_c(yh,"pathname",mh("getPathname","setPathname")),_c(yh,"search",mh("getSearch","setSearch")),_c(yh,"searchParams",mh("getSearchParams")),_c(yh,"hash",mh("getHash","setHash"))),Mc(yh,"toJSON",function(){return tl(this).serialize()},{enumerable:!0}),Mc(yh,"toString",function(){return tl(this).serialize()},{enumerable:!0}),ol){var gh=ol.createObjectURL,bh=ol.revokeObjectURL;gh&&Mc(vh,"createObjectURL",Fc(gh,ol)),bh&&Mc(vh,"revokeObjectURL",Fc(bh,ol))}Wc(vh,"URL"),Lc({global:!0,constructor:!0,forced:!Nc,sham:!Ic},{URL:vh});var wh=Sn,Ph=T,Sh=Ra,Oh=pa,jh=ia,kh=Te("URL"),Ah=jh&&Ph(function(){kh.canParse()}),Eh=Ph(function(){return 1!==kh.canParse.length});wh({target:"URL",stat:!0,forced:!Ah||Eh},{canParse:function(e){var t=Sh(arguments.length,1),r=Oh(e),n=t<2||void 0===arguments[1]?void 0:Oh(arguments[1]);try{return!!new kh(r,n)}catch(e){return!1}}});var Th=Sn,Rh=Ra,Uh=pa,xh=ia,qh=Te("URL");Th({target:"URL",stat:!0,forced:!xh},{parse:function(e){var t=Rh(arguments.length,1),r=Uh(e),n=t<2||void 0===arguments[1]?void 0:Uh(arguments[1]);try{return new qh(r,n)}catch(e){return null}}});var Ch=k(Oe.URL),Lh=function(e){function t(t){var r=e.call(this,t.message)||this;return r.name="PostgrestError",r.details=t.details,r.hint=t.hint,r.code=t.code,r}return r(t,e),t}(Error),Ih=function(){function e(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!==(t=e.shouldThrowOnError)&&void 0!==t&&t,this.signal=e.signal,this.isMaybeSingle=null!==(r=e.isMaybeSingle)&&void 0!==r&&r,e.fetch?this.fetch=e.fetch:this.fetch=fetch}return e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.setHeader=function(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this},e.prototype.then=function(e,t){var r=this;void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json");var n=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(function(e){return o(r,0,void 0,function(){var t,r,n,o,a,s,u,c,l,h,f,d;return i(this,function(i){switch(i.label){case 0:return t=null,r=null,n=null,o=e.status,a=e.statusText,e.ok?"HEAD"===this.method?[3,2]:[4,e.text()]:[3,3];case 1:""===(c=i.sent())||(r="text/csv"===this.headers.get("Accept")||this.headers.get("Accept")&&(null===(l=this.headers.get("Accept"))||void 0===l?void 0:l.includes("application/vnd.pgrst.plan+text"))?c:JSON.parse(c)),i.label=2;case 2:return s=null===(h=this.headers.get("Prefer"))||void 0===h?void 0:h.match(/count=(exact|planned|estimated)/),u=null===(f=e.headers.get("content-range"))||void 0===f?void 0:f.split("/"),s&&u&&u.length>1&&(n=parseInt(u[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(r)&&(r.length>1?(t={code:"PGRST116",details:"Results contain ".concat(r.length," rows, application/vnd.pgrst.object+json requires 1 row"),hint:null,message:"JSON object requested, multiple (or no) rows returned"},r=null,n=null,o=406,a="Not Acceptable"):r=1===r.length?r[0]:null),[3,5];case 3:return[4,e.text()];case 4:c=i.sent();try{t=JSON.parse(c),Array.isArray(t)&&404===e.status&&(r=[],t=null,o=200,a="OK")}catch(r){404===e.status&&""===c?(o=204,a="No Content"):t={message:c}}if(t&&this.isMaybeSingle&&(null===(d=null==t?void 0:t.details)||void 0===d?void 0:d.includes("0 rows"))&&(t=null,o=200,a="OK"),t&&this.shouldThrowOnError)throw new Lh(t);i.label=5;case 5:return[2,{error:t,data:r,count:n,status:o,statusText:a}]}})})});return this.shouldThrowOnError||(n=n.catch(function(e){var t,r,n;return{error:{message:"".concat(null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError",": ").concat(null==e?void 0:e.message),details:"".concat(null!==(r=null==e?void 0:e.stack)&&void 0!==r?r:""),hint:"",code:"".concat(null!==(n=null==e?void 0:e.code)&&void 0!==n?n:"")},data:null,count:null,status:0,statusText:""}})),n.then(e,t)},e.prototype.returns=function(){return this},e.prototype.overrideTypes=function(){return this},e}(),Nh=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.select=function(e){var t=!1,r=(null!=e?e:"*").split("").map(function(e){return/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)}).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this},t.prototype.order=function(e,t){var r=void 0===t?{}:t,n=r.ascending,o=void 0===n||n,i=r.nullsFirst,a=r.foreignTable,s=r.referencedTable,u=void 0===s?a:s,c=u?"".concat(u,".order"):"order",l=this.url.searchParams.get(c);return this.url.searchParams.set(c,"".concat(l?"".concat(l,","):"").concat(e,".").concat(o?"asc":"desc").concat(void 0===i?"":i?".nullsfirst":".nullslast")),this},t.prototype.limit=function(e,t){var r=void 0===t?{}:t,n=r.foreignTable,o=r.referencedTable,i=void 0===o?n:o,a=void 0===i?"limit":"".concat(i,".limit");return this.url.searchParams.set(a,"".concat(e)),this},t.prototype.range=function(e,t,r){var n=void 0===r?{}:r,o=n.foreignTable,i=n.referencedTable,a=void 0===i?o:i,s=void 0===a?"offset":"".concat(a,".offset"),u=void 0===a?"limit":"".concat(a,".limit");return this.url.searchParams.set(s,"".concat(e)),this.url.searchParams.set(u,"".concat(t-e+1)),this},t.prototype.abortSignal=function(e){return this.signal=e,this},t.prototype.single=function(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this},t.prototype.maybeSingle=function(){return"GET"===this.method?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this},t.prototype.csv=function(){return this.headers.set("Accept","text/csv"),this},t.prototype.geojson=function(){return this.headers.set("Accept","application/geo+json"),this},t.prototype.explain=function(e){var t,r=void 0===e?{}:e,n=r.analyze,o=void 0!==n&&n,i=r.verbose,a=void 0!==i&&i,s=r.settings,u=void 0!==s&&s,c=r.buffers,l=void 0!==c&&c,h=r.wal,f=void 0!==h&&h,d=r.format,p=void 0===d?"text":d,v=[o?"analyze":null,a?"verbose":null,u?"settings":null,l?"buffers":null,f?"wal":null].filter(Boolean).join("|"),y=null!==(t=this.headers.get("Accept"))&&void 0!==t?t:"application/json";return this.headers.set("Accept","application/vnd.pgrst.plan+".concat(p,'; for="').concat(y,'"; options=').concat(v,";")),this},t.prototype.rollback=function(){return this.headers.append("Prefer","tx=rollback"),this},t.prototype.returns=function(){return this},t.prototype.maxAffected=function(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer","max-affected=".concat(e)),this},t}(Ih),Bh=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.eq=function(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this},t.prototype.neq=function(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this},t.prototype.gt=function(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this},t.prototype.gte=function(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this},t.prototype.lt=function(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this},t.prototype.lte=function(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this},t.prototype.like=function(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this},t.prototype.likeAllOf=function(e,t){return this.url.searchParams.append(e,"like(all).{".concat(t.join(","),"}")),this},t.prototype.likeAnyOf=function(e,t){return this.url.searchParams.append(e,"like(any).{".concat(t.join(","),"}")),this},t.prototype.ilike=function(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this},t.prototype.ilikeAllOf=function(e,t){return this.url.searchParams.append(e,"ilike(all).{".concat(t.join(","),"}")),this},t.prototype.ilikeAnyOf=function(e,t){return this.url.searchParams.append(e,"ilike(any).{".concat(t.join(","),"}")),this},t.prototype.is=function(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this},t.prototype.in=function(e,t){var r=Array.from(new Set(t)).map(function(e){return"string"==typeof e&&new RegExp("[,()]").test(e)?'"'.concat(e,'"'):"".concat(e)}).join(",");return this.url.searchParams.append(e,"in.(".concat(r,")")),this},t.prototype.contains=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this},t.prototype.containedBy=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this},t.prototype.rangeGt=function(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this},t.prototype.rangeGte=function(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this},t.prototype.rangeLt=function(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this},t.prototype.rangeLte=function(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this},t.prototype.rangeAdjacent=function(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this},t.prototype.overlaps=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this},t.prototype.textSearch=function(e,t,r){var n=void 0===r?{}:r,o=n.config,i=n.type,a="";"plain"===i?a="pl":"phrase"===i?a="ph":"websearch"===i&&(a="w");var s=void 0===o?"":"(".concat(o,")");return this.url.searchParams.append(e,"".concat(a,"fts").concat(s,".").concat(t)),this},t.prototype.match=function(e){var t=this;return Object.entries(e).forEach(function(e){var r=e[0],n=e[1];t.url.searchParams.append(r,"eq.".concat(n))}),this},t.prototype.not=function(e,t,r){return this.url.searchParams.append(e,"not.".concat(t,".").concat(r)),this},t.prototype.or=function(e,t){var r=void 0===t?{}:t,n=r.foreignTable,o=r.referencedTable,i=void 0===o?n:o,a=i?"".concat(i,".or"):"or";return this.url.searchParams.append(a,"(".concat(e,")")),this},t.prototype.filter=function(e,t,r){return this.url.searchParams.append(e,"".concat(t,".").concat(r)),this},t}(Nh),Fh=function(){function e(e,t){var r=t.headers,n=void 0===r?{}:r,o=t.schema,i=t.fetch;this.url=e,this.headers=new Headers(n),this.schema=o,this.fetch=i}return e.prototype.select=function(e,t){var r=void 0===t?{}:t,n=r.head,o=void 0!==n&&n,i=r.count,a=o?"HEAD":"GET",s=!1,u=(null!=e?e:"*").split("").map(function(e){return/\s/.test(e)&&!s?"":('"'===e&&(s=!s),e)}).join("");return this.url.searchParams.set("select",u),i&&this.headers.append("Prefer","count=".concat(i)),new Bh({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})},e.prototype.insert=function(e,t){var r,n=void 0===t?{}:t,o=n.count,i=n.defaultToNull,a=void 0===i||i;if(o&&this.headers.append("Prefer","count=".concat(o)),a||this.headers.append("Prefer","missing=default"),Array.isArray(e)){var s=e.reduce(function(e,t){return e.concat(Object.keys(t))},[]);if(s.length>0){var u=Array.from(new Set(s)).map(function(e){return'"'.concat(e,'"')});this.url.searchParams.set("columns",u.join(","))}}return new Bh({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.upsert=function(e,t){var r,n=void 0===t?{}:t,o=n.onConflict,i=n.ignoreDuplicates,a=void 0!==i&&i,s=n.count,u=n.defaultToNull,c=void 0===u||u;if(this.headers.append("Prefer","resolution=".concat(a?"ignore":"merge","-duplicates")),void 0!==o&&this.url.searchParams.set("on_conflict",o),s&&this.headers.append("Prefer","count=".concat(s)),c||this.headers.append("Prefer","missing=default"),Array.isArray(e)){var l=e.reduce(function(e,t){return e.concat(Object.keys(t))},[]);if(l.length>0){var h=Array.from(new Set(l)).map(function(e){return'"'.concat(e,'"')});this.url.searchParams.set("columns",h.join(","))}}return new Bh({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.update=function(e,t){var r,n=(void 0===t?{}:t).count;return n&&this.headers.append("Prefer","count=".concat(n)),new Bh({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.delete=function(e){var t,r=(void 0===e?{}:e).count;return r&&this.headers.append("Prefer","count=".concat(r)),new Bh({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch})},e}(),Hh=function(e){function t(t,r){var n=r.headers,o=void 0===n?{}:n,i=r.fetch;return e.call(this,t,{headers:o,schema:void 0,fetch:i})||this}return r(t,e),t}(Fh),Mh=function(){function e(e,t){var r=void 0===t?{}:t,n=r.headers,o=void 0===n?{}:n,i=r.fetch;this.url=e,this.headers=new Headers(o),this.fetch=i}return e.prototype.from=function(e){var t=new Ch("".concat(this.url,"/").concat(e));return new Hh(t,{headers:this.headers,fetch:this.fetch})},e}();function _h(e,t){if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var r=e.callFunction.bind(e);return e.models=S(r,e),e.mysql=zh(e,{envId:null==t?void 0:t.envId}),e.rdb=zh(e,{envId:null==t?void 0:t.envId}),e}function zh(e,t){var r=null==t?void 0:t.envId,a=(null==t?void 0:t.mysqlBaseUrl)||Dh(e,null==t?void 0:t.envId).mysql,s=null==t?void 0:t.fetch;return function(t){var u=this;return new Mh(a,{fetch:s||function(a,s){return o(u,0,void 0,function(){var o,u,l,h;return i(this,function(i){switch(i.label){case 0:return o=(null==t?void 0:t.instance)||"default",u=(null==t?void 0:t.database)||r,l={},(null==s?void 0:s.headers)instanceof Headers?s.headers.forEach(function(e,t){l[t]=e}):l=(null==s?void 0:s.headers)||{},[4,c(e)];case 1:return h=i.sent(),[2,e.callFunction({name:"httpOverCallFunction",data:{url:a.toString(),method:(null==s?void 0:s.method)||"GET",headers:n(n(n({},h?{Authorization:"Bearer ".concat(h)}:{}),l||{}),{"Content-Type":"application/json","X-Db-Instance":o,"Accept-Profile":u,"Content-Profile":u}),body:null==s?void 0:s.body}}).then(function(e){var t=null==e?void 0:e.result;return{ok:(null==t?void 0:t.statusCode)>=200&&(null==t?void 0:t.statusCode)<300,status:(null==t?void 0:t.statusCode)||200,statusText:(null==t?void 0:t.statusMessage)||"OK",json:function(){return Promise.resolve((null==t?void 0:t.body)||{})},text:function(){return Promise.resolve("string"==typeof(null==t?void 0:t.body)?t.body:JSON.stringify((null==t?void 0:t.body)||{}))},headers:new Headers((null==t?void 0:t.headers)||{})}})]}})})}})}}function Dh(e,t){var r=function(e,t){var r,n,o,i,a=t||(null===(n=null===(r=null==e?void 0:e.extend)||void 0===r?void 0:r.AI)||void 0===n?void 0:n.env);return"string"==typeof a&&a.trim()||(a=null===(o=null==e?void 0:e.config)||void 0===o?void 0:o.env),"string"==typeof a&&a.trim()||(a=null===(i=null==e?void 0:e.config)||void 0===i?void 0:i.envName),"string"==typeof a&&a.trim()?a.trim():""}(e,t);if(!r)throw new Error("Generating default gateway base url failed: env not found");return{model:"https://".concat(r,".api.tcloudbasegateway.com/v1/model"),sql:"https://".concat(r,".api.tcloudbasegateway.com/v1/sql"),mysql:"https://".concat(r,".api.tcloudbasegateway.com/v1/rdb/rest")}}var Gh={init:_h,generateHTTPClient:g,generateMySQLClient:zh};e.default=Gh,e.generateHTTPClient=g,e.generateMySQLClient=zh,e.getAccessToken=c,e.init=_h,e.initHTTPOverCallFunction=function(e,t){var r=this;if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var a,s=e.callFunction.bind(e);try{var u=(null==t?void 0:t.baseUrl)||Dh(e,null==t?void 0:t.envId).model,l=(null==t?void 0:t.sqlBaseUrl)||Dh(e,null==t?void 0:t.envId).sql;a=g(s,function(t){var a=t.url,u=t.body,l=t.method,h=t.headers;return o(r,0,void 0,function(){var t,r,o;return i(this,function(i){switch(i.label){case 0:return[4,c(e)];case 1:return t=i.sent(),[4,s({name:"httpOverCallFunction",data:{url:a,method:null==l?void 0:l.toUpperCase(),headers:n(n(n({},t?{Authorization:"Bearer ".concat(t)}:{}),h||{}),{"Content-Type":"application/json"}),body:u}})];case 2:return r=i.sent(),[2,null===(o=null==r?void 0:r.result)||void 0===o?void 0:o.body]}})})},u,{sqlBaseUrl:l,cloud:e})}catch(e){console.error("init http orm client failed, try call function orm",e),a=S(s)}return e.models=a,e.mysql=zh(e,{envId:null==t?void 0:t.envId,mysqlBaseUrl:null==t?void 0:t.mysqlBaseUrl}),e},Object.defineProperty(e,"__esModule",{value:!0})});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).wxCloudClientSDK={})}(this,function(e){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},t(e,r)};function r(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function o(e,t,r,n){return new(r||(r=Promise))(function(t,o){function i(e){try{a(n.next(e))}catch(e){o(e)}}function s(e){try{a(n.throw(e))}catch(e){o(e)}}function a(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r(function(e){e(n)})).then(i,s)}a((n=n.apply(e,[])).next())})}function i(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var s=function(e){function t(t,r){var n=e.call(this,t)||this;return n.name="WxCloudSDKError",n.code=null==r?void 0:r.code,n.requestId=null==r?void 0:r.requestId,n.originError=null==r?void 0:r.originError,n}return r(t,e),t}(Error);function a(){return"undefined"!=typeof window&&window||"undefined"!=typeof globalThis&&globalThis}function c(){try{var e=a();if(!e)return;return"undefined"==typeof wx?a().location.href:e.__wxRoute}catch(e){}}var u=function(e){return o(void 0,0,void 0,function(){var t,r,n,o;return i(this,function(i){switch(i.label){case 0:if(!(null===(n=null==e?void 0:e.auth)||void 0===n?void 0:n.getSession))return[2,""];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,e.auth.getSession()];case 2:return t=i.sent().data,[2,(null===(o=t.session)||void 0===o?void 0:o.access_token)||""];case 3:return r=i.sent(),console.log("[WxCloudSDKError] getAccessToken failed",r),[2,""];case 4:return[2]}})})},l=function(e){var t=e.dataSourceName,r=e.methodName,l=e.params,d=e.realMethodName,h=e.callFunction,f=e.envType,p=void 0===f?"prod":f,v=e.mode,y=e.cloud;return o(void 0,0,void 0,function(){var e,o,f,g,m,b,_;return i(this,function(i){switch(i.label){case 0:return e={data:{},requestId:""},[4,u(y)];case 1:o=i.sent(),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,h({name:"lowcode-datasource",data:n({dataSourceName:t,methodName:r,params:l,userAgent:(S=a(),(null==S?void 0:S.navigator)?S.navigator.userAgent:"undefined"!=typeof wx&&wx.getSystemInfo?(wx.getSystemInfo({success:function(e){e&&(w=["brand","model","version","system","platform","SDKVersion","language"].map(function(t){return"".concat(t,": ").concat(e[t])}).join(", "))}}),w):void 0),referrer:c(),"x-sdk-version":"1.8.5",envType:p,mode:v},o?{access_token:o}:{})})];case 3:if(f=i.sent(),g=(null===(b=null==f?void 0:f.result)||void 0===b?void 0:b.requestId)||(null==f?void 0:f.requestId)||(null==f?void 0:f.requestID),null==f?void 0:f.result.code)throw new s("【错误】".concat(null==f?void 0:f.result.message,"\n【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(d,"\n【错误码】").concat(null==f?void 0:f.result.code,"\n【请求ID】").concat(g||"N/A"),{code:null==f?void 0:f.result.code,requestId:g});return e.data=(null===(_=null==f?void 0:f.result)||void 0===_?void 0:_.data)||{},e.requestId=g,[3,5];case 4:throw"WxCloudSDKError"===(m=i.sent()).name?m:(console.log(m),new s("【错误】".concat(m.message,"\n 【操作】调用 models.").concat(t?"".concat(t,"."):"").concat(d,"\n 【请求ID】N/A"),{code:"UnknownError",originError:m}));case 5:return[2,e]}var w,S})})},d=function(e){var t=e.sql,r=e.params,n=e.config,s=e.callFunction,a=e.unsafe,c=void 0!==a&&a,u=e.cloud;return o(void 0,0,void 0,function(){return i(this,function(e){return[2,l({realMethodName:"$runSQL",methodName:"callWedaApi",params:{action:"RunMysqlCommand",data:{sqlTemplate:t,config:n,parameter:c?"":Object.entries(r||{}).reduce(function(e,t){var r=t[0],n=t[1];if(void 0!==n){var o="OBJECT";switch(typeof n){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(n)?"ARRAY":"OBJECT"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e},[])||[]}},callFunction:s,mode:"sdk",cloud:u})]})})},h=function(e,t){return{$runSQL:function(r,s,a){return o(this,0,void 0,function(){return i(this,function(o){switch(o.label){case 0:return[4,d({sql:r,params:s,config:n(n({},a),{preparedStatements:!0}),callFunction:e,cloud:t})];case 1:return[2,o.sent()]}})})},$runSQLRaw:function(r,s){return o(this,0,void 0,function(){return i(this,function(o){switch(o.label){case 0:return[4,d({sql:r,params:[],config:n(n({},s),{preparedStatements:!1}),callFunction:e,cloud:t})];case 1:return[2,o.sent()]}})})}}},f={filter:{where:{}},select:{$master:!0}};function p(e){return{getUrl:function(t){return"".concat(t,"/").concat(e)},method:"post"}}var v={get:n(n({},p("get")),{defaultParams:n({},f)}),list:n(n({},p("list")),{defaultParams:n({},f)}),create:p("create"),createMany:p("createMany"),update:n(n({},p("update")),{method:"put"}),updateMany:n(n({},p("updateMany")),{method:"put"}),upsert:p("upsert"),delete:p("delete"),deleteMany:p("deleteMany")},y="Unknown error occurred",g="NotSupported",m=function(e,t,r,n){var o=h(e,null==n?void 0:n.cloud);return new Proxy({},{get:function(e,i){if("string"==typeof i)return Object.prototype.hasOwnProperty.call(o,i)?o[i]:_(r,i,t,n)}})},b=function(e,t,r,n,o){return new s("【错误】".concat(e,"\n【操作】调用 models.").concat(t,".").concat(r,"\n【错误码】").concat(n,"\n【请求ID】").concat(o),{code:n,requestId:o})},_=function(e,t,r,a){var c=new Proxy({},{get:function(c,u){if("runSQLTemplate"!==u){var l=v[u];if(!l){var d=new Error("不支持的操作: ".concat(u));throw new s(d.message||y,{originError:d,code:g,requestId:"N/A"})}return function(n){return void 0===n&&(n={}),o(void 0,0,void 0,function(){var o,a,c,d,h,f,p,v,g,m;return i(this,function(i){switch(i.label){case 0:o=l.getUrl,a=l.method,c=l.defaultParams,d=void 0===c?{}:c,h=Object.assign({},d,n),f="pre"===h.envType?"pre":"prod",p=[e,f,o(t)].join("/"),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r({url:p,body:JSON.stringify(h),method:a})];case 2:if((v=i.sent()).code)throw b(null==v?void 0:v.message,t,u,null==v?void 0:v.code,null==v?void 0:v.requestId);return"get"===u&&Object.assign(v,{data:null!==(m=v.data.record)&&void 0!==m?m:v.data}),[2,v];case 3:throw g=i.sent(),new s((null==g?void 0:g.message)||y,{originError:g});case 4:return[2]}})})}}if(!(null==a?void 0:a.sqlBaseUrl)){d=new Error("不支持的操作: ".concat(u));throw new s(d.message||y,{originError:d,code:g,requestId:"N/A"})}return function(e){return o(void 0,0,void 0,function(){var o,c,l,d,h,f,p,v,g,m,_,w,S,I,P,E;return i(this,function(i){switch(i.label){case 0:o=e.params,c=e.templateName,l=e.envType,d="pre"===l?"pre":"prod",h=[a.sqlBaseUrl,d,c,"run"].join("/"),f=Object.entries(o||{}).reduce(function(e,t){var r=t[0],n=t[1];if(void 0!==n){var o="OBJECT";switch(typeof n){case"boolean":o="BOOLEAN";break;case"number":o="NUMBER";break;case"string":o="STRING";break;default:o=Array.isArray(n)?"ARRAY":"OBJECT"}e.push({key:r,type:o,value:"STRING"===o?n:JSON.stringify(n)})}return e},[]),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r({url:h,body:JSON.stringify({parameter:f}),method:"POST"})];case 2:if(p=i.sent(),null===(g=null==p?void 0:p.Response)||void 0===g?void 0:g.Error)throw b(null===(_=null===(m=null==p?void 0:p.Response)||void 0===m?void 0:m.Error)||void 0===_?void 0:_.Message,t,u,null===(S=null===(w=null==p?void 0:p.Response)||void 0===w?void 0:w.Error)||void 0===S?void 0:S.Code,null===(I=null==p?void 0:p.Response)||void 0===I?void 0:I.RequestId);return[2,n(n({},null!==(P=null==p?void 0:p.Response)&&void 0!==P?P:{}),{data:null===(E=null==p?void 0:p.Response)||void 0===E?void 0:E.Data})];case 3:throw v=i.sent(),new s((null==v?void 0:v.message)||y,{originError:v});case 4:return[2]}})})}}});return c},w={create:{methodName:"wedaCreateV2"},createMany:{methodName:"wedaBatchCreateV2"},update:{methodName:"wedaUpdateV2"},upsert:{methodName:"wedaUpsertV2"},updateMany:{methodName:"wedaBatchUpdateV2"},delete:{methodName:"wedaDeleteV2"},deleteMany:{methodName:"wedaBatchDeleteV2"},get:{methodName:"wedaGetItemV2",defaultParams:{filter:{where:{}},select:{$master:!0}}},list:{methodName:"wedaGetRecordsV2",defaultParams:{filter:{where:{}},select:{$master:!0}}}},S=function(e,t){var r=h(e,t);return new Proxy({},{get:function(a,c){if("string"==typeof c)return Object.prototype.hasOwnProperty.call(r,c)?r[c]:function(e,t,r){return new Proxy({},{get:function(a,c){var u=w[c];if(!u){var d=new Error("不支持的操作: ".concat(c));throw new s(d.message||"Unknown error occurred",{originError:d,code:"NotSupported",requestId:"N/A"})}return function(s){return o(void 0,0,void 0,function(){var o,a,d,h,f;return i(this,function(i){switch(i.label){case 0:return o=n(n({},u.defaultParams||{}),s||{}),[4,l({callFunction:t,dataSourceName:e,methodName:u.methodName,realMethodName:c,params:o,envType:null==s?void 0:s.envType,cloud:r})];case 1:return a=i.sent(),d={data:{}},h=u.responseKey,d.data=h?null===(f=null==a?void 0:a.data)||void 0===f?void 0:f[h]:null==a?void 0:a.data,[2,d]}})})}}})}(c,e,t)}})},I=function(){function e(e){var t=this;this.map=new Map,e&&(e instanceof Headers?e.forEach(function(e,r){t.append(r,e)}):Array.isArray(e)?e.forEach(function(e){var r=e[0],n=e[1];t.append(r,n)}):"object"==typeof e&&Object.keys(e).forEach(function(r){t.append(r,e[r])}))}return e.prototype.append=function(e,t){var r=e.toLowerCase(),n=this.map.get(r);n?this.map.set(r,"".concat(n,", ").concat(t)):this.map.set(r,String(t))},e.prototype.delete=function(e){this.map.delete(e.toLowerCase())},e.prototype.forEach=function(e,t){var r=this;this.map.forEach(function(n,o){e.call(t,n,o,r)})},e.prototype.get=function(e){return this.map.get(e.toLowerCase())||null},e.prototype.has=function(e){return this.map.has(e.toLowerCase())},e.prototype.set=function(e,t){this.map.set(e.toLowerCase(),String(t))},e.prototype.entries=function(){return this.map.entries()},e.prototype.keys=function(){return this.map.keys()},e.prototype.values=function(){return this.map.values()},e.prototype.getSetCookie=function(){var e=[];return this.map.forEach(function(t,r){"set-cookie"===r&&e.push(t)}),e},e.prototype.toJSON=function(){var e={};return this.map.forEach(function(t,r){e[r]=t}),e},e.prototype[Symbol.iterator]=function(){return this.entries()},e}();"object"!=typeof globalThis||globalThis.Headers||(globalThis.Headers=I);var P="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T,R,C=function(e){try{return!!e()}catch(e){return!0}},O=!C(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}),A=O,k=Function.prototype,U=k.call,q=A&&k.bind.bind(U,U),L=A?q:function(e){return function(){return U.apply(e,arguments)}},x=L,j=x({}.toString),N=x("".slice),D=function(e){return N(j(e),8,-1)},W=C,B=D,F=Object,M=L("".split),H=W(function(){return!F("z").propertyIsEnumerable(0)})?function(e){return"String"===B(e)?M(e,""):F(e)}:F,z=function(e){return null==e},V=z,G=TypeError,K=function(e){if(V(e))throw new G("Can't call method on "+e);return e},Y=H,Q=K,J=function(e){return Y(Q(e))},$={},X=function(e){return e&&e.Math===Math&&e},Z=X("object"==typeof globalThis&&globalThis)||X("object"==typeof window&&window)||X("object"==typeof self&&self)||X("object"==typeof P&&P)||X("object"==typeof P&&P)||function(){return this}()||Function("return this")(),ee="object"==typeof document&&document.all,te=void 0===ee&&void 0!==ee?function(e){return"function"==typeof e||e===ee}:function(e){return"function"==typeof e},re=te,ne=Z.WeakMap,oe=re(ne)&&/native code/.test(String(ne)),ie=te,se=function(e){return"object"==typeof e?null!==e:ie(e)},ae=!C(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),ce={},ue=se,le=Z.document,de=ue(le)&&ue(le.createElement),he=function(e){return de?le.createElement(e):{}},fe=he,pe=!ae&&!C(function(){return 7!==Object.defineProperty(fe("div"),"a",{get:function(){return 7}}).a}),ve=ae&&C(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),ye=se,ge=String,me=TypeError,be=function(e){if(ye(e))return e;throw new me(ge(e)+" is not an object")},_e=O,we=Function.prototype.call,Se=_e?we.bind(we):function(){return we.apply(we,arguments)},Ie={},Pe=Ie,Ee=Z,Te=te,Re=function(e){return Te(e)?e:void 0},Ce=function(e,t){return arguments.length<2?Re(Pe[e])||Re(Ee[e]):Pe[e]&&Pe[e][t]||Ee[e]&&Ee[e][t]},Oe=L({}.isPrototypeOf),Ae=Z.navigator,ke=Ae&&Ae.userAgent,Ue=Z,qe=ke?String(ke):"",Le=Ue.process,xe=Ue.Deno,je=Le&&Le.versions||xe&&xe.version,Ne=je&&je.v8;Ne&&(R=(T=Ne.split("."))[0]>0&&T[0]<4?1:+(T[0]+T[1])),!R&&qe&&(!(T=qe.match(/Edge\/(\d+)/))||T[1]>=74)&&(T=qe.match(/Chrome\/(\d+)/))&&(R=+T[1]);var De=R,We=C,Be=Z.String,Fe=!!Object.getOwnPropertySymbols&&!We(function(){var e=Symbol("symbol detection");return!Be(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&De&&De<41}),Me=Fe&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,He=Ce,ze=te,Ve=Oe,Ge=Object,Ke=Me?function(e){return"symbol"==typeof e}:function(e){var t=He("Symbol");return ze(t)&&Ve(t.prototype,Ge(e))},Ye=String,Qe=function(e){try{return Ye(e)}catch(e){return"Object"}},Je=te,$e=Qe,Xe=TypeError,Ze=function(e){if(Je(e))return e;throw new Xe($e(e)+" is not a function")},et=Ze,tt=z,rt=function(e,t){var r=e[t];return tt(r)?void 0:et(r)},nt=Se,ot=te,it=se,st=TypeError,at={exports:{}},ct=Z,ut=Object.defineProperty,lt=Z,dt=function(e,t){try{ut(ct,e,{value:t,configurable:!0,writable:!0})}catch(r){ct[e]=t}return t},ht="__core-js_shared__",ft=at.exports=lt[ht]||dt(ht,{});(ft.versions||(ft.versions=[])).push({version:"3.45.0",mode:"pure",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.45.0/LICENSE",source:"https://github.com/zloirock/core-js"});var pt=at.exports,vt=pt,yt=function(e,t){return vt[e]||(vt[e]=t||{})},gt=K,mt=Object,bt=function(e){return mt(gt(e))},_t=bt,wt=L({}.hasOwnProperty),St=Object.hasOwn||function(e,t){return wt(_t(e),t)},It=L,Pt=0,Et=Math.random(),Tt=It(1.1.toString),Rt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Tt(++Pt+Et,36)},Ct=yt,Ot=St,At=Rt,kt=Fe,Ut=Me,qt=Z.Symbol,Lt=Ct("wks"),xt=Ut?qt.for||qt:qt&&qt.withoutSetter||At,jt=function(e){return Ot(Lt,e)||(Lt[e]=kt&&Ot(qt,e)?qt[e]:xt("Symbol."+e)),Lt[e]},Nt=Se,Dt=se,Wt=Ke,Bt=rt,Ft=function(e,t){var r,n;if("string"===t&&ot(r=e.toString)&&!it(n=nt(r,e)))return n;if(ot(r=e.valueOf)&&!it(n=nt(r,e)))return n;if("string"!==t&&ot(r=e.toString)&&!it(n=nt(r,e)))return n;throw new st("Can't convert object to primitive value")},Mt=TypeError,Ht=jt("toPrimitive"),zt=function(e,t){if(!Dt(e)||Wt(e))return e;var r,n=Bt(e,Ht);if(n){if(void 0===t&&(t="default"),r=Nt(n,e,t),!Dt(r)||Wt(r))return r;throw new Mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),Ft(e,t)},Vt=Ke,Gt=function(e){var t=zt(e,"string");return Vt(t)?t:t+""},Kt=ae,Yt=pe,Qt=ve,Jt=be,$t=Gt,Xt=TypeError,Zt=Object.defineProperty,er=Object.getOwnPropertyDescriptor,tr="enumerable",rr="configurable",nr="writable";ce.f=Kt?Qt?function(e,t,r){if(Jt(e),t=$t(t),Jt(r),"function"==typeof e&&"prototype"===t&&"value"in r&&nr in r&&!r[nr]){var n=er(e,t);n&&n[nr]&&(e[t]=r.value,r={configurable:rr in r?r[rr]:n[rr],enumerable:tr in r?r[tr]:n[tr],writable:!1})}return Zt(e,t,r)}:Zt:function(e,t,r){if(Jt(e),t=$t(t),Jt(r),Yt)try{return Zt(e,t,r)}catch(e){}if("get"in r||"set"in r)throw new Xt("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var or,ir,sr,ar=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},cr=ce,ur=ar,lr=ae?function(e,t,r){return cr.f(e,t,ur(1,r))}:function(e,t,r){return e[t]=r,e},dr=Rt,hr=yt("keys"),fr=function(e){return hr[e]||(hr[e]=dr(e))},pr={},vr=oe,yr=Z,gr=se,mr=lr,br=St,_r=pt,wr=fr,Sr=pr,Ir="Object already initialized",Pr=yr.TypeError,Er=yr.WeakMap;if(vr||_r.state){var Tr=_r.state||(_r.state=new Er);Tr.get=Tr.get,Tr.has=Tr.has,Tr.set=Tr.set,or=function(e,t){if(Tr.has(e))throw new Pr(Ir);return t.facade=e,Tr.set(e,t),t},ir=function(e){return Tr.get(e)||{}},sr=function(e){return Tr.has(e)}}else{var Rr=wr("state");Sr[Rr]=!0,or=function(e,t){if(br(e,Rr))throw new Pr(Ir);return t.facade=e,mr(e,Rr,t),t},ir=function(e){return br(e,Rr)?e[Rr]:{}},sr=function(e){return br(e,Rr)}}var Cr={set:or,get:ir,has:sr,enforce:function(e){return sr(e)?ir(e):or(e,{})},getterFor:function(e){return function(t){var r;if(!gr(t)||(r=ir(t)).type!==e)throw new Pr("Incompatible receiver, "+e+" required");return r}}},Or=O,Ar=Function.prototype,kr=Ar.apply,Ur=Ar.call,qr="object"==typeof Reflect&&Reflect.apply||(Or?Ur.bind(kr):function(){return Ur.apply(kr,arguments)}),Lr=D,xr=L,jr=function(e){if("Function"===Lr(e))return xr(e)},Nr={},Dr={},Wr={}.propertyIsEnumerable,Br=Object.getOwnPropertyDescriptor,Fr=Br&&!Wr.call({1:2},1);Dr.f=Fr?function(e){var t=Br(this,e);return!!t&&t.enumerable}:Wr;var Mr=ae,Hr=Se,zr=Dr,Vr=ar,Gr=J,Kr=Gt,Yr=St,Qr=pe,Jr=Object.getOwnPropertyDescriptor;Nr.f=Mr?Jr:function(e,t){if(e=Gr(e),t=Kr(t),Qr)try{return Jr(e,t)}catch(e){}if(Yr(e,t))return Vr(!Hr(zr.f,e,t),e[t])};var $r=C,Xr=te,Zr=/#|\.prototype\./,en=function(e,t){var r=rn[tn(e)];return r===on||r!==nn&&(Xr(t)?$r(t):!!t)},tn=en.normalize=function(e){return String(e).replace(Zr,".").toLowerCase()},rn=en.data={},nn=en.NATIVE="N",on=en.POLYFILL="P",sn=en,an=Ze,cn=O,un=jr(jr.bind),ln=function(e,t){return an(e),void 0===t?e:cn?un(e,t):function(){return e.apply(t,arguments)}},dn=Z,hn=qr,fn=jr,pn=te,vn=Nr.f,yn=sn,gn=Ie,mn=ln,bn=lr,_n=St,wn=function(e){var t=function(r,n,o){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,o)}return hn(e,this,arguments)};return t.prototype=e.prototype,t},Sn=function(e,t){var r,n,o,i,s,a,c,u,l,d=e.target,h=e.global,f=e.stat,p=e.proto,v=h?dn:f?dn[d]:dn[d]&&dn[d].prototype,y=h?gn:gn[d]||bn(gn,d,{})[d],g=y.prototype;for(i in t)n=!(r=yn(h?i:d+(f?".":"#")+i,e.forced))&&v&&_n(v,i),a=y[i],n&&(c=e.dontCallGetSet?(l=vn(v,i))&&l.value:v[i]),s=n&&c?c:t[i],(r||p||typeof a!=typeof s)&&(u=e.bind&&n?mn(s,dn):e.wrap&&n?wn(s):p&&pn(s)?fn(s):s,(e.sham||s&&s.sham||a&&a.sham)&&bn(u,"sham",!0),bn(y,i,u),p&&(_n(gn,o=d+"Prototype")||bn(gn,o,{}),bn(gn[o],i,s),e.real&&g&&(r||!g[i])&&bn(g,i,s)))},In=ae,Pn=St,En=Function.prototype,Tn=In&&Object.getOwnPropertyDescriptor,Rn=Pn(En,"name"),Cn={EXISTS:Rn,PROPER:Rn&&"something"===function(){}.name,CONFIGURABLE:Rn&&(!In||In&&Tn(En,"name").configurable)},On={},An=Math.ceil,kn=Math.floor,Un=Math.trunc||function(e){var t=+e;return(t>0?kn:An)(t)},qn=Un,Ln=function(e){var t=+e;return t!=t||0===t?0:qn(t)},xn=Ln,jn=Math.max,Nn=Math.min,Dn=function(e,t){var r=xn(e);return r<0?jn(r+t,0):Nn(r,t)},Wn=Ln,Bn=Math.min,Fn=function(e){var t=Wn(e);return t>0?Bn(t,9007199254740991):0},Mn=function(e){return Fn(e.length)},Hn=J,zn=Dn,Vn=Mn,Gn=function(e){return function(t,r,n){var o=Hn(t),i=Vn(o);if(0===i)return!e&&-1;var s,a=zn(n,i);if(e&&r!=r){for(;i>a;)if((s=o[a++])!=s)return!0}else for(;i>a;a++)if((e||a in o)&&o[a]===r)return e||a||0;return!e&&-1}},Kn={includes:Gn(!0),indexOf:Gn(!1)},Yn=St,Qn=J,Jn=Kn.indexOf,$n=pr,Xn=L([].push),Zn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],eo=function(e,t){var r,n=Qn(e),o=0,i=[];for(r in n)!Yn($n,r)&&Yn(n,r)&&Xn(i,r);for(;t.length>o;)Yn(n,r=t[o++])&&(~Jn(i,r)||Xn(i,r));return i},to=Zn,ro=Object.keys||function(e){return eo(e,to)},no=ae,oo=ve,io=ce,so=be,ao=J,co=ro;On.f=no&&!oo?Object.defineProperties:function(e,t){so(e);for(var r,n=ao(t),o=co(t),i=o.length,s=0;i>s;)io.f(e,r=o[s++],n[r]);return e};var uo,lo=Ce("document","documentElement"),ho=be,fo=On,po=Zn,vo=pr,yo=lo,go=he,mo="prototype",bo="script",_o=fr("IE_PROTO"),wo=function(){},So=function(e){return"<"+bo+">"+e+"</"+bo+">"},Io=function(e){e.write(So("")),e.close();var t=e.parentWindow.Object;return e=null,t},Po=function(){try{uo=new ActiveXObject("htmlfile")}catch(e){}var e,t,r;Po="undefined"!=typeof document?document.domain&&uo?Io(uo):(t=go("iframe"),r="java"+bo+":",t.style.display="none",yo.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(So("document.F=Object")),e.close(),e.F):Io(uo);for(var n=po.length;n--;)delete Po[mo][po[n]];return Po()};vo[_o]=!0;var Eo,To,Ro,Co=Object.create||function(e,t){var r;return null!==e?(wo[mo]=ho(e),r=new wo,wo[mo]=null,r[_o]=e):r=Po(),void 0===t?r:fo.f(r,t)},Oo=!C(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),Ao=St,ko=te,Uo=bt,qo=Oo,Lo=fr("IE_PROTO"),xo=Object,jo=xo.prototype,No=qo?xo.getPrototypeOf:function(e){var t=Uo(e);if(Ao(t,Lo))return t[Lo];var r=t.constructor;return ko(r)&&t instanceof r?r.prototype:t instanceof xo?jo:null},Do=lr,Wo=function(e,t,r,n){return n&&n.enumerable?e[t]=r:Do(e,t,r),e},Bo=C,Fo=te,Mo=se,Ho=Co,zo=No,Vo=Wo,Go=jt("iterator"),Ko=!1;[].keys&&("next"in(Ro=[].keys())?(To=zo(zo(Ro)))!==Object.prototype&&(Eo=To):Ko=!0);var Yo=!Mo(Eo)||Bo(function(){var e={};return Eo[Go].call(e)!==e});Fo((Eo=Yo?{}:Ho(Eo))[Go])||Vo(Eo,Go,function(){return this});var Qo={IteratorPrototype:Eo,BUGGY_SAFARI_ITERATORS:Ko},Jo={};Jo[jt("toStringTag")]="z";var $o="[object z]"===String(Jo),Xo=$o,Zo=te,ei=D,ti=jt("toStringTag"),ri=Object,ni="Arguments"===ei(function(){return arguments}()),oi=Xo?ei:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(e){}}(t=ri(e),ti))?r:ni?ei(t):"Object"===(n=ei(t))&&Zo(t.callee)?"Arguments":n},ii=oi,si=$o?{}.toString:function(){return"[object "+ii(this)+"]"},ai=$o,ci=ce.f,ui=lr,li=St,di=si,hi=jt("toStringTag"),fi=function(e,t,r,n){var o=r?e:e&&e.prototype;o&&(li(o,hi)||ci(o,hi,{configurable:!0,value:t}),n&&!ai&&ui(o,"toString",di))},pi=Qo.IteratorPrototype,vi=Co,yi=ar,gi=fi,mi=$,bi=function(){return this},_i=function(e,t,r,n){var o=t+" Iterator";return e.prototype=vi(pi,{next:yi(+!n,r)}),gi(e,o,!1,!0),mi[o]=bi,e},wi=Sn,Si=Se,Ii=Cn,Pi=_i,Ei=No,Ti=fi,Ri=Wo,Ci=$,Oi=Qo,Ai=Ii.PROPER,ki=Oi.BUGGY_SAFARI_ITERATORS,Ui=jt("iterator"),qi="keys",Li="values",xi="entries",ji=function(){return this},Ni=function(e,t,r,n,o,i,s){Pi(r,t,n);var a,c,u,l=function(e){if(e===o&&v)return v;if(!ki&&e&&e in f)return f[e];switch(e){case qi:case Li:case xi:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",h=!1,f=e.prototype,p=f[Ui]||f["@@iterator"]||o&&f[o],v=!ki&&p||l(o),y="Array"===t&&f.entries||p;if(y&&(a=Ei(y.call(new e)))!==Object.prototype&&a.next&&(Ti(a,d,!0,!0),Ci[d]=ji),Ai&&o===Li&&p&&p.name!==Li&&(h=!0,v=function(){return Si(p,this)}),o)if(c={values:l(Li),keys:i?v:l(qi),entries:l(xi)},s)for(u in c)(ki||h||!(u in f))&&Ri(f,u,c[u]);else wi({target:t,proto:!0,forced:ki||h},c);return s&&f[Ui]!==v&&Ri(f,Ui,v,{name:o}),Ci[t]=v,c},Di=function(e,t){return{value:e,done:t}},Wi=J,Bi=$,Fi=Cr;ce.f;var Mi=Ni,Hi=Di,zi="Array Iterator",Vi=Fi.set,Gi=Fi.getterFor(zi);Mi(Array,"Array",function(e,t){Vi(this,{type:zi,target:Wi(e),index:0,kind:t})},function(){var e=Gi(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,Hi(void 0,!0);switch(e.kind){case"keys":return Hi(r,!1);case"values":return Hi(t[r],!1)}return Hi([r,t[r]],!1)},"values"),Bi.Arguments=Bi.Array;var Ki=Sn,Yi=L,Qi=Dn,Ji=RangeError,$i=String.fromCharCode,Xi=String.fromCodePoint,Zi=Yi([].join);Ki({target:"String",stat:!0,arity:1,forced:!!Xi&&1!==Xi.length},{fromCodePoint:function(e){for(var t,r=[],n=arguments.length,o=0;n>o;){if(t=+arguments[o++],Qi(t,1114111)!==t)throw new Ji(t+" is not a valid code point");r[o]=t<65536?$i(t):$i(55296+((t-=65536)>>10),t%1024+56320)}return Zi(r,"")}});var es=Z,ts=ae,rs=Object.getOwnPropertyDescriptor,ns=C,os=!0,is=jt("iterator"),ss=!ns(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return e.pathname="c%20d",t.forEach(function(e,r){t.delete("b"),n+=r+e}),r.delete("a",2),r.delete("b",void 0),!e.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b")||!t.size&&os||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[is]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==n||"x"!==new URL("https://x",void 0).host}),as=ce,cs=function(e,t,r){return as.f(e,t,r)},us=Wo,ls=Oe,ds=TypeError,hs=function(e,t){if(ls(t,e))return e;throw new ds("Incorrect invocation")},fs=oi,ps=String,vs=function(e){if("Symbol"===fs(e))throw new TypeError("Cannot convert a Symbol value to a string");return ps(e)},ys=oi,gs=rt,ms=z,bs=$,_s=jt("iterator"),ws=function(e){if(!ms(e))return gs(e,_s)||gs(e,"@@iterator")||bs[ys(e)]},Ss=Se,Is=Ze,Ps=be,Es=Qe,Ts=ws,Rs=TypeError,Cs=function(e,t){var r=arguments.length<2?Ts(e):t;if(Is(r))return Ps(Ss(r,e));throw new Rs(Es(e)+" is not iterable")},Os=TypeError,As=function(e,t){if(e<t)throw new Os("Not enough arguments");return e},ks=L([].slice),Us=ks,qs=Math.floor,Ls=function(e,t){var r=e.length;if(r<8)for(var n,o,i=1;i<r;){for(o=i,n=e[i];o&&t(e[o-1],n)>0;)e[o]=e[--o];o!==i++&&(e[o]=n)}else for(var s=qs(r/2),a=Ls(Us(e,0,s),t),c=Ls(Us(e,s),t),u=a.length,l=c.length,d=0,h=0;d<u||h<l;)e[d+h]=d<u&&h<l?t(a[d],c[h])<=0?a[d++]:c[h++]:d<u?a[d++]:c[h++];return e},xs=Sn,js=Z,Ns=function(e){if(!ts)return es[e];var t=rs(es,e);return t&&t.value},Ds=Ce,Ws=Se,Bs=L,Fs=ae,Ms=ss,Hs=Wo,zs=cs,Vs=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:us(e,n,t[n],r);return e},Gs=fi,Ks=_i,Ys=Cr,Qs=hs,Js=te,$s=St,Xs=ln,Zs=oi,ea=be,ta=se,ra=vs,na=Co,oa=ar,ia=Cs,sa=ws,aa=Di,ca=As,ua=Ls,la=jt("iterator"),da="URLSearchParams",ha=da+"Iterator",fa=Ys.set,pa=Ys.getterFor(da),va=Ys.getterFor(ha),ya=Ns("fetch"),ga=Ns("Request"),ma=Ns("Headers"),ba=ga&&ga.prototype,_a=ma&&ma.prototype,wa=js.TypeError,Sa=js.encodeURIComponent,Ia=String.fromCharCode,Pa=Ds("String","fromCodePoint"),Ea=parseInt,Ta=Bs("".charAt),Ra=Bs([].join),Ca=Bs([].push),Oa=Bs("".replace),Aa=Bs([].shift),ka=Bs([].splice),Ua=Bs("".split),qa=Bs("".slice),La=Bs(/./.exec),xa=/\+/g,ja=/^[0-9a-f]+$/i,Na=function(e,t){var r=qa(e,t,t+2);return La(ja,r)?Ea(r,16):NaN},Da=function(e){for(var t=0,r=128;r>0&&0!==(e&r);r>>=1)t++;return t},Wa=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},Ba=function(e){for(var t=(e=Oa(e,xa," ")).length,r="",n=0;n<t;){var o=Ta(e,n);if("%"===o){if("%"===Ta(e,n+1)||n+3>t){r+="%",n++;continue}var i=Na(e,n+1);if(i!=i){r+=o,n++;continue}n+=2;var s=Da(i);if(0===s)o=Ia(i);else{if(1===s||s>4){r+="�",n++;continue}for(var a=[i],c=1;c<s&&!(++n+3>t||"%"!==Ta(e,n));){var u=Na(e,n+1);if(u!=u){n+=3;break}if(u>191||u<128)break;Ca(a,u),n+=2,c++}if(a.length!==s){r+="�";continue}var l=Wa(a);null===l?r+="�":o=Pa(l)}}r+=o,n++}return r},Fa=/[!'()~]|%20/g,Ma={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Ha=function(e){return Ma[e]},za=function(e){return Oa(Sa(e),Fa,Ha)},Va=Ks(function(e,t){fa(this,{type:ha,target:pa(e).entries,index:0,kind:t})},da,function(){var e=va(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,aa(void 0,!0);var n=t[r];switch(e.kind){case"keys":return aa(n.key,!1);case"values":return aa(n.value,!1)}return aa([n.key,n.value],!1)},!0),Ga=function(e){this.entries=[],this.url=null,void 0!==e&&(ta(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===Ta(e,0)?qa(e,1):e:ra(e)))};Ga.prototype={type:da,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,o,i,s,a,c=this.entries,u=sa(e);if(u)for(r=(t=ia(e,u)).next;!(n=Ws(r,t)).done;){if(i=(o=ia(ea(n.value))).next,(s=Ws(i,o)).done||(a=Ws(i,o)).done||!Ws(i,o).done)throw new wa("Expected sequence with length 2");Ca(c,{key:ra(s.value),value:ra(a.value)})}else for(var l in e)$s(e,l)&&Ca(c,{key:l,value:ra(e[l])})},parseQuery:function(e){if(e)for(var t,r,n=this.entries,o=Ua(e,"&"),i=0;i<o.length;)(t=o[i++]).length&&(r=Ua(t,"="),Ca(n,{key:Ba(Aa(r)),value:Ba(Ra(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],Ca(r,za(e.key)+"="+za(e.value));return Ra(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Ka=function(){Qs(this,Ya);var e=fa(this,new Ga(arguments.length>0?arguments[0]:void 0));Fs||(this.size=e.entries.length)},Ya=Ka.prototype;if(Vs(Ya,{append:function(e,t){var r=pa(this);ca(arguments.length,2),Ca(r.entries,{key:ra(e),value:ra(t)}),Fs||this.length++,r.updateURL()},delete:function(e){for(var t=pa(this),r=ca(arguments.length,1),n=t.entries,o=ra(e),i=r<2?void 0:arguments[1],s=void 0===i?i:ra(i),a=0;a<n.length;){var c=n[a];if(c.key!==o||void 0!==s&&c.value!==s)a++;else if(ka(n,a,1),void 0!==s)break}Fs||(this.size=n.length),t.updateURL()},get:function(e){var t=pa(this).entries;ca(arguments.length,1);for(var r=ra(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){var t=pa(this).entries;ca(arguments.length,1);for(var r=ra(e),n=[],o=0;o<t.length;o++)t[o].key===r&&Ca(n,t[o].value);return n},has:function(e){for(var t=pa(this).entries,r=ca(arguments.length,1),n=ra(e),o=r<2?void 0:arguments[1],i=void 0===o?o:ra(o),s=0;s<t.length;){var a=t[s++];if(a.key===n&&(void 0===i||a.value===i))return!0}return!1},set:function(e,t){var r=pa(this);ca(arguments.length,1);for(var n,o=r.entries,i=!1,s=ra(e),a=ra(t),c=0;c<o.length;c++)(n=o[c]).key===s&&(i?ka(o,c--,1):(i=!0,n.value=a));i||Ca(o,{key:s,value:a}),Fs||(this.size=o.length),r.updateURL()},sort:function(){var e=pa(this);ua(e.entries,function(e,t){return e.key>t.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,r=pa(this).entries,n=Xs(e,arguments.length>1?arguments[1]:void 0),o=0;o<r.length;)n((t=r[o++]).value,t.key,this)},keys:function(){return new Va(this,"keys")},values:function(){return new Va(this,"values")},entries:function(){return new Va(this,"entries")}},{enumerable:!0}),Hs(Ya,la,Ya.entries,{name:"entries"}),Hs(Ya,"toString",function(){return pa(this).serialize()},{enumerable:!0}),Fs&&zs(Ya,"size",{get:function(){return pa(this).entries.length},configurable:!0,enumerable:!0}),Gs(Ka,da),xs({global:!0,constructor:!0,forced:!Ms},{URLSearchParams:Ka}),!Ms&&Js(ma)){var Qa=Bs(_a.has),Ja=Bs(_a.set),$a=function(e){if(ta(e)){var t,r=e.body;if(Zs(r)===da)return t=e.headers?new ma(e.headers):new ma,Qa(t,"content-type")||Ja(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),na(e,{body:oa(0,ra(r)),headers:oa(0,t)})}return e};if(Js(ya)&&xs({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return ya(e,arguments.length>1?$a(arguments[1]):{})}}),Js(ga)){var Xa=function(e){return Qs(this,ba),new ga(e,arguments.length>1?$a(arguments[1]):{})};ba.constructor=Xa,Xa.prototype=ba,xs({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Xa})}}var Za={URLSearchParams:Ka,getState:pa},ec=L,tc=Ln,rc=vs,nc=K,oc=ec("".charAt),ic=ec("".charCodeAt),sc=ec("".slice),ac=function(e){return function(t,r){var n,o,i=rc(nc(t)),s=tc(r),a=i.length;return s<0||s>=a?e?"":void 0:(n=ic(i,s))<55296||n>56319||s+1===a||(o=ic(i,s+1))<56320||o>57343?e?oc(i,s):n:e?sc(i,s,s+2):o-56320+(n-55296<<10)+65536}},cc={codeAt:ac(!1),charAt:ac(!0)},uc=cc.charAt,lc=vs,dc=Cr,hc=Ni,fc=Di,pc="String Iterator",vc=dc.set,yc=dc.getterFor(pc);hc(String,"String",function(e){vc(this,{type:pc,string:lc(e),index:0})},function(){var e,t=yc(this),r=t.string,n=t.index;return n>=r.length?fc(void 0,!0):(e=uc(r,n),t.index+=e.length,fc(e,!1))});var gc={};gc.f=Object.getOwnPropertySymbols;var mc=ae,bc=L,_c=Se,wc=C,Sc=ro,Ic=gc,Pc=Dr,Ec=bt,Tc=H,Rc=Object.assign,Cc=Object.defineProperty,Oc=bc([].concat),Ac=!Rc||wc(function(){if(mc&&1!==Rc({b:1},Rc(Cc({},"a",{enumerable:!0,get:function(){Cc(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach(function(e){t[e]=e}),7!==Rc({},e)[r]||Sc(Rc({},t)).join("")!==n})?function(e,t){for(var r=Ec(e),n=arguments.length,o=1,i=Ic.f,s=Pc.f;n>o;)for(var a,c=Tc(arguments[o++]),u=i?Oc(Sc(c),i(c)):Sc(c),l=u.length,d=0;l>d;)a=u[d++],mc&&!_c(s,c,a)||(r[a]=c[a]);return r}:Rc,kc=Se,Uc=be,qc=rt,Lc=be,xc=function(e,t,r){var n,o;Uc(e);try{if(!(n=qc(e,"return"))){if("throw"===t)throw r;return r}n=kc(n,e)}catch(e){o=!0,n=e}if("throw"===t)throw r;if(o)throw n;return Uc(n),r},jc=$,Nc=jt("iterator"),Dc=Array.prototype,Wc=te,Bc=pt,Fc=L(Function.toString);Wc(Bc.inspectSource)||(Bc.inspectSource=function(e){return Fc(e)});var Mc=Bc.inspectSource,Hc=L,zc=C,Vc=te,Gc=oi,Kc=Mc,Yc=function(){},Qc=Ce("Reflect","construct"),Jc=/^\s*(?:class|function)\b/,$c=Hc(Jc.exec),Xc=!Jc.test(Yc),Zc=function(e){if(!Vc(e))return!1;try{return Qc(Yc,[],e),!0}catch(e){return!1}},eu=function(e){if(!Vc(e))return!1;switch(Gc(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Xc||!!$c(Jc,Kc(e))}catch(e){return!0}};eu.sham=!0;var tu,ru=!Qc||zc(function(){var e;return Zc(Zc.call)||!Zc(Object)||!Zc(function(){e=!0})||e})?eu:Zc,nu=ae,ou=ce,iu=ar,su=ln,au=Se,cu=bt,uu=function(e,t,r,n){try{return n?t(Lc(r)[0],r[1]):t(r)}catch(t){xc(e,"throw",t)}},lu=function(e){return void 0!==e&&(jc.Array===e||Dc[Nc]===e)},du=ru,hu=Mn,fu=function(e,t,r){nu?ou.f(e,t,iu(0,r)):e[t]=r},pu=Cs,vu=ws,yu=Array,gu=L,mu=2147483647,bu=/[^\0-\u007E]/,_u=/[.\u3002\uFF0E\uFF61]/g,wu="Overflow: input needs wider integers to process",Su=RangeError,Iu=gu(_u.exec),Pu=Math.floor,Eu=String.fromCharCode,Tu=gu("".charCodeAt),Ru=gu([].join),Cu=gu([].push),Ou=gu("".replace),Au=gu("".split),ku=gu("".toLowerCase),Uu=function(e){return e+22+75*(e<26)},qu=function(e,t,r){var n=0;for(e=r?Pu(e/700):e>>1,e+=Pu(e/t);e>455;)e=Pu(e/35),n+=36;return Pu(n+36*e/(e+38))},Lu=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var o=Tu(e,r++);if(o>=55296&&o<=56319&&r<n){var i=Tu(e,r++);56320==(64512&i)?Cu(t,((1023&o)<<10)+(1023&i)+65536):(Cu(t,o),r--)}else Cu(t,o)}return t}(e);var r,n,o=e.length,i=128,s=0,a=72;for(r=0;r<e.length;r++)(n=e[r])<128&&Cu(t,Eu(n));var c=t.length,u=c;for(c&&Cu(t,"-");u<o;){var l=mu;for(r=0;r<e.length;r++)(n=e[r])>=i&&n<l&&(l=n);var d=u+1;if(l-i>Pu((mu-s)/d))throw new Su(wu);for(s+=(l-i)*d,i=l,r=0;r<e.length;r++){if((n=e[r])<i&&++s>mu)throw new Su(wu);if(n===i){for(var h=s,f=36;;){var p=f<=a?1:f>=a+26?26:f-a;if(h<p)break;var v=h-p,y=36-p;Cu(t,Eu(Uu(p+v%y))),h=Pu(v/y),f+=36}Cu(t,Eu(Uu(h))),a=qu(s,d,u===c),s=0,u++}}s++,i++}return Ru(t,"")},xu=Sn,ju=ae,Nu=ss,Du=Z,Wu=ln,Bu=L,Fu=Wo,Mu=cs,Hu=hs,zu=St,Vu=Ac,Gu=function(e){var t=cu(e),r=du(this),n=arguments.length,o=n>1?arguments[1]:void 0,i=void 0!==o;i&&(o=su(o,n>2?arguments[2]:void 0));var s,a,c,u,l,d,h=vu(t),f=0;if(!h||this===yu&&lu(h))for(s=hu(t),a=r?new this(s):yu(s);s>f;f++)d=i?o(t[f],f):t[f],fu(a,f,d);else for(a=r?new this:[],l=(u=pu(t,h)).next;!(c=au(l,u)).done;f++)d=i?uu(u,o,[c.value,f],!0):c.value,fu(a,f,d);return a.length=f,a},Ku=ks,Yu=cc.codeAt,Qu=function(e){var t,r,n=[],o=Au(Ou(ku(e),_u,"."),".");for(t=0;t<o.length;t++)r=o[t],Cu(n,Iu(bu,r)?"xn--"+Lu(r):r);return Ru(n,".")},Ju=vs,$u=fi,Xu=As,Zu=Za,el=Cr,tl=el.set,rl=el.getterFor("URL"),nl=Zu.URLSearchParams,ol=Zu.getState,il=Du.URL,sl=Du.TypeError,al=Du.parseInt,cl=Math.floor,ul=Math.pow,ll=Bu("".charAt),dl=Bu(/./.exec),hl=Bu([].join),fl=Bu(1.1.toString),pl=Bu([].pop),vl=Bu([].push),yl=Bu("".replace),gl=Bu([].shift),ml=Bu("".split),bl=Bu("".slice),_l=Bu("".toLowerCase),wl=Bu([].unshift),Sl="Invalid scheme",Il="Invalid host",Pl="Invalid port",El=/[a-z]/i,Tl=/[\d+-.a-z]/i,Rl=/\d/,Cl=/^0x/i,Ol=/^[0-7]+$/,Al=/^\d+$/,kl=/^[\da-f]+$/i,Ul=/[\0\t\n\r #%/:<>?@[\\\]^|]/,ql=/[\0\t\n\r #/:<>?@[\\\]^|]/,Ll=/^[\u0000-\u0020]+/,xl=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,jl=/[\t\n\r]/g,Nl=function(e){var t,r,n,o;if("number"==typeof e){for(t=[],r=0;r<4;r++)wl(t,e%256),e=cl(e/256);return hl(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,o=0,i=0;i<8;i++)0!==e[i]?(o>r&&(t=n,r=o),n=null,o=0):(null===n&&(n=i),++o);return o>r?n:t}(e),r=0;r<8;r++)o&&0===e[r]||(o&&(o=!1),n===r?(t+=r?":":"::",o=!0):(t+=fl(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},Dl={},Wl=Vu({},Dl,{" ":1,'"':1,"<":1,">":1,"`":1}),Bl=Vu({},Wl,{"#":1,"?":1,"{":1,"}":1}),Fl=Vu({},Bl,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Ml=function(e,t){var r=Yu(e,0);return r>32&&r<127&&!zu(t,e)?e:encodeURIComponent(e)},Hl={ftp:21,file:null,http:80,https:443,ws:80,wss:443},zl=function(e,t){var r;return 2===e.length&&dl(El,ll(e,0))&&(":"===(r=ll(e,1))||!t&&"|"===r)},Vl=function(e){var t;return e.length>1&&zl(bl(e,0,2))&&(2===e.length||"/"===(t=ll(e,2))||"\\"===t||"?"===t||"#"===t)},Gl=function(e){return"."===e||"%2e"===_l(e)},Kl=function(e){return".."===(e=_l(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},Yl={},Ql={},Jl={},$l={},Xl={},Zl={},ed={},td={},rd={},nd={},od={},id={},sd={},ad={},cd={},ud={},ld={},dd={},hd={},fd={},pd={},vd=function(e,t,r){var n,o,i,s=Ju(e);if(t){if(o=this.parse(s))throw new sl(o);this.searchParams=null}else{if(void 0!==r&&(n=new vd(r,!0)),o=this.parse(s,null,n))throw new sl(o);(i=ol(new nl)).bindURL(this),this.searchParams=i}};vd.prototype={type:"URL",parse:function(e,t,r){var n,o,i,s,a=this,c=t||Yl,u=0,l="",d=!1,h=!1,f=!1;for(e=Ju(e),t||(a.scheme="",a.username="",a.password="",a.host=null,a.port=null,a.path=[],a.query=null,a.fragment=null,a.cannotBeABaseURL=!1,e=yl(e,Ll,""),e=yl(e,xl,"$1")),e=yl(e,jl,""),n=Gu(e);u<=n.length;){switch(o=n[u],c){case Yl:if(!o||!dl(El,o)){if(t)return Sl;c=Jl;continue}l+=_l(o),c=Ql;break;case Ql:if(o&&(dl(Tl,o)||"+"===o||"-"===o||"."===o))l+=_l(o);else{if(":"!==o){if(t)return Sl;l="",c=Jl,u=0;continue}if(t&&(a.isSpecial()!==zu(Hl,l)||"file"===l&&(a.includesCredentials()||null!==a.port)||"file"===a.scheme&&!a.host))return;if(a.scheme=l,t)return void(a.isSpecial()&&Hl[a.scheme]===a.port&&(a.port=null));l="","file"===a.scheme?c=ad:a.isSpecial()&&r&&r.scheme===a.scheme?c=$l:a.isSpecial()?c=td:"/"===n[u+1]?(c=Xl,u++):(a.cannotBeABaseURL=!0,vl(a.path,""),c=hd)}break;case Jl:if(!r||r.cannotBeABaseURL&&"#"!==o)return Sl;if(r.cannotBeABaseURL&&"#"===o){a.scheme=r.scheme,a.path=Ku(r.path),a.query=r.query,a.fragment="",a.cannotBeABaseURL=!0,c=pd;break}c="file"===r.scheme?ad:Zl;continue;case $l:if("/"!==o||"/"!==n[u+1]){c=Zl;continue}c=rd,u++;break;case Xl:if("/"===o){c=nd;break}c=dd;continue;case Zl:if(a.scheme=r.scheme,o===tu)a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,a.path=Ku(r.path),a.query=r.query;else if("/"===o||"\\"===o&&a.isSpecial())c=ed;else if("?"===o)a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,a.path=Ku(r.path),a.query="",c=fd;else{if("#"!==o){a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,a.path=Ku(r.path),a.path.length--,c=dd;continue}a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,a.path=Ku(r.path),a.query=r.query,a.fragment="",c=pd}break;case ed:if(!a.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){a.username=r.username,a.password=r.password,a.host=r.host,a.port=r.port,c=dd;continue}c=nd}else c=rd;break;case td:if(c=rd,"/"!==o||"/"!==ll(l,u+1))continue;u++;break;case rd:if("/"!==o&&"\\"!==o){c=nd;continue}break;case nd:if("@"===o){d&&(l="%40"+l),d=!0,i=Gu(l);for(var p=0;p<i.length;p++){var v=i[p];if(":"!==v||f){var y=Ml(v,Fl);f?a.password+=y:a.username+=y}else f=!0}l=""}else if(o===tu||"/"===o||"?"===o||"#"===o||"\\"===o&&a.isSpecial()){if(d&&""===l)return"Invalid authority";u-=Gu(l).length+1,l="",c=od}else l+=o;break;case od:case id:if(t&&"file"===a.scheme){c=ud;continue}if(":"!==o||h){if(o===tu||"/"===o||"?"===o||"#"===o||"\\"===o&&a.isSpecial()){if(a.isSpecial()&&""===l)return Il;if(t&&""===l&&(a.includesCredentials()||null!==a.port))return;if(s=a.parseHost(l))return s;if(l="",c=ld,t)return;continue}"["===o?h=!0:"]"===o&&(h=!1),l+=o}else{if(""===l)return Il;if(s=a.parseHost(l))return s;if(l="",c=sd,t===id)return}break;case sd:if(!dl(Rl,o)){if(o===tu||"/"===o||"?"===o||"#"===o||"\\"===o&&a.isSpecial()||t){if(""!==l){var g=al(l,10);if(g>65535)return Pl;a.port=a.isSpecial()&&g===Hl[a.scheme]?null:g,l=""}if(t)return;c=ld;continue}return Pl}l+=o;break;case ad:if(a.scheme="file","/"===o||"\\"===o)c=cd;else{if(!r||"file"!==r.scheme){c=dd;continue}switch(o){case tu:a.host=r.host,a.path=Ku(r.path),a.query=r.query;break;case"?":a.host=r.host,a.path=Ku(r.path),a.query="",c=fd;break;case"#":a.host=r.host,a.path=Ku(r.path),a.query=r.query,a.fragment="",c=pd;break;default:Vl(hl(Ku(n,u),""))||(a.host=r.host,a.path=Ku(r.path),a.shortenPath()),c=dd;continue}}break;case cd:if("/"===o||"\\"===o){c=ud;break}r&&"file"===r.scheme&&!Vl(hl(Ku(n,u),""))&&(zl(r.path[0],!0)?vl(a.path,r.path[0]):a.host=r.host),c=dd;continue;case ud:if(o===tu||"/"===o||"\\"===o||"?"===o||"#"===o){if(!t&&zl(l))c=dd;else if(""===l){if(a.host="",t)return;c=ld}else{if(s=a.parseHost(l))return s;if("localhost"===a.host&&(a.host=""),t)return;l="",c=ld}continue}l+=o;break;case ld:if(a.isSpecial()){if(c=dd,"/"!==o&&"\\"!==o)continue}else if(t||"?"!==o)if(t||"#"!==o){if(o!==tu&&(c=dd,"/"!==o))continue}else a.fragment="",c=pd;else a.query="",c=fd;break;case dd:if(o===tu||"/"===o||"\\"===o&&a.isSpecial()||!t&&("?"===o||"#"===o)){if(Kl(l)?(a.shortenPath(),"/"===o||"\\"===o&&a.isSpecial()||vl(a.path,"")):Gl(l)?"/"===o||"\\"===o&&a.isSpecial()||vl(a.path,""):("file"===a.scheme&&!a.path.length&&zl(l)&&(a.host&&(a.host=""),l=ll(l,0)+":"),vl(a.path,l)),l="","file"===a.scheme&&(o===tu||"?"===o||"#"===o))for(;a.path.length>1&&""===a.path[0];)gl(a.path);"?"===o?(a.query="",c=fd):"#"===o&&(a.fragment="",c=pd)}else l+=Ml(o,Bl);break;case hd:"?"===o?(a.query="",c=fd):"#"===o?(a.fragment="",c=pd):o!==tu&&(a.path[0]+=Ml(o,Dl));break;case fd:t||"#"!==o?o!==tu&&("'"===o&&a.isSpecial()?a.query+="%27":a.query+="#"===o?"%23":Ml(o,Dl)):(a.fragment="",c=pd);break;case pd:o!==tu&&(a.fragment+=Ml(o,Wl))}u++}},parseHost:function(e){var t,r,n;if("["===ll(e,0)){if("]"!==ll(e,e.length-1))return Il;if(t=function(e){var t,r,n,o,i,s,a,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,h=function(){return ll(e,d)};if(":"===h()){if(":"!==ll(e,1))return;d+=2,l=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=r=0;r<4&&dl(kl,h());)t=16*t+al(h(),16),d++,r++;if("."===h()){if(0===r)return;if(d-=r,u>6)return;for(n=0;h();){if(o=null,n>0){if(!("."===h()&&n<4))return;d++}if(!dl(Rl,h()))return;for(;dl(Rl,h());){if(i=al(h(),10),null===o)o=i;else{if(0===o)return;o=10*o+i}if(o>255)return;d++}c[u]=256*c[u]+o,2!==++n&&4!==n||u++}if(4!==n)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(s=u-l,u=7;0!==u&&s>0;)a=c[u],c[u--]=c[l+s-1],c[l+--s]=a;else if(8!==u)return;return c}(bl(e,1,-1)),!t)return Il;this.host=t}else if(this.isSpecial()){if(e=Qu(e),dl(Ul,e))return Il;if(t=function(e){var t,r,n,o,i,s,a,c=ml(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""===(o=c[n]))return e;if(i=10,o.length>1&&"0"===ll(o,0)&&(i=dl(Cl,o)?16:8,o=bl(o,8===i?1:2)),""===o)s=0;else{if(!dl(10===i?Al:8===i?Ol:kl,o))return e;s=al(o,i)}vl(r,s)}for(n=0;n<t;n++)if(s=r[n],n===t-1){if(s>=ul(256,5-t))return null}else if(s>255)return null;for(a=pl(r),n=0;n<r.length;n++)a+=r[n]*ul(256,3-n);return a}(e),null===t)return Il;this.host=t}else{if(dl(ql,e))return Il;for(t="",r=Gu(e),n=0;n<r.length;n++)t+=Ml(r[n],Dl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return zu(Hl,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&zl(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,o=e.host,i=e.port,s=e.path,a=e.query,c=e.fragment,u=t+":";return null!==o?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=Nl(o),null!==i&&(u+=":"+i)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?s[0]:s.length?"/"+hl(s,"/"):"",null!==a&&(u+="?"+a),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw new sl(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new yd(e.path[0]).origin}catch(e){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+Nl(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Ju(e)+":",Yl)},getUsername:function(){return this.username},setUsername:function(e){var t=Gu(Ju(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=Ml(t[r],Fl)}},getPassword:function(){return this.password},setPassword:function(e){var t=Gu(Ju(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=Ml(t[r],Fl)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?Nl(e):Nl(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,od)},getHostname:function(){var e=this.host;return null===e?"":Nl(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,id)},getPort:function(){var e=this.port;return null===e?"":Ju(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=Ju(e))?this.port=null:this.parse(e,sd))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+hl(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,ld))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=Ju(e))?this.query=null:("?"===ll(e,0)&&(e=bl(e,1)),this.query="",this.parse(e,fd)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=Ju(e))?("#"===ll(e,0)&&(e=bl(e,1)),this.fragment="",this.parse(e,pd)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var yd=function(e){var t=Hu(this,gd),r=Xu(arguments.length,1)>1?arguments[1]:void 0,n=tl(t,new vd(e,!1,r));ju||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},gd=yd.prototype,md=function(e,t){return{get:function(){return rl(this)[e]()},set:t&&function(e){return rl(this)[t](e)},configurable:!0,enumerable:!0}};if(ju&&(Mu(gd,"href",md("serialize","setHref")),Mu(gd,"origin",md("getOrigin")),Mu(gd,"protocol",md("getProtocol","setProtocol")),Mu(gd,"username",md("getUsername","setUsername")),Mu(gd,"password",md("getPassword","setPassword")),Mu(gd,"host",md("getHost","setHost")),Mu(gd,"hostname",md("getHostname","setHostname")),Mu(gd,"port",md("getPort","setPort")),Mu(gd,"pathname",md("getPathname","setPathname")),Mu(gd,"search",md("getSearch","setSearch")),Mu(gd,"searchParams",md("getSearchParams")),Mu(gd,"hash",md("getHash","setHash"))),Fu(gd,"toJSON",function(){return rl(this).serialize()},{enumerable:!0}),Fu(gd,"toString",function(){return rl(this).serialize()},{enumerable:!0}),il){var bd=il.createObjectURL,_d=il.revokeObjectURL;bd&&Fu(yd,"createObjectURL",Wu(bd,il)),_d&&Fu(yd,"revokeObjectURL",Wu(_d,il))}$u(yd,"URL"),xu({global:!0,constructor:!0,forced:!Nu,sham:!ju},{URL:yd});var wd=Sn,Sd=C,Id=As,Pd=vs,Ed=ss,Td=Ce("URL"),Rd=Ed&&Sd(function(){Td.canParse()}),Cd=Sd(function(){return 1!==Td.canParse.length});wd({target:"URL",stat:!0,forced:!Rd||Cd},{canParse:function(e){var t=Id(arguments.length,1),r=Pd(e),n=t<2||void 0===arguments[1]?void 0:Pd(arguments[1]);try{return!!new Td(r,n)}catch(e){return!1}}});var Od=Sn,Ad=As,kd=vs,Ud=ss,qd=Ce("URL");Od({target:"URL",stat:!0,forced:!Ud},{parse:function(e){var t=Ad(arguments.length,1),r=kd(e),n=t<2||void 0===arguments[1]?void 0:kd(arguments[1]);try{return new qd(r,n)}catch(e){return null}}});var Ld=E(Ie.URL),xd=function(e){function t(t){var r=e.call(this,t.message)||this;return r.name="PostgrestError",r.details=t.details,r.hint=t.hint,r.code=t.code,r}return r(t,e),t}(Error),jd=function(){function e(e){var t,r;this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!==(t=e.shouldThrowOnError)&&void 0!==t&&t,this.signal=e.signal,this.isMaybeSingle=null!==(r=e.isMaybeSingle)&&void 0!==r&&r,e.fetch?this.fetch=e.fetch:this.fetch=fetch}return e.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},e.prototype.setHeader=function(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this},e.prototype.then=function(e,t){var r=this;void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json");var n=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(function(e){return o(r,0,void 0,function(){var t,r,n,o,s,a,c,u,l,d,h,f;return i(this,function(i){switch(i.label){case 0:return t=null,r=null,n=null,o=e.status,s=e.statusText,e.ok?"HEAD"===this.method?[3,2]:[4,e.text()]:[3,3];case 1:""===(u=i.sent())||(r="text/csv"===this.headers.get("Accept")||this.headers.get("Accept")&&(null===(l=this.headers.get("Accept"))||void 0===l?void 0:l.includes("application/vnd.pgrst.plan+text"))?u:JSON.parse(u)),i.label=2;case 2:return a=null===(d=this.headers.get("Prefer"))||void 0===d?void 0:d.match(/count=(exact|planned|estimated)/),c=null===(h=e.headers.get("content-range"))||void 0===h?void 0:h.split("/"),a&&c&&c.length>1&&(n=parseInt(c[1])),this.isMaybeSingle&&"GET"===this.method&&Array.isArray(r)&&(r.length>1?(t={code:"PGRST116",details:"Results contain ".concat(r.length," rows, application/vnd.pgrst.object+json requires 1 row"),hint:null,message:"JSON object requested, multiple (or no) rows returned"},r=null,n=null,o=406,s="Not Acceptable"):r=1===r.length?r[0]:null),[3,5];case 3:return[4,e.text()];case 4:u=i.sent();try{t=JSON.parse(u),Array.isArray(t)&&404===e.status&&(r=[],t=null,o=200,s="OK")}catch(r){404===e.status&&""===u?(o=204,s="No Content"):t={message:u}}if(t&&this.isMaybeSingle&&(null===(f=null==t?void 0:t.details)||void 0===f?void 0:f.includes("0 rows"))&&(t=null,o=200,s="OK"),t&&this.shouldThrowOnError)throw new xd(t);i.label=5;case 5:return[2,{error:t,data:r,count:n,status:o,statusText:s}]}})})});return this.shouldThrowOnError||(n=n.catch(function(e){var t,r,n;return{error:{message:"".concat(null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"FetchError",": ").concat(null==e?void 0:e.message),details:"".concat(null!==(r=null==e?void 0:e.stack)&&void 0!==r?r:""),hint:"",code:"".concat(null!==(n=null==e?void 0:e.code)&&void 0!==n?n:"")},data:null,count:null,status:0,statusText:""}})),n.then(e,t)},e.prototype.returns=function(){return this},e.prototype.overrideTypes=function(){return this},e}(),Nd=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.select=function(e){var t=!1,r=(null!=e?e:"*").split("").map(function(e){return/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)}).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this},t.prototype.order=function(e,t){var r=void 0===t?{}:t,n=r.ascending,o=void 0===n||n,i=r.nullsFirst,s=r.foreignTable,a=r.referencedTable,c=void 0===a?s:a,u=c?"".concat(c,".order"):"order",l=this.url.searchParams.get(u);return this.url.searchParams.set(u,"".concat(l?"".concat(l,","):"").concat(e,".").concat(o?"asc":"desc").concat(void 0===i?"":i?".nullsfirst":".nullslast")),this},t.prototype.limit=function(e,t){var r=void 0===t?{}:t,n=r.foreignTable,o=r.referencedTable,i=void 0===o?n:o,s=void 0===i?"limit":"".concat(i,".limit");return this.url.searchParams.set(s,"".concat(e)),this},t.prototype.range=function(e,t,r){var n=void 0===r?{}:r,o=n.foreignTable,i=n.referencedTable,s=void 0===i?o:i,a=void 0===s?"offset":"".concat(s,".offset"),c=void 0===s?"limit":"".concat(s,".limit");return this.url.searchParams.set(a,"".concat(e)),this.url.searchParams.set(c,"".concat(t-e+1)),this},t.prototype.abortSignal=function(e){return this.signal=e,this},t.prototype.single=function(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this},t.prototype.maybeSingle=function(){return"GET"===this.method?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this},t.prototype.csv=function(){return this.headers.set("Accept","text/csv"),this},t.prototype.geojson=function(){return this.headers.set("Accept","application/geo+json"),this},t.prototype.explain=function(e){var t,r=void 0===e?{}:e,n=r.analyze,o=void 0!==n&&n,i=r.verbose,s=void 0!==i&&i,a=r.settings,c=void 0!==a&&a,u=r.buffers,l=void 0!==u&&u,d=r.wal,h=void 0!==d&&d,f=r.format,p=void 0===f?"text":f,v=[o?"analyze":null,s?"verbose":null,c?"settings":null,l?"buffers":null,h?"wal":null].filter(Boolean).join("|"),y=null!==(t=this.headers.get("Accept"))&&void 0!==t?t:"application/json";return this.headers.set("Accept","application/vnd.pgrst.plan+".concat(p,'; for="').concat(y,'"; options=').concat(v,";")),this},t.prototype.rollback=function(){return this.headers.append("Prefer","tx=rollback"),this},t.prototype.returns=function(){return this},t.prototype.maxAffected=function(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer","max-affected=".concat(e)),this},t}(jd),Dd=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.eq=function(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this},t.prototype.neq=function(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this},t.prototype.gt=function(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this},t.prototype.gte=function(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this},t.prototype.lt=function(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this},t.prototype.lte=function(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this},t.prototype.like=function(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this},t.prototype.likeAllOf=function(e,t){return this.url.searchParams.append(e,"like(all).{".concat(t.join(","),"}")),this},t.prototype.likeAnyOf=function(e,t){return this.url.searchParams.append(e,"like(any).{".concat(t.join(","),"}")),this},t.prototype.ilike=function(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this},t.prototype.ilikeAllOf=function(e,t){return this.url.searchParams.append(e,"ilike(all).{".concat(t.join(","),"}")),this},t.prototype.ilikeAnyOf=function(e,t){return this.url.searchParams.append(e,"ilike(any).{".concat(t.join(","),"}")),this},t.prototype.is=function(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this},t.prototype.in=function(e,t){var r=Array.from(new Set(t)).map(function(e){return"string"==typeof e&&new RegExp("[,()]").test(e)?'"'.concat(e,'"'):"".concat(e)}).join(",");return this.url.searchParams.append(e,"in.(".concat(r,")")),this},t.prototype.contains=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this},t.prototype.containedBy=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this},t.prototype.rangeGt=function(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this},t.prototype.rangeGte=function(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this},t.prototype.rangeLt=function(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this},t.prototype.rangeLte=function(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this},t.prototype.rangeAdjacent=function(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this},t.prototype.overlaps=function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this},t.prototype.textSearch=function(e,t,r){var n=void 0===r?{}:r,o=n.config,i=n.type,s="";"plain"===i?s="pl":"phrase"===i?s="ph":"websearch"===i&&(s="w");var a=void 0===o?"":"(".concat(o,")");return this.url.searchParams.append(e,"".concat(s,"fts").concat(a,".").concat(t)),this},t.prototype.match=function(e){var t=this;return Object.entries(e).forEach(function(e){var r=e[0],n=e[1];t.url.searchParams.append(r,"eq.".concat(n))}),this},t.prototype.not=function(e,t,r){return this.url.searchParams.append(e,"not.".concat(t,".").concat(r)),this},t.prototype.or=function(e,t){var r=void 0===t?{}:t,n=r.foreignTable,o=r.referencedTable,i=void 0===o?n:o,s=i?"".concat(i,".or"):"or";return this.url.searchParams.append(s,"(".concat(e,")")),this},t.prototype.filter=function(e,t,r){return this.url.searchParams.append(e,"".concat(t,".").concat(r)),this},t}(Nd),Wd=function(){function e(e,t){var r=t.headers,n=void 0===r?{}:r,o=t.schema,i=t.fetch;this.url=e,this.headers=new Headers(n),this.schema=o,this.fetch=i}return e.prototype.select=function(e,t){var r=void 0===t?{}:t,n=r.head,o=void 0!==n&&n,i=r.count,s=o?"HEAD":"GET",a=!1,c=(null!=e?e:"*").split("").map(function(e){return/\s/.test(e)&&!a?"":('"'===e&&(a=!a),e)}).join("");return this.url.searchParams.set("select",c),i&&this.headers.append("Prefer","count=".concat(i)),new Dd({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})},e.prototype.insert=function(e,t){var r,n=void 0===t?{}:t,o=n.count,i=n.defaultToNull,s=void 0===i||i;if(o&&this.headers.append("Prefer","count=".concat(o)),s||this.headers.append("Prefer","missing=default"),Array.isArray(e)){var a=e.reduce(function(e,t){return e.concat(Object.keys(t))},[]);if(a.length>0){var c=Array.from(new Set(a)).map(function(e){return'"'.concat(e,'"')});this.url.searchParams.set("columns",c.join(","))}}return new Dd({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.upsert=function(e,t){var r,n=void 0===t?{}:t,o=n.onConflict,i=n.ignoreDuplicates,s=void 0!==i&&i,a=n.count,c=n.defaultToNull,u=void 0===c||c;if(this.headers.append("Prefer","resolution=".concat(s?"ignore":"merge","-duplicates")),void 0!==o&&this.url.searchParams.set("on_conflict",o),a&&this.headers.append("Prefer","count=".concat(a)),u||this.headers.append("Prefer","missing=default"),Array.isArray(e)){var l=e.reduce(function(e,t){return e.concat(Object.keys(t))},[]);if(l.length>0){var d=Array.from(new Set(l)).map(function(e){return'"'.concat(e,'"')});this.url.searchParams.set("columns",d.join(","))}}return new Dd({method:"POST",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.update=function(e,t){var r,n=(void 0===t?{}:t).count;return n&&this.headers.append("Prefer","count=".concat(n)),new Dd({method:"PATCH",url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:null!==(r=this.fetch)&&void 0!==r?r:fetch})},e.prototype.delete=function(e){var t,r=(void 0===e?{}:e).count;return r&&this.headers.append("Prefer","count=".concat(r)),new Dd({method:"DELETE",url:this.url,headers:this.headers,schema:this.schema,fetch:null!==(t=this.fetch)&&void 0!==t?t:fetch})},e}(),Bd=function(e){function t(t,r){var n=r.headers,o=void 0===n?{}:n,i=r.fetch;return e.call(this,t,{headers:o,schema:void 0,fetch:i})||this}return r(t,e),t}(Wd),Fd=function(){function e(e,t){var r=void 0===t?{}:t,n=r.headers,o=void 0===n?{}:n,i=r.fetch;this.url=e,this.headers=new Headers(o),this.fetch=i}return e.prototype.from=function(e){var t=new Ld("".concat(this.url,"/").concat(e));return new Bd(t,{headers:this.headers,fetch:this.fetch})},e}();function Md(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Hd(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function zd(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Hd(Object(r),!0).forEach(function(t){Md(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hd(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}const Vd="/auth";var Gd,Kd,Yd,Qd;!function(e){e.AUTH_SIGN_UP_URL="/v1/signup",e.AUTH_TOKEN_URL="/v1/token",e.AUTH_REVOKE_URL="/v1/revoke",e.WEDA_USER_URL="/v1/plugin/weda/userinfo",e.AUTH_RESET_PASSWORD="/v1/reset",e.AUTH_GET_DEVICE_CODE="/v1/device/code",e.CHECK_USERNAME="/v1/checkUsername",e.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",e.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",e.AUTH_SIGN_IN_URL="/v1/signin",e.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",e.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",e.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",e.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",e.PROVIDER_TOKEN_URL="/v1/provider/token",e.PROVIDER_URI_URL="/v1/provider/uri",e.USER_ME_URL="/v1/user/me",e.AUTH_SIGNOUT_URL="/v1/user/signout",e.USER_QUERY_URL="/v1/user/query",e.USER_PRIFILE_URL="/v1/user/profile",e.USER_BASIC_EDIT_URL="/v1/user/basic/edit",e.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",e.PROVIDER_LIST="/v1/user/provider",e.PROVIDER_BIND_URL="/v1/user/provider/bind",e.PROVIDER_UNBIND_URL="/v1/user/provider",e.CHECK_PWD_URL="/v1/user/sudo",e.SUDO_URL="/v1/user/sudo",e.BIND_CONTACT_URL="/v1/user/contact",e.AUTH_SET_PASSWORD="/v1/user/password",e.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",e.AUTHORIZE_URL="/v1/user/authorize",e.AUTHORIZE_INFO_URL="/v1/user/authorize/info",e.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",e.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",e.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",e.VERIFICATION_URL="/v1/verification",e.VERIFY_URL="/v1/verification/verify",e.CAPTCHA_DATA_URL="/v1/captcha/data",e.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",e.GET_CAPTCHA_URL="/v1/captcha/init",e.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",e.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status"}(Gd||(Gd={})),function(e){e.AUTH_SIGN_IN_URL="/v2/signin/username",e.AUTH_TOKEN_URL="/v2/token",e.USER_ME_URL="/v2/user/me",e.VERIFY_URL="/v2/signin/verificationcode",e.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",e.AUTH_PUBLIC_KEY="/v2/signin/publichkey",e.AUTH_RESET_PASSWORD="/v2/signin/password/update"}(Kd||(Kd={})),function(e){e.REGISTER="REGISTER",e.SIGN_IN="SIGN_IN",e.PASSWORD_RESET="PASSWORD_RESET",e.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",e.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE"}(Yd||(Yd={})),function(e){e.UNREACHABLE="unreachable",e.LOCAL="local",e.CANCELLED="cancelled",e.UNKNOWN="unknown",e.UNAUTHENTICATED="unauthenticated",e.RESOURCE_EXHAUSTED="resource_exhausted",e.FAILED_PRECONDITION="failed_precondition",e.INVALID_ARGUMENT="invalid_argument",e.DEADLINE_EXCEEDED="deadline_exceeded",e.NOT_FOUND="not_found",e.ALREADY_EXISTS="already_exists",e.PERMISSION_DENIED="permission_denied",e.ABORTED="aborted",e.OUT_OF_RANGE="out_of_range",e.UNIMPLEMENTED="unimplemented",e.INTERNAL="internal",e.UNAVAILABLE="unavailable",e.DATA_LOSS="data_loss",e.INVALID_PASSWORD="invalid_password",e.PASSWORD_NOT_SET="password_not_set",e.INVALID_STATUS="invalid_status",e.USER_PENDING="user_pending",e.USER_BLOCKED="user_blocked",e.INVALID_VERIFICATION_CODE="invalid_verification_code",e.TWO_FACTOR_REQUIRED="two_factor_required",e.INVALID_TWO_FACTOR="invalid_two_factor",e.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",e.UNDER_REVIEW="under_review",e.INVALID_REQUEST="invalid_request",e.UNAUTHORIZED_CLIENT="unauthorized_client",e.ACCESS_DENIED="access_denied",e.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",e.INVALID_SCOPE="invalid_scope",e.INVALID_GRANT="invalid_grant",e.SERVER_ERROR="server_error",e.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",e.INTERACTION_REQUIRED="interaction_required",e.LOGIN_REQUIRED="login_required",e.ACCOUNT_SELECTION_REQUIRED="account_selection_required",e.CONSENT_REQUIRED="consent_required",e.INVALID_REQUEST_URI="invalid_request_uri",e.INVALID_REQUEST_OBJECT="invalid_request_object",e.REQUEST_NOT_SUPPORTED="request_not_supported",e.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",e.REGISTRATION_NOT_SUPPORTED="registration_not_supported",e.CAPTCHA_REQUIRED="captcha_required",e.CAPTCHA_INVALID="captcha_invalid"}(Qd||(Qd={}));const Jd="sign_out",$d="sign_in",Xd="credentials_error",Zd="SIGNED_OUT",eh="SIGNED_IN",th="INITIAL_SESSION",rh="PASSWORD_RECOVERY",nh="TOKEN_REFRESHED",oh="USER_UPDATED",ih="BIND_IDENTITY",sh="loginStateChanged",ah="authStateChanged",ch="sign_in",uh="bind_identity";var lh;function dh(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}!function(e){e.CLIENT_ID="client_id",e.CLIENT_SECRET="client_secret",e.RESPONSE_TYPE="response_type",e.SCOPE="scope",e.STATE="state",e.REDIRECT_URI="redirect_uri",e.ERROR="error",e.ERROR_DESCRIPTION="error_description",e.ERROR_URI="error_uri",e.GRANT_TYPE="grant_type",e.CODE="code",e.ACCESS_TOKEN="access_token",e.TOKEN_TYPE="token_type",e.EXPIRES_IN="expires_in",e.USERNAME="username",e.PASSWORD="password",e.REFRESH_TOKEN="refresh_token"}(lh||(lh={}));const hh=e=>{const t=t=>{for(const r in e)e.hasOwnProperty(r)&&(t[r]=hh(e[r]));return t},r=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return e.slice();switch(r){case"Object":return t(Object.create(Object.getPrototypeOf(e)));case"Array":return t([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},fh=e=>{const t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""};let ph=new Map;class vh{constructor(e){this.clientId=(null==e?void 0:e.clientId)||"",ph=ph||new Map}async run(e,t){e="".concat(this.clientId,"_").concat(e);let r=ph.get(e);return r||(r=new Promise((r,n)=>{(async()=>{try{await this.runIdlePromise();const e=t();r(await e)}catch(e){n(e)}finally{ph.delete(e)}})()}),ph.set(e,r)),r}runIdlePromise(){return Promise.resolve()}}const yh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",gh=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;const mh=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!gh.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");let t;e+="==".slice(2-(3&e.length));let r,n,o="",i=0;for(;i<e.length;)t=yh.indexOf(e.charAt(i++))<<18|yh.indexOf(e.charAt(i++))<<12|(r=yh.indexOf(e.charAt(i++)))<<6|(n=yh.indexOf(e.charAt(i++))),o+=64===r?String.fromCharCode(t>>16&255):64===n?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return o};function bh(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent(mh(e).replace(/(.)/g,e=>{let t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)}))}(t)}catch(e){return mh(t)}}function _h(){if("undefined"==typeof globalThis)return!1;const{wx:e}=globalThis;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}let wh=!1;function Sh(){wh=wh||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{_h()||(wh=wh||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?Sh():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",Sh,!1))}catch(lf){}var Ih,Ph="undefined"!=typeof process&&void 0!==process.env&&"development"===process.env.NODE_ENV,Eh="https://support.qq.com/products/148793",Th="INVALID_PARAMS",Rh="INVALID_OPERATION",Ch="OPERATION_FAIL";!function(e){e.local="local",e.none="none",e.session="session"}(Ih||(Ih={}));var Oh=function(){},Ah=function(){},kh=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};function Uh(e,t){if("undefined"==typeof window)return!1;var r=decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}function qh(e,t){console.warn("[".concat("@cloudbase/js-sdk","][").concat(e,"]:").concat(t))}function Lh(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat("@cloudbase/js-sdk","][").concat(e,"]:").concat(t)}))}function xh(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,c=void 0!==a&&a,u=e.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,d=s;l<d.length;l++){var h=d[l],f=h.type,p=h.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}c&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)}function jh(e){var t={},r=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){e=r[1];var n=r[2];n&&(t=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach(function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)}),t}(n))}var o=t.token,i=kh(t,["token"]);return/^data:/.test(e)&&!o?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:o?{state:i.state,token:o,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}var Nh=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Dh=this&&this.__assign||function(){return Dh=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Dh.apply(this,arguments)},Wh=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},Bh=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Fh=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return Nh(t,e),t.prototype.get=function(e){return this.request(Dh(Dh({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(Dh(Dh({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(Dh(Dh({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,i=e.headers,s=void 0===i?{}:i,a={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===a?(Object.keys(t).forEach(function(e){c.append(e,t[e])}),c.append("key",n),c.append("file",r),this.request(Dh(Dh({},e),{data:c,method:a}),this.restrictedMethods.includes("upload"))):this.request(Dh(Dh({},e),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return Wh(this,void 0,void 0,function(){var t,r,n,o;return Bh(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(Dh(Dh({},e),{headers:{},responseType:"blob"}))];case 1:return t=i.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise(function(t){t({statusCode:200,tempFilePath:e.url})})]}})})},t.prototype.fetch=function(e){var t;return Wh(this,void 0,void 0,function(){var r,n,o,i,s,a,c,u,l,d,h,f,p,v=this;return Bh(this,function(y){switch(y.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,i=void 0!==o&&o,s=e.stream,a=void 0!==s&&s,c=e.signal,u=e.timeout,l=e.shouldThrowOnError,d=void 0===l||l,h=null!=u?u:this.timeout,c&&(c.aborted&&r.abort(),c.addEventListener("abort",function(){return r.abort()})),f=null,i&&h&&(f=setTimeout(function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))},h)),[4,fetch(n,Dh(Dh({},e),{signal:r.signal})).then(function(e){return Wh(v,void 0,void 0,function(){var t,r,n;return Bh(this,function(o){switch(o.label){case 0:return clearTimeout(f),d?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){if(clearTimeout(f),d)return Promise.reject(e)})];case 1:return p=y.sent(),[2,{data:a?p.body:(null===(t=p.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?p.json():p.text(),statusCode:p.status,header:p.headers}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i,s,a,c=e.url,u=e.headers,l=void 0===u?{}:u,d=e.data,h=e.responseType,f=e.withCredentials,p=e.body,v=e.onUploadProgress,y=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach(function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)}("https:",c,"get"===n?d:{}),g=new XMLHttpRequest;g.open(n,y),h&&(g.responseType=h),Object.keys(l).forEach(function(e){g.setRequestHeader(e,l[e])}),v&&g.upload.addEventListener("progress",v),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach(function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o}),e.header=r,e.statusCode=g.status;try{e.data="blob"===h?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===h?g.response:g.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout(function(){console.warn(r.timeoutMsg),g.abort()},r.timeout)),a=d,s="[object FormData]"===Object.prototype.toString.call(a)?d:"application/x-www-form-urlencoded"===l["content-type"]?function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")}(d):p||(d?JSON.stringify(d):void 0),f&&(g.withCredentials=!0),g.send(s)})},t}(Oh);var Mh,Hh=this&&this.__assign||function(){return Hh=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Hh.apply(this,arguments)};function zh(){return{adapter:Hh({},{type:"default",root:window,reqClass:Fh,wsClass:WebSocket,localStorage:localStorage}),runtime:Mh.WEB}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(Mh||(Mh={}));var Vh=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Gh=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},Kh=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Yh=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return Vh(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(Ah);var Qh=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:(qh(Th,"localStorage is not supported on current platform"),new Yh(t.root));case"none":return new Yh(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:Ch,msg:"[".concat("@cloudbase/js-sdk","][").concat(Ch,"]setStore failed"),info:e}))}}else qh(Rh,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return Gh(this,void 0,void 0,function(){var n;return Kh(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}qh(Rh,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return Gh(this,void 0,void 0,function(){var n;return Kh(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}})})},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):qh(Rh,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return Gh(this,void 0,void 0,function(){return Kh(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}(),Jh=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),$h=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};var Xh=function(e,t){this.data=t||null,this.name=e},Zh=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return Jh(t,e),t}(Xh),ef=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if(function(e,t){return e instanceof t}(e,Zh))return console.error(e.error),this;var r="string"==typeof e?new Xh(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,i=this.listeners[n]?$h([],this.listeners[n],!0):[];o<i.length;o++){i[o].call(this,r)}}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}(),tf=new ef,rf=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},nf=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},of=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(of=-1!==navigator.userAgent.indexOf("Firefox"));var sf=of?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,af=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function cf(e){var t=e.mode,r=void 0===t?"async":t,n=e.customInfo,o=void 0===n?{}:n,i=e.title,s=e.messages,a=void 0===s?[]:s;return function(e,t,n){if(Ph){var s=o.className||e.constructor.name,c=o.methodName||t,u=n.value,l=function(e){var t="",r=e.stack.split("\n"),n=r.findIndex(function(e){return sf.test(e)});if(-1!==n){var o=af.exec(r[n+1]||"");t=o?o[0]:""}return t}(new Error);n.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=uf({err:new Error,className:s,methodName:c,sourceLink:l});try{return u.apply(this,e)}catch(e){var n=e,o=e.message,d=e.error,h=e.error_description,f={title:i||"".concat(s,".").concat(c," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var p=JSON.parse(o);f.subtitle=o,p.code&&(r?(r.code=p.code,r.msg=p.msg):(e.code=p.code,e.message=p.msg),n=r||e,f.content=a.map(function(e){return{type:"info",body:e}}))}throw d&&h&&(f.subtitle=h,r?(r.code=d,r.msg=h):(e.code=d,e.message=h),n=r||e,f.content=a.map(function(e){return{type:"info",body:e}})),xh(f),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return rf(this,void 0,void 0,function(){var t,r,n,o,d,h,f,p;return nf(this,function(v){switch(v.label){case 0:t=uf({err:new Error,className:s,methodName:c,sourceLink:l}),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,u.apply(this,e)];case 2:return[2,v.sent()];case 3:throw r=v.sent(),n=r,o=r.message,d=r.error,h=r.error_description,f={title:i||"".concat(s,".").concat(c," failed"),content:[{type:"error",body:r}]},o&&/^\{.*\}$/.test(o)&&(p=JSON.parse(o),f.subtitle=p,p.code&&(t?(t.code=p.code,t.message=p.msg):(r.code=p.code,r.message=p.msg),n=t||r,f.content=a.map(function(e){return{type:"info",body:e}}))),d&&h&&(f.subtitle=h,t?(t.code=d,t.msg=h):(r.code=d,r.message=h),n=t||r,f.content=a.map(function(e){return{type:"info",body:e}})),xh(f),n;case 4:return[2]}})})}}}}function uf(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),a=of?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),c=of?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),u=s.findIndex(function(e){return a.test(e)});if(-1!==u){var l=s.filter(function(e,t){return t>u});l.unshift(s[u].replace(c,"".concat(r,".").concat(n)).replace(af,o)),(i=new Error).stack="".concat(of?"@debugger":"Error","\n").concat(l.join("\n"))}return i}function lf(e){this.message=e}function df(e){this.message=e}lf.prototype=new Error,lf.prototype.name="InvalidCharacterError","undefined"!=typeof window&&window.atob&&window.atob.bind(window),df.prototype=new Error,df.prototype.name="InvalidTokenError";const hf="x-request-id",ff="x-device-id",pf="device_id",vf=async function(e,t){let r=null,n=null;try{const o=Object.assign({},t);o.method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body));const i=await fetch(e,o),s=await i.json();null!=s&&s.error?(n=s,n.error_uri=new URL(e).pathname):r=s}catch(t){n={error:Qd.UNREACHABLE,error_description:t.message,error_uri:new URL(e).pathname}}if(n)throw n;return r};const yf=new class{constructor(e){this._env=(null==e?void 0:e.env)||""}async getItem(e){return window.localStorage.getItem("".concat(e).concat(this._env))}async removeItem(e){window.localStorage.removeItem("".concat(e).concat(this._env))}async setItem(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)}getItemSync(e){return window.localStorage.getItem("".concat(e).concat(this._env))}removeItemSync(e){window.localStorage.removeItem("".concat(e).concat(this._env))}setItemSync(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)}};function gf(e){let t=!0;return null!=e&&e.expires_at&&null!=e&&e.access_token&&(t=e.expires_at<new Date),t}class mf{constructor(e){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new vh({clientId:this.clientId}),this.credentials=e.credentials||null}getStorageCredentialsSync(){let e=null;const t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{var r;e=JSON.parse(t),null!==(r=e)&&void 0!==r&&r.expires_at&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e}async setCredentials(e){if(null!=e&&e.expires_in){if(null!=e&&e.expires_at||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),this.storage){const t=JSON.stringify(e);await this.storage.setItem(this.tokenSectionName,t)}this.credentials=e}else this.storage&&await this.storage.removeItem(this.tokenSectionName),this.credentials=null}setAccessKeyCredentials(e){this.accessKeyCredentials=e}async getCredentials(){return this.singlePromise.run("getCredentials",async()=>{if(gf(this.credentials)){const{credentials:e,isAccessKeyCredentials:t}=await this.getStorageCredentials();if(t)return e;this.credentials=e}return this.credentials})}async getStorageCredentials(){return this.singlePromise.run("_getStorageCredentials",async()=>{let e=null,t=!1;const r=await this.storage.getItem(this.tokenSectionName);if(r)try{var n;e=JSON.parse(r),null!==(n=e)&&void 0!==n&&n.expires_at&&(e.expires_at=new Date(e.expires_at))}catch(t){await this.storage.removeItem(this.tokenSectionName),e=null}else e=this.accessKeyCredentials||null,t=!0;return{credentials:e,isAccessKeyCredentials:t}})}}class bf{constructor(e){var t;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,e.clientSecret||(e.clientSecret=""),!e.clientId&&e.env&&(e.clientId=e.env),this.apiOrigin=e.apiOrigin,this.apiPath=e.apiPath||Vd,this.clientId=e.clientId,this.i18n=e.i18n,this.eventBus=e.eventBus,this.singlePromise=new vh({clientId:this.clientId}),this.retry=this.formatRetry(e.retry,bf.defaultRetry),e.baseRequest?this.baseRequest=e.baseRequest:this.baseRequest=vf,this.tokenInURL=e.tokenInURL,this.headers=e.headers,this.storage=e.storage||yf,this.localCredentials=new mf({tokenSectionName:"credentials_".concat(e.clientId),storage:this.storage,clientId:e.clientId}),this.clientSecret=e.clientSecret,e.clientId&&(this.basicAuth="Basic ".concat(function(e){let t,r,n,o,i="",s=0;const a=(e=String(e)).length%3;for(;s<e.length;){if((r=e.charCodeAt(s++))>255||(n=e.charCodeAt(s++))>255||(o=e.charCodeAt(s++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");t=r<<16|n<<8|o,i+=yh.charAt(t>>18&63)+yh.charAt(t>>12&63)+yh.charAt(t>>6&63)+yh.charAt(63&t)}return a?i.slice(0,a-3)+"===".substring(a):i}("".concat(e.clientId,":").concat(this.clientSecret)))),this.wxCloud=e.wxCloud;try{_h()&&(this.useWxCloud=e.useWxCloud,void 0===this.wxCloud&&e.env&&(wx.cloud.init({env:e.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=e.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=e.anonymousSignInFunc,this.onCredentialsError=e.onCredentialsError,this.getInitialSession=e.getInitialSession,this.onInitialSessionObtained=e.onInitialSessionObtained,this.logDebugMessages=null!==(t=e.debug)&&void 0!==t&&t,tf.on("lang_change",e=>{var t;this.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||this.i18n})}setGetInitialSession(e){this.getInitialSession=e}setOnInitialSessionObtained(e){this.onInitialSessionObtained=e}async initialize(e){return this.initializePromise?await this.initializePromise:void 0!==e?(this.initializePromise=e,await this.initializePromise):(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async setCredentials(e){return await this.initializePromise,this._acquireLock(-1,async()=>this.localCredentials.setCredentials(e))}setAccessKeyCredentials(e){return this.localCredentials.setAccessKeyCredentials(e)}async getAccessToken(){await this.initializePromise;const e=await this.getCredentials();if(null!=e&&e.access_token)return Promise.resolve(e.access_token);const t={error:Qd.UNAUTHENTICATED};return Promise.reject(t)}async request(e,t){var r,n,o,i;t||(t={});const s=this.formatRetry(t.retry,this.retry);if(t.headers=zd(zd({},t.headers),{},{[null===(r=this.i18n)||void 0===r?void 0:r.LANG_HEADER_KEY]:null===(n=this.i18n)||void 0===n?void 0:n.lang}),this.headers&&(t.headers=zd(zd({},this.headers),t.headers)),t.headers[hf]||(t.headers[hf]=dh()),!t.headers[ff]){const e=await this.getDeviceId();t.headers[ff]=e}if(null!==(o=t)&&void 0!==o&&o.withBasicAuth&&this.basicAuth&&(t.headers.Authorization=this.basicAuth),null!==(i=t)&&void 0!==i&&i.withCredentials){const r=t.getCredentials?await t.getCredentials():await this.getCredentials();r&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(r.access_token)):t.headers.Authorization="".concat(r.token_type," ").concat(r.access_token))}else this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(this.clientId));e.startsWith("/")&&(e="".concat(this.apiOrigin).concat(this.apiPath).concat(e));let a=null;const c=s+1;for(let r=0;r<c;r++){try{var u;if(a=t.useWxCloud||this.useWxCloud?await this.wxCloudCallFunction(e,t):await this.baseRequest(e,t),null!==(u=a)&&void 0!==u&&u.code)throw{error:a.code,error_description:a.message,error_uri:new URL(e).pathname};break}catch(e){if(t.withCredentials&&e&&e.error===Qd.UNAUTHENTICATED)return await this.setCredentials(null),Promise.reject(e);if(r===s||!e||"unreachable"!==e.error)return Promise.reject(e)}await this.sleep(bf.retryInterval)}return a}async wxCloudCallFunction(e,t){let r=null,n=null;try{var o;let i="";try{i=await wx.getRendererUserAgent()}catch(e){}const{result:s}=await this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:zd({origin:"https://servicewechat.com","User-Agent":i},t.headers),body:t.body}});null!=s&&null!==(o=s.body)&&void 0!==o&&o.error_code?(n=null==s?void 0:s.body,n.error_uri=fh(e)):r=null==s?void 0:s.body}catch(t){n={error:Qd.UNREACHABLE,error_description:t.message,error_uri:fh(e)}}if(n)throw n;return r}async getCredentials(){return await this.initializePromise,this._acquireLock(-1,async()=>this._getCredentials())}getCredentialsSync(){return this.localCredentials.getStorageCredentialsSync()}getCredentialsAsync(){return this.getCredentials()}async getScope(){const e=await this.localCredentials.getCredentials();if(!e){var t;const e="credentials not found";return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:e}),this.unAuthenticatedError(e)}return e.scope}async getGroups(){const e=await this.localCredentials.getCredentials();if(!e){var t;const e="credentials not found";return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:e}),this.unAuthenticatedError(e)}return e.groups}async refreshToken(e,t){return await this.initializePromise,this._acquireLock(-1,async()=>this._refreshToken(e,t))}async _refreshToken(e,t){return this.singlePromise.run("_refreshToken",async()=>{if(!e||!e.refresh_token){var r;const e="no refresh token found in credentials";return null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:e}),this.unAuthenticatedError(e)}try{var n;const t=await this.refreshTokenFunc(e.refresh_token,e);return await this.localCredentials.setCredentials(t),null===(n=this.eventBus)||void 0===n||n.fire(ah,{event:nh}),t}catch(e){var o;if(null!=t&&t.throwError)throw e;if(e.error===Qd.INVALID_GRANT){var i;await this.localCredentials.setCredentials(null);const t=e.error_description;return null===(i=this.onCredentialsError)||void 0===i||i.call(this,{msg:t}),this.unAuthenticatedError(t)}return null===(o=this.onCredentialsError)||void 0===o||o.call(this,{msg:e.error_description}),Promise.reject(e)}})}async anonymousLogin(e){return this.singlePromise.run("_anonymousLogin",async()=>{if(this.anonymousSignInFunc){const t=await this.anonymousSignInFunc(e);e=t||await this.localCredentials.getCredentials()}else e=await this.anonymousSignIn(e);return e})}checkRetry(e){let t=null;if(("number"!=typeof e||e<bf.minRetry||e>bf.maxRetry)&&(t={error:Qd.UNREACHABLE,error_description:"wrong options param: retry"}),t)throw t;return e}formatRetry(e,t){return void 0===e?t:this.checkRetry(e)}async sleep(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}async anonymousSignIn(e){return this.singlePromise.run("_anonymous",async()=>{if(!e||"anonymous"!==e.scope)return this.unAuthenticatedError("no anonymous in credentials");try{const e=await this.request(Gd.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}});return await this.localCredentials.setCredentials(e),e}catch(e){return e.error===Qd.INVALID_GRANT?(await this.localCredentials.setCredentials(null),this.unAuthenticatedError(e.error_description)):Promise.reject(e)}})}async defaultRefreshTokenFunc(e,t){if(void 0===e||""===e){var r;const e="refresh token not found";return null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:e}),this.unAuthenticatedError(e)}let n=Gd.AUTH_TOKEN_URL;"v2"===(null==t?void 0:t.version)&&(n=Kd.AUTH_TOKEN_URL);return zd(zd({},await this.request(n,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})),{},{version:(null==t?void 0:t.version)||"v1"})}async getDeviceId(){if(this.deviceID)return this.deviceID;let e=await this.storage.getItem(pf);return"string"==typeof e&&e.length>=16&&e.length<=48||(e=dh(),await this.storage.setItem(pf,e)),this.deviceID=e,e}unAuthenticatedError(e){const t={error:Qd.UNAUTHENTICATED,error_description:e};return Promise.reject(t)}_debug(){if(this.logDebugMessages){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];console.log("[OAuth2Client]",...t)}}async _initialize(){try{if(!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),{error:null};this._debug("#_initialize()","calling getInitialSession callback");try{const{data:e,error:t}=await this.getInitialSession();if(null!=e&&e.session&&(this._debug("#_initialize()","session obtained from getInitialSession",e.session),await this.localCredentials.setCredentials(null==e?void 0:e.session)),this.onInitialSessionObtained){this._debug("#_initialize()","calling onInitialSessionObtained callback");try{await this.onInitialSessionObtained(e,t)}catch(e){this._debug("#_initialize()","error in onInitialSessionObtained",e)}}return t?(this._debug("#_initialize()","error from getInitialSession",t),{error:t}):{error:null}}catch(e){return this._debug("#_initialize()","exception during getInitialSession",e),{error:e instanceof Error?e:new Error(String(e))}}}catch(e){return this._debug("#_initialize()","unexpected error",e),{error:e instanceof Error?e:new Error(String(e))}}finally{this._debug("#_initialize()","end")}}async _acquireLock(e,t){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const e=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=(async()=>(await e,await t()))();return this.pendingInLock.push((async()=>{try{await r}catch(e){}})()),r}this._debug("#_acquireLock","acquiring lock for client",this.clientId);try{this.lockAcquired=!0;const e=t();for(this.pendingInLock.push((async()=>{try{await e}catch(e){}})()),await e;this.pendingInLock.length;){const e=[...this.pendingInLock];await Promise.all(e),this.pendingInLock.splice(0,e.length)}return await e}finally{this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1}}finally{this._debug("#_acquireLock","end")}}async _getCredentials(){let e=await this.localCredentials.getCredentials();if(!e){var t;const e="credentials not found";return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:e}),this.unAuthenticatedError(e)}if(gf(e))if(e.refresh_token)try{e=await this._refreshToken(e)}catch(t){var r;if("anonymous"!==e.scope)return null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:t.error_description}),Promise.reject(t);e=await this.anonymousLogin(e)}else{if("anonymous"!==e.scope){var n;const e="no refresh token found in credentials";return null===(n=this.onCredentialsError)||void 0===n||n.call(this,{msg:e}),this.unAuthenticatedError(e)}e=await this.anonymousLogin(e)}return e}}bf.defaultRetry=2,bf.minRetry=0,bf.maxRetry=5,bf.retryInterval=1e3;const _f=(e,t)=>{let r;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];clearTimeout(r),r=setTimeout(()=>e.apply(null,o),t)}},wf=new ef,Sf="resolveCaptchaData",If="position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999",Pf="position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000",Ef="margin-bottom:15px",Tf="display:flex;align-items:center;justify-content:space-between;margin-bottom:15px",Rf="width:100%;height:auto;border:1px solid #eee",Cf="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",Of="width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px",Af="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",kf="background:#6c757d;cursor:not-allowed",Uf=async(e,t)=>{const{captchaData:r,state:n,token:o}=jh(e);return(e=>{let{oauthInstance:t,captchaState:r}=e;const n="captcha-image",o=async()=>{try{const e=await t.createCaptchaData({state:r.state});r=zd(zd({},r),{},{captchaData:e.data,token:e.token}),document.getElementById(n).src=e.data}catch(e){console.error("刷新图形验证码失败",e)}},i=(e,t,r)=>{const n=document.createElement(e);return t&&(n.style.cssText=t),r&&(n.textContent=r),n},s=i("div",If),a=i("div",Pf);a.appendChild(i("p",Ef,"请输入你看到的字符:"));const c=i("div",Tf),u=i("img",Rf);u.id=n,u.src=r.captchaData,c.appendChild(u);const l=i("button",Cf,"刷新");l.onclick=_f(async()=>{l.textContent="加载中...",l.disabled=!0,l.style.cssText="".concat(Cf,";").concat(kf);try{await o()}finally{l.textContent="刷新",l.disabled=!1,l.style.cssText=Cf}},500),c.appendChild(l),a.appendChild(c);const d=i("input",Of);d.type="text",d.placeholder="输入字符",d.maxLength=4,a.appendChild(d);const h=i("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");a.appendChild(h);const f=e=>{h.textContent=e,h.style.display="block"},p=i("button",Af,"确定");p.onclick=_f(async()=>{const e=d.value.trim();if(e){h.style.display="none",p.textContent="验证中...",p.disabled=!0,p.style.cssText="".concat(Af,";").concat(kf);try{const n=await t.verifyCaptchaData({token:r.token,key:e});wf.fire(Sf,n),console.log("图形验证码校验成功"),document.body.removeChild(s),document.body.removeChild(a)}catch(e){console.error("图形验证码校验失败",e);const t=e.error_description||"图形验证码校验失败";f(t),d.value="",d.focus(),await o()}finally{p.textContent="确定",p.disabled=!1,p.style.cssText=Af}}else f("请输入字符")},500),a.appendChild(p),document.body.appendChild(s),document.body.appendChild(a)})({oauthInstance:t,captchaState:{captchaData:r,state:n,token:o}}),new Promise(e=>{console.log("等待图形验证码校验结果..."),wf.on(Sf,t=>{e(null==t?void 0:t.data)})})};class qf{constructor(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=yf),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}isMatch(){var e,t;return(null===(e=this.config)||void 0===e||null===(e=e.adapter)||void 0===e||null===(t=e.isMatch)||void 0===t?void 0:t.call(e))||_h()}async request(e,t){t||(t={}),t.method||(t.method="GET");const r="".concat(t.method,":").concat(e);let n,o=e;t.withCaptcha&&(o=await this.appendCaptchaTokenToURL(e,r,!1));try{n=await this.config.request(o,t)}catch(n){return n.error===Qd.CAPTCHA_REQUIRED||n.error===Qd.CAPTCHA_INVALID?(e=await this.appendCaptchaTokenToURL(e,r,n.error===Qd.CAPTCHA_INVALID),this.config.request(e,t)):Promise.reject(n)}return n}getDefaultOpenURIWithCallback(){return e=>Uf(e,this.config.oauthInstance)}async getCaptchaToken(e,t){if(!e){const e=await this.findCaptchaToken();if(e)return e}const r=await this.config.request(Gd.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1}),n="".concat(r.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(r.token)),o=await this.config.openURIWithCallback(n);return this.saveCaptchaToken(o),o.captcha_token}async appendCaptchaTokenToURL(e,t,r){const n=await this.getCaptchaToken(r,t);return e.indexOf("?")>0?e+="&captcha_token=".concat(n):e+="?captcha_token=".concat(n),e}async saveCaptchaToken(e){e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10));const t=JSON.stringify(e);await this.config.storage.setItem(this.tokenSectionName,t)}async findCaptchaToken(){const e=await this.config.storage.getItem(this.tokenSectionName);if(null!=e)try{const t=JSON.parse(e);null!=t&&t.expires_at&&(t.expires_at=new Date(t.expires_at));return t.expires_at<new Date?null:t.captcha_token}catch(e){return await this.config.storage.removeItem(this.tokenSectionName),null}return null}}class Lf{constructor(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}parse(e){e.split("&").forEach(e=>{const[t,r]=e.split("=").map(decodeURIComponent);this.append(t,r)})}append(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]}get(e){return this.params[e]?this.params[e][0]:null}getAll(e){return this.params[e]||[]}delete(e){delete this.params[e]}has(e){return Object.prototype.hasOwnProperty.call(this.params,e)}set(e,t){this.params[e]=[t]}toString(){const e=[];for(const t in this.params)Object.prototype.hasOwnProperty.call(this.params,t)&&this.params[t].forEach(r=>{e.push("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(r)))});return e.join("&")}}class xf extends Error{constructor(e){super(e.error_description||e.message),this.__isAuthError=!0,this.name="AuthError",this.status=e.error,this.code=e.error_code}}const jf=["provider_redirect_uri","other_params"];async function Nf(e,t){try{return void 0}catch(t){if(e)return(async()=>{try{return require("../utils/encrypt")}catch(e){try{return await Promise.resolve().then(function(){return yp})}catch(e){return}}})()}}let Df=class e{static parseParamsToSearch(e){Object.keys(e).forEach(t=>{e[t]||delete e[t]});return new Lf(e).toString()}constructor(e){let{request:t}=e,r=e.credentialsClient;if(!r){const t={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};r=new bf(t)}if(!t){const n=r.request.bind(r),o=new qf(zd({env:e.env,clientId:e.clientId,request:n,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=o.request.bind(o)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:r,storage:e.storage||yf,adapter:e.adapter}}getParamsByVersion(e,t){var r;const n=hh(e),o=(null===(r={v2:Kd}[null==n?void 0:n.version])||void 0===r?void 0:r[t])||Gd[t];return n&&delete n.version,{params:n,url:o}}async signIn(e){const t=e.version||"v1",r=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL");r.params.query&&delete r.params.query;const n=await this.getEncryptParams(r.params),o=await this.config.request(r.url,{method:"POST",body:n});return await this.config.credentialsClient.setCredentials(zd(zd({},o),{},{version:t})),Promise.resolve(o)}async signInAnonymously(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=await this.config.request(Gd.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e,useWxCloud:t});return await this.config.credentialsClient.setCredentials(r),Promise.resolve(r)}async signUp(e){const t=await this.config.request(Gd.AUTH_SIGN_UP_URL,{method:"POST",body:e});return await this.config.credentialsClient.setCredentials(t),Promise.resolve(t)}async signOut(e){let t={};if(e){try{t=await this.config.request(Gd.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})}catch(e){e.error!==Qd.UNAUTHENTICATED&&console.log("sign_out_error",e)}return await this.config.credentialsClient.setCredentials(),t}const r=await this.config.credentialsClient.getAccessToken(),n=await this.config.request(Gd.AUTH_REVOKE_URL,{method:"POST",body:{token:r}});return await this.config.credentialsClient.setCredentials(),Promise.resolve(n)}async revokeAllDevices(){await this.config.request(Gd.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})}async revokeDevice(e){await this.config.request(Gd.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})}async getVerification(e,t){let r=!1;if("CUR_USER"===e.target)r=!0;else{await this.hasLoginState()&&(r=!0)}const n=hh(e);return n.phone_number&&!/^\+\d{1,3}\s+\d+/.test(n.phone_number)&&(n.phone_number="+86 ".concat(n.phone_number)),this.config.request(Gd.VERIFICATION_URL,{method:"POST",body:n,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:r})}async verify(e){const t=this.getParamsByVersion(e,"VERIFY_URL"),r=await this.config.request(t.url,{method:"POST",body:t.params});return"v2"===(null==e?void 0:e.version)&&await this.config.credentialsClient.setCredentials(zd(zd({},r),{},{version:"v2"})),r}async genProviderRedirectUri(t){const{provider_redirect_uri:r,other_params:n={}}=t,o=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(t,jf);r&&!o.redirect_uri&&(o.redirect_uri=r);let i="".concat(Gd.PROVIDER_URI_URL,"?").concat(e.parseParamsToSearch(o));return Object.keys(n).forEach(e=>{const t=n[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(i+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))}),this.config.request(i,{method:"GET"})}async grantProviderToken(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.config.request(Gd.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:t})}async patchProviderToken(e){return this.config.request(Gd.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})}async signInWithProvider(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),n=await this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:t});return await this.config.credentialsClient.setCredentials(zd(zd({},n),{},{version:(null==e?void 0:e.version)||"v1"})),Promise.resolve(n)}async toBindIdentity(e){const t=e.credentials||await this.config.credentialsClient.localCredentials.getCredentials();let r;try{await this.bindWithProvider({provider_token:e.provider_token},t),r={data:{type:uh,provider:e.provider},error:null}}catch(e){r={data:{type:uh},error:new xf(e)}}var n,o;e.fireEvent&&(null===(n=this.config.eventBus)||void 0===n||null===(o=n.fire)||void 0===o||o.call(n,ah,{event:ih,info:r}));return r}async getInitialSession(){let e={};try{var t,r,n,o,i;if("undefined"==typeof window||"undefined"==typeof document)return{data:null,error:null};const s=new URLSearchParams(null===(t=location)||void 0===t?void 0:t.search),a=s.get("code"),c=s.get("state");if(!a||!c)return{data:null,error:null};let u=null;try{u=JSON.parse(sessionStorage.getItem(c)||"null")}catch(e){}e={type:null===(r=u)||void 0===r?void 0:r.type};const l=s.get("error"),d=s.get("error_description");if(l||d)return{data:e,error:new xf({message:d||l||"Unknown error from OAuth provider"})};const h=(null===(n=u)||void 0===n?void 0:n.provider)||s.get("provider");if(!h)return{data:e,error:new xf({message:"Provider is required for OAuth verification"})};const f=location.origin+location.pathname,{provider_token:p}=await this.grantProviderToken({provider_id:h,provider_redirect_uri:f,provider_code:a});let v,y,g=null;if(u.type===uh)v=await this.config.credentialsClient.localCredentials.getCredentials(),y=await this.toBindIdentity({provider:h,provider_token:p,credentials:v});else if(u.type===ch){y=this.getParamsByVersion({provider:h},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),v=await this.config.request(y.url,{method:"POST",body:{provider_token:p}});try{g=await this.getUserInfo({credentials:v})}catch(e){console.error("get user info error",e)}y={data:zd(zd({},e),{},{session:v,user:g}),error:null}}s.delete("code"),s.delete("state"),s.delete("provider"),this.restoreUrlState(void 0===(null===(o=u)||void 0===o?void 0:o.search)?"?".concat(s.toString()):u.search,(null===(i=u)||void 0===i?void 0:i.hash)||location.hash);try{sessionStorage.removeItem(c)}catch(e){}return y}catch(t){return{data:e,error:new xf(t)}}}async signInCustom(e){const t=await this.config.request(Gd.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e});return await this.config.credentialsClient.setCredentials(t),Promise.resolve(t)}async signInWithWechat(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=await this.config.request(Gd.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:e});return await this.config.credentialsClient.setCredentials(t),Promise.resolve(t)}async bindWithProvider(e,t){return this.config.request(Gd.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?()=>t:void 0})}async getUserProfile(e){return this.getUserInfo(e)}async getUserInfo(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=this.getParamsByVersion(t,"USER_ME_URL");if(null!==(e=r.params)&&void 0!==e&&e.query){const e=new Lf(r.params.query);r.url+="?".concat(e.toString())}const n=await this.config.request(r.url,{method:"GET",withCredentials:!0,getCredentials:t.credentials?()=>t.credentials:void 0});return n.sub&&(n.uid=n.sub),n}async getWedaUserInfo(){return await this.config.request(Gd.WEDA_USER_URL,{method:"GET",withCredentials:!0})}async deleteMe(t){const r=this.getParamsByVersion(t,"USER_ME_URL"),n="".concat(r.url,"?").concat(e.parseParamsToSearch(r.params));return this.config.request(n,{method:"DELETE",withCredentials:!0})}async hasLoginState(){try{return await this.config.credentialsClient.getAccessToken(),!0}catch(e){return!1}}hasLoginStateSync(){return this.config.credentialsClient.getCredentialsSync()}async getLoginState(){return this.config.credentialsClient.getCredentialsAsync()}async transByProvider(e){return this.config.request(Gd.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})}async grantToken(e){const t=this.getParamsByVersion(e,"AUTH_TOKEN_URL");return this.config.request(t.url,{method:"POST",body:t.params})}async getProviders(){return this.config.request(Gd.PROVIDER_LIST,{method:"GET",withCredentials:!0})}async unbindProvider(e){return this.config.request("".concat(Gd.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})}async checkPassword(e){return this.config.request("".concat(Gd.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})}async editContact(e){return this.config.request("".concat(Gd.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})}async setPassword(e){return this.config.request("".concat(Gd.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})}async updatePasswordByOld(e){const t=await this.sudo({password:e.old_password});return this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})}async sudo(e){return this.config.request("".concat(Gd.SUDO_URL),{method:"POST",withCredentials:!0,body:e})}async sendVerificationCodeToCurrentUser(e){return e.target="CUR_USER",this.config.request(Gd.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})}async changeBoundProvider(e){return this.config.request("".concat(Gd.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})}async setUserProfile(e){return this.config.request(Gd.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})}async updateUserBasicInfo(e){return this.config.request(Gd.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})}async queryUserProfile(e){const t=new Lf(e);return this.config.request("".concat(Gd.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})}setCustomSignFunc(e){this.getCustomSignTicketFn=e}async signInWithCustomTicket(){const e=this.getCustomSignTicketFn;if(!e)return Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"});const t=await e();return this.signInCustom({provider_id:"custom",ticket:t})}async resetPassword(e){return this.config.request(Gd.AUTH_RESET_PASSWORD,{method:"POST",body:e})}async authorize(e){return this.config.request(Gd.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})}async authorizeDevice(e){return this.config.request(Gd.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})}async deviceAuthorize(e){return this.config.request(Gd.AUTH_GET_DEVICE_CODE,{method:"POST",body:e,withCredentials:!0})}async authorizeInfo(t){const r="".concat(Gd.AUTHORIZE_INFO_URL,"?").concat(e.parseParamsToSearch(t));let n=!0,o=!1;return await this.hasLoginState()&&(o=!0,n=!1),this.config.request(r,{method:"GET",withBasicAuth:n,withCredentials:o})}async checkUsername(e){return this.config.request(Gd.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})}async checkIfUserExist(e){const t=new Lf(e);return this.config.request("".concat(Gd.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})}async loginScope(){return this.config.credentialsClient.getScope()}async loginGroups(){return this.config.credentialsClient.getGroups()}async refreshTokenForce(e){const t=await this.config.credentialsClient.getCredentials();return await this.config.credentialsClient.refreshToken(zd(zd({},t),{},{version:(null==e?void 0:e.version)||"v1"}))}async getCredentials(){return this.config.credentialsClient.getCredentials()}async getPublicKey(){return this.config.request(Kd.AUTH_PUBLIC_KEY,{method:"POST",body:{}})}async getEncryptParams(e){const{isEncrypt:t}=e;delete e.isEncrypt;const r=hh(e),n=await Nf(t,this.config.adapter);if(!n)return e;let o="",i="";try{const e=await this.getPublicKey();if(o=e.public_key,i=e.public_key_thumbprint,!o||!i)throw e}catch(e){throw e}return{params:n.getEncryptInfo({publicKey:o,payload:r}),public_key_thumbprint:i}}async getProviderSubType(){return this.config.request(Gd.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})}async verifyCaptchaData(e){let{token:t,key:r}=e;return this.config.request(Gd.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:r},withCredentials:!1})}async createCaptchaData(e){let{state:t,redirect_uri:r}=e;return this.config.request(Gd.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:r},withCredentials:!1})}async getMiniProgramCode(e){return this.config.request(Gd.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})}async getMiniProgramQrCodeStatus(e){return this.config.request(Gd.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})}async getUserBehaviorLog(e){const t="".concat(Gd.GET_USER_BEHAVIOR_LOG,"?").concat({LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"}[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):"");return this.config.request(t,{method:"GET",withCredentials:!0})}async modifyPassword(e){let t="",r="";const n=await Nf(!0,this.config.adapter);if(!n)throw new Error("do not support encrypt, a encrypt util required.");try{const e=await this.getPublicKey();if(t=e.public_key,r=e.public_key_thumbprint,!t||!r)throw e}catch(e){throw e}const o=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",i=n.getEncryptInfo({publicKey:t,payload:e.new_password});return this.config.request(Gd.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:o,encrypt_new_password:i,public_key_thumbprint:r}})}async modifyPasswordWithoutLogin(e){let t="",r="";const n=await Nf(!0,this.config.adapter);if(!n)throw new Error("do not support encrypt, a encrypt util required.");try{const e=await this.getPublicKey();if(t=e.public_key,r=e.public_key_thumbprint,!t||!r)throw e}catch(e){throw e}const o=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",i=n.getEncryptInfo({publicKey:t,payload:e.new_password});return this.config.request(Kd.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:o,new_password:i,public_key_thumbprint:r}})}restoreUrlState(e,t){if(void 0!==e)try{const r=new URL(window.location.href);r.search=e,r.hash=t||"",window.history.replaceState(null,"",r.toString())}catch(e){}}};class Wf{constructor(e){const{apiOrigin:t,apiPath:r=Vd,clientId:n,env:o,storage:i,request:s,baseRequest:a,anonymousSignInFunc:c,wxCloud:u,adapter:l,onCredentialsError:d,headers:h,i18n:f,useWxCloud:p,eventBus:v,detectSessionInUrl:y,debug:g}=e;this.detectSessionInUrl=null!=y&&y,this.oauth2client=new bf({apiOrigin:t,apiPath:r,clientId:n,env:o,storage:i,baseRequest:a||s,anonymousSignInFunc:c,wxCloud:u,onCredentialsError:d,headers:h||{},i18n:f,useWxCloud:p,eventBus:v,debug:g}),this.authApi=new Df(zd(zd({credentialsClient:this.oauth2client},e),{},{request:s?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:l})),y&&this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi))}initializeSession(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))}}var Bf={exports:{}};!function(e){"undefined"!=typeof window&&window,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){e.exports=r(1)},function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},c=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0});var u=r(3),l=r(2),d=function(e){function t(t){void 0===t&&(t={});var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r._timeout=n||0,r._timeoutMsg=o||"请求超时",r._restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.post=function(e){var t=this;return new Promise(function(r,n){var o=e.url,i=e.data,s=e.headers,a=wx.request({url:u.formatUrl("https:",o),data:i,timeout:t._timeout,method:"POST",header:s,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):n(e)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("post")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{a.abort()}catch(e){}}}})})},t.prototype.get=function(e){var t=this;return new Promise(function(r,n){var o=e.url,i=e.body,s=e.headers,a=u.formatUrl("https:",o),c=wx.request({url:a,data:i,timeout:t._timeout,method:"GET",header:s,success:function(e){e.statusCode>=200&&e.statusCode<300?r({statusCode:e.statusCode,status:e.statusCode,data:e.data}):n(e)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("get")&&e.errMsg.includes("timeout")){console.warn(t._timeoutMsg);try{c.abort()}catch(e){console.warn("Error when aborting requestTask",e)}}}})})},t.prototype.upload=function(e){var t=this,r=this;return new Promise(function(n){return s(t,void 0,void 0,function(){var t,o,s,c,u,l;return a(this,function(a){return t=e.url,o=e.file,s=e.data,c=e.headers,u=e.onUploadProgress,l=wx.uploadFile({url:t,filePath:o,name:"file",formData:i({},s),header:c,timeout:this._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&s.success_action_status&&(t.statusCode=parseInt(s.success_action_status,10)),n(t)},fail:function(e){n(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{l.abort()}catch(e){}}}}),u&&l.onProgressUpdate(function(e){u(e)}),[2]})})})},t.prototype.download=function(e){var t=this,r=this;return new Promise(function(n,o){var i=e.url,s=e.headers,a=wx.downloadFile({url:u.formatUrl("https:",i),header:s,timeout:t._timeout,success:function(e){200===e.statusCode&&e.tempFilePath?n({statusCode:200,tempFilePath:e.tempFilePath}):n(e)},fail:function(e){o(e)},complete:function(e){if(e&&e.errMsg&&r._timeout&&-1!==r._restrictedMethods.indexOf("download")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{a.abort()}catch(e){}}}})})},t.prototype.fetch=function(e){var t=e.url,r=e.body,n=e.enableAbort,o=e.headers,i=e.method,s=e.stream,a=void 0!==s&&s,c=e.signal,d=e.timeout,h=this,f=null!=d?d:this._timeout,p=null,v=new l.ReadableStream({start:function(e){p=e},cancel:function(){p=null}});return new Promise(function(e,s){a&&e({data:v});var l=wx.request({url:u.formatUrl("https:",t),data:r,timeout:f,method:i.toUpperCase(),header:o,success:function(t){var r;null===(r=p)||void 0===r||r.close(),!a&&e(t)},fail:function(e){var t;if(null===(t=p)||void 0===t||t.close(),s(e),a)throw e},complete:function(e){if(e&&e.errMsg&&f&&-1!==h._restrictedMethods.indexOf("post")&&n&&"request:fail timeout"===e.errMsg){console.warn(h._timeoutMsg);try{l.abort()}catch(e){console.warn("Error when aborting requestTask",e)}}},enableChunked:a});if(l.onChunkReceived(function(e){var t;null===(t=p)||void 0===t||t.enqueue(new Uint8Array(e.data))}),c){var d=function(){try{l.abort()}catch(e){console.warn("Error when aborting requestTask",e)}};c.aborted?d():c.addEventListener("abort",function(){return d()})}})},t}(u.AbstractSDKRequest);t.WxRequest=d,t.wxMpStorage={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}};var h=function(e,t){void 0===t&&(t={});var r=wx.connectSocket(i({url:e},t));return{set onopen(e){r.onOpen(e)},set onmessage(e){r.onMessage(e)},set onclose(e){r.onClose(e)},set onerror(e){r.onError(e)},send:function(e){return r.send({data:e})},close:function(e,t){return r.close({code:e,reason:t})},get readyState(){return r.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};function f(e){var t={},r=e.replace(/^[?#]/,"");return r?(r.split("&").forEach(function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)}),t):t}t.WxMpWebSocket=h,t.parseQueryString=f;var p={genAdapter:function(e){return{root:{globalThis:{}},reqClass:d,wsClass:h,captchaOptions:{openURIWithCallback:function(t){var r=e.EventBus,n={},o=t;console.log("openURIWithCallback",t);var s=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(s){o=s[1],console.log("openURIWithCallback url",o);var a=s[2];a&&(n=f(a))}console.log("openURIWithCallback queryObj",n);var u=n.token,l=c(n,["token"]);return/^data:/.test(o)&&!u?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: "+t}):u?new Promise(function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",i(i({},l),{token:u,url:o})),r.$once("RESOLVE_CAPTCHA_DATA",function(t){e(t)})}):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:t.wxMpStorage,primaryStorage:u.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof Page)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0},runtime:"wx_mp"};t.default=p},function(e,t,r){
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* web-streams-polyfill v4.0.0
|
|
5
|
+
* Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
|
|
6
|
+
* This code is released under the MIT license.
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
*/
|
|
9
|
+
function n(){}function o(e){return"object"==typeof e&&null!==e||"function"==typeof e}r.r(t),r.d(t,"ByteLengthQueuingStrategy",function(){return Vr}),r.d(t,"CountQueuingStrategy",function(){return Qr}),r.d(t,"ReadableByteStreamController",function(){return Oe}),r.d(t,"ReadableStream",function(){return qr}),r.d(t,"ReadableStreamBYOBReader",function(){return ut}),r.d(t,"ReadableStreamBYOBRequest",function(){return Ce}),r.d(t,"ReadableStreamDefaultController",function(){return vr}),r.d(t,"ReadableStreamDefaultReader",function(){return te}),r.d(t,"TransformStream",function(){return rn}),r.d(t,"TransformStreamDefaultController",function(){return un}),r.d(t,"WritableStream",function(){return Pt}),r.d(t,"WritableStreamDefaultController",function(){return zt}),r.d(t,"WritableStreamDefaultWriter",function(){return Nt});const i=n;function s(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const a=Promise,c=Promise.resolve.bind(a),u=Promise.prototype.then,l=Promise.reject.bind(a),d=c;function h(e){return new a(e)}function f(e){return h(t=>t(e))}function p(e){return l(e)}function v(e,t,r){return u.call(e,t,r)}function y(e,t,r){v(v(e,t,r),void 0,i)}function g(e,t){y(e,t)}function m(e,t){y(e,void 0,t)}function b(e,t,r){return v(e,t,r)}function _(e){v(e,void 0,i)}let w=e=>{if("function"==typeof queueMicrotask)w=queueMicrotask;else{const e=f(void 0);w=t=>v(e,t)}return w(e)};function S(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function I(e,t,r){try{return f(S(e,t,r))}catch(e){return p(e)}}class E{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let n=r+1;const o=e._elements,i=o[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),o[r]=void 0,i}forEach(e){let t=this._cursor,r=this._front,n=r._elements;for(;!(t===n.length&&void 0===r._next||t===n.length&&(r=r._next,n=r._elements,t=0,0===n.length));)e(n[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}const T=Symbol("[[AbortSteps]]"),R=Symbol("[[ErrorSteps]]"),C=Symbol("[[CancelSteps]]"),O=Symbol("[[PullSteps]]"),A=Symbol("[[ReleaseSteps]]");function k(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?x(e):"closed"===t._state?function(e){x(e),D(e)}(e):j(e,t._storedError)}function U(e,t){return Wr(e._ownerReadableStream,t)}function q(e){const t=e._ownerReadableStream;"readable"===t._state?N(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){j(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[A](),t._reader=void 0,e._ownerReadableStream=void 0}function L(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function x(e){e._closedPromise=h((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function j(e,t){x(e),N(e,t)}function N(e,t){void 0!==e._closedPromise_reject&&(_(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function D(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const W=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},B=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function F(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError("".concat(t," is not an object."));var r}function M(e,t){if("function"!=typeof e)throw new TypeError("".concat(t," is not a function."))}function H(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError("".concat(t," is not an object."))}function z(e,t,r){if(void 0===e)throw new TypeError("Parameter ".concat(t," is required in '").concat(r,"'."))}function V(e,t,r){if(void 0===e)throw new TypeError("".concat(t," is required in '").concat(r,"'."))}function G(e){return Number(e)}function K(e){return 0===e?0:e}function Y(e,t){const r=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=K(n),!W(n))throw new TypeError("".concat(t," is not a finite number"));if(n=function(e){return K(B(e))}(n),n<0||n>r)throw new TypeError("".concat(t," is outside the accepted range of 0 to ").concat(r,", inclusive"));return W(n)&&0!==n?n:0}function Q(e,t){if(!Nr(e))throw new TypeError("".concat(t," is not a ReadableStream."))}function J(e){return new te(e)}function $(e,t){e._reader._readRequests.push(t)}function X(e,t,r){const n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function Z(e){return e._reader._readRequests.length}function ee(e){const t=e._reader;return void 0!==t&&!!re(t)}class te{constructor(e){if(z(e,1,"ReadableStreamDefaultReader"),Q(e,"First parameter"),Dr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");k(this,e),this._readRequests=new E}get closed(){return re(this)?this._closedPromise:p(ie("closed"))}cancel(e){return re(this)?void 0===this._ownerReadableStream?p(L("cancel")):U(this,e):p(ie("cancel"))}read(){if(!re(this))return p(ie("read"));if(void 0===this._ownerReadableStream)return p(L("read from"));let e,t;const r=h((r,n)=>{e=r,t=n});return ne(this,{_chunkSteps:t=>e({value:t,done:!1}),_closeSteps:()=>e({value:void 0,done:!0}),_errorSteps:e=>t(e)}),r}releaseLock(){if(!re(this))throw ie("releaseLock");void 0!==this._ownerReadableStream&&function(e){q(e),oe(e,new TypeError("Reader was released"))}(this)}}function re(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof te}function ne(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[O](t)}function oe(e,t){const r=e._readRequests;e._readRequests=new E,r.forEach(e=>{e._errorSteps(t)})}function ie(e){return new TypeError("ReadableStreamDefaultReader.prototype.".concat(e," can only be used on a ReadableStreamDefaultReader"))}var se,ae,ce;function ue(e){return e.slice()}function le(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}Object.defineProperties(te.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(te.prototype.cancel,"cancel"),s(te.prototype.read,"read"),s(te.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(te.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});let de=e=>(de="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,de(e)),he=e=>(he="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,he(e));function fe(e,t,r){if(e.slice)return e.slice(t,r);const n=r-t,o=new ArrayBuffer(n);return le(o,0,e,t,n),o}function pe(e,t){const r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError("".concat(String(t)," is not a function"));return r}}function ve(e){try{const t=e.done,r=e.value;return v(d(r),e=>({done:t,value:e}))}catch(e){return p(e)}}const ye=null!==(ce=null!==(se=Symbol.asyncIterator)&&void 0!==se?se:null===(ae=Symbol.for)||void 0===ae?void 0:ae.call(Symbol,"Symbol.asyncIterator"))&&void 0!==ce?ce:"@@asyncIterator";function ge(e){const t=S(e.nextMethod,e.iterator,[]);if(!o(t))throw new TypeError("The iterator.next() method must return an object");return t}class me{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?b(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise?b(this._ongoingPromise,t,t):t()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader;let t,r;const n=h((e,n)=>{t=e,r=n});return ne(e,{_chunkSteps:e=>{this._ongoingPromise=void 0,w(()=>t({value:e,done:!1}))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,q(e),t({value:void 0,done:!0})},_errorSteps:t=>{this._ongoingPromise=void 0,this._isFinished=!0,q(e),r(t)}}),n}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(!this._preventCancel){const r=U(t,e);return q(t),b(r,()=>({value:e,done:!0}))}return q(t),f({value:e,done:!0})}}const be={next(){return _e(this)?this._asyncIteratorImpl.next():p(we("next"))},return(e){return _e(this)?this._asyncIteratorImpl.return(e):p(we("return"))},[ye](){return this}};function _e(e){if(!o(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof me}catch(e){return!1}}function we(e){return new TypeError("ReadableStreamAsyncIterator.".concat(e," can only be used on a ReadableSteamAsyncIterator"))}Object.defineProperty(be,ye,{enumerable:!1});const Se=Number.isNaN||function(e){return e!=e};function Ie(e){const t=fe(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function Pe(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Ee(e,t,r){if("number"!=typeof(n=r)||Se(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function Te(e){e._queue=new E,e._queueTotalSize=0}function Re(e){return e===DataView}class Ce{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!ke(this))throw rt("view");return this._view}respond(e){if(!ke(this))throw rt("respond");if(z(e,1,"respond"),e=Y(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(he(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");Ze(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!ke(this))throw rt("respondWithNewView");if(z(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(he(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");et(this._associatedReadableByteStreamController,e)}}Object.defineProperties(Ce.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),s(Ce.prototype.respond,"respond"),s(Ce.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Ce.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class Oe{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Ae(this))throw nt("byobRequest");return $e(this)}get desiredSize(){if(!Ae(this))throw nt("desiredSize");return Xe(this)}close(){if(!Ae(this))throw nt("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError("The stream (in ".concat(e," state) is not in the readable state and cannot be closed"));Ke(this)}enqueue(e){if(!Ae(this))throw nt("enqueue");if(z(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError("The stream (in ".concat(t," state) is not in the readable state and cannot be enqueued to"));Ye(this,e)}error(e){if(!Ae(this))throw nt("error");Qe(this,e)}[C](e){qe(this),Te(this);const t=this._cancelAlgorithm(e);return Ge(this),t}[O](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void Je(this,e);const r=this._autoAllocateChunkSize;if(void 0!==r){let n;try{n=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}const o={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}$(t,e),Ue(this)}[A](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new E,this._pendingPullIntos.push(e)}}}function Ae(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof Oe}function ke(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof Ce}function Ue(e){(function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&!e._closeRequested&&!!e._started&&(!!(ee(t)&&Z(t)>0)||!!(ct(t)&&at(t)>0)||Xe(e)>0)})(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,y(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Ue(e)),null),t=>(Qe(e,t),null))))}function qe(e){Me(e),e._pendingPullIntos=new E}function Le(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=xe(t);"default"===t.readerType?X(e,n,r):function(e,t,r){const n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function xe(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function je(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function Ne(e,t,r,n){let o;try{o=fe(t,r,r+n)}catch(t){throw Qe(e,t),t}je(e,o,0,n)}function De(e,t){t.bytesFilled>0&&Ne(e,t.buffer,t.byteOffset,t.bytesFilled),Ve(e)}function We(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),n=t.bytesFilled+r;let o=r,i=!1;const s=n-n%t.elementSize;s>=t.minimumFill&&(o=s-t.bytesFilled,i=!0);const a=e._queue;for(;o>0;){const r=a.peek(),n=Math.min(o,r.byteLength),i=t.byteOffset+t.bytesFilled;le(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?a.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,Be(e,n,t),o-=n}return i}function Be(e,t,r){r.bytesFilled+=t}function Fe(e){0===e._queueTotalSize&&e._closeRequested?(Ge(e),Br(e._controlledReadableByteStream)):Ue(e)}function Me(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function He(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos.peek();We(e,t)&&(Ve(e),Le(e._controlledReadableByteStream,t))}}function ze(e,t){const r=e._pendingPullIntos.peek();Me(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&Ve(e);const r=e._controlledReadableByteStream;if(ct(r))for(;at(r)>0;)Le(r,Ve(e))}(e,r):function(e,t,r){if(Be(0,t,r),"none"===r.readerType)return De(e,r),void He(e);if(r.bytesFilled<r.minimumFill)return;Ve(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled;Ne(e,r.buffer,t-n,n)}r.bytesFilled-=n,Le(e._controlledReadableByteStream,r),He(e)}(e,t,r),Ue(e)}function Ve(e){return e._pendingPullIntos.shift()}function Ge(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function Ke(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(t.bytesFilled%t.elementSize!=0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw Qe(e,t),t}}Ge(e),Br(t)}}function Ye(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=t;if(he(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const s=de(n);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(he(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Me(e),t.buffer=de(t.buffer),"none"===t.readerType&&De(e,t)}ee(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;Je(e,t._readRequests.shift())}}(e),0===Z(r)?je(e,s,o,i):(e._pendingPullIntos.length>0&&Ve(e),X(r,new Uint8Array(s,o,i),!1))):ct(r)?(je(e,s,o,i),He(e)):je(e,s,o,i),Ue(e)}function Qe(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(qe(e),Te(e),Ge(e),Fr(r,t))}function Je(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,Fe(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function $e(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(Ce.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function Xe(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ze(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=de(r.buffer),ze(e,t)}function et(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const n=t.byteLength;r.buffer=de(t.buffer),ze(e,n)}function tt(e,t,r,n,o,i,s){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Te(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=s,t._pendingPullIntos=new E,e._readableStreamController=t,y(f(r()),()=>(t._started=!0,Ue(t),null),e=>(Qe(t,e),null))}function rt(e){return new TypeError("ReadableStreamBYOBRequest.prototype.".concat(e," can only be used on a ReadableStreamBYOBRequest"))}function nt(e){return new TypeError("ReadableByteStreamController.prototype.".concat(e," can only be used on a ReadableByteStreamController"))}function ot(e,t){if("byob"!==(e="".concat(e)))throw new TypeError("".concat(t," '").concat(e,"' is not a valid enumeration value for ReadableStreamReaderMode"));return e}function it(e){return new ut(e)}function st(e,t){e._reader._readIntoRequests.push(t)}function at(e){return e._reader._readIntoRequests.length}function ct(e){const t=e._reader;return void 0!==t&&!!lt(t)}Object.defineProperties(Oe.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),s(Oe.prototype.close,"close"),s(Oe.prototype.enqueue,"enqueue"),s(Oe.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Oe.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class ut{constructor(e){if(z(e,1,"ReadableStreamBYOBReader"),Q(e,"First parameter"),Dr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Ae(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");k(this,e),this._readIntoRequests=new E}get closed(){return lt(this)?this._closedPromise:p(ft("closed"))}cancel(e){return lt(this)?void 0===this._ownerReadableStream?p(L("cancel")):U(this,e):p(ft("cancel"))}read(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!lt(this))return p(ft("read"));if(!ArrayBuffer.isView(e))return p(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return p(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return p(new TypeError("view's buffer must have non-zero byteLength"));if(he(e.buffer))return p(new TypeError("view's buffer has been detached"));try{t=function(e,t){var r;return F(e,t),{min:Y(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,"".concat(t," has member 'min' that"))}}(r,"options")}catch(e){return p(e)}const n=t.min;if(0===n)return p(new TypeError("options.min must be greater than 0"));if(function(e){return Re(e.constructor)}(e)){if(n>e.byteLength)return p(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>e.length)return p(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return p(L("read from"));let o,i;const s=h((e,t)=>{o=e,i=t});return dt(this,e,n,{_chunkSteps:e=>o({value:e,done:!1}),_closeSteps:e=>o({value:e,done:!0}),_errorSteps:e=>i(e)}),s}releaseLock(){if(!lt(this))throw ft("releaseLock");void 0!==this._ownerReadableStream&&function(e){q(e),ht(e,new TypeError("Reader was released"))}(this)}}function lt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof ut}function dt(e,t,r,n){const o=e._ownerReadableStream;o._disturbed=!0,"errored"===o._state?n._errorSteps(o._storedError):function(e,t,r,n){const o=e._controlledReadableByteStream,i=t.constructor,s=function(e){return Re(e)?1:e.BYTES_PER_ELEMENT}(i),{byteOffset:a,byteLength:c}=t,u=r*s;let l;try{l=de(t.buffer)}catch(e){return void n._errorSteps(e)}const d={buffer:l,bufferByteLength:l.byteLength,byteOffset:a,byteLength:c,bytesFilled:0,minimumFill:u,elementSize:s,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(d),void st(o,n);if("closed"!==o._state){if(e._queueTotalSize>0){if(We(e,d)){const t=xe(d);return Fe(e),void n._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return Qe(e,t),void n._errorSteps(t)}}e._pendingPullIntos.push(d),st(o,n),Ue(e)}else{const e=new i(d.buffer,d.byteOffset,0);n._closeSteps(e)}}(o._readableStreamController,t,r,n)}function ht(e,t){const r=e._readIntoRequests;e._readIntoRequests=new E,r.forEach(e=>{e._errorSteps(t)})}function ft(e){return new TypeError("ReadableStreamBYOBReader.prototype.".concat(e," can only be used on a ReadableStreamBYOBReader"))}function pt(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(Se(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function vt(e){const{size:t}=e;return t||(()=>1)}function yt(e,t){F(e,t);const r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:G(r),size:void 0===n?void 0:gt(n,"".concat(t," has member 'size' that"))}}function gt(e,t){return M(e,t),t=>G(e(t))}function mt(e,t,r){return M(e,r),r=>I(e,t,[r])}function bt(e,t,r){return M(e,r),()=>I(e,t,[])}function _t(e,t,r){return M(e,r),r=>S(e,t,[r])}function wt(e,t,r){return M(e,r),(r,n)=>I(e,t,[r,n])}function St(e,t){if(!Rt(e))throw new TypeError("".concat(t," is not a WritableStream."))}Object.defineProperties(ut.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),s(ut.prototype.cancel,"cancel"),s(ut.prototype.read,"read"),s(ut.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ut.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});const It="function"==typeof AbortController;class Pt{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};void 0===e?e=null:H(e,"First parameter");const r=yt(t,"Second parameter"),n=function(e,t){F(e,t);const r=null==e?void 0:e.abort,n=null==e?void 0:e.close,o=null==e?void 0:e.start,i=null==e?void 0:e.type,s=null==e?void 0:e.write;return{abort:void 0===r?void 0:mt(r,e,"".concat(t," has member 'abort' that")),close:void 0===n?void 0:bt(n,e,"".concat(t," has member 'close' that")),start:void 0===o?void 0:_t(o,e,"".concat(t," has member 'start' that")),write:void 0===s?void 0:wt(s,e,"".concat(t," has member 'write' that")),type:i}}(e,"First parameter");if(Tt(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=vt(r);!function(e,t,r,n){const o=Object.create(zt.prototype);let i,s,a,c;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.write?e=>t.write(e,o):()=>f(void 0),a=void 0!==t.close?()=>t.close():()=>f(void 0),c=void 0!==t.abort?e=>t.abort(e):()=>f(void 0),Gt(e,o,i,s,a,c,r,n)}(this,n,pt(r,1),o)}get locked(){if(!Rt(this))throw Zt("locked");return Ct(this)}abort(e){return Rt(this)?Ct(this)?p(new TypeError("Cannot abort a stream that already has a writer")):Ot(this,e):p(Zt("abort"))}close(){return Rt(this)?Ct(this)?p(new TypeError("Cannot close a stream that already has a writer")):Lt(this)?p(new TypeError("Cannot close an already-closing stream")):At(this):p(Zt("close"))}getWriter(){if(!Rt(this))throw Zt("getWriter");return Et(this)}}function Et(e){return new Nt(e)}function Tt(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new E,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function Rt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof Pt}function Ct(e){return void 0!==e._writer}function Ot(e,t){var r;if("closed"===e._state||"errored"===e._state)return f(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort(t);const n=e._state;if("closed"===n||"errored"===n)return f(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,t=void 0);const i=h((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=i,o||Ut(e,t),i}function At(e){const t=e._state;if("closed"===t||"errored"===t)return p(new TypeError("The stream (in ".concat(t," state) is not in the writable state and cannot be closed")));const r=h((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n}),n=e._writer;var o;return void 0!==n&&e._backpressure&&"writable"===t&&dr(n),Ee(o=e._writableStreamController,Ht,0),Qt(o),r}function kt(e,t){"writable"!==e._state?qt(e):Ut(e,t)}function Ut(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&Bt(n,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&qt(e)}function qt(e){e._state="errored",e._writableStreamController[R]();const t=e._storedError;if(e._writeRequests.forEach(e=>{e._reject(t)}),e._writeRequests=new E,void 0===e._pendingAbortRequest)return void xt(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void xt(e);y(e._writableStreamController[T](r._reason),()=>(r._resolve(),xt(e),null),t=>(r._reject(t),xt(e),null))}function Lt(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function xt(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&ir(t,e._storedError)}function jt(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){ar(e)}(r):dr(r)),e._backpressure=t}Object.defineProperties(Pt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),s(Pt.prototype.abort,"abort"),s(Pt.prototype.close,"close"),s(Pt.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Pt.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class Nt{constructor(e){if(z(e,1,"WritableStreamDefaultWriter"),St(e,"First parameter"),Ct(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!Lt(e)&&e._backpressure?ar(this):ur(this),nr(this);else if("erroring"===t)cr(this,e._storedError),nr(this);else if("closed"===t)ur(this),nr(this),sr(this);else{const t=e._storedError;cr(this,t),or(this,t)}}get closed(){return Dt(this)?this._closedPromise:p(tr("closed"))}get desiredSize(){if(!Dt(this))throw tr("desiredSize");if(void 0===this._ownerWritableStream)throw rr("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:Yt(t._writableStreamController)}(this)}get ready(){return Dt(this)?this._readyPromise:p(tr("ready"))}abort(e){return Dt(this)?void 0===this._ownerWritableStream?p(rr("abort")):function(e,t){return Ot(e._ownerWritableStream,t)}(this,e):p(tr("abort"))}close(){if(!Dt(this))return p(tr("close"));const e=this._ownerWritableStream;return void 0===e?p(rr("close")):Lt(e)?p(new TypeError("Cannot close an already-closing stream")):Wt(this)}releaseLock(){if(!Dt(this))throw tr("releaseLock");void 0!==this._ownerWritableStream&&Ft(this)}write(e){return Dt(this)?void 0===this._ownerWritableStream?p(rr("write to")):Mt(this,e):p(tr("write"))}}function Dt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof Nt}function Wt(e){return At(e._ownerWritableStream)}function Bt(e,t){"pending"===e._readyPromiseState?lr(e,t):function(e,t){cr(e,t)}(e,t)}function Ft(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Bt(e,r),function(e,t){"pending"===e._closedPromiseState?ir(e,t):function(e,t){or(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Mt(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,o=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Jt(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return p(rr("write to"));const i=r._state;if("errored"===i)return p(r._storedError);if(Lt(r)||"closed"===i)return p(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return p(r._storedError);const s=function(e){return h((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)})}(r);return function(e,t,r){try{Ee(e,t,r)}catch(t){return void Jt(e,t)}const n=e._controlledWritableStream;Lt(n)||"writable"!==n._state||jt(n,$t(e)),Qt(e)}(n,t,o),s}Object.defineProperties(Nt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),s(Nt.prototype.abort,"abort"),s(Nt.prototype.close,"close"),s(Nt.prototype.releaseLock,"releaseLock"),s(Nt.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Nt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Ht={};class zt{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Vt(this))throw er("abortReason");return this._abortReason}get signal(){if(!Vt(this))throw er("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e){if(!Vt(this))throw er("error");"writable"===this._controlledWritableStream._state&&Xt(this,e)}[T](e){const t=this._abortAlgorithm(e);return Kt(this),t}[R](){Te(this)}}function Vt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof zt}function Gt(e,t,r,n,o,i,s,a){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Te(t),t._abortReason=void 0,t._abortController=function(){if(It)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=a,t._strategyHWM=s,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=i;const c=$t(t);jt(e,c),y(f(r()),()=>(t._started=!0,Qt(t),null),r=>(t._started=!0,kt(e,r),null))}function Kt(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Yt(e){return e._strategyHWM-e._queueTotalSize}function Qt(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void qt(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Ht?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),Pe(e);const r=e._closeAlgorithm();Kt(e),y(r,()=>(function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&sr(t)}(t),null),e=>(function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),kt(e,t)}(t,e),null))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),y(e._writeAlgorithm(t),()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(Pe(e),!Lt(r)&&"writable"===t){const t=$t(e);jt(r,t)}return Qt(e),null},t=>("writable"===r._state&&Kt(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,kt(e,t)}(r,t),null))}(e,r)}function Jt(e,t){"writable"===e._controlledWritableStream._state&&Xt(e,t)}function $t(e){return Yt(e)<=0}function Xt(e,t){const r=e._controlledWritableStream;Kt(e),Ut(r,t)}function Zt(e){return new TypeError("WritableStream.prototype.".concat(e," can only be used on a WritableStream"))}function er(e){return new TypeError("WritableStreamDefaultController.prototype.".concat(e," can only be used on a WritableStreamDefaultController"))}function tr(e){return new TypeError("WritableStreamDefaultWriter.prototype.".concat(e," can only be used on a WritableStreamDefaultWriter"))}function rr(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function nr(e){e._closedPromise=h((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function or(e,t){nr(e),ir(e,t)}function ir(e,t){void 0!==e._closedPromise_reject&&(_(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function sr(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function ar(e){e._readyPromise=h((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function cr(e,t){ar(e),lr(e,t)}function ur(e){ar(e),dr(e)}function lr(e,t){void 0!==e._readyPromise_reject&&(_(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function dr(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(zt.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(zt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const hr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:void 0!==P?P:void 0,fr=function(){const e=null==hr?void 0:hr.DOMException;return function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;if("DOMException"!==e.name)return!1;try{return new e,!0}catch(e){return!1}}(e)?e:void 0}()||function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return s(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function pr(e,t,r,o,i,s){const a=J(e),c=Et(t);e._disturbed=!0;let u=!1,l=f(void 0);return h((d,b)=>{let w;if(void 0!==s){if(w=()=>{const r=void 0!==s.reason?s.reason:new fr("Aborted","AbortError"),n=[];o||n.push(()=>"writable"===t._state?Ot(t,r):f(void 0)),i||n.push(()=>"readable"===e._state?Wr(e,r):f(void 0)),R(()=>Promise.all(n.map(e=>e())),!0,r)},s.aborted)return void w();s.addEventListener("abort",w)}var S,I,P;if(T(e,a._closedPromise,e=>(o?C(!0,e):R(()=>Ot(t,e),!0,e),null)),T(t,c._closedPromise,t=>(i?C(!0,t):R(()=>Wr(e,t),!0,t),null)),S=e,I=a._closedPromise,P=()=>(r?C():R(()=>function(e){const t=e._ownerWritableStream,r=t._state;return Lt(t)||"closed"===r?f(void 0):"errored"===r?p(t._storedError):Wt(e)}(c)),null),"closed"===S._state?P():g(I,P),Lt(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");i?C(!0,t):R(()=>Wr(e,t),!0,t)}function E(){const e=l;return v(l,()=>e!==l?E():void 0)}function T(e,t,r){"errored"===e._state?r(e._storedError):m(t,r)}function R(e,r,n){function o(){return y(e(),()=>O(r,n),e=>O(!0,e)),null}u||(u=!0,"writable"!==t._state||Lt(t)?o():g(E(),o))}function C(e,r){u||(u=!0,"writable"!==t._state||Lt(t)?O(e,r):g(E(),()=>O(e,r)))}function O(e,t){return Ft(c),q(a),void 0!==s&&s.removeEventListener("abort",w),e?b(t):d(void 0),null}_(h((e,t)=>{!function r(o){o?e():v(u?f(!0):v(c._readyPromise,()=>h((e,t)=>{ne(a,{_chunkSteps:t=>{l=v(Mt(c,t),void 0,n),e(!1)},_closeSteps:()=>e(!0),_errorSteps:t})})),r,t)}(!1)}))})}class vr{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!yr(this))throw Tr("desiredSize");return Ir(this)}close(){if(!yr(this))throw Tr("close");if(!Pr(this))throw new TypeError("The stream is not in a state that permits close");_r(this)}enqueue(e){if(!yr(this))throw Tr("enqueue");if(!Pr(this))throw new TypeError("The stream is not in a state that permits enqueue");return wr(this,e)}error(e){if(!yr(this))throw Tr("error");Sr(this,e)}[C](e){Te(this);const t=this._cancelAlgorithm(e);return br(this),t}[O](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=Pe(this);this._closeRequested&&0===this._queue.length?(br(this),Br(t)):gr(this),e._chunkSteps(r)}else $(t,e),gr(this)}[A](){}}function yr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof vr}function gr(e){mr(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,y(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,gr(e)),null),t=>(Sr(e,t),null))))}function mr(e){const t=e._controlledReadableStream;return!!Pr(e)&&!!e._started&&(!!(Dr(t)&&Z(t)>0)||Ir(e)>0)}function br(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function _r(e){if(!Pr(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(br(e),Br(t))}function wr(e,t){if(!Pr(e))return;const r=e._controlledReadableStream;if(Dr(r)&&Z(r)>0)X(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw Sr(e,t),t}try{Ee(e,t,r)}catch(t){throw Sr(e,t),t}}gr(e)}function Sr(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(Te(e),br(e),Fr(r,t))}function Ir(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Pr(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function Er(e,t,r,n,o,i,s){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Te(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=s,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,e._readableStreamController=t,y(f(r()),()=>(t._started=!0,gr(t),null),e=>(Sr(t,e),null))}function Tr(e){return new TypeError("ReadableStreamDefaultController.prototype.".concat(e," can only be used on a ReadableStreamDefaultController"))}function Rr(e){return o(t=e)&&void 0!==t.getReader?function(e){let t;return t=Lr(n,function(){let r;try{r=e.read()}catch(r){return p(r)}return b(r,e=>{if(!o(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)_r(t._readableStreamController);else{const r=e.value;wr(t._readableStreamController,r)}})},function(t){try{return f(e.cancel(t))}catch(t){return p(t)}},0),t}(e.getReader()):function(e){let t;const r=function e(t){let r=arguments.length>2?arguments[2]:void 0;if(void 0===r)if("async"===(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"sync")){if(void 0===(r=pe(t,ye)))return function(e){const t={next(){let t;try{t=ge(e)}catch(e){return p(e)}return ve(t)},return(t){let r;try{const n=pe(e.iterator,"return");if(void 0===n)return f({done:!0,value:t});r=S(n,e.iterator,[t])}catch(e){return p(e)}return o(r)?ve(r):p(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(e(t,"sync",pe(t,Symbol.iterator)))}else r=pe(t,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=S(r,t,[]);if(!o(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}(e,"async");return t=Lr(n,function(){let e;try{e=ge(r)}catch(e){return p(e)}return b(f(e),e=>{if(!o(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(e.done)_r(t._readableStreamController);else{const r=e.value;wr(t._readableStreamController,r)}})},function(e){const t=r.iterator;let n;try{n=pe(t,"return")}catch(e){return p(e)}return void 0===n?f(void 0):b(I(n,t,[e]),e=>{if(!o(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")})},0),t}(e);var t}function Cr(e,t,r){return M(e,r),r=>I(e,t,[r])}function Or(e,t,r){return M(e,r),r=>I(e,t,[r])}function Ar(e,t,r){return M(e,r),r=>S(e,t,[r])}function kr(e,t){if("bytes"!==(e="".concat(e)))throw new TypeError("".concat(t," '").concat(e,"' is not a valid enumeration value for ReadableStreamType"));return e}function Ur(e,t){F(e,t);const r=null==e?void 0:e.preventAbort,n=null==e?void 0:e.preventCancel,o=null==e?void 0:e.preventClose,i=null==e?void 0:e.signal;return void 0!==i&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError("".concat(t," is not an AbortSignal."))}(i,"".concat(t," has member 'signal' that")),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:i}}Object.defineProperties(vr.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),s(vr.prototype.close,"close"),s(vr.prototype.enqueue,"enqueue"),s(vr.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(vr.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class qr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};void 0===e?e=null:H(e,"First parameter");const r=yt(t,"Second parameter"),n=function(e,t){F(e,t);const r=e,n=null==r?void 0:r.autoAllocateChunkSize,o=null==r?void 0:r.cancel,i=null==r?void 0:r.pull,s=null==r?void 0:r.start,a=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===n?void 0:Y(n,"".concat(t," has member 'autoAllocateChunkSize' that")),cancel:void 0===o?void 0:Cr(o,r,"".concat(t," has member 'cancel' that")),pull:void 0===i?void 0:Or(i,r,"".concat(t," has member 'pull' that")),start:void 0===s?void 0:Ar(s,r,"".concat(t," has member 'start' that")),type:void 0===a?void 0:kr(a,"".concat(t," has member 'type' that"))}}(e,"First parameter");if(jr(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){const n=Object.create(Oe.prototype);let o,i,s;o=void 0!==t.start?()=>t.start(n):()=>{},i=void 0!==t.pull?()=>t.pull(n):()=>f(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>f(void 0);const a=t.autoAllocateChunkSize;if(0===a)throw new TypeError("autoAllocateChunkSize must be greater than 0");tt(e,n,o,i,s,r,a)}(this,n,pt(r,0))}else{const e=vt(r);!function(e,t,r,n){const o=Object.create(vr.prototype);let i,s,a;i=void 0!==t.start?()=>t.start(o):()=>{},s=void 0!==t.pull?()=>t.pull(o):()=>f(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>f(void 0),Er(e,o,i,s,a,r,n)}(this,n,pt(r,1),e)}}get locked(){if(!Nr(this))throw Mr("locked");return Dr(this)}cancel(e){return Nr(this)?Dr(this)?p(new TypeError("Cannot cancel a stream that already has a reader")):Wr(this,e):p(Mr("cancel"))}getReader(e){if(!Nr(this))throw Mr("getReader");return void 0===function(e,t){F(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:ot(r,"".concat(t," has member 'mode' that"))}}(e,"First parameter").mode?J(this):it(this)}pipeThrough(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Nr(this))throw Mr("pipeThrough");z(e,1,"pipeThrough");const r=function(e,t){F(e,t);const r=null==e?void 0:e.readable;V(r,"readable","ReadableWritablePair"),Q(r,"".concat(t," has member 'readable' that"));const n=null==e?void 0:e.writable;return V(n,"writable","ReadableWritablePair"),St(n,"".concat(t," has member 'writable' that")),{readable:r,writable:n}}(e,"First parameter"),n=Ur(t,"Second parameter");if(Dr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Ct(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return _(pr(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable}pipeTo(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Nr(this))return p(Mr("pipeTo"));if(void 0===e)return p("Parameter 1 is required in 'pipeTo'.");if(!Rt(e))return p(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));try{t=Ur(r,"Second parameter")}catch(e){return p(e)}return Dr(this)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Ct(e)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):pr(this,e,t.preventClose,t.preventAbort,t.preventCancel,t.signal)}tee(){if(!Nr(this))throw Mr("tee");return ue(function(e){return Ae(e._readableStreamController)?function(e){let t,r,n,o,i,s=J(e),a=!1,c=!1,u=!1,l=!1,d=!1;const p=h(e=>{i=e});function v(e){m(e._closedPromise,t=>(e!==s||(Qe(n._readableStreamController,t),Qe(o._readableStreamController,t),l&&d||i(void 0)),null))}function y(){lt(s)&&(q(s),s=J(e),v(s)),ne(s,{_chunkSteps:t=>{w(()=>{c=!1,u=!1;const r=t;let s=t;if(!l&&!d)try{s=Ie(t)}catch(t){return Qe(n._readableStreamController,t),Qe(o._readableStreamController,t),void i(Wr(e,t))}l||Ye(n._readableStreamController,r),d||Ye(o._readableStreamController,s),a=!1,c?b():u&&_()})},_closeSteps:()=>{a=!1,l||Ke(n._readableStreamController),d||Ke(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&Ze(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&Ze(o._readableStreamController,0),l&&d||i(void 0)},_errorSteps:()=>{a=!1}})}function g(t,r){re(s)&&(q(s),s=it(e),v(s));const h=r?o:n,f=r?n:o;dt(s,t,1,{_chunkSteps:t=>{w(()=>{c=!1,u=!1;const n=r?d:l;if(r?l:d)n||et(h._readableStreamController,t);else{let r;try{r=Ie(t)}catch(t){return Qe(h._readableStreamController,t),Qe(f._readableStreamController,t),void i(Wr(e,t))}n||et(h._readableStreamController,t),Ye(f._readableStreamController,r)}a=!1,c?b():u&&_()})},_closeSteps:e=>{a=!1;const t=r?d:l,n=r?l:d;t||Ke(h._readableStreamController),n||Ke(f._readableStreamController),void 0!==e&&(t||et(h._readableStreamController,e),!n&&f._readableStreamController._pendingPullIntos.length>0&&Ze(f._readableStreamController,0)),t&&n||i(void 0)},_errorSteps:()=>{a=!1}})}function b(){if(a)return c=!0,f(void 0);a=!0;const e=$e(n._readableStreamController);return null===e?y():g(e._view,!1),f(void 0)}function _(){if(a)return u=!0,f(void 0);a=!0;const e=$e(o._readableStreamController);return null===e?y():g(e._view,!0),f(void 0)}function S(){}return n=xr(S,b,function(n){if(l=!0,t=n,d){const n=ue([t,r]),o=Wr(e,n);i(o)}return p}),o=xr(S,_,function(n){if(d=!0,r=n,l){const n=ue([t,r]),o=Wr(e,n);i(o)}return p}),v(s),[n,o]}(e):function(e){const t=J(e);let r,n,o,i,s,a=!1,c=!1,u=!1,l=!1;const d=h(e=>{s=e});function p(){return a?(c=!0,f(void 0)):(a=!0,ne(t,{_chunkSteps:e=>{w(()=>{c=!1;const t=e,r=e;u||wr(o._readableStreamController,t),l||wr(i._readableStreamController,r),a=!1,c&&p()})},_closeSteps:()=>{a=!1,u||_r(o._readableStreamController),l||_r(i._readableStreamController),u&&l||s(void 0)},_errorSteps:()=>{a=!1}}),f(void 0))}function v(){}return o=Lr(v,p,function(t){if(u=!0,r=t,l){const t=ue([r,n]),o=Wr(e,t);s(o)}return d}),i=Lr(v,p,function(t){if(l=!0,n=t,u){const t=ue([r,n]),o=Wr(e,t);s(o)}return d}),m(t._closedPromise,e=>(Sr(o._readableStreamController,e),Sr(i._readableStreamController,e),u&&l||s(void 0),null)),[o,i]}(e)}(this))}values(e){if(!Nr(this))throw Mr("values");return function(e,t){const r=J(e),n=new me(r,t),o=Object.create(be);return o._asyncIteratorImpl=n,o}(this,function(e){F(e,"First parameter");const t=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(t)}}(e).preventCancel)}[ye](e){return this.values(e)}static from(e){return Rr(e)}}function Lr(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:()=>1;const i=Object.create(qr.prototype);return jr(i),Er(i,Object.create(vr.prototype),e,t,r,n,o),i}function xr(e,t,r){const n=Object.create(qr.prototype);return jr(n),tt(n,Object.create(Oe.prototype),e,t,r,0,void 0),n}function jr(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Nr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof qr}function Dr(e){return void 0!==e._reader}function Wr(e,t){if(e._disturbed=!0,"closed"===e._state)return f(void 0);if("errored"===e._state)return p(e._storedError);Br(e);const r=e._reader;if(void 0!==r&<(r)){const e=r._readIntoRequests;r._readIntoRequests=new E,e.forEach(e=>{e._closeSteps(void 0)})}return b(e._readableStreamController[C](t),n)}function Br(e){e._state="closed";const t=e._reader;if(void 0!==t&&(D(t),re(t))){const e=t._readRequests;t._readRequests=new E,e.forEach(e=>{e._closeSteps()})}}function Fr(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(N(r,t),re(r)?oe(r,t):ht(r,t))}function Mr(e){return new TypeError("ReadableStream.prototype.".concat(e," can only be used on a ReadableStream"))}function Hr(e,t){F(e,t);const r=null==e?void 0:e.highWaterMark;return V(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:G(r)}}Object.defineProperties(qr,{from:{enumerable:!0}}),Object.defineProperties(qr.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),s(qr.from,"from"),s(qr.prototype.cancel,"cancel"),s(qr.prototype.getReader,"getReader"),s(qr.prototype.pipeThrough,"pipeThrough"),s(qr.prototype.pipeTo,"pipeTo"),s(qr.prototype.tee,"tee"),s(qr.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(qr.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(qr.prototype,ye,{value:qr.prototype.values,writable:!0,configurable:!0});const zr=e=>e.byteLength;s(zr,"size");class Vr{constructor(e){z(e,1,"ByteLengthQueuingStrategy"),e=Hr(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!Kr(this))throw Gr("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!Kr(this))throw Gr("size");return zr}}function Gr(e){return new TypeError("ByteLengthQueuingStrategy.prototype.".concat(e," can only be used on a ByteLengthQueuingStrategy"))}function Kr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof Vr}Object.defineProperties(Vr.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Vr.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const Yr=()=>1;s(Yr,"size");class Qr{constructor(e){z(e,1,"CountQueuingStrategy"),e=Hr(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!$r(this))throw Jr("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!$r(this))throw Jr("size");return Yr}}function Jr(e){return new TypeError("CountQueuingStrategy.prototype.".concat(e," can only be used on a CountQueuingStrategy"))}function $r(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof Qr}function Xr(e,t,r){return M(e,r),r=>I(e,t,[r])}function Zr(e,t,r){return M(e,r),r=>S(e,t,[r])}function en(e,t,r){return M(e,r),(r,n)=>I(e,t,[r,n])}function tn(e,t,r){return M(e,r),r=>I(e,t,[r])}Object.defineProperties(Qr.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Qr.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class rn{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};void 0===e&&(e=null);const r=yt(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},"Second parameter"),n=yt(t,"Third parameter"),o=function(e,t){F(e,t);const r=null==e?void 0:e.cancel,n=null==e?void 0:e.flush,o=null==e?void 0:e.readableType,i=null==e?void 0:e.start,s=null==e?void 0:e.transform,a=null==e?void 0:e.writableType;return{cancel:void 0===r?void 0:tn(r,e,"".concat(t," has member 'cancel' that")),flush:void 0===n?void 0:Xr(n,e,"".concat(t," has member 'flush' that")),readableType:o,start:void 0===i?void 0:Zr(i,e,"".concat(t," has member 'start' that")),transform:void 0===s?void 0:en(s,e,"".concat(t," has member 'transform' that")),writableType:a}}(e,"First parameter");if(void 0!==o.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==o.writableType)throw new RangeError("Invalid writableType specified");const i=pt(n,0),s=vt(n),a=pt(r,1),c=vt(r);let u;!function(e,t,r,n,o,i){function s(){return t}e._writable=function(e,t,r,n){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:()=>1;const s=Object.create(Pt.prototype);return Tt(s),Gt(s,Object.create(zt.prototype),e,t,r,n,o,i),s}(s,function(t){return function(e,t){const r=e._transformStreamController;return e._backpressure?b(e._backpressureChangePromise,()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return fn(r,t)}):fn(r,t)}(e,t)},function(){return function(e){const t=e._transformStreamController;if(void 0!==t._finishPromise)return t._finishPromise;const r=e._readable;t._finishPromise=h((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r});const n=t._flushAlgorithm();return dn(t),y(n,()=>("errored"===r._state?yn(t,r._storedError):(_r(r._readableStreamController),vn(t)),null),e=>(Sr(r._readableStreamController,e),yn(t,e),null)),t._finishPromise}(e)},function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._readable;r._finishPromise=h((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const o=r._cancelAlgorithm(t);return dn(r),y(o,()=>("errored"===n._state?yn(r,n._storedError):(Sr(n._readableStreamController,t),vn(r)),null),e=>(Sr(n._readableStreamController,e),yn(r,e),null)),r._finishPromise}(e,t)},r,n),e._readable=Lr(s,function(){return function(e){return cn(e,!1),e._backpressureChangePromise}(e)},function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._writable;r._finishPromise=h((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const o=r._cancelAlgorithm(t);return dn(r),y(o,()=>("errored"===n._state?yn(r,n._storedError):(Jt(n._writableStreamController,t),an(e),vn(r)),null),t=>(Jt(n._writableStreamController,t),an(e),yn(r,t),null)),r._finishPromise}(e,t)},o,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,cn(e,!0),e._transformStreamController=void 0}(this,h(e=>{u=e}),a,c,i,s),function(e,t){const r=Object.create(un.prototype);let n,o,i;n=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return hn(r,e),f(void 0)}catch(e){return p(e)}},o=void 0!==t.flush?()=>t.flush(r):()=>f(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>f(void 0),function(e,t,r,n,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n,t._cancelAlgorithm=o,t._finishPromise=void 0,t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0}(e,r,n,o,i)}(this,o),void 0!==o.start?u(o.start(this._transformStreamController)):u(void 0)}get readable(){if(!nn(this))throw gn("readable");return this._readable}get writable(){if(!nn(this))throw gn("writable");return this._writable}}function nn(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof rn}function on(e,t){Sr(e._readable._readableStreamController,t),sn(e,t)}function sn(e,t){dn(e._transformStreamController),Jt(e._writable._writableStreamController,t),an(e)}function an(e){e._backpressure&&cn(e,!1)}function cn(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=h(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}Object.defineProperties(rn.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(rn.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class un{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!ln(this))throw pn("desiredSize");return Ir(this._controlledTransformStream._readable._readableStreamController)}enqueue(e){if(!ln(this))throw pn("enqueue");hn(this,e)}error(e){if(!ln(this))throw pn("error");var t;t=e,on(this._controlledTransformStream,t)}terminate(){if(!ln(this))throw pn("terminate");!function(e){const t=e._controlledTransformStream;_r(t._readable._readableStreamController),sn(t,new TypeError("TransformStream terminated"))}(this)}}function ln(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof un}function dn(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function hn(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!Pr(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{wr(n,t)}catch(e){throw sn(r,e),r._readable._storedError}(function(e){return!mr(e)})(n)!==r._backpressure&&cn(r,!0)}function fn(e,t){return b(e._transformAlgorithm(t),void 0,t=>{throw on(e._controlledTransformStream,t),t})}function pn(e){return new TypeError("TransformStreamDefaultController.prototype.".concat(e," can only be used on a TransformStreamDefaultController"))}function vn(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function yn(e,t){void 0!==e._finishPromise_reject&&(_(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function gn(e){return new TypeError("TransformStream.prototype.".concat(e," can only be used on a TransformStream"))}Object.defineProperties(un.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),s(un.prototype.enqueue,"enqueue"),s(un.prototype.error,"error"),s(un.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(un.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0})},function(e,t,r){var n;r.r(t),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function s(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}r.d(t,"StorageType",function(){return n}),r.d(t,"AbstractSDKRequest",function(){return o}),r.d(t,"AbstractStorage",function(){return i}),r.d(t,"formatUrl",function(){return s})}])}(Bf);var Ff=E(Bf.exports),Mf=this&&this.__assign||function(){return Mf=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Mf.apply(this,arguments)},Hf=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},zf=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},Vf=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return Hf(this,void 0,void 0,function(){return zf(this,function(t){return[2,this.localStorage.getItem(e)]})})},e.prototype.removeItem=function(e){return Hf(this,void 0,void 0,function(){return zf(this,function(t){return this.localStorage.removeItem(e),[2]})})},e.prototype.setItem=function(e,t){return Hf(this,void 0,void 0,function(){return zf(this,function(r){return this.localStorage.setItem(e,t),[2]})})},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),Gf=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,Kf=function(e,t){var r,n,o,i=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||i),(null==e?void 0:e.error)?(e.error_uri=function(e){return Gf.test(e)?RegExp.$1:e}(null==t?void 0:t.url),e):(null==e?void 0:e.data)||{}};var Yf=function(e,t){var r=Mf({},e),n={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!Ff.isMatch()||e.storage&&e.baseRequest)return r;try{var o=Ff.genAdapter({}),i=o.localStorage,s=o.reqClass;if(i&&(n.storage=new Vf({localStorage:i,adapter:t})),s){var a=new s({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});n.request=function(e){return function(t,r){return Hf(this,void 0,void 0,function(){return zf(this,function(n){return[2,new Promise(function(n,o){var i=Object.assign({},r);i.body&&"string"!=typeof i.body&&(i.body=JSON.stringify(i.body));var s=wx.request({url:t,data:i.body,timeout:e._timeout,method:i.method||"GET",header:i.headers,success:function(e){(e=Kf(e,Mf(Mf({},r),{url:t}))).error&&o(e),n(e)},fail:function(e){o({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{s.abort()}catch(e){}}}})})]})})}}(a)}return r.captchaOptions&&(n.baseRequest=n.request,n.request=void 0),Mf(Mf({},r),n)}catch(e){console.error("adapter generate fail:",e)}return r},Qf=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=Mf({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new Vf({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var n=new t.reqClass({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});r.baseRequest=function(e,t){var r,o,i,s,a;return Hf(this,void 0,void 0,function(){var c,u,l,d;return zf(this,function(h){switch(h.label){case 0:if(c={},u=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(l=null===(i=null===(o=null==n?void 0:n[u])||void 0===o?void 0:o.bind)||void 0===i?void 0:i.call(o,n)))throw new Error("invalid 【".concat(u,"】 request method"));h.label=1;case 1:return h.trys.push([1,3,,4]),(null===(s=t.headers)||void 0===s?void 0:s["content-type"])&&!(null===(a=t.headers)||void 0===a?void 0:a["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,l(Mf({url:e},t))];case 2:return c=h.sent(),c=Kf(c,Mf(Mf({},t),{url:e})),[3,4];case 3:throw d=h.sent(),c=Mf(Mf({},null==d?void 0:d.data),d);case 4:if(null==c?void 0:c.error)throw c;return[2,c]}})})}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):Yf(e,e.adapter)};var Jf=this&&this.__assign||function(){return Jf=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Jf.apply(this,arguments)},$f=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},Xf=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},Zf=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((n=n.apply(e,t||[])).next())})},ep=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},tp=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},rp=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},np=function(e){return function(t){e.fire(sh,Jf(Jf({},t),{eventType:Xd}))}},op=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}return e.prototype.checkLocalInfo=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]})})},e.prototype.checkLocalInfoAsync=function(){return Zf(this,void 0,void 0,function(){var e,t,r,n;return ep(this,function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}})})},e.prototype.update=function(e){return Zf(this,void 0,void 0,function(){var t;return ep(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(Jf({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}})})},e.prototype.updateUserBasicInfo=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(Jf({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}})})},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&Lh(Th,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return Zf(this,void 0,void 0,function(){var t;return ep(this,function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}})})},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return Zf(this,void 0,void 0,function(){var t;return ep(this,function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}})})},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at"].forEach(function(t){e[t]=r[t]})},$f([cf({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"update",null),$f([cf({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[String,String]),Xf("design:returntype",void 0)],e.prototype,"updatePassword",null),$f([cf({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[String]),Xf("design:returntype",void 0)],e.prototype,"updateUsername",null),$f([cf({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"refresh",null),e}(),ip=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||Lh(Th,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new op({cache:this.cache,oauthInstance:n})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}})})},e}(),sp=function(){function e(e){this.listeners=new Map,this.hasListenerSetUp=!1,this.config=e,this.oauthInstance=e.oauthInstance,this.cache=e.cache,this.init(),this.setAccessKey()}return e.prototype.bindPhoneNumber=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.editContact(e)]})})},e.prototype.unbindProvider=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]})})},e.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},e.prototype.verify=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.verify(e)]})})},e.prototype.getVerification=function(e,t){return Zf(this,void 0,void 0,function(){return ep(this,function(r){return[2,this.oauthInstance.authApi.getVerification(e,t)]})})},Object.defineProperty(e.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}qh(Rh,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),e.prototype.getCurrentUser=function(){return Zf(this,void 0,void 0,function(){var e,t;return ep(this,function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(e=r.sent())?(t=e.user.getLocalUserInfo(),[4,e.user.checkLocalInfoAsync()]):[3,3];case 2:return r.sent(),[2,Jf(Jf({},e.user),t)];case 3:return[2,null]}})})},e.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return Zf(this,void 0,void 0,function(){var e,r,n=this;return ep(this,function(o){switch(o.label){case 0:if(!Ff.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return Zf(n,void 0,void 0,function(){var n,o;return ep(this,function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},t)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}})})},[4,new Promise(function(e,t){wx.login({success:function(o){return Zf(n,void 0,void 0,function(){var n;return ep(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),t(n),[3,3];case 3:return[2]}})})},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})})];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}})})},e.prototype.bindOpenId=function(){return Zf(this,void 0,void 0,function(){var e,t,r=this;return ep(this,function(n){switch(n.label){case 0:if(!Ff.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return Zf(r,void 0,void 0,function(){var r;return ep(this,function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}})})},[4,new Promise(function(e,n){wx.login({success:function(o){return Zf(r,void 0,void 0,function(){var r;return ep(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})})];case 1:return n.sent(),[2]}})})},e.prototype.signInWithUnionId=function(){return Zf(this,void 0,void 0,function(){var e=this;return ep(this,function(t){switch(t.label){case 0:if(!Ff.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise(function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return Zf(e,void 0,void 0,function(){var e,i,s,a,c;return ep(this,function(u){switch(u.label){case 0:e=null==n?void 0:n.appId,u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return i=u.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=u.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return c=u.sent(),r(c),[3,5];case 5:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}})})},e.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,c=void 0===a?void 0:a;return Zf(this,void 0,void 0,function(){return ep(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:c,username:s,loginType:"sms"})]}catch(e){throw e}return[2]})})},e.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,c=void 0===a?"":a;return Zf(this,void 0,void 0,function(){return ep(this,function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:c,loginType:"email"})]}catch(e){throw e}return[2]})})},e.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},e.prototype.signIn=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},e.prototype.setPassword=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.setPassword(e)]})})},e.prototype.isUsernameRegistered=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return"string"!=typeof e&&Lh(Th,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}})})},e.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new ip({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;qh(Rh,"current platform's storage is asynchronous, please use getLoginState instead")},e.prototype.getLoginState=function(){return Zf(this,void 0,void 0,function(){var e;return ep(this,function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new ip({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}})})},e.prototype.getUserInfo=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return[2,this.getCurrentUser()]})})},e.prototype.getWedaUserInfo=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]})})},e.prototype.updateUserBasicInfo=function(e){return Zf(this,void 0,void 0,function(){var t;return ep(this,function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},e.prototype.bindWithProvider=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]})})},e.prototype.queryUser=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]})})},e.prototype.getAccessToken=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}})})},e.prototype.grantProviderToken=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]})})},e.prototype.patchProviderToken=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]})})},e.prototype.signInWithProvider=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},e.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}})})},e.prototype.grantToken=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}})})},e.prototype.genProviderRedirectUri=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]})})},e.prototype.resetPassword=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]})})},e.prototype.deviceAuthorize=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]})})},e.prototype.sudo=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.sudo(e)]})})},e.prototype.deleteMe=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]})})},e.prototype.getProviders=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return[2,this.oauthInstance.authApi.getProviders()]})})},e.prototype.loginScope=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return[2,this.oauthInstance.authApi.loginScope()]})})},e.prototype.loginGroups=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return[2,this.oauthInstance.authApi.loginGroups()]})})},e.prototype.onLoginStateChanged=function(e){var t;return Zf(this,void 0,void 0,function(){var r,n=this;return ep(this,function(o){switch(o.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(sh,function(t){return Zf(n,void 0,void 0,function(){var r,n,o;return ep(this,function(i){switch(i.label){case 0:return(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.eventType)===Xd?[3,2]:[4,this.getLoginState()];case 1:return n=i.sent(),[3,3];case 2:n={},i.label=3;case 3:return r=n,e.call(this,Jf(Jf({},t),r)),[2]}})})}),[4,this.getLoginState()];case 1:return r=o.sent(),e.call(this,r),[2]}})})},e.prototype.refreshTokenForce=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]})})},e.prototype.getCredentials=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return[2,this.oauthInstance.authApi.getCredentials()]})})},e.prototype.setCredentials=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}})})},e.prototype.getProviderSubType=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]})})},e.prototype.createCaptchaData=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]})})},e.prototype.verifyCaptchaData=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]})})},e.prototype.getMiniProgramQrCode=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]})})},e.prototype.getMiniProgramQrCodeStatus=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]})})},e.prototype.modifyPassword=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]})})},e.prototype.modifyPasswordWithoutLogin=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]})})},e.prototype.getUserBehaviorLog=function(e){return Zf(this,void 0,void 0,function(){return ep(this,function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]})})},e.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.username,s=void 0===i?"":i,a=e.bindInfo,c=void 0===a?void 0:a,u=e.loginType,l=void 0===u?"":u;return Zf(this,void 0,void 0,function(){var e,t,n,i,a,u,d;return ep(this,function(h){switch(h.label){case 0:return h.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=h.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=/^\+\d{1,3}\s+/.test(s)?s:"+86 ".concat(s),i={phone_number:n},"email"===l&&(i={email:n=s}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(a=h.sent())?void 0:a.error_code)throw a;return c?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==c?void 0:c.providerToken})]:[3,4];case 3:if(null==(u=h.sent())?void 0:u.error_code)throw u;h.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(Jf(Jf({},i),{verification_token:t,provider_token:null==c?void 0:c.providerId}))];case 6:if(null==(d=h.sent())?void 0:d.error_code)throw d;h.label=7;case 7:return[2,this.createLoginState()];case 8:throw h.sent();case 9:return[2]}})})},e.prototype.createLoginState=function(e,t){var r,n;return Zf(this,void 0,void 0,function(){var o;return ep(this,function(i){switch(i.label){case 0:return[4,(o=new ip({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return i.sent(),(null==t?void 0:t.userInfo)?(o.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(o.user.refresh(e),[3,5]):[3,3];case 3:return[4,o.user.refresh(e)];case 4:i.sent(),i.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(sh,{eventType:$d}),null===(n=this.config.eventBus)||void 0===n||n.fire(ah,{event:eh}),[2,o]}})})},e.prototype.setAccessKey=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){if(this.config.accessKey)try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:this.config.accessKey,token_type:"Bearer",scope:"accessKey",expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]})})},e.prototype.signInAnonymously=function(e){return Zf(this,void 0,void 0,function(){var t,r,n,o;return ep(this,function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return i.sent(),[4,this.createLoginState()];case 2:return t=i.sent(),[4,this.getSession()];case 3:return r=i.sent().data,n=(void 0===r?{}:r).session,[2,Jf(Jf({},t),{data:{user:n.user,session:n},error:null})];case 4:return o=i.sent(),[2,{data:{},error:new xf(o)}];case 5:return[2]}})})},e.prototype.signUp=function(e){return Zf(this,void 0,void 0,function(){var t,r,n=this;return ep(this,function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?[4,this.oauthInstance.authApi.signUp(e)]:[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=o.sent(),[2,{data:{verifyOtp:function(r){var o=r.token,i=r.messageId,s=void 0===i?t.verification_id:i;return Zf(n,void 0,void 0,function(){var r,n,i,a,c;return ep(this,function(u){switch(u.label){case 0:return u.trys.push([0,8,,9]),[4,this.verify({verification_id:s||t.verification_id,verification_code:o})];case 1:return r=u.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:r.verification_token})]:[3,3];case 2:return u.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(e))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp(Jf(Jf(Jf({},n),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:r.verification_token,verification_code:o}))];case 4:return u.sent(),[4,this.createLoginState()];case 5:u.sent(),u.label=6;case 6:return[4,this.getSession()];case 7:return i=u.sent().data,[2,{data:{user:(a=(void 0===i?{}:i).session).user,session:a},error:null}];case 8:return c=u.sent(),[2,{data:{},error:new xf(c)}];case 9:return[2]}})})}},error:null}];case 4:return r=o.sent(),[2,{data:{},error:new xf(r)}];case 5:return[2]}})})},e.prototype.signOut=function(e){var t,r;return Zf(this,void 0,void 0,function(){var n,o,i;return ep(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return o=s.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return s.sent(),this.setAccessKey(),null===(t=this.config.eventBus)||void 0===t||t.fire(sh,{eventType:Jd}),null===(r=this.config.eventBus)||void 0===r||r.fire(ah,{event:Zd}),[2,Jf(Jf({},o),{data:{},error:null})];case 3:return i=s.sent(),[2,{data:{},error:new xf(i)}];case 4:return[2]}})})},e.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},e.prototype.signInWithPassword=function(e){return Zf(this,void 0,void 0,function(){var t,r,n;return ep(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(Jf({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new xf(n)}];case 4:return[2]}})})},e.prototype.signInWithIdToken=function(e){return Zf(this,void 0,void 0,function(){var t,r,n;return ep(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new xf(n)}];case 4:return[2]}})})},e.prototype.signInWithOtp=function(e){return Zf(this,void 0,void 0,function(){var t,r,n=this;return ep(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 1:return t=o.sent(),[2,{data:{user:null,session:null,verifyOtp:function(r){var o=r.token,i=r.messageId,s=void 0===i?t.verification_id:i;return Zf(n,void 0,void 0,function(){return ep(this,function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:o,messageId:s})]})})}},error:null}];case 2:return r=o.sent(),[2,{data:{},error:new xf(r)}];case 3:return[2]}})})},e.prototype.verifyOAuth=function(e){return Zf(this,void 0,void 0,function(){var t,r,n,o,i,s,a,c,u;return ep(this,function(l){switch(l.label){case 0:t={},l.label=1;case 1:return l.trys.push([1,7,,8]),r=(null==e?void 0:e.code)||Uh("code"),n=(null==e?void 0:e.state)||Uh("state"),r?n?(o=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}}(n),t.type=null==o?void 0:o.type,(i=(null==e?void 0:e.provider)||(null==o?void 0:o.provider)||Uh("provider"))?[4,this.grantProviderToken({provider_id:i,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:t,error:new xf({message:"Provider is required"})}]):[2,{data:{},error:new xf({message:"State is required"})}]:[2,{data:{},error:new xf({message:"Code is required"})}];case 2:return s=l.sent().provider_token,a=void 0,o.type!==uh?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:s,provider:i,fireEvent:!0})];case 3:return a=l.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:s})];case 5:(a=l.sent()).data=Jf(Jf({},t),a.data),l.label=6;case 6:return(c=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),c.delete("state"),function(e,t){if(void 0!==e){var r=new URL(window.location.href);r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href)}}(void 0===(null==o?void 0:o.search)?"?".concat(c.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}}(n),[2,a];case 7:return u=l.sent(),[2,{data:t,error:new xf(u)}];case 8:return[2]}})})},e.prototype.signInWithOAuth=function(e){var t,r,n,o,i;return Zf(this,void 0,void 0,function(){var s,a,c,u,l,d,h,f,p;return ep(this,function(v){switch(v.label){case 0:return v.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),c=a.origin+a.pathname,u=(null===(r=e.options)||void 0===r?void 0:r.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:c,state:u})];case 1:return l=v.sent().uri,d=decodeURIComponent(l),h=d,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(f=new URL(d),Object.entries(e.options.queryParams).forEach(function(e){var t=e[0],r=e[1];f.searchParams.set(t,r)}),h=f.toString()),function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}}(u,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(o=e.options)||void 0===o?void 0:o.type)||ch}),rp()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(h),[2,{data:{url:h,provider:e.provider},error:null}];case 2:return p=v.sent(),[2,{data:{},error:new xf(p)}];case 3:return[2]}})})},e.prototype.getClaims=function(){return Zf(this,void 0,void 0,function(){var e,t,r;return ep(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=n.sent().accessToken,t=function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{const t=e.split(".").map((e,t)=>2===t?e:JSON.parse(bh(e)));return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:"")}}(e),[2,{data:t,error:null}];case 2:return r=n.sent(),[2,{data:{},error:new xf(r)}];case 3:return[2]}})})},e.prototype.resetPasswordForEmail=function(e,t){return Zf(this,void 0,void 0,function(){var r,n,o,i,s,a,c=this;return ep(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(t||{}).redirectTo,n=e.includes("@"),o=void 0,n?o={email:e}:(i=this.formatPhone(e),o={phone_number:i}),[4,this.getVerification(o)];case 1:return s=u.sent(),[2,{data:{updateUser:function(t){return Zf(c,void 0,void 0,function(){var o,i,a,c;return ep(this,function(u){switch(u.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:t.nonce})];case 2:return o=u.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone_number:n?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return u.sent(),null===(c=this.config.eventBus)||void 0===c||c.fire(ah,{event:rh}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return i=u.sent(),r&&rp()&&window.location.assign(r),[2,i];case 5:return a=u.sent(),[2,{data:{},error:new xf(a)}];case 6:return[2]}})})}},error:null}];case 2:return a=u.sent(),[2,{data:{},error:new xf(a)}];case 3:return[2]}})})},e.prototype.resetPasswordForOld=function(e){return Zf(this,void 0,void 0,function(){var t,r,n;return ep(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new xf(n)}];case 4:return[2]}})})},e.prototype.verifyOtp=function(e){return Zf(this,void 0,void 0,function(){var t,r,n,o;return ep(this,function(i){switch(i.label){case 0:return i.trys.push([0,6,,7]),t=e.type,this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:e.token})]:[3,2];case 1:return i.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:e.token,username:e.email||this.formatPhone(e.phone)||"",loginType:e.email?"email":"phone"})];case 3:i.sent(),i.label=4;case 4:return[4,this.getSession()];case 5:return r=i.sent().data,[2,{data:{user:(n=(void 0===r?{}:r).session).user,session:n},error:null}];case 6:return o=i.sent(),[2,{data:{},error:new xf(o)}];case 7:return[2]}})})},e.prototype.getSession=function(){return Zf(this,void 0,void 0,function(){var e,t,r,n;return ep(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?[4,this.getUser()]:[2,{data:{session:null},error:null}];case 2:return t=o.sent().data,r=(void 0===t?{}:t).user,[2,{data:{session:Jf(Jf({},e),{user:r}),user:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new xf(n)}];case 4:return[2]}})})},e.prototype.refreshSession=function(e){return Zf(this,void 0,void 0,function(){var t,r,n,o,i;return ep(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=s.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return r=s.sent(),[4,this.getUser()];case 3:return n=s.sent().data,[2,{data:{user:o=(void 0===n?{}:n).user,session:Jf(Jf({},r),{user:o})},error:null}];case 4:return i=s.sent(),[2,{data:{},error:new xf(i)}];case 5:return[2]}})})},e.prototype.getUser=function(){return Zf(this,void 0,void 0,function(){var e,t;return ep(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=this.convertToUser,[4,this.getUserInfo()];case 1:return[2,{data:{user:e.apply(this,[r.sent()])},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new xf(t)}];case 3:return[2]}})})},e.prototype.refreshUser=function(){return Zf(this,void 0,void 0,function(){var e,t,r;return ep(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return n.sent(),[4,this.getSession()];case 2:return e=n.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new xf(r)}];case 4:return[2]}})})},e.prototype.updateUser=function(e){var t;return Zf(this,void 0,void 0,function(){var r,n,o,i,s,a,c,u,l,d,h,f,p=this;return ep(this,function(v){switch(v.label){case 0:if(v.trys.push([0,8,,9]),!Object.keys(e).some(function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]}))throw new xf({message:"At least one field must be provided for update"});return r=e.email,n=e.phone,o=tp(e,["email","phone"]),s=void 0!==n,a={},(i=void 0!==r)||s?(c=void 0,i?(c={email:e.email},u="email_change"):(l=this.formatPhone(e.phone),c={phone_number:l},u="phone_change"),[4,this.getVerification(c)]):[3,4];case 1:return d=v.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:v.sent(),v.label=3;case 3:return a={messageId:d.verification_id,verifyOtp:function(t){return Zf(p,void 0,void 0,function(){var r,n,o;return ep(this,function(s){switch(s.label){case 0:return s.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:d.verification_id})]:[3,3];case 1:return s.sent(),[4,this.updateUserBasicInfo({email:e.email})];case 2:return s.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:d.verification_id})]:[3,6];case 4:return s.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return s.sent(),[3,9];case 6:return[4,this.verifyOtp({type:u,email:i?e.email:void 0,phone:i?void 0:e.phone,token:t.token,messageId:d.verification_id})];case 7:return s.sent(),[4,this.updateUserBasicInfo(e)];case 8:s.sent(),s.label=9;case 9:return[4,this.getUser()];case 10:return r=s.sent().data.user,null===(o=this.config.eventBus)||void 0===o||o.fire(ah,{event:oh}),[2,{data:{user:r},error:null}];case 11:return n=s.sent(),[2,{data:{},error:new xf(n)}];case 12:return[2]}})})}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:v.sent(),v.label=6;case 6:return[4,this.getUser()];case 7:return h=v.sent().data.user,null===(t=this.config.eventBus)||void 0===t||t.fire(ah,{event:oh}),[2,{data:Jf({user:h},a),error:null}];case 8:return f=v.sent(),[2,{data:{},error:new xf(f)}];case 9:return[2]}})})},e.prototype.getUserIdentities=function(){var e;return Zf(this,void 0,void 0,function(){var t,r;return ep(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=n.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter(function(e){return!!e.bind})},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new xf(r)}];case 3:return[2]}})})},e.prototype.linkIdentity=function(e){return Zf(this,void 0,void 0,function(){var t;return ep(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:uh}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new xf(t)}];case 3:return[2]}})})},e.prototype.unlinkIdentity=function(e){return Zf(this,void 0,void 0,function(){var t;return ep(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new xf(t)}];case 3:return[2]}})})},e.prototype.reauthenticate=function(){return Zf(this,void 0,void 0,function(){var e,t,r,n,o=this;return ep(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.getUser()];case 1:return e=i.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),t=e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return r=i.sent(),[2,{data:{updateUser:function(e){return Zf(o,void 0,void 0,function(){var n,o,i,s,a;return ep(this,function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:r.verification_id,verification_code:e.nonce})]:[3,5];case 2:return n=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return o=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:o.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(Jf(Jf({verificationInfo:r,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return i=c.sent().data,[2,{data:{user:(s=(void 0===i?{}:i).session).user,session:s},error:null}];case 9:return a=c.sent(),[2,{data:{},error:new xf(a)}];case 10:return[2]}})})}},error:null}];case 3:return n=i.sent(),[2,{data:{},error:new xf(n)}];case 4:return[2]}})})},e.prototype.resend=function(e){return Zf(this,void 0,void 0,function(){var t,r,n;return ep(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),t="signup"===e.type?"ANY":"USER",r={target:t},"email"in e&&(r.email=e.email),"phone"in e&&(r.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return n=o.sent(),[2,{data:{},error:new xf(n)}];case 3:return[2]}})})},e.prototype.setSession=function(e){var t;return Zf(this,void 0,void 0,function(){var r,n,o;return ep(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,n=(void 0===r?{}:r).session,null===(t=this.config.eventBus)||void 0===t||t.fire(ah,{event:eh}),[2,{data:{user:n.user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new xf(o)}];case 4:return[2]}})})},e.prototype.exchangeCodeForSession=function(){return Zf(this,void 0,void 0,function(){return ep(this,function(e){return[2]})})},e.prototype.deleteUser=function(e){return Zf(this,void 0,void 0,function(){var t,r;return ep(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new xf(r)}];case 4:return[2]}})})},e.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),Zf(this,void 0,void 0,function(){var t,r,n,o,i;return ep(this,function(s){try{return t=e.config_version||"env",r=Object.keys(e.query||{}).map(function(t){return"".concat(t,"=").concat(e.query[t])}).join("&"),Ff.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=e.redirect_uri||window.location.href,o=new URL(n),i="".concat(o.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=i),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new xf(e)}]}return[2]})})},e.prototype.signInWithCustomTicket=function(e){return Zf(this,void 0,void 0,function(){var t,r,n,o;return ep(this,function(i){switch(i.label){case 0:e&&this.setCustomSignFunc(e),i.label=1;case 1:return i.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return i.sent(),[4,this.createLoginState()];case 3:return t=i.sent(),[4,this.getSession()];case 4:return r=i.sent().data,n=(void 0===r?{}:r).session,[2,Jf(Jf({},t),{data:{user:n.user,session:n},error:null})];case 5:return o=i.sent(),[2,{data:{},error:new xf(o)}];case 6:return[2]}})})},e.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return Zf(this,void 0,void 0,function(){var e,t,n,o,i,s,a=this;return ep(this,function(c){switch(c.label){case 0:if(!Ff.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return Zf(a,void 0,void 0,function(){var n,o;return ep(this,function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},r)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:n.provider_token},r)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}})})},c.label=1;case 1:return c.trys.push([1,5,,6]),[4,new Promise(function(e,r){wx.login({success:function(n){return Zf(a,void 0,void 0,function(){var o;return ep(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(n.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),r(o),[3,3];case 3:return[2]}})})},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})})];case 2:return c.sent(),[4,this.createLoginState()];case 3:return n=c.sent(),[4,this.getSession()];case 4:return o=c.sent().data,i=(void 0===o?{}:o).session,[2,Jf(Jf({},n),{data:{user:i.user,session:i},error:null})];case 5:return s=c.sent(),[2,{data:{},error:new xf(s)}];case 6:return[2]}})})},e.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t;return Zf(this,void 0,void 0,function(){var e,t,n,o,i,s,a,c,u;return ep(this,function(l){switch(l.label){case 0:return Ff.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone"},provider_id:e.appId},[4,wx.login()]):[2,{data:{},error:new xf({message:"wx api undefined"})}];case 1:n=l.sent().code,t.provider_code=n,l.label=2;case 2:return l.trys.push([2,6,,7]),[4,this.oauthInstance.authApi.grantProviderToken(t)];case 3:if((o=l.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.patchProviderToken({provider_token:o.provider_token,provider_id:e.appId,provider_params:{code:r,provider_code_type:"phone"}})];case 4:if((o=l.sent()).error_code)throw o;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:o.provider_token})];case 5:if(null==(i=l.sent())?void 0:i.error_code)throw i;return[3,7];case 6:return s=l.sent(),[2,{data:{},error:new xf(s)}];case 7:return[4,this.createLoginState()];case 8:return a=l.sent(),[4,this.getSession()];case 9:return c=l.sent().data,u=(void 0===c?{}:c).session,[2,Jf(Jf({},a),{data:{user:u.user,session:u},error:null})]}})})},e.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},e.prototype.notifyListeners=function(e,t,r){this.listeners.forEach(function(n){n.forEach(function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}})})},e.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(ah,function(e){return Zf(t,void 0,void 0,function(){var t,r,n,o,i;return ep(this,function(s){switch(s.label){case 0:return t=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.event,r=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}})})})},e.prototype.convertToUser=function(e){var t,r,n,o,i;if(!e)return null;var s=(null==e?void 0:e.email)||"",a=(null==e?void 0:e.phone_number)||"",c=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:c,aud:"authenticated",role:null===(r=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===r?void 0:r.call(t,function(e){return"string"==typeof e?e:e.id}),email:s||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:a,phone_confirmed_at:a?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(n=e.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(o=e.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:e.hasPassword},identities:(null===(i=null==e?void 0:e.providers)||void 0===i?void 0:i.map(function(t){return{id:t.id||"",identity_id:t.id||"",user_id:c,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}}))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},e.prototype.validateParams=function(e,t){for(var r=0,n=Object.entries(t);r<n.length;r++){var o=n[r],i=o[0],s=o[1];if(s.required&&(void 0===(null==e?void 0:e[i])||null===(null==e?void 0:e[i])||""===(null==e?void 0:e[i])))throw new xf({message:s.message})}},e.prototype.validateAtLeastOne=function(e,t,r){if(!t.some(function(t){return t.some(function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])})}))throw new xf({message:r})},e.prototype.init=function(){var e;return Zf(this,void 0,void 0,function(){return ep(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&(null===(e=this.config.eventBus)||void 0===e||e.fire(ah,{event:th})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}})})},$f([cf({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"bindPhoneNumber",null),$f([cf({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"unbindProvider",null),$f([cf({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",void 0)],e.prototype,"bindEmail",null),$f([cf({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"verify",null),$f([cf({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object,Object]),Xf("design:returntype",Promise)],e.prototype,"getVerification",null),$f([cf({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Promise)],e.prototype,"getCurrentUser",null),$f([cf({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"signInAnonymouslyInWx",null),$f([cf({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Promise)],e.prototype,"bindOpenId",null),$f([cf({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Promise)],e.prototype,"signInWithUnionId",null),$f([cf({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"signInWithSms",null),$f([cf({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"signInWithEmail",null),$f([cf({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[String]),Xf("design:returntype",Promise)],e.prototype,"isUsernameRegistered",null),$f([cf({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Promise)],e.prototype,"getLoginState",null),$f([cf({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Promise)],e.prototype,"getUserInfo",null),$f([cf({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Promise)],e.prototype,"getWedaUserInfo",null),$f([cf({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Promise)],e.prototype,"bindWithProvider",null),$f([cf({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Eh)]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Promise)],e.prototype,"getProviderSubType",null),e}();function ap(e,t){var r=this,n=e.region,o=void 0===n?"ap-shanghai":n,i=e.i18n,s=e.accessKey,a=e.useWxCloud,c=(null==t?void 0:t.platform)||zh.bind(t)(),u=c.runtime,l=c.adapter,d=t||{},h=d.env,f=d.clientId,p=d.debug,v=d.cache,y=d.app,g=(t||{}).apiOrigin;g||(g="https://".concat(h,".").concat(o,".tcb-api.tencentcloudapi.com"));var m={env:h,clientId:f,i18n:i,accessKey:s,useWxCloud:a,eventBus:new ef},b=new Wf(Qf(Jf(Jf({},m),{apiOrigin:g,apiPath:(null==e?void 0:e.apiPath)||Vd,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:l,onCredentialsError:np(m.eventBus),headers:Jf({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:p}))),_=new sp(Jf(Jf({},m),{region:o,persistence:e.persistence,debug:p,cache:v||new Qh({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(h)},platformInfo:c}),runtime:u||"web",_fromApp:y,oauthInstance:b}));return b.initializeSession(function(e,t){return Zf(r,void 0,void 0,function(){return ep(this,function(r){return e?(e.type===ch?t?m.eventBus.fire(ah,{event:eh,info:Jf(Jf({},e),{error:t})}):e.user&&_.createLoginState({},{userInfo:e.user}):e.type===uh&&m.eventBus.fire(ah,{event:ih,info:Jf(Jf({},e),{error:t})}),[2]):[2]})})}),{authInstance:_,oauthInstance:b}}var cp="auth",up={name:"auth",namespace:cp,entity:function(e){var t=function(e){var t;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:Vd};var r=this.platform.adapter,n=e.persistence||r.primaryStorage;n&&n!==this.config.persistence&&this.updateConfig({persistence:n});var o=ap(Jf(Jf({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(this.config.endPointMode||"CLOUD_API"),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),i=o.authInstance,s=o.oauthInstance;return this.oauthInstance=s,this.authInstance=i,this.authInstance},r=t.call(this,e);return Object.assign(t,r),Object.setPrototypeOf(t,Object.getPrototypeOf(r)),this[cp]=t,t}};try{cloudbase.registerComponent(up)}catch(lf){}var lp=new Map;function dp(e,t){if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var r=e.callFunction.bind(e);return e.auth=function(e,t){var r,n,o;if(null==e?void 0:e.auth)return console.log("[Auth]: use cloud.auth"),e.auth;if(!(null==t?void 0:t.envId))return console.log("[Auth Error]: envId is required"),null;var i=lp.get(t.envId);if(i)return i;try{var s=(null===(r=null==t?void 0:t.adapter)||void 0===r?void 0:r.genAdapter)?t.adapter.genAdapter():null===(o=null===(n=[Ff].find(function(e){return e.isMatch()}))||void 0===n?void 0:n.genAdapter)||void 0===o?void 0:o.call(n,{}),a=ap({wxCloud:e,useWxCloud:!0},{clientId:null==t?void 0:t.envId,env:null==t?void 0:t.envId,platform:{runtime:"wx-client",adapter:s},apiOrigin:""}).authInstance;return lp.set(t.envId,a),{signInWithOpenId:a.signInWithOpenId.bind(a),updateUser:a.updateUser.bind(a),getUser:a.getUser.bind(a),getSession:a.getSession.bind(a),refreshSession:a.refreshSession.bind(a),signOut:a.signOut.bind(a)}}catch(e){return console.log("[Auth Error]:",e),null}}(e,n(n({},t),{envId:fp(e,null==t?void 0:t.envId)})),e.models=S(r,e),e.mysql=hp(e,{envId:null==t?void 0:t.envId}),e.rdb=hp(e,{envId:null==t?void 0:t.envId}),e}function hp(e,t){var r=null==t?void 0:t.envId,s=(null==t?void 0:t.mysqlBaseUrl)||pp(e,null==t?void 0:t.envId).mysql,a=null==t?void 0:t.fetch;return function(t){var c=this;return new Fd(s,{fetch:a||function(s,a){return o(c,0,void 0,function(){var o,c,l,d;return i(this,function(i){switch(i.label){case 0:return o=(null==t?void 0:t.instance)||"default",c=(null==t?void 0:t.database)||r,l={},(null==a?void 0:a.headers)instanceof Headers?a.headers.forEach(function(e,t){l[t]=e}):l=(null==a?void 0:a.headers)||{},[4,u(e)];case 1:return d=i.sent(),[2,e.callFunction({name:"httpOverCallFunction",data:{url:s.toString(),method:(null==a?void 0:a.method)||"GET",headers:n(n(n({},d?{Authorization:"Bearer ".concat(d)}:{}),l||{}),{"Content-Type":"application/json","X-Db-Instance":o,"Accept-Profile":c,"Content-Profile":c}),body:null==a?void 0:a.body}}).then(function(e){var t=null==e?void 0:e.result;return{ok:(null==t?void 0:t.statusCode)>=200&&(null==t?void 0:t.statusCode)<300,status:(null==t?void 0:t.statusCode)||200,statusText:(null==t?void 0:t.statusMessage)||"OK",json:function(){return Promise.resolve((null==t?void 0:t.body)||{})},text:function(){return Promise.resolve("string"==typeof(null==t?void 0:t.body)?t.body:JSON.stringify((null==t?void 0:t.body)||{}))},headers:new Headers((null==t?void 0:t.headers)||{})}})]}})})}})}}function fp(e,t){var r,n,o,i,s=t||(null===(n=null===(r=null==e?void 0:e.extend)||void 0===r?void 0:r.AI)||void 0===n?void 0:n.env);return"string"==typeof s&&s.trim()||(s=null===(o=null==e?void 0:e.config)||void 0===o?void 0:o.env),"string"==typeof s&&s.trim()||(s=null===(i=null==e?void 0:e.config)||void 0===i?void 0:i.envName),"string"==typeof s&&s.trim()?s.trim():""}function pp(e,t){var r=fp(e,t);if(!r)throw new Error("Generating default gateway base url failed: env not found");return{model:"https://".concat(r,".api.tcloudbasegateway.com/v1/model"),sql:"https://".concat(r,".api.tcloudbasegateway.com/v1/sql"),mysql:"https://".concat(r,".api.tcloudbasegateway.com/v1/rdb/rest")}}var vp={init:dp,generateHTTPClient:m,generateMySQLClient:hp};var yp=Object.freeze({__proto__:null,getEncryptInfo:function(){let{publicKey:e="",payload:t={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e)return"";try{const r=hh(t),n=new(void 0);n.setPublicKey(e);return n.encryptLong("object"==typeof r?JSON.stringify(r):r)}catch(e){console.error("encrypt error:",e)}return""}});e.default=vp,e.generateHTTPClient=m,e.generateMySQLClient=hp,e.getAccessToken=u,e.init=dp,e.initHTTPOverCallFunction=function(e,t){var r=this;if(!e)throw new Error("cloud is required");if(!e.callFunction)throw new Error("cloud.callFunction is required");var s,a=e.callFunction.bind(e);try{var c=(null==t?void 0:t.baseUrl)||pp(e,null==t?void 0:t.envId).model,l=(null==t?void 0:t.sqlBaseUrl)||pp(e,null==t?void 0:t.envId).sql;s=m(a,function(t){var s=t.url,c=t.body,l=t.method,d=t.headers;return o(r,0,void 0,function(){var t,r,o;return i(this,function(i){switch(i.label){case 0:return[4,u(e)];case 1:return t=i.sent(),[4,a({name:"httpOverCallFunction",data:{url:s,method:null==l?void 0:l.toUpperCase(),headers:n(n(n({},t?{Authorization:"Bearer ".concat(t)}:{}),d||{}),{"Content-Type":"application/json"}),body:c}})];case 2:return r=i.sent(),[2,null===(o=null==r?void 0:r.result)||void 0===o?void 0:o.body]}})})},c,{sqlBaseUrl:l,cloud:e})}catch(e){console.error("init http orm client failed, try call function orm",e),s=S(a)}return e.models=s,e.mysql=hp(e,{envId:null==t?void 0:t.envId,mysqlBaseUrl:null==t?void 0:t.mysqlBaseUrl}),e},Object.defineProperty(e,"__esModule",{value:!0})});
|