@shumai-one/shumai 0.5.1 → 0.5.3

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.
Files changed (164) hide show
  1. package/bin/chunk-03zkxckm.js +2 -0
  2. package/bin/chunk-04nqnkzs.js +4 -0
  3. package/bin/chunk-157axqz1.js +1 -0
  4. package/bin/{chunk-zp5b1mb6.js → chunk-1tesbv8w.js} +2 -2
  5. package/bin/chunk-23780yj6.js +3 -0
  6. package/bin/{chunk-mt532a33.js → chunk-24da4wg9.js} +1 -1
  7. package/bin/chunk-24nx3krz.js +2 -0
  8. package/bin/{chunk-5t05jpna.js → chunk-26am2rzm.js} +1 -1
  9. package/bin/{chunk-vre5andt.js → chunk-2pt9h882.js} +3 -3
  10. package/bin/{chunk-xyh5dkr5.js → chunk-2rrcdhkj.js} +1 -1
  11. package/bin/{chunk-6v6c2921.js → chunk-2w2bknn2.js} +4 -4
  12. package/bin/{chunk-f22nrm6r.js → chunk-3ahax79y.js} +4 -4
  13. package/bin/{chunk-1k16xsqq.js → chunk-3wcvema0.js} +6 -6
  14. package/bin/{chunk-20anqpf1.js → chunk-40tmh04g.js} +2 -2
  15. package/bin/chunk-45p7d22e.js +2 -0
  16. package/bin/chunk-461gcgrs.js +2 -0
  17. package/bin/{chunk-2g5qdx4s.js → chunk-4bc3gqmn.js} +2 -2
  18. package/bin/{chunk-m5cpsm28.js → chunk-4nkwe7dz.js} +2 -2
  19. package/bin/{chunk-gptzcgte.js → chunk-59ayg5am.js} +1 -1
  20. package/bin/{chunk-5patxztz.js → chunk-5ebb2pdf.js} +3 -3
  21. package/bin/{chunk-d7mgjqf8.js → chunk-5y3kx4kk.js} +1 -1
  22. package/bin/{chunk-4437dnfa.js → chunk-68xsb3t8.js} +1 -1
  23. package/bin/{chunk-m2dtwvg0.js → chunk-6hs63sva.js} +31 -31
  24. package/bin/{chunk-628k58ek.js → chunk-6hzktewz.js} +2 -2
  25. package/bin/{chunk-0e8xg41c.js → chunk-6pwf7qa6.js} +1 -1
  26. package/bin/{chunk-q5mkbnr9.js → chunk-6sq6dfa1.js} +2 -2
  27. package/bin/chunk-87secbzy.js +1 -0
  28. package/bin/chunk-8pykp70z.js +1 -0
  29. package/bin/{chunk-zhe16jvg.js → chunk-8ts3xkme.js} +1 -1
  30. package/bin/{chunk-ehhsezbj.js → chunk-909h3qzp.js} +2 -2
  31. package/bin/{chunk-j909v9p5.js → chunk-929abwgr.js} +1 -1
  32. package/bin/{chunk-0ttr4a6b.js → chunk-9ca8a5f2.js} +2 -2
  33. package/bin/{chunk-6vvs18bw.js → chunk-9fyb95r5.js} +1 -1
  34. package/bin/{chunk-kzsdp31a.js → chunk-a8bymrv1.js} +2 -2
  35. package/bin/chunk-axeq2pq5.js +2 -0
  36. package/bin/{chunk-z7p7s55t.js → chunk-b3tkvdfk.js} +2 -2
  37. package/bin/{chunk-r1m4q8vw.js → chunk-b5r0be06.js} +2 -2
  38. package/bin/{chunk-z8mmqfm4.js → chunk-b6dbqs39.js} +1 -1
  39. package/bin/{chunk-0yv0nnmh.js → chunk-b88tdt79.js} +2 -2
  40. package/bin/{chunk-grsgkkrb.js → chunk-bcyvxp1c.js} +6 -6
  41. package/bin/{chunk-3cvbb6kh.js → chunk-bn0taqr3.js} +2 -2
  42. package/bin/chunk-cb37q6t0.js +1 -0
  43. package/bin/{chunk-sg7n2g3z.js → chunk-cdk8vqeg.js} +4 -4
  44. package/bin/chunk-cfqny70c.js +3 -0
  45. package/bin/{chunk-3m6ch1x5.js → chunk-cqnected.js} +2 -2
  46. package/bin/{chunk-hr2027z3.js → chunk-cvfznrnt.js} +8 -8
  47. package/bin/chunk-d1q1tn36.js +1 -0
  48. package/bin/chunk-d1rjpbgv.js +2 -0
  49. package/bin/{chunk-asgxtqf0.js → chunk-eshwjf91.js} +2 -2
  50. package/bin/{chunk-1dt700ws.js → chunk-fa9yq17g.js} +49 -49
  51. package/bin/{chunk-rkq6jvhb.js → chunk-fnkkwna8.js} +2 -2
  52. package/bin/{chunk-zfqz72sd.js → chunk-fpjvr3qw.js} +1 -1
  53. package/bin/{chunk-5jbx9gqe.js → chunk-fsr83nb1.js} +1 -1
  54. package/bin/{chunk-80qz30dc.js → chunk-fxg81vtx.js} +2 -2
  55. package/bin/chunk-fznchvm7.js +1 -0
  56. package/bin/chunk-g2z0c39g.js +1 -0
  57. package/bin/chunk-gnt9gewm.js +2 -0
  58. package/bin/{chunk-h9x81yp6.js → chunk-gvcjqcjf.js} +1 -1
  59. package/bin/chunk-hbnpx0a5.js +1 -0
  60. package/bin/chunk-hgy9rqt1.js +1 -0
  61. package/bin/chunk-hk659cg2.css +1 -0
  62. package/bin/{chunk-03bfjh8k.js → chunk-hn2g40r6.js} +2 -2
  63. package/bin/{chunk-exgtwask.js → chunk-hsx4pns6.js} +1 -1
  64. package/bin/{chunk-6ns2vhbd.js → chunk-hy5ncvpf.js} +2 -2
  65. package/bin/{chunk-y03z5rrg.js → chunk-j420aqk8.js} +3 -3
  66. package/bin/{chunk-tcat7q9p.js → chunk-jt6v15wx.js} +2 -2
  67. package/bin/{chunk-ar6kq7hh.js → chunk-k3ds96cb.js} +2 -2
  68. package/bin/{chunk-mqr096rn.js → chunk-k97axrc4.js} +1 -1
  69. package/bin/{chunk-zcrtr8qd.js → chunk-m41tbrvt.js} +2 -2
  70. package/bin/chunk-m9f21ye9.js +1 -0
  71. package/bin/chunk-md7pgk86.js +2 -0
  72. package/bin/chunk-me3zmpj5.js +14 -0
  73. package/bin/chunk-mg6sybt0.js +1 -0
  74. package/bin/{chunk-xyk7vk42.js → chunk-mzme3m82.js} +2 -2
  75. package/bin/chunk-n08h1jgx.js +2 -0
  76. package/bin/{chunk-z1r86fna.js → chunk-ncv8v6mj.js} +2 -2
  77. package/bin/{chunk-h153xefb.js → chunk-nmd1901j.js} +1 -1
  78. package/bin/{chunk-62sj29j8.js → chunk-np39aknv.js} +2 -2
  79. package/bin/{chunk-9h6nn1a3.js → chunk-p7zw53ep.js} +1 -1
  80. package/bin/{chunk-kgfa5y9w.js → chunk-ppb4aj0y.js} +4 -4
  81. package/bin/{chunk-5yd9cv7f.js → chunk-pwq6dbb5.js} +3 -3
  82. package/bin/chunk-q1gfypy3.js +2 -0
  83. package/bin/{chunk-3z20b2hz.js → chunk-q4qqmes7.js} +2 -2
  84. package/bin/{chunk-j3xaq9s3.js → chunk-q7t5zs7n.js} +2 -2
  85. package/bin/{chunk-hx76pje1.js → chunk-qcpeefhr.js} +1 -1
  86. package/bin/{chunk-gy8z8sd7.js → chunk-qjdvs1s5.js} +1 -1
  87. package/bin/{chunk-dvkzhpxx.js → chunk-qqapw198.js} +2 -2
  88. package/bin/chunk-qx553512.js +211 -0
  89. package/bin/chunk-r3s1x5wp.js +1 -0
  90. package/bin/{chunk-zwb9kamp.js → chunk-rh8dy99a.js} +2 -2
  91. package/bin/{chunk-e3r1m6rb.js → chunk-s0vfj06y.js} +1 -1
  92. package/bin/chunk-s6g2mzpn.js +2 -0
  93. package/bin/{chunk-c4wnhekn.js → chunk-s9sf37dv.js} +2 -2
  94. package/bin/{chunk-qgkbxw1k.js → chunk-sbyyn9yw.js} +2 -2
  95. package/bin/{chunk-xvdd04gy.js → chunk-scvepfv8.js} +1 -1
  96. package/bin/chunk-sjbvt3wa.js +2 -0
  97. package/bin/{chunk-31vx01aw.js → chunk-srmx5z3v.js} +2 -2
  98. package/bin/{chunk-36r20sj7.js → chunk-srv5kvm4.js} +1 -1
  99. package/bin/{chunk-7vd5yajk.js → chunk-t1h12r3q.js} +7 -7
  100. package/bin/chunk-t6myw0jf.js +2 -0
  101. package/bin/chunk-t8jfp3vx.js +1 -0
  102. package/bin/{chunk-3584j9fc.js → chunk-tqdde9bj.js} +2 -2
  103. package/bin/{chunk-wydd7sz7.js → chunk-v5hz09a1.js} +2 -2
  104. package/bin/chunk-vk9ecq8n.js +2 -0
  105. package/bin/{chunk-3zvvct3r.js → chunk-vsnq4381.js} +1 -1
  106. package/bin/{chunk-r6gkv98n.js → chunk-w4adkd0a.js} +5 -5
  107. package/bin/{chunk-4mq874m3.js → chunk-wbmqbpgm.js} +2 -2
  108. package/bin/{chunk-kvqp50dm.js → chunk-wperd2h9.js} +2 -2
  109. package/bin/{chunk-wkxm6yny.js → chunk-xbw7ffrz.js} +2 -2
  110. package/bin/{chunk-v42jcex0.js → chunk-xdrpahym.js} +4 -4
  111. package/bin/{chunk-s978ftze.js → chunk-xfmnfcv2.js} +3 -3
  112. package/bin/chunk-xhngtwn9.js +1 -0
  113. package/bin/chunk-xjnehexk.js +2 -0
  114. package/bin/chunk-xzb0t8mx.js +1 -0
  115. package/bin/{chunk-rn9rktp4.js → chunk-y5h5d5gx.js} +4 -4
  116. package/bin/{chunk-rsdpycdr.js → chunk-y6xyc4wp.js} +2 -2
  117. package/bin/{chunk-m1xc3t0p.js → chunk-zpk87b33.js} +6 -6
  118. package/bin/{chunk-trndqdaa.js → chunk-zq5j9wsc.js} +1 -1
  119. package/bin/{chunk-t597y392.js → chunk-zsg61vr0.js} +1 -1
  120. package/bin/chunk-zts21ft7.js +1 -0
  121. package/bin/{chunk-zf2h3w7t.js → chunk-zzbn0b6c.js} +1 -1
  122. package/bin/shumai-app.html +1 -1
  123. package/bin/shumai-app.js +431 -409
  124. package/package.json +7 -7
  125. package/prisma/migrations/20261008134859_add_transcode_3d/migration.sql +2 -0
  126. package/prisma/migrations/20261014054332_add_embedding_768/migration.sql +8 -0
  127. package/prisma/schema.prisma +11 -8
  128. package/bin/chunk-088e1ath.js +0 -3
  129. package/bin/chunk-18kgmvme.js +0 -2
  130. package/bin/chunk-1ya6vx4k.js +0 -1
  131. package/bin/chunk-3xw70yr4.js +0 -2
  132. package/bin/chunk-4frhvsy0.js +0 -1
  133. package/bin/chunk-57nqvcg7.js +0 -1
  134. package/bin/chunk-58hdvwj2.js +0 -1
  135. package/bin/chunk-5seey9ee.js +0 -2
  136. package/bin/chunk-66hdwm6f.js +0 -2
  137. package/bin/chunk-6devq6jh.js +0 -2
  138. package/bin/chunk-756mr32b.js +0 -2
  139. package/bin/chunk-9k86d2a3.js +0 -4
  140. package/bin/chunk-a5fsqkt7.js +0 -1
  141. package/bin/chunk-axfwh5et.js +0 -2
  142. package/bin/chunk-c0vbj8za.js +0 -1
  143. package/bin/chunk-dcmfn4hs.js +0 -2
  144. package/bin/chunk-dy79b8kd.js +0 -1
  145. package/bin/chunk-ehvyq65t.js +0 -2
  146. package/bin/chunk-g21k2awz.js +0 -2
  147. package/bin/chunk-g9f9nzcc.js +0 -1
  148. package/bin/chunk-gzzfta3s.js +0 -2
  149. package/bin/chunk-k9cgfzgk.js +0 -3
  150. package/bin/chunk-nbfcknsq.js +0 -1
  151. package/bin/chunk-phzemmmy.js +0 -2
  152. package/bin/chunk-qcf3tb72.js +0 -1
  153. package/bin/chunk-rgfh5apb.js +0 -1
  154. package/bin/chunk-rh1hs8wa.js +0 -2
  155. package/bin/chunk-rpxayeqd.js +0 -1
  156. package/bin/chunk-s33pcxn0.js +0 -1
  157. package/bin/chunk-s9svhjv6.js +0 -2
  158. package/bin/chunk-tcp4q15p.js +0 -1
  159. package/bin/chunk-vnk2p7mq.css +0 -1
  160. package/bin/chunk-vsefjzzj.js +0 -211
  161. package/bin/chunk-wf32n1s3.js +0 -1
  162. package/bin/chunk-yd1k76na.js +0 -2
  163. package/bin/chunk-yfm9xwes.js +0 -14
  164. package/bin/chunk-zkep4r7d.js +0 -1
@@ -1,10 +1,10 @@
1
1
  // @bun
2
- import{H,w,G}from"./chunk-kzsdp31a.js";var es=w(function(Xp,Zn){function Ee(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Zn.exports=Ee;Ee.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Ee.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);if(this._timer)clearTimeout(this._timer);this._timeouts=[],this._cachedTimeouts=null};Ee.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;if(this._timer=setTimeout(function(){if(n._attempts++,n._operationTimeoutCb){if(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref)n._timeout.unref()}n._fn(n._attempts)},r),this._options.unref)this._timer.unref();return!0};Ee.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var r=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};Ee.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Ee.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Ee.prototype.start=Ee.prototype.try;Ee.prototype.errors=function(){return this._errors};Ee.prototype.attempts=function(){return this._attempts};Ee.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,r=0;for(var n=0;n<this._errors.length;n++){var s=this._errors[n],i=s.message,u=(e[i]||0)+1;if(e[i]=u,u>=r)t=s,r=u}return t}});var rs=w(function(mr){var lu=es();mr.operation=function(e){var t=mr.timeouts(e);return new lu(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};mr.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var n=[];for(var s=0;s<t.retries;s++)n.push(this.createTimeout(s,t));if(e&&e.forever&&!n.length)n.push(this.createTimeout(s,t));return n.sort(function(i,u){return i-u}),n};mr.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};mr.wrap=function(e,t,r){if(t instanceof Array)r=t,t=null;if(!r){r=[];for(var n in e)if(typeof e[n]==="function")r.push(n)}for(var s=0;s<r.length;s++){var i=r[s],u=e[i];e[i]=function(y){var S=mr.operation(t),A=Array.prototype.slice.call(arguments,1),k=A.pop();A.push(function(N){if(S.retry(N))return;if(N)arguments[0]=S.mainError();k.apply(this,arguments)}),S.attempt(function(){y.apply(e,A)})}.bind(e,u),e[i].options=t}}});var Eu=w(function(Zp,Pt){var pu=rs(),gu=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class Er extends Error{constructor(e){super();if(e instanceof Error)this.originalError=e,{message:e}=e;else this.originalError=Error(e),this.originalError.stack=this.stack;this.name="AbortError",this.message=e}}var _u=(e,t,r)=>{let n=r.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=n,e},yu=(e)=>gu.includes(e),ns=(e,t)=>new Promise((r,n)=>{t={onFailedAttempt:()=>{},retries:10,...t};let s=pu.operation(t);s.attempt(async(i)=>{try{r(await e(i))}catch(u){if(!(u instanceof Error)){n(TypeError(`Non-error was thrown: "${u}". You should only throw errors.`));return}if(u instanceof Er)s.stop(),n(u.originalError);else if(u instanceof TypeError&&!yu(u.message))s.stop(),n(u);else{_u(u,i,t);try{await t.onFailedAttempt(u)}catch(h){n(h);return}if(!s.retry(u))n(s.mainError())}}})});Pt.exports=ns;Pt.exports.default=ns;Pt.exports.AbortError=Er});var wr=w(function(eg,hs){var It=Object.prototype.hasOwnProperty,ls=Object.prototype.toString,{defineProperty:ss,getOwnPropertyDescriptor:is}=Object,os=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return ls.call(t)==="[object Array]"},as=function(t){if(!t||ls.call(t)!=="[object Object]")return!1;var r=It.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&It.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!n)return!1;var s;for(s in t);return typeof s>"u"||It.call(t,s)},cs=function(t,r){if(ss&&r.name==="__proto__")ss(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},us=function(t,r){if(r==="__proto__"){if(!It.call(t,r))return;else if(is)return is(t,r).value}return t[r]};hs.exports=function e(){var t,r,n,s,i,u,h=arguments[0],y=1,S=arguments.length,A=!1;if(typeof h==="boolean")A=h,h=arguments[1]||{},y=2;if(h==null||typeof h!=="object"&&typeof h!=="function")h={};for(;y<S;++y)if(t=arguments[y],t!=null){for(r in t)if(n=us(h,r),s=us(t,r),h!==s){if(A&&s&&(as(s)||(i=os(s)))){if(i)i=!1,u=n&&os(n)?n:[];else u=n&&as(n)?n:{};cs(h,{name:r,newValue:e(A,u,s)})}else if(typeof s<"u")cs(h,{name:r,newValue:s})}}return h}});var fs=w(function(tg,mu){mu.exports={name:"gaxios",version:"7.3.1",description:"A simple common HTTP client specifically for Google APIs and services.",main:"build/cjs/src/index.js",types:"build/cjs/src/index.d.ts",files:["build/"],exports:{".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},scripts:{lint:"gts check --no-inline-config",test:"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000",compile:"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs",fix:"gts fix",prepare:"npm run compile",pretest:"npm run compile",webpack:"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js",docs:"jsdoc -c .jsdoc.js","samples-test":"cd samples/ && npm link ../ && npm test && cd ../",prelint:"cd samples; npm link ../; npm install",clean:"gts clean"},repository:{type:"git",directory:"core/packages/gaxios",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google"],engines:{node:">=18"},author:"Google, LLC",license:"Apache-2.0",devDependencies:{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","@types/tmp":"^0.2.6",assert:"^2.0.0",browserify:"^17.0.0",c8:"^10.1.3",cors:"^2.8.5",express:"^5.0.0",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.0",mocha:"^11.1.0",multiparty:"^4.2.1",mv:"^2.1.1",ncp:"^2.0.0",nock:"14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0",puppeteer:"^24.0.0",sinon:"21.0.3","stream-browserify":"^3.0.0",tmp:"0.2.7","ts-loader":"^9.5.2",typescript:"5.8.3","undici-types":"^7.24.1",webpack:"^5.97.1","webpack-cli":"^6.0.1"},dependencies:{extend:"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/gaxios"}});var ps=w(function(rg,ds){var wu=fs();ds.exports={pkg:wu}});var vr=w(function(we){var _s=we&&we.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(we,"__esModule",{value:!0});we.GaxiosError=we.GAXIOS_ERROR_SYMBOL=void 0;we.defaultErrorRedactor=ys;var gs=_s(wr()),Tu=_s(ps()),Tr=Tu.default.pkg;we.GAXIOS_ERROR_SYMBOL=Symbol.for(`${Tr.name}-gaxios-error`);class Ar extends Error{config;response;code;status;error;[we.GAXIOS_ERROR_SYMBOL]=Tr.version;static[Symbol.hasInstance](e){if(e&&typeof e==="object"&&we.GAXIOS_ERROR_SYMBOL in e&&e[we.GAXIOS_ERROR_SYMBOL]===Tr.version)return!0;return Function.prototype[Symbol.hasInstance].call(Ar,e)}constructor(e,t,r,n){super(e,{cause:n});if(this.config=t,this.response=r,this.error=n instanceof Error?n:void 0,this.config=(0,gs.default)(!0,{},t),this.response)this.response.config=(0,gs.default)(!0,{},this.response.config);if(this.response){try{this.response.data=Au(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}if(n instanceof DOMException)this.code=n.name;else if(n&&typeof n==="object"&&"code"in n&&(typeof n.code==="string"||typeof n.code==="number"))this.code=n.code}static extractAPIErrorFromResponse(e,t="The request failed"){let r=t;if(typeof e.data==="string")r=e.data;if(e.data&&typeof e.data==="object"&&"error"in e.data&&e.data.error&&!e.ok){if(typeof e.data.error==="string")return{message:e.data.error,code:e.status,status:e.statusText};if(typeof e.data.error==="object"){r="message"in e.data.error&&typeof e.data.error.message==="string"?e.data.error.message:r;let n="status"in e.data.error&&typeof e.data.error.status==="string"?e.data.error.status:e.statusText,s="code"in e.data.error&&typeof e.data.error.code==="number"?e.data.error.code:e.status;if("errors"in e.data.error&&Array.isArray(e.data.error.errors)){let i=[];for(let u of e.data.error.errors)if(typeof u==="object"&&"message"in u&&typeof u.message==="string")i.push(u.message);return Object.assign({message:i.join(`
3
- `)||r,code:s,status:n},e.data.error)}return Object.assign({message:r,code:s,status:n},e.data.error)}}return{message:r,code:e.status,status:e.statusText}}}we.GaxiosError=Ar;function Au(e,t){switch(e){case"stream":return t;case"json":return JSON.parse(JSON.stringify(t));case"arraybuffer":return JSON.parse(Buffer.from(t).toString("utf8"));case"blob":return JSON.parse(t.text());default:return t}}function ys(e){function r(i){if(!i)return;i.forEach((u,h)=>{if(/^authentication$/i.test(h)||/^authorization$/i.test(h)||/secret/i.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")})}function n(i,u){if(typeof i==="object"&&i!==null&&typeof i[u]==="string"){let h=i[u];if(/grant_type=/i.test(h)||/assertion=/i.test(h)||/secret/i.test(h))i[u]="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}function s(i){if(!i||typeof i!=="object")return;else if(i instanceof FormData||i instanceof URLSearchParams||"forEach"in i&&"set"in i)i.forEach((u,h)=>{if(["grant_type","assertion"].includes(h)||/secret/.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")});else{if("grant_type"in i)i.grant_type="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("assertion"in i)i.assertion="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("client_secret"in i)i.client_secret="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}if(e.config){if(r(e.config.headers),n(e.config,"data"),s(e.config.data),n(e.config,"body"),s(e.config.body),e.config.url.searchParams.has("token"))e.config.url.searchParams.set("token","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.");if(e.config.url.searchParams.has("client_secret"))e.config.url.searchParams.set("client_secret","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")}if(e.response){if(ys({config:e.response.config}),r(e.response.headers),e.response.bodyUsed)n(e.response,"data"),s(e.response.data)}return e}});var ws=w(function(Es){Object.defineProperty(Es,"__esModule",{value:!0});Es.getRetryConfig=vu;async function vu(e){let t=ms(e);if(!e||!e.config||!t&&!e.config.retry)return{shouldRetry:!1};t=t||{},t.currentRetryAttempt=t.currentRetryAttempt||0,t.retry=t.retry===void 0||t.retry===null?3:t.retry,t.httpMethodsToRetry=t.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],t.noResponseRetries=t.noResponseRetries===void 0||t.noResponseRetries===null?2:t.noResponseRetries,t.retryDelayMultiplier=t.retryDelayMultiplier?t.retryDelayMultiplier:2,t.timeOfFirstRequest=t.timeOfFirstRequest?t.timeOfFirstRequest:Date.now(),t.totalTimeout=t.totalTimeout?t.totalTimeout:Number.MAX_SAFE_INTEGER,t.maxRetryDelay=t.maxRetryDelay?t.maxRetryDelay:Number.MAX_SAFE_INTEGER;let r=[[100,199],[408,408],[429,429],[500,599]];if(t.statusCodesToRetry=t.statusCodesToRetry||r,e.config.retryConfig=t,!await(t.shouldRetry||Su)(e))return{shouldRetry:!1,config:e.config};let s=Cu(t);e.config.retryConfig.currentRetryAttempt+=1;let i=t.retryBackoff?t.retryBackoff(e,s):new Promise((u)=>{setTimeout(u,s)});if(t.onRetryAttempt)await t.onRetryAttempt(e);return await i,{shouldRetry:!0,config:e.config}}function Su(e){let t=ms(e);if(e.config.signal?.aborted&&e.code!=="TimeoutError"||e.code==="AbortError")return!1;if(!t||t.retry===0)return!1;if(!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries)return!1;if(!t.httpMethodsToRetry||!t.httpMethodsToRetry.includes(e.config.method?.toUpperCase()||"GET"))return!1;if(e.response&&e.response.status){let r=!1;for(let[n,s]of t.statusCodesToRetry){let i=e.response.status;if(i>=n&&i<=s){r=!0;break}}if(!r)return!1}if(t.currentRetryAttempt=t.currentRetryAttempt||0,t.currentRetryAttempt>=t.retry)return!1;return!0}function ms(e){if(e&&e.config&&e.config.retryConfig)return e.config.retryConfig;return}function Cu(e){let r=(e.currentRetryAttempt?0:e.retryDelay??100)+(Math.pow(e.retryDelayMultiplier,e.currentRetryAttempt)-1)/2*1000,n=e.totalTimeout-(Date.now()-e.timeOfFirstRequest);return Math.min(r,n,e.maxRetryDelay)}});var Sr=w(function(As){Object.defineProperty(As,"__esModule",{value:!0});As.GaxiosInterceptorManager=void 0;class Ts extends Set{}As.GaxiosInterceptorManager=Ts});var Os=w(function(et){var ku=et&&et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Ze;Object.defineProperty(et,"__esModule",{value:!0});et.Gaxios=void 0;var bu=ku(wr()),xu=G("https"),We=vr(),Ru=ws(),Ss=G("stream"),Cs=Sr(),Nu=async()=>globalThis.crypto?.randomUUID()||(await import("crypto")).randomUUID(),Pu=204;class Cr{agentCache=new Map;defaults;interceptors;constructor(e){this.defaults=e||{},this.interceptors={request:new Cs.GaxiosInterceptorManager,response:new Cs.GaxiosInterceptorManager}}fetch(...e){let t=e[0],r=e[1],n=void 0,s=new Headers;if(typeof t==="string")n=new URL(t);else if(t instanceof URL)n=t;else if(t&&t.url)n=new URL(t.url);if(t&&typeof t==="object"&&"headers"in t)Ze.mergeHeaders(s,t.headers);if(r)Ze.mergeHeaders(s,new Headers(r.headers));if(typeof t==="object"&&!(t instanceof URL))return this.request({...r,...t,headers:s,url:n});else return this.request({...r,headers:s,url:n})}async request(e={}){let t=await this.#n(e);return t=await this.#t(t),this.#r(this._request(t))}async _defaultAdapter(e){let t=e.fetchImplementation||this.defaults.fetchImplementation||await Ze.#c(),r={...e};delete r.data;let n=await t(e.url,r),s=await this.getResponseData(e,n);if(!Object.getOwnPropertyDescriptor(n,"data")?.configurable)Object.defineProperties(n,{data:{configurable:!0,writable:!0,enumerable:!0,value:s}});return Object.assign(n,{config:e,data:s})}async _request(e){try{let t;if(e.adapter)t=await e.adapter(e,this._defaultAdapter.bind(this));else t=await this._defaultAdapter(e);if(!e.validateStatus(t.status)){if(e.responseType==="stream"){let n=[];for await(let s of t.data)n.push(s);t.data=Buffer.concat(n.map((s)=>typeof s==="string"?Buffer.from(s):s)).toString("utf8")}let r=We.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new We.GaxiosError(r?.message,e,t,r)}return t}catch(t){let r;if(t instanceof We.GaxiosError)r=t;else if(t instanceof Error)r=new We.GaxiosError(t.message,e,void 0,t);else r=new We.GaxiosError("Unexpected Gaxios Error",e,void 0,t);let{shouldRetry:n,config:s}=await Ru.getRetryConfig(r);if(n&&s)return r.config.retryConfig.currentRetryAttempt=s.retryConfig.currentRetryAttempt,e.retryConfig=r.config?.retryConfig,this.#s(e),this._request(e);if(e.errorRedactor)e.errorRedactor(r);throw r}}async getResponseData(e,t){if(t.status===Pu)return"";if(e.maxContentLength&&t.headers.has("content-length")&&e.maxContentLength<Number.parseInt(t.headers?.get("content-length")||""))throw new We.GaxiosError("Response's `Content-Length` is over the limit.",e,Object.assign(t,{config:e}));switch(e.responseType){case"stream":return t.body;case"json":{let r=await t.text();try{return JSON.parse(r)}catch{return r}}case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"text":return t.text();default:return this.getResponseDataFromContentType(t)}}#e(e,t=[]){let r=new URL(e),n=[...t],s=(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[];for(let i of s)n.push(i.trim());for(let i of n)if(i instanceof RegExp){if(i.test(r.toString()))return!1}else if(i instanceof URL){if(i.origin===r.origin)return!1}else if(i.startsWith("*.")||i.startsWith(".")){let u=i.replace(/^\*\./,".");if(r.hostname.endsWith(u))return!1}else if(i===r.origin||i===r.hostname||i===r.href)return!1;return!0}async#t(e){let t=Promise.resolve(e);for(let r of this.interceptors.request.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#r(e){let t=Promise.resolve(e);for(let r of this.interceptors.response.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#n(e){let t=new Headers(this.defaults.headers);Ze.mergeHeaders(t,e.headers);let r=(0,bu.default)(!0,{},this.defaults,e);if(!r.url)throw Error("URL is required.");if(r.baseURL)r.url=new URL(r.url,r.baseURL);if(r.url=new URL(r.url),r.params)if(r.paramsSerializer){let i=r.paramsSerializer(r.params);if(i.startsWith("?"))i=i.slice(1);let u=r.url.toString().includes("?")?"&":"?";r.url=r.url+u+i}else{let i=r.url instanceof URL?r.url:new URL(r.url);for(let[u,h]of new URLSearchParams(r.params))i.searchParams.append(u,h);r.url=i}if(typeof e.maxContentLength==="number")r.size=e.maxContentLength;if(typeof e.maxRedirects==="number")r.follow=e.maxRedirects;let n=typeof r.data==="string"||r.data instanceof ArrayBuffer||r.data instanceof Blob||globalThis.File&&r.data instanceof File||r.data instanceof FormData||r.data instanceof Ss.Readable||r.data instanceof ReadableStream||r.data instanceof String||r.data instanceof URLSearchParams||ArrayBuffer.isView(r.data)||["Blob","File","FormData"].includes(r.data?.constructor?.name||"");if(r.multipart?.length){let i=await Nu();t.set("content-type",`multipart/related; boundary=${i}`),r.body=Ss.Readable.from(this.getMultipartRequest(r.multipart,i))}else if(n)r.body=r.data;else if(typeof r.data==="object")if(t.get("Content-Type")==="application/x-www-form-urlencoded")r.body=r.paramsSerializer?r.paramsSerializer(r.data):new URLSearchParams(r.data);else{if(!t.has("content-type"))t.set("content-type","application/json");r.body=JSON.stringify(r.data)}else if(r.data)r.body=r.data;if(r.validateStatus=r.validateStatus||this.validateStatus,r.responseType=r.responseType||"unknown",!t.has("accept")&&r.responseType==="json")t.set("accept","application/json");let s=r.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(r.agent);else if(s&&this.#e(r.url,r.noProxy)){let i=await Ze.#a();if(this.agentCache.has(s))r.agent=this.agentCache.get(s);else r.agent=new i(s,{cert:r.cert,key:r.key}),this.agentCache.set(s,r.agent)}else if(r.cert&&r.key)if(this.agentCache.has(r.key))r.agent=this.agentCache.get(r.key);else r.agent=new xu.Agent({cert:r.cert,key:r.key}),this.agentCache.set(r.key,r.agent);if(typeof r.errorRedactor!=="function"&&r.errorRedactor!==!1)r.errorRedactor=We.defaultErrorRedactor;if(r.body&&!("duplex"in r))r.duplex="half";return this.#s(r),Object.assign(r,{headers:t,url:r.url instanceof URL?r.url:new URL(r.url)})}#s(e){if(e.timeout){let t=AbortSignal.timeout(e.timeout);if(e.signal&&!e.signal.aborted)e.signal=AbortSignal.any([e.signal,t]);else e.signal=t}}validateStatus(e){return e>=200&&e<300}async getResponseDataFromContentType(e){let t=e.headers.get("Content-Type");if(t===null)return e.text();if(t=t.toLowerCase(),t.includes("application/json")){let r=await e.text();try{r=JSON.parse(r)}catch{}return r}else if(t.match(/^text\//))return e.text();else return e.blob()}async*getMultipartRequest(e,t){let r=`--${t}--`;for(let n of e){let s=n.headers.get("Content-Type")||"application/octet-stream";if(yield`--${t}\r
2
+ import{H,w,G}from"./chunk-a8bymrv1.js";var es=w(function(Xp,Zn){function Ee(e,t){if(typeof t==="boolean")t={forever:t};if(this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever)this._cachedTimeouts=this._timeouts.slice(0)}Zn.exports=Ee;Ee.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Ee.prototype.stop=function(){if(this._timeout)clearTimeout(this._timeout);if(this._timer)clearTimeout(this._timer);this._timeouts=[],this._cachedTimeouts=null};Ee.prototype.retry=function(e){if(this._timeout)clearTimeout(this._timeout);if(!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;if(this._timer=setTimeout(function(){if(n._attempts++,n._operationTimeoutCb){if(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref)n._timeout.unref()}n._fn(n._attempts)},r),this._options.unref)this._timer.unref();return!0};Ee.prototype.attempt=function(e,t){if(this._fn=e,t){if(t.timeout)this._operationTimeout=t.timeout;if(t.cb)this._operationTimeoutCb=t.cb}var r=this;if(this._operationTimeoutCb)this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout);this._operationStart=new Date().getTime(),this._fn(this._attempts)};Ee.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Ee.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Ee.prototype.start=Ee.prototype.try;Ee.prototype.errors=function(){return this._errors};Ee.prototype.attempts=function(){return this._attempts};Ee.prototype.mainError=function(){if(this._errors.length===0)return null;var e={},t=null,r=0;for(var n=0;n<this._errors.length;n++){var s=this._errors[n],i=s.message,u=(e[i]||0)+1;if(e[i]=u,u>=r)t=s,r=u}return t}});var rs=w(function(mr){var lu=es();mr.operation=function(e){var t=mr.timeouts(e);return new lu(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};mr.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1000,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw Error("minTimeout is greater than maxTimeout");var n=[];for(var s=0;s<t.retries;s++)n.push(this.createTimeout(s,t));if(e&&e.forever&&!n.length)n.push(this.createTimeout(s,t));return n.sort(function(i,u){return i-u}),n};mr.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,n=Math.round(r*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return n=Math.min(n,t.maxTimeout),n};mr.wrap=function(e,t,r){if(t instanceof Array)r=t,t=null;if(!r){r=[];for(var n in e)if(typeof e[n]==="function")r.push(n)}for(var s=0;s<r.length;s++){var i=r[s],u=e[i];e[i]=function(y){var S=mr.operation(t),A=Array.prototype.slice.call(arguments,1),k=A.pop();A.push(function(N){if(S.retry(N))return;if(N)arguments[0]=S.mainError();k.apply(this,arguments)}),S.attempt(function(){y.apply(e,A)})}.bind(e,u),e[i].options=t}}});var Cu=w(function(Zp,Pt){var pu=rs(),gu=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class Er extends Error{constructor(e){super();if(e instanceof Error)this.originalError=e,{message:e}=e;else this.originalError=Error(e),this.originalError.stack=this.stack;this.name="AbortError",this.message=e}}var _u=(e,t,r)=>{let n=r.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=n,e},yu=(e)=>gu.includes(e),ns=(e,t)=>new Promise((r,n)=>{t={onFailedAttempt:()=>{},retries:10,...t};let s=pu.operation(t);s.attempt(async(i)=>{try{r(await e(i))}catch(u){if(!(u instanceof Error)){n(TypeError(`Non-error was thrown: "${u}". You should only throw errors.`));return}if(u instanceof Er)s.stop(),n(u.originalError);else if(u instanceof TypeError&&!yu(u.message))s.stop(),n(u);else{_u(u,i,t);try{await t.onFailedAttempt(u)}catch(h){n(h);return}if(!s.retry(u))n(s.mainError())}}})});Pt.exports=ns;Pt.exports.default=ns;Pt.exports.AbortError=Er});var wr=w(function(eg,hs){var It=Object.prototype.hasOwnProperty,ls=Object.prototype.toString,{defineProperty:ss,getOwnPropertyDescriptor:is}=Object,os=function(t){if(typeof Array.isArray==="function")return Array.isArray(t);return ls.call(t)==="[object Array]"},as=function(t){if(!t||ls.call(t)!=="[object Object]")return!1;var r=It.call(t,"constructor"),n=t.constructor&&t.constructor.prototype&&It.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!n)return!1;var s;for(s in t);return typeof s>"u"||It.call(t,s)},cs=function(t,r){if(ss&&r.name==="__proto__")ss(t,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0});else t[r.name]=r.newValue},us=function(t,r){if(r==="__proto__"){if(!It.call(t,r))return;else if(is)return is(t,r).value}return t[r]};hs.exports=function e(){var t,r,n,s,i,u,h=arguments[0],y=1,S=arguments.length,A=!1;if(typeof h==="boolean")A=h,h=arguments[1]||{},y=2;if(h==null||typeof h!=="object"&&typeof h!=="function")h={};for(;y<S;++y)if(t=arguments[y],t!=null){for(r in t)if(n=us(h,r),s=us(t,r),h!==s){if(A&&s&&(as(s)||(i=os(s)))){if(i)i=!1,u=n&&os(n)?n:[];else u=n&&as(n)?n:{};cs(h,{name:r,newValue:e(A,u,s)})}else if(typeof s<"u")cs(h,{name:r,newValue:s})}}return h}});var fs=w(function(tg,mu){mu.exports={name:"gaxios",version:"7.3.1",description:"A simple common HTTP client specifically for Google APIs and services.",main:"build/cjs/src/index.js",types:"build/cjs/src/index.d.ts",files:["build/"],exports:{".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},scripts:{lint:"gts check --no-inline-config",test:"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000",compile:"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs",fix:"gts fix",prepare:"npm run compile",pretest:"npm run compile",webpack:"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js",docs:"jsdoc -c .jsdoc.js","samples-test":"cd samples/ && npm link ../ && npm test && cd ../",prelint:"cd samples; npm link ../; npm install",clean:"gts clean"},repository:{type:"git",directory:"core/packages/gaxios",url:"https://github.com/googleapis/google-cloud-node.git"},keywords:["google"],engines:{node:">=18"},author:"Google, LLC",license:"Apache-2.0",devDependencies:{"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","@types/tmp":"^0.2.6",assert:"^2.0.0",browserify:"^17.0.0",c8:"^10.1.3",cors:"^2.8.5",express:"^5.0.0",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.0",mocha:"^11.1.0",multiparty:"^4.2.1",mv:"^2.1.1",ncp:"^2.0.0",nock:"14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0",puppeteer:"^24.0.0",sinon:"21.0.3","stream-browserify":"^3.0.0",tmp:"0.2.7","ts-loader":"^9.5.2",typescript:"5.8.3","undici-types":"^7.24.1",webpack:"^5.97.1","webpack-cli":"^6.0.1"},dependencies:{extend:"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},homepage:"https://github.com/googleapis/google-cloud-node/tree/main/core/packages/gaxios"}});var ps=w(function(rg,ds){var Eu=fs();ds.exports={pkg:Eu}});var vr=w(function(we){var _s=we&&we.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(we,"__esModule",{value:!0});we.GaxiosError=we.GAXIOS_ERROR_SYMBOL=void 0;we.defaultErrorRedactor=ys;var gs=_s(wr()),wu=_s(ps()),Tr=wu.default.pkg;we.GAXIOS_ERROR_SYMBOL=Symbol.for(`${Tr.name}-gaxios-error`);class Ar extends Error{config;response;code;status;error;[we.GAXIOS_ERROR_SYMBOL]=Tr.version;static[Symbol.hasInstance](e){if(e&&typeof e==="object"&&we.GAXIOS_ERROR_SYMBOL in e&&e[we.GAXIOS_ERROR_SYMBOL]===Tr.version)return!0;return Function.prototype[Symbol.hasInstance].call(Ar,e)}constructor(e,t,r,n){super(e,{cause:n});if(this.config=t,this.response=r,this.error=n instanceof Error?n:void 0,this.config=(0,gs.default)(!0,{},t),this.response)this.response.config=(0,gs.default)(!0,{},this.response.config);if(this.response){try{this.response.data=Tu(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}if(n instanceof DOMException)this.code=n.name;else if(n&&typeof n==="object"&&"code"in n&&(typeof n.code==="string"||typeof n.code==="number"))this.code=n.code}static extractAPIErrorFromResponse(e,t="The request failed"){let r=t;if(typeof e.data==="string")r=e.data;if(e.data&&typeof e.data==="object"&&"error"in e.data&&e.data.error&&!e.ok){if(typeof e.data.error==="string")return{message:e.data.error,code:e.status,status:e.statusText};if(typeof e.data.error==="object"){r="message"in e.data.error&&typeof e.data.error.message==="string"?e.data.error.message:r;let n="status"in e.data.error&&typeof e.data.error.status==="string"?e.data.error.status:e.statusText,s="code"in e.data.error&&typeof e.data.error.code==="number"?e.data.error.code:e.status;if("errors"in e.data.error&&Array.isArray(e.data.error.errors)){let i=[];for(let u of e.data.error.errors)if(typeof u==="object"&&"message"in u&&typeof u.message==="string")i.push(u.message);return Object.assign({message:i.join(`
3
+ `)||r,code:s,status:n},e.data.error)}return Object.assign({message:r,code:s,status:n},e.data.error)}}return{message:r,code:e.status,status:e.statusText}}}we.GaxiosError=Ar;function Tu(e,t){switch(e){case"stream":return t;case"json":return JSON.parse(JSON.stringify(t));case"arraybuffer":return JSON.parse(Buffer.from(t).toString("utf8"));case"blob":return JSON.parse(t.text());default:return t}}function ys(e){function r(i){if(!i)return;i.forEach((u,h)=>{if(/^authentication$/i.test(h)||/^authorization$/i.test(h)||/secret/i.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")})}function n(i,u){if(typeof i==="object"&&i!==null&&typeof i[u]==="string"){let h=i[u];if(/grant_type=/i.test(h)||/assertion=/i.test(h)||/secret/i.test(h))i[u]="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}function s(i){if(!i||typeof i!=="object")return;else if(i instanceof FormData||i instanceof URLSearchParams||"forEach"in i&&"set"in i)i.forEach((u,h)=>{if(["grant_type","assertion"].includes(h)||/secret/.test(h))i.set(h,"<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")});else{if("grant_type"in i)i.grant_type="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("assertion"in i)i.assertion="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";if("client_secret"in i)i.client_secret="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>."}}if(e.config){if(r(e.config.headers),n(e.config,"data"),s(e.config.data),n(e.config,"body"),s(e.config.body),e.config.url.searchParams.has("token"))e.config.url.searchParams.set("token","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.");if(e.config.url.searchParams.has("client_secret"))e.config.url.searchParams.set("client_secret","<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.")}if(e.response){if(ys({config:e.response.config}),r(e.response.headers),e.response.bodyUsed)n(e.response,"data"),s(e.response.data)}return e}});var ws=w(function(Es){Object.defineProperty(Es,"__esModule",{value:!0});Es.getRetryConfig=Au;async function Au(e){let t=ms(e);if(!e||!e.config||!t&&!e.config.retry)return{shouldRetry:!1};t=t||{},t.currentRetryAttempt=t.currentRetryAttempt||0,t.retry=t.retry===void 0||t.retry===null?3:t.retry,t.httpMethodsToRetry=t.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],t.noResponseRetries=t.noResponseRetries===void 0||t.noResponseRetries===null?2:t.noResponseRetries,t.retryDelayMultiplier=t.retryDelayMultiplier?t.retryDelayMultiplier:2,t.timeOfFirstRequest=t.timeOfFirstRequest?t.timeOfFirstRequest:Date.now(),t.totalTimeout=t.totalTimeout?t.totalTimeout:Number.MAX_SAFE_INTEGER,t.maxRetryDelay=t.maxRetryDelay?t.maxRetryDelay:Number.MAX_SAFE_INTEGER;let r=[[100,199],[408,408],[429,429],[500,599]];if(t.statusCodesToRetry=t.statusCodesToRetry||r,e.config.retryConfig=t,!await(t.shouldRetry||vu)(e))return{shouldRetry:!1,config:e.config};let s=Su(t);e.config.retryConfig.currentRetryAttempt+=1;let i=t.retryBackoff?t.retryBackoff(e,s):new Promise((u)=>{setTimeout(u,s)});if(t.onRetryAttempt)await t.onRetryAttempt(e);return await i,{shouldRetry:!0,config:e.config}}function vu(e){let t=ms(e);if(e.config.signal?.aborted&&e.code!=="TimeoutError"||e.code==="AbortError")return!1;if(!t||t.retry===0)return!1;if(!e.response&&(t.currentRetryAttempt||0)>=t.noResponseRetries)return!1;if(!t.httpMethodsToRetry||!t.httpMethodsToRetry.includes(e.config.method?.toUpperCase()||"GET"))return!1;if(e.response&&e.response.status){let r=!1;for(let[n,s]of t.statusCodesToRetry){let i=e.response.status;if(i>=n&&i<=s){r=!0;break}}if(!r)return!1}if(t.currentRetryAttempt=t.currentRetryAttempt||0,t.currentRetryAttempt>=t.retry)return!1;return!0}function ms(e){if(e&&e.config&&e.config.retryConfig)return e.config.retryConfig;return}function Su(e){let r=(e.currentRetryAttempt?0:e.retryDelay??100)+(Math.pow(e.retryDelayMultiplier,e.currentRetryAttempt)-1)/2*1000,n=e.totalTimeout-(Date.now()-e.timeOfFirstRequest);return Math.min(r,n,e.maxRetryDelay)}});var Sr=w(function(As){Object.defineProperty(As,"__esModule",{value:!0});As.GaxiosInterceptorManager=void 0;class Ts extends Set{}As.GaxiosInterceptorManager=Ts});var Os=w(function(et){var ku=et&&et.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Ze;Object.defineProperty(et,"__esModule",{value:!0});et.Gaxios=void 0;var bu=ku(wr()),xu=G("https"),We=vr(),Ru=ws(),Ss=G("stream"),Cs=Sr(),Nu=async()=>globalThis.crypto?.randomUUID()||(await import("crypto")).randomUUID(),Pu=204;class Cr{agentCache=new Map;defaults;interceptors;constructor(e){this.defaults=e||{},this.interceptors={request:new Cs.GaxiosInterceptorManager,response:new Cs.GaxiosInterceptorManager}}fetch(...e){let t=e[0],r=e[1],n=void 0,s=new Headers;if(typeof t==="string")n=new URL(t);else if(t instanceof URL)n=t;else if(t&&t.url)n=new URL(t.url);if(t&&typeof t==="object"&&"headers"in t)Ze.mergeHeaders(s,t.headers);if(r)Ze.mergeHeaders(s,new Headers(r.headers));if(typeof t==="object"&&!(t instanceof URL))return this.request({...r,...t,headers:s,url:n});else return this.request({...r,headers:s,url:n})}async request(e={}){let t=await this.#n(e);return t=await this.#t(t),this.#r(this._request(t))}async _defaultAdapter(e){let t=e.fetchImplementation||this.defaults.fetchImplementation||await Ze.#c(),r={...e};delete r.data;let n=await t(e.url,r),s=await this.getResponseData(e,n);if(!Object.getOwnPropertyDescriptor(n,"data")?.configurable)Object.defineProperties(n,{data:{configurable:!0,writable:!0,enumerable:!0,value:s}});return Object.assign(n,{config:e,data:s})}async _request(e){try{let t;if(e.adapter)t=await e.adapter(e,this._defaultAdapter.bind(this));else t=await this._defaultAdapter(e);if(!e.validateStatus(t.status)){if(e.responseType==="stream"){let n=[];for await(let s of t.data)n.push(s);t.data=Buffer.concat(n.map((s)=>typeof s==="string"?Buffer.from(s):s)).toString("utf8")}let r=We.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new We.GaxiosError(r?.message,e,t,r)}return t}catch(t){let r;if(t instanceof We.GaxiosError)r=t;else if(t instanceof Error)r=new We.GaxiosError(t.message,e,void 0,t);else r=new We.GaxiosError("Unexpected Gaxios Error",e,void 0,t);let{shouldRetry:n,config:s}=await Ru.getRetryConfig(r);if(n&&s)return r.config.retryConfig.currentRetryAttempt=s.retryConfig.currentRetryAttempt,e.retryConfig=r.config?.retryConfig,this.#s(e),this._request(e);if(e.errorRedactor)e.errorRedactor(r);throw r}}async getResponseData(e,t){if(t.status===Pu)return"";if(e.maxContentLength&&t.headers.has("content-length")&&e.maxContentLength<Number.parseInt(t.headers?.get("content-length")||""))throw new We.GaxiosError("Response's `Content-Length` is over the limit.",e,Object.assign(t,{config:e}));switch(e.responseType){case"stream":return t.body;case"json":{let r=await t.text();try{return JSON.parse(r)}catch{return r}}case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"text":return t.text();default:return this.getResponseDataFromContentType(t)}}#e(e,t=[]){let r=new URL(e),n=[...t],s=(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[];for(let i of s)n.push(i.trim());for(let i of n)if(i instanceof RegExp){if(i.test(r.toString()))return!1}else if(i instanceof URL){if(i.origin===r.origin)return!1}else if(i.startsWith("*.")||i.startsWith(".")){let u=i.replace(/^\*\./,".");if(r.hostname.endsWith(u))return!1}else if(i===r.origin||i===r.hostname||i===r.href)return!1;return!0}async#t(e){let t=Promise.resolve(e);for(let r of this.interceptors.request.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#r(e){let t=Promise.resolve(e);for(let r of this.interceptors.response.values())if(r)t=t.then(r.resolved,r.rejected);return t}async#n(e){let t=new Headers(this.defaults.headers);Ze.mergeHeaders(t,e.headers);let r=(0,bu.default)(!0,{},this.defaults,e);if(!r.url)throw Error("URL is required.");if(r.baseURL)r.url=new URL(r.url,r.baseURL);if(r.url=new URL(r.url),r.params)if(r.paramsSerializer){let i=r.paramsSerializer(r.params);if(i.startsWith("?"))i=i.slice(1);let u=r.url.toString().includes("?")?"&":"?";r.url=r.url+u+i}else{let i=r.url instanceof URL?r.url:new URL(r.url);for(let[u,h]of new URLSearchParams(r.params))i.searchParams.append(u,h);r.url=i}if(typeof e.maxContentLength==="number")r.size=e.maxContentLength;if(typeof e.maxRedirects==="number")r.follow=e.maxRedirects;let n=typeof r.data==="string"||r.data instanceof ArrayBuffer||r.data instanceof Blob||globalThis.File&&r.data instanceof File||r.data instanceof FormData||r.data instanceof Ss.Readable||r.data instanceof ReadableStream||r.data instanceof String||r.data instanceof URLSearchParams||ArrayBuffer.isView(r.data)||["Blob","File","FormData"].includes(r.data?.constructor?.name||"");if(r.multipart?.length){let i=await Nu();t.set("content-type",`multipart/related; boundary=${i}`),r.body=Ss.Readable.from(this.getMultipartRequest(r.multipart,i))}else if(n)r.body=r.data;else if(typeof r.data==="object")if(t.get("Content-Type")==="application/x-www-form-urlencoded")r.body=r.paramsSerializer?r.paramsSerializer(r.data):new URLSearchParams(r.data);else{if(!t.has("content-type"))t.set("content-type","application/json");r.body=JSON.stringify(r.data)}else if(r.data)r.body=r.data;if(r.validateStatus=r.validateStatus||this.validateStatus,r.responseType=r.responseType||"unknown",!t.has("accept")&&r.responseType==="json")t.set("accept","application/json");let s=r.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(r.agent);else if(s&&this.#e(r.url,r.noProxy)){let i=await Ze.#a();if(this.agentCache.has(s))r.agent=this.agentCache.get(s);else r.agent=new i(s,{cert:r.cert,key:r.key}),this.agentCache.set(s,r.agent)}else if(r.cert&&r.key)if(this.agentCache.has(r.key))r.agent=this.agentCache.get(r.key);else r.agent=new xu.Agent({cert:r.cert,key:r.key}),this.agentCache.set(r.key,r.agent);if(typeof r.errorRedactor!=="function"&&r.errorRedactor!==!1)r.errorRedactor=We.defaultErrorRedactor;if(r.body&&!("duplex"in r))r.duplex="half";return this.#s(r),Object.assign(r,{headers:t,url:r.url instanceof URL?r.url:new URL(r.url)})}#s(e){if(e.timeout){let t=AbortSignal.timeout(e.timeout);if(e.signal&&!e.signal.aborted)e.signal=AbortSignal.any([e.signal,t]);else e.signal=t}}validateStatus(e){return e>=200&&e<300}async getResponseDataFromContentType(e){let t=e.headers.get("Content-Type");if(t===null)return e.text();if(t=t.toLowerCase(),t.includes("application/json")){let r=await e.text();try{r=JSON.parse(r)}catch{}return r}else if(t.match(/^text\//))return e.text();else return e.blob()}async*getMultipartRequest(e,t){let r=`--${t}--`;for(let n of e){let s=n.headers.get("Content-Type")||"application/octet-stream";if(yield`--${t}\r
4
4
  Content-Type: ${s}\r
5
5
  \r
6
6
  `,typeof n.content==="string")yield n.content;else yield*n.content;yield`\r
7
- `}yield r}static#i;static#o;static async#a(){return this.#i||=(await import("./chunk-mqr096rn.js").then((m)=>H(m.default))).HttpsProxyAgent,this.#i}static async#c(){let e=typeof window<"u"&&!!window;return this.#o||=e?window.fetch:(await import("node-fetch")).default,this.#o}static mergeHeaders(e,...t){e=e instanceof Headers?e:new Headers(e);for(let r of t)(r instanceof Headers?r:new Headers(r)).forEach((s,i)=>{i==="set-cookie"?e.append(i,s):e.set(i,s)});return e}}et.Gaxios=Cr;Ze=Cr});var ie=w(function(le){var Iu=le&&le.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),ju=le&&le.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Iu(t,e,r)};Object.defineProperty(le,"__esModule",{value:!0});le.instance=le.Gaxios=le.GaxiosError=void 0;le.request=Uu;var ks=Os();Object.defineProperty(le,"Gaxios",{enumerable:!0,get:function(){return ks.Gaxios}});var Du=vr();Object.defineProperty(le,"GaxiosError",{enumerable:!0,get:function(){return Du.GaxiosError}});ju(Sr(),le);le.instance=new ks.Gaxios;async function Uu(e){return le.instance.request(e)}});var Or=w(function(bs,jt){(function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,{ceil:n,floor:s}=Math,i="[BigNumber Error] ",u=i+"Number primitive has more than 15 significant digits: ",h=100000000000000,y=14,S=9007199254740991,A=[1,10,100,1000,1e4,1e5,1e6,1e7,1e8,1e9,10000000000,100000000000,1000000000000,10000000000000],k=1e7,N=1e9;function F(U){var D,B,X,C=v.prototype={constructor:v,toString:null,valueOf:null},ne=new v(1),Q=20,Z=4,he=-7,fe=21,Ke=-1e7,Se=1e7,Je=!1,ft=1,Le=0,fr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Ve="0123456789abcdefghijklmnopqrstuvwxyz",dr=!0;function v(o,a){var c,_,f,p,E,l,d,m,g=this;if(!(g instanceof v))return new v(o,a);if(a==null){if(o&&o._isBigNumber===!0){if(g.s=o.s,!o.c||o.e>Se)g.c=g.e=null;else if(o.e<Ke)g.c=[g.e=0];else g.e=o.e,g.c=o.c.slice();return}if((l=typeof o=="number")&&o*0==0){if(g.s=1/o<0?(o=-o,-1):1,o===~~o){for(p=0,E=o;E>=10;E/=10,p++);if(p>Se)g.c=g.e=null;else g.e=p,g.c=[o];return}m=String(o)}else{if(!r.test(m=String(o)))return X(g,m,l);g.s=m.charCodeAt(0)==45?(m=m.slice(1),-1):1}if((p=m.indexOf("."))>-1)m=m.replace(".","");if((E=m.search(/e/i))>0){if(p<0)p=E;p+=+m.slice(E+1),m=m.substring(0,E)}else if(p<0)p=m.length}else{if(b(a,2,Ve.length,"Base"),a==10&&dr)return g=new v(o),ye(g,Q+g.e+1,Z);if(m=String(o),l=typeof o=="number"){if(o*0!=0)return X(g,m,l,a);if(g.s=1/o<0?(m=m.slice(1),-1):1,v.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(u+o)}else g.s=m.charCodeAt(0)===45?(m=m.slice(1),-1):1;c=Ve.slice(0,a),p=E=0;for(d=m.length;E<d;E++)if(c.indexOf(_=m.charAt(E))<0){if(_=="."){if(E>p){p=d;continue}}else if(!f){if(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase())){f=!0,E=-1,p=0;continue}}return X(g,String(o),l,a)}if(l=!1,m=B(m,a,10,g.s),(p=m.indexOf("."))>-1)m=m.replace(".","");else p=m.length}for(E=0;m.charCodeAt(E)===48;E++);for(d=m.length;m.charCodeAt(--d)===48;);if(m=m.slice(E,++d)){if(d-=E,l&&v.DEBUG&&d>15&&(o>S||o!==s(o)))throw Error(u+g.s*o);if((p=p-E-1)>Se)g.c=g.e=null;else if(p<Ke)g.c=[g.e=0];else{if(g.e=p,g.c=[],E=(p+1)%y,p<0)E+=y;if(E<d){if(E)g.c.push(+m.slice(0,E));for(d-=y;E<d;)g.c.push(+m.slice(E,E+=y));E=y-(m=m.slice(E)).length}else E-=d;for(;E--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}v.clone=F,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(o){var a,c;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(a="DECIMAL_PLACES"))c=o[a],b(c,0,N,a),Q=c;if(o.hasOwnProperty(a="ROUNDING_MODE"))c=o[a],b(c,0,8,a),Z=c;if(o.hasOwnProperty(a="EXPONENTIAL_AT"))if(c=o[a],c&&c.pop)b(c[0],-N,0,a),b(c[1],0,N,a),he=c[0],fe=c[1];else b(c,-N,N,a),he=-(fe=c<0?-c:c);if(o.hasOwnProperty(a="RANGE"))if(c=o[a],c&&c.pop)b(c[0],-N,-1,a),b(c[1],1,N,a),Ke=c[0],Se=c[1];else if(b(c,-N,N,a),c)Ke=-(Se=c<0?-c:c);else throw Error(i+a+" cannot be zero: "+c);if(o.hasOwnProperty(a="CRYPTO"))if(c=o[a],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Je=c;else throw Je=!c,Error(i+"crypto unavailable");else Je=c;else throw Error(i+a+" not true or false: "+c);if(o.hasOwnProperty(a="MODULO_MODE"))c=o[a],b(c,0,9,a),ft=c;if(o.hasOwnProperty(a="POW_PRECISION"))c=o[a],b(c,0,N,a),Le=c;if(o.hasOwnProperty(a="FORMAT"))if(c=o[a],typeof c=="object")fr=c;else throw Error(i+a+" not an object: "+c);if(o.hasOwnProperty(a="ALPHABET"))if(c=o[a],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))dr=c.slice(0,10)=="0123456789",Ve=c;else throw Error(i+a+" invalid: "+c)}else throw Error(i+"Object expected: "+o);return{DECIMAL_PLACES:Q,ROUNDING_MODE:Z,EXPONENTIAL_AT:[he,fe],RANGE:[Ke,Se],CRYPTO:Je,MODULO_MODE:ft,POW_PRECISION:Le,FORMAT:fr,ALPHABET:Ve}},v.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var a,c,{c:_,e:f,s:p}=o;e:if({}.toString.call(_)=="[object Array]"){if((p===1||p===-1)&&f>=-N&&f<=N&&f===s(f)){if(_[0]===0){if(f===0&&_.length===1)return!0;break e}if(a=(f+1)%y,a<1)a+=y;if(String(_[0]).length==a){for(a=0;a<_.length;a++)if(c=_[a],c<0||c>=h||c!==s(c))break e;if(c!==0)return!0}}}else if(_===null&&f===null&&(p===null||p===1||p===-1))return!0;throw Error(i+"Invalid BigNumber: "+o)},v.maximum=v.max=function(){return Qn(arguments,-1)},v.minimum=v.min=function(){return Qn(arguments,1)},v.random=function(){var o=9007199254740992,a=Math.random()*o&2097151?function(){return s(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var _,f,p,E,l,d=0,m=[],g=new v(ne);if(c==null)c=Q;else b(c,0,N);if(E=n(c/y),Je)if(crypto.getRandomValues){_=crypto.getRandomValues(new Uint32Array(E*=2));for(;d<E;)if(l=_[d]*131072+(_[d+1]>>>11),l>=9000000000000000)f=crypto.getRandomValues(new Uint32Array(2)),_[d]=f[0],_[d+1]=f[1];else m.push(l%100000000000000),d+=2;d=E/2}else if(crypto.randomBytes){_=crypto.randomBytes(E*=7);for(;d<E;)if(l=(_[d]&31)*281474976710656+_[d+1]*1099511627776+_[d+2]*4294967296+_[d+3]*16777216+(_[d+4]<<16)+(_[d+5]<<8)+_[d+6],l>=9000000000000000)crypto.randomBytes(7).copy(_,d);else m.push(l%100000000000000),d+=7;d=E/7}else throw Je=!1,Error(i+"crypto unavailable");if(!Je){for(;d<E;)if(l=a(),l<9000000000000000)m[d++]=l%100000000000000}if(E=m[--d],c%=y,E&&c)l=A[y-c],m[d]=s(E/l)*l;for(;m[d]===0;m.pop(),d--);if(d<0)m=[p=0];else{for(p=-1;m[0]===0;m.splice(0,1),p-=y);for(d=1,l=m[0];l>=10;l/=10,d++);if(d<y)p-=y-d}return g.e=p,g.c=m,g}}(),v.sum=function(){var o=1,a=arguments,c=new v(a[0]);for(;o<a.length;)c=c.plus(a[o++]);return c},B=function(){var o="0123456789";function a(c,_,f,p){var E,l=[0],d,m=0,g=c.length;for(;m<g;){for(d=l.length;d--;l[d]*=_);l[0]+=p.indexOf(c.charAt(m++));for(E=0;E<l.length;E++)if(l[E]>f-1){if(l[E+1]==null)l[E+1]=0;l[E+1]+=l[E]/f|0,l[E]%=f}}return l.reverse()}return function(c,_,f,p,E){var l,d,m,g,T,R,P,L,ee=c.indexOf("."),se=Q,M=Z;if(ee>=0)g=Le,Le=0,c=c.replace(".",""),L=new v(_),R=L.pow(c.length-ee),Le=g,L.c=a(ce(x(R.c),R.e,"0"),10,f,o),L.e=L.c.length;P=a(c,_,f,E?(l=Ve,o):(l=o,Ve)),m=g=P.length;for(;P[--g]==0;P.pop());if(!P[0])return l.charAt(0);if(ee<0)--m;else R.c=P,R.e=m,R.s=p,R=D(R,L,se,M,f),P=R.c,T=R.r,m=R.e;if(d=m+se+1,ee=P[d],g=f/2,T=T||d<0||P[d+1]!=null,T=M<4?(ee!=null||T)&&(M==0||M==(R.s<0?3:2)):ee>g||ee==g&&(M==4||T||M==6&&P[d-1]&1||M==(R.s<0?8:7)),d<1||!P[0])c=T?ce(l.charAt(1),-se,l.charAt(0)):l.charAt(0);else{if(P.length=d,T){for(--f;++P[--d]>f;)if(P[d]=0,!d)++m,P=[1].concat(P)}for(g=P.length;!P[--g];);for(ee=0,c="";ee<=g;c+=l.charAt(P[ee++]));c=ce(c,m,l.charAt(0))}return c}}(),D=function(){function o(_,f,p){var E,l,d,m,g=0,T=_.length,R=f%k,P=f/k|0;for(_=_.slice();T--;)d=_[T]%k,m=_[T]/k|0,E=P*d+m*R,l=R*d+E%k*k+g,g=(l/p|0)+(E/k|0)+P*m,_[T]=l%p;if(g)_=[g].concat(_);return _}function a(_,f,p,E){var l,d;if(p!=E)d=p>E?1:-1;else for(l=d=0;l<p;l++)if(_[l]!=f[l]){d=_[l]>f[l]?1:-1;break}return d}function c(_,f,p,E){var l=0;for(;p--;)_[p]-=l,l=_[p]<f[p]?1:0,_[p]=l*E+_[p]-f[p];for(;!_[0]&&_.length>1;_.splice(0,1));}return function(_,f,p,E,l){var d,m,g,T,R,P,L,ee,se,M,J,ae,Nt,_r,yr,Re,dt,me=_.s==f.s?1:-1,ue=_.c,te=f.c;if(!ue||!ue[0]||!te||!te[0])return new v(!_.s||!f.s||(ue?te&&ue[0]==te[0]:!te)?NaN:ue&&ue[0]==0||!te?me*0:me/0);if(ee=new v(me),se=ee.c=[],m=_.e-f.e,me=p+m+1,!l)l=h,m=W(_.e/y)-W(f.e/y),me=me/y|0;for(g=0;te[g]==(ue[g]||0);g++);if(te[g]>(ue[g]||0))m--;if(me<0)se.push(1),T=!0;else{if(_r=ue.length,Re=te.length,g=0,me+=2,R=s(l/(te[0]+1)),R>1)te=o(te,R,l),ue=o(ue,R,l),Re=te.length,_r=ue.length;Nt=Re,M=ue.slice(0,Re),J=M.length;for(;J<Re;M[J++]=0);if(dt=te.slice(),dt=[0].concat(dt),yr=te[0],te[1]>=l/2)yr++;do{if(R=0,d=a(te,M,Re,J),d<0){if(ae=M[0],Re!=J)ae=ae*l+(M[1]||0);if(R=s(ae/yr),R>1){if(R>=l)R=l-1;P=o(te,R,l),L=P.length,J=M.length;while(a(P,M,L,J)==1)R--,c(P,Re<L?dt:te,L,l),L=P.length,d=1}else{if(R==0)d=R=1;P=te.slice(),L=P.length}if(L<J)P=[0].concat(P);if(c(M,P,J,l),J=M.length,d==-1)while(a(te,M,Re,J)<1)R++,c(M,Re<J?dt:te,J,l),J=M.length}else if(d===0)R++,M=[0];if(se[g++]=R,M[0])M[J++]=ue[Nt]||0;else M=[ue[Nt]],J=1}while((Nt++<_r||M[0]!=null)&&me--);if(T=M[0]!=null,!se[0])se.splice(0,1)}if(l==h){for(g=1,me=se[0];me>=10;me/=10,g++);ye(ee,p+(ee.e=g+m*y-1)+1,E,T)}else ee.e=m,ee.r=+T;return ee}}();function pr(o,a,c,_){var f,p,E,l,d;if(c==null)c=Z;else b(c,0,8);if(!o.c)return o.toString();if(f=o.c[0],E=o.e,a==null)d=x(o.c),d=_==1||_==2&&(E<=he||E>=fe)?re(d,E):ce(d,E,"0");else if(o=ye(new v(o),a,c),p=o.e,d=x(o.c),l=d.length,_==1||_==2&&(a<=p||p<=he)){for(;l<a;d+="0",l++);d=re(d,p)}else if(a-=E+(_===2&&p>E),d=ce(d,p,"0"),p+1>l){if(--a>0)for(d+=".";a--;d+="0");}else if(a+=p-l,a>0){if(p+1==l)d+=".";for(;a--;d+="0");}return o.s<0&&f?"-"+d:d}function Qn(o,a){var c,_,f=1,p=new v(o[0]);for(;f<o.length;f++)if(_=new v(o[f]),!_.s||(c=j(p,_))===a||c===0&&p.s===a)p=_;return p}function gr(o,a,c){var _=1,f=a.length;for(;!a[--f];a.pop());for(f=a[0];f>=10;f/=10,_++);if((c=_+c*y-1)>Se)o.c=o.e=null;else if(c<Ke)o.c=[o.e=0];else o.e=c,o.c=a;return o}X=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,a=/^([^.]+)\.$/,c=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(p,E,l,d){var m,g=l?E:E.replace(f,"");if(_.test(g))p.s=isNaN(g)?null:g<0?-1:1;else{if(!l){if(g=g.replace(o,function(T,R,P){return m=(P=P.toLowerCase())=="x"?16:P=="b"?2:8,!d||d==m?R:T}),d)m=d,g=g.replace(a,"$1").replace(c,"0.$1");if(E!=g)return new v(g,m)}if(v.DEBUG)throw Error(i+"Not a"+(d?" base "+d:"")+" number: "+E);p.s=null}p.c=p.e=null}}();function ye(o,a,c,_){var f,p,E,l,d,m,g,T=o.c,R=A;if(T){e:{for(f=1,l=T[0];l>=10;l/=10,f++);if(p=a-f,p<0)p+=y,E=a,d=T[m=0],g=s(d/R[f-E-1]%10);else if(m=n((p+1)/y),m>=T.length)if(_){for(;T.length<=m;T.push(0));d=g=0,f=1,p%=y,E=p-y+1}else break e;else{d=l=T[m];for(f=1;l>=10;l/=10,f++);p%=y,E=p-y+f,g=E<0?0:s(d/R[f-E-1]%10)}if(_=_||a<0||T[m+1]!=null||(E<0?d:d%R[f-E-1]),_=c<4?(g||_)&&(c==0||c==(o.s<0?3:2)):g>5||g==5&&(c==4||_||c==6&&(p>0?E>0?d/R[f-E]:0:T[m-1])%10&1||c==(o.s<0?8:7)),a<1||!T[0]){if(T.length=0,_)a-=o.e+1,T[0]=R[(y-a%y)%y],o.e=-a||0;else T[0]=o.e=0;return o}if(p==0)T.length=m,l=1,m--;else T.length=m+1,l=R[y-p],T[m]=E>0?s(d/R[f-E]%R[E])*l:0;if(_)for(;;)if(m==0){for(p=1,E=T[0];E>=10;E/=10,p++);E=T[0]+=l;for(l=1;E>=10;E/=10,l++);if(p!=l){if(o.e++,T[0]==h)T[0]=1}break}else{if(T[m]+=l,T[m]!=h)break;T[m--]=0,l=1}for(p=T.length;T[--p]===0;T.pop());}if(o.e>Se)o.c=o.e=null;else if(o.e<Ke)o.c=[o.e=0]}return o}function je(o){var a,c=o.e;if(c===null)return o.toString();return a=x(o.c),a=c<=he||c>=fe?re(a,c):ce(a,c,"0"),o.s<0?"-"+a:a}if(C.absoluteValue=C.abs=function(){var o=new v(this);if(o.s<0)o.s=1;return o},C.comparedTo=function(o,a){return j(this,new v(o,a))},C.decimalPlaces=C.dp=function(o,a){var c,_,f,p=this;if(o!=null){if(b(o,0,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o+p.e+1,a)}if(!(c=p.c))return null;if(_=((f=c.length-1)-W(this.e/y))*y,f=c[f])for(;f%10==0;f/=10,_--);if(_<0)_=0;return _},C.dividedBy=C.div=function(o,a){return D(this,new v(o,a),Q,Z)},C.dividedToIntegerBy=C.idiv=function(o,a){return D(this,new v(o,a),0,1)},C.exponentiatedBy=C.pow=function(o,a){var c,_,f,p,E,l,d,m,g,T=this;if(o=new v(o),o.c&&!o.isInteger())throw Error(i+"Exponent not an integer: "+je(o));if(a!=null)a=new v(a);if(l=o.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!o.c||!o.c[0])return g=new v(Math.pow(+je(T),l?o.s*(2-K(o)):+je(o))),a?g.mod(a):g;if(d=o.s<0,a){if(a.c?!a.c[0]:!a.s)return new v(NaN);if(_=!d&&T.isInteger()&&a.isInteger(),_)T=T.mod(a)}else if(o.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||l&&T.c[1]>=240000000:T.c[0]<80000000000000||l&&T.c[0]<=99999750000000))){if(p=T.s<0&&K(o)?-0:0,T.e>-1)p=1/p;return new v(d?1/p:p)}else if(Le)p=n(Le/y+2);if(l){if(c=new v(0.5),d)o.s=1;m=K(o)}else f=Math.abs(+je(o)),m=f%2;g=new v(ne);for(;;){if(m){if(g=g.times(T),!g.c)break;if(p){if(g.c.length>p)g.c.length=p}else if(_)g=g.mod(a)}if(f){if(f=s(f/2),f===0)break;m=f%2}else if(o=o.times(c),ye(o,o.e+1,1),o.e>14)m=K(o);else{if(f=+je(o),f===0)break;m=f%2}if(T=T.times(T),p){if(T.c&&T.c.length>p)T.c.length=p}else if(_)T=T.mod(a)}if(_)return g;if(d)g=ne.div(g);return a?g.mod(a):p?ye(g,Le,Z,E):g},C.integerValue=function(o){var a=new v(this);if(o==null)o=Z;else b(o,0,8);return ye(a,a.e+1,o)},C.isEqualTo=C.eq=function(o,a){return j(this,new v(o,a))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(o,a){return j(this,new v(o,a))>0},C.isGreaterThanOrEqualTo=C.gte=function(o,a){return(a=j(this,new v(o,a)))===1||a===0},C.isInteger=function(){return!!this.c&&W(this.e/y)>this.c.length-2},C.isLessThan=C.lt=function(o,a){return j(this,new v(o,a))<0},C.isLessThanOrEqualTo=C.lte=function(o,a){return(a=j(this,new v(o,a)))===-1||a===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(o,a){var c,_,f,p,E=this,l=E.s;if(o=new v(o,a),a=o.s,!l||!a)return new v(NaN);if(l!=a)return o.s=-a,E.plus(o);var d=E.e/y,m=o.e/y,g=E.c,T=o.c;if(!d||!m){if(!g||!T)return g?(o.s=-a,o):new v(T?E:NaN);if(!g[0]||!T[0])return T[0]?(o.s=-a,o):new v(g[0]?E:Z==3?-0:0)}if(d=W(d),m=W(m),g=g.slice(),l=d-m){if(p=l<0)l=-l,f=g;else m=d,f=T;f.reverse();for(a=l;a--;f.push(0));f.reverse()}else{_=(p=(l=g.length)<(a=T.length))?l:a;for(l=a=0;a<_;a++)if(g[a]!=T[a]){p=g[a]<T[a];break}}if(p)f=g,g=T,T=f,o.s=-o.s;if(a=(_=T.length)-(c=g.length),a>0)for(;a--;g[c++]=0);a=h-1;for(;_>l;){if(g[--_]<T[_]){for(c=_;c&&!g[--c];g[c]=a);--g[c],g[_]+=h}g[_]-=T[_]}for(;g[0]==0;g.splice(0,1),--m);if(!g[0])return o.s=Z==3?-1:1,o.c=[o.e=0],o;return gr(o,g,m)},C.modulo=C.mod=function(o,a){var c,_,f=this;if(o=new v(o,a),!f.c||!o.s||o.c&&!o.c[0])return new v(NaN);else if(!o.c||f.c&&!f.c[0])return new v(f);if(ft==9)_=o.s,o.s=1,c=D(f,o,0,3),o.s=_,c.s*=_;else c=D(f,o,0,ft);if(o=f.minus(c.times(o)),!o.c[0]&&ft==1)o.s=f.s;return o},C.multipliedBy=C.times=function(o,a){var c,_,f,p,E,l,d,m,g,T,R,P,L,ee,se,M=this,J=M.c,ae=(o=new v(o,a)).c;if(!J||!ae||!J[0]||!ae[0]){if(!M.s||!o.s||J&&!J[0]&&!ae||ae&&!ae[0]&&!J)o.c=o.e=o.s=null;else if(o.s*=M.s,!J||!ae)o.c=o.e=null;else o.c=[0],o.e=0;return o}if(_=W(M.e/y)+W(o.e/y),o.s*=M.s,d=J.length,T=ae.length,d<T)L=J,J=ae,ae=L,f=d,d=T,T=f;for(f=d+T,L=[];f--;L.push(0));ee=h,se=k;for(f=T;--f>=0;){c=0,R=ae[f]%se,P=ae[f]/se|0;for(E=d,p=f+E;p>f;)m=J[--E]%se,g=J[E]/se|0,l=P*m+g*R,m=R*m+l%se*se+L[p]+c,c=(m/ee|0)+(l/se|0)+P*g,L[p--]=m%ee;L[p]=c}if(c)++_;else L.splice(0,1);return gr(o,L,_)},C.negated=function(){var o=new v(this);return o.s=-o.s||null,o},C.plus=function(o,a){var c,_=this,f=_.s;if(o=new v(o,a),a=o.s,!f||!a)return new v(NaN);if(f!=a)return o.s=-a,_.minus(o);var p=_.e/y,E=o.e/y,l=_.c,d=o.c;if(!p||!E){if(!l||!d)return new v(f/0);if(!l[0]||!d[0])return d[0]?o:new v(l[0]?_:f*0)}if(p=W(p),E=W(E),l=l.slice(),f=p-E){if(f>0)E=p,c=d;else f=-f,c=l;c.reverse();for(;f--;c.push(0));c.reverse()}if(f=l.length,a=d.length,f-a<0)c=d,d=l,l=c,a=f;for(f=0;a;)f=(l[--a]=l[a]+d[a]+f)/h|0,l[a]=h===l[a]?0:l[a]%h;if(f)l=[f].concat(l),++E;return gr(o,l,E)},C.precision=C.sd=function(o,a){var c,_,f,p=this;if(o!=null&&o!==!!o){if(b(o,1,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o,a)}if(!(c=p.c))return null;if(f=c.length-1,_=f*y+1,f=c[f]){for(;f%10==0;f/=10,_--);for(f=c[0];f>=10;f/=10,_++);}if(o&&p.e+1>_)_=p.e+1;return _},C.shiftedBy=function(o){return b(o,-S,S),this.times("1e"+o)},C.squareRoot=C.sqrt=function(){var o,a,c,_,f,p=this,{c:E,s:l,e:d}=p,m=Q+4,g=new v("0.5");if(l!==1||!E||!E[0])return new v(!l||l<0&&(!E||E[0])?NaN:E?p:1/0);if(l=Math.sqrt(+je(p)),l==0||l==1/0){if(a=x(E),(a.length+d)%2==0)a+="0";if(l=Math.sqrt(+a),d=W((d+1)/2)-(d<0||d%2),l==1/0)a="5e"+d;else a=l.toExponential(),a=a.slice(0,a.indexOf("e")+1)+d;c=new v(a)}else c=new v(l+"");if(c.c[0]){if(d=c.e,l=d+m,l<3)l=0;for(;;)if(f=c,c=g.times(f.plus(D(p,f,m,1))),x(f.c).slice(0,l)===(a=x(c.c)).slice(0,l)){if(c.e<d)--l;if(a=a.slice(l-3,l+1),a=="9999"||!_&&a=="4999"){if(!_){if(ye(f,f.e+Q+2,0),f.times(f).eq(p)){c=f;break}}m+=4,l+=4,_=1}else{if(!+a||!+a.slice(1)&&a.charAt(0)=="5")ye(c,c.e+Q+2,1),o=!c.times(c).eq(p);break}}}return ye(c,c.e+Q+1,Z,o)},C.toExponential=function(o,a){if(o!=null)b(o,0,N),o++;return pr(this,o,a,1)},C.toFixed=function(o,a){if(o!=null)b(o,0,N),o=o+this.e+1;return pr(this,o,a)},C.toFormat=function(o,a,c){var _,f=this;if(c==null)if(o!=null&&a&&typeof a=="object")c=a,a=null;else if(o&&typeof o=="object")c=o,o=a=null;else c=fr;else if(typeof c!="object")throw Error(i+"Argument not an object: "+c);if(_=f.toFixed(o,a),f.c){var p,E=_.split("."),l=+c.groupSize,d=+c.secondaryGroupSize,m=c.groupSeparator||"",g=E[0],T=E[1],R=f.s<0,P=R?g.slice(1):g,L=P.length;if(d)p=l,l=d,d=p,L-=p;if(l>0&&L>0){p=L%l||l,g=P.substr(0,p);for(;p<L;p+=l)g+=m+P.substr(p,l);if(d>0)g+=m+P.slice(p);if(R)g="-"+g}_=T?g+(c.decimalSeparator||"")+((d=+c.fractionGroupSize)?T.replace(new RegExp("\\d{"+d+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):T):g}return(c.prefix||"")+_+(c.suffix||"")},C.toFraction=function(o){var a,c,_,f,p,E,l,d,m,g,T,R,P=this,L=P.c;if(o!=null){if(l=new v(o),!l.isInteger()&&(l.c||l.s!==1)||l.lt(ne))throw Error(i+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+je(l))}if(!L)return new v(P);a=new v(ne),m=c=new v(ne),_=d=new v(ne),R=x(L),p=a.e=R.length-P.e-1,a.c[0]=A[(E=p%y)<0?y+E:E],o=!o||l.comparedTo(a)>0?p>0?a:m:l,E=Se,Se=1/0,l=new v(R),d.c[0]=0;for(;;){if(g=D(l,a,0,1),f=c.plus(g.times(_)),f.comparedTo(o)==1)break;c=_,_=f,m=d.plus(g.times(f=m)),d=f,a=l.minus(g.times(f=a)),l=f}return f=D(o.minus(c),_,0,1),d=d.plus(f.times(m)),c=c.plus(f.times(_)),d.s=m.s=P.s,p=p*2,T=D(m,_,p,Z).minus(P).abs().comparedTo(D(d,c,p,Z).minus(P).abs())<1?[m,_]:[d,c],Se=E,T},C.toNumber=function(){return+je(this)},C.toPrecision=function(o,a){if(o!=null)b(o,1,N);return pr(this,o,a,2)},C.toString=function(o){var a,c=this,_=c.s,f=c.e;if(f===null)if(_){if(a="Infinity",_<0)a="-"+a}else a="NaN";else{if(o==null)a=f<=he||f>=fe?re(x(c.c),f):ce(x(c.c),f,"0");else if(o===10&&dr)c=ye(new v(c),Q+f+1,Z),a=ce(x(c.c),c.e,"0");else b(o,2,Ve.length,"Base"),a=B(ce(x(c.c),f,"0"),10,o,_,!0);if(_<0&&c.c[0])a="-"+a}return a},C.valueOf=C.toJSON=function(){return je(this)},C._isBigNumber=!0,U!=null)v.set(U);return v}function W(U){var D=U|0;return U>0||U===D?D:D-1}function x(U){var D,B,X=1,C=U.length,ne=U[0]+"";for(;X<C;){D=U[X++]+"",B=y-D.length;for(;B--;D="0"+D);ne+=D}for(C=ne.length;ne.charCodeAt(--C)===48;);return ne.slice(0,C+1||1)}function j(U,D){var B,X,C=U.c,ne=D.c,Q=U.s,Z=D.s,he=U.e,fe=D.e;if(!Q||!Z)return null;if(B=C&&!C[0],X=ne&&!ne[0],B||X)return B?X?0:-Z:Q;if(Q!=Z)return Q;if(B=Q<0,X=he==fe,!C||!ne)return X?0:!C^B?1:-1;if(!X)return he>fe^B?1:-1;Z=(he=C.length)<(fe=ne.length)?he:fe;for(Q=0;Q<Z;Q++)if(C[Q]!=ne[Q])return C[Q]>ne[Q]^B?1:-1;return he==fe?0:he>fe^B?1:-1}function b(U,D,B,X){if(U<D||U>B||U!==s(U))throw Error(i+(X||"Argument")+(typeof U=="number"?U<D||U>B?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function K(U){var D=U.c.length-1;return W(U.e/y)==D&&U.c[D]%2!=0}function re(U,D){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(D<0?"e":"e+")+D}function ce(U,D,B){var X,C;if(D<0){for(C=B+".";++D;C+=B);U=C+U}else if(X=U.length,++D>X){for(C=B,D-=X;--D;C+=B);U+=C}else if(D<X)U=U.slice(0,D)+"."+U.slice(D);return U}if(t=F(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd)define(function(){return t});else if(typeof jt<"u"&&jt.exports)jt.exports=t;else{if(!e)e=typeof self<"u"&&self?self:window;e.BigNumber=t}})(bs)});var Ps=w(function(cg,Ns){var xs=Or(),Rs=cg;(function(){function e(S){return S<10?"0"+S:S}var t=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,s,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':"\\\"","\\":"\\\\"},u;function h(S){return r.lastIndex=0,r.test(S)?'"'+S.replace(r,function(A){var k=i[A];return typeof k==="string"?k:"\\u"+("0000"+A.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+S+'"'}function y(S,A){var k,N,F,W,x=n,j,b=A[S],K=b!=null&&(b instanceof xs||xs.isBigNumber(b));if(b&&typeof b==="object"&&typeof b.toJSON==="function")b=b.toJSON(S);if(typeof u==="function")b=u.call(A,S,b);switch(typeof b){case"string":if(K)return b;else return h(b);case"number":return isFinite(b)?String(b):"null";case"boolean":case"null":case"bigint":return String(b);case"object":if(!b)return"null";if(n+=s,j=[],Object.prototype.toString.apply(b)==="[object Array]"){W=b.length;for(k=0;k<W;k+=1)j[k]=y(k,b)||"null";return F=j.length===0?"[]":n?`[
7
+ `}yield r}static#i;static#o;static async#a(){return this.#i||=(await import("./chunk-k97axrc4.js").then((m)=>H(m.default))).HttpsProxyAgent,this.#i}static async#c(){let e=typeof window<"u"&&!!window;return this.#o||=e?window.fetch:(await import("node-fetch")).default,this.#o}static mergeHeaders(e,...t){e=e instanceof Headers?e:new Headers(e);for(let r of t)(r instanceof Headers?r:new Headers(r)).forEach((s,i)=>{i==="set-cookie"?e.append(i,s):e.set(i,s)});return e}}et.Gaxios=Cr;Ze=Cr});var ie=w(function(le){var Iu=le&&le.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),ju=le&&le.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Iu(t,e,r)};Object.defineProperty(le,"__esModule",{value:!0});le.instance=le.Gaxios=le.GaxiosError=void 0;le.request=Uu;var ks=Os();Object.defineProperty(le,"Gaxios",{enumerable:!0,get:function(){return ks.Gaxios}});var Du=vr();Object.defineProperty(le,"GaxiosError",{enumerable:!0,get:function(){return Du.GaxiosError}});ju(Sr(),le);le.instance=new ks.Gaxios;async function Uu(e){return le.instance.request(e)}});var Or=w(function(bs,jt){(function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,{ceil:n,floor:s}=Math,i="[BigNumber Error] ",u=i+"Number primitive has more than 15 significant digits: ",h=100000000000000,y=14,S=9007199254740991,A=[1,10,100,1000,1e4,1e5,1e6,1e7,1e8,1e9,10000000000,100000000000,1000000000000,10000000000000],k=1e7,N=1e9;function F(U){var D,B,X,C=v.prototype={constructor:v,toString:null,valueOf:null},ne=new v(1),Q=20,Z=4,he=-7,fe=21,Ke=-1e7,Se=1e7,Je=!1,ft=1,Le=0,fr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Ve="0123456789abcdefghijklmnopqrstuvwxyz",dr=!0;function v(o,a){var c,_,f,p,E,l,d,m,g=this;if(!(g instanceof v))return new v(o,a);if(a==null){if(o&&o._isBigNumber===!0){if(g.s=o.s,!o.c||o.e>Se)g.c=g.e=null;else if(o.e<Ke)g.c=[g.e=0];else g.e=o.e,g.c=o.c.slice();return}if((l=typeof o=="number")&&o*0==0){if(g.s=1/o<0?(o=-o,-1):1,o===~~o){for(p=0,E=o;E>=10;E/=10,p++);if(p>Se)g.c=g.e=null;else g.e=p,g.c=[o];return}m=String(o)}else{if(!r.test(m=String(o)))return X(g,m,l);g.s=m.charCodeAt(0)==45?(m=m.slice(1),-1):1}if((p=m.indexOf("."))>-1)m=m.replace(".","");if((E=m.search(/e/i))>0){if(p<0)p=E;p+=+m.slice(E+1),m=m.substring(0,E)}else if(p<0)p=m.length}else{if(b(a,2,Ve.length,"Base"),a==10&&dr)return g=new v(o),ye(g,Q+g.e+1,Z);if(m=String(o),l=typeof o=="number"){if(o*0!=0)return X(g,m,l,a);if(g.s=1/o<0?(m=m.slice(1),-1):1,v.DEBUG&&m.replace(/^0\.0*|\./,"").length>15)throw Error(u+o)}else g.s=m.charCodeAt(0)===45?(m=m.slice(1),-1):1;c=Ve.slice(0,a),p=E=0;for(d=m.length;E<d;E++)if(c.indexOf(_=m.charAt(E))<0){if(_=="."){if(E>p){p=d;continue}}else if(!f){if(m==m.toUpperCase()&&(m=m.toLowerCase())||m==m.toLowerCase()&&(m=m.toUpperCase())){f=!0,E=-1,p=0;continue}}return X(g,String(o),l,a)}if(l=!1,m=B(m,a,10,g.s),(p=m.indexOf("."))>-1)m=m.replace(".","");else p=m.length}for(E=0;m.charCodeAt(E)===48;E++);for(d=m.length;m.charCodeAt(--d)===48;);if(m=m.slice(E,++d)){if(d-=E,l&&v.DEBUG&&d>15&&(o>S||o!==s(o)))throw Error(u+g.s*o);if((p=p-E-1)>Se)g.c=g.e=null;else if(p<Ke)g.c=[g.e=0];else{if(g.e=p,g.c=[],E=(p+1)%y,p<0)E+=y;if(E<d){if(E)g.c.push(+m.slice(0,E));for(d-=y;E<d;)g.c.push(+m.slice(E,E+=y));E=y-(m=m.slice(E)).length}else E-=d;for(;E--;m+="0");g.c.push(+m)}}else g.c=[g.e=0]}v.clone=F,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(o){var a,c;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(a="DECIMAL_PLACES"))c=o[a],b(c,0,N,a),Q=c;if(o.hasOwnProperty(a="ROUNDING_MODE"))c=o[a],b(c,0,8,a),Z=c;if(o.hasOwnProperty(a="EXPONENTIAL_AT"))if(c=o[a],c&&c.pop)b(c[0],-N,0,a),b(c[1],0,N,a),he=c[0],fe=c[1];else b(c,-N,N,a),he=-(fe=c<0?-c:c);if(o.hasOwnProperty(a="RANGE"))if(c=o[a],c&&c.pop)b(c[0],-N,-1,a),b(c[1],1,N,a),Ke=c[0],Se=c[1];else if(b(c,-N,N,a),c)Ke=-(Se=c<0?-c:c);else throw Error(i+a+" cannot be zero: "+c);if(o.hasOwnProperty(a="CRYPTO"))if(c=o[a],c===!!c)if(c)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Je=c;else throw Je=!c,Error(i+"crypto unavailable");else Je=c;else throw Error(i+a+" not true or false: "+c);if(o.hasOwnProperty(a="MODULO_MODE"))c=o[a],b(c,0,9,a),ft=c;if(o.hasOwnProperty(a="POW_PRECISION"))c=o[a],b(c,0,N,a),Le=c;if(o.hasOwnProperty(a="FORMAT"))if(c=o[a],typeof c=="object")fr=c;else throw Error(i+a+" not an object: "+c);if(o.hasOwnProperty(a="ALPHABET"))if(c=o[a],typeof c=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(c))dr=c.slice(0,10)=="0123456789",Ve=c;else throw Error(i+a+" invalid: "+c)}else throw Error(i+"Object expected: "+o);return{DECIMAL_PLACES:Q,ROUNDING_MODE:Z,EXPONENTIAL_AT:[he,fe],RANGE:[Ke,Se],CRYPTO:Je,MODULO_MODE:ft,POW_PRECISION:Le,FORMAT:fr,ALPHABET:Ve}},v.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var a,c,{c:_,e:f,s:p}=o;e:if({}.toString.call(_)=="[object Array]"){if((p===1||p===-1)&&f>=-N&&f<=N&&f===s(f)){if(_[0]===0){if(f===0&&_.length===1)return!0;break e}if(a=(f+1)%y,a<1)a+=y;if(String(_[0]).length==a){for(a=0;a<_.length;a++)if(c=_[a],c<0||c>=h||c!==s(c))break e;if(c!==0)return!0}}}else if(_===null&&f===null&&(p===null||p===1||p===-1))return!0;throw Error(i+"Invalid BigNumber: "+o)},v.maximum=v.max=function(){return Qn(arguments,-1)},v.minimum=v.min=function(){return Qn(arguments,1)},v.random=function(){var o=9007199254740992,a=Math.random()*o&2097151?function(){return s(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(c){var _,f,p,E,l,d=0,m=[],g=new v(ne);if(c==null)c=Q;else b(c,0,N);if(E=n(c/y),Je)if(crypto.getRandomValues){_=crypto.getRandomValues(new Uint32Array(E*=2));for(;d<E;)if(l=_[d]*131072+(_[d+1]>>>11),l>=9000000000000000)f=crypto.getRandomValues(new Uint32Array(2)),_[d]=f[0],_[d+1]=f[1];else m.push(l%100000000000000),d+=2;d=E/2}else if(crypto.randomBytes){_=crypto.randomBytes(E*=7);for(;d<E;)if(l=(_[d]&31)*281474976710656+_[d+1]*1099511627776+_[d+2]*4294967296+_[d+3]*16777216+(_[d+4]<<16)+(_[d+5]<<8)+_[d+6],l>=9000000000000000)crypto.randomBytes(7).copy(_,d);else m.push(l%100000000000000),d+=7;d=E/7}else throw Je=!1,Error(i+"crypto unavailable");if(!Je){for(;d<E;)if(l=a(),l<9000000000000000)m[d++]=l%100000000000000}if(E=m[--d],c%=y,E&&c)l=A[y-c],m[d]=s(E/l)*l;for(;m[d]===0;m.pop(),d--);if(d<0)m=[p=0];else{for(p=-1;m[0]===0;m.splice(0,1),p-=y);for(d=1,l=m[0];l>=10;l/=10,d++);if(d<y)p-=y-d}return g.e=p,g.c=m,g}}(),v.sum=function(){var o=1,a=arguments,c=new v(a[0]);for(;o<a.length;)c=c.plus(a[o++]);return c},B=function(){var o="0123456789";function a(c,_,f,p){var E,l=[0],d,m=0,g=c.length;for(;m<g;){for(d=l.length;d--;l[d]*=_);l[0]+=p.indexOf(c.charAt(m++));for(E=0;E<l.length;E++)if(l[E]>f-1){if(l[E+1]==null)l[E+1]=0;l[E+1]+=l[E]/f|0,l[E]%=f}}return l.reverse()}return function(c,_,f,p,E){var l,d,m,g,T,R,P,L,ee=c.indexOf("."),se=Q,M=Z;if(ee>=0)g=Le,Le=0,c=c.replace(".",""),L=new v(_),R=L.pow(c.length-ee),Le=g,L.c=a(ce(x(R.c),R.e,"0"),10,f,o),L.e=L.c.length;P=a(c,_,f,E?(l=Ve,o):(l=o,Ve)),m=g=P.length;for(;P[--g]==0;P.pop());if(!P[0])return l.charAt(0);if(ee<0)--m;else R.c=P,R.e=m,R.s=p,R=D(R,L,se,M,f),P=R.c,T=R.r,m=R.e;if(d=m+se+1,ee=P[d],g=f/2,T=T||d<0||P[d+1]!=null,T=M<4?(ee!=null||T)&&(M==0||M==(R.s<0?3:2)):ee>g||ee==g&&(M==4||T||M==6&&P[d-1]&1||M==(R.s<0?8:7)),d<1||!P[0])c=T?ce(l.charAt(1),-se,l.charAt(0)):l.charAt(0);else{if(P.length=d,T){for(--f;++P[--d]>f;)if(P[d]=0,!d)++m,P=[1].concat(P)}for(g=P.length;!P[--g];);for(ee=0,c="";ee<=g;c+=l.charAt(P[ee++]));c=ce(c,m,l.charAt(0))}return c}}(),D=function(){function o(_,f,p){var E,l,d,m,g=0,T=_.length,R=f%k,P=f/k|0;for(_=_.slice();T--;)d=_[T]%k,m=_[T]/k|0,E=P*d+m*R,l=R*d+E%k*k+g,g=(l/p|0)+(E/k|0)+P*m,_[T]=l%p;if(g)_=[g].concat(_);return _}function a(_,f,p,E){var l,d;if(p!=E)d=p>E?1:-1;else for(l=d=0;l<p;l++)if(_[l]!=f[l]){d=_[l]>f[l]?1:-1;break}return d}function c(_,f,p,E){var l=0;for(;p--;)_[p]-=l,l=_[p]<f[p]?1:0,_[p]=l*E+_[p]-f[p];for(;!_[0]&&_.length>1;_.splice(0,1));}return function(_,f,p,E,l){var d,m,g,T,R,P,L,ee,se,M,J,ae,Nt,_r,yr,Re,dt,me=_.s==f.s?1:-1,ue=_.c,te=f.c;if(!ue||!ue[0]||!te||!te[0])return new v(!_.s||!f.s||(ue?te&&ue[0]==te[0]:!te)?NaN:ue&&ue[0]==0||!te?me*0:me/0);if(ee=new v(me),se=ee.c=[],m=_.e-f.e,me=p+m+1,!l)l=h,m=W(_.e/y)-W(f.e/y),me=me/y|0;for(g=0;te[g]==(ue[g]||0);g++);if(te[g]>(ue[g]||0))m--;if(me<0)se.push(1),T=!0;else{if(_r=ue.length,Re=te.length,g=0,me+=2,R=s(l/(te[0]+1)),R>1)te=o(te,R,l),ue=o(ue,R,l),Re=te.length,_r=ue.length;Nt=Re,M=ue.slice(0,Re),J=M.length;for(;J<Re;M[J++]=0);if(dt=te.slice(),dt=[0].concat(dt),yr=te[0],te[1]>=l/2)yr++;do{if(R=0,d=a(te,M,Re,J),d<0){if(ae=M[0],Re!=J)ae=ae*l+(M[1]||0);if(R=s(ae/yr),R>1){if(R>=l)R=l-1;P=o(te,R,l),L=P.length,J=M.length;while(a(P,M,L,J)==1)R--,c(P,Re<L?dt:te,L,l),L=P.length,d=1}else{if(R==0)d=R=1;P=te.slice(),L=P.length}if(L<J)P=[0].concat(P);if(c(M,P,J,l),J=M.length,d==-1)while(a(te,M,Re,J)<1)R++,c(M,Re<J?dt:te,J,l),J=M.length}else if(d===0)R++,M=[0];if(se[g++]=R,M[0])M[J++]=ue[Nt]||0;else M=[ue[Nt]],J=1}while((Nt++<_r||M[0]!=null)&&me--);if(T=M[0]!=null,!se[0])se.splice(0,1)}if(l==h){for(g=1,me=se[0];me>=10;me/=10,g++);ye(ee,p+(ee.e=g+m*y-1)+1,E,T)}else ee.e=m,ee.r=+T;return ee}}();function pr(o,a,c,_){var f,p,E,l,d;if(c==null)c=Z;else b(c,0,8);if(!o.c)return o.toString();if(f=o.c[0],E=o.e,a==null)d=x(o.c),d=_==1||_==2&&(E<=he||E>=fe)?re(d,E):ce(d,E,"0");else if(o=ye(new v(o),a,c),p=o.e,d=x(o.c),l=d.length,_==1||_==2&&(a<=p||p<=he)){for(;l<a;d+="0",l++);d=re(d,p)}else if(a-=E+(_===2&&p>E),d=ce(d,p,"0"),p+1>l){if(--a>0)for(d+=".";a--;d+="0");}else if(a+=p-l,a>0){if(p+1==l)d+=".";for(;a--;d+="0");}return o.s<0&&f?"-"+d:d}function Qn(o,a){var c,_,f=1,p=new v(o[0]);for(;f<o.length;f++)if(_=new v(o[f]),!_.s||(c=j(p,_))===a||c===0&&p.s===a)p=_;return p}function gr(o,a,c){var _=1,f=a.length;for(;!a[--f];a.pop());for(f=a[0];f>=10;f/=10,_++);if((c=_+c*y-1)>Se)o.c=o.e=null;else if(c<Ke)o.c=[o.e=0];else o.e=c,o.c=a;return o}X=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,a=/^([^.]+)\.$/,c=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(p,E,l,d){var m,g=l?E:E.replace(f,"");if(_.test(g))p.s=isNaN(g)?null:g<0?-1:1;else{if(!l){if(g=g.replace(o,function(T,R,P){return m=(P=P.toLowerCase())=="x"?16:P=="b"?2:8,!d||d==m?R:T}),d)m=d,g=g.replace(a,"$1").replace(c,"0.$1");if(E!=g)return new v(g,m)}if(v.DEBUG)throw Error(i+"Not a"+(d?" base "+d:"")+" number: "+E);p.s=null}p.c=p.e=null}}();function ye(o,a,c,_){var f,p,E,l,d,m,g,T=o.c,R=A;if(T){e:{for(f=1,l=T[0];l>=10;l/=10,f++);if(p=a-f,p<0)p+=y,E=a,d=T[m=0],g=s(d/R[f-E-1]%10);else if(m=n((p+1)/y),m>=T.length)if(_){for(;T.length<=m;T.push(0));d=g=0,f=1,p%=y,E=p-y+1}else break e;else{d=l=T[m];for(f=1;l>=10;l/=10,f++);p%=y,E=p-y+f,g=E<0?0:s(d/R[f-E-1]%10)}if(_=_||a<0||T[m+1]!=null||(E<0?d:d%R[f-E-1]),_=c<4?(g||_)&&(c==0||c==(o.s<0?3:2)):g>5||g==5&&(c==4||_||c==6&&(p>0?E>0?d/R[f-E]:0:T[m-1])%10&1||c==(o.s<0?8:7)),a<1||!T[0]){if(T.length=0,_)a-=o.e+1,T[0]=R[(y-a%y)%y],o.e=-a||0;else T[0]=o.e=0;return o}if(p==0)T.length=m,l=1,m--;else T.length=m+1,l=R[y-p],T[m]=E>0?s(d/R[f-E]%R[E])*l:0;if(_)for(;;)if(m==0){for(p=1,E=T[0];E>=10;E/=10,p++);E=T[0]+=l;for(l=1;E>=10;E/=10,l++);if(p!=l){if(o.e++,T[0]==h)T[0]=1}break}else{if(T[m]+=l,T[m]!=h)break;T[m--]=0,l=1}for(p=T.length;T[--p]===0;T.pop());}if(o.e>Se)o.c=o.e=null;else if(o.e<Ke)o.c=[o.e=0]}return o}function je(o){var a,c=o.e;if(c===null)return o.toString();return a=x(o.c),a=c<=he||c>=fe?re(a,c):ce(a,c,"0"),o.s<0?"-"+a:a}if(C.absoluteValue=C.abs=function(){var o=new v(this);if(o.s<0)o.s=1;return o},C.comparedTo=function(o,a){return j(this,new v(o,a))},C.decimalPlaces=C.dp=function(o,a){var c,_,f,p=this;if(o!=null){if(b(o,0,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o+p.e+1,a)}if(!(c=p.c))return null;if(_=((f=c.length-1)-W(this.e/y))*y,f=c[f])for(;f%10==0;f/=10,_--);if(_<0)_=0;return _},C.dividedBy=C.div=function(o,a){return D(this,new v(o,a),Q,Z)},C.dividedToIntegerBy=C.idiv=function(o,a){return D(this,new v(o,a),0,1)},C.exponentiatedBy=C.pow=function(o,a){var c,_,f,p,E,l,d,m,g,T=this;if(o=new v(o),o.c&&!o.isInteger())throw Error(i+"Exponent not an integer: "+je(o));if(a!=null)a=new v(a);if(l=o.e>14,!T.c||!T.c[0]||T.c[0]==1&&!T.e&&T.c.length==1||!o.c||!o.c[0])return g=new v(Math.pow(+je(T),l?o.s*(2-K(o)):+je(o))),a?g.mod(a):g;if(d=o.s<0,a){if(a.c?!a.c[0]:!a.s)return new v(NaN);if(_=!d&&T.isInteger()&&a.isInteger(),_)T=T.mod(a)}else if(o.e>9&&(T.e>0||T.e<-1||(T.e==0?T.c[0]>1||l&&T.c[1]>=240000000:T.c[0]<80000000000000||l&&T.c[0]<=99999750000000))){if(p=T.s<0&&K(o)?-0:0,T.e>-1)p=1/p;return new v(d?1/p:p)}else if(Le)p=n(Le/y+2);if(l){if(c=new v(0.5),d)o.s=1;m=K(o)}else f=Math.abs(+je(o)),m=f%2;g=new v(ne);for(;;){if(m){if(g=g.times(T),!g.c)break;if(p){if(g.c.length>p)g.c.length=p}else if(_)g=g.mod(a)}if(f){if(f=s(f/2),f===0)break;m=f%2}else if(o=o.times(c),ye(o,o.e+1,1),o.e>14)m=K(o);else{if(f=+je(o),f===0)break;m=f%2}if(T=T.times(T),p){if(T.c&&T.c.length>p)T.c.length=p}else if(_)T=T.mod(a)}if(_)return g;if(d)g=ne.div(g);return a?g.mod(a):p?ye(g,Le,Z,E):g},C.integerValue=function(o){var a=new v(this);if(o==null)o=Z;else b(o,0,8);return ye(a,a.e+1,o)},C.isEqualTo=C.eq=function(o,a){return j(this,new v(o,a))===0},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(o,a){return j(this,new v(o,a))>0},C.isGreaterThanOrEqualTo=C.gte=function(o,a){return(a=j(this,new v(o,a)))===1||a===0},C.isInteger=function(){return!!this.c&&W(this.e/y)>this.c.length-2},C.isLessThan=C.lt=function(o,a){return j(this,new v(o,a))<0},C.isLessThanOrEqualTo=C.lte=function(o,a){return(a=j(this,new v(o,a)))===-1||a===0},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&this.c[0]==0},C.minus=function(o,a){var c,_,f,p,E=this,l=E.s;if(o=new v(o,a),a=o.s,!l||!a)return new v(NaN);if(l!=a)return o.s=-a,E.plus(o);var d=E.e/y,m=o.e/y,g=E.c,T=o.c;if(!d||!m){if(!g||!T)return g?(o.s=-a,o):new v(T?E:NaN);if(!g[0]||!T[0])return T[0]?(o.s=-a,o):new v(g[0]?E:Z==3?-0:0)}if(d=W(d),m=W(m),g=g.slice(),l=d-m){if(p=l<0)l=-l,f=g;else m=d,f=T;f.reverse();for(a=l;a--;f.push(0));f.reverse()}else{_=(p=(l=g.length)<(a=T.length))?l:a;for(l=a=0;a<_;a++)if(g[a]!=T[a]){p=g[a]<T[a];break}}if(p)f=g,g=T,T=f,o.s=-o.s;if(a=(_=T.length)-(c=g.length),a>0)for(;a--;g[c++]=0);a=h-1;for(;_>l;){if(g[--_]<T[_]){for(c=_;c&&!g[--c];g[c]=a);--g[c],g[_]+=h}g[_]-=T[_]}for(;g[0]==0;g.splice(0,1),--m);if(!g[0])return o.s=Z==3?-1:1,o.c=[o.e=0],o;return gr(o,g,m)},C.modulo=C.mod=function(o,a){var c,_,f=this;if(o=new v(o,a),!f.c||!o.s||o.c&&!o.c[0])return new v(NaN);else if(!o.c||f.c&&!f.c[0])return new v(f);if(ft==9)_=o.s,o.s=1,c=D(f,o,0,3),o.s=_,c.s*=_;else c=D(f,o,0,ft);if(o=f.minus(c.times(o)),!o.c[0]&&ft==1)o.s=f.s;return o},C.multipliedBy=C.times=function(o,a){var c,_,f,p,E,l,d,m,g,T,R,P,L,ee,se,M=this,J=M.c,ae=(o=new v(o,a)).c;if(!J||!ae||!J[0]||!ae[0]){if(!M.s||!o.s||J&&!J[0]&&!ae||ae&&!ae[0]&&!J)o.c=o.e=o.s=null;else if(o.s*=M.s,!J||!ae)o.c=o.e=null;else o.c=[0],o.e=0;return o}if(_=W(M.e/y)+W(o.e/y),o.s*=M.s,d=J.length,T=ae.length,d<T)L=J,J=ae,ae=L,f=d,d=T,T=f;for(f=d+T,L=[];f--;L.push(0));ee=h,se=k;for(f=T;--f>=0;){c=0,R=ae[f]%se,P=ae[f]/se|0;for(E=d,p=f+E;p>f;)m=J[--E]%se,g=J[E]/se|0,l=P*m+g*R,m=R*m+l%se*se+L[p]+c,c=(m/ee|0)+(l/se|0)+P*g,L[p--]=m%ee;L[p]=c}if(c)++_;else L.splice(0,1);return gr(o,L,_)},C.negated=function(){var o=new v(this);return o.s=-o.s||null,o},C.plus=function(o,a){var c,_=this,f=_.s;if(o=new v(o,a),a=o.s,!f||!a)return new v(NaN);if(f!=a)return o.s=-a,_.minus(o);var p=_.e/y,E=o.e/y,l=_.c,d=o.c;if(!p||!E){if(!l||!d)return new v(f/0);if(!l[0]||!d[0])return d[0]?o:new v(l[0]?_:f*0)}if(p=W(p),E=W(E),l=l.slice(),f=p-E){if(f>0)E=p,c=d;else f=-f,c=l;c.reverse();for(;f--;c.push(0));c.reverse()}if(f=l.length,a=d.length,f-a<0)c=d,d=l,l=c,a=f;for(f=0;a;)f=(l[--a]=l[a]+d[a]+f)/h|0,l[a]=h===l[a]?0:l[a]%h;if(f)l=[f].concat(l),++E;return gr(o,l,E)},C.precision=C.sd=function(o,a){var c,_,f,p=this;if(o!=null&&o!==!!o){if(b(o,1,N),a==null)a=Z;else b(a,0,8);return ye(new v(p),o,a)}if(!(c=p.c))return null;if(f=c.length-1,_=f*y+1,f=c[f]){for(;f%10==0;f/=10,_--);for(f=c[0];f>=10;f/=10,_++);}if(o&&p.e+1>_)_=p.e+1;return _},C.shiftedBy=function(o){return b(o,-S,S),this.times("1e"+o)},C.squareRoot=C.sqrt=function(){var o,a,c,_,f,p=this,{c:E,s:l,e:d}=p,m=Q+4,g=new v("0.5");if(l!==1||!E||!E[0])return new v(!l||l<0&&(!E||E[0])?NaN:E?p:1/0);if(l=Math.sqrt(+je(p)),l==0||l==1/0){if(a=x(E),(a.length+d)%2==0)a+="0";if(l=Math.sqrt(+a),d=W((d+1)/2)-(d<0||d%2),l==1/0)a="5e"+d;else a=l.toExponential(),a=a.slice(0,a.indexOf("e")+1)+d;c=new v(a)}else c=new v(l+"");if(c.c[0]){if(d=c.e,l=d+m,l<3)l=0;for(;;)if(f=c,c=g.times(f.plus(D(p,f,m,1))),x(f.c).slice(0,l)===(a=x(c.c)).slice(0,l)){if(c.e<d)--l;if(a=a.slice(l-3,l+1),a=="9999"||!_&&a=="4999"){if(!_){if(ye(f,f.e+Q+2,0),f.times(f).eq(p)){c=f;break}}m+=4,l+=4,_=1}else{if(!+a||!+a.slice(1)&&a.charAt(0)=="5")ye(c,c.e+Q+2,1),o=!c.times(c).eq(p);break}}}return ye(c,c.e+Q+1,Z,o)},C.toExponential=function(o,a){if(o!=null)b(o,0,N),o++;return pr(this,o,a,1)},C.toFixed=function(o,a){if(o!=null)b(o,0,N),o=o+this.e+1;return pr(this,o,a)},C.toFormat=function(o,a,c){var _,f=this;if(c==null)if(o!=null&&a&&typeof a=="object")c=a,a=null;else if(o&&typeof o=="object")c=o,o=a=null;else c=fr;else if(typeof c!="object")throw Error(i+"Argument not an object: "+c);if(_=f.toFixed(o,a),f.c){var p,E=_.split("."),l=+c.groupSize,d=+c.secondaryGroupSize,m=c.groupSeparator||"",g=E[0],T=E[1],R=f.s<0,P=R?g.slice(1):g,L=P.length;if(d)p=l,l=d,d=p,L-=p;if(l>0&&L>0){p=L%l||l,g=P.substr(0,p);for(;p<L;p+=l)g+=m+P.substr(p,l);if(d>0)g+=m+P.slice(p);if(R)g="-"+g}_=T?g+(c.decimalSeparator||"")+((d=+c.fractionGroupSize)?T.replace(new RegExp("\\d{"+d+"}\\B","g"),"$&"+(c.fractionGroupSeparator||"")):T):g}return(c.prefix||"")+_+(c.suffix||"")},C.toFraction=function(o){var a,c,_,f,p,E,l,d,m,g,T,R,P=this,L=P.c;if(o!=null){if(l=new v(o),!l.isInteger()&&(l.c||l.s!==1)||l.lt(ne))throw Error(i+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+je(l))}if(!L)return new v(P);a=new v(ne),m=c=new v(ne),_=d=new v(ne),R=x(L),p=a.e=R.length-P.e-1,a.c[0]=A[(E=p%y)<0?y+E:E],o=!o||l.comparedTo(a)>0?p>0?a:m:l,E=Se,Se=1/0,l=new v(R),d.c[0]=0;for(;;){if(g=D(l,a,0,1),f=c.plus(g.times(_)),f.comparedTo(o)==1)break;c=_,_=f,m=d.plus(g.times(f=m)),d=f,a=l.minus(g.times(f=a)),l=f}return f=D(o.minus(c),_,0,1),d=d.plus(f.times(m)),c=c.plus(f.times(_)),d.s=m.s=P.s,p=p*2,T=D(m,_,p,Z).minus(P).abs().comparedTo(D(d,c,p,Z).minus(P).abs())<1?[m,_]:[d,c],Se=E,T},C.toNumber=function(){return+je(this)},C.toPrecision=function(o,a){if(o!=null)b(o,1,N);return pr(this,o,a,2)},C.toString=function(o){var a,c=this,_=c.s,f=c.e;if(f===null)if(_){if(a="Infinity",_<0)a="-"+a}else a="NaN";else{if(o==null)a=f<=he||f>=fe?re(x(c.c),f):ce(x(c.c),f,"0");else if(o===10&&dr)c=ye(new v(c),Q+f+1,Z),a=ce(x(c.c),c.e,"0");else b(o,2,Ve.length,"Base"),a=B(ce(x(c.c),f,"0"),10,o,_,!0);if(_<0&&c.c[0])a="-"+a}return a},C.valueOf=C.toJSON=function(){return je(this)},C._isBigNumber=!0,U!=null)v.set(U);return v}function W(U){var D=U|0;return U>0||U===D?D:D-1}function x(U){var D,B,X=1,C=U.length,ne=U[0]+"";for(;X<C;){D=U[X++]+"",B=y-D.length;for(;B--;D="0"+D);ne+=D}for(C=ne.length;ne.charCodeAt(--C)===48;);return ne.slice(0,C+1||1)}function j(U,D){var B,X,C=U.c,ne=D.c,Q=U.s,Z=D.s,he=U.e,fe=D.e;if(!Q||!Z)return null;if(B=C&&!C[0],X=ne&&!ne[0],B||X)return B?X?0:-Z:Q;if(Q!=Z)return Q;if(B=Q<0,X=he==fe,!C||!ne)return X?0:!C^B?1:-1;if(!X)return he>fe^B?1:-1;Z=(he=C.length)<(fe=ne.length)?he:fe;for(Q=0;Q<Z;Q++)if(C[Q]!=ne[Q])return C[Q]>ne[Q]^B?1:-1;return he==fe?0:he>fe^B?1:-1}function b(U,D,B,X){if(U<D||U>B||U!==s(U))throw Error(i+(X||"Argument")+(typeof U=="number"?U<D||U>B?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function K(U){var D=U.c.length-1;return W(U.e/y)==D&&U.c[D]%2!=0}function re(U,D){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(D<0?"e":"e+")+D}function ce(U,D,B){var X,C;if(D<0){for(C=B+".";++D;C+=B);U=C+U}else if(X=U.length,++D>X){for(C=B,D-=X;--D;C+=B);U+=C}else if(D<X)U=U.slice(0,D)+"."+U.slice(D);return U}if(t=F(),t.default=t.BigNumber=t,typeof define=="function"&&define.amd)define(function(){return t});else if(typeof jt<"u"&&jt.exports)jt.exports=t;else{if(!e)e=typeof self<"u"&&self?self:window;e.BigNumber=t}})(bs)});var Ps=w(function(cg,Ns){var xs=Or(),Rs=cg;(function(){function e(S){return S<10?"0"+S:S}var t=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,s,i={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':"\\\"","\\":"\\\\"},u;function h(S){return r.lastIndex=0,r.test(S)?'"'+S.replace(r,function(A){var k=i[A];return typeof k==="string"?k:"\\u"+("0000"+A.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+S+'"'}function y(S,A){var k,N,F,W,x=n,j,b=A[S],K=b!=null&&(b instanceof xs||xs.isBigNumber(b));if(b&&typeof b==="object"&&typeof b.toJSON==="function")b=b.toJSON(S);if(typeof u==="function")b=u.call(A,S,b);switch(typeof b){case"string":if(K)return b;else return h(b);case"number":return isFinite(b)?String(b):"null";case"boolean":case"null":case"bigint":return String(b);case"object":if(!b)return"null";if(n+=s,j=[],Object.prototype.toString.apply(b)==="[object Array]"){W=b.length;for(k=0;k<W;k+=1)j[k]=y(k,b)||"null";return F=j.length===0?"[]":n?`[
8
8
  `+n+j.join(`,
9
9
  `+n)+`
10
10
  `+x+"]":"["+j.join(",")+"]",n=x,F}if(u&&typeof u==="object"){W=u.length;for(k=0;k<W;k+=1)if(typeof u[k]==="string"){if(N=u[k],F=y(N,b),F)j.push(h(N)+(n?": ":":")+F)}}else Object.keys(b).forEach(function(re){var ce=y(re,b);if(ce)j.push(h(re)+(n?": ":":")+ce)});return F=j.length===0?"{}":n?`{
@@ -22,11 +22,11 @@ ${A}
22
22
  ${k}`,F=`${u}/${e.region}/${n}/${Dd}`,W=`${sc}
23
23
  ${i}
24
24
  ${F}
25
- `+await e.crypto.sha256DigestHex(N),x=await Ud(e.crypto,e.securityCredentials.secretAccessKey,u,e.region,n),j=await kt(e.crypto,x,W),b=`${sc} Credential=${e.securityCredentials.accessKeyId}/${F}, SignedHeaders=${A}, Signature=${ic.fromArrayBufferToHex(j)}`;return{amzDate:t.has("date")?void 0:i,authorizationHeader:b,canonicalQuerystring:e.canonicalQuerystring}}});var dc=w(function(lc){Object.defineProperty(lc,"__esModule",{value:!0});lc.DefaultAwsSecurityCredentialsSupplier=void 0;var ar=_e();class uc{regionUrl;securityCredentialsUrl;imdsV2SessionTokenUrl;additionalGaxiosOptions;constructor(e){this.regionUrl=e.regionUrl,this.securityCredentialsUrl=e.securityCredentialsUrl,this.imdsV2SessionTokenUrl=e.imdsV2SessionTokenUrl,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getAwsRegion(e){if(this.#n)return this.#n;let t=new Headers;if(!this.#n&&this.imdsV2SessionTokenUrl)t.set("x-aws-ec2-metadata-token",await this.#e(e.transporter));if(!this.regionUrl)throw RangeError('Unable to determine AWS region due to missing "options.credential_source.region_url"');let r={...this.additionalGaxiosOptions,url:this.regionUrl,method:"GET",responseType:"text",headers:t};ar.AuthClient.setMethodName(r,"getAwsRegion");let n=await e.transporter.request(r);return n.data.substr(0,n.data.length-1)}async getAwsSecurityCredentials(e){if(this.#s)return this.#s;let t=new Headers;if(this.imdsV2SessionTokenUrl)t.set("x-aws-ec2-metadata-token",await this.#e(e.transporter));let r=await this.#t(t,e.transporter),n=await this.#r(r,t,e.transporter);return{accessKeyId:n.AccessKeyId,secretAccessKey:n.SecretAccessKey,token:n.Token}}async#e(e){let t={...this.additionalGaxiosOptions,url:this.imdsV2SessionTokenUrl,method:"PUT",responseType:"text",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"300"}};return ar.AuthClient.setMethodName(t,"#getImdsV2SessionToken"),(await e.request(t)).data}async#t(e,t){if(!this.securityCredentialsUrl)throw Error('Unable to determine AWS role name due to missing "options.credential_source.url"');let r={...this.additionalGaxiosOptions,url:this.securityCredentialsUrl,method:"GET",responseType:"text",headers:e};return ar.AuthClient.setMethodName(r,"#getAwsRoleName"),(await t.request(r)).data}async#r(e,t,r){let n={...this.additionalGaxiosOptions,url:`${this.securityCredentialsUrl}/${e}`,headers:t,responseType:"json"};return ar.AuthClient.setMethodName(n,"#retrieveAwsSecurityCredentials"),(await r.request(n)).data}get#n(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||null}get#s(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY)return{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,token:process.env.AWS_SESSION_TOKEN};return null}}lc.DefaultAwsSecurityCredentialsSupplier=uc});var On=w(function(gc){Object.defineProperty(gc,"__esModule",{value:!0});gc.AwsClient=void 0;var Fd=Cn(),Md=$e(),Ld=dc(),pc=Oe(),Gd=ie();class cr extends Md.BaseExternalAccountClient{environmentId;awsSecurityCredentialsSupplier;regionalCredVerificationUrl;awsRequestSigner;region;static#e="https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15";static AWS_EC2_METADATA_IPV4_ADDRESS="169.254.169.254";static AWS_EC2_METADATA_IPV6_ADDRESS="fd00:ec2::254";constructor(e){super(e);let t=pc.originalOrCamelOptions(e),r=t.get("credential_source"),n=t.get("aws_security_credentials_supplier");if(!r&&!n)throw Error("A credential source or AWS security credentials supplier must be specified.");if(r&&n)throw Error("Only one of credential source or AWS security credentials supplier can be specified.");if(n)this.awsSecurityCredentialsSupplier=n,this.regionalCredVerificationUrl=cr.#e,this.credentialSourceType="programmatic";else{let s=pc.originalOrCamelOptions(r);this.environmentId=s.get("environment_id");let i=s.get("region_url"),u=s.get("url"),h=s.get("imdsv2_session_token_url");this.awsSecurityCredentialsSupplier=new Ld.DefaultAwsSecurityCredentialsSupplier({regionUrl:i,securityCredentialsUrl:u,imdsV2SessionTokenUrl:h}),this.regionalCredVerificationUrl=s.get("regional_cred_verification_url"),this.credentialSourceType="aws",this.validateEnvironmentId()}this.awsRequestSigner=null,this.region=""}validateEnvironmentId(){let e=this.environmentId?.match(/^(aws)(\d+)$/);if(!e||!this.regionalCredVerificationUrl)throw Error('No valid AWS "credential_source" provided');else if(parseInt(e[2],10)!==1)throw Error(`aws version "${e[2]}" is not supported in the current build.`)}async retrieveSubjectToken(){if(!this.awsRequestSigner)this.region=await this.awsSecurityCredentialsSupplier.getAwsRegion(this.supplierContext),this.awsRequestSigner=new Fd.AwsRequestSigner(async()=>this.awsSecurityCredentialsSupplier.getAwsSecurityCredentials(this.supplierContext),this.region);let e=await this.awsRequestSigner.getRequestOptions({...cr.RETRY_CONFIG,url:this.regionalCredVerificationUrl.replace("{region}",this.region),method:"POST"}),t=[];return Gd.Gaxios.mergeHeaders({"x-goog-cloud-target-resource":this.audience},e.headers).forEach((n,s)=>t.push({key:s,value:n})),encodeURIComponent(JSON.stringify({url:e.url,method:e.method,headers:t}))}}gc.AwsClient=cr});var jn=w(function(Ec){Object.defineProperty(Ec,"__esModule",{value:!0});Ec.InvalidSubjectTokenError=Ec.InvalidMessageFieldError=Ec.InvalidCodeFieldError=Ec.InvalidTokenTypeFieldError=Ec.InvalidExpirationTimeFieldError=Ec.InvalidSuccessFieldError=Ec.InvalidVersionFieldError=Ec.ExecutableResponseError=Ec.ExecutableResponse=void 0;var ur="urn:ietf:params:oauth:token-type:saml2",kn="urn:ietf:params:oauth:token-type:id_token",bn="urn:ietf:params:oauth:token-type:jwt";class yc{version;success;expirationTime;tokenType;errorCode;errorMessage;subjectToken;constructor(e){if(!e.version)throw new xn("Executable response must contain a 'version' field.");if(e.success===void 0)throw new Rn("Executable response must contain a 'success' field.");if(this.version=e.version,this.success=e.success,this.success){if(this.expirationTime=e.expiration_time,this.tokenType=e.token_type,this.tokenType!==ur&&this.tokenType!==kn&&this.tokenType!==bn)throw new Nn(`Executable response must contain a 'token_type' field when successful and it must be one of ${kn}, ${bn}, or ${ur}.`);if(this.tokenType===ur){if(!e.saml_response)throw new lr(`Executable response must contain a 'saml_response' field when token_type=${ur}.`);this.subjectToken=e.saml_response}else{if(!e.id_token)throw new lr(`Executable response must contain a 'id_token' field when token_type=${kn} or ${bn}.`);this.subjectToken=e.id_token}}else{if(!e.code)throw new Pn("Executable response must contain a 'code' field when unsuccessful.");if(!e.message)throw new In("Executable response must contain a 'message' field when unsuccessful.");this.errorCode=e.code,this.errorMessage=e.message}}isValid(){return!this.isExpired()&&this.success}isExpired(){return this.expirationTime!==void 0&&this.expirationTime<Math.round(Date.now()/1000)}}Ec.ExecutableResponse=yc;class Me extends Error{constructor(e){super(e);Object.setPrototypeOf(this,new.target.prototype)}}Ec.ExecutableResponseError=Me;class xn extends Me{}Ec.InvalidVersionFieldError=xn;class Rn extends Me{}Ec.InvalidSuccessFieldError=Rn;class mc extends Me{}Ec.InvalidExpirationTimeFieldError=mc;class Nn extends Me{}Ec.InvalidTokenTypeFieldError=Nn;class Pn extends Me{}Ec.InvalidCodeFieldError=Pn;class In extends Me{}Ec.InvalidMessageFieldError=In;class lr extends Me{}Ec.InvalidSubjectTokenError=lr});var Fn=w(function(Tc){Object.defineProperty(Tc,"__esModule",{value:!0});Tc.PluggableAuthHandler=Tc.ExecutableError=void 0;var Qe=jn(),zd=G("child_process"),Dn=G("fs");class Un extends Error{code;constructor(e,t){super(`The executable failed with exit code: ${t} and error message: ${e}.`);this.code=t,Object.setPrototypeOf(this,new.target.prototype)}}Tc.ExecutableError=Un;class qn{commandComponents;timeoutMillis;outputFile;constructor(e){if(!e.command)throw Error("No command provided.");if(this.commandComponents=qn.parseCommand(e.command),this.timeoutMillis=e.timeoutMillis,!this.timeoutMillis)throw Error("No timeoutMillis provided.");this.outputFile=e.outputFile}retrieveResponseFromExecutable(e){return new Promise((t,r)=>{let n=zd.spawn(this.commandComponents[0],this.commandComponents.slice(1),{env:{...process.env,...Object.fromEntries(e)}}),s="";n.stdout.on("data",(u)=>{s+=u}),n.stderr.on("data",(u)=>{s+=u});let i=setTimeout(()=>(n.removeAllListeners(),n.kill(),r(Error("The executable failed to finish within the timeout specified."))),this.timeoutMillis);n.on("close",(u)=>{if(clearTimeout(i),u===0)try{let h=JSON.parse(s),y=new Qe.ExecutableResponse(h);return t(y)}catch(h){if(h instanceof Qe.ExecutableResponseError)return r(h);return r(new Qe.ExecutableResponseError(`The executable returned an invalid response: ${s}`))}else return r(new Un(s,u.toString()))})})}async retrieveCachedResponse(){if(!this.outputFile||this.outputFile.length===0)return;let e;try{e=await Dn.promises.realpath(this.outputFile)}catch{return}if(!(await Dn.promises.lstat(e)).isFile())return;let t=await Dn.promises.readFile(e,{encoding:"utf8"});if(t==="")return;try{let r=JSON.parse(t);if(new Qe.ExecutableResponse(r).isValid())return new Qe.ExecutableResponse(r);return}catch(r){if(r instanceof Qe.ExecutableResponseError)throw r;throw new Qe.ExecutableResponseError(`The output file contained an invalid response: ${t}`)}}static parseCommand(e){let t=e.match(/(?:[^\s"]+|"[^"]*")+/g);if(!t)throw Error(`Provided command: "${e}" could not be parsed.`);for(let r=0;r<t.length;r++)if(t[r][0]==='"'&&t[r].slice(-1)==='"')t[r]=t[r].slice(1,-1);return t}}Tc.PluggableAuthHandler=qn});var Ln=w(function(Mn){Object.defineProperty(Mn,"__esModule",{value:!0});Mn.PluggableAuthClient=Mn.ExecutableError=void 0;var Qd=$e(),Zd=jn(),Oc=Fn(),ep=Fn();Object.defineProperty(Mn,"ExecutableError",{enumerable:!0,get:function(){return ep.ExecutableError}});var tp=30000,vc=5000,Sc=120000,rp="GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES",Cc=1;class kc extends Qd.BaseExternalAccountClient{command;timeoutMillis;outputFile;handler;constructor(e){super(e);if(!e.credential_source.executable)throw Error('No valid Pluggable Auth "credential_source" provided.');if(this.command=e.credential_source.executable.command,!this.command)throw Error('No valid Pluggable Auth "credential_source" provided.');if(e.credential_source.executable.timeout_millis===void 0)this.timeoutMillis=tp;else if(this.timeoutMillis=e.credential_source.executable.timeout_millis,this.timeoutMillis<vc||this.timeoutMillis>Sc)throw Error(`Timeout must be between ${vc} and ${Sc} milliseconds.`);this.outputFile=e.credential_source.executable.output_file,this.handler=new Oc.PluggableAuthHandler({command:this.command,timeoutMillis:this.timeoutMillis,outputFile:this.outputFile}),this.credentialSourceType="executable"}async retrieveSubjectToken(){if(process.env[rp]!=="1")throw Error("Pluggable Auth executables need to be explicitly allowed to run by setting the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment Variable to 1.");let e=void 0;if(this.outputFile)e=await this.handler.retrieveCachedResponse();if(!e){let t=new Map;if(t.set("GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE",this.audience),t.set("GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE",this.subjectTokenType),t.set("GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE","0"),this.outputFile)t.set("GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE",this.outputFile);let r=this.getServiceAccountEmail();if(r)t.set("GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL",r);e=await this.handler.retrieveResponseFromExecutable(t)}if(e.version>Cc)throw Error(`Version of executable is not currently supported, maximum supported version is ${Cc}.`);if(!e.success)throw new Oc.ExecutableError(e.errorMessage,e.errorCode);if(this.outputFile){if(!e.expirationTime)throw new Zd.InvalidExpirationTimeFieldError("The executable response must contain the `expiration_time` field for successful responses when an output_file has been specified in the configuration.")}if(e.isExpired())throw Error("Executable response is expired.");return e.subjectToken}}Mn.PluggableAuthClient=kc});var Gn=w(function(Rc){Object.defineProperty(Rc,"__esModule",{value:!0});Rc.ExternalAccountClient=void 0;var np=$e(),sp=Sn(),ip=On(),op=Ln();class xc{constructor(){throw Error("ExternalAccountClients should be initialized via: ExternalAccountClient.fromJSON(), directly via explicit constructors, eg. new AwsClient(options), new IdentityPoolClient(options), newPluggableAuthClientOptions, or via new GoogleAuth(options).getClient()")}static fromJSON(e){if(e&&e.type===np.EXTERNAL_ACCOUNT_TYPE)if(e.credential_source?.environment_id)return new ip.AwsClient(e);else if(e.credential_source?.executable)return new op.PluggableAuthClient(e);else return new sp.IdentityPoolClient(e);else return null}}Rc.ExternalAccountClient=xc});var Hn=w(function(Uc){Object.defineProperty(Uc,"__esModule",{value:!0});Uc.ExternalAccountAuthorizedUserClient=Uc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=void 0;var Pc=_e(),Ic=gn(),jc=ie(),ap=G("stream"),cp=$e();Uc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE="external_account_authorized_user";var up="https://sts.{universeDomain}/v1/oauthtoken";class Bn extends Ic.OAuthClientAuthHandler{#e;constructor(e){super(e);this.#e=e.tokenRefreshEndpoint}async refreshToken(e,t){let r={...Bn.RETRY_CONFIG,url:this.#e,method:"POST",headers:t,data:new URLSearchParams({grant_type:"refresh_token",refresh_token:e}),responseType:"json"};Pc.AuthClient.setMethodName(r,"refreshToken"),this.applyClientAuthenticationOptions(r);try{let n=await this.transporter.request(r),s=n.data;return s.res=n,s}catch(n){if(n instanceof jc.GaxiosError&&n.response)throw Ic.getErrorFromOAuthErrorResponse(n.response.data,n);throw n}}}class Dc extends Pc.AuthClient{cachedAccessToken;externalAccountAuthorizedUserHandler;refreshToken;constructor(e){super(e);if(e.universe_domain)this.universeDomain=e.universe_domain;this.refreshToken=e.refresh_token;let t={confidentialClientType:"basic",clientId:e.client_id,clientSecret:e.client_secret};if(this.externalAccountAuthorizedUserHandler=new Bn({tokenRefreshEndpoint:e.token_url??up.replace("{universeDomain}",this.universeDomain),transporter:this.transporter,clientAuthentication:t}),this.cachedAccessToken=null,this.quotaProjectId=e.quota_project_id,typeof e?.eagerRefreshThresholdMillis!=="number")this.eagerRefreshThresholdMillis=cp.EXPIRATION_TIME_OFFSET;else this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis;this.forceRefreshOnFailure=!!e?.forceRefreshOnFailure}async getAccessToken(){if(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=jc.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof ap.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=await this.externalAccountAuthorizedUserHandler.refreshToken(this.refreshToken);if(this.cachedAccessToken={access_token:e.access_token,expiry_date:new Date().getTime()+e.expires_in*1000,res:e.res},e.refresh_token!==void 0)this.refreshToken=e.refresh_token;return this.cachedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Uc.ExternalAccountAuthorizedUserClient=Dc});var Jn=w(function(Fc){Object.defineProperty(Fc,"__esModule",{value:!0});Fc.GdchClient=Fc.GDCH_SERVICE_ACCOUNT_TYPE=void 0;var hp=G("crypto"),fp=G("fs"),dp=G("https"),pp=Be(),gp=3600;Fc.GDCH_SERVICE_ACCOUNT_TYPE="gdch_service_account";class Kn extends pp.OAuth2Client{projectId;privateKeyId;privateKey;serviceIdentityName;tokenServerUri;caCertPath;apiAudience;lifetime;gdchOptions;caAgentPromise;cachedCaCertPath;lastCaCertReadTime=0;CA_CERT_TTL_MS=300000;constructor(e={}){super(e);this.gdchOptions=e,this.projectId=e.projectId||void 0,this.privateKeyId=e.privateKeyId,this.privateKey=e.privateKey,this.serviceIdentityName=e.serviceIdentityName,this.tokenServerUri=e.tokenServerUri,this.caCertPath=e.caCertPath,this.apiAudience=e.apiAudience,this.lifetime=e.lifetime||gp,this.credentials={refresh_token:"gdch-placeholder",expiry_date:1}}createWithGdchAudience(e){if(!e)throw Error("Audience cannot be null or empty for GDCH service account credentials.");return new Kn({...this.gdchOptions,projectId:this.projectId,privateKeyId:this.privateKeyId,privateKey:this.privateKey,serviceIdentityName:this.serviceIdentityName,tokenServerUri:this.tokenServerUri,caCertPath:this.caCertPath,lifetime:this.lifetime,apiAudience:e})}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the GDCH credentials settings.");if(e.type!==Fc.GDCH_SERVICE_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${Fc.GDCH_SERVICE_ACCOUNT_TYPE}" type`);if(e.format_version!=="1")throw Error("Only format version 1 is supported.");if(!e.project)throw Error("The incoming JSON object does not contain a project field");if(!e.private_key_id)throw Error("The incoming JSON object does not contain a private_key_id field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");if(!e.name)throw Error("The incoming JSON object does not contain a name field");if(!e.token_uri)throw Error("The incoming JSON object does not contain a token_uri field");this.projectId=e.project,this.privateKeyId=e.private_key_id,this.privateKey=e.private_key,this.serviceIdentityName=e.name,this.tokenServerUri=e.token_uri,this.caCertPath=e.ca_cert_path,this.gdchOptions={...this.gdchOptions,projectId:e.project,privateKeyId:e.private_key_id,privateKey:e.private_key,serviceIdentityName:e.name,tokenServerUri:e.token_uri,caCertPath:e.ca_cert_path}}async refreshTokenNoCache(){if(!this.apiAudience)throw Error("Audience cannot be null or empty for GDCH service account credentials. Specify the audience by calling createWithGdchAudience.");if(!this.privateKey)throw Error("Private key is not configured for GDCH credentials.");if(!this.privateKeyId)throw Error("Private key ID is not configured for GDCH credentials.");if(!this.projectId)throw Error("Project is not configured for GDCH credentials.");if(!this.serviceIdentityName)throw Error("Service identity name is not configured for GDCH credentials.");if(!this.tokenServerUri)throw Error("Token server URI is not configured for GDCH credentials.");let e=this.createAssertion(),t={audience:this.apiAudience,grant_type:"urn:ietf:params:oauth:token-type:token-exchange",requested_token_type:"urn:ietf:params:oauth:token-type:access_token",subject_token:e,subject_token_type:"urn:k8s:params:oauth:token-type:serviceaccount"},r={url:this.tokenServerUri,method:"POST",headers:{"Content-Type":"application/json"},data:t,responseType:"json",timeout:1e4,retry:!0,retryConfig:{httpMethodsToRetry:["POST"],statusCodesToRetry:[[500,599]],noResponseRetries:3}};if(this.caCertPath)r.agent=await this.getCaAgent();try{let n=await this.transporter.request(r),s=n.data;if(!s.access_token)throw Error("Token response did not contain an access_token.");if(!s.expires_in)throw Error("Token response did not contain an expires_in field.");let i={access_token:s.access_token,token_type:"STS-Bearer",expiry_date:Date.now()+s.expires_in*1000};return this.emit("tokens",i),{res:n,tokens:i}}catch(n){if(n&&n.config&&n.config.data)try{if(typeof n.config.data==="string"){let s=JSON.parse(n.config.data);if(s.subject_token)s.subject_token="***REDACTED***",n.config.data=JSON.stringify(s)}else if(typeof n.config.data==="object"&&n.config.data.subject_token)n.config.data.subject_token="***REDACTED***"}catch{}if(n instanceof Error)n.message=`Error getting access token for GDCH service account: ${n.message}, iss: ${this.serviceIdentityName}`;throw n}}createAssertion(){let e={alg:"ES256",typ:"JWT",kid:this.privateKeyId},t=`system:serviceaccount:${this.projectId}:${this.serviceIdentityName}`,r=Math.floor(Date.now()/1000),n={iss:t,sub:t,iat:r,exp:r+this.lifetime,aud:this.tokenServerUri},s=this.base64UrlEncode(JSON.stringify(e)),i=this.base64UrlEncode(JSON.stringify(n)),u=`${s}.${i}`,h=hp.sign("sha256",Buffer.from(u),{key:this.privateKey,dsaEncoding:"ieee-p1363"}),y=this.base64UrlEncode(h);return`${u}.${y}`}async requestAsync(e,t=!1){if(this.caCertPath&&!e.agent){let r=(e.url||"").toString();if(!r.includes("googleapis.com")&&!r.includes("google.com"))e.agent=await this.getCaAgent()}return super.requestAsync(e,t)}getCaAgent(){if(!this.caCertPath){this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;return}let e=Date.now(),t=e-this.lastCaCertReadTime>this.CA_CERT_TTL_MS;if(this.caAgentPromise&&this.caCertPath===this.cachedCaCertPath&&!t)return this.caAgentPromise;this.cachedCaCertPath=this.caCertPath,this.lastCaCertReadTime=e;let r=this.caCertPath;return this.caAgentPromise=(async()=>{try{let n=await fp.promises.readFile(r);return new dp.Agent({ca:n})}catch(n){if(this.cachedCaCertPath===r)this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;if(n instanceof Error)n.message=`Error reading certificate file from CA cert path, value '${r}': ${n.message}`;throw n}})(),this.caAgentPromise}toJSON(){return{...this,privateKey:this.privateKey?"***REDACTED***":void 0,_clientSecret:this._clientSecret?"***REDACTED***":void 0,apiKey:this.apiKey?"***REDACTED***":void 0,gdchOptions:this.gdchOptions?{...this.gdchOptions,privateKey:this.gdchOptions.privateKey?"***REDACTED***":void 0,clientSecret:this.gdchOptions.clientSecret?"***REDACTED***":void 0,client_secret:this.gdchOptions.client_secret?"***REDACTED***":void 0,apiKey:this.gdchOptions.apiKey?"***REDACTED***":void 0,credentials:this.gdchOptions.credentials?{...this.gdchOptions.credentials,access_token:this.gdchOptions.credentials.access_token?"***REDACTED***":void 0,refresh_token:this.gdchOptions.credentials.refresh_token?"***REDACTED***":void 0}:void 0}:void 0,credentials:{...this.credentials,access_token:this.credentials?.access_token?"***REDACTED***":void 0,refresh_token:this.credentials?.refresh_token?"***REDACTED***":void 0}}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}base64UrlEncode(e){return(typeof e==="string"?Buffer.from(e):e).toString("base64url")}}Fc.GdchClient=Kn});var Jc=w(function($c){Object.defineProperty($c,"__esModule",{value:!0});$c.GoogleAuth=$c.GoogleAuthExceptionMessages=void 0;var _p=G("child_process"),xt=G("fs"),yp=ie(),Rt=yt(),mp=G("os"),hr=G("path"),Ep=mt(),wp=Wr(),Tp=Yr(),Ap=zr(),ut=fn(),Gc=dn(),ht=pn(),vp=Gn(),bt=$e(),Vn=_e(),Bc=Hn(),Wn=Jn(),Lc=Oe();$c.GoogleAuthExceptionMessages={API_KEY_WITH_CREDENTIALS:"API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.",NO_PROJECT_ID_FOUND:`Unable to detect a Project Id in the current environment.
25
+ `+await e.crypto.sha256DigestHex(N),x=await Ud(e.crypto,e.securityCredentials.secretAccessKey,u,e.region,n),j=await kt(e.crypto,x,W),b=`${sc} Credential=${e.securityCredentials.accessKeyId}/${F}, SignedHeaders=${A}, Signature=${ic.fromArrayBufferToHex(j)}`;return{amzDate:t.has("date")?void 0:i,authorizationHeader:b,canonicalQuerystring:e.canonicalQuerystring}}});var fc=w(function(lc){Object.defineProperty(lc,"__esModule",{value:!0});lc.DefaultAwsSecurityCredentialsSupplier=void 0;var ar=_e();class uc{regionUrl;securityCredentialsUrl;imdsV2SessionTokenUrl;additionalGaxiosOptions;constructor(e){this.regionUrl=e.regionUrl,this.securityCredentialsUrl=e.securityCredentialsUrl,this.imdsV2SessionTokenUrl=e.imdsV2SessionTokenUrl,this.additionalGaxiosOptions=e.additionalGaxiosOptions}async getAwsRegion(e){if(this.#n)return this.#n;let t=new Headers;if(!this.#n&&this.imdsV2SessionTokenUrl)t.set("x-aws-ec2-metadata-token",await this.#e(e.transporter));if(!this.regionUrl)throw RangeError('Unable to determine AWS region due to missing "options.credential_source.region_url"');let r={...this.additionalGaxiosOptions,url:this.regionUrl,method:"GET",responseType:"text",headers:t};ar.AuthClient.setMethodName(r,"getAwsRegion");let n=await e.transporter.request(r);return n.data.substr(0,n.data.length-1)}async getAwsSecurityCredentials(e){if(this.#s)return this.#s;let t=new Headers;if(this.imdsV2SessionTokenUrl)t.set("x-aws-ec2-metadata-token",await this.#e(e.transporter));let r=await this.#t(t,e.transporter),n=await this.#r(r,t,e.transporter);return{accessKeyId:n.AccessKeyId,secretAccessKey:n.SecretAccessKey,token:n.Token}}async#e(e){let t={...this.additionalGaxiosOptions,url:this.imdsV2SessionTokenUrl,method:"PUT",responseType:"text",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"300"}};return ar.AuthClient.setMethodName(t,"#getImdsV2SessionToken"),(await e.request(t)).data}async#t(e,t){if(!this.securityCredentialsUrl)throw Error('Unable to determine AWS role name due to missing "options.credential_source.url"');let r={...this.additionalGaxiosOptions,url:this.securityCredentialsUrl,method:"GET",responseType:"text",headers:e};return ar.AuthClient.setMethodName(r,"#getAwsRoleName"),(await t.request(r)).data}async#r(e,t,r){let n={...this.additionalGaxiosOptions,url:`${this.securityCredentialsUrl}/${e}`,headers:t,responseType:"json"};return ar.AuthClient.setMethodName(n,"#retrieveAwsSecurityCredentials"),(await r.request(n)).data}get#n(){return process.env.AWS_REGION||process.env.AWS_DEFAULT_REGION||null}get#s(){if(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY)return{accessKeyId:process.env.AWS_ACCESS_KEY_ID,secretAccessKey:process.env.AWS_SECRET_ACCESS_KEY,token:process.env.AWS_SESSION_TOKEN};return null}}lc.DefaultAwsSecurityCredentialsSupplier=uc});var On=w(function(pc){Object.defineProperty(pc,"__esModule",{value:!0});pc.AwsClient=void 0;var Fd=Cn(),Md=$e(),Ld=fc(),dc=Oe(),Gd=ie();class cr extends Md.BaseExternalAccountClient{environmentId;awsSecurityCredentialsSupplier;regionalCredVerificationUrl;awsRequestSigner;region;static#e="https://sts.{region}.amazonaws.com?Action=GetCallerIdentity&Version=2011-06-15";static AWS_EC2_METADATA_IPV4_ADDRESS="169.254.169.254";static AWS_EC2_METADATA_IPV6_ADDRESS="fd00:ec2::254";constructor(e){super(e);let t=dc.originalOrCamelOptions(e),r=t.get("credential_source"),n=t.get("aws_security_credentials_supplier");if(!r&&!n)throw Error("A credential source or AWS security credentials supplier must be specified.");if(r&&n)throw Error("Only one of credential source or AWS security credentials supplier can be specified.");if(n)this.awsSecurityCredentialsSupplier=n,this.regionalCredVerificationUrl=cr.#e,this.credentialSourceType="programmatic";else{let s=dc.originalOrCamelOptions(r);this.environmentId=s.get("environment_id");let i=s.get("region_url"),u=s.get("url"),h=s.get("imdsv2_session_token_url");this.awsSecurityCredentialsSupplier=new Ld.DefaultAwsSecurityCredentialsSupplier({regionUrl:i,securityCredentialsUrl:u,imdsV2SessionTokenUrl:h}),this.regionalCredVerificationUrl=s.get("regional_cred_verification_url"),this.credentialSourceType="aws",this.validateEnvironmentId()}this.awsRequestSigner=null,this.region=""}validateEnvironmentId(){let e=this.environmentId?.match(/^(aws)(\d+)$/);if(!e||!this.regionalCredVerificationUrl)throw Error('No valid AWS "credential_source" provided');else if(parseInt(e[2],10)!==1)throw Error(`aws version "${e[2]}" is not supported in the current build.`)}async retrieveSubjectToken(){if(!this.awsRequestSigner)this.region=await this.awsSecurityCredentialsSupplier.getAwsRegion(this.supplierContext),this.awsRequestSigner=new Fd.AwsRequestSigner(async()=>this.awsSecurityCredentialsSupplier.getAwsSecurityCredentials(this.supplierContext),this.region);let e=await this.awsRequestSigner.getRequestOptions({...cr.RETRY_CONFIG,url:this.regionalCredVerificationUrl.replace("{region}",this.region),method:"POST"}),t=[];return Gd.Gaxios.mergeHeaders({"x-goog-cloud-target-resource":this.audience},e.headers).forEach((n,s)=>t.push({key:s,value:n})),encodeURIComponent(JSON.stringify({url:e.url,method:e.method,headers:t}))}}pc.AwsClient=cr});var jn=w(function(mc){Object.defineProperty(mc,"__esModule",{value:!0});mc.InvalidSubjectTokenError=mc.InvalidMessageFieldError=mc.InvalidCodeFieldError=mc.InvalidTokenTypeFieldError=mc.InvalidExpirationTimeFieldError=mc.InvalidSuccessFieldError=mc.InvalidVersionFieldError=mc.ExecutableResponseError=mc.ExecutableResponse=void 0;var ur="urn:ietf:params:oauth:token-type:saml2",kn="urn:ietf:params:oauth:token-type:id_token",bn="urn:ietf:params:oauth:token-type:jwt";class _c{version;success;expirationTime;tokenType;errorCode;errorMessage;subjectToken;constructor(e){if(!e.version)throw new xn("Executable response must contain a 'version' field.");if(e.success===void 0)throw new Rn("Executable response must contain a 'success' field.");if(this.version=e.version,this.success=e.success,this.success){if(this.expirationTime=e.expiration_time,this.tokenType=e.token_type,this.tokenType!==ur&&this.tokenType!==kn&&this.tokenType!==bn)throw new Nn(`Executable response must contain a 'token_type' field when successful and it must be one of ${kn}, ${bn}, or ${ur}.`);if(this.tokenType===ur){if(!e.saml_response)throw new lr(`Executable response must contain a 'saml_response' field when token_type=${ur}.`);this.subjectToken=e.saml_response}else{if(!e.id_token)throw new lr(`Executable response must contain a 'id_token' field when token_type=${kn} or ${bn}.`);this.subjectToken=e.id_token}}else{if(!e.code)throw new Pn("Executable response must contain a 'code' field when unsuccessful.");if(!e.message)throw new In("Executable response must contain a 'message' field when unsuccessful.");this.errorCode=e.code,this.errorMessage=e.message}}isValid(){return!this.isExpired()&&this.success}isExpired(){return this.expirationTime!==void 0&&this.expirationTime<Math.round(Date.now()/1000)}}mc.ExecutableResponse=_c;class Me extends Error{constructor(e){super(e);Object.setPrototypeOf(this,new.target.prototype)}}mc.ExecutableResponseError=Me;class xn extends Me{}mc.InvalidVersionFieldError=xn;class Rn extends Me{}mc.InvalidSuccessFieldError=Rn;class yc extends Me{}mc.InvalidExpirationTimeFieldError=yc;class Nn extends Me{}mc.InvalidTokenTypeFieldError=Nn;class Pn extends Me{}mc.InvalidCodeFieldError=Pn;class In extends Me{}mc.InvalidMessageFieldError=In;class lr extends Me{}mc.InvalidSubjectTokenError=lr});var Fn=w(function(wc){Object.defineProperty(wc,"__esModule",{value:!0});wc.PluggableAuthHandler=wc.ExecutableError=void 0;var Qe=jn(),zd=G("child_process"),Dn=G("fs");class Un extends Error{code;constructor(e,t){super(`The executable failed with exit code: ${t} and error message: ${e}.`);this.code=t,Object.setPrototypeOf(this,new.target.prototype)}}wc.ExecutableError=Un;class qn{commandComponents;timeoutMillis;outputFile;constructor(e){if(!e.command)throw Error("No command provided.");if(this.commandComponents=qn.parseCommand(e.command),this.timeoutMillis=e.timeoutMillis,!this.timeoutMillis)throw Error("No timeoutMillis provided.");this.outputFile=e.outputFile}retrieveResponseFromExecutable(e){return new Promise((t,r)=>{let n=zd.spawn(this.commandComponents[0],this.commandComponents.slice(1),{env:{...process.env,...Object.fromEntries(e)}}),s="";n.stdout.on("data",(u)=>{s+=u}),n.stderr.on("data",(u)=>{s+=u});let i=setTimeout(()=>(n.removeAllListeners(),n.kill(),r(Error("The executable failed to finish within the timeout specified."))),this.timeoutMillis);n.on("close",(u)=>{if(clearTimeout(i),u===0)try{let h=JSON.parse(s),y=new Qe.ExecutableResponse(h);return t(y)}catch(h){if(h instanceof Qe.ExecutableResponseError)return r(h);return r(new Qe.ExecutableResponseError(`The executable returned an invalid response: ${s}`))}else return r(new Un(s,u.toString()))})})}async retrieveCachedResponse(){if(!this.outputFile||this.outputFile.length===0)return;let e;try{e=await Dn.promises.realpath(this.outputFile)}catch{return}if(!(await Dn.promises.lstat(e)).isFile())return;let t=await Dn.promises.readFile(e,{encoding:"utf8"});if(t==="")return;try{let r=JSON.parse(t);if(new Qe.ExecutableResponse(r).isValid())return new Qe.ExecutableResponse(r);return}catch(r){if(r instanceof Qe.ExecutableResponseError)throw r;throw new Qe.ExecutableResponseError(`The output file contained an invalid response: ${t}`)}}static parseCommand(e){let t=e.match(/(?:[^\s"]+|"[^"]*")+/g);if(!t)throw Error(`Provided command: "${e}" could not be parsed.`);for(let r=0;r<t.length;r++)if(t[r][0]==='"'&&t[r].slice(-1)==='"')t[r]=t[r].slice(1,-1);return t}}wc.PluggableAuthHandler=qn});var Ln=w(function(Mn){Object.defineProperty(Mn,"__esModule",{value:!0});Mn.PluggableAuthClient=Mn.ExecutableError=void 0;var Qd=$e(),Zd=jn(),Cc=Fn(),ep=Fn();Object.defineProperty(Mn,"ExecutableError",{enumerable:!0,get:function(){return ep.ExecutableError}});var tp=30000,Ac=5000,vc=120000,rp="GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES",Sc=1;class Oc extends Qd.BaseExternalAccountClient{command;timeoutMillis;outputFile;handler;constructor(e){super(e);if(!e.credential_source.executable)throw Error('No valid Pluggable Auth "credential_source" provided.');if(this.command=e.credential_source.executable.command,!this.command)throw Error('No valid Pluggable Auth "credential_source" provided.');if(e.credential_source.executable.timeout_millis===void 0)this.timeoutMillis=tp;else if(this.timeoutMillis=e.credential_source.executable.timeout_millis,this.timeoutMillis<Ac||this.timeoutMillis>vc)throw Error(`Timeout must be between ${Ac} and ${vc} milliseconds.`);this.outputFile=e.credential_source.executable.output_file,this.handler=new Cc.PluggableAuthHandler({command:this.command,timeoutMillis:this.timeoutMillis,outputFile:this.outputFile}),this.credentialSourceType="executable"}async retrieveSubjectToken(){if(process.env[rp]!=="1")throw Error("Pluggable Auth executables need to be explicitly allowed to run by setting the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment Variable to 1.");let e=void 0;if(this.outputFile)e=await this.handler.retrieveCachedResponse();if(!e){let t=new Map;if(t.set("GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE",this.audience),t.set("GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE",this.subjectTokenType),t.set("GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE","0"),this.outputFile)t.set("GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE",this.outputFile);let r=this.getServiceAccountEmail();if(r)t.set("GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL",r);e=await this.handler.retrieveResponseFromExecutable(t)}if(e.version>Sc)throw Error(`Version of executable is not currently supported, maximum supported version is ${Sc}.`);if(!e.success)throw new Cc.ExecutableError(e.errorMessage,e.errorCode);if(this.outputFile){if(!e.expirationTime)throw new Zd.InvalidExpirationTimeFieldError("The executable response must contain the `expiration_time` field for successful responses when an output_file has been specified in the configuration.")}if(e.isExpired())throw Error("Executable response is expired.");return e.subjectToken}}Mn.PluggableAuthClient=Oc});var Gn=w(function(Rc){Object.defineProperty(Rc,"__esModule",{value:!0});Rc.ExternalAccountClient=void 0;var np=$e(),sp=Sn(),ip=On(),op=Ln();class xc{constructor(){throw Error("ExternalAccountClients should be initialized via: ExternalAccountClient.fromJSON(), directly via explicit constructors, eg. new AwsClient(options), new IdentityPoolClient(options), newPluggableAuthClientOptions, or via new GoogleAuth(options).getClient()")}static fromJSON(e){if(e&&e.type===np.EXTERNAL_ACCOUNT_TYPE)if(e.credential_source?.environment_id)return new ip.AwsClient(e);else if(e.credential_source?.executable)return new op.PluggableAuthClient(e);else return new sp.IdentityPoolClient(e);else return null}}Rc.ExternalAccountClient=xc});var Hn=w(function(Uc){Object.defineProperty(Uc,"__esModule",{value:!0});Uc.ExternalAccountAuthorizedUserClient=Uc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=void 0;var Pc=_e(),Ic=gn(),jc=ie(),ap=G("stream"),cp=$e();Uc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE="external_account_authorized_user";var up="https://sts.{universeDomain}/v1/oauthtoken";class Bn extends Ic.OAuthClientAuthHandler{#e;constructor(e){super(e);this.#e=e.tokenRefreshEndpoint}async refreshToken(e,t){let r={...Bn.RETRY_CONFIG,url:this.#e,method:"POST",headers:t,data:new URLSearchParams({grant_type:"refresh_token",refresh_token:e}),responseType:"json"};Pc.AuthClient.setMethodName(r,"refreshToken"),this.applyClientAuthenticationOptions(r);try{let n=await this.transporter.request(r),s=n.data;return s.res=n,s}catch(n){if(n instanceof jc.GaxiosError&&n.response)throw Ic.getErrorFromOAuthErrorResponse(n.response.data,n);throw n}}}class Dc extends Pc.AuthClient{cachedAccessToken;externalAccountAuthorizedUserHandler;refreshToken;constructor(e){super(e);if(e.universe_domain)this.universeDomain=e.universe_domain;this.refreshToken=e.refresh_token;let t={confidentialClientType:"basic",clientId:e.client_id,clientSecret:e.client_secret};if(this.externalAccountAuthorizedUserHandler=new Bn({tokenRefreshEndpoint:e.token_url??up.replace("{universeDomain}",this.universeDomain),transporter:this.transporter,clientAuthentication:t}),this.cachedAccessToken=null,this.quotaProjectId=e.quota_project_id,typeof e?.eagerRefreshThresholdMillis!=="number")this.eagerRefreshThresholdMillis=cp.EXPIRATION_TIME_OFFSET;else this.eagerRefreshThresholdMillis=e.eagerRefreshThresholdMillis;this.forceRefreshOnFailure=!!e?.forceRefreshOnFailure}async getAccessToken(){if(!this.cachedAccessToken||this.isExpired(this.cachedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedAccessToken.access_token,res:this.cachedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=jc.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof ap.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=await this.externalAccountAuthorizedUserHandler.refreshToken(this.refreshToken);if(this.cachedAccessToken={access_token:e.access_token,expiry_date:new Date().getTime()+e.expires_in*1000,res:e.res},e.refresh_token!==void 0)this.refreshToken=e.refresh_token;return this.cachedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Uc.ExternalAccountAuthorizedUserClient=Dc});var Jn=w(function(Fc){Object.defineProperty(Fc,"__esModule",{value:!0});Fc.GdchClient=Fc.GDCH_SERVICE_ACCOUNT_TYPE=void 0;var hp=G("crypto"),fp=G("fs"),dp=G("https"),pp=Be(),gp=3600;Fc.GDCH_SERVICE_ACCOUNT_TYPE="gdch_service_account";class Kn extends pp.OAuth2Client{projectId;privateKeyId;privateKey;serviceIdentityName;tokenServerUri;caCertPath;apiAudience;lifetime;gdchOptions;caAgentPromise;cachedCaCertPath;lastCaCertReadTime=0;CA_CERT_TTL_MS=300000;constructor(e={}){super(e);this.gdchOptions=e,this.projectId=e.projectId||void 0,this.privateKeyId=e.privateKeyId,this.privateKey=e.privateKey,this.serviceIdentityName=e.serviceIdentityName,this.tokenServerUri=e.tokenServerUri,this.caCertPath=e.caCertPath,this.apiAudience=e.apiAudience,this.lifetime=e.lifetime||gp,this.credentials={refresh_token:"gdch-placeholder",expiry_date:1}}createWithGdchAudience(e){if(!e)throw Error("Audience cannot be null or empty for GDCH service account credentials.");return new Kn({...this.gdchOptions,projectId:this.projectId,privateKeyId:this.privateKeyId,privateKey:this.privateKey,serviceIdentityName:this.serviceIdentityName,tokenServerUri:this.tokenServerUri,caCertPath:this.caCertPath,lifetime:this.lifetime,apiAudience:e})}fromJSON(e){if(!e)throw Error("Must pass in a JSON object containing the GDCH credentials settings.");if(e.type!==Fc.GDCH_SERVICE_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${Fc.GDCH_SERVICE_ACCOUNT_TYPE}" type`);if(e.format_version!=="1")throw Error("Only format version 1 is supported.");if(!e.project)throw Error("The incoming JSON object does not contain a project field");if(!e.private_key_id)throw Error("The incoming JSON object does not contain a private_key_id field");if(!e.private_key)throw Error("The incoming JSON object does not contain a private_key field");if(!e.name)throw Error("The incoming JSON object does not contain a name field");if(!e.token_uri)throw Error("The incoming JSON object does not contain a token_uri field");this.projectId=e.project,this.privateKeyId=e.private_key_id,this.privateKey=e.private_key,this.serviceIdentityName=e.name,this.tokenServerUri=e.token_uri,this.caCertPath=e.ca_cert_path,this.gdchOptions={...this.gdchOptions,projectId:e.project,privateKeyId:e.private_key_id,privateKey:e.private_key,serviceIdentityName:e.name,tokenServerUri:e.token_uri,caCertPath:e.ca_cert_path}}async refreshTokenNoCache(){if(!this.apiAudience)throw Error("Audience cannot be null or empty for GDCH service account credentials. Specify the audience by calling createWithGdchAudience.");if(!this.privateKey)throw Error("Private key is not configured for GDCH credentials.");if(!this.privateKeyId)throw Error("Private key ID is not configured for GDCH credentials.");if(!this.projectId)throw Error("Project is not configured for GDCH credentials.");if(!this.serviceIdentityName)throw Error("Service identity name is not configured for GDCH credentials.");if(!this.tokenServerUri)throw Error("Token server URI is not configured for GDCH credentials.");let e=this.createAssertion(),t={audience:this.apiAudience,grant_type:"urn:ietf:params:oauth:token-type:token-exchange",requested_token_type:"urn:ietf:params:oauth:token-type:access_token",subject_token:e,subject_token_type:"urn:k8s:params:oauth:token-type:serviceaccount"},r={url:this.tokenServerUri,method:"POST",headers:{"Content-Type":"application/json"},data:t,responseType:"json",timeout:1e4,retry:!0,retryConfig:{httpMethodsToRetry:["POST"],statusCodesToRetry:[[500,599]],noResponseRetries:3}};if(this.caCertPath)r.agent=await this.getCaAgent();try{let n=await this.transporter.request(r),s=n.data;if(!s.access_token)throw Error("Token response did not contain an access_token.");if(!s.expires_in)throw Error("Token response did not contain an expires_in field.");let i={access_token:s.access_token,token_type:"STS-Bearer",expiry_date:Date.now()+s.expires_in*1000};return this.emit("tokens",i),{res:n,tokens:i}}catch(n){if(n&&n.config&&n.config.data)try{if(typeof n.config.data==="string"){let s=JSON.parse(n.config.data);if(s.subject_token)s.subject_token="***REDACTED***",n.config.data=JSON.stringify(s)}else if(typeof n.config.data==="object"&&n.config.data.subject_token)n.config.data.subject_token="***REDACTED***"}catch{}if(n instanceof Error)n.message=`Error getting access token for GDCH service account: ${n.message}, iss: ${this.serviceIdentityName}`;throw n}}createAssertion(){let e={alg:"ES256",typ:"JWT",kid:this.privateKeyId},t=`system:serviceaccount:${this.projectId}:${this.serviceIdentityName}`,r=Math.floor(Date.now()/1000),n={iss:t,sub:t,iat:r,exp:r+this.lifetime,aud:this.tokenServerUri},s=this.base64UrlEncode(JSON.stringify(e)),i=this.base64UrlEncode(JSON.stringify(n)),u=`${s}.${i}`,h=hp.sign("sha256",Buffer.from(u),{key:this.privateKey,dsaEncoding:"ieee-p1363"}),y=this.base64UrlEncode(h);return`${u}.${y}`}async requestAsync(e,t=!1){if(this.caCertPath&&!e.agent){let r=(e.url||"").toString();if(!r.includes("googleapis.com")&&!r.includes("google.com"))e.agent=await this.getCaAgent()}return super.requestAsync(e,t)}getCaAgent(){if(!this.caCertPath){this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;return}let e=Date.now(),t=e-this.lastCaCertReadTime>this.CA_CERT_TTL_MS;if(this.caAgentPromise&&this.caCertPath===this.cachedCaCertPath&&!t)return this.caAgentPromise;this.cachedCaCertPath=this.caCertPath,this.lastCaCertReadTime=e;let r=this.caCertPath;return this.caAgentPromise=(async()=>{try{let n=await fp.promises.readFile(r);return new dp.Agent({ca:n})}catch(n){if(this.cachedCaCertPath===r)this.caAgentPromise=void 0,this.cachedCaCertPath=void 0,this.lastCaCertReadTime=0;if(n instanceof Error)n.message=`Error reading certificate file from CA cert path, value '${r}': ${n.message}`;throw n}})(),this.caAgentPromise}toJSON(){return{...this,privateKey:this.privateKey?"***REDACTED***":void 0,_clientSecret:this._clientSecret?"***REDACTED***":void 0,apiKey:this.apiKey?"***REDACTED***":void 0,gdchOptions:this.gdchOptions?{...this.gdchOptions,privateKey:this.gdchOptions.privateKey?"***REDACTED***":void 0,clientSecret:this.gdchOptions.clientSecret?"***REDACTED***":void 0,client_secret:this.gdchOptions.client_secret?"***REDACTED***":void 0,apiKey:this.gdchOptions.apiKey?"***REDACTED***":void 0,credentials:this.gdchOptions.credentials?{...this.gdchOptions.credentials,access_token:this.gdchOptions.credentials.access_token?"***REDACTED***":void 0,refresh_token:this.gdchOptions.credentials.refresh_token?"***REDACTED***":void 0}:void 0}:void 0,credentials:{...this.credentials,access_token:this.credentials?.access_token?"***REDACTED***":void 0,refresh_token:this.credentials?.refresh_token?"***REDACTED***":void 0}}}[Symbol.for("nodejs.util.inspect.custom")](){return this.toJSON()}base64UrlEncode(e){return(typeof e==="string"?Buffer.from(e):e).toString("base64url")}}Fc.GdchClient=Kn});var Jc=w(function($c){Object.defineProperty($c,"__esModule",{value:!0});$c.GoogleAuth=$c.GoogleAuthExceptionMessages=void 0;var _p=G("child_process"),xt=G("fs"),yp=ie(),Rt=yt(),mp=G("os"),hr=G("path"),Ep=mt(),wp=Wr(),Tp=Yr(),Ap=zr(),ut=fn(),Gc=dn(),ht=pn(),vp=Gn(),bt=$e(),Vn=_e(),Bc=Hn(),Wn=Jn(),Lc=Oe();$c.GoogleAuthExceptionMessages={API_KEY_WITH_CREDENTIALS:"API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.",NO_PROJECT_ID_FOUND:`Unable to detect a Project Id in the current environment.
26
26
  To learn more about authentication and Google APIs, visit:
27
27
  https://cloud.google.com/docs/authentication/getting-started`,NO_CREDENTIALS_FOUND:`Unable to find credentials in current environment.
28
28
  To learn more about authentication and Google APIs, visit:
29
29
  https://cloud.google.com/docs/authentication/getting-started`,NO_ADC_FOUND:"Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.",NO_UNIVERSE_DOMAIN_FOUND:`Unable to detect a Universe Domain in the current environment.
30
30
  To learn more about Universe Domain retrieval, visit:
31
- https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};class Hc{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(e={}){if(this._cachedProjectId=e.projectId||null,this.cachedCredential=e.authClient||null,this.keyFilename=e.keyFilename||e.keyFile,this.scopes=e.scopes,this.clientOptions=e.clientOptions||{},this.jsonContent=e.credentials||null,this.apiKey=e.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw RangeError($c.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);if(e.universeDomain)this.clientOptions.universeDomain=e.universeDomain}setGapicJWTValues(e){e.defaultServicePath=this.defaultServicePath,e.useJWTAccessWithScope=this.useJWTAccessWithScope,e.defaultScopes=this.defaultScopes}getProjectId(e){if(e)this.getProjectIdAsync().then((t)=>e(null,t),e);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(e){if(e instanceof Error&&e.message===$c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;else throw e}}async findAndCacheProjectId(){let e=null;if(e||=await this.getProductionProjectId(),e||=await this.getFileProjectId(),e||=await this.getDefaultServiceProjectId(),e||=await this.getGCEProjectId(),e||=await this.getExternalAccountClientProjectId(),e)return this._cachedProjectId=e,e;else throw Error($c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){if(this._cachedProjectId)return this._cachedProjectId;if(!this._findProjectIdPromise)this._findProjectIdPromise=this.findAndCacheProjectId();return this._findProjectIdPromise}async getUniverseDomainFromMetadataServer(){let e;try{e=await Rt.universe("universe-domain"),e||=Vn.DEFAULT_UNIVERSE}catch(t){if(t&&t?.response?.status===404)e=Vn.DEFAULT_UNIVERSE;else throw t}return e}async getUniverseDomain(){let e=Lc.originalOrCamelOptions(this.clientOptions).get("universe_domain");try{e??=(await this.getClient()).universeDomain}catch{e??=Vn.DEFAULT_UNIVERSE}return e}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(e={},t){let r;if(typeof e==="function")t=e;else r=e;if(t)this.getApplicationDefaultAsync(r).then((n)=>t(null,n.credential,n.projectId),t);else return this.getApplicationDefaultAsync(r)}async getApplicationDefaultAsync(e={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let t;if(t=await this._tryGetApplicationCredentialsFromEnvironmentVariable(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(t=await this._tryGetApplicationCredentialsFromWellKnownFile(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(await this._checkIsGCE())return e.scopes=this.getAnyScopes(),await this.#t(new wp.Compute(e));throw Error($c.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(e,t=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let r=await this.getProjectIdOptional();if(t)e.quotaProjectId=t;return this.cachedCredential=e,{credential:e,projectId:r}}async _checkIsGCE(){if(this.checkIsGCE===void 0)this.checkIsGCE=Rt.getGCPResidency()||await Rt.isAvailable();return this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(e){let t=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!t||t.length===0)return null;try{return await this._getApplicationCredentialsFromFilePath(t,e)}catch(r){if(r instanceof Error)r.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${r.message}`;throw r}}async _tryGetApplicationCredentialsFromWellKnownFile(e){let t=process.env.CLOUDSDK_CONFIG;if(!t)if(this._isWindows()){if(process.env.APPDATA)t=hr.join(process.env.APPDATA,"gcloud")}else{let s=process.env.HOME;if(s)t=hr.join(s,".config","gcloud")}if(!t)return null;let r=hr.join(t,"application_default_credentials.json");if(!xt.existsSync(r))return null;return await this._getApplicationCredentialsFromFilePath(r,e)}async _getApplicationCredentialsFromFilePath(e,t={}){if(!e||e.length===0)throw Error("The file path is invalid.");try{if(e=xt.realpathSync(e),!xt.lstatSync(e).isFile())throw Error()}catch(n){if(n instanceof Error)n.message=`The file at ${e} does not exist, or it is not a file. ${n.message}`;throw n}let r=xt.createReadStream(e);return this.fromStream(r,t)}fromImpersonatedJSON(e){if(!e)throw Error("Must pass in a JSON object containing an impersonated refresh token");if(e.type!==ht.IMPERSONATED_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${ht.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!e.source_credentials)throw Error("The incoming JSON object does not contain a source_credentials field");if(!e.service_account_impersonation_url)throw Error("The incoming JSON object does not contain a service_account_impersonation_url field");let t=this.fromJSON(e.source_credentials);if(e.service_account_impersonation_url?.length>256)throw RangeError(`Target principal is too long: ${e.service_account_impersonation_url}`);let r=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(e.service_account_impersonation_url)?.groups?.target;if(!r)throw RangeError(`Cannot extract target principal from ${e.service_account_impersonation_url}`);let n=(this.scopes||e.scopes||this.defaultScopes)??[];return new ht.Impersonated({...e,sourceClient:t,targetPrincipal:r,targetScopes:Array.isArray(n)?n:[n]})}fromJSON(e,t={}){let r,n=Lc.originalOrCamelOptions(t).get("universe_domain");if(e.type===Gc.USER_REFRESH_ACCOUNT_TYPE)r=new Gc.UserRefreshClient(t),r.fromJSON(e);else if(e.type===ht.IMPERSONATED_ACCOUNT_TYPE)r=this.fromImpersonatedJSON(e);else if(e.type===bt.EXTERNAL_ACCOUNT_TYPE)r=vp.ExternalAccountClient.fromJSON({...e,...t}),r.scopes=this.getAnyScopes();else if(e.type===Bc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE)r=new Bc.ExternalAccountAuthorizedUserClient({...e,...t});else if(e.type===Wn.GDCH_SERVICE_ACCOUNT_TYPE)r=new Wn.GdchClient(t),r.fromJSON(e);else t.scopes=this.scopes,r=new ut.JWT(t),this.setGapicJWTValues(r),r.fromJSON(e);if(n)r.universeDomain=n;return r}_cacheClientFromJSON(e,t){let r=this.fromJSON(e,t);return this.jsonContent=e,this.cachedCredential=r,r}fromStream(e,t={},r){let n={};if(typeof t==="function")r=t;else n=t;if(r)this.fromStreamAsync(e,n).then((s)=>r(null,s),r);else return this.fromStreamAsync(e,n)}fromStreamAsync(e,t){return new Promise((r,n)=>{if(!e)throw Error("Must pass in a stream containing the Google auth settings.");let s=[];e.setEncoding("utf8").on("error",n).on("data",(i)=>s.push(i)).on("end",()=>{try{try{let i=JSON.parse(s.join("")),u=this._cacheClientFromJSON(i,t);return r(u)}catch(i){if(!this.keyFilename)throw i;let u=new ut.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=u,this.setGapicJWTValues(u),r(u)}}catch(i){return n(i)}})})}fromAPIKey(e,t={}){return new ut.JWT({...t,apiKey:e})}_isWindows(){let e=mp.platform();if(e&&e.length>=3){if(e.substring(0,3).toLowerCase()==="win")return!0}return!1}async getDefaultServiceProjectId(){return new Promise((e)=>{_p.exec("gcloud config config-helper --format json",(t,r)=>{if(!t&&r)try{let n=JSON.parse(r).configuration.properties.core.project;e(n);return}catch(n){}e(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let t=await this.getClient();if(t&&t.projectId)return t.projectId}let e=await this._tryGetApplicationCredentialsFromEnvironmentVariable();if(e)return e.projectId;else return null}async getExternalAccountClientProjectId(){if(!this.jsonContent||this.jsonContent.type!==bt.EXTERNAL_ACCOUNT_TYPE)return null;return await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await Rt.project("project-id")}catch(e){return null}}getCredentials(e){if(e)this.getCredentialsAsync().then((t)=>e(null,t),e);else return this.getCredentialsAsync()}async getCredentialsAsync(){let e=await this.getClient();if(e instanceof ht.Impersonated)return{client_email:e.getTargetPrincipal()};if(e instanceof bt.BaseExternalAccountClient){let t=e.getServiceAccountEmail();if(t)return{client_email:t,universe_domain:e.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[t,r]=await Promise.all([Rt.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:t,universe_domain:r}}throw Error($c.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#r();try{let e=await this.#e;if(e instanceof Wn.GdchClient&&!e.apiAudience){let t=this.clientOptions,r=t.apiEndpoint||t.servicePath;if(r){let s=`${r.startsWith("http")?"":"https://"}${r}`.replace(/\/+$/,""),i=e.createWithGdchAudience(s);return this.cachedCredential=i,i}}return e}finally{this.#e=null}}async#r(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);else if(this.keyFilename){let e=hr.resolve(this.keyFilename),t=xt.createReadStream(e);return await this.fromStreamAsync(t,this.clientOptions)}else if(this.apiKey){let e=await this.fromAPIKey(this.apiKey,this.clientOptions);e.scopes=this.scopes;let{credential:t}=await this.#t(e);return t}else{let{credential:e}=await this.getApplicationDefaultAsync(this.clientOptions);return e}}async getIdTokenClient(e){let t=await this.getClient();if(!("fetchIdToken"in t))throw Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new Tp.IdTokenClient({targetAudience:e,idTokenProvider:t})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(e){return(await this.getClient()).getRequestHeaders(e)}async authorizeRequest(e={}){let t=e.url,n=await(await this.getClient()).getRequestHeaders(t);return e.headers=yp.Gaxios.mergeHeaders(e.headers,n),e}async fetch(...e){return(await this.getClient()).fetch(...e)}async request(e){return(await this.getClient()).request(e)}getEnv(){return Ap.getEnv()}async sign(e,t){let r=await this.getClient(),n=await this.getUniverseDomain();if(t=t||`https://iamcredentials.${n}/v1/projects/-/serviceAccounts/`,r instanceof ht.Impersonated)return(await r.sign(e)).signedBlob;let s=Ep.createCrypto();if(r instanceof ut.JWT&&r.key)return await s.sign(r.key,e);let i=await this.getCredentials();if(!i.client_email)throw Error("Cannot sign data without `client_email`.");return this.signBlob(s,i.client_email,e,t)}async signBlob(e,t,r,n){let s=new URL(n+`${t}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:e.encodeBase64StringUtf8(r)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}}$c.GoogleAuth=Hc});var zc=w(function(Wc){Object.defineProperty(Wc,"__esModule",{value:!0});Wc.IAMAuth=void 0;class Vc{selector;token;constructor(e,t){this.selector=e,this.token=t,this.selector=e,this.token=t}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}Wc.IAMAuth=Vc});var eu=w(function(Qc){Object.defineProperty(Qc,"__esModule",{value:!0});Qc.DownscopedClient=Qc.EXPIRATION_TIME_OFFSET=Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var Sp=ie(),Cp=G("stream"),Yn=_e(),Op=er(),kp="urn:ietf:params:oauth:grant-type:token-exchange",bp="urn:ietf:params:oauth:token-type:access_token",xp="urn:ietf:params:oauth:token-type:access_token";Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;Qc.EXPIRATION_TIME_OFFSET=300000;class Xc extends Yn.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(e,t={accessBoundary:{accessBoundaryRules:[]}}){super(e instanceof Yn.AuthClient?{}:e);if(e instanceof Yn.AuthClient)this.authClient=e,this.credentialAccessBoundary=t;else this.authClient=e.authClient,this.credentialAccessBoundary=e.credentialAccessBoundary;if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw Error("At least one access boundary rule needs to be defined.");else if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw Error(`The provided access boundary has more than ${Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let r of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(r.availablePermissions.length===0)throw Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new Op.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(e){if(!e.expiry_date)throw Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(e),this.cachedDownscopedAccessToken=e}async getAccessToken(){if(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=Sp.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof Cp.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=(await this.authClient.getAccessToken()).token,t={grantType:kp,requestedTokenType:bp,subjectToken:e,subjectTokenType:xp},r=await this.stsCredential.exchangeToken(t,void 0,this.credentialAccessBoundary),n=this.authClient.credentials?.expiry_date||null,s=r.expires_in?new Date().getTime()+r.expires_in*1000:n;return this.cachedDownscopedAccessToken={access_token:r.access_token,expiry_date:s,res:r.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Qc.DownscopedClient=Xc});var su=w(function(ru){Object.defineProperty(ru,"__esModule",{value:!0});ru.PassThroughClient=void 0;var Np=_e();class tu extends Np.AuthClient{async request(e){return this.transporter.request(e)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}ru.PassThroughClient=tu});var hc=w(function(O){var Pp=O&&O.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Ip=O&&O.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Pp(t,e,r)};Object.defineProperty(O,"__esModule",{value:!0});O.GoogleAuth=O.auth=O.GDCH_SERVICE_ACCOUNT_TYPE=O.GdchClient=O.PassThroughClient=O.ExternalAccountAuthorizedUserClient=O.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=O.ExecutableError=O.PluggableAuthClient=O.DownscopedClient=O.BaseExternalAccountClient=O.ExternalAccountClient=O.IdentityPoolClient=O.AwsRequestSigner=O.AwsClient=O.UserRefreshClient=O.LoginTicket=O.ClientAuthentication=O.OAuth2Client=O.CodeChallengeMethod=O.Impersonated=O.JWT=O.JWTAccess=O.IdTokenClient=O.IAMAuth=O.GCPEnv=O.Compute=O.DEFAULT_UNIVERSE=O.AuthClient=O.gaxios=O.gcpMetadata=void 0;var iu=Jc();Object.defineProperty(O,"GoogleAuth",{enumerable:!0,get:function(){return iu.GoogleAuth}});O.gcpMetadata=yt();O.gaxios=ie();var ou=_e();Object.defineProperty(O,"AuthClient",{enumerable:!0,get:function(){return ou.AuthClient}});Object.defineProperty(O,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return ou.DEFAULT_UNIVERSE}});var jp=Wr();Object.defineProperty(O,"Compute",{enumerable:!0,get:function(){return jp.Compute}});var Dp=zr();Object.defineProperty(O,"GCPEnv",{enumerable:!0,get:function(){return Dp.GCPEnv}});var Up=zc();Object.defineProperty(O,"IAMAuth",{enumerable:!0,get:function(){return Up.IAMAuth}});var qp=Yr();Object.defineProperty(O,"IdTokenClient",{enumerable:!0,get:function(){return qp.IdTokenClient}});var Fp=ln();Object.defineProperty(O,"JWTAccess",{enumerable:!0,get:function(){return Fp.JWTAccess}});var Mp=fn();Object.defineProperty(O,"JWT",{enumerable:!0,get:function(){return Mp.JWT}});var Lp=pn();Object.defineProperty(O,"Impersonated",{enumerable:!0,get:function(){return Lp.Impersonated}});var Xn=Be();Object.defineProperty(O,"CodeChallengeMethod",{enumerable:!0,get:function(){return Xn.CodeChallengeMethod}});Object.defineProperty(O,"OAuth2Client",{enumerable:!0,get:function(){return Xn.OAuth2Client}});Object.defineProperty(O,"ClientAuthentication",{enumerable:!0,get:function(){return Xn.ClientAuthentication}});var Gp=Jr();Object.defineProperty(O,"LoginTicket",{enumerable:!0,get:function(){return Gp.LoginTicket}});var Bp=dn();Object.defineProperty(O,"UserRefreshClient",{enumerable:!0,get:function(){return Bp.UserRefreshClient}});var Hp=On();Object.defineProperty(O,"AwsClient",{enumerable:!0,get:function(){return Hp.AwsClient}});var $p=Cn();Object.defineProperty(O,"AwsRequestSigner",{enumerable:!0,get:function(){return $p.AwsRequestSigner}});var Kp=Sn();Object.defineProperty(O,"IdentityPoolClient",{enumerable:!0,get:function(){return Kp.IdentityPoolClient}});var Jp=Gn();Object.defineProperty(O,"ExternalAccountClient",{enumerable:!0,get:function(){return Jp.ExternalAccountClient}});var Vp=$e();Object.defineProperty(O,"BaseExternalAccountClient",{enumerable:!0,get:function(){return Vp.BaseExternalAccountClient}});var Wp=eu();Object.defineProperty(O,"DownscopedClient",{enumerable:!0,get:function(){return Wp.DownscopedClient}});var au=Ln();Object.defineProperty(O,"PluggableAuthClient",{enumerable:!0,get:function(){return au.PluggableAuthClient}});Object.defineProperty(O,"ExecutableError",{enumerable:!0,get:function(){return au.ExecutableError}});var cu=Hn();Object.defineProperty(O,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return cu.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(O,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return cu.ExternalAccountAuthorizedUserClient}});var Yp=su();Object.defineProperty(O,"PassThroughClient",{enumerable:!0,get:function(){return Yp.PassThroughClient}});var uu=Jn();Object.defineProperty(O,"GdchClient",{enumerable:!0,get:function(){return uu.GdchClient}});Object.defineProperty(O,"GDCH_SERVICE_ACCOUNT_TYPE",{enumerable:!0,get:function(){return uu.GDCH_SERVICE_ACCOUNT_TYPE}});Ip(cn(),O);var zp=new iu.GoogleAuth;O.auth=zp});
32
- export{Eu,hc};
31
+ https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys`};class Hc{checkIsGCE=void 0;useJWTAccessWithScope;defaultServicePath;get isGCE(){return this.checkIsGCE}_findProjectIdPromise;_cachedProjectId;jsonContent=null;apiKey;cachedCredential=null;#e=null;defaultScopes;keyFilename;scopes;clientOptions={};constructor(e={}){if(this._cachedProjectId=e.projectId||null,this.cachedCredential=e.authClient||null,this.keyFilename=e.keyFilename||e.keyFile,this.scopes=e.scopes,this.clientOptions=e.clientOptions||{},this.jsonContent=e.credentials||null,this.apiKey=e.apiKey||this.clientOptions.apiKey||null,this.apiKey&&(this.jsonContent||this.clientOptions.credentials))throw RangeError($c.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);if(e.universeDomain)this.clientOptions.universeDomain=e.universeDomain}setGapicJWTValues(e){e.defaultServicePath=this.defaultServicePath,e.useJWTAccessWithScope=this.useJWTAccessWithScope,e.defaultScopes=this.defaultScopes}getProjectId(e){if(e)this.getProjectIdAsync().then((t)=>e(null,t),e);else return this.getProjectIdAsync()}async getProjectIdOptional(){try{return await this.getProjectId()}catch(e){if(e instanceof Error&&e.message===$c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)return null;else throw e}}async findAndCacheProjectId(){let e=null;if(e||=await this.getProductionProjectId(),e||=await this.getFileProjectId(),e||=await this.getDefaultServiceProjectId(),e||=await this.getGCEProjectId(),e||=await this.getExternalAccountClientProjectId(),e)return this._cachedProjectId=e,e;else throw Error($c.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND)}async getProjectIdAsync(){if(this._cachedProjectId)return this._cachedProjectId;if(!this._findProjectIdPromise)this._findProjectIdPromise=this.findAndCacheProjectId();return this._findProjectIdPromise}async getUniverseDomainFromMetadataServer(){let e;try{e=await Rt.universe("universe-domain"),e||=Vn.DEFAULT_UNIVERSE}catch(t){if(t&&t?.response?.status===404)e=Vn.DEFAULT_UNIVERSE;else throw t}return e}async getUniverseDomain(){let e=Lc.originalOrCamelOptions(this.clientOptions).get("universe_domain");try{e??=(await this.getClient()).universeDomain}catch{e??=Vn.DEFAULT_UNIVERSE}return e}getAnyScopes(){return this.scopes||this.defaultScopes}getApplicationDefault(e={},t){let r;if(typeof e==="function")t=e;else r=e;if(t)this.getApplicationDefaultAsync(r).then((n)=>t(null,n.credential,n.projectId),t);else return this.getApplicationDefaultAsync(r)}async getApplicationDefaultAsync(e={}){if(this.cachedCredential)return await this.#t(this.cachedCredential,null);let t;if(t=await this._tryGetApplicationCredentialsFromEnvironmentVariable(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(t=await this._tryGetApplicationCredentialsFromWellKnownFile(e),t){if(t instanceof ut.JWT)t.scopes=this.scopes;else if(t instanceof bt.BaseExternalAccountClient)t.scopes=this.getAnyScopes();return await this.#t(t)}if(await this._checkIsGCE())return e.scopes=this.getAnyScopes(),await this.#t(new wp.Compute(e));throw Error($c.GoogleAuthExceptionMessages.NO_ADC_FOUND)}async#t(e,t=process.env.GOOGLE_CLOUD_QUOTA_PROJECT||null){let r=await this.getProjectIdOptional();if(t)e.quotaProjectId=t;return this.cachedCredential=e,{credential:e,projectId:r}}async _checkIsGCE(){if(this.checkIsGCE===void 0)this.checkIsGCE=Rt.getGCPResidency()||await Rt.isAvailable();return this.checkIsGCE}async _tryGetApplicationCredentialsFromEnvironmentVariable(e){let t=process.env.GOOGLE_APPLICATION_CREDENTIALS||process.env.google_application_credentials;if(!t||t.length===0)return null;try{return await this._getApplicationCredentialsFromFilePath(t,e)}catch(r){if(r instanceof Error)r.message=`Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${r.message}`;throw r}}async _tryGetApplicationCredentialsFromWellKnownFile(e){let t=process.env.CLOUDSDK_CONFIG;if(!t)if(this._isWindows()){if(process.env.APPDATA)t=hr.join(process.env.APPDATA,"gcloud")}else{let s=process.env.HOME;if(s)t=hr.join(s,".config","gcloud")}if(!t)return null;let r=hr.join(t,"application_default_credentials.json");if(!xt.existsSync(r))return null;return await this._getApplicationCredentialsFromFilePath(r,e)}async _getApplicationCredentialsFromFilePath(e,t={}){if(!e||e.length===0)throw Error("The file path is invalid.");try{if(e=xt.realpathSync(e),!xt.lstatSync(e).isFile())throw Error()}catch(n){if(n instanceof Error)n.message=`The file at ${e} does not exist, or it is not a file. ${n.message}`;throw n}let r=xt.createReadStream(e);return this.fromStream(r,t)}fromImpersonatedJSON(e){if(!e)throw Error("Must pass in a JSON object containing an impersonated refresh token");if(e.type!==ht.IMPERSONATED_ACCOUNT_TYPE)throw Error(`The incoming JSON object does not have the "${ht.IMPERSONATED_ACCOUNT_TYPE}" type`);if(!e.source_credentials)throw Error("The incoming JSON object does not contain a source_credentials field");if(!e.service_account_impersonation_url)throw Error("The incoming JSON object does not contain a service_account_impersonation_url field");let t=this.fromJSON(e.source_credentials);if(e.service_account_impersonation_url?.length>256)throw RangeError(`Target principal is too long: ${e.service_account_impersonation_url}`);let r=/(?<target>[^/]+):(generateAccessToken|generateIdToken)$/.exec(e.service_account_impersonation_url)?.groups?.target;if(!r)throw RangeError(`Cannot extract target principal from ${e.service_account_impersonation_url}`);let n=(this.scopes||e.scopes||this.defaultScopes)??[];return new ht.Impersonated({...e,sourceClient:t,targetPrincipal:r,targetScopes:Array.isArray(n)?n:[n]})}fromJSON(e,t={}){let r,n=Lc.originalOrCamelOptions(t).get("universe_domain");if(e.type===Gc.USER_REFRESH_ACCOUNT_TYPE)r=new Gc.UserRefreshClient(t),r.fromJSON(e);else if(e.type===ht.IMPERSONATED_ACCOUNT_TYPE)r=this.fromImpersonatedJSON(e);else if(e.type===bt.EXTERNAL_ACCOUNT_TYPE)r=vp.ExternalAccountClient.fromJSON({...e,...t}),r.scopes=this.getAnyScopes();else if(e.type===Bc.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE)r=new Bc.ExternalAccountAuthorizedUserClient({...e,...t});else if(e.type===Wn.GDCH_SERVICE_ACCOUNT_TYPE)r=new Wn.GdchClient(t),r.fromJSON(e);else t.scopes=this.scopes,r=new ut.JWT(t),this.setGapicJWTValues(r),r.fromJSON(e);if(n)r.universeDomain=n;return r}_cacheClientFromJSON(e,t){let r=this.fromJSON(e,t);return this.jsonContent=e,this.cachedCredential=r,r}fromStream(e,t={},r){let n={};if(typeof t==="function")r=t;else n=t;if(r)this.fromStreamAsync(e,n).then((s)=>r(null,s),r);else return this.fromStreamAsync(e,n)}fromStreamAsync(e,t){return new Promise((r,n)=>{if(!e)throw Error("Must pass in a stream containing the Google auth settings.");let s=[];e.setEncoding("utf8").on("error",n).on("data",(i)=>s.push(i)).on("end",()=>{try{try{let i=JSON.parse(s.join("")),u=this._cacheClientFromJSON(i,t);return r(u)}catch(i){if(!this.keyFilename)throw i;let u=new ut.JWT({...this.clientOptions,keyFile:this.keyFilename});return this.cachedCredential=u,this.setGapicJWTValues(u),r(u)}}catch(i){return n(i)}})})}fromAPIKey(e,t={}){return new ut.JWT({...t,apiKey:e})}_isWindows(){let e=mp.platform();if(e&&e.length>=3){if(e.substring(0,3).toLowerCase()==="win")return!0}return!1}async getDefaultServiceProjectId(){return new Promise((e)=>{_p.exec("gcloud config config-helper --format json",(t,r)=>{if(!t&&r)try{let n=JSON.parse(r).configuration.properties.core.project;e(n);return}catch(n){}e(null)})})}getProductionProjectId(){return process.env.GCLOUD_PROJECT||process.env.GOOGLE_CLOUD_PROJECT||process.env.gcloud_project||process.env.google_cloud_project}async getFileProjectId(){if(this.cachedCredential)return this.cachedCredential.projectId;if(this.keyFilename){let t=await this.getClient();if(t&&t.projectId)return t.projectId}let e=await this._tryGetApplicationCredentialsFromEnvironmentVariable();if(e)return e.projectId;else return null}async getExternalAccountClientProjectId(){if(!this.jsonContent||this.jsonContent.type!==bt.EXTERNAL_ACCOUNT_TYPE)return null;return await(await this.getClient()).getProjectId()}async getGCEProjectId(){try{return await Rt.project("project-id")}catch(e){return null}}getCredentials(e){if(e)this.getCredentialsAsync().then((t)=>e(null,t),e);else return this.getCredentialsAsync()}async getCredentialsAsync(){let e=await this.getClient();if(e instanceof ht.Impersonated)return{client_email:e.getTargetPrincipal()};if(e instanceof bt.BaseExternalAccountClient){let t=e.getServiceAccountEmail();if(t)return{client_email:t,universe_domain:e.universeDomain}}if(this.jsonContent)return{client_email:this.jsonContent.client_email,private_key:this.jsonContent.private_key,universe_domain:this.jsonContent.universe_domain};if(await this._checkIsGCE()){let[t,r]=await Promise.all([Rt.instance("service-accounts/default/email"),this.getUniverseDomain()]);return{client_email:t,universe_domain:r}}throw Error($c.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND)}async getClient(){if(this.cachedCredential)return this.cachedCredential;this.#e=this.#e||this.#r();try{let e=await this.#e;if(e instanceof Wn.GdchClient&&!e.apiAudience){let t=this.clientOptions,r=t.apiEndpoint||t.servicePath;if(r){let s=`${r.startsWith("http")?"":"https://"}${r}`.replace(/\/+$/,""),i=e.createWithGdchAudience(s);return this.cachedCredential=i,i}}return e}finally{this.#e=null}}async#r(){if(this.jsonContent)return this._cacheClientFromJSON(this.jsonContent,this.clientOptions);else if(this.keyFilename){let e=hr.resolve(this.keyFilename),t=xt.createReadStream(e);return await this.fromStreamAsync(t,this.clientOptions)}else if(this.apiKey){let e=await this.fromAPIKey(this.apiKey,this.clientOptions);e.scopes=this.scopes;let{credential:t}=await this.#t(e);return t}else{let{credential:e}=await this.getApplicationDefaultAsync(this.clientOptions);return e}}async getIdTokenClient(e){let t=await this.getClient();if(!("fetchIdToken"in t))throw Error("Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.");return new Tp.IdTokenClient({targetAudience:e,idTokenProvider:t})}async getAccessToken(){return(await(await this.getClient()).getAccessToken()).token}async getRequestHeaders(e){return(await this.getClient()).getRequestHeaders(e)}async authorizeRequest(e={}){let t=e.url,n=await(await this.getClient()).getRequestHeaders(t);return e.headers=yp.Gaxios.mergeHeaders(e.headers,n),e}async fetch(...e){return(await this.getClient()).fetch(...e)}async request(e){return(await this.getClient()).request(e)}getEnv(){return Ap.getEnv()}async sign(e,t){let r=await this.getClient(),n=await this.getUniverseDomain();if(t=t||`https://iamcredentials.${n}/v1/projects/-/serviceAccounts/`,r instanceof ht.Impersonated)return(await r.sign(e)).signedBlob;let s=Ep.createCrypto();if(r instanceof ut.JWT&&r.key)return await s.sign(r.key,e);let i=await this.getCredentials();if(!i.client_email)throw Error("Cannot sign data without `client_email`.");return this.signBlob(s,i.client_email,e,t)}async signBlob(e,t,r,n){let s=new URL(n+`${t}:signBlob`);return(await this.request({method:"POST",url:s.href,data:{payload:e.encodeBase64StringUtf8(r)},retry:!0,retryConfig:{httpMethodsToRetry:["POST"]}})).data.signedBlob}}$c.GoogleAuth=Hc});var zc=w(function(Wc){Object.defineProperty(Wc,"__esModule",{value:!0});Wc.IAMAuth=void 0;class Vc{selector;token;constructor(e,t){this.selector=e,this.token=t,this.selector=e,this.token=t}getRequestHeaders(){return{"x-goog-iam-authority-selector":this.selector,"x-goog-iam-authorization-token":this.token}}}Wc.IAMAuth=Vc});var eu=w(function(Qc){Object.defineProperty(Qc,"__esModule",{value:!0});Qc.DownscopedClient=Qc.EXPIRATION_TIME_OFFSET=Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=void 0;var Sp=ie(),Cp=G("stream"),Yn=_e(),Op=er(),kp="urn:ietf:params:oauth:grant-type:token-exchange",bp="urn:ietf:params:oauth:token-type:access_token",xp="urn:ietf:params:oauth:token-type:access_token";Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT=10;Qc.EXPIRATION_TIME_OFFSET=300000;class Xc extends Yn.AuthClient{authClient;credentialAccessBoundary;cachedDownscopedAccessToken;stsCredential;constructor(e,t={accessBoundary:{accessBoundaryRules:[]}}){super(e instanceof Yn.AuthClient?{}:e);if(e instanceof Yn.AuthClient)this.authClient=e,this.credentialAccessBoundary=t;else this.authClient=e.authClient,this.credentialAccessBoundary=e.credentialAccessBoundary;if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length===0)throw Error("At least one access boundary rule needs to be defined.");else if(this.credentialAccessBoundary.accessBoundary.accessBoundaryRules.length>Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT)throw Error(`The provided access boundary has more than ${Qc.MAX_ACCESS_BOUNDARY_RULES_COUNT} access boundary rules.`);for(let r of this.credentialAccessBoundary.accessBoundary.accessBoundaryRules)if(r.availablePermissions.length===0)throw Error("At least one permission should be defined in access boundary rules.");this.stsCredential=new Op.StsCredentials({tokenExchangeEndpoint:`https://sts.${this.universeDomain}/v1/token`}),this.cachedDownscopedAccessToken=null}setCredentials(e){if(!e.expiry_date)throw Error("The access token expiry_date field is missing in the provided credentials.");super.setCredentials(e),this.cachedDownscopedAccessToken=e}async getAccessToken(){if(!this.cachedDownscopedAccessToken||this.isExpired(this.cachedDownscopedAccessToken))await this.refreshAccessTokenAsync();return{token:this.cachedDownscopedAccessToken.access_token,expirationTime:this.cachedDownscopedAccessToken.expiry_date,res:this.cachedDownscopedAccessToken.res}}async getRequestHeaders(){let e=await this.getAccessToken(),t=new Headers({authorization:`Bearer ${e.token}`});return this.addSharedMetadataHeaders(t)}request(e,t){if(t)this.requestAsync(e).then((r)=>t(null,r),(r)=>t(r,r.response));else return this.requestAsync(e)}async requestAsync(e,t=!1){let r;try{let n=await this.getRequestHeaders();e.headers=Sp.Gaxios.mergeHeaders(e.headers),this.addUserProjectAndAuthHeaders(e.headers,n),r=await this.transporter.request(e)}catch(n){let s=n.response;if(s){let i=s.status,u=s.config.data instanceof Cp.Readable;if(!t&&(i===401||i===403)&&!u&&this.forceRefreshOnFailure)return await this.refreshAccessTokenAsync(),await this.requestAsync(e,!0)}throw n}return r}async refreshAccessTokenAsync(){let e=(await this.authClient.getAccessToken()).token,t={grantType:kp,requestedTokenType:bp,subjectToken:e,subjectTokenType:xp},r=await this.stsCredential.exchangeToken(t,void 0,this.credentialAccessBoundary),n=this.authClient.credentials?.expiry_date||null,s=r.expires_in?new Date().getTime()+r.expires_in*1000:n;return this.cachedDownscopedAccessToken={access_token:r.access_token,expiry_date:s,res:r.res},this.credentials={},Object.assign(this.credentials,this.cachedDownscopedAccessToken),delete this.credentials.res,this.emit("tokens",{refresh_token:null,expiry_date:this.cachedDownscopedAccessToken.expiry_date,access_token:this.cachedDownscopedAccessToken.access_token,token_type:"Bearer",id_token:null}),this.cachedDownscopedAccessToken}isExpired(e){let t=new Date().getTime();return e.expiry_date?t>=e.expiry_date-this.eagerRefreshThresholdMillis:!1}}Qc.DownscopedClient=Xc});var su=w(function(ru){Object.defineProperty(ru,"__esModule",{value:!0});ru.PassThroughClient=void 0;var Np=_e();class tu extends Np.AuthClient{async request(e){return this.transporter.request(e)}async getAccessToken(){return{}}async getRequestHeaders(){return new Headers}}ru.PassThroughClient=tu});var bc=w(function(O){var Pp=O&&O.__createBinding||(Object.create?function(e,t,r,n){if(n===void 0)n=r;var s=Object.getOwnPropertyDescriptor(t,r);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable))s={enumerable:!0,get:function(){return t[r]}};Object.defineProperty(e,n,s)}:function(e,t,r,n){if(n===void 0)n=r;e[n]=t[r]}),Ip=O&&O.__exportStar||function(e,t){for(var r in e)if(r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r))Pp(t,e,r)};Object.defineProperty(O,"__esModule",{value:!0});O.GoogleAuth=O.auth=O.GDCH_SERVICE_ACCOUNT_TYPE=O.GdchClient=O.PassThroughClient=O.ExternalAccountAuthorizedUserClient=O.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE=O.ExecutableError=O.PluggableAuthClient=O.DownscopedClient=O.BaseExternalAccountClient=O.ExternalAccountClient=O.IdentityPoolClient=O.AwsRequestSigner=O.AwsClient=O.UserRefreshClient=O.LoginTicket=O.ClientAuthentication=O.OAuth2Client=O.CodeChallengeMethod=O.Impersonated=O.JWT=O.JWTAccess=O.IdTokenClient=O.IAMAuth=O.GCPEnv=O.Compute=O.DEFAULT_UNIVERSE=O.AuthClient=O.gaxios=O.gcpMetadata=void 0;var iu=Jc();Object.defineProperty(O,"GoogleAuth",{enumerable:!0,get:function(){return iu.GoogleAuth}});O.gcpMetadata=yt();O.gaxios=ie();var ou=_e();Object.defineProperty(O,"AuthClient",{enumerable:!0,get:function(){return ou.AuthClient}});Object.defineProperty(O,"DEFAULT_UNIVERSE",{enumerable:!0,get:function(){return ou.DEFAULT_UNIVERSE}});var jp=Wr();Object.defineProperty(O,"Compute",{enumerable:!0,get:function(){return jp.Compute}});var Dp=zr();Object.defineProperty(O,"GCPEnv",{enumerable:!0,get:function(){return Dp.GCPEnv}});var Up=zc();Object.defineProperty(O,"IAMAuth",{enumerable:!0,get:function(){return Up.IAMAuth}});var qp=Yr();Object.defineProperty(O,"IdTokenClient",{enumerable:!0,get:function(){return qp.IdTokenClient}});var Fp=ln();Object.defineProperty(O,"JWTAccess",{enumerable:!0,get:function(){return Fp.JWTAccess}});var Mp=fn();Object.defineProperty(O,"JWT",{enumerable:!0,get:function(){return Mp.JWT}});var Lp=pn();Object.defineProperty(O,"Impersonated",{enumerable:!0,get:function(){return Lp.Impersonated}});var Xn=Be();Object.defineProperty(O,"CodeChallengeMethod",{enumerable:!0,get:function(){return Xn.CodeChallengeMethod}});Object.defineProperty(O,"OAuth2Client",{enumerable:!0,get:function(){return Xn.OAuth2Client}});Object.defineProperty(O,"ClientAuthentication",{enumerable:!0,get:function(){return Xn.ClientAuthentication}});var Gp=Jr();Object.defineProperty(O,"LoginTicket",{enumerable:!0,get:function(){return Gp.LoginTicket}});var Bp=dn();Object.defineProperty(O,"UserRefreshClient",{enumerable:!0,get:function(){return Bp.UserRefreshClient}});var Hp=On();Object.defineProperty(O,"AwsClient",{enumerable:!0,get:function(){return Hp.AwsClient}});var $p=Cn();Object.defineProperty(O,"AwsRequestSigner",{enumerable:!0,get:function(){return $p.AwsRequestSigner}});var Kp=Sn();Object.defineProperty(O,"IdentityPoolClient",{enumerable:!0,get:function(){return Kp.IdentityPoolClient}});var Jp=Gn();Object.defineProperty(O,"ExternalAccountClient",{enumerable:!0,get:function(){return Jp.ExternalAccountClient}});var Vp=$e();Object.defineProperty(O,"BaseExternalAccountClient",{enumerable:!0,get:function(){return Vp.BaseExternalAccountClient}});var Wp=eu();Object.defineProperty(O,"DownscopedClient",{enumerable:!0,get:function(){return Wp.DownscopedClient}});var au=Ln();Object.defineProperty(O,"PluggableAuthClient",{enumerable:!0,get:function(){return au.PluggableAuthClient}});Object.defineProperty(O,"ExecutableError",{enumerable:!0,get:function(){return au.ExecutableError}});var cu=Hn();Object.defineProperty(O,"EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE",{enumerable:!0,get:function(){return cu.EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE}});Object.defineProperty(O,"ExternalAccountAuthorizedUserClient",{enumerable:!0,get:function(){return cu.ExternalAccountAuthorizedUserClient}});var Yp=su();Object.defineProperty(O,"PassThroughClient",{enumerable:!0,get:function(){return Yp.PassThroughClient}});var uu=Jn();Object.defineProperty(O,"GdchClient",{enumerable:!0,get:function(){return uu.GdchClient}});Object.defineProperty(O,"GDCH_SERVICE_ACCOUNT_TYPE",{enumerable:!0,get:function(){return uu.GDCH_SERVICE_ACCOUNT_TYPE}});Ip(cn(),O);var zp=new iu.GoogleAuth;O.auth=zp});
32
+ export{Cu,bc};
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{Jr}from"./chunk-5patxztz.js";import{cr}from"./chunk-r1m4q8vw.js";import{pn,qi}from"./chunk-3fjgf7eb.js";import{xc,il,Jt}from"./chunk-j3xaq9s3.js";class g extends Error{code;diagnosticDetails;constructor(r,t,n){super(r);this.name="PiMessagesResponseError",this.code=t,this.diagnosticDetails=n}}function x(r){try{let t=JSON.parse(r),n=t?.error;return t&&typeof n==="object"&&n!==null&&!Array.isArray(n)?t:void 0}catch{return}}function m(r){return r.length>8192?`${r.slice(0,8192)}\u2026`:r}function y(r,t,n){let e=typeof n?.error?.message==="string"?n.error.message:void 0,s=typeof n?.error?.code==="string"?n.error.code:void 0,a=e??t,o=s?` (${s})`:"";return`${r.status} ${r.statusText}: ${a}${o}`}function w(r,t,n,e){let s=x(e),a=typeof s?.error?.code==="string"?s.error.code:void 0;return new g(y(n,e,s),a,{version:1,provider:r.provider,model:r.id,url:t.toString(),status:n.status,statusText:n.statusText,error:s?.error,body:s?void 0:m(e),timestampMs:Date.now()})}function h(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}function l(r,t){if(!t)return;il(r,{type:"pi_messages_rewrite",timestamp:Date.now(),details:{...t}})}function b(r){let t={role:"assistant",content:[],api:r.api,provider:r.provider,model:r.id,usage:h(),stopReason:"stop",timestamp:Date.now()},n=new Map;return(e)=>{switch(e.type){case"done":return Object.assign(t,{stopReason:e.reason,usage:e.usage,responseId:e.responseId}),l(t,e.rewrite),{type:"done",reason:e.reason,message:t};case"error":return Object.assign(t,{stopReason:e.reason,usage:e.usage,errorMessage:e.errorMessage,responseId:e.responseId}),l(t,e.rewrite),{type:"error",reason:e.reason,error:t};case"start":break;case"text_start":t.content[e.contentIndex]={type:"text",text:""};break;case"text_delta":t.content[e.contentIndex].text+=e.delta;break;case"text_end":Object.assign(t.content[e.contentIndex],{text:e.content,textSignature:e.contentSignature});break;case"thinking_start":t.content[e.contentIndex]={type:"thinking",thinking:""};break;case"thinking_delta":t.content[e.contentIndex].thinking+=e.delta;break;case"thinking_end":Object.assign(t.content[e.contentIndex],{thinking:e.content,thinkingSignature:e.contentSignature,redacted:e.redacted});break;case"toolcall_start":t.content[e.contentIndex]={type:"toolCall",id:e.id,name:e.toolName,arguments:{}},n.set(e.contentIndex,"");break;case"toolcall_delta":{let s=`${n.get(e.contentIndex)??""}${e.delta}`;n.set(e.contentIndex,s),t.content[e.contentIndex].arguments=Jr(s);break}case"toolcall_end":return Object.assign(t.content[e.contentIndex],e.toolCall),n.delete(e.contentIndex),{type:"toolcall_end",contentIndex:e.contentIndex,toolCall:t.content[e.contentIndex],partial:t}}return{...e,partial:t}}}async function*I(r){let t=new TextDecoder,n=r.getReader(),e="";try{while(!0){let{done:s,value:a}=await n.read();e+=s?t.decode():t.decode(a,{stream:!0}),e=e.replace(/\r\n/g,`
2
+ import{Jr}from"./chunk-5ebb2pdf.js";import{dr}from"./chunk-b5r0be06.js";import{pn,qi}from"./chunk-3fjgf7eb.js";import{Tc,dl,Jt}from"./chunk-q7t5zs7n.js";class g extends Error{code;diagnosticDetails;constructor(r,t,n){super(r);this.name="PiMessagesResponseError",this.code=t,this.diagnosticDetails=n}}function x(r){try{let t=JSON.parse(r),n=t?.error;return t&&typeof n==="object"&&n!==null&&!Array.isArray(n)?t:void 0}catch{return}}function m(r){return r.length>8192?`${r.slice(0,8192)}\u2026`:r}function y(r,t,n){let e=typeof n?.error?.message==="string"?n.error.message:void 0,s=typeof n?.error?.code==="string"?n.error.code:void 0,a=e??t,o=s?` (${s})`:"";return`${r.status} ${r.statusText}: ${a}${o}`}function w(r,t,n,e){let s=x(e),a=typeof s?.error?.code==="string"?s.error.code:void 0;return new g(y(n,e,s),a,{version:1,provider:r.provider,model:r.id,url:t.toString(),status:n.status,statusText:n.statusText,error:s?.error,body:s?void 0:m(e),timestampMs:Date.now()})}function h(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}function l(r,t){if(!t)return;dl(r,{type:"pi_messages_rewrite",timestamp:Date.now(),details:{...t}})}function b(r){let t={role:"assistant",content:[],api:r.api,provider:r.provider,model:r.id,usage:h(),stopReason:"stop",timestamp:Date.now()},n=new Map;return(e)=>{switch(e.type){case"done":return Object.assign(t,{stopReason:e.reason,usage:e.usage,responseId:e.responseId}),l(t,e.rewrite),{type:"done",reason:e.reason,message:t};case"error":return Object.assign(t,{stopReason:e.reason,usage:e.usage,errorMessage:e.errorMessage,responseId:e.responseId}),l(t,e.rewrite),{type:"error",reason:e.reason,error:t};case"start":break;case"text_start":t.content[e.contentIndex]={type:"text",text:""};break;case"text_delta":t.content[e.contentIndex].text+=e.delta;break;case"text_end":Object.assign(t.content[e.contentIndex],{text:e.content,textSignature:e.contentSignature});break;case"thinking_start":t.content[e.contentIndex]={type:"thinking",thinking:""};break;case"thinking_delta":t.content[e.contentIndex].thinking+=e.delta;break;case"thinking_end":Object.assign(t.content[e.contentIndex],{thinking:e.content,thinkingSignature:e.contentSignature,redacted:e.redacted});break;case"toolcall_start":t.content[e.contentIndex]={type:"toolCall",id:e.id,name:e.toolName,arguments:{}},n.set(e.contentIndex,"");break;case"toolcall_delta":{let s=`${n.get(e.contentIndex)??""}${e.delta}`;n.set(e.contentIndex,s),t.content[e.contentIndex].arguments=Jr(s);break}case"toolcall_end":return Object.assign(t.content[e.contentIndex],e.toolCall),n.delete(e.contentIndex),{type:"toolcall_end",contentIndex:e.contentIndex,toolCall:t.content[e.contentIndex],partial:t}}return{...e,partial:t}}}async function*I(r){let t=new TextDecoder,n=r.getReader(),e="";try{while(!0){let{done:s,value:a}=await n.read();e+=s?t.decode():t.decode(a,{stream:!0}),e=e.replace(/\r\n/g,`
3
3
  `);let o=e.indexOf(`
4
4
 
5
5
  `);while(o!==-1){let c=f(e.slice(0,o));if(c)yield c;e=e.slice(o+2),o=e.indexOf(`
6
6
 
7
7
  `)}if(s)break}if(e.trim()){let s=f(e);if(s)yield s}}finally{n.releaseLock()}}function f(r){let t=r.split(`
8
- `).find((n)=>n.startsWith("data:"))?.slice(5).trim();return t&&t!=="[DONE]"?JSON.parse(t):void 0}function k(r,t,n){let e=n?"aborted":"error",s={role:"assistant",content:[],api:r.api,provider:r.provider,model:r.id,usage:h(),stopReason:e,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()};if(!n&&t instanceof g)il(s,xc("pi_messages_response_failure",t,t.diagnosticDetails));return{type:"error",reason:e,error:s}}function E(r,t){if(r)return r;return cr("PI_CACHE_RETENTION",t)==="long"?"long":void 0}var R=(r,t,n)=>{let e=new Jt,s=b(r);return(async()=>{try{let a=n?.apiKey;if(!a)throw Error(`No API key provided for provider "${r.provider}"`);let o=new URL(`${r.baseUrl.replace(/\/+$/u,"")}/messages`);if(n?.debug)o.searchParams.set("debug","1");let c={model:r.id,context:t,options:{temperature:n?.temperature,maxTokens:n?.maxTokens,reasoning:n?.reasoning,cacheRetention:E(n?.cacheRetention,n?.env),sessionId:n?.sessionId,toolChoice:n?.toolChoice}},p=await n?.onPayload?.(c,r);if(p!==void 0)c=p;let i=await fetch(o,{method:"POST",headers:{authorization:`Bearer ${a}`,accept:"text/event-stream","content-type":"application/json",...qi(n?.headers)},body:JSON.stringify(c),signal:n?.signal});if(await n?.onResponse?.({status:i.status,headers:pn(i.headers)},r),!i.ok){let d=await i.text();throw w(r,o,i,d)}if(!i.body)throw Error(`${r.provider} response has no body`);for await(let d of I(i.body)){let u=s(d);if(e.push(u),u.type==="done"||u.type==="error")return}throw Error(`${r.provider} stream ended without a terminal event`)}catch(a){e.push(k(r,a,n?.signal?.aborted??!1))}})(),e},P=(r,t,n)=>{let e=n;return R(r,t,{...n,reasoning:n?.reasoning,toolChoice:e?.toolChoice,debug:e?.debug})};export{g as PiMessagesResponseError,R as stream,P as streamSimple};
8
+ `).find((n)=>n.startsWith("data:"))?.slice(5).trim();return t&&t!=="[DONE]"?JSON.parse(t):void 0}function k(r,t,n){let e=n?"aborted":"error",s={role:"assistant",content:[],api:r.api,provider:r.provider,model:r.id,usage:h(),stopReason:e,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()};if(!n&&t instanceof g)dl(s,Tc("pi_messages_response_failure",t,t.diagnosticDetails));return{type:"error",reason:e,error:s}}function E(r,t){if(r)return r;return dr("PI_CACHE_RETENTION",t)==="long"?"long":void 0}var R=(r,t,n)=>{let e=new Jt,s=b(r);return(async()=>{try{let a=n?.apiKey;if(!a)throw Error(`No API key provided for provider "${r.provider}"`);let o=new URL(`${r.baseUrl.replace(/\/+$/u,"")}/messages`);if(n?.debug)o.searchParams.set("debug","1");let c={model:r.id,context:t,options:{temperature:n?.temperature,maxTokens:n?.maxTokens,reasoning:n?.reasoning,cacheRetention:E(n?.cacheRetention,n?.env),sessionId:n?.sessionId,toolChoice:n?.toolChoice}},p=await n?.onPayload?.(c,r);if(p!==void 0)c=p;let i=await fetch(o,{method:"POST",headers:{authorization:`Bearer ${a}`,accept:"text/event-stream","content-type":"application/json",...qi(n?.headers)},body:JSON.stringify(c),signal:n?.signal});if(await n?.onResponse?.({status:i.status,headers:pn(i.headers)},r),!i.ok){let d=await i.text();throw w(r,o,i,d)}if(!i.body)throw Error(`${r.provider} response has no body`);for await(let d of I(i.body)){let u=s(d);if(e.push(u),u.type==="done"||u.type==="error")return}throw Error(`${r.provider} stream ended without a terminal event`)}catch(a){e.push(k(r,a,n?.signal?.aborted??!1))}})(),e},P=(r,t,n)=>{let e=n;return R(r,t,{...n,reasoning:n?.reasoning,toolChoice:e?.toolChoice,debug:e?.debug})};export{g as PiMessagesResponseError,R as stream,P as streamSimple};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import"./chunk-bcyvxp1c.js";import{_f,nM}from"./chunk-j420aqk8.js";export{_f as createKyselyAdapter,nM as kyselyAdapter};
@@ -0,0 +1,2 @@
1
+ import{u,S,L,t,o,O,ve,we,E,sn,an,ln,cn,Ce,Ie,Te,ge,Ae,_e,Zc,vi,e0,t0,a0,l0,c0,Om,De,Hs,Ih,rv,iv,cv,qv,Rw,Pw,Rx,Px,Kc,RE,bp,DE,Dl,NC,DC,Gs,UI,$d,Hp,Xe,et,tt,rt,nt,ot,st,it,ue,ae,pe,le,z,M}from"./chunk-qx553512.js";import{fo}from"./chunk-fxg81vtx.js";import{Nr}from"./chunk-68xsb3t8.js";S();function Jl({open:G,onOpenChange:F,title:V,members:_,isOwner:i,onInvite:g,onUpdateRole:D,onRemoveMember:y,currentUserId:H,availableMembersToAdd:C,onAddMember:c,type:n="team"}){let[x,b]=u("editor"),[m,A]=u(null),[T,j]=u(!1),[f,p]=u(null),[l,w]=u(null),[R,I]=u({}),[s,d]=u(null),v=(e)=>{if(!e)return"";switch(e.toLowerCase()){case"owner":return Kc();case"editor":return Hs();case"reviewer":return Gs();default:return e}},k=(e,a)=>{I((r)=>({...r,[e]:a}))},U=async(e,a)=>{if(!D)return;p(e);try{await D(e,a),M.success(Px())}catch(r){console.error(r),M.error(cv())}finally{p(null)}},q=async()=>{if(!y||!l?.id)return;p(l.id);try{await y(l.id),M.success(Rx()),w(null)}catch(e){console.error(e),M.error(iv())}finally{p(null)}},J=async()=>{if(!g)return;j(!0);try{let e=await g(x),a=`${window.location.origin}/signup?inviteCode=${e}`;A(a)}catch(e){console.error(e),M.error(rv())}finally{j(!1)}},K=async()=>{if(m){if(await fo(m))M.success(Rw())}},h=(e)=>{if(!e)return"??";return e.split(" ").map((a)=>a[0]).slice(0,2).join("").toUpperCase()},Q=(e)=>{if(!e)A(null),b("editor"),I({}),d(null);F(e)},N=Array.isArray(_)?_:[],W=Array.isArray(C)?C:[],X=n==="project"&&i?N.filter((e)=>e.role==="owner"||e.scope==="project"||e.hasCustomRole):N,B=n==="project"&&i?N.filter((e)=>e.scope==="team"&&e.role!=="owner"&&!e.hasCustomRole):[],P=n==="project"&&i?W.filter((e)=>e.scope==="project"):[];return t(ue,{open:G,onOpenChange:Q,children:o(ae,{className:"sm:max-w-xl",onOpenAutoFocus:(e)=>e.preventDefault(),children:[t(pe,{children:t(le,{children:V})}),o("div",{className:"space-y-4",children:[t("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:X.map((e)=>{let a=n==="team"&&e.scope==="project";return o("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[o("div",{className:"flex items-center gap-3",children:[o(Ce,{children:[e.image&&t(Ie,{src:e.image,alt:e.name,className:"object-cover"}),t(Te,{children:h(e.name)})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:e.name}),o("div",{className:"flex items-center gap-2",children:[!a&&t("span",{className:"text-xs text-muted-foreground capitalize",children:v(e.role)}),e.scope&&o(L,{children:[!a&&t("span",{className:"text-[10px] text-muted-foreground/70",children:"•"}),t("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?Hp():bp()})]})]})]})]}),i&&e.role!=="owner"&&e.id!==H&&o("div",{className:"flex items-center gap-2",children:[a?t(sn,{children:o(an,{children:[t(ln,{asChild:!0,children:t("span",{children:t(E,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26 justify-between",disabled:!0,children:t(ve,{className:"ml-auto h-3 w-3 opacity-50"})})})}),t(cn,{side:"top",children:t("p",{className:"text-xs",children:DE()})})]})}):o(ge,{children:[t(Ae,{asChild:!0,children:o(E,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:f===e.id,children:[v(e.role),t(ve,{className:"ml-1 h-3 w-3 opacity-50"})]})}),t(_e,{children:o(Zc,{value:e.role,onValueChange:(r)=>U(e.id,r),children:[t(vi,{value:"editor",className:"text-xs",children:Hs()}),t(vi,{value:"reviewer",className:"text-xs",children:Gs()})]})})]}),t(E,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>w(e),disabled:f===e.id,children:f===e.id?t(O,{className:"h-3 w-3 animate-spin"}):t(we,{className:"h-3 w-3"})})]})]},e.id)})}),t(Xe,{open:!!l,onOpenChange:(e)=>!e&&w(null),children:o(et,{children:[o(tt,{children:[t(nt,{children:NC()}),t(ot,{children:DC({name:l?.name||"",type:n==="project"?RE():$d()})})]}),o(rt,{children:[t(it,{children:De()}),t(st,{onClick:q,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:Dl()})]})]})})," ",i&&c&&B.length>0&&o("div",{className:"border-t pt-4",children:[t("h4",{className:"text-sm font-medium mb-1",children:a0()}),t("p",{className:"text-xs text-muted-foreground mb-3 font-normal",children:l0()}),t("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:B.map((e)=>{let a=R[e.id]||"editor";return o("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[o("div",{className:"flex items-center gap-3",children:[o(Ce,{children:[e.image&&t(Ie,{src:e.image,alt:e.name,className:"object-cover"}),t(Te,{children:h(e.name)})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:e.name}),t("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?Hp():bp()})]})]}),o("div",{className:"flex items-center gap-2",children:[o(ge,{children:[t(Ae,{asChild:!0,children:o(E,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:s===e.id,children:[v(a),t(ve,{className:"ml-1 h-3 w-3 opacity-50"})]})}),t(_e,{children:o(Zc,{value:a,onValueChange:(r)=>k(e.id,r),children:[t(vi,{value:"editor",className:"text-xs",children:Hs()}),t(vi,{value:"reviewer",className:"text-xs",children:Gs()})]})})]}),t(E,{onClick:async()=>{d(e.id);try{await c(e.id,a),M.success(Om({name:e.name||""}))}catch(r){console.error(r),M.error(Ih({name:e.name||""}))}finally{d(null)}},disabled:s!==null,size:"sm",className:"h-8 text-xs px-3",children:s===e.id?t(O,{className:"h-3 w-3 animate-spin"}):UI()})]})]},e.id)})})]}),i&&c&&P.length>0&&o("div",{className:"border-t pt-4",children:[t("h4",{className:"text-sm font-medium mb-1",children:e0()}),t("p",{className:"text-xs text-muted-foreground mb-3 font-normal",children:t0()}),t("div",{className:"max-h-[200px] overflow-y-auto space-y-2 pr-1",children:P.map((e)=>{let a=R[e.id]||"editor";return o("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50",children:[o("div",{className:"flex items-center gap-3",children:[o(Ce,{children:[e.image&&t(Ie,{src:e.image,alt:e.name,className:"object-cover"}),t(Te,{children:h(e.name)})]}),o("div",{className:"flex flex-col",children:[t("span",{className:"text-sm font-medium",children:e.name}),t("span",{className:"text-xs text-muted-foreground capitalize",children:e.scope==="team"?Hp():bp()})]})]}),o("div",{className:"flex items-center gap-2",children:[o(ge,{children:[t(Ae,{asChild:!0,children:o(E,{variant:"outline",size:"sm",className:"h-8 px-2 text-xs capitalize w-26",disabled:s===e.id,children:[v(a),t(ve,{className:"ml-1 h-3 w-3 opacity-50"})]})}),t(_e,{children:o(Zc,{value:a,onValueChange:(r)=>k(e.id,r),children:[t(vi,{value:"editor",className:"text-xs",children:Hs()}),t(vi,{value:"reviewer",className:"text-xs",children:Gs()})]})})]}),t(E,{onClick:async()=>{d(e.id);try{await c(e.id,a),M.success(Om({name:e.name||""}))}catch(r){console.error(r),M.error(Ih({name:e.name||""}))}finally{d(null)}},disabled:s!==null,size:"sm",className:"h-8 text-xs px-3",children:s===e.id?t(O,{className:"h-3 w-3 animate-spin"}):c0()})]})]},e.id)})})]}),i&&g&&o("div",{className:"border-t pt-4",children:[t("h4",{className:"text-sm font-medium mb-3",children:Pw()}),o("div",{className:"space-y-3",children:[o("div",{className:"flex gap-2",children:[o(ge,{children:[t(Ae,{asChild:!0,children:o(E,{variant:"outline",className:"w-[120px] justify-between",children:[x==="editor"?Hs():Gs(),t(ve,{className:"h-4 w-4 opacity-50"})]})}),t(_e,{children:o(Zc,{value:x,onValueChange:(e)=>b(e),children:[t(vi,{value:"editor",children:Hs()}),t(vi,{value:"reviewer",children:Gs()})]})})]}),o(E,{onClick:J,disabled:T,className:"flex-1",children:[T&&t(O,{className:"mr-2 h-4 w-4 animate-spin"}),qv()]})]}),m&&o("div",{className:"flex gap-2",children:[t(z,{value:m,readOnly:!0}),t(E,{variant:"outline",size:"icon",onClick:K,children:t(Nr,{className:"h-4 w-4"})})]})]})]})]})]})})}
2
+ export{Jl};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Xt,qt}from"./chunk-rn9rktp4.js";import{w,G}from"./chunk-kzsdp31a.js";var Vo=w(function(he){var{hasOwn:V}=Xt(),{streamCollector:te}=Xt();he.streamCollector=te;var{buildQueryString:K,HttpResponse:Q}=qt(),H=G("https"),{Readable:oe}=G("stream"),N=G("http2");function I(e){let t=e&&typeof e==="object"&&"reason"in e?e.reason:void 0;if(t){if(t instanceof Error){let s=Error("Request aborted");return s.name="AbortError",s.cause=t,s}let n=Error(String(t));return n.name="AbortError",n}let o=Error("Request aborted");return o.name="AbortError",o}var ne=["ECONNRESET","EPIPE","ETIMEDOUT"],J=(e)=>{let t={};for(let o in e){if(!V(e,o))continue;let n=e[o];t[o]=Array.isArray(n)?n.join(","):n}return t},h={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:(e)=>clearTimeout(e)},F=1000,se=(e,t,o=0)=>{if(!o)return-1;let n=(s)=>{let i=h.setTimeout(()=>{e.destroy(),t(Object.assign(Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${o} ms.`),{name:"TimeoutError"}))},o-s),c=(a)=>{if(a?.connecting)a.on("connect",()=>{h.clearTimeout(i)});else h.clearTimeout(i)};if(e.socket)c(e.socket);else e.on("socket",c)};if(o<2000)return n(0),0;return h.setTimeout(n.bind(null,F),F)},re=(e,t,o=0,n,s)=>{if(o)return h.setTimeout(()=>{let i=`@smithy/node-http-handler - [${n?"ERROR":"WARN"}] a request has exceeded the configured ${o} ms requestTimeout.`;if(n){let c=Object.assign(Error(i),{name:"TimeoutError",code:"ETIMEDOUT"});e.destroy(c),t(c)}else i+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",s?.warn?.(i)},o);return-1},ie=3000,ce=(e,{keepAlive:t,keepAliveMsecs:o},n=ie)=>{if(t!==!0)return-1;let s=()=>{if(e.socket)e.socket.setKeepAlive(t,o||0);else e.on("socket",(i)=>{i.setKeepAlive(t,o||0)})};if(n===0)return s(),0;return h.setTimeout(s,n)},j=3000,ae=(e,t,o=0)=>{let n=(s)=>{let i=o-s,c=()=>{e.destroy(),t(Object.assign(Error(`@smithy/node-http-handler - the request socket timed out after ${o} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}))};if(e.socket)e.socket.setTimeout(i,c),e.on("close",()=>e.socket?.removeListener("timeout",c));else e.setTimeout(i,c)};if(0<o&&o<6000)return n(0),0;return h.setTimeout(n.bind(null,o===0?0:j),j)},B=6000;async function X(e,t,o=B,n=!1){let s=t.headers,i=s?s.Expect||s.expect:void 0,c=-1,a=!0;if(!n&&i==="100-continue")a=await Promise.race([new Promise((u)=>{c=Number(h.setTimeout(()=>u(!0),Math.max(B,o)))}),new Promise((u)=>{e.on("continue",()=>{h.clearTimeout(c),u(!0)}),e.on("response",()=>{h.clearTimeout(c),u(!1)}),e.on("error",()=>{h.clearTimeout(c),u(!1)})})]);if(a)ue(e,t.body)}function ue(e,t){if(t instanceof oe){t.pipe(e);return}if(t){let o=Buffer.isBuffer(t);if(o||typeof t==="string"){if(o&&t.byteLength===0)e.end();else e.end(t);return}let s=t;if(typeof s==="object"&&s.buffer&&typeof s.byteOffset==="number"&&typeof s.byteLength==="number"){e.end(Buffer.from(s.buffer,s.byteOffset,s.byteLength));return}e.end(Buffer.from(t));return}e.end()}var fe=0,O=void 0,W=void 0;class L{config;configProvider;socketWarningTimestamp=0;externalAgent=!1;metadata={handlerProtocol:"http/1.1"};static create(e){if(typeof e?.handle==="function")return e;return new L(e)}static checkSocketUsage(e,t,o=console){let{sockets:n,requests:s,maxSockets:i}=e;if(typeof i!=="number"||i===1/0)return t;let c=15000;if(Date.now()-c<t)return t;if(n&&s)for(let a in n){if(!V(n,a))continue;let u=n[a]?.length??0,l=s[a]?.length??0;if(u>=i&&l>=2*i)return o?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${u} and ${l} additional requests are enqueued.
2
+ import{Xt,qt}from"./chunk-y5h5d5gx.js";import{w,G}from"./chunk-a8bymrv1.js";var Ko=w(function(he){var{hasOwn:V}=Xt(),{streamCollector:te}=Xt();he.streamCollector=te;var{buildQueryString:K,HttpResponse:Q}=qt(),H=G("https"),{Readable:oe}=G("stream"),N=G("http2");function I(e){let t=e&&typeof e==="object"&&"reason"in e?e.reason:void 0;if(t){if(t instanceof Error){let s=Error("Request aborted");return s.name="AbortError",s.cause=t,s}let n=Error(String(t));return n.name="AbortError",n}let o=Error("Request aborted");return o.name="AbortError",o}var ne=["ECONNRESET","EPIPE","ETIMEDOUT"],J=(e)=>{let t={};for(let o in e){if(!V(e,o))continue;let n=e[o];t[o]=Array.isArray(n)?n.join(","):n}return t},h={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:(e)=>clearTimeout(e)},F=1000,se=(e,t,o=0)=>{if(!o)return-1;let n=(s)=>{let i=h.setTimeout(()=>{e.destroy(),t(Object.assign(Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${o} ms.`),{name:"TimeoutError"}))},o-s),c=(a)=>{if(a?.connecting)a.on("connect",()=>{h.clearTimeout(i)});else h.clearTimeout(i)};if(e.socket)c(e.socket);else e.on("socket",c)};if(o<2000)return n(0),0;return h.setTimeout(n.bind(null,F),F)},re=(e,t,o=0,n,s)=>{if(o)return h.setTimeout(()=>{let i=`@smithy/node-http-handler - [${n?"ERROR":"WARN"}] a request has exceeded the configured ${o} ms requestTimeout.`;if(n){let c=Object.assign(Error(i),{name:"TimeoutError",code:"ETIMEDOUT"});e.destroy(c),t(c)}else i+=" Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.",s?.warn?.(i)},o);return-1},ie=3000,ce=(e,{keepAlive:t,keepAliveMsecs:o},n=ie)=>{if(t!==!0)return-1;let s=()=>{if(e.socket)e.socket.setKeepAlive(t,o||0);else e.on("socket",(i)=>{i.setKeepAlive(t,o||0)})};if(n===0)return s(),0;return h.setTimeout(s,n)},j=3000,ae=(e,t,o=0)=>{let n=(s)=>{let i=o-s,c=()=>{e.destroy(),t(Object.assign(Error(`@smithy/node-http-handler - the request socket timed out after ${o} ms of inactivity (configured by client requestHandler).`),{name:"TimeoutError"}))};if(e.socket)e.socket.setTimeout(i,c),e.on("close",()=>e.socket?.removeListener("timeout",c));else e.setTimeout(i,c)};if(0<o&&o<6000)return n(0),0;return h.setTimeout(n.bind(null,o===0?0:j),j)},B=6000;async function X(e,t,o=B,n=!1){let s=t.headers,i=s?s.Expect||s.expect:void 0,c=-1,a=!0;if(!n&&i==="100-continue")a=await Promise.race([new Promise((u)=>{c=Number(h.setTimeout(()=>u(!0),Math.max(B,o)))}),new Promise((u)=>{e.on("continue",()=>{h.clearTimeout(c),u(!0)}),e.on("response",()=>{h.clearTimeout(c),u(!1)}),e.on("error",()=>{h.clearTimeout(c),u(!1)})})]);if(a)ue(e,t.body)}function ue(e,t){if(t instanceof oe){t.pipe(e);return}if(t){let o=Buffer.isBuffer(t);if(o||typeof t==="string"){if(o&&t.byteLength===0)e.end();else e.end(t);return}let s=t;if(typeof s==="object"&&s.buffer&&typeof s.byteOffset==="number"&&typeof s.byteLength==="number"){e.end(Buffer.from(s.buffer,s.byteOffset,s.byteLength));return}e.end(Buffer.from(t));return}e.end()}var fe=0,O=void 0,W=void 0;class L{config;configProvider;socketWarningTimestamp=0;externalAgent=!1;metadata={handlerProtocol:"http/1.1"};static create(e){if(typeof e?.handle==="function")return e;return new L(e)}static checkSocketUsage(e,t,o=console){let{sockets:n,requests:s,maxSockets:i}=e;if(typeof i!=="number"||i===1/0)return t;let c=15000;if(Date.now()-c<t)return t;if(n&&s)for(let a in n){if(!V(n,a))continue;let u=n[a]?.length??0,l=s[a]?.length??0;if(u>=i&&l>=2*i)return o?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${u} and ${l} additional requests are enqueued.
3
3
  See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
4
4
  or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`),Date.now()}return t}constructor(e){this.configProvider=new Promise((t,o)=>{if(typeof e==="function")e().then((n)=>{t(this.resolveDefaultConfig(n))}).catch(o);else t(this.resolveDefaultConfig(e))})}destroy(){this.config?.httpAgent?.destroy(),this.config?.httpsAgent?.destroy()}async handle(e,{abortSignal:t,requestTimeout:o}={}){if(!this.config)this.config=await this.configProvider;let n=this.config,s=n.logger,i=e.protocol==="https:";if(!i&&!this.config.httpAgent)this.config.httpAgent=await this.config.httpAgentProvider();return new Promise((c,a)=>{let u=void 0,l=-1,m=-1,T=-1,C=-1,E=-1,k=()=>{h.clearTimeout(l),h.clearTimeout(m),h.clearTimeout(T),h.clearTimeout(C),h.clearTimeout(E)},U=async(r)=>{await u,k(),c(r)},p=async(r)=>{await u,k(),a(r)};if(t?.aborted){let r=I(t);p(r);return}let S=e.headers,R=S?(S.Expect??S.expect)==="100-continue":!1,x=i?n.httpsAgent:n.httpAgent;if(R&&!this.externalAgent)x=new(i?H.Agent:O)({keepAlive:!1,maxSockets:1/0});l=h.setTimeout(()=>{this.socketWarningTimestamp=L.checkSocketUsage(x,this.socketWarningTimestamp,s)},n.socketAcquisitionWarningTimeout??(n.requestTimeout??2000)+(n.connectionTimeout??1000));let D=e.query?K(e.query):"",v=void 0;if(e.username!=null||e.password!=null){let r=e.username??"",f=e.password??"";v=`${r}:${f}`}let P=e.path;if(D)P+=`?${D}`;if(e.fragment)P+=`#${e.fragment}`;let y=e.hostname??"";if(y[0]==="["&&y.endsWith("]"))y=e.hostname.slice(1,-1);else y=e.hostname;let _={headers:e.headers,host:y,method:e.method,path:P,port:e.port,agent:x,auth:v},g=(i?H.request:W)(_,(r)=>{let f=new Q({statusCode:r.statusCode||-1,reason:r.statusMessage,headers:J(r.headers),body:r});U({response:f})});if(g.on("error",(r)=>{if(ne.includes(r.code))p(Object.assign(r,{name:"TimeoutError"}));else p(r)}),t){let r=()=>{g.destroy();let f=I(t);p(f)};if(typeof t.addEventListener==="function"){let f=t;f.addEventListener("abort",r,{once:!0}),g.once("close",()=>f.removeEventListener("abort",r))}else t.onabort=r}let b=o??n.requestTimeout;m=se(g,p,n.connectionTimeout),T=re(g,p,b,n.throwOnRequestTimeout,s??console),C=ae(g,p,n.socketTimeout);let d=_.agent;if(typeof d==="object"&&"keepAlive"in d)E=ce(g,{keepAlive:d.keepAlive,keepAliveMsecs:d.keepAliveMsecs});u=X(g,e,b,this.externalAgent).catch((r)=>(k(),a(r)))})}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then((o)=>{if(e===Symbol.for("logger"))return{...o,logger:o.logger??t};return{...o,[e]:t}})}httpHandlerConfigs(){return this.config??{}}resolveDefaultConfig(e){let{requestTimeout:t,connectionTimeout:o,socketTimeout:n,socketAcquisitionWarningTimeout:s,httpAgent:i,httpsAgent:c,throwOnRequestTimeout:a,logger:u}=e||{},l=!0,m=50;return{connectionTimeout:o,requestTimeout:t,socketTimeout:n,socketAcquisitionWarningTimeout:s,throwOnRequestTimeout:a,httpAgentProvider:async()=>{let T=G("http"),{Agent:C,request:E}=T.default??T;if(W=E,O=C,i instanceof O||typeof i?.destroy==="function")return this.externalAgent=!0,i;return new O({keepAlive:!0,maxSockets:50,...i})},httpsAgent:(()=>{if(c instanceof H.Agent||typeof c?.destroy==="function")return this.externalAgent=!0,c;return new H.Agent({keepAlive:!0,maxSockets:50,...c})})(),logger:u}}}var de=new Uint16Array(1);class M{id=de[0]++;total=0;max=0;session;refs=0;constructor(e){e.unref(),this.session=e}retain(){if(this.session.destroyed)throw Error("@smithy/node-http-handler - cannot acquire reference to destroyed session.");this.refs+=1,this.total+=1,this.max=Math.max(this.refs,this.max),this.session.ref()}free(){if(this.session.destroyed)return;if(this.refs-=1,this.refs===0)this.session.unref();if(this.refs<0)throw Error("@smithy/node-http-handler - ClientHttp2Session refcount at zero, cannot decrement.")}deref(){return this.session}close(){if(!this.session.closed)this.session.close()}destroy(){if(this.refs=0,!this.session.destroyed)this.session.destroy()}useCount(){return this.refs}}class Y{sessions=[];maxConcurrency=0;constructor(e){this.sessions=(e??[]).map((t)=>new M(t))}poll(){let e=!1;for(let t of this.sessions){if(t.deref().destroyed){e=!0;continue}if(!this.maxConcurrency||t.useCount()<this.maxConcurrency)return t}if(e){for(let t of this.sessions)if(t.deref().destroyed)this.remove(t)}}offerLast(e){this.sessions.push(e)}remove(e){let t=this.sessions.indexOf(e);if(t>-1)this.sessions.splice(t,1)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}setMaxConcurrency(e){this.maxConcurrency=e}destroy(e){this.remove(e),e.destroy()}}class Z{config;connectOptions;connectionPools=new Map;constructor(e){if(this.config=e,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw RangeError("maxConcurrency must be greater than zero.")}lease(e,t){let o=this.getUrlString(e),n=this.getPool(o);if(!this.config.disableConcurrency&&!t.isEventStream){let u=n.poll();if(u)return u.retain(),u}let s=new M(this.connect(o)),i=s.deref();if(this.config.maxConcurrency)i.settings({maxConcurrentStreams:this.config.maxConcurrency},(u)=>{if(u)throw Error("Fail to set maxConcurrentStreams to "+this.config.maxConcurrency+"when creating new session for "+e.destination.toString())});let c=()=>{this.removeFromPoolAndClose(o,s)},a=()=>{this.removeFromPoolAndCheckedDestroy(o,s)};if(i.on("goaway",c),i.on("error",a),i.on("frameError",a),i.on("close",a),t.requestTimeout)i.setTimeout(t.requestTimeout,a);return n.offerLast(s),s.retain(),s}release(e,t){t.free()}createIsolatedSession(e,t){let o=this.getUrlString(e),n=new M(this.connect(o)),s=n.deref();s.settings({maxConcurrentStreams:1});let i=()=>{n.destroy()};if(s.on("error",i),s.on("frameError",i),s.on("close",i),t.requestTimeout)s.setTimeout(t.requestTimeout,i);return n.retain(),n}destroy(){for(let[e,t]of this.connectionPools){for(let o of[...t])o.destroy();this.connectionPools.delete(e)}}setMaxConcurrentStreams(e){if(e&&e<=0)throw RangeError("maxConcurrentStreams must be greater than zero.");this.config.maxConcurrency=e;for(let t of this.connectionPools.values())t.setMaxConcurrency(e)}setDisableConcurrentStreams(e){this.config.disableConcurrency=e}setNodeHttp2ConnectOptions(e){this.connectOptions=e}debug(){let e={};for(let[t,o]of this.connectionPools){let n=[];for(let s of o)n.push({id:s.id,active:s.useCount(),maxConcurrent:s.max,totalRequests:s.total});e[t]={sessions:n}}return e}removeFromPoolAndClose(e,t){this.connectionPools.get(e)?.remove(t),t.close()}removeFromPoolAndCheckedDestroy(e,t){this.connectionPools.get(e)?.remove(t),t.destroy()}getPool(e){if(!this.connectionPools.has(e)){let t=new Y;if(this.config.maxConcurrency)t.setMaxConcurrency(this.config.maxConcurrency);this.connectionPools.set(e,t)}return this.connectionPools.get(e)}getUrlString(e){return e.destination.toString()}connect(e){return this.connectOptions===void 0?N.connect(e):N.connect(e,this.connectOptions)}}var{constants:z}=N;class q{config;configProvider;metadata={handlerProtocol:"h2"};connectionManager=new Z({});static create(e){if(typeof e?.handle==="function")return e;return new q(e)}constructor(e){this.configProvider=new Promise((t,o)=>{if(typeof e==="function")e().then((n)=>{t(n||{})}).catch(o);else t(e||{})})}destroy(){this.connectionManager.destroy()}async handle(e,{abortSignal:t,requestTimeout:o,isEventStream:n}={}){if(!this.config){this.config=await this.configProvider;let{disableConcurrentStreams:u,maxConcurrentStreams:l,nodeHttp2ConnectOptions:m}=this.config;if(this.connectionManager.setDisableConcurrentStreams(u??!1),l)this.connectionManager.setMaxConcurrentStreams(l);if(m)this.connectionManager.setNodeHttp2ConnectOptions(m)}let{requestTimeout:s,disableConcurrentStreams:i}=this.config,c=i||n,a=o??s;return new Promise((u,l)=>{let m=!1,T=void 0,C=async(r)=>{await T,u(r)},E=async(r)=>{await T,l(r)};if(t?.aborted){m=!0;let r=I(t);E(r);return}let{hostname:k,method:U,port:p,protocol:S,query:R}=e,x="";if(e.username!=null||e.password!=null){let r=e.username??"",f=e.password??"";x=`${r}:${f}@`}let D=`${S}//${x}${k}${p?`:${p}`:""}`,v={destination:new URL(D)},P={requestTimeout:this.config?.sessionTimeout,isEventStream:n},y=c?this.connectionManager.createIsolatedSession(v,P):this.connectionManager.lease(v,P),_=y.deref(),A=(r)=>{if(c)y.destroy();m=!0,E(r)},g=R?K(R):"",b=e.path;if(g)b+=`?${g}`;if(e.fragment)b+=`#${e.fragment}`;let d=_.request({...e.headers,[z.HTTP2_HEADER_PATH]:b,[z.HTTP2_HEADER_METHOD]:U});if(a)d.setTimeout(a,()=>{d.close();let r=Error(`Stream timed out because of no activity for ${a} ms`);r.name="TimeoutError",A(r)});if(t){let r=()=>{d.close();let f=I(t);A(f)};if(typeof t.addEventListener==="function"){let f=t;f.addEventListener("abort",r,{once:!0}),d.once("close",()=>f.removeEventListener("abort",r))}else t.onabort=r}d.on("frameError",(r,f,ee)=>{A(Error(`Frame type id ${r} in stream id ${ee} has failed with code ${f}.`))}),d.on("error",A),d.on("aborted",()=>{A(Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${d.rstCode}.`))}),d.on("response",(r)=>{let f=new Q({statusCode:r[":status"]??-1,headers:J(r),body:d});if(m=!0,C({response:f}),c)_.close()}),d.on("close",()=>{if(c)y.destroy();else this.connectionManager.release(v,y);if(!m)A(Error("Unexpected error: http2 request did not get a response"))}),T=X(d,e,a)})}updateHttpClientConfig(e,t){this.config=void 0,this.configProvider=this.configProvider.then((o)=>({...o,[e]:t}))}httpHandlerConfigs(){return this.config??{}}}he.DEFAULT_REQUEST_TIMEOUT=fe;he.NodeHttp2Handler=q;he.NodeHttpHandler=L});
5
- export{Vo};
5
+ export{Ko};
@@ -1,2 +1,2 @@
1
- import{I}from"./chunk-vsefjzzj.js";var e=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Vn=I("user",e);var c=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],ao=I("users",c);
2
- export{Vn,ao};
1
+ import{I}from"./chunk-qx553512.js";var e=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Kn=I("user",e);var c=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],co=I("users",c);
2
+ export{Kn,co};