@powerhousedao/ph-clint-app 0.1.0-dev.89 → 0.1.0-dev.90

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 (106) hide show
  1. package/dist/browser/{editor-BuHwuzRa.js → editor-Bp2wUo8R.js} +748 -522
  2. package/dist/browser/editor-Bp2wUo8R.js.map +1 -0
  3. package/dist/browser/editors/ph-clint-project-editor/module.js +1 -1
  4. package/dist/connect/assets/{AddDriveModal-BoKLJyUY-DwlVwt2n.js → AddDriveModal-BoKLJyUY-cGJwd_2F.js} +2 -2
  5. package/dist/connect/assets/{AddDriveModal-BoKLJyUY-DwlVwt2n.js.map → AddDriveModal-BoKLJyUY-cGJwd_2F.js.map} +1 -1
  6. package/dist/connect/assets/{ClearStorageModal-CXoNWmRe-lBEW3sSH.js → ClearStorageModal-CXoNWmRe-D3ifKRm-.js} +2 -2
  7. package/dist/connect/assets/{ClearStorageModal-CXoNWmRe-lBEW3sSH.js.map → ClearStorageModal-CXoNWmRe-D3ifKRm-.js.map} +1 -1
  8. package/dist/connect/assets/{CookiesPolicyModal-1nOh6oN3-BYSDp-5J.js → CookiesPolicyModal-1nOh6oN3-kK_sx5mz.js} +2 -2
  9. package/dist/connect/assets/{CookiesPolicyModal-1nOh6oN3-BYSDp-5J.js.map → CookiesPolicyModal-1nOh6oN3-kK_sx5mz.js.map} +1 -1
  10. package/dist/connect/assets/{CreateDocumentModal-nQbLVDq3-DJbJhlYp.js → CreateDocumentModal-nQbLVDq3-DFAye2CX.js} +2 -2
  11. package/dist/connect/assets/{CreateDocumentModal-nQbLVDq3-DJbJhlYp.js.map → CreateDocumentModal-nQbLVDq3-DFAye2CX.js.map} +1 -1
  12. package/dist/connect/assets/{DebugSettingsModal-5SDhy5gt-Du3PKhbh.js → DebugSettingsModal-5SDhy5gt-DLMPdDQB.js} +2 -2
  13. package/dist/connect/assets/{DebugSettingsModal-5SDhy5gt-Du3PKhbh.js.map → DebugSettingsModal-5SDhy5gt-DLMPdDQB.js.map} +1 -1
  14. package/dist/connect/assets/{DeleteDriveModal-6P0T1QgD-CaEKmseP.js → DeleteDriveModal-6P0T1QgD-CK6cPXbT.js} +2 -2
  15. package/dist/connect/assets/{DeleteDriveModal-6P0T1QgD-CaEKmseP.js.map → DeleteDriveModal-6P0T1QgD-CK6cPXbT.js.map} +1 -1
  16. package/dist/connect/assets/{DeleteItemModal-BmV1aQyZ-B01dssV-.js → DeleteItemModal-BmV1aQyZ-Ld9lHNhl.js} +2 -2
  17. package/dist/connect/assets/{DeleteItemModal-BmV1aQyZ-B01dssV-.js.map → DeleteItemModal-BmV1aQyZ-Ld9lHNhl.js.map} +1 -1
  18. package/dist/connect/assets/{DisclaimerModal-CVTFfN0_-CfPGYzP1.js → DisclaimerModal-CVTFfN0_-D7N9TDI4.js} +2 -2
  19. package/dist/connect/assets/{DisclaimerModal-CVTFfN0_-CfPGYzP1.js.map → DisclaimerModal-CVTFfN0_-D7N9TDI4.js.map} +1 -1
  20. package/dist/connect/assets/{DownloadDocumentWithErrorsModal-CXeFUtaz-UexzRqQT.js → DownloadDocumentWithErrorsModal-CXeFUtaz-CYIIl42M.js} +2 -2
  21. package/dist/connect/assets/{DownloadDocumentWithErrorsModal-CXeFUtaz-UexzRqQT.js.map → DownloadDocumentWithErrorsModal-CXeFUtaz-CYIIl42M.js.map} +1 -1
  22. package/dist/connect/assets/{DriveAuthRequiredModal-B3VdLwSH-C5FZCMC5.js → DriveAuthRequiredModal-B3VdLwSH-fqmI_4sF.js} +2 -2
  23. package/dist/connect/assets/{DriveAuthRequiredModal-B3VdLwSH-C5FZCMC5.js.map → DriveAuthRequiredModal-B3VdLwSH-fqmI_4sF.js.map} +1 -1
  24. package/dist/connect/assets/{DriveSettingsModal-CsNFEJ9E-BoXSbW1c.js → DriveSettingsModal-CsNFEJ9E-BR2vyeU8.js} +2 -2
  25. package/dist/connect/assets/{DriveSettingsModal-CsNFEJ9E-BoXSbW1c.js.map → DriveSettingsModal-CsNFEJ9E-BR2vyeU8.js.map} +1 -1
  26. package/dist/connect/assets/{InspectorModal-BsSihzuc-hukmcBoP.js → InspectorModal-BsSihzuc-B0n5gbGB.js} +2 -2
  27. package/dist/connect/assets/{InspectorModal-BsSihzuc-hukmcBoP.js.map → InspectorModal-BsSihzuc-B0n5gbGB.js.map} +1 -1
  28. package/dist/connect/assets/{MissingPackageModal-Bn036mWQ-BOXHWmFa.js → MissingPackageModal-Bn036mWQ-C021G1nV.js} +2 -2
  29. package/dist/connect/assets/{MissingPackageModal-Bn036mWQ-BOXHWmFa.js.map → MissingPackageModal-Bn036mWQ-C021G1nV.js.map} +1 -1
  30. package/dist/connect/assets/{SettingsModal-S_A5qf95-Fz0f2CXX.js → SettingsModal-S_A5qf95-uzigz0nk.js} +2 -2
  31. package/dist/connect/assets/{SettingsModal-S_A5qf95-Fz0f2CXX.js.map → SettingsModal-S_A5qf95-uzigz0nk.js.map} +1 -1
  32. package/dist/connect/assets/{UpgradeDriveModal-C7lV4rAX-BkeBWpDi.js → UpgradeDriveModal-C7lV4rAX-CTIf4duw.js} +2 -2
  33. package/dist/connect/assets/{UpgradeDriveModal-C7lV4rAX-BkeBWpDi.js.map → UpgradeDriveModal-C7lV4rAX-CTIf4duw.js.map} +1 -1
  34. package/dist/connect/assets/build-info-cc1PjSvF-DtAGzh0W.js.map +1 -1
  35. package/dist/connect/assets/chunk-pbuEa-1d-KEQyMDN_.js.map +1 -1
  36. package/dist/connect/assets/{components-ByEUkO4U-Mc23VVA-.js → components-ByEUkO4U-xPZUVkzr.js} +4 -4
  37. package/dist/connect/assets/{components-ByEUkO4U-Mc23VVA-.js.map → components-ByEUkO4U-xPZUVkzr.js.map} +1 -1
  38. package/dist/connect/assets/{components-HCKyLh9m.js → components-Djrujufg.js} +2 -2
  39. package/dist/connect/assets/{components-HCKyLh9m.js.map → components-Djrujufg.js.map} +1 -1
  40. package/dist/connect/assets/{connect-pRAhId57.js → connect-CGvtDtZh.js} +2 -2
  41. package/dist/connect/assets/{connect-pRAhId57.js.map → connect-CGvtDtZh.js.map} +1 -1
  42. package/dist/connect/assets/{connect.config-Bt4pvvWV-CAyer5pZ.js → connect.config-Bt4pvvWV-Dj3FkjaZ.js} +2 -2
  43. package/dist/connect/assets/{connect.config-Bt4pvvWV-CAyer5pZ.js.map → connect.config-Bt4pvvWV-Dj3FkjaZ.js.map} +1 -1
  44. package/dist/connect/assets/{dist-DmhUSVtT.js → dist-t-ezfpxv.js} +3 -3
  45. package/dist/connect/assets/{dist-DmhUSVtT.js.map → dist-t-ezfpxv.js.map} +1 -1
  46. package/dist/connect/assets/{editor-B560eld_-CIE3_3II.js → editor-B560eld_-DLpKHubk.js} +2 -2
  47. package/dist/connect/assets/{editor-B560eld_-CIE3_3II.js.map → editor-B560eld_-DLpKHubk.js.map} +1 -1
  48. package/dist/connect/assets/editor-BaQ62r3i.js +2 -0
  49. package/dist/connect/assets/editor-BaQ62r3i.js.map +1 -0
  50. package/dist/connect/assets/{editor-CAVHtR-v-ClzvSfK5.js → editor-CAVHtR-v-D33T9vW0.js} +2 -2
  51. package/dist/connect/assets/{editor-CAVHtR-v-ClzvSfK5.js.map → editor-CAVHtR-v-D33T9vW0.js.map} +1 -1
  52. package/dist/connect/assets/{editor-CVCLxUhe-C6nP7EPN.js → editor-CVCLxUhe-C9Ftgu1S.js} +2 -2
  53. package/dist/connect/assets/{editor-CVCLxUhe-C6nP7EPN.js.map → editor-CVCLxUhe-C9Ftgu1S.js.map} +1 -1
  54. package/dist/connect/assets/{editor-DnG2Zzet-CRhirYbH.js → editor-DnG2Zzet-CQ38uSti.js} +2 -2
  55. package/dist/connect/assets/{editor-DnG2Zzet-CRhirYbH.js.map → editor-DnG2Zzet-CQ38uSti.js.map} +1 -1
  56. package/dist/connect/assets/{editor-mor7dV6n-DDigdbLM.js → editor-mor7dV6n-NTU9k1uj.js} +2 -2
  57. package/dist/connect/assets/{editor-mor7dV6n-DDigdbLM.js.map → editor-mor7dV6n-NTU9k1uj.js.map} +1 -1
  58. package/dist/connect/assets/{editor-xCnDas6c-CyHuSL7M.js → editor-xCnDas6c-DdGhx--5.js} +2 -2
  59. package/dist/connect/assets/{editor-xCnDas6c-CyHuSL7M.js.map → editor-xCnDas6c-DdGhx--5.js.map} +1 -1
  60. package/dist/connect/assets/esm-dD38MHAT.js +10 -0
  61. package/dist/connect/assets/esm-dD38MHAT.js.map +1 -0
  62. package/dist/connect/assets/{hooks-Btogj1f0-CMXQZV6d.js → hooks-Btogj1f0-BKAAmyt-.js} +2 -2
  63. package/dist/connect/assets/{hooks-Btogj1f0-CMXQZV6d.js.map → hooks-Btogj1f0-BKAAmyt-.js.map} +1 -1
  64. package/dist/connect/assets/index-NB86TKkT.js +3 -0
  65. package/dist/connect/assets/{index-DS7vbdaR.js.map → index-NB86TKkT.js.map} +1 -1
  66. package/dist/connect/assets/{load-BWibkoFV-BVilFVpD.js → load-BWibkoFV-CDRjWwYQ.js} +2 -2
  67. package/dist/connect/assets/{load-BWibkoFV-BVilFVpD.js.map → load-BWibkoFV-CDRjWwYQ.js.map} +1 -1
  68. package/dist/connect/assets/module-1hr_ne9w-CWAVsMzZ.js.map +1 -1
  69. package/dist/connect/assets/{module-DP3LMNU7.js → module-7zCQE1MC.js} +2 -2
  70. package/dist/connect/assets/{module-DP3LMNU7.js.map → module-7zCQE1MC.js.map} +1 -1
  71. package/dist/connect/assets/module-CRq_lUkG-D61oeRlC.js.map +1 -1
  72. package/dist/connect/assets/module-DP3bVbak-VbUPIBZP.js.map +1 -1
  73. package/dist/connect/assets/package-BZLLR0Ma-B7vswMvI.js.map +1 -1
  74. package/dist/connect/assets/{pglite-seed-BWk7yOwr-T-NGWlGh.js → pglite-seed-BWk7yOwr-b2F0oJiP.js} +2 -2
  75. package/dist/connect/assets/{pglite-seed-BWk7yOwr-T-NGWlGh.js.map → pglite-seed-BWk7yOwr-b2F0oJiP.js.map} +1 -1
  76. package/dist/connect/assets/pglite.worker-BuyZ0d7u.js.map +1 -1
  77. package/dist/connect/assets/pglite.worker.legacy-D5InEf0i.js.map +1 -1
  78. package/dist/connect/assets/{ph-clint-project-BZ5X7dVQ.js → ph-clint-project-p1zY6e17.js} +2 -2
  79. package/dist/connect/assets/{ph-clint-project-BZ5X7dVQ.js.map → ph-clint-project-p1zY6e17.js.map} +1 -1
  80. package/dist/connect/assets/{reactor-BxNvHOKC-DmVBqCt_.js → reactor-BxNvHOKC-CeMF1M2u.js} +4 -4
  81. package/dist/connect/assets/{reactor-BxNvHOKC-DmVBqCt_.js.map → reactor-BxNvHOKC-CeMF1M2u.js.map} +1 -1
  82. package/dist/connect/assets/{registerServiceWorker-D9l1kja7-oC4nicB2.js → registerServiceWorker-D9l1kja7-DG3DqQna.js} +2 -2
  83. package/dist/connect/assets/{registerServiceWorker-D9l1kja7-oC4nicB2.js.map → registerServiceWorker-D9l1kja7-DG3DqQna.js.map} +1 -1
  84. package/dist/connect/assets/reload-connect-toast-CwvSc6F--BQcqGaN_.js.map +1 -1
  85. package/dist/connect/assets/runtime-config-DL3QjcfM-D9g4VFtY.js.map +1 -1
  86. package/dist/connect/assets/toast-BEy42aYx-Dg_jZf6v.js.map +1 -1
  87. package/dist/connect/assets/{useRegistryPackages-B-gFECmd-CXOBKziY.js → useRegistryPackages-B-gFECmd-C8h2M5qM.js} +2 -2
  88. package/dist/connect/assets/{useRegistryPackages-B-gFECmd-CXOBKziY.js.map → useRegistryPackages-B-gFECmd-C8h2M5qM.js.map} +1 -1
  89. package/dist/connect/assets/{useVetraDocument-tpjMF571-DT5T1mNT.js → useVetraDocument-tpjMF571-DxT9GgCx.js} +2 -2
  90. package/dist/connect/assets/{useVetraDocument-tpjMF571-DT5T1mNT.js.map → useVetraDocument-tpjMF571-DxT9GgCx.js.map} +1 -1
  91. package/dist/connect/assets/utils-BiV3cs9Y-B7i9WJ1b.js.map +1 -1
  92. package/dist/connect/assets/{utils-CkWB3DRk-CxqNKFWP.js → utils-CkWB3DRk-BURJYofr.js} +2 -2
  93. package/dist/connect/assets/{utils-CkWB3DRk-CxqNKFWP.js.map → utils-CkWB3DRk-BURJYofr.js.map} +1 -1
  94. package/dist/connect/index.html +3 -3
  95. package/dist/connect/powerhouse.config.json +1 -1
  96. package/dist/node/{editor-Bev0bZuJ.mjs → editor-BC9t7D3T.mjs} +748 -517
  97. package/dist/node/editor-BC9t7D3T.mjs.map +1 -0
  98. package/dist/node/editors/ph-clint-project-editor/module.mjs +1 -1
  99. package/package.json +2 -2
  100. package/dist/browser/editor-BuHwuzRa.js.map +0 -1
  101. package/dist/connect/assets/editor-BrPMvNFl.js +0 -2
  102. package/dist/connect/assets/editor-BrPMvNFl.js.map +0 -1
  103. package/dist/connect/assets/esm-mbrYcWED.js +0 -10
  104. package/dist/connect/assets/esm-mbrYcWED.js.map +0 -1
  105. package/dist/connect/assets/index-DS7vbdaR.js +0 -3
  106. package/dist/node/editor-Bev0bZuJ.mjs.map +0 -1
@@ -1,10 +0,0 @@
1
- import{a as e,i as t,n,r,t as i}from"./chunk-BNv3lrIs.js";import{t as a}from"./__vite-browser-external-Bo8I1g8S.js";var o=i(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,`defaultMaxListeners`,{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),s=i((e=>{e.parse=function(e,n){return new t(e,n).parse()};var t=class e{constructor(e,t){this.source=e,this.transform=t||n,this.position=0,this.entries=[],this.recorded=[],this.dimension=0}isEof(){return this.position>=this.source.length}nextCharacter(){var e=this.source[this.position++];return e===`\\`?{value:this.source[this.position++],escaped:!0}:{value:e,escaped:!1}}record(e){this.recorded.push(e)}newEntry(e){var t;(this.recorded.length>0||e)&&(t=this.recorded.join(``),t===`NULL`&&!e&&(t=null),t!==null&&(t=this.transform(t)),this.entries.push(t),this.recorded=[])}consumeDimensions(){if(this.source[0]===`[`)for(;!this.isEof()&&this.nextCharacter().value!==`=`;);}parse(t){var n,r,i;for(this.consumeDimensions();!this.isEof();)if(n=this.nextCharacter(),n.value===`{`&&!i)this.dimension++,this.dimension>1&&(r=new e(this.source.substr(this.position-1),this.transform),this.entries.push(r.parse(!0)),this.position+=r.position-2);else if(n.value===`}`&&!i){if(this.dimension--,!this.dimension&&(this.newEntry(),t))return this.entries}else n.value===`"`&&!n.escaped?(i&&this.newEntry(!0),i=!i):n.value===`,`&&!i?this.newEntry():this.record(n.value);if(this.dimension!==0)throw Error(`array dimension not balanced`);return this.entries}};function n(e){return e}})),c=i(((e,t)=>{var n=s();t.exports={create:function(e,t){return{parse:function(){return n.parse(e,t)}}}}})),l=i(((e,t)=>{var n=/(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/,r=/^(\d{1,})-(\d{2})-(\d{2})( BC)?$/,i=/([Z+-])(\d{2})?:?(\d{2})?:?(\d{2})?/,a=/^-?infinity$/;t.exports=function(e){if(a.test(e))return Number(e.replace(`i`,`I`));var t=n.exec(e);if(!t)return o(e)||null;var r=!!t[8],i=parseInt(t[1],10);r&&(i=c(i));var u=parseInt(t[2],10)-1,d=t[3],f=parseInt(t[4],10),p=parseInt(t[5],10),m=parseInt(t[6],10),h=t[7];h=h?1e3*parseFloat(h):0;var g,_=s(e);return _==null?(g=new Date(i,u,d,f,p,m,h),l(i)&&g.setFullYear(i)):(g=new Date(Date.UTC(i,u,d,f,p,m,h)),l(i)&&g.setUTCFullYear(i),_!==0&&g.setTime(g.getTime()-_)),g};function o(e){var t=r.exec(e);if(t){var n=parseInt(t[1],10);t[4]&&(n=c(n));var i=parseInt(t[2],10)-1,a=t[3],o=new Date(n,i,a);return l(n)&&o.setFullYear(n),o}}function s(e){if(e.endsWith(`+00`))return 0;var t=i.exec(e.split(` `)[1]);if(t){var n=t[1];if(n===`Z`)return 0;var r=n===`-`?-1:1;return(parseInt(t[2],10)*3600+parseInt(t[3]||0,10)*60+parseInt(t[4]||0,10))*r*1e3}}function c(e){return-(e-1)}function l(e){return e>=0&&e<100}})),u=i(((e,t)=>{t.exports=r;var n=Object.prototype.hasOwnProperty;function r(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)n.call(r,i)&&(e[i]=r[i])}return e}})),d=i(((e,t)=>{var n=u();t.exports=r;function r(e){if(!(this instanceof r))return new r(e);n(this,_(e))}var i=[`seconds`,`minutes`,`hours`,`days`,`months`,`years`];r.prototype.toPostgres=function(){var e=i.filter(this.hasOwnProperty,this);return this.milliseconds&&e.indexOf(`seconds`)<0&&e.push(`seconds`),e.length===0?`0`:e.map(function(e){var t=this[e]||0;return e===`seconds`&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/\.?0+$/,``)),t+` `+e},this).join(` `)};var a={years:`Y`,months:`M`,days:`D`,hours:`H`,minutes:`M`,seconds:`S`},o=[`years`,`months`,`days`],s=[`hours`,`minutes`,`seconds`];r.prototype.toISOString=r.prototype.toISO=function(){var e=o.map(n,this).join(``),t=s.map(n,this).join(``);return`P`+e+`T`+t;function n(e){var t=this[e]||0;return e===`seconds`&&this.milliseconds&&(t=(t+this.milliseconds/1e3).toFixed(6).replace(/0+$/,``)),t+a[e]}};var c=`([+-]?\\d+)`,l=c+`\\s+years?`,d=c+`\\s+mons?`,f=c+`\\s+days?`,p=new RegExp([l,d,f,`([+-])?([\\d]*):(\\d\\d):(\\d\\d)\\.?(\\d{1,6})?`].map(function(e){return`(`+e+`)?`}).join(`\\s*`)),m={years:2,months:4,days:6,hours:9,minutes:10,seconds:11,milliseconds:12},h=[`hours`,`minutes`,`seconds`,`milliseconds`];function g(e){var t=e+`000000`.slice(e.length);return parseInt(t,10)/1e3}function _(e){if(!e)return{};var t=p.exec(e),n=t[8]===`-`;return Object.keys(m).reduce(function(e,r){var i=t[m[r]];return!i||(i=r===`milliseconds`?g(i):parseInt(i,10),!i)?e:(n&&~h.indexOf(r)&&(i*=-1),e[r]=i,e)},{})}})),f=i(((e,t)=>{var n=Buffer.from||Buffer;t.exports=function(e){if(/^\\x/.test(e))return n(e.substr(2),`hex`);for(var t=``,r=0;r<e.length;)if(e[r]!==`\\`)t+=e[r],++r;else if(/[0-7]{3}/.test(e.substr(r+1,3)))t+=String.fromCharCode(parseInt(e.substr(r+1,3),8)),r+=4;else{for(var i=1;r+i<e.length&&e[r+i]===`\\`;)i++;for(var a=0;a<Math.floor(i/2);++a)t+=`\\`;r+=Math.floor(i/2)*2}return n(t,`binary`)}})),p=i(((e,t)=>{var n=s(),r=c(),i=l(),a=d(),o=f();function u(e){return function(t){return t===null?t:e(t)}}function p(e){return e===null?e:e===`TRUE`||e===`t`||e===`true`||e===`y`||e===`yes`||e===`on`||e===`1`}function m(e){return e?n.parse(e,p):null}function h(e){return parseInt(e,10)}function g(e){return e?n.parse(e,u(h)):null}function _(e){return e?n.parse(e,u(function(e){return T(e).trim()})):null}var v=function(e){return e?r.create(e,function(e){return e!==null&&(e=D(e)),e}).parse():null},y=function(e){return e?r.create(e,function(e){return e!==null&&(e=parseFloat(e)),e}).parse():null},b=function(e){return e?r.create(e).parse():null},x=function(e){return e?r.create(e,function(e){return e!==null&&(e=i(e)),e}).parse():null},S=function(e){return e?r.create(e,function(e){return e!==null&&(e=a(e)),e}).parse():null},C=function(e){return e?n.parse(e,u(o)):null},w=function(e){return parseInt(e,10)},T=function(e){var t=String(e);return/^\d+$/.test(t)?t:e},E=function(e){return e?n.parse(e,u(JSON.parse)):null},D=function(e){return e[0]===`(`?(e=e.substring(1,e.length-1).split(`,`),{x:parseFloat(e[0]),y:parseFloat(e[1])}):null},O=function(e){if(e[0]!==`<`&&e[1]!==`(`)return null;for(var t=`(`,n=``,r=!1,i=2;i<e.length-1;i++){if(r||(t+=e[i]),e[i]===`)`){r=!0;continue}else if(!r)continue;e[i]!==`,`&&(n+=e[i])}var a=D(t);return a.radius=parseFloat(n),a};t.exports={init:function(e){e(20,T),e(21,w),e(23,w),e(26,w),e(700,parseFloat),e(701,parseFloat),e(16,p),e(1082,i),e(1114,i),e(1184,i),e(600,D),e(651,b),e(718,O),e(1e3,m),e(1001,C),e(1005,g),e(1007,g),e(1028,g),e(1016,_),e(1017,v),e(1021,y),e(1022,y),e(1231,y),e(1014,b),e(1015,b),e(1008,b),e(1009,b),e(1040,b),e(1041,b),e(1115,x),e(1182,x),e(1185,x),e(1186,a),e(1187,S),e(17,o),e(114,JSON.parse.bind(JSON)),e(3802,JSON.parse.bind(JSON)),e(199,E),e(3807,E),e(3907,b),e(2951,b),e(791,b),e(1183,b),e(1270,b)}}})),m=i(((e,t)=>{var n=1e6;function r(e){var t=e.readInt32BE(0),r=e.readUInt32BE(4),i=``;t<0&&(t=~t+(r===0),r=~r+1>>>0,i=`-`);var a=``,o=t%n,s,c,l,u,d;if(t=t/n>>>0,s=4294967296*o+r,r=s/n>>>0,c=``+(s-n*r),r===0&&t===0)return i+c+a;for(l=``,u=6-c.length,d=0;d<u;d++)l+=`0`;if(a=l+c+a,o=t%n,t=t/n>>>0,s=4294967296*o+r,r=s/n>>>0,c=``+(s-n*r),r===0&&t===0)return i+c+a;for(l=``,u=6-c.length,d=0;d<u;d++)l+=`0`;if(a=l+c+a,o=t%n,t=t/n>>>0,s=4294967296*o+r,r=s/n>>>0,c=``+(s-n*r),r===0&&t===0)return i+c+a;for(l=``,u=6-c.length,d=0;d<u;d++)l+=`0`;return a=l+c+a,o=t%n,s=4294967296*o+r,c=``+s%n,i+c+a}t.exports=r})),h=i(((e,t)=>{var n=m(),r=function(e,t,n,r,i){n||=0,r||=!1,i||=function(e,t,n){return e*2**n+t};var a=n>>3,o=function(e){return r?~e&255:e},s=255,c=8-n%8;t<c&&(s=255<<8-t&255,c=t),n&&(s>>=n%8);var l=0;n%8+t>=8&&(l=i(0,o(e[a])&s,c));for(var u=t+n>>3,d=a+1;d<u;d++)l=i(l,o(e[d]),8);var f=(t+n)%8;return f>0&&(l=i(l,o(e[u])>>8-f,f)),l},i=function(e,t,n){var i=2**(n-1)-1,a=r(e,1),o=r(e,n,1);if(o===0)return 0;var s=1,c=r(e,t,n+1,!1,function(e,t,n){e===0&&(e=1);for(var r=1;r<=n;r++)s/=2,(t&1<<n-r)>0&&(e+=s);return e});return o==2**(n+1)-1?c===0?a===0?1/0:-1/0:NaN:(a===0?1:-1)*2**(o-i)*c},a=function(e){return r(e,1)==1?-1*(r(e,15,1,!0)+1):r(e,15,1)},o=function(e){return r(e,1)==1?-1*(r(e,31,1,!0)+1):r(e,31,1)},s=function(e){return i(e,23,8)},c=function(e){return i(e,52,11)},l=function(e){var t=r(e,16,32);if(t==49152)return NaN;for(var n=1e4**r(e,16,16),i=0,a=r(e,16),o=0;o<a;o++)i+=r(e,16,64+16*o)*n,n/=1e4;var s=10**r(e,16,48);return(t===0?1:-1)*Math.round(i*s)/s},u=function(e,t){var n=r(t,1),i=r(t,63,1),a=new Date((n===0?1:-1)*i/1e3+9466848e5);return e||a.setTime(a.getTime()+a.getTimezoneOffset()*6e4),a.usec=i%1e3,a.getMicroSeconds=function(){return this.usec},a.setMicroSeconds=function(e){this.usec=e},a.getUTCMicroSeconds=function(){return this.usec},a},d=function(e){var t=r(e,32);r(e,32,32);for(var n=r(e,32,64),i=96,a=[],o=0;o<t;o++)a[o]=r(e,32,i),i+=32,i+=32;var s=function(t){var n=r(e,32,i);if(i+=32,n==4294967295)return null;var a;if(t==23||t==20)return a=r(e,n*8,i),i+=n*8,a;if(t==25)return a=e.toString(this.encoding,i>>3,(i+=n<<3)>>3),a;console.log(`ERROR: ElementType not implemented: `+t)},c=function(e,t){var n=[],r;if(e.length>1){var i=e.shift();for(r=0;r<i;r++)n[r]=c(e,t);e.unshift(i)}else for(r=0;r<e[0];r++)n[r]=s(t);return n};return c(a,n)},f=function(e){return e.toString(`utf8`)},p=function(e){return e===null?null:r(e,8)>0};t.exports={init:function(e){e(20,n),e(21,a),e(23,o),e(26,o),e(1700,l),e(700,s),e(701,c),e(16,p),e(1114,u.bind(null,!1)),e(1184,u.bind(null,!0)),e(1e3,d),e(1007,d),e(1016,d),e(1008,d),e(1009,d),e(25,f)}}})),g=i(((e,t)=>{t.exports={BOOL:16,BYTEA:17,CHAR:18,INT8:20,INT2:21,INT4:23,REGPROC:24,TEXT:25,OID:26,TID:27,XID:28,CID:29,JSON:114,XML:142,PG_NODE_TREE:194,SMGR:210,PATH:602,POLYGON:604,CIDR:650,FLOAT4:700,FLOAT8:701,ABSTIME:702,RELTIME:703,TINTERVAL:704,CIRCLE:718,MACADDR8:774,MONEY:790,MACADDR:829,INET:869,ACLITEM:1033,BPCHAR:1042,VARCHAR:1043,DATE:1082,TIME:1083,TIMESTAMP:1114,TIMESTAMPTZ:1184,INTERVAL:1186,TIMETZ:1266,BIT:1560,VARBIT:1562,NUMERIC:1700,REFCURSOR:1790,REGPROCEDURE:2202,REGOPER:2203,REGOPERATOR:2204,REGCLASS:2205,REGTYPE:2206,UUID:2950,TXID_SNAPSHOT:2970,PG_LSN:3220,PG_NDISTINCT:3361,PG_DEPENDENCIES:3402,TSVECTOR:3614,TSQUERY:3615,GTSVECTOR:3642,REGCONFIG:3734,REGDICTIONARY:3769,JSONB:3802,REGNAMESPACE:4089,REGROLE:4096}})),_=i((e=>{var t=p(),n=h(),r=c(),i=g();e.getTypeParser=s,e.setTypeParser=l,e.arrayParser=r,e.builtins=i;var a={text:{},binary:{}};function o(e){return String(e)}function s(e,t){return t||=`text`,a[t]&&a[t][e]||o}function l(e,t,n){typeof t==`function`&&(n=t,t=`text`),a[t][e]=n}t.init(function(e,t){a.text[e]=t}),n.init(function(e,t){a.binary[e]=t})})),v=i(((e,t)=>{var n;try{n=process.platform===`win32`?{}.USERNAME:{}.USER}catch{}t.exports={host:`localhost`,user:n,database:void 0,password:null,connectionString:void 0,port:5432,rows:0,binary:!1,max:10,idleTimeoutMillis:3e4,client_encoding:``,ssl:!1,application_name:void 0,fallback_application_name:void 0,options:void 0,parseInputDatesAsUTC:!1,statement_timeout:!1,lock_timeout:!1,idle_in_transaction_session_timeout:!1,query_timeout:!1,connect_timeout:0,keepalives:1,keepalives_idle:0};var r=_(),i=r.getTypeParser(20,`text`),a=r.getTypeParser(1016,`text`);t.exports.__defineSetter__(`parseInt8`,function(e){r.setTypeParser(20,`text`,e?r.getTypeParser(23,`text`):i),r.setTypeParser(1016,`text`,e?r.getTypeParser(1007,`text`):a)})})),y=i(((e,t)=>{var n=v(),r=a(),{isDate:i}=r.types||r;function o(e){return`"`+e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)+`"`}function s(e){let t=`{`;for(let n=0;n<e.length;n++)if(n>0&&(t+=`,`),e[n]===null||e[n]===void 0)t+=`NULL`;else if(Array.isArray(e[n]))t+=s(e[n]);else if(ArrayBuffer.isView(e[n])){let r=e[n];if(!(r instanceof Buffer)){let e=Buffer.from(r.buffer,r.byteOffset,r.byteLength);r=e.length===r.byteLength?e:e.slice(r.byteOffset,r.byteOffset+r.byteLength)}t+=`\\\\x`+r.toString(`hex`)}else t+=o(c(e[n]));return t+=`}`,t}var c=function(e,t){if(e==null)return null;if(typeof e==`object`){if(e instanceof Buffer)return e;if(ArrayBuffer.isView(e)){let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength);return t.length===e.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}return i(e)?n.parseInputDatesAsUTC?d(e):u(e):Array.isArray(e)?s(e):l(e,t)}return e.toString()};function l(e,t){if(e&&typeof e.toPostgres==`function`){if(t||=[],t.indexOf(e)!==-1)throw Error(`circular reference detected while preparing "`+e+`" for query`);return t.push(e),c(e.toPostgres(c),t)}return JSON.stringify(e)}function u(e){let t=-e.getTimezoneOffset(),n=e.getFullYear(),r=n<1;r&&(n=Math.abs(n)+1);let i=String(n).padStart(4,`0`)+`-`+String(e.getMonth()+1).padStart(2,`0`)+`-`+String(e.getDate()).padStart(2,`0`)+`T`+String(e.getHours()).padStart(2,`0`)+`:`+String(e.getMinutes()).padStart(2,`0`)+`:`+String(e.getSeconds()).padStart(2,`0`)+`.`+String(e.getMilliseconds()).padStart(3,`0`);return t<0?(i+=`-`,t*=-1):i+=`+`,i+=String(Math.floor(t/60)).padStart(2,`0`)+`:`+String(t%60).padStart(2,`0`),r&&(i+=` BC`),i}function d(e){let t=e.getUTCFullYear(),n=t<1;n&&(t=Math.abs(t)+1);let r=String(t).padStart(4,`0`)+`-`+String(e.getUTCMonth()+1).padStart(2,`0`)+`-`+String(e.getUTCDate()).padStart(2,`0`)+`T`+String(e.getUTCHours()).padStart(2,`0`)+`:`+String(e.getUTCMinutes()).padStart(2,`0`)+`:`+String(e.getUTCSeconds()).padStart(2,`0`)+`.`+String(e.getUTCMilliseconds()).padStart(3,`0`);return r+=`+00:00`,n&&(r+=` BC`),r}function f(e,t,n){return e=typeof e==`string`?{text:e}:e,t&&(typeof t==`function`?e.callback=t:e.values=t),n&&(e.callback=n),e}t.exports={prepareValue:function(e){return c(e)},normalizeQueryConfig:f,escapeIdentifier:function(e){return`"`+e.replace(/"/g,`""`)+`"`},escapeLiteral:function(e){let t=!1,n=`'`;if(e==null||typeof e!=`string`)return`''`;for(let r=0;r<e.length;r++){let i=e[r];i===`'`?n+=i+i:i===`\\`?(n+=i+i,t=!0):n+=i}return n+=`'`,t===!0&&(n=` E`+n),n}}})),b=i(((e,t)=>{var n=a();function r(e){return n.createHash(`md5`).update(e,`utf-8`).digest(`hex`)}function i(e,t,n){let i=r(t+e);return`md5`+r(Buffer.concat([Buffer.from(i),n]))}function o(e){return n.createHash(`sha256`).update(e).digest()}function s(e,t){return e=e.replace(/(\D)-/,`$1`),n.createHash(e).update(t).digest()}function c(e,t){return n.createHmac(`sha256`,e).update(t).digest()}async function l(e,t,r){return n.pbkdf2Sync(e,t,r,32,`sha256`)}t.exports={postgresMd5PasswordHash:i,randomBytes:n.randomBytes,deriveKey:l,sha256:o,hashByName:s,hmacSha256:c,md5:r}})),x=i(((e,t)=>{var n=a();t.exports={postgresMd5PasswordHash:l,randomBytes:s,deriveKey:p,sha256:u,hashByName:d,hmacSha256:f,md5:c};var r=n.webcrypto||globalThis.crypto,i=r.subtle,o=new TextEncoder;function s(e){return r.getRandomValues(Buffer.alloc(e))}async function c(e){try{return n.createHash(`md5`).update(e,`utf-8`).digest(`hex`)}catch{let t=typeof e==`string`?o.encode(e):e,n=await i.digest(`MD5`,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}}async function l(e,t,n){let r=await c(t+e);return`md5`+await c(Buffer.concat([Buffer.from(r),n]))}async function u(e){return await i.digest(`SHA-256`,e)}async function d(e,t){return await i.digest(e,t)}async function f(e,t){let n=await i.importKey(`raw`,e,{name:`HMAC`,hash:`SHA-256`},!1,[`sign`]);return await i.sign(`HMAC`,n,o.encode(t))}async function p(e,t,n){let r=await i.importKey(`raw`,o.encode(e),`PBKDF2`,!1,[`deriveBits`]),a={name:`PBKDF2`,hash:`SHA-256`,salt:t,iterations:n};return await i.deriveBits(a,r,256,[`deriveBits`])}})),S=i(((e,t)=>{parseInt(process.versions&&process.versions.node&&process.versions.node.split(`.`)[0])<15?t.exports=b():t.exports=x()})),C=i(((e,t)=>{function n(e,t){return Error(`SASL channel binding: `+e+` when parsing public certificate `+t.toString(`base64`))}function r(e,t){let r=e[t++];if(r<128)return{length:r,index:t};let i=r&127;if(i>4)throw n(`bad length`,e);r=0;for(let n=0;n<i;n++)r=r<<8|e[t++];return{length:r,index:t}}function i(e,t){if(e[t++]!==6)throw n(`non-OID data`,e);let{length:i,index:a}=r(e,t);t=a;let o=t+i,s=e[t++],c=(s/40>>0)+`.`+s%40;for(;t<o;){let n=0;for(;t<o;){let r=e[t++];if(n=n<<7|r&127,r<128)break}c+=`.`+n}return{oid:c,index:t}}function a(e,t){if(e[t++]!==48)throw n(`non-sequence data`,e);return r(e,t)}function o(e,t){t===void 0&&(t=0),t=a(e,t).index;let{length:o,index:s}=a(e,t);t=s+o,t=a(e,t).index;let{oid:c,index:l}=i(e,t);switch(c){case`1.2.840.113549.1.1.4`:return`MD5`;case`1.2.840.113549.1.1.5`:return`SHA-1`;case`1.2.840.113549.1.1.11`:return`SHA-256`;case`1.2.840.113549.1.1.12`:return`SHA-384`;case`1.2.840.113549.1.1.13`:return`SHA-512`;case`1.2.840.113549.1.1.14`:return`SHA-224`;case`1.2.840.113549.1.1.15`:return`SHA512-224`;case`1.2.840.113549.1.1.16`:return`SHA512-256`;case`1.2.840.10045.4.1`:return`SHA-1`;case`1.2.840.10045.4.3.1`:return`SHA-224`;case`1.2.840.10045.4.3.2`:return`SHA-256`;case`1.2.840.10045.4.3.3`:return`SHA-384`;case`1.2.840.10045.4.3.4`:return`SHA-512`;case`1.2.840.113549.1.1.10`:{if(t=l,t=a(e,t).index,e[t++]!==160)throw n(`non-tag data`,e);t=r(e,t).index,t=a(e,t).index;let{oid:o}=i(e,t);switch(o){case`1.2.840.113549.2.5`:return`MD5`;case`1.3.14.3.2.26`:return`SHA-1`;case`2.16.840.1.101.3.4.2.1`:return`SHA-256`;case`2.16.840.1.101.3.4.2.2`:return`SHA-384`;case`2.16.840.1.101.3.4.2.3`:return`SHA-512`}throw n(`unknown hash OID `+o,e)}case`1.3.101.110`:case`1.3.101.112`:return`SHA-512`;case`1.3.101.111`:case`1.3.101.113`:throw n(`Ed448 certificate channel binding is not currently supported by Postgres`)}throw n(`unknown OID `+c,e)}t.exports={signatureAlgorithmHashFromCertificate:o}})),w=i(((e,t)=>{var n=S(),{signatureAlgorithmHashFromCertificate:r}=C();function i(e,t){let r=[`SCRAM-SHA-256`];t&&r.unshift(`SCRAM-SHA-256-PLUS`);let i=r.find(t=>e.includes(t));if(!i)throw Error(`SASL: Only mechanism(s) `+r.join(` and `)+` are supported`);if(i===`SCRAM-SHA-256-PLUS`&&typeof t.getPeerCertificate!=`function`)throw Error(`SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate`);let a=n.randomBytes(18).toString(`base64`);return{mechanism:i,clientNonce:a,response:(i===`SCRAM-SHA-256-PLUS`?`p=tls-server-end-point`:t?`y`:`n`)+`,,n=*,r=`+a,message:`SASLInitialResponse`}}async function a(e,t,i,a){if(e.message!==`SASLInitialResponse`)throw Error(`SASL: Last message was not SASLInitialResponse`);if(typeof t!=`string`)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string`);if(t===``)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a non-empty string`);if(typeof i!=`string`)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: serverData must be a string`);let o=u(i);if(!o.nonce.startsWith(e.clientNonce))throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce does not start with client nonce`);if(o.nonce.length===e.clientNonce.length)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short`);let s=`n=*,r=`+e.clientNonce,c=`r=`+o.nonce+`,s=`+o.salt+`,i=`+o.iteration,l=a?`eSws`:`biws`;if(e.mechanism===`SCRAM-SHA-256-PLUS`){let e=a.getPeerCertificate().raw,t=r(e);(t===`MD5`||t===`SHA-1`)&&(t=`SHA-256`);let i=await n.hashByName(t,e);l=Buffer.concat([Buffer.from(`p=tls-server-end-point,,`),Buffer.from(i)]).toString(`base64`)}let d=`c=`+l+`,r=`+o.nonce,p=s+`,`+c+`,`+d,m=Buffer.from(o.salt,`base64`),h=await n.deriveKey(t,m,o.iteration),g=await n.hmacSha256(h,`Client Key`),_=await n.sha256(g),v=await n.hmacSha256(_,p),y=f(Buffer.from(g),Buffer.from(v)).toString(`base64`),b=await n.hmacSha256(h,`Server Key`),x=await n.hmacSha256(b,p);e.message=`SASLResponse`,e.serverSignature=Buffer.from(x).toString(`base64`),e.response=d+`,p=`+y}function o(e,t){if(e.message!==`SASLResponse`)throw Error(`SASL: Last message was not SASLResponse`);if(typeof t!=`string`)throw Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: serverData must be a string`);let{serverSignature:n}=d(t);if(n!==e.serverSignature)throw Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature does not match`)}function s(e){if(typeof e!=`string`)throw TypeError(`SASL: text must be a string`);return e.split(``).map((t,n)=>e.charCodeAt(n)).every(e=>e>=33&&e<=43||e>=45&&e<=126)}function c(e){return/^(?:[a-zA-Z0-9+/]{4})*(?:[a-zA-Z0-9+/]{2}==|[a-zA-Z0-9+/]{3}=)?$/.test(e)}function l(e){if(typeof e!=`string`)throw TypeError(`SASL: attribute pairs text must be a string`);return new Map(e.split(`,`).map(e=>{if(!/^.=/.test(e))throw Error(`SASL: Invalid attribute pair entry`);return[e[0],e.substring(2)]}))}function u(e){let t=l(e),n=t.get(`r`);if(!n)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce missing`);if(!s(n))throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: nonce must only contain printable characters`);let r=t.get(`s`);if(!r)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: salt missing`);if(!c(r))throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: salt must be base64`);let i=t.get(`i`);if(!i)throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration missing`);if(!/^[1-9][0-9]*$/.test(i))throw Error(`SASL: SCRAM-SERVER-FIRST-MESSAGE: invalid iteration count`);return{nonce:n,salt:r,iteration:parseInt(i,10)}}function d(e){let t=l(e).get(`v`);if(!t)throw Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing`);if(!c(t))throw Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature must be base64`);return{serverSignature:t}}function f(e,t){if(!Buffer.isBuffer(e))throw TypeError(`first argument must be a Buffer`);if(!Buffer.isBuffer(t))throw TypeError(`second argument must be a Buffer`);if(e.length!==t.length)throw Error(`Buffer lengths must match`);if(e.length===0)throw Error(`Buffers cannot be empty`);return Buffer.from(e.map((n,r)=>e[r]^t[r]))}t.exports={startSession:i,continueSession:a,finalizeSession:o}})),T=i(((e,t)=>{var n=_();function r(e){this._types=e||n,this.text={},this.binary={}}r.prototype.getOverrides=function(e){switch(e){case`text`:return this.text;case`binary`:return this.binary;default:return{}}},r.prototype.setTypeParser=function(e,t,n){typeof t==`function`&&(n=t,t=`text`),this.getOverrides(t)[e]=n},r.prototype.getTypeParser=function(e,t){return t||=`text`,this.getOverrides(t)[e]||this._types.getTypeParser(e,t)},t.exports=r})),E=i(((e,t)=>{function n(e,t={}){if(e.charAt(0)===`/`){let t=e.split(` `);return{host:t[0],database:t[1]}}let n={},r,i=!1;/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(e)&&(e=encodeURI(e).replace(/%25(\d\d)/g,`%$1`));try{try{r=new URL(e,`postgres://base`)}catch{r=new URL(e.replace(`@/`,`@___DUMMY___/`),`postgres://base`),i=!0}}catch(e){throw e.input&&=`*****REDACTED*****`,e}for(let e of r.searchParams.entries())n[e[0]]=e[1];if(n.user=n.user||decodeURIComponent(r.username),n.password=n.password||decodeURIComponent(r.password),r.protocol==`socket:`)return n.host=decodeURI(r.pathname),n.database=r.searchParams.get(`db`),n.client_encoding=r.searchParams.get(`encoding`),n;let o=i?``:r.hostname;n.host?o&&/^%2f/i.test(o)&&(r.pathname=o+r.pathname):n.host=decodeURIComponent(o),n.port||=r.port;let c=r.pathname.slice(1)||null;n.database=c?decodeURI(c):null,(n.ssl===`true`||n.ssl===`1`)&&(n.ssl=!0),n.ssl===`0`&&(n.ssl=!1),(n.sslcert||n.sslkey||n.sslrootcert||n.sslmode)&&(n.ssl={});let l=n.sslcert||n.sslkey||n.sslrootcert?a():null;if(n.sslcert&&(n.ssl.cert=l.readFileSync(n.sslcert).toString()),n.sslkey&&(n.ssl.key=l.readFileSync(n.sslkey).toString()),n.sslrootcert&&(n.ssl.ca=l.readFileSync(n.sslrootcert).toString()),t.useLibpqCompat&&n.uselibpqcompat)throw Error(`Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.`);if(n.uselibpqcompat===`true`||t.useLibpqCompat)switch(n.sslmode){case`disable`:n.ssl=!1;break;case`prefer`:n.ssl.rejectUnauthorized=!1;break;case`require`:n.sslrootcert?n.ssl.checkServerIdentity=function(){}:n.ssl.rejectUnauthorized=!1;break;case`verify-ca`:if(!n.ssl.ca)throw Error(`SECURITY WARNING: Using sslmode=verify-ca requires specifying a CA with sslrootcert. If a public CA is used, verify-ca allows connections to a server that somebody else may have registered with the CA, making you vulnerable to Man-in-the-Middle attacks. Either specify a custom CA certificate with sslrootcert parameter or use sslmode=verify-full for proper security.`);n.ssl.checkServerIdentity=function(){};break;case`verify-full`:break}else switch(n.sslmode){case`disable`:n.ssl=!1;break;case`prefer`:case`require`:case`verify-ca`:case`verify-full`:n.sslmode!==`verify-full`&&s(n.sslmode);break;case`no-verify`:n.ssl.rejectUnauthorized=!1;break}return n}function r(e){return Object.entries(e).reduce((e,[t,n])=>(n!=null&&(e[t]=n),e),{})}function i(e){return Object.entries(e).reduce((e,[t,n])=>{if(t===`ssl`){let i=n;typeof i==`boolean`&&(e[t]=i),typeof i==`object`&&(e[t]=r(i))}else if(n!=null)if(t===`port`){if(n!==``){let r=parseInt(n,10);if(isNaN(r))throw Error(`Invalid ${t}: ${n}`);e[t]=r}}else e[t]=n;return e},{})}function o(e){return i(n(e))}function s(e){!s.warned&&typeof process<`u`&&process.emitWarning&&(s.warned=!0,process.emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
2
- In the next major version (pg-connection-string v3.0.0 and pg v9.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees.
3
-
4
- To prepare for this change:
5
- - If you want the current behavior, explicitly use 'sslmode=verify-full'
6
- - If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${e}'
7
-
8
- See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`))}t.exports=n,n.parse=n,n.toClientConfig=i,n.parseIntoClientConfig=o})),D=i(((e,t)=>{var n=a(),r=v(),i=E().parse,o=function(e,t,n){return t[e]?t[e]:(n===void 0?n={}[`PG`+e.toUpperCase()]:n===!1||(n={}[n]),n||r[e])},s=function(){switch({}.PGSSLMODE){case`disable`:return!1;case`prefer`:case`require`:case`verify-ca`:case`verify-full`:return!0;case`no-verify`:return{rejectUnauthorized:!1}}return r.ssl},c=function(e){return`'`+(``+e).replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)+`'`},l=function(e,t,n){let r=t[n];r!=null&&e.push(n+`=`+c(r))};t.exports=class{constructor(e){e=typeof e==`string`?i(e):e||{},e.connectionString&&(e=Object.assign({},e,i(e.connectionString))),this.user=o(`user`,e),this.database=o(`database`,e),this.database===void 0&&(this.database=this.user),this.port=parseInt(o(`port`,e),10),this.host=o(`host`,e),Object.defineProperty(this,`password`,{configurable:!0,enumerable:!1,writable:!0,value:o(`password`,e)}),this.binary=o(`binary`,e),this.options=o(`options`,e),this.ssl=e.ssl===void 0?s():e.ssl,typeof this.ssl==`string`&&this.ssl===`true`&&(this.ssl=!0),this.ssl===`no-verify`&&(this.ssl={rejectUnauthorized:!1}),this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,`key`,{enumerable:!1}),this.client_encoding=o(`client_encoding`,e),this.replication=o(`replication`,e),this.isDomainSocket=!(this.host||``).indexOf(`/`),this.application_name=o(`application_name`,e,`PGAPPNAME`),this.fallback_application_name=o(`fallback_application_name`,e,!1),this.statement_timeout=o(`statement_timeout`,e,!1),this.lock_timeout=o(`lock_timeout`,e,!1),this.idle_in_transaction_session_timeout=o(`idle_in_transaction_session_timeout`,e,!1),this.query_timeout=o(`query_timeout`,e,!1),e.connectionTimeoutMillis===void 0?this.connect_timeout={}.PGCONNECT_TIMEOUT||0:this.connect_timeout=Math.floor(e.connectionTimeoutMillis/1e3),e.keepAlive===!1?this.keepalives=0:e.keepAlive===!0&&(this.keepalives=1),typeof e.keepAliveInitialDelayMillis==`number`&&(this.keepalives_idle=Math.floor(e.keepAliveInitialDelayMillis/1e3))}getLibpqConnectionString(e){let t=[];l(t,this,`user`),l(t,this,`password`),l(t,this,`port`),l(t,this,`application_name`),l(t,this,`fallback_application_name`),l(t,this,`connect_timeout`),l(t,this,`options`);let r=typeof this.ssl==`object`?this.ssl:this.ssl?{sslmode:this.ssl}:{};if(l(t,r,`sslmode`),l(t,r,`sslca`),l(t,r,`sslkey`),l(t,r,`sslcert`),l(t,r,`sslrootcert`),this.database&&t.push(`dbname=`+c(this.database)),this.replication&&t.push(`replication=`+c(this.replication)),this.host&&t.push(`host=`+c(this.host)),this.isDomainSocket)return e(null,t.join(` `));this.client_encoding&&t.push(`client_encoding=`+c(this.client_encoding)),n.lookup(this.host,function(n,r){return n?e(n,null):(t.push(`hostaddr=`+c(r)),e(null,t.join(` `)))})}}})),O=i(((e,t)=>{var n=_(),r=/^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;t.exports=class{constructor(e,t){this.command=null,this.rowCount=null,this.oid=null,this.rows=[],this.fields=[],this._parsers=void 0,this._types=t,this.RowCtor=null,this.rowAsArray=e===`array`,this.rowAsArray&&(this.parseRow=this._parseRowAsArray),this._prebuiltEmptyResultObject=null}addCommandComplete(e){let t;t=e.text?r.exec(e.text):r.exec(e.command),t&&(this.command=t[1],t[3]?(this.oid=parseInt(t[2],10),this.rowCount=parseInt(t[3],10)):t[2]&&(this.rowCount=parseInt(t[2],10)))}_parseRowAsArray(e){let t=Array(e.length);for(let n=0,r=e.length;n<r;n++){let r=e[n];r===null?t[n]=null:t[n]=this._parsers[n](r)}return t}parseRow(e){let t={...this._prebuiltEmptyResultObject};for(let n=0,r=e.length;n<r;n++){let r=e[n],i=this.fields[n].name;if(r!==null){let e=this.fields[n].format===`binary`?Buffer.from(r):r;t[i]=this._parsers[n](e)}else t[i]=null}return t}addRow(e){this.rows.push(e)}addFields(e){this.fields=e,this.fields.length&&(this._parsers=Array(e.length));let t={};for(let r=0;r<e.length;r++){let i=e[r];t[i.name]=null,this._types?this._parsers[r]=this._types.getTypeParser(i.dataTypeID,i.format||`text`):this._parsers[r]=n.getTypeParser(i.dataTypeID,i.format||`text`)}this._prebuiltEmptyResultObject={...t}}}})),ee=i(((e,t)=>{var{EventEmitter:n}=o(),r=O(),i=y();t.exports=class extends n{constructor(e,t,n){super(),e=i.normalizeQueryConfig(e,t,n),this.text=e.text,this.values=e.values,this.rows=e.rows,this.types=e.types,this.name=e.name,this.queryMode=e.queryMode,this.binary=e.binary,this.portal=e.portal||``,this.callback=e.callback,this._rowMode=e.rowMode,process.domain&&e.callback&&(this.callback=process.domain.bind(e.callback)),this._result=new r(this._rowMode,this.types),this._results=this._result,this._canceledDueToError=!1}requiresPreparation(){return this.queryMode===`extended`||this.name||this.rows?!0:!this.text||!this.values?!1:this.values.length>0}_checkForMultirow(){this._result.command&&(Array.isArray(this._results)||(this._results=[this._result]),this._result=new r(this._rowMode,this._result._types),this._results.push(this._result))}handleRowDescription(e){this._checkForMultirow(),this._result.addFields(e.fields),this._accumulateRows=this.callback||!this.listeners(`row`).length}handleDataRow(e){let t;if(!this._canceledDueToError){try{t=this._result.parseRow(e.fields)}catch(e){this._canceledDueToError=e;return}this.emit(`row`,t,this._result),this._accumulateRows&&this._result.addRow(t)}}handleCommandComplete(e,t){this._checkForMultirow(),this._result.addCommandComplete(e),this.rows&&t.sync()}handleEmptyQuery(e){this.rows&&e.sync()}handleError(e,t){if(this._canceledDueToError&&=(e=this._canceledDueToError,!1),this.callback)return this.callback(e);this.emit(`error`,e)}handleReadyForQuery(e){if(this._canceledDueToError)return this.handleError(this._canceledDueToError,e);if(this.callback)try{this.callback(null,this._results)}catch(e){process.nextTick(()=>{throw e})}this.emit(`end`,this._results)}submit(e){if(typeof this.text!=`string`&&typeof this.name!=`string`)return Error(`A query must have either text or a name. Supplying neither is unsupported.`);let t=e.parsedStatements[this.name];if(this.text&&t&&this.text!==t)return Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);if(this.values&&!Array.isArray(this.values))return Error(`Query values must be an array`);if(this.requiresPreparation()){e.stream.cork&&e.stream.cork();try{this.prepare(e)}finally{e.stream.uncork&&e.stream.uncork()}}else e.query(this.text);return null}hasBeenParsed(e){return this.name&&e.parsedStatements[this.name]}handlePortalSuspended(e){this._getRows(e,this.rows)}_getRows(e,t){e.execute({portal:this.portal,rows:t}),t?e.flush():e.sync()}prepare(e){this.hasBeenParsed(e)||e.parse({text:this.text,name:this.name,types:this.types});try{e.bind({portal:this.portal,statement:this.name,values:this.values,binary:this.binary,valueMapper:i.prepareValue})}catch(t){this.handleError(t,e);return}e.describe({type:`P`,name:this.portal||``}),this._getRows(e,this.rows)}handleCopyInResponse(e){e.sendCopyFail(`No source stream defined`)}handleCopyData(e,t){}}})),k=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NoticeMessage=e.DataRowMessage=e.CommandCompleteMessage=e.ReadyForQueryMessage=e.NotificationResponseMessage=e.BackendKeyDataMessage=e.AuthenticationMD5Password=e.ParameterStatusMessage=e.ParameterDescriptionMessage=e.RowDescriptionMessage=e.Field=e.CopyResponse=e.CopyDataMessage=e.DatabaseError=e.copyDone=e.emptyQuery=e.replicationStart=e.portalSuspended=e.noData=e.closeComplete=e.bindComplete=e.parseComplete=void 0,e.parseComplete={name:`parseComplete`,length:5},e.bindComplete={name:`bindComplete`,length:5},e.closeComplete={name:`closeComplete`,length:5},e.noData={name:`noData`,length:5},e.portalSuspended={name:`portalSuspended`,length:5},e.replicationStart={name:`replicationStart`,length:4},e.emptyQuery={name:`emptyQuery`,length:4},e.copyDone={name:`copyDone`,length:4},e.DatabaseError=class extends Error{constructor(e,t,n){super(e),this.length=t,this.name=n}},e.CopyDataMessage=class{constructor(e,t){this.length=e,this.chunk=t,this.name=`copyData`}},e.CopyResponse=class{constructor(e,t,n,r){this.length=e,this.name=t,this.binary=n,this.columnTypes=Array(r)}},e.Field=class{constructor(e,t,n,r,i,a,o){this.name=e,this.tableID=t,this.columnID=n,this.dataTypeID=r,this.dataTypeSize=i,this.dataTypeModifier=a,this.format=o}},e.RowDescriptionMessage=class{constructor(e,t){this.length=e,this.fieldCount=t,this.name=`rowDescription`,this.fields=Array(this.fieldCount)}},e.ParameterDescriptionMessage=class{constructor(e,t){this.length=e,this.parameterCount=t,this.name=`parameterDescription`,this.dataTypeIDs=Array(this.parameterCount)}},e.ParameterStatusMessage=class{constructor(e,t,n){this.length=e,this.parameterName=t,this.parameterValue=n,this.name=`parameterStatus`}},e.AuthenticationMD5Password=class{constructor(e,t){this.length=e,this.salt=t,this.name=`authenticationMD5Password`}},e.BackendKeyDataMessage=class{constructor(e,t,n){this.length=e,this.processID=t,this.secretKey=n,this.name=`backendKeyData`}},e.NotificationResponseMessage=class{constructor(e,t,n,r){this.length=e,this.processId=t,this.channel=n,this.payload=r,this.name=`notification`}},e.ReadyForQueryMessage=class{constructor(e,t){this.length=e,this.status=t,this.name=`readyForQuery`}},e.CommandCompleteMessage=class{constructor(e,t){this.length=e,this.text=t,this.name=`commandComplete`}},e.DataRowMessage=class{constructor(e,t){this.length=e,this.fields=t,this.name=`dataRow`,this.fieldCount=t.length}},e.NoticeMessage=class{constructor(e,t){this.length=e,this.message=t,this.name=`notice`}}})),A=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Writer=void 0,e.Writer=class{constructor(e=256){this.size=e,this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(e)}ensure(e){if(this.buffer.length-this.offset<e){let t=this.buffer,n=t.length+(t.length>>1)+e;this.buffer=Buffer.allocUnsafe(n),t.copy(this.buffer)}}addInt32(e){return this.ensure(4),this.buffer[this.offset++]=e>>>24&255,this.buffer[this.offset++]=e>>>16&255,this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addInt16(e){return this.ensure(2),this.buffer[this.offset++]=e>>>8&255,this.buffer[this.offset++]=e>>>0&255,this}addCString(e){if(!e)this.ensure(1);else{let t=Buffer.byteLength(e);this.ensure(t+1),this.buffer.write(e,this.offset,`utf-8`),this.offset+=t}return this.buffer[this.offset++]=0,this}addString(e=``){let t=Buffer.byteLength(e);return this.ensure(t),this.buffer.write(e,this.offset),this.offset+=t,this}add(e){return this.ensure(e.length),e.copy(this.buffer,this.offset),this.offset+=e.length,this}join(e){if(e){this.buffer[this.headerPosition]=e;let t=this.offset-(this.headerPosition+1);this.buffer.writeInt32BE(t,this.headerPosition+1)}return this.buffer.slice(e?0:5,this.offset)}flush(e){let t=this.join(e);return this.offset=5,this.headerPosition=0,this.buffer=Buffer.allocUnsafe(this.size),t}}})),j=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.serialize=void 0;var t=A(),n=new t.Writer,r=e=>{n.addInt16(3).addInt16(0);for(let t of Object.keys(e))n.addCString(t).addCString(e[t]);n.addCString(`client_encoding`).addCString(`UTF8`);let r=n.addCString(``).flush(),i=r.length+4;return new t.Writer().addInt32(i).add(r).flush()},i=()=>{let e=Buffer.allocUnsafe(8);return e.writeInt32BE(8,0),e.writeInt32BE(80877103,4),e},a=e=>n.addCString(e).flush(112),o=function(e,t){return n.addCString(e).addInt32(Buffer.byteLength(t)).addString(t),n.flush(112)},s=function(e){return n.addString(e).flush(112)},c=e=>n.addCString(e).flush(81),l=[],u=e=>{let t=e.name||``;t.length>63&&(console.error(`Warning! Postgres only supports 63 characters for query names.`),console.error(`You supplied %s (%s)`,t,t.length),console.error(`This can cause conflicts and silent errors executing queries`));let r=e.types||l,i=r.length,a=n.addCString(t).addCString(e.text).addInt16(i);for(let e=0;e<i;e++)a.addInt32(r[e]);return n.flush(80)},d=new t.Writer,f=function(e,t){for(let r=0;r<e.length;r++){let i=t?t(e[r],r):e[r];i==null?(n.addInt16(0),d.addInt32(-1)):i instanceof Buffer?(n.addInt16(1),d.addInt32(i.length),d.add(i)):(n.addInt16(0),d.addInt32(Buffer.byteLength(i)),d.addString(i))}},p=(e={})=>{let t=e.portal||``,r=e.statement||``,i=e.binary||!1,a=e.values||l,o=a.length;return n.addCString(t).addCString(r),n.addInt16(o),f(a,e.valueMapper),n.addInt16(o),n.add(d.flush()),n.addInt16(1),n.addInt16(+!!i),n.flush(66)},m=Buffer.from([69,0,0,0,9,0,0,0,0,0]),h=e=>{if(!e||!e.portal&&!e.rows)return m;let t=e.portal||``,n=e.rows||0,r=Buffer.byteLength(t),i=4+r+1+4,a=Buffer.allocUnsafe(1+i);return a[0]=69,a.writeInt32BE(i,1),a.write(t,5,`utf-8`),a[r+5]=0,a.writeUInt32BE(n,a.length-4),a},g=(e,t)=>{let n=Buffer.allocUnsafe(16);return n.writeInt32BE(16,0),n.writeInt16BE(1234,4),n.writeInt16BE(5678,6),n.writeInt32BE(e,8),n.writeInt32BE(t,12),n},_=(e,t)=>{let n=4+Buffer.byteLength(t)+1,r=Buffer.allocUnsafe(1+n);return r[0]=e,r.writeInt32BE(n,1),r.write(t,5,`utf-8`),r[n]=0,r},v=n.addCString(`P`).flush(68),y=n.addCString(`S`).flush(68),b=e=>e.name?_(68,`${e.type}${e.name||``}`):e.type===`P`?v:y,x=e=>_(67,`${e.type}${e.name||``}`),S=e=>n.add(e).flush(100),C=e=>_(102,e),w=e=>Buffer.from([e,0,0,0,4]),T=w(72),E=w(83),D=w(88),O=w(99);e.serialize={startup:r,password:a,requestSsl:i,sendSASLInitialResponseMessage:o,sendSCRAMClientFinalMessage:s,query:c,parse:u,bind:p,execute:h,describe:b,close:x,flush:()=>T,sync:()=>E,end:()=>D,copyData:S,copyDone:()=>O,copyFail:C,cancel:g}})),M=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.BufferReader=void 0,e.BufferReader=class{constructor(e=0){this.offset=e,this.buffer=Buffer.allocUnsafe(0),this.encoding=`utf-8`}setBuffer(e,t){this.offset=e,this.buffer=t}int16(){let e=this.buffer.readInt16BE(this.offset);return this.offset+=2,e}byte(){let e=this.buffer[this.offset];return this.offset++,e}int32(){let e=this.buffer.readInt32BE(this.offset);return this.offset+=4,e}uint32(){let e=this.buffer.readUInt32BE(this.offset);return this.offset+=4,e}string(e){let t=this.buffer.toString(this.encoding,this.offset,this.offset+e);return this.offset+=e,t}cstring(){let e=this.offset,t=e;for(;this.buffer[t++]!==0;);return this.offset=t,this.buffer.toString(this.encoding,e,t-1)}bytes(e){let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}}})),te=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Parser=void 0;var t=k(),n=M(),r=1,i=r+4,a=-1,o=Buffer.allocUnsafe(0);e.Parser=class{constructor(e){if(this.buffer=o,this.bufferLength=0,this.bufferOffset=0,this.reader=new n.BufferReader,e?.mode===`binary`)throw Error(`Binary mode not supported yet`);this.mode=e?.mode||`text`}parse(e,t){this.mergeBuffer(e);let n=this.bufferOffset+this.bufferLength,a=this.bufferOffset;for(;a+i<=n;){let e=this.buffer[a],o=this.buffer.readUInt32BE(a+r),s=r+o;if(s+a<=n)t(this.handlePacket(a+i,e,o,this.buffer)),a+=s;else break}a===n?(this.buffer=o,this.bufferLength=0,this.bufferOffset=0):(this.bufferLength=n-a,this.bufferOffset=a)}mergeBuffer(e){if(this.bufferLength>0){let t=this.bufferLength+e.byteLength;if(t+this.bufferOffset>this.buffer.byteLength){let e;if(t<=this.buffer.byteLength&&this.bufferOffset>=this.bufferLength)e=this.buffer;else{let n=this.buffer.byteLength*2;for(;t>=n;)n*=2;e=Buffer.allocUnsafe(n)}this.buffer.copy(e,0,this.bufferOffset,this.bufferOffset+this.bufferLength),this.buffer=e,this.bufferOffset=0}e.copy(this.buffer,this.bufferOffset+this.bufferLength),this.bufferLength=t}else this.buffer=e,this.bufferOffset=0,this.bufferLength=e.byteLength}handlePacket(e,n,r,i){let{reader:a}=this;a.setBuffer(e,i);let f;switch(n){case 50:f=t.bindComplete;break;case 49:f=t.parseComplete;break;case 51:f=t.closeComplete;break;case 110:f=t.noData;break;case 115:f=t.portalSuspended;break;case 99:f=t.copyDone;break;case 87:f=t.replicationStart;break;case 73:f=t.emptyQuery;break;case 68:f=_(a);break;case 67:f=c(a);break;case 90:f=s(a);break;case 65:f=p(a);break;case 82:f=b(a,r);break;case 83:f=v(a);break;case 75:f=y(a);break;case 69:f=x(a,`error`);break;case 78:f=x(a,`notice`);break;case 84:f=m(a);break;case 116:f=g(a);break;case 71:f=u(a);break;case 72:f=d(a);break;case 100:f=l(a,r);break;default:return new t.DatabaseError(`received invalid response: `+n.toString(16),r,`error`)}return a.setBuffer(0,o),f.length=r,f}};var s=e=>{let n=e.string(1);return new t.ReadyForQueryMessage(a,n)},c=e=>{let n=e.cstring();return new t.CommandCompleteMessage(a,n)},l=(e,n)=>{let r=e.bytes(n-4);return new t.CopyDataMessage(a,r)},u=e=>f(e,`copyInResponse`),d=e=>f(e,`copyOutResponse`),f=(e,n)=>{let r=e.byte()!==0,i=e.int16(),o=new t.CopyResponse(a,n,r,i);for(let t=0;t<i;t++)o.columnTypes[t]=e.int16();return o},p=e=>{let n=e.int32(),r=e.cstring(),i=e.cstring();return new t.NotificationResponseMessage(a,n,r,i)},m=e=>{let n=e.int16(),r=new t.RowDescriptionMessage(a,n);for(let t=0;t<n;t++)r.fields[t]=h(e);return r},h=e=>{let n=e.cstring(),r=e.uint32(),i=e.int16(),a=e.uint32(),o=e.int16(),s=e.int32(),c=e.int16()===0?`text`:`binary`;return new t.Field(n,r,i,a,o,s,c)},g=e=>{let n=e.int16(),r=new t.ParameterDescriptionMessage(a,n);for(let t=0;t<n;t++)r.dataTypeIDs[t]=e.int32();return r},_=e=>{let n=e.int16(),r=Array(n);for(let t=0;t<n;t++){let n=e.int32();r[t]=n===-1?null:e.string(n)}return new t.DataRowMessage(a,r)},v=e=>{let n=e.cstring(),r=e.cstring();return new t.ParameterStatusMessage(a,n,r)},y=e=>{let n=e.int32(),r=e.int32();return new t.BackendKeyDataMessage(a,n,r)},b=(e,n)=>{let r=e.int32(),i={name:`authenticationOk`,length:n};switch(r){case 0:break;case 3:i.length===8&&(i.name=`authenticationCleartextPassword`);break;case 5:if(i.length===12){i.name=`authenticationMD5Password`;let n=e.bytes(4);return new t.AuthenticationMD5Password(a,n)}break;case 10:{i.name=`authenticationSASL`,i.mechanisms=[];let t;do t=e.cstring(),t&&i.mechanisms.push(t);while(t)}break;case 11:i.name=`authenticationSASLContinue`,i.data=e.string(n-8);break;case 12:i.name=`authenticationSASLFinal`,i.data=e.string(n-8);break;default:throw Error(`Unknown authenticationOk message type `+r)}return i},x=(e,n)=>{let r={},i=e.string(1);for(;i!==`\0`;)r[i]=e.cstring(),i=e.string(1);let o=r.M,s=n===`notice`?new t.NoticeMessage(a,o):new t.DatabaseError(o,a,n);return s.severity=r.S,s.code=r.C,s.detail=r.D,s.hint=r.H,s.position=r.P,s.internalPosition=r.p,s.internalQuery=r.q,s.where=r.W,s.schema=r.s,s.table=r.t,s.column=r.c,s.dataType=r.d,s.constraint=r.n,s.file=r.F,s.line=r.L,s.routine=r.R,s}})),N=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DatabaseError=e.serialize=e.parse=void 0;var t=k();Object.defineProperty(e,`DatabaseError`,{enumerable:!0,get:function(){return t.DatabaseError}});var n=j();Object.defineProperty(e,`serialize`,{enumerable:!0,get:function(){return n.serialize}});var r=te();function i(e,t){let n=new r.Parser;return e.on(`data`,e=>n.parse(e,t)),new Promise(t=>e.on(`end`,()=>t()))}e.parse=i})),ne=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={}})),P=i(((e,t)=>{var{getStream:n,getSecureStream:r}=c();t.exports={getStream:n,getSecureStream:r};function i(){function e(e){return new(a()).Socket}function t(e){return a().connect(e)}return{getStream:e,getSecureStream:t}}function o(){function e(e){let{CloudflareSocket:t}=ne();return new t(e)}function t(e){return e.socket.startTls(e),e.socket}return{getStream:e,getSecureStream:t}}function s(){if(typeof navigator==`object`&&navigator!==null&&typeof navigator.userAgent==`string`)return navigator.userAgent===`Cloudflare-Workers`;if(typeof Response==`function`){let e=new Response(null,{cf:{thing:!0}});if(typeof e.cf==`object`&&e.cf!==null&&e.cf.thing)return!0}return!1}function c(){return s()?o():i()}})),F=i(((e,t)=>{var n=o().EventEmitter,{parse:r,serialize:i}=N(),{getStream:s,getSecureStream:c}=P(),l=i.flush(),u=i.sync(),d=i.end();t.exports=class extends n{constructor(e){super(),e||={},this.stream=e.stream||s(e.ssl),typeof this.stream==`function`&&(this.stream=this.stream(e)),this._keepAlive=e.keepAlive,this._keepAliveInitialDelayMillis=e.keepAliveInitialDelayMillis,this.parsedStatements={},this.ssl=e.ssl||!1,this._ending=!1,this._emitMessage=!1;let t=this;this.on(`newListener`,function(e){e===`message`&&(t._emitMessage=!0)})}connect(e,t){let n=this;this._connecting=!0,this.stream.setNoDelay(!0),this.stream.connect(e,t),this.stream.once(`connect`,function(){n._keepAlive&&n.stream.setKeepAlive(!0,n._keepAliveInitialDelayMillis),n.emit(`connect`)});let r=function(e){n._ending&&(e.code===`ECONNRESET`||e.code===`EPIPE`)||n.emit(`error`,e)};if(this.stream.on(`error`,r),this.stream.on(`close`,function(){n.emit(`end`)}),!this.ssl)return this.attachListeners(this.stream);this.stream.once(`data`,function(e){switch(e.toString(`utf8`)){case`S`:break;case`N`:return n.stream.end(),n.emit(`error`,Error(`The server does not support SSL connections`));default:return n.stream.end(),n.emit(`error`,Error(`There was an error establishing an SSL connection`))}let i={socket:n.stream};n.ssl!==!0&&(Object.assign(i,n.ssl),`key`in n.ssl&&(i.key=n.ssl.key));let o=a();o.isIP&&o.isIP(t)===0&&(i.servername=t);try{n.stream=c(i)}catch(e){return n.emit(`error`,e)}n.attachListeners(n.stream),n.stream.on(`error`,r),n.emit(`sslconnect`)})}attachListeners(e){r(e,e=>{let t=e.name===`error`?`errorMessage`:e.name;this._emitMessage&&this.emit(`message`,e),this.emit(t,e)})}requestSsl(){this.stream.write(i.requestSsl())}startup(e){this.stream.write(i.startup(e))}cancel(e,t){this._send(i.cancel(e,t))}password(e){this._send(i.password(e))}sendSASLInitialResponseMessage(e,t){this._send(i.sendSASLInitialResponseMessage(e,t))}sendSCRAMClientFinalMessage(e){this._send(i.sendSCRAMClientFinalMessage(e))}_send(e){return this.stream.writable?this.stream.write(e):!1}query(e){this._send(i.query(e))}parse(e){this._send(i.parse(e))}bind(e){this._send(i.bind(e))}execute(e){this._send(i.execute(e))}flush(){this.stream.writable&&this.stream.write(l)}sync(){this._ending=!0,this._send(u)}ref(){this.stream.ref()}unref(){this.stream.unref()}end(){if(this._ending=!0,!this._connecting||!this.stream.writable){this.stream.end();return}return this.stream.write(d,()=>{this.stream.end()})}close(e){this._send(i.close(e))}describe(e){this._send(i.describe(e))}sendCopyFromChunk(e){this._send(i.copyData(e))}endCopyFrom(){this._send(i.copyDone())}sendCopyFail(e){this._send(i.copyFail(e))}}})),re=i((e=>{e.byteLength=c,e.toByteArray=u,e.fromByteArray=p;for(var t=[],n=[],r=typeof Uint8Array<`u`?Uint8Array:Array,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,a=0,o=i.length;a<o;++a)t[a]=i[a],n[i.charCodeAt(a)]=a;n[45]=62,n[95]=63;function s(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function c(e){var t=s(e),n=t[0],r=t[1];return(n+r)*3/4-r}function l(e,t,n){return(t+n)*3/4-n}function u(e){var t,i=s(e),a=i[0],o=i[1],c=new r(l(e,a,o)),u=0,d=o>0?a-4:a,f;for(f=0;f<d;f+=4)t=n[e.charCodeAt(f)]<<18|n[e.charCodeAt(f+1)]<<12|n[e.charCodeAt(f+2)]<<6|n[e.charCodeAt(f+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=t&255;return o===2&&(t=n[e.charCodeAt(f)]<<2|n[e.charCodeAt(f+1)]>>4,c[u++]=t&255),o===1&&(t=n[e.charCodeAt(f)]<<10|n[e.charCodeAt(f+1)]<<4|n[e.charCodeAt(f+2)]>>2,c[u++]=t>>8&255,c[u++]=t&255),c}function d(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[e&63]}function f(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(d(r));return i.join(``)}function p(e){for(var n,r=e.length,i=r%3,a=[],o=16383,s=0,c=r-i;s<c;s+=o)a.push(f(e,s,s+o>c?c:s+o));return i===1?(n=e[r-1],a.push(t[n>>2]+t[n<<4&63]+`==`)):i===2&&(n=(e[r-2]<<8)+e[r-1],a.push(t[n>>10]+t[n>>4&63]+t[n<<2&63]+`=`)),a.join(``)}})),ie=i((e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}})),I=i((e=>{var t=re(),n=ie(),r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=s,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;var i=2147483647;e.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=a(),!s.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,`parent`,{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,`offset`,{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function o(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return d(e)}return c(e,t,n)}s.poolSize=8192;function c(e,t,n){if(typeof e==`string`)return f(e,t);if(ArrayBuffer.isView(e))return m(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Z(e,ArrayBuffer)||e&&Z(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<`u`&&(Z(e,SharedArrayBuffer)||e&&Z(e.buffer,SharedArrayBuffer)))return h(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return s.from(r,t,n);let i=g(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return s.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}s.from=function(e,t,n){return c(e,t,n)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array);function l(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function u(e,t,n){return l(e),e<=0||t===void 0?o(e):typeof n==`string`?o(e).fill(t,n):o(e).fill(t)}s.alloc=function(e,t,n){return u(e,t,n)};function d(e){return l(e),o(e<0?0:_(e)|0)}s.allocUnsafe=function(e){return d(e)},s.allocUnsafeSlow=function(e){return d(e)};function f(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!s.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=y(e,t)|0,r=o(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function p(e){let t=e.length<0?0:_(e.length)|0,n=o(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function m(e){if(Z(e,Uint8Array)){let t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return p(e)}function h(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new Uint8Array(e):n===void 0?new Uint8Array(e,t):new Uint8Array(e,t,n),Object.setPrototypeOf(r,s.prototype),r}function g(e){if(s.isBuffer(e)){let t=_(e.length)|0,n=o(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Q(e.length)?o(0):p(e);if(e.type===`Buffer`&&Array.isArray(e.data))return p(e.data)}function _(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function v(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==s.prototype},s.compare=function(e,t){if(Z(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),Z(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(e)||!s.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},s.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},s.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return s.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=s.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Z(t,Uint8Array))i+t.length>r.length?(s.isBuffer(t)||(t=s.from(t)),t.copy(r,i)):Uint8Array.prototype.set.call(r,t,i);else if(s.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function y(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Z(e,ArrayBuffer))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return J(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return ce(e).length;default:if(i)return r?-1:J(e).length;t=(``+t).toLowerCase(),i=!0}}s.byteLength=y;function b(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return N(this,t,n);case`utf8`:case`utf-8`:return k(this,t,n);case`ascii`:return M(this,t,n);case`latin1`:case`binary`:return te(this,t,n);case`base64`:return ee(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ne(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}s.prototype._isBuffer=!0;function x(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}s.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)x(this,t,t+1);return this},s.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)x(this,t,t+3),x(this,t+1,t+2);return this},s.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)x(this,t,t+7),x(this,t+1,t+6),x(this,t+2,t+5),x(this,t+3,t+4);return this},s.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?k(this,0,e):b.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(e){if(!s.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:s.compare(this,e)===0},s.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(s.prototype[r]=s.prototype.inspect),s.prototype.compare=function(e,t,n,r,i){if(Z(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let a=i-r,o=n-t,c=Math.min(a,o),l=this.slice(r,i),u=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==u[e]){a=l[e],o=u[e];break}return a<o?-1:+(o<a)};function S(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Q(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=s.from(t,r)),s.isBuffer(t))return t.length===0?-1:C(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof Uint8Array.prototype.indexOf==`function`?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):C(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function C(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}s.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},s.prototype.indexOf=function(e,t,n){return S(this,e,t,n,!0)},s.prototype.lastIndexOf=function(e,t,n){return S(this,e,t,n,!1)};function w(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Q(r))return o;e[n+o]=r}return o}function T(e,t,n,r){return X(J(t,e.length-n),e,n,r)}function E(e,t,n,r){return X(Y(t),e,n,r)}function D(e,t,n,r){return X(ce(t),e,n,r)}function O(e,t,n,r){return X(se(t,e.length-n),e,n,r)}s.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return w(this,e,t,n);case`utf8`:case`utf-8`:return T(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return E(this,e,t,n);case`base64`:return D(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return O(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},s.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function ee(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function k(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return j(r)}var A=4096;function j(e){let t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=A));return n}function M(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function te(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function N(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=le[e[r]];return i}function ne(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}s.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,s.prototype),r};function P(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}s.prototype.readUintLE=s.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},s.prototype.readUintBE=s.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},s.prototype.readUint8=s.prototype.readUInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(e,t){return e>>>=0,t||P(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readBigUInt64LE=$(function(e){e>>>=0,G(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),s.prototype.readBigUInt64BE=$(function(e){e>>>=0,G(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),s.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},s.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||P(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},s.prototype.readInt8=function(e,t){return e>>>=0,t||P(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){e>>>=0,t||P(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},s.prototype.readInt16BE=function(e,t){e>>>=0,t||P(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},s.prototype.readInt32LE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return e>>>=0,t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readBigInt64LE=$(function(e){e>>>=0,G(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),s.prototype.readBigInt64BE=$(function(e){e>>>=0,G(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&K(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),s.prototype.readFloatLE=function(e,t){return e>>>=0,t||P(e,4,this.length),n.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return e>>>=0,t||P(e,4,this.length),n.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return e>>>=0,t||P(e,8,this.length),n.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return e>>>=0,t||P(e,8,this.length),n.read(this,e,!1,52,8)};function F(e,t,n,r,i,a){if(!s.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;F(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;F(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},s.prototype.writeUint8=s.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,1,255,0),this[t]=e&255,t+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function I(e,t,n,r,i){W(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function L(e,t,n,r,i){W(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}s.prototype.writeBigUInt64LE=$(function(e,t=0){return I(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeBigUInt64BE=$(function(e,t=0){return L(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),s.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);F(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);F(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||F(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},s.prototype.writeBigInt64LE=$(function(e,t=0){return I(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),s.prototype.writeBigInt64BE=$(function(e,t=0){return L(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function R(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function z(e,t,r,i,a){return t=+t,r>>>=0,a||R(e,t,r,4,34028234663852886e22,-34028234663852886e22),n.write(e,t,r,i,23,4),r+4}s.prototype.writeFloatLE=function(e,t,n){return z(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return z(this,e,t,!1,n)};function B(e,t,r,i,a){return t=+t,r>>>=0,a||R(e,t,r,8,17976931348623157e292,-17976931348623157e292),n.write(e,t,r,i,52,8),r+8}s.prototype.writeDoubleLE=function(e,t,n){return B(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return B(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(!s.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof Uint8Array.prototype.copyWithin==`function`?this.copyWithin(t,n,r):Uint8Array.prototype.set.call(e,this.subarray(n,r),t),i},s.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!s.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=s.isBuffer(e)?e:s.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};var V={};function H(e,t,n){V[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}H(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),H(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),H(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=U(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=U(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function U(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function ae(e,t,n){G(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&K(t,e.length-(n+1))}function W(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new V.ERR_OUT_OF_RANGE(`value`,i,e)}ae(r,i,a)}function G(e,t){if(typeof e!=`number`)throw new V.ERR_INVALID_ARG_TYPE(t,`number`,e)}function K(e,t,n){throw Math.floor(e)===e?t<0?new V.ERR_BUFFER_OUT_OF_BOUNDS:new V.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(G(e,n),new V.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}var oe=/[^+/0-9A-Za-z-_]/g;function q(e){if(e=e.split(`=`)[0],e=e.trim().replace(oe,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function J(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function Y(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function se(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function ce(e){return t.toByteArray(q(e))}function X(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Z(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Q(e){return e!==e}var le=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function $(e){return typeof BigInt>`u`?ue:e}function ue(){throw Error(`BigInt not supported`)}})),L=i(((e,t)=>{var n=I(),r=n.Buffer;function i(e,t){for(var n in e)t[n]=e[n]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=a);function a(e,t,n){return r(e,t,n)}a.prototype=Object.create(r.prototype),i(r,a),a.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return r(e,t,n)},a.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var i=r(e);return t===void 0?i.fill(0):typeof n==`string`?i.fill(t,n):i.fill(t),i},a.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r(e)},a.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return n.SlowBuffer(e)}})),R=i((e=>{var t=L().Buffer,n=t.isEncoding||function(e){switch(e=``+e,e&&e.toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:case`raw`:return!0;default:return!1}};function r(e){if(!e)return`utf8`;for(var t;;)switch(e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:if(t)return;e=(``+e).toLowerCase(),t=!0}}function i(e){var i=r(e);if(typeof i!=`string`&&(t.isEncoding===n||!n(e)))throw Error(`Unknown encoding: `+e);return i||e}e.StringDecoder=a;function a(e){this.encoding=i(e);var n;switch(this.encoding){case`utf16le`:this.text=f,this.end=p,n=4;break;case`utf8`:this.fillLast=l,n=4;break;case`base64`:this.text=m,this.end=h,n=3;break;default:this.write=g,this.end=_;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(n)}a.prototype.write=function(e){if(e.length===0)return``;var t,n;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return``;n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||``},a.prototype.end=d,a.prototype.text=u,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e,t,n){var r=t.length-1;if(r<n)return 0;var i=o(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function c(e,t,n){if((t[0]&192)!=128)return e.lastNeed=0,`�`;if(e.lastNeed>1&&t.length>1){if((t[1]&192)!=128)return e.lastNeed=1,`�`;if(e.lastNeed>2&&t.length>2&&(t[2]&192)!=128)return e.lastNeed=2,`�`}}function l(e){var t=this.lastTotal-this.lastNeed,n=c(this,e,t);if(n!==void 0)return n;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function u(e,t){var n=s(this,e,t);if(!this.lastNeed)return e.toString(`utf8`,t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString(`utf8`,t,r)}function d(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+`�`:t}function f(e,t){if((e.length-t)%2==0){var n=e.toString(`utf16le`,t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString(`utf16le`,t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):``;if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString(`utf16le`,0,n)}return t}function m(e,t){var n=(e.length-t)%3;return n===0?e.toString(`base64`,t):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString(`base64`,t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+this.lastChar.toString(`base64`,0,3-this.lastNeed):t}function g(e){return e.toString(this.encoding)}function _(e){return e&&e.length?this.write(e):``}})),z=i(((e,t)=>{var{Transform:n}=a(),{StringDecoder:r}=R(),i=Symbol(`last`),o=Symbol(`decoder`);function s(e,t,n){let r;if(this.overflow){if(r=this[o].write(e).split(this.matcher),r.length===1)return n();r.shift(),this.overflow=!1}else this[i]+=this[o].write(e),r=this[i].split(this.matcher);this[i]=r.pop();for(let e=0;e<r.length;e++)try{l(this,this.mapper(r[e]))}catch(e){return n(e)}if(this.overflow=this[i].length>this.maxLength,this.overflow&&!this.skipOverflow){n(Error(`maximum buffer reached`));return}n()}function c(e){if(this[i]+=this[o].end(),this[i])try{l(this,this.mapper(this[i]))}catch(t){return e(t)}e()}function l(e,t){t!==void 0&&e.push(t)}function u(e){return e}function d(e,t,a){switch(e||=/\r?\n/,t||=u,a||={},arguments.length){case 1:typeof e==`function`?(t=e,e=/\r?\n/):typeof e==`object`&&!(e instanceof RegExp)&&!e[Symbol.split]&&(a=e,e=/\r?\n/);break;case 2:typeof e==`function`?(a=t,t=e,e=/\r?\n/):typeof t==`object`&&(a=t,t=u)}a=Object.assign({},a),a.autoDestroy=!0,a.transform=s,a.flush=c,a.readableObjectMode=!0;let l=new n(a);return l[i]=``,l[o]=new r(`utf8`),l.matcher=e,l.mapper=t,l.maxLength=a.maxLength,l.skipOverflow=a.skipOverflow||!1,l.overflow=!1,l._destroy=function(e,t){this._writableState.errorEmitted=!1,t(e)},l}t.exports=d})),B=i(((e,t)=>{var n=a(),r=a().Stream,i=z(),o=a(),s=5432,c=process.platform===`win32`,l=process.stderr,u=56,d=7,f=61440,p=32768;function m(e){return(e&f)==p}var h=[`host`,`port`,`database`,`user`,`password`],g=h.length,_=h[g-1];function v(){if(l instanceof r&&!0===l.writable){var e=Array.prototype.slice.call(arguments).concat(`
9
- `);l.write(o.format.apply(o,e))}}Object.defineProperty(t.exports,`isWin`,{get:function(){return c},set:function(e){c=e}}),t.exports.warnTo=function(e){var t=l;return l=e,t},t.exports.getFileName=function(e){var t=e||{};return t.PGPASSFILE||(c?n.join(t.APPDATA||`./`,`postgresql`,`pgpass.conf`):n.join(t.HOME||`./`,`.pgpass`))},t.exports.usePgPass=function(e,t){return Object.prototype.hasOwnProperty.call({},`PGPASSWORD`)?!1:c?!0:(t||=`<unkn>`,m(e.mode)?e.mode&(u|d)?(v(`WARNING: password file "%s" has group or world access; permissions should be u=rw (0600) or less`,t),!1):!0:(v(`WARNING: password file "%s" is not a plain file`,t),!1))};var y=t.exports.match=function(e,t){return h.slice(0,-1).reduce(function(n,r,i){return i==1&&Number(e[r]||s)===Number(t[r])?n&&!0:n&&(t[r]===`*`||t[r]===e[r])},!0)};t.exports.getPassword=function(e,t,n){var r,a=t.pipe(i());function o(t){var n=b(t);n&&x(n)&&y(e,n)&&(r=n[_],a.end())}var s=function(){t.destroy(),n(r)},c=function(e){t.destroy(),v(`WARNING: error on reading file: %s`,e),n(void 0)};t.on(`error`,c),a.on(`data`,o).on(`end`,s).on(`error`,c)};var b=t.exports.parseLine=function(e){if(e.length<11||e.match(/^\s+#/))return null;for(var t=``,n=``,r=0,i=0,a={},o=!1,s=function(t,n,r){var i=e.substring(n,r);Object.hasOwnProperty.call({},`PGPASS_NO_DEESCAPE`)||(i=i.replace(/\\([:\\])/g,`$1`)),a[h[t]]=i},c=0;c<e.length-1;c+=1){if(t=e.charAt(c+1),n=e.charAt(c),o=r==g-1,o){s(r,i);break}c>=0&&t==`:`&&n!==`\\`&&(s(r,i,c+1),i=c+2,r+=1)}return a=Object.keys(a).length===g?a:null,a},x=t.exports.isValidEntry=function(e){for(var t={0:function(e){return e.length>0},1:function(e){return e===`*`?!0:(e=Number(e),isFinite(e)&&e>0&&e<9007199254740992&&Math.floor(e)===e)},2:function(e){return e.length>0},3:function(e){return e.length>0},4:function(e){return e.length>0}},n=0;n<h.length;n+=1){var r=t[n];if(!r(e[h[n]]||``))return!1}return!0}})),V=i(((e,t)=>{a();var n=a(),r=B();t.exports=function(e,t){var i=r.getFileName();n.stat(i,function(a,o){if(a||!r.usePgPass(o,i))return t(void 0);var s=n.createReadStream(i);r.getPassword(e,s,t)})},t.exports.warnTo=r.warnTo})),H=i(((e,t)=>{var n=o().EventEmitter,r=y(),i=a(),s=w(),c=T(),l=D(),u=ee(),d=v(),f=F(),p=S(),m=i.deprecate(()=>{},`Client.activeQuery is deprecated and will be removed in a future version.`),h=i.deprecate(()=>{},`Client.queryQueue is deprecated and will be removed in a future version.`),g=i.deprecate(()=>{},`pgpass support is deprecated and will be removed in a future version. You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this funciton you can call the pgpass module in your own code.`),_=i.deprecate(()=>{},`Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in a future version.`),b=class extends n{constructor(e){super(),this.connectionParameters=new l(e),this.user=this.connectionParameters.user,this.database=this.connectionParameters.database,this.port=this.connectionParameters.port,this.host=this.connectionParameters.host,Object.defineProperty(this,`password`,{configurable:!0,enumerable:!1,writable:!0,value:this.connectionParameters.password}),this.replication=this.connectionParameters.replication;let t=e||{};t.Promise&&_(),this._Promise=t.Promise||global.Promise,this._types=new c(t.types),this._ending=!1,this._ended=!1,this._connecting=!1,this._connected=!1,this._connectionError=!1,this._queryable=!0,this._activeQuery=null,this.enableChannelBinding=!!t.enableChannelBinding,this.connection=t.connection||new f({stream:t.stream,ssl:this.connectionParameters.ssl,keepAlive:t.keepAlive||!1,keepAliveInitialDelayMillis:t.keepAliveInitialDelayMillis||0,encoding:this.connectionParameters.client_encoding||`utf8`}),this._queryQueue=[],this.binary=t.binary||d.binary,this.processID=null,this.secretKey=null,this.ssl=this.connectionParameters.ssl||!1,this.ssl&&this.ssl.key&&Object.defineProperty(this.ssl,`key`,{enumerable:!1}),this._connectionTimeoutMillis=t.connectionTimeoutMillis||0}get activeQuery(){return m(),this._activeQuery}set activeQuery(e){m(),this._activeQuery=e}_getActiveQuery(){return this._activeQuery}_errorAllQueries(e){let t=t=>{process.nextTick(()=>{t.handleError(e,this.connection)})},n=this._getActiveQuery();n&&(t(n),this._activeQuery=null),this._queryQueue.forEach(t),this._queryQueue.length=0}_connect(e){let t=this,n=this.connection;if(this._connectionCallback=e,this._connecting||this._connected){let t=Error(`Client has already been connected. You cannot reuse a client.`);process.nextTick(()=>{e(t)});return}this._connecting=!0,this._connectionTimeoutMillis>0&&(this.connectionTimeoutHandle=setTimeout(()=>{n._ending=!0,n.stream.destroy(Error(`timeout expired`))},this._connectionTimeoutMillis),this.connectionTimeoutHandle.unref&&this.connectionTimeoutHandle.unref()),this.host&&this.host.indexOf(`/`)===0?n.connect(this.host+`/.s.PGSQL.`+this.port):n.connect(this.port,this.host),n.on(`connect`,function(){t.ssl?n.requestSsl():n.startup(t.getStartupConf())}),n.on(`sslconnect`,function(){n.startup(t.getStartupConf())}),this._attachListeners(n),n.once(`end`,()=>{let e=this._ending?Error(`Connection terminated`):Error(`Connection terminated unexpectedly`);clearTimeout(this.connectionTimeoutHandle),this._errorAllQueries(e),this._ended=!0,this._ending||(this._connecting&&!this._connectionError?this._connectionCallback?this._connectionCallback(e):this._handleErrorEvent(e):this._connectionError||this._handleErrorEvent(e)),process.nextTick(()=>{this.emit(`end`)})})}connect(e){if(e){this._connect(e);return}return new this._Promise((e,t)=>{this._connect(n=>{n?t(n):e(this)})})}_attachListeners(e){e.on(`authenticationCleartextPassword`,this._handleAuthCleartextPassword.bind(this)),e.on(`authenticationMD5Password`,this._handleAuthMD5Password.bind(this)),e.on(`authenticationSASL`,this._handleAuthSASL.bind(this)),e.on(`authenticationSASLContinue`,this._handleAuthSASLContinue.bind(this)),e.on(`authenticationSASLFinal`,this._handleAuthSASLFinal.bind(this)),e.on(`backendKeyData`,this._handleBackendKeyData.bind(this)),e.on(`error`,this._handleErrorEvent.bind(this)),e.on(`errorMessage`,this._handleErrorMessage.bind(this)),e.on(`readyForQuery`,this._handleReadyForQuery.bind(this)),e.on(`notice`,this._handleNotice.bind(this)),e.on(`rowDescription`,this._handleRowDescription.bind(this)),e.on(`dataRow`,this._handleDataRow.bind(this)),e.on(`portalSuspended`,this._handlePortalSuspended.bind(this)),e.on(`emptyQuery`,this._handleEmptyQuery.bind(this)),e.on(`commandComplete`,this._handleCommandComplete.bind(this)),e.on(`parseComplete`,this._handleParseComplete.bind(this)),e.on(`copyInResponse`,this._handleCopyInResponse.bind(this)),e.on(`copyData`,this._handleCopyData.bind(this)),e.on(`notification`,this._handleNotification.bind(this))}_getPassword(e){let t=this.connection;if(typeof this.password==`function`)this._Promise.resolve().then(()=>this.password()).then(n=>{if(n!==void 0){if(typeof n!=`string`){t.emit(`error`,TypeError(`Password must be a string`));return}this.connectionParameters.password=this.password=n}else this.connectionParameters.password=this.password=null;e()}).catch(e=>{t.emit(`error`,e)});else if(this.password!==null)e();else try{V()(this.connectionParameters,t=>{t!==void 0&&(g(),this.connectionParameters.password=this.password=t),e()})}catch(e){this.emit(`error`,e)}}_handleAuthCleartextPassword(e){this._getPassword(()=>{this.connection.password(this.password)})}_handleAuthMD5Password(e){this._getPassword(async()=>{try{let t=await p.postgresMd5PasswordHash(this.user,this.password,e.salt);this.connection.password(t)}catch(e){this.emit(`error`,e)}})}_handleAuthSASL(e){this._getPassword(()=>{try{this.saslSession=s.startSession(e.mechanisms,this.enableChannelBinding&&this.connection.stream),this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism,this.saslSession.response)}catch(e){this.connection.emit(`error`,e)}})}async _handleAuthSASLContinue(e){try{await s.continueSession(this.saslSession,this.password,e.data,this.enableChannelBinding&&this.connection.stream),this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)}catch(e){this.connection.emit(`error`,e)}}_handleAuthSASLFinal(e){try{s.finalizeSession(this.saslSession,e.data),this.saslSession=null}catch(e){this.connection.emit(`error`,e)}}_handleBackendKeyData(e){this.processID=e.processID,this.secretKey=e.secretKey}_handleReadyForQuery(e){this._connecting&&(this._connecting=!1,this._connected=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback&&=(this._connectionCallback(null,this),null),this.emit(`connect`));let t=this._getActiveQuery();this._activeQuery=null,this.readyForQuery=!0,t&&t.handleReadyForQuery(this.connection),this._pulseQueryQueue()}_handleErrorWhileConnecting(e){if(!this._connectionError){if(this._connectionError=!0,clearTimeout(this.connectionTimeoutHandle),this._connectionCallback)return this._connectionCallback(e);this.emit(`error`,e)}}_handleErrorEvent(e){if(this._connecting)return this._handleErrorWhileConnecting(e);this._queryable=!1,this._errorAllQueries(e),this.emit(`error`,e)}_handleErrorMessage(e){if(this._connecting)return this._handleErrorWhileConnecting(e);let t=this._getActiveQuery();if(!t){this._handleErrorEvent(e);return}this._activeQuery=null,t.handleError(e,this.connection)}_handleRowDescription(e){let t=this._getActiveQuery();if(t==null){let e=Error(`Received unexpected rowDescription message from backend.`);this._handleErrorEvent(e);return}t.handleRowDescription(e)}_handleDataRow(e){let t=this._getActiveQuery();if(t==null){let e=Error(`Received unexpected dataRow message from backend.`);this._handleErrorEvent(e);return}t.handleDataRow(e)}_handlePortalSuspended(e){let t=this._getActiveQuery();if(t==null){let e=Error(`Received unexpected portalSuspended message from backend.`);this._handleErrorEvent(e);return}t.handlePortalSuspended(this.connection)}_handleEmptyQuery(e){let t=this._getActiveQuery();if(t==null){let e=Error(`Received unexpected emptyQuery message from backend.`);this._handleErrorEvent(e);return}t.handleEmptyQuery(this.connection)}_handleCommandComplete(e){let t=this._getActiveQuery();if(t==null){let e=Error(`Received unexpected commandComplete message from backend.`);this._handleErrorEvent(e);return}t.handleCommandComplete(e,this.connection)}_handleParseComplete(){let e=this._getActiveQuery();if(e==null){let e=Error(`Received unexpected parseComplete message from backend.`);this._handleErrorEvent(e);return}e.name&&(this.connection.parsedStatements[e.name]=e.text)}_handleCopyInResponse(e){let t=this._getActiveQuery();if(t==null){let e=Error(`Received unexpected copyInResponse message from backend.`);this._handleErrorEvent(e);return}t.handleCopyInResponse(this.connection)}_handleCopyData(e){let t=this._getActiveQuery();if(t==null){let e=Error(`Received unexpected copyData message from backend.`);this._handleErrorEvent(e);return}t.handleCopyData(e,this.connection)}_handleNotification(e){this.emit(`notification`,e)}_handleNotice(e){this.emit(`notice`,e)}getStartupConf(){let e=this.connectionParameters,t={user:e.user,database:e.database},n=e.application_name||e.fallback_application_name;return n&&(t.application_name=n),e.replication&&(t.replication=``+e.replication),e.statement_timeout&&(t.statement_timeout=String(parseInt(e.statement_timeout,10))),e.lock_timeout&&(t.lock_timeout=String(parseInt(e.lock_timeout,10))),e.idle_in_transaction_session_timeout&&(t.idle_in_transaction_session_timeout=String(parseInt(e.idle_in_transaction_session_timeout,10))),e.options&&(t.options=e.options),t}cancel(e,t){if(e.activeQuery===t){let t=this.connection;this.host&&this.host.indexOf(`/`)===0?t.connect(this.host+`/.s.PGSQL.`+this.port):t.connect(this.port,this.host),t.on(`connect`,function(){t.cancel(e.processID,e.secretKey)})}else e._queryQueue.indexOf(t)!==-1&&e._queryQueue.splice(e._queryQueue.indexOf(t),1)}setTypeParser(e,t,n){return this._types.setTypeParser(e,t,n)}getTypeParser(e,t){return this._types.getTypeParser(e,t)}escapeIdentifier(e){return r.escapeIdentifier(e)}escapeLiteral(e){return r.escapeLiteral(e)}_pulseQueryQueue(){if(this.readyForQuery===!0){this._activeQuery=this._queryQueue.shift();let e=this._getActiveQuery();if(e){this.readyForQuery=!1,this.hasExecuted=!0;let t=e.submit(this.connection);t&&process.nextTick(()=>{e.handleError(t,this.connection),this.readyForQuery=!0,this._pulseQueryQueue()})}else this.hasExecuted&&(this._activeQuery=null,this.emit(`drain`))}}query(e,t,n){let r,i,a,o,s;if(e==null)throw TypeError(`Client was passed a null or undefined query`);return typeof e.submit==`function`?(a=e.query_timeout||this.connectionParameters.query_timeout,i=r=e,typeof t==`function`&&(r.callback=r.callback||t)):(a=e.query_timeout||this.connectionParameters.query_timeout,r=new u(e,t,n),r.callback||(i=new this._Promise((e,t)=>{r.callback=(n,r)=>n?t(n):e(r)}).catch(e=>{throw Error.captureStackTrace(e),e}))),a&&(s=r.callback,o=setTimeout(()=>{let e=Error(`Query read timeout`);process.nextTick(()=>{r.handleError(e,this.connection)}),s(e),r.callback=()=>{};let t=this._queryQueue.indexOf(r);t>-1&&this._queryQueue.splice(t,1),this._pulseQueryQueue()},a),r.callback=(e,t)=>{clearTimeout(o),s(e,t)}),this.binary&&!r.binary&&(r.binary=!0),r._result&&!r._result._types&&(r._result._types=this._types),this._queryable?this._ending?(process.nextTick(()=>{r.handleError(Error(`Client was closed and is not queryable`),this.connection)}),i):(this._queryQueue.push(r),this._pulseQueryQueue(),i):(process.nextTick(()=>{r.handleError(Error(`Client has encountered a connection error and is not queryable`),this.connection)}),i)}ref(){this.connection.ref()}unref(){this.connection.unref()}end(e){if(this._ending=!0,!this.connection._connecting||this._ended)if(e)e();else return this._Promise.resolve();if(this._getActiveQuery()||!this._queryable?this.connection.stream.destroy():this.connection.end(),e)this.connection.once(`end`,e);else return new this._Promise(e=>{this.connection.once(`end`,e)})}get queryQueue(){return h(),this._queryQueue}};b.Query=u,t.exports=b})),U=i(((e,t)=>{var n=o().EventEmitter,r=function(){},i=(e,t)=>{let n=e.findIndex(t);return n===-1?void 0:e.splice(n,1)[0]},a=class{constructor(e,t,n){this.client=e,this.idleListener=t,this.timeoutId=n}},s=class{constructor(e){this.callback=e}};function c(){throw Error(`Release called on client which has already been released to the pool.`)}function l(e,t){if(t)return{callback:t,result:void 0};let n,r;return{callback:function(e,t){e?n(e):r(t)},result:new e(function(e,t){r=e,n=t}).catch(e=>{throw Error.captureStackTrace(e),e})}}function u(e,t){return function n(r){r.client=t,t.removeListener(`error`,n),t.on(`error`,()=>{e.log(`additional client error after disconnection due to error`,r)}),e._remove(t),e.emit(`error`,r,t)}}t.exports=class extends n{constructor(e,t){super(),this.options=Object.assign({},e),e!=null&&`password`in e&&Object.defineProperty(this.options,`password`,{configurable:!0,enumerable:!1,writable:!0,value:e.password}),e!=null&&e.ssl&&e.ssl.key&&Object.defineProperty(this.options.ssl,`key`,{enumerable:!1}),this.options.max=this.options.max||this.options.poolSize||10,this.options.min=this.options.min||0,this.options.maxUses=this.options.maxUses||1/0,this.options.allowExitOnIdle=this.options.allowExitOnIdle||!1,this.options.maxLifetimeSeconds=this.options.maxLifetimeSeconds||0,this.log=this.options.log||function(){},this.Client=this.options.Client||t||J().Client,this.Promise=this.options.Promise||global.Promise,this.options.idleTimeoutMillis===void 0&&(this.options.idleTimeoutMillis=1e4),this._clients=[],this._idle=[],this._expired=new WeakSet,this._pendingQueue=[],this._endCallback=void 0,this.ending=!1,this.ended=!1}_promiseTry(e){let t=this.Promise;return typeof t.try==`function`?t.try(e):new t(t=>t(e()))}_isFull(){return this._clients.length>=this.options.max}_isAboveMin(){return this._clients.length>this.options.min}_pulseQueue(){if(this.log(`pulse queue`),this.ended){this.log(`pulse queue ended`);return}if(this.ending){this.log(`pulse queue on ending`),this._idle.length&&this._idle.slice().map(e=>{this._remove(e.client)}),this._clients.length||(this.ended=!0,this._endCallback());return}if(!this._pendingQueue.length){this.log(`no queued requests`);return}if(!this._idle.length&&this._isFull())return;let e=this._pendingQueue.shift();if(this._idle.length){let t=this._idle.pop();clearTimeout(t.timeoutId);let n=t.client;n.ref&&n.ref();let r=t.idleListener;return this._acquireClient(n,e,r,!1)}if(!this._isFull())return this.newClient(e);throw Error(`unexpected condition`)}_remove(e,t){let n=i(this._idle,t=>t.client===e);n!==void 0&&clearTimeout(n.timeoutId),this._clients=this._clients.filter(t=>t!==e);let r=this;e.end(()=>{r.emit(`remove`,e),typeof t==`function`&&t()})}connect(e){if(this.ending){let t=Error(`Cannot use a pool after calling end on the pool`);return e?e(t):this.Promise.reject(t)}let t=l(this.Promise,e),n=t.result;if(this._isFull()||this._idle.length){if(this._idle.length&&process.nextTick(()=>this._pulseQueue()),!this.options.connectionTimeoutMillis)return this._pendingQueue.push(new s(t.callback)),n;let e=(e,n,r)=>{clearTimeout(a),t.callback(e,n,r)},r=new s(e),a=setTimeout(()=>{i(this._pendingQueue,t=>t.callback===e),r.timedOut=!0,t.callback(Error(`timeout exceeded when trying to connect`))},this.options.connectionTimeoutMillis);return a.unref&&a.unref(),this._pendingQueue.push(r),n}return this.newClient(new s(t.callback)),n}newClient(e){let t=new this.Client(this.options);this._clients.push(t);let n=u(this,t);this.log(`checking client timeout`);let i,a=!1;this.options.connectionTimeoutMillis&&(i=setTimeout(()=>{t.connection?(this.log(`ending client due to timeout`),a=!0,t.connection.stream.destroy()):t.isConnected()||(this.log(`ending client due to timeout`),a=!0,t.end())},this.options.connectionTimeoutMillis)),this.log(`connecting new client`),t.connect(o=>{if(i&&clearTimeout(i),t.on(`error`,n),o)this.log(`client failed to connect`,o),this._clients=this._clients.filter(e=>e!==t),a&&(o=Error(`Connection terminated due to connection timeout`,{cause:o})),this._pulseQueue(),e.timedOut||e.callback(o,void 0,r);else{if(this.log(`new client connected`),this.options.onConnect){this._promiseTry(()=>this.options.onConnect(t)).then(()=>{this._afterConnect(t,e,n)},n=>{this._clients=this._clients.filter(e=>e!==t),t.end(()=>{this._pulseQueue(),e.timedOut||e.callback(n,void 0,r)})});return}return this._afterConnect(t,e,n)}})}_afterConnect(e,t,n){if(this.options.maxLifetimeSeconds!==0){let t=setTimeout(()=>{this.log(`ending client due to expired lifetime`),this._expired.add(e),this._idle.findIndex(t=>t.client===e)!==-1&&this._acquireClient(e,new s((e,t,n)=>n()),n,!1)},this.options.maxLifetimeSeconds*1e3);t.unref(),e.once(`end`,()=>clearTimeout(t))}return this._acquireClient(e,t,n,!0)}_acquireClient(e,t,n,i){i&&this.emit(`connect`,e),this.emit(`acquire`,e),e.release=this._releaseOnce(e,n),e.removeListener(`error`,n),t.timedOut?i&&this.options.verify?this.options.verify(e,e.release):e.release():i&&this.options.verify?this.options.verify(e,n=>{if(n)return e.release(n),t.callback(n,void 0,r);t.callback(void 0,e,e.release)}):t.callback(void 0,e,e.release)}_releaseOnce(e,t){let n=!1;return r=>{n&&c(),n=!0,this._release(e,t,r)}}_release(e,t,n){if(e.on(`error`,t),e._poolUseCount=(e._poolUseCount||0)+1,this.emit(`release`,n,e),n||this.ending||!e._queryable||e._ending||e._poolUseCount>=this.options.maxUses)return e._poolUseCount>=this.options.maxUses&&this.log(`remove expended client`),this._remove(e,this._pulseQueue.bind(this));if(this._expired.has(e))return this.log(`remove expired client`),this._expired.delete(e),this._remove(e,this._pulseQueue.bind(this));let r;this.options.idleTimeoutMillis&&this._isAboveMin()&&(r=setTimeout(()=>{this._isAboveMin()&&(this.log(`remove idle client`),this._remove(e,this._pulseQueue.bind(this)))},this.options.idleTimeoutMillis),this.options.allowExitOnIdle&&r.unref()),this.options.allowExitOnIdle&&e.unref(),this._idle.push(new a(e,t,r)),this._pulseQueue()}query(e,t,n){if(typeof e==`function`){let t=l(this.Promise,e);return setImmediate(function(){return t.callback(Error(`Passing a function as the first parameter to pool.query is not supported`))}),t.result}typeof t==`function`&&(n=t,t=void 0);let r=l(this.Promise,n);return n=r.callback,this.connect((r,i)=>{if(r)return n(r);let a=!1,o=e=>{a||(a=!0,i.release(e),n(e))};i.once(`error`,o),this.log(`dispatching query`);try{i.query(e,t,(e,t)=>{if(this.log(`query dispatched`),i.removeListener(`error`,o),!a)return a=!0,i.release(e),e?n(e):n(void 0,t)})}catch(e){return i.release(e),n(e)}}),r.result}end(e){if(this.log(`ending`),this.ending){let t=Error(`Called end on pool more than once`);return e?e(t):this.Promise.reject(t)}this.ending=!0;let t=l(this.Promise,e);return this._endCallback=t.callback,this._pulseQueue(),t.result}get waitingCount(){return this._pendingQueue.length}get idleCount(){return this._idle.length}get expiredCount(){return this._clients.reduce((e,t)=>e+ +!!this._expired.has(t),0)}get totalCount(){return this._clients.length}}})),ae=r({default:()=>W}),W,G=n((()=>{throw W={},Error(`Could not resolve "pg-native" imported by "pg". Is it installed?`)})),K=i(((e,t)=>{var n=o().EventEmitter,r=a(),i=y(),s=t.exports=function(e,t,r){n.call(this),e=i.normalizeQueryConfig(e,t,r),this.text=e.text,this.values=e.values,this.name=e.name,this.queryMode=e.queryMode,this.callback=e.callback,this.state=`new`,this._arrayMode=e.rowMode===`array`,this._emitRowEvents=!1,this.on(`newListener`,function(e){e===`row`&&(this._emitRowEvents=!0)}.bind(this))};r.inherits(s,n);var c={sqlState:`code`,statementPosition:`position`,messagePrimary:`message`,context:`where`,schemaName:`schema`,tableName:`table`,columnName:`column`,dataTypeName:`dataType`,constraintName:`constraint`,sourceFile:`file`,sourceLine:`line`,sourceFunction:`routine`};s.prototype.handleError=function(e){let t=this.native.pq.resultErrorFields();if(t)for(let n in t){let r=c[n]||n;e[r]=t[n]}this.callback?this.callback(e):this.emit(`error`,e),this.state=`error`},s.prototype.then=function(e,t){return this._getPromise().then(e,t)},s.prototype.catch=function(e){return this._getPromise().catch(e)},s.prototype._getPromise=function(){return this._promise||=new Promise(function(e,t){this._once(`end`,e),this._once(`error`,t)}.bind(this)),this._promise},s.prototype.submit=function(e){this.state=`running`;let t=this;this.native=e.native,e.native.arrayMode=this._arrayMode;let n=function(n,r,i){if(e.native.arrayMode=!1,setImmediate(function(){t.emit(`_done`)}),n)return t.handleError(n);t._emitRowEvents&&(i.length>1?r.forEach((e,n)=>{e.forEach(e=>{t.emit(`row`,e,i[n])})}):r.forEach(function(e){t.emit(`row`,e,i)})),t.state=`end`,t.emit(`end`,i),t.callback&&t.callback(null,i)};if(process.domain&&(n=process.domain.bind(n)),this.name){this.name.length>63&&(console.error(`Warning! Postgres only supports 63 characters for query names.`),console.error(`You supplied %s (%s)`,this.name,this.name.length),console.error(`This can cause conflicts and silent errors executing queries`));let r=(this.values||[]).map(i.prepareValue);if(e.namedQueries[this.name]){if(this.text&&e.namedQueries[this.name]!==this.text){let e=Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`);return n(e)}return e.native.execute(this.name,r,n)}return e.native.prepare(this.name,this.text,r.length,function(i){return i?n(i):(e.namedQueries[t.name]=t.text,t.native.execute(t.name,r,n))})}else if(this.values){if(!Array.isArray(this.values))return n(Error(`Query values must be an array`));let t=this.values.map(i.prepareValue);e.native.query(this.text,t,n)}else this.queryMode===`extended`?e.native.query(this.text,[],n):e.native.query(this.text,n)}})),oe=i(((e,n)=>{var r;try{r=(G(),t(ae))}catch(e){throw e}var i=T(),s=o().EventEmitter,c=a(),l=D(),u=K(),d=n.exports=function(e){s.call(this),e||={},this._Promise=e.Promise||global.Promise,this._types=new i(e.types),this.native=new r({types:this._types}),this._queryQueue=[],this._ending=!1,this._connecting=!1,this._connected=!1,this._queryable=!0;let t=this.connectionParameters=new l(e);e.nativeConnectionString&&(t.nativeConnectionString=e.nativeConnectionString),this.user=t.user,Object.defineProperty(this,`password`,{configurable:!0,enumerable:!1,writable:!0,value:t.password}),this.database=t.database,this.host=t.host,this.port=t.port,this.namedQueries={}};d.Query=u,c.inherits(d,s),d.prototype._errorAllQueries=function(e){let t=t=>{process.nextTick(()=>{t.native=this.native,t.handleError(e)})};this._hasActiveQuery()&&(t(this._activeQuery),this._activeQuery=null),this._queryQueue.forEach(t),this._queryQueue.length=0},d.prototype._connect=function(e){let t=this;if(this._connecting){process.nextTick(()=>e(Error(`Client has already been connected. You cannot reuse a client.`)));return}this._connecting=!0,this.connectionParameters.getLibpqConnectionString(function(n,r){if(t.connectionParameters.nativeConnectionString&&(r=t.connectionParameters.nativeConnectionString),n)return e(n);t.native.connect(r,function(n){if(n)return t.native.end(),e(n);t._connected=!0,t.native.on(`error`,function(e){t._queryable=!1,t._errorAllQueries(e),t.emit(`error`,e)}),t.native.on(`notification`,function(e){t.emit(`notification`,{channel:e.relname,payload:e.extra})}),t.emit(`connect`),t._pulseQueryQueue(!0),e(null,this)})})},d.prototype.connect=function(e){if(e){this._connect(e);return}return new this._Promise((e,t)=>{this._connect(n=>{n?t(n):e(this)})})},d.prototype.query=function(e,t,n){let r,i,a,o,s;if(e==null)throw TypeError(`Client was passed a null or undefined query`);if(typeof e.submit==`function`)a=e.query_timeout||this.connectionParameters.query_timeout,i=r=e,typeof t==`function`&&(e.callback=t);else if(a=e.query_timeout||this.connectionParameters.query_timeout,r=new u(e,t,n),!r.callback){let e,t;i=new this._Promise((n,r)=>{e=n,t=r}).catch(e=>{throw Error.captureStackTrace(e),e}),r.callback=(n,r)=>n?t(n):e(r)}return a&&(s=r.callback,o=setTimeout(()=>{let e=Error(`Query read timeout`);process.nextTick(()=>{r.handleError(e,this.connection)}),s(e),r.callback=()=>{};let t=this._queryQueue.indexOf(r);t>-1&&this._queryQueue.splice(t,1),this._pulseQueryQueue()},a),r.callback=(e,t)=>{clearTimeout(o),s(e,t)}),this._queryable?this._ending?(r.native=this.native,process.nextTick(()=>{r.handleError(Error(`Client was closed and is not queryable`))}),i):(this._queryQueue.push(r),this._pulseQueryQueue(),i):(r.native=this.native,process.nextTick(()=>{r.handleError(Error(`Client has encountered a connection error and is not queryable`))}),i)},d.prototype.end=function(e){let t=this;this._ending=!0,this._connected||this.once(`connect`,this.end.bind(this,e));let n;return e||(n=new this._Promise(function(t,n){e=e=>e?n(e):t()})),this.native.end(function(){t._errorAllQueries(Error(`Connection terminated`)),process.nextTick(()=>{t.emit(`end`),e&&e()})}),n},d.prototype._hasActiveQuery=function(){return this._activeQuery&&this._activeQuery.state!==`error`&&this._activeQuery.state!==`end`},d.prototype._pulseQueryQueue=function(e){if(!this._connected||this._hasActiveQuery())return;let t=this._queryQueue.shift();if(!t){e||this.emit(`drain`);return}this._activeQuery=t,t.submit(this);let n=this;t.once(`_done`,function(){n._pulseQueryQueue()})},d.prototype.cancel=function(e){this._activeQuery===e?this.native.cancel(function(){}):this._queryQueue.indexOf(e)!==-1&&this._queryQueue.splice(this._queryQueue.indexOf(e),1)},d.prototype.ref=function(){},d.prototype.unref=function(){},d.prototype.setTypeParser=function(e,t,n){return this._types.setTypeParser(e,t,n)},d.prototype.getTypeParser=function(e,t){return this._types.getTypeParser(e,t)}})),q=i(((e,t)=>{t.exports=oe()})),J=i(((e,t)=>{var n=H(),r=v(),i=F(),a=O(),o=y(),s=U(),c=T(),{DatabaseError:l}=N(),{escapeIdentifier:u,escapeLiteral:d}=y(),f=e=>class extends s{constructor(t){super(t,e)}},p=function(e){this.defaults=r,this.Client=e,this.Query=this.Client.Query,this.Pool=f(this.Client),this._pools=[],this.Connection=i,this.types=_(),this.DatabaseError=l,this.TypeOverrides=c,this.escapeIdentifier=u,this.escapeLiteral=d,this.Result=a,this.utils=o},m=n,h=!1;try{h=!!{}.NODE_PG_FORCE_NATIVE}catch{}h&&(m=q()),t.exports=new p(m),Object.defineProperty(t.exports,`native`,{configurable:!0,enumerable:!1,get(){let e=null;try{e=new p(q())}catch(e){if(e.code!==`MODULE_NOT_FOUND`)throw e}return Object.defineProperty(t.exports,`native`,{value:e}),e}})})),Y=e(J(),1);Y.default.Client,Y.default.Pool,Y.default.Connection,Y.default.types,Y.default.Query,Y.default.DatabaseError,Y.default.escapeIdentifier,Y.default.escapeLiteral,Y.default.Result,Y.default.TypeOverrides,Y.default.defaults;var se=Y.default;export{se as default};
10
- //# sourceMappingURL=esm-mbrYcWED.js.map