@ermis-network/ermis-chat-sdk 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +330 -0
  2. package/dist/encryption/index.browser.cjs +13045 -0
  3. package/dist/encryption/index.browser.cjs.map +1 -0
  4. package/dist/encryption/index.browser.mjs +12959 -0
  5. package/dist/encryption/index.browser.mjs.map +1 -0
  6. package/dist/encryption/index.cjs +13045 -0
  7. package/dist/encryption/index.cjs.map +1 -0
  8. package/dist/encryption/index.d.mts +3 -0
  9. package/dist/encryption/index.d.ts +3 -0
  10. package/dist/encryption/index.mjs +12959 -0
  11. package/dist/encryption/index.mjs.map +1 -0
  12. package/dist/index-CcvHIY5q.d.mts +4988 -0
  13. package/dist/index-CcvHIY5q.d.ts +4988 -0
  14. package/dist/index.browser.cjs +20192 -5766
  15. package/dist/index.browser.cjs.map +1 -1
  16. package/dist/index.browser.full-bundle.min.js +20 -16
  17. package/dist/index.browser.full-bundle.min.js.map +1 -1
  18. package/dist/index.browser.mjs +20106 -5731
  19. package/dist/index.browser.mjs.map +1 -1
  20. package/dist/index.cjs +20191 -5765
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.mts +15 -1337
  23. package/dist/index.d.ts +15 -1337
  24. package/dist/index.mjs +20106 -5731
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/wasm_worker.worker.mjs +8 -4
  27. package/dist/wasm_worker.worker.mjs.map +1 -1
  28. package/package.json +21 -6
  29. package/public/e2ee-media-stream-worker.js +627 -0
  30. package/public/openmls_wasm_bg.wasm +0 -0
  31. package/src/attachment_utils.ts +0 -148
  32. package/src/auth.ts +0 -352
  33. package/src/channel.ts +0 -1879
  34. package/src/channel_state.ts +0 -612
  35. package/src/client.ts +0 -1759
  36. package/src/client_state.ts +0 -55
  37. package/src/connection.ts +0 -587
  38. package/src/ermis_call_node.ts +0 -1046
  39. package/src/errors.ts +0 -60
  40. package/src/events.ts +0 -46
  41. package/src/hevc_decoder_config.ts +0 -305
  42. package/src/index.ts +0 -17
  43. package/src/media_stream_receiver.ts +0 -593
  44. package/src/media_stream_sender.ts +0 -465
  45. package/src/shims/empty.ts +0 -1
  46. package/src/signal_message.ts +0 -171
  47. package/src/system_message.ts +0 -259
  48. package/src/token_manager.ts +0 -48
  49. package/src/types.ts +0 -594
  50. package/src/utils.ts +0 -553
  51. package/src/wasm/ermis_call_node_wasm.d.ts +0 -156
  52. package/src/wasm/ermis_call_node_wasm.js +0 -1568
  53. package/src/wasm_worker.ts +0 -219
  54. package/src/wasm_worker_proxy.ts +0 -244
@@ -1,23 +1,24 @@
1
- "use strict";var ErmisChatSDK=(()=>{var Ep=Object.create;var js=Object.defineProperty;var Sp=Object.getOwnPropertyDescriptor;var Rp=Object.getOwnPropertyNames;var Tp=Object.getPrototypeOf,kp=Object.prototype.hasOwnProperty;var k=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ap=(s,e)=>()=>(s&&(e=s(s=0)),e);var y=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Pi=(s,e)=>{for(var t in e)js(s,t,{get:e[t],enumerable:!0})},Da=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Rp(e))!kp.call(s,n)&&n!==t&&js(s,n,{get:()=>e[n],enumerable:!(i=Sp(e,n))||i.enumerable});return s};var xe=(s,e,t)=>(t=s!=null?Ep(Tp(s)):{},Da(e||!s||!s.__esModule?js(t,"default",{value:s,enumerable:!0}):t,s)),ts=s=>Da(js({},"__esModule",{value:!0}),s);var za=y((sg,$a)=>{"use strict";var Ba=k("stream").Stream,fu=k("util");$a.exports=Ne;function Ne(){this.source=null,this.dataSize=0,this.maxDataSize=1024*1024,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}fu.inherits(Ne,Ba);Ne.create=function(s,e){var t=new this;e=e||{};for(var i in e)t[i]=e[i];t.source=s;var n=s.emit;return s.emit=function(){return t._handleEmit(arguments),n.apply(s,arguments)},s.on("error",function(){}),t.pauseStream&&s.pause(),t};Object.defineProperty(Ne.prototype,"readable",{configurable:!0,enumerable:!0,get:function(){return this.source.readable}});Ne.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)};Ne.prototype.resume=function(){this._released||this.release(),this.source.resume()};Ne.prototype.pause=function(){this.source.pause()};Ne.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(s){this.emit.apply(this,s)}.bind(this)),this._bufferedEvents=[]};Ne.prototype.pipe=function(){var s=Ba.prototype.pipe.apply(this,arguments);return this.resume(),s};Ne.prototype._handleEmit=function(s){if(this._released){this.emit.apply(this,s);return}s[0]==="data"&&(this.dataSize+=s[1].length,this._checkIfMaxDataSizeExceeded()),this._bufferedEvents.push(s)};Ne.prototype._checkIfMaxDataSizeExceeded=function(){if(!this._maxDataSizeExceeded&&!(this.dataSize<=this.maxDataSize)){this._maxDataSizeExceeded=!0;var s="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this.emit("error",new Error(s))}}});var Ka=y((ig,Ha)=>{"use strict";var gu=k("util"),Va=k("stream").Stream,Wa=za();Ha.exports=ee;function ee(){this.writable=!1,this.readable=!0,this.dataSize=0,this.maxDataSize=2*1024*1024,this.pauseStreams=!0,this._released=!1,this._streams=[],this._currentStream=null,this._insideLoop=!1,this._pendingNext=!1}gu.inherits(ee,Va);ee.create=function(s){var e=new this;s=s||{};for(var t in s)e[t]=s[t];return e};ee.isStreamLike=function(s){return typeof s!="function"&&typeof s!="string"&&typeof s!="boolean"&&typeof s!="number"&&!Buffer.isBuffer(s)};ee.prototype.append=function(s){var e=ee.isStreamLike(s);if(e){if(!(s instanceof Wa)){var t=Wa.create(s,{maxDataSize:1/0,pauseStream:this.pauseStreams});s.on("data",this._checkDataSize.bind(this)),s=t}this._handleErrors(s),this.pauseStreams&&s.pause()}return this._streams.push(s),this};ee.prototype.pipe=function(s,e){return Va.prototype.pipe.call(this,s,e),this.resume(),s};ee.prototype._getNext=function(){if(this._currentStream=null,this._insideLoop){this._pendingNext=!0;return}this._insideLoop=!0;try{do this._pendingNext=!1,this._realGetNext();while(this._pendingNext)}finally{this._insideLoop=!1}};ee.prototype._realGetNext=function(){var s=this._streams.shift();if(typeof s>"u"){this.end();return}if(typeof s!="function"){this._pipeNext(s);return}var e=s;e(function(t){var i=ee.isStreamLike(t);i&&(t.on("data",this._checkDataSize.bind(this)),this._handleErrors(t)),this._pipeNext(t)}.bind(this))};ee.prototype._pipeNext=function(s){this._currentStream=s;var e=ee.isStreamLike(s);if(e){s.on("end",this._getNext.bind(this)),s.pipe(this,{end:!1});return}var t=s;this.write(t),this._getNext()};ee.prototype._handleErrors=function(s){var e=this;s.on("error",function(t){e._emitError(t)})};ee.prototype.write=function(s){this.emit("data",s)};ee.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&typeof this._currentStream.pause=="function"&&this._currentStream.pause(),this.emit("pause"))};ee.prototype.resume=function(){this._released||(this._released=!0,this.writable=!0,this._getNext()),this.pauseStreams&&this._currentStream&&typeof this._currentStream.resume=="function"&&this._currentStream.resume(),this.emit("resume")};ee.prototype.end=function(){this._reset(),this.emit("end")};ee.prototype.destroy=function(){this._reset(),this.emit("close")};ee.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null};ee.prototype._checkDataSize=function(){if(this._updateDataSize(),!(this.dataSize<=this.maxDataSize)){var s="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this._emitError(new Error(s))}};ee.prototype._updateDataSize=function(){this.dataSize=0;var s=this;this._streams.forEach(function(e){e.dataSize&&(s.dataSize+=e.dataSize)}),this._currentStream&&this._currentStream.dataSize&&(this.dataSize+=this._currentStream.dataSize)};ee.prototype._emitError=function(s){this._reset(),this.emit("error",s)}});var as={};Pi(as,{default:()=>ut});var ut,Ze=Ap(()=>{"use strict";ut=null});var Ja=y((ng,xu)=>{xu.exports={"application/1d-interleaved-parityfec":{source:"iana"},"application/3gpdash-qoe-report+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/3gpp-ims+xml":{source:"iana",compressible:!0},"application/3gpphal+json":{source:"iana",compressible:!0},"application/3gpphalforms+json":{source:"iana",compressible:!0},"application/a2l":{source:"iana"},"application/ace+cbor":{source:"iana"},"application/activemessage":{source:"iana"},"application/activity+json":{source:"iana",compressible:!0},"application/alto-costmap+json":{source:"iana",compressible:!0},"application/alto-costmapfilter+json":{source:"iana",compressible:!0},"application/alto-directory+json":{source:"iana",compressible:!0},"application/alto-endpointcost+json":{source:"iana",compressible:!0},"application/alto-endpointcostparams+json":{source:"iana",compressible:!0},"application/alto-endpointprop+json":{source:"iana",compressible:!0},"application/alto-endpointpropparams+json":{source:"iana",compressible:!0},"application/alto-error+json":{source:"iana",compressible:!0},"application/alto-networkmap+json":{source:"iana",compressible:!0},"application/alto-networkmapfilter+json":{source:"iana",compressible:!0},"application/alto-updatestreamcontrol+json":{source:"iana",compressible:!0},"application/alto-updatestreamparams+json":{source:"iana",compressible:!0},"application/aml":{source:"iana"},"application/andrew-inset":{source:"iana",extensions:["ez"]},"application/applefile":{source:"iana"},"application/applixware":{source:"apache",extensions:["aw"]},"application/at+jwt":{source:"iana"},"application/atf":{source:"iana"},"application/atfx":{source:"iana"},"application/atom+xml":{source:"iana",compressible:!0,extensions:["atom"]},"application/atomcat+xml":{source:"iana",compressible:!0,extensions:["atomcat"]},"application/atomdeleted+xml":{source:"iana",compressible:!0,extensions:["atomdeleted"]},"application/atomicmail":{source:"iana"},"application/atomsvc+xml":{source:"iana",compressible:!0,extensions:["atomsvc"]},"application/atsc-dwd+xml":{source:"iana",compressible:!0,extensions:["dwd"]},"application/atsc-dynamic-event-message":{source:"iana"},"application/atsc-held+xml":{source:"iana",compressible:!0,extensions:["held"]},"application/atsc-rdt+json":{source:"iana",compressible:!0},"application/atsc-rsat+xml":{source:"iana",compressible:!0,extensions:["rsat"]},"application/atxml":{source:"iana"},"application/auth-policy+xml":{source:"iana",compressible:!0},"application/bacnet-xdd+zip":{source:"iana",compressible:!1},"application/batch-smtp":{source:"iana"},"application/bdoc":{compressible:!1,extensions:["bdoc"]},"application/beep+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/calendar+json":{source:"iana",compressible:!0},"application/calendar+xml":{source:"iana",compressible:!0,extensions:["xcs"]},"application/call-completion":{source:"iana"},"application/cals-1840":{source:"iana"},"application/captive+json":{source:"iana",compressible:!0},"application/cbor":{source:"iana"},"application/cbor-seq":{source:"iana"},"application/cccex":{source:"iana"},"application/ccmp+xml":{source:"iana",compressible:!0},"application/ccxml+xml":{source:"iana",compressible:!0,extensions:["ccxml"]},"application/cdfx+xml":{source:"iana",compressible:!0,extensions:["cdfx"]},"application/cdmi-capability":{source:"iana",extensions:["cdmia"]},"application/cdmi-container":{source:"iana",extensions:["cdmic"]},"application/cdmi-domain":{source:"iana",extensions:["cdmid"]},"application/cdmi-object":{source:"iana",extensions:["cdmio"]},"application/cdmi-queue":{source:"iana",extensions:["cdmiq"]},"application/cdni":{source:"iana"},"application/cea":{source:"iana"},"application/cea-2018+xml":{source:"iana",compressible:!0},"application/cellml+xml":{source:"iana",compressible:!0},"application/cfw":{source:"iana"},"application/city+json":{source:"iana",compressible:!0},"application/clr":{source:"iana"},"application/clue+xml":{source:"iana",compressible:!0},"application/clue_info+xml":{source:"iana",compressible:!0},"application/cms":{source:"iana"},"application/cnrp+xml":{source:"iana",compressible:!0},"application/coap-group+json":{source:"iana",compressible:!0},"application/coap-payload":{source:"iana"},"application/commonground":{source:"iana"},"application/conference-info+xml":{source:"iana",compressible:!0},"application/cose":{source:"iana"},"application/cose-key":{source:"iana"},"application/cose-key-set":{source:"iana"},"application/cpl+xml":{source:"iana",compressible:!0,extensions:["cpl"]},"application/csrattrs":{source:"iana"},"application/csta+xml":{source:"iana",compressible:!0},"application/cstadata+xml":{source:"iana",compressible:!0},"application/csvm+json":{source:"iana",compressible:!0},"application/cu-seeme":{source:"apache",extensions:["cu"]},"application/cwt":{source:"iana"},"application/cybercash":{source:"iana"},"application/dart":{compressible:!0},"application/dash+xml":{source:"iana",compressible:!0,extensions:["mpd"]},"application/dash-patch+xml":{source:"iana",compressible:!0,extensions:["mpp"]},"application/dashdelta":{source:"iana"},"application/davmount+xml":{source:"iana",compressible:!0,extensions:["davmount"]},"application/dca-rft":{source:"iana"},"application/dcd":{source:"iana"},"application/dec-dx":{source:"iana"},"application/dialog-info+xml":{source:"iana",compressible:!0},"application/dicom":{source:"iana"},"application/dicom+json":{source:"iana",compressible:!0},"application/dicom+xml":{source:"iana",compressible:!0},"application/dii":{source:"iana"},"application/dit":{source:"iana"},"application/dns":{source:"iana"},"application/dns+json":{source:"iana",compressible:!0},"application/dns-message":{source:"iana"},"application/docbook+xml":{source:"apache",compressible:!0,extensions:["dbk"]},"application/dots+cbor":{source:"iana"},"application/dskpp+xml":{source:"iana",compressible:!0},"application/dssc+der":{source:"iana",extensions:["dssc"]},"application/dssc+xml":{source:"iana",compressible:!0,extensions:["xdssc"]},"application/dvcs":{source:"iana"},"application/ecmascript":{source:"iana",compressible:!0,extensions:["es","ecma"]},"application/edi-consent":{source:"iana"},"application/edi-x12":{source:"iana",compressible:!1},"application/edifact":{source:"iana",compressible:!1},"application/efi":{source:"iana"},"application/elm+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/elm+xml":{source:"iana",compressible:!0},"application/emergencycalldata.cap+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/emergencycalldata.comment+xml":{source:"iana",compressible:!0},"application/emergencycalldata.control+xml":{source:"iana",compressible:!0},"application/emergencycalldata.deviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.ecall.msd":{source:"iana"},"application/emergencycalldata.providerinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.serviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.subscriberinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.veds+xml":{source:"iana",compressible:!0},"application/emma+xml":{source:"iana",compressible:!0,extensions:["emma"]},"application/emotionml+xml":{source:"iana",compressible:!0,extensions:["emotionml"]},"application/encaprtp":{source:"iana"},"application/epp+xml":{source:"iana",compressible:!0},"application/epub+zip":{source:"iana",compressible:!1,extensions:["epub"]},"application/eshop":{source:"iana"},"application/exi":{source:"iana",extensions:["exi"]},"application/expect-ct-report+json":{source:"iana",compressible:!0},"application/express":{source:"iana",extensions:["exp"]},"application/fastinfoset":{source:"iana"},"application/fastsoap":{source:"iana"},"application/fdt+xml":{source:"iana",compressible:!0,extensions:["fdt"]},"application/fhir+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/fhir+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/fido.trusted-apps+json":{compressible:!0},"application/fits":{source:"iana"},"application/flexfec":{source:"iana"},"application/font-sfnt":{source:"iana"},"application/font-tdpfr":{source:"iana",extensions:["pfr"]},"application/font-woff":{source:"iana",compressible:!1},"application/framework-attributes+xml":{source:"iana",compressible:!0},"application/geo+json":{source:"iana",compressible:!0,extensions:["geojson"]},"application/geo+json-seq":{source:"iana"},"application/geopackage+sqlite3":{source:"iana"},"application/geoxacml+xml":{source:"iana",compressible:!0},"application/gltf-buffer":{source:"iana"},"application/gml+xml":{source:"iana",compressible:!0,extensions:["gml"]},"application/gpx+xml":{source:"apache",compressible:!0,extensions:["gpx"]},"application/gxf":{source:"apache",extensions:["gxf"]},"application/gzip":{source:"iana",compressible:!1,extensions:["gz"]},"application/h224":{source:"iana"},"application/held+xml":{source:"iana",compressible:!0},"application/hjson":{extensions:["hjson"]},"application/http":{source:"iana"},"application/hyperstudio":{source:"iana",extensions:["stk"]},"application/ibe-key-request+xml":{source:"iana",compressible:!0},"application/ibe-pkg-reply+xml":{source:"iana",compressible:!0},"application/ibe-pp-data":{source:"iana"},"application/iges":{source:"iana"},"application/im-iscomposing+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/index":{source:"iana"},"application/index.cmd":{source:"iana"},"application/index.obj":{source:"iana"},"application/index.response":{source:"iana"},"application/index.vnd":{source:"iana"},"application/inkml+xml":{source:"iana",compressible:!0,extensions:["ink","inkml"]},"application/iotp":{source:"iana"},"application/ipfix":{source:"iana",extensions:["ipfix"]},"application/ipp":{source:"iana"},"application/isup":{source:"iana"},"application/its+xml":{source:"iana",compressible:!0,extensions:["its"]},"application/java-archive":{source:"apache",compressible:!1,extensions:["jar","war","ear"]},"application/java-serialized-object":{source:"apache",compressible:!1,extensions:["ser"]},"application/java-vm":{source:"apache",compressible:!1,extensions:["class"]},"application/javascript":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["js","mjs"]},"application/jf2feed+json":{source:"iana",compressible:!0},"application/jose":{source:"iana"},"application/jose+json":{source:"iana",compressible:!0},"application/jrd+json":{source:"iana",compressible:!0},"application/jscalendar+json":{source:"iana",compressible:!0},"application/json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["json","map"]},"application/json-patch+json":{source:"iana",compressible:!0},"application/json-seq":{source:"iana"},"application/json5":{extensions:["json5"]},"application/jsonml+json":{source:"apache",compressible:!0,extensions:["jsonml"]},"application/jwk+json":{source:"iana",compressible:!0},"application/jwk-set+json":{source:"iana",compressible:!0},"application/jwt":{source:"iana"},"application/kpml-request+xml":{source:"iana",compressible:!0},"application/kpml-response+xml":{source:"iana",compressible:!0},"application/ld+json":{source:"iana",compressible:!0,extensions:["jsonld"]},"application/lgr+xml":{source:"iana",compressible:!0,extensions:["lgr"]},"application/link-format":{source:"iana"},"application/load-control+xml":{source:"iana",compressible:!0},"application/lost+xml":{source:"iana",compressible:!0,extensions:["lostxml"]},"application/lostsync+xml":{source:"iana",compressible:!0},"application/lpf+zip":{source:"iana",compressible:!1},"application/lxf":{source:"iana"},"application/mac-binhex40":{source:"iana",extensions:["hqx"]},"application/mac-compactpro":{source:"apache",extensions:["cpt"]},"application/macwriteii":{source:"iana"},"application/mads+xml":{source:"iana",compressible:!0,extensions:["mads"]},"application/manifest+json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["webmanifest"]},"application/marc":{source:"iana",extensions:["mrc"]},"application/marcxml+xml":{source:"iana",compressible:!0,extensions:["mrcx"]},"application/mathematica":{source:"iana",extensions:["ma","nb","mb"]},"application/mathml+xml":{source:"iana",compressible:!0,extensions:["mathml"]},"application/mathml-content+xml":{source:"iana",compressible:!0},"application/mathml-presentation+xml":{source:"iana",compressible:!0},"application/mbms-associated-procedure-description+xml":{source:"iana",compressible:!0},"application/mbms-deregister+xml":{source:"iana",compressible:!0},"application/mbms-envelope+xml":{source:"iana",compressible:!0},"application/mbms-msk+xml":{source:"iana",compressible:!0},"application/mbms-msk-response+xml":{source:"iana",compressible:!0},"application/mbms-protection-description+xml":{source:"iana",compressible:!0},"application/mbms-reception-report+xml":{source:"iana",compressible:!0},"application/mbms-register+xml":{source:"iana",compressible:!0},"application/mbms-register-response+xml":{source:"iana",compressible:!0},"application/mbms-schedule+xml":{source:"iana",compressible:!0},"application/mbms-user-service-description+xml":{source:"iana",compressible:!0},"application/mbox":{source:"iana",extensions:["mbox"]},"application/media-policy-dataset+xml":{source:"iana",compressible:!0,extensions:["mpf"]},"application/media_control+xml":{source:"iana",compressible:!0},"application/mediaservercontrol+xml":{source:"iana",compressible:!0,extensions:["mscml"]},"application/merge-patch+json":{source:"iana",compressible:!0},"application/metalink+xml":{source:"apache",compressible:!0,extensions:["metalink"]},"application/metalink4+xml":{source:"iana",compressible:!0,extensions:["meta4"]},"application/mets+xml":{source:"iana",compressible:!0,extensions:["mets"]},"application/mf4":{source:"iana"},"application/mikey":{source:"iana"},"application/mipc":{source:"iana"},"application/missing-blocks+cbor-seq":{source:"iana"},"application/mmt-aei+xml":{source:"iana",compressible:!0,extensions:["maei"]},"application/mmt-usd+xml":{source:"iana",compressible:!0,extensions:["musd"]},"application/mods+xml":{source:"iana",compressible:!0,extensions:["mods"]},"application/moss-keys":{source:"iana"},"application/moss-signature":{source:"iana"},"application/mosskey-data":{source:"iana"},"application/mosskey-request":{source:"iana"},"application/mp21":{source:"iana",extensions:["m21","mp21"]},"application/mp4":{source:"iana",extensions:["mp4s","m4p"]},"application/mpeg4-generic":{source:"iana"},"application/mpeg4-iod":{source:"iana"},"application/mpeg4-iod-xmt":{source:"iana"},"application/mrb-consumer+xml":{source:"iana",compressible:!0},"application/mrb-publish+xml":{source:"iana",compressible:!0},"application/msc-ivr+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msc-mixer+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msword":{source:"iana",compressible:!1,extensions:["doc","dot"]},"application/mud+json":{source:"iana",compressible:!0},"application/multipart-core":{source:"iana"},"application/mxf":{source:"iana",extensions:["mxf"]},"application/n-quads":{source:"iana",extensions:["nq"]},"application/n-triples":{source:"iana",extensions:["nt"]},"application/nasdata":{source:"iana"},"application/news-checkgroups":{source:"iana",charset:"US-ASCII"},"application/news-groupinfo":{source:"iana",charset:"US-ASCII"},"application/news-transmission":{source:"iana"},"application/nlsml+xml":{source:"iana",compressible:!0},"application/node":{source:"iana",extensions:["cjs"]},"application/nss":{source:"iana"},"application/oauth-authz-req+jwt":{source:"iana"},"application/oblivious-dns-message":{source:"iana"},"application/ocsp-request":{source:"iana"},"application/ocsp-response":{source:"iana"},"application/octet-stream":{source:"iana",compressible:!1,extensions:["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]},"application/oda":{source:"iana",extensions:["oda"]},"application/odm+xml":{source:"iana",compressible:!0},"application/odx":{source:"iana"},"application/oebps-package+xml":{source:"iana",compressible:!0,extensions:["opf"]},"application/ogg":{source:"iana",compressible:!1,extensions:["ogx"]},"application/omdoc+xml":{source:"apache",compressible:!0,extensions:["omdoc"]},"application/onenote":{source:"apache",extensions:["onetoc","onetoc2","onetmp","onepkg"]},"application/opc-nodeset+xml":{source:"iana",compressible:!0},"application/oscore":{source:"iana"},"application/oxps":{source:"iana",extensions:["oxps"]},"application/p21":{source:"iana"},"application/p21+zip":{source:"iana",compressible:!1},"application/p2p-overlay+xml":{source:"iana",compressible:!0,extensions:["relo"]},"application/parityfec":{source:"iana"},"application/passport":{source:"iana"},"application/patch-ops-error+xml":{source:"iana",compressible:!0,extensions:["xer"]},"application/pdf":{source:"iana",compressible:!1,extensions:["pdf"]},"application/pdx":{source:"iana"},"application/pem-certificate-chain":{source:"iana"},"application/pgp-encrypted":{source:"iana",compressible:!1,extensions:["pgp"]},"application/pgp-keys":{source:"iana",extensions:["asc"]},"application/pgp-signature":{source:"iana",extensions:["asc","sig"]},"application/pics-rules":{source:"apache",extensions:["prf"]},"application/pidf+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pidf-diff+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pkcs10":{source:"iana",extensions:["p10"]},"application/pkcs12":{source:"iana"},"application/pkcs7-mime":{source:"iana",extensions:["p7m","p7c"]},"application/pkcs7-signature":{source:"iana",extensions:["p7s"]},"application/pkcs8":{source:"iana",extensions:["p8"]},"application/pkcs8-encrypted":{source:"iana"},"application/pkix-attr-cert":{source:"iana",extensions:["ac"]},"application/pkix-cert":{source:"iana",extensions:["cer"]},"application/pkix-crl":{source:"iana",extensions:["crl"]},"application/pkix-pkipath":{source:"iana",extensions:["pkipath"]},"application/pkixcmp":{source:"iana",extensions:["pki"]},"application/pls+xml":{source:"iana",compressible:!0,extensions:["pls"]},"application/poc-settings+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/postscript":{source:"iana",compressible:!0,extensions:["ai","eps","ps"]},"application/ppsp-tracker+json":{source:"iana",compressible:!0},"application/problem+json":{source:"iana",compressible:!0},"application/problem+xml":{source:"iana",compressible:!0},"application/provenance+xml":{source:"iana",compressible:!0,extensions:["provx"]},"application/prs.alvestrand.titrax-sheet":{source:"iana"},"application/prs.cww":{source:"iana",extensions:["cww"]},"application/prs.cyn":{source:"iana",charset:"7-BIT"},"application/prs.hpub+zip":{source:"iana",compressible:!1},"application/prs.nprend":{source:"iana"},"application/prs.plucker":{source:"iana"},"application/prs.rdf-xml-crypt":{source:"iana"},"application/prs.xsf+xml":{source:"iana",compressible:!0},"application/pskc+xml":{source:"iana",compressible:!0,extensions:["pskcxml"]},"application/pvd+json":{source:"iana",compressible:!0},"application/qsig":{source:"iana"},"application/raml+yaml":{compressible:!0,extensions:["raml"]},"application/raptorfec":{source:"iana"},"application/rdap+json":{source:"iana",compressible:!0},"application/rdf+xml":{source:"iana",compressible:!0,extensions:["rdf","owl"]},"application/reginfo+xml":{source:"iana",compressible:!0,extensions:["rif"]},"application/relax-ng-compact-syntax":{source:"iana",extensions:["rnc"]},"application/remote-printing":{source:"iana"},"application/reputon+json":{source:"iana",compressible:!0},"application/resource-lists+xml":{source:"iana",compressible:!0,extensions:["rl"]},"application/resource-lists-diff+xml":{source:"iana",compressible:!0,extensions:["rld"]},"application/rfc+xml":{source:"iana",compressible:!0},"application/riscos":{source:"iana"},"application/rlmi+xml":{source:"iana",compressible:!0},"application/rls-services+xml":{source:"iana",compressible:!0,extensions:["rs"]},"application/route-apd+xml":{source:"iana",compressible:!0,extensions:["rapd"]},"application/route-s-tsid+xml":{source:"iana",compressible:!0,extensions:["sls"]},"application/route-usd+xml":{source:"iana",compressible:!0,extensions:["rusd"]},"application/rpki-ghostbusters":{source:"iana",extensions:["gbr"]},"application/rpki-manifest":{source:"iana",extensions:["mft"]},"application/rpki-publication":{source:"iana"},"application/rpki-roa":{source:"iana",extensions:["roa"]},"application/rpki-updown":{source:"iana"},"application/rsd+xml":{source:"apache",compressible:!0,extensions:["rsd"]},"application/rss+xml":{source:"apache",compressible:!0,extensions:["rss"]},"application/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"application/rtploopback":{source:"iana"},"application/rtx":{source:"iana"},"application/samlassertion+xml":{source:"iana",compressible:!0},"application/samlmetadata+xml":{source:"iana",compressible:!0},"application/sarif+json":{source:"iana",compressible:!0},"application/sarif-external-properties+json":{source:"iana",compressible:!0},"application/sbe":{source:"iana"},"application/sbml+xml":{source:"iana",compressible:!0,extensions:["sbml"]},"application/scaip+xml":{source:"iana",compressible:!0},"application/scim+json":{source:"iana",compressible:!0},"application/scvp-cv-request":{source:"iana",extensions:["scq"]},"application/scvp-cv-response":{source:"iana",extensions:["scs"]},"application/scvp-vp-request":{source:"iana",extensions:["spq"]},"application/scvp-vp-response":{source:"iana",extensions:["spp"]},"application/sdp":{source:"iana",extensions:["sdp"]},"application/secevent+jwt":{source:"iana"},"application/senml+cbor":{source:"iana"},"application/senml+json":{source:"iana",compressible:!0},"application/senml+xml":{source:"iana",compressible:!0,extensions:["senmlx"]},"application/senml-etch+cbor":{source:"iana"},"application/senml-etch+json":{source:"iana",compressible:!0},"application/senml-exi":{source:"iana"},"application/sensml+cbor":{source:"iana"},"application/sensml+json":{source:"iana",compressible:!0},"application/sensml+xml":{source:"iana",compressible:!0,extensions:["sensmlx"]},"application/sensml-exi":{source:"iana"},"application/sep+xml":{source:"iana",compressible:!0},"application/sep-exi":{source:"iana"},"application/session-info":{source:"iana"},"application/set-payment":{source:"iana"},"application/set-payment-initiation":{source:"iana",extensions:["setpay"]},"application/set-registration":{source:"iana"},"application/set-registration-initiation":{source:"iana",extensions:["setreg"]},"application/sgml":{source:"iana"},"application/sgml-open-catalog":{source:"iana"},"application/shf+xml":{source:"iana",compressible:!0,extensions:["shf"]},"application/sieve":{source:"iana",extensions:["siv","sieve"]},"application/simple-filter+xml":{source:"iana",compressible:!0},"application/simple-message-summary":{source:"iana"},"application/simplesymbolcontainer":{source:"iana"},"application/sipc":{source:"iana"},"application/slate":{source:"iana"},"application/smil":{source:"iana"},"application/smil+xml":{source:"iana",compressible:!0,extensions:["smi","smil"]},"application/smpte336m":{source:"iana"},"application/soap+fastinfoset":{source:"iana"},"application/soap+xml":{source:"iana",compressible:!0},"application/sparql-query":{source:"iana",extensions:["rq"]},"application/sparql-results+xml":{source:"iana",compressible:!0,extensions:["srx"]},"application/spdx+json":{source:"iana",compressible:!0},"application/spirits-event+xml":{source:"iana",compressible:!0},"application/sql":{source:"iana"},"application/srgs":{source:"iana",extensions:["gram"]},"application/srgs+xml":{source:"iana",compressible:!0,extensions:["grxml"]},"application/sru+xml":{source:"iana",compressible:!0,extensions:["sru"]},"application/ssdl+xml":{source:"apache",compressible:!0,extensions:["ssdl"]},"application/ssml+xml":{source:"iana",compressible:!0,extensions:["ssml"]},"application/stix+json":{source:"iana",compressible:!0},"application/swid+xml":{source:"iana",compressible:!0,extensions:["swidtag"]},"application/tamp-apex-update":{source:"iana"},"application/tamp-apex-update-confirm":{source:"iana"},"application/tamp-community-update":{source:"iana"},"application/tamp-community-update-confirm":{source:"iana"},"application/tamp-error":{source:"iana"},"application/tamp-sequence-adjust":{source:"iana"},"application/tamp-sequence-adjust-confirm":{source:"iana"},"application/tamp-status-query":{source:"iana"},"application/tamp-status-response":{source:"iana"},"application/tamp-update":{source:"iana"},"application/tamp-update-confirm":{source:"iana"},"application/tar":{compressible:!0},"application/taxii+json":{source:"iana",compressible:!0},"application/td+json":{source:"iana",compressible:!0},"application/tei+xml":{source:"iana",compressible:!0,extensions:["tei","teicorpus"]},"application/tetra_isi":{source:"iana"},"application/thraud+xml":{source:"iana",compressible:!0,extensions:["tfi"]},"application/timestamp-query":{source:"iana"},"application/timestamp-reply":{source:"iana"},"application/timestamped-data":{source:"iana",extensions:["tsd"]},"application/tlsrpt+gzip":{source:"iana"},"application/tlsrpt+json":{source:"iana",compressible:!0},"application/tnauthlist":{source:"iana"},"application/token-introspection+jwt":{source:"iana"},"application/toml":{compressible:!0,extensions:["toml"]},"application/trickle-ice-sdpfrag":{source:"iana"},"application/trig":{source:"iana",extensions:["trig"]},"application/ttml+xml":{source:"iana",compressible:!0,extensions:["ttml"]},"application/tve-trigger":{source:"iana"},"application/tzif":{source:"iana"},"application/tzif-leap":{source:"iana"},"application/ubjson":{compressible:!1,extensions:["ubj"]},"application/ulpfec":{source:"iana"},"application/urc-grpsheet+xml":{source:"iana",compressible:!0},"application/urc-ressheet+xml":{source:"iana",compressible:!0,extensions:["rsheet"]},"application/urc-targetdesc+xml":{source:"iana",compressible:!0,extensions:["td"]},"application/urc-uisocketdesc+xml":{source:"iana",compressible:!0},"application/vcard+json":{source:"iana",compressible:!0},"application/vcard+xml":{source:"iana",compressible:!0},"application/vemmi":{source:"iana"},"application/vividence.scriptfile":{source:"apache"},"application/vnd.1000minds.decision-model+xml":{source:"iana",compressible:!0,extensions:["1km"]},"application/vnd.3gpp-prose+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-prose-pc3ch+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-v2x-local-service-information":{source:"iana"},"application/vnd.3gpp.5gnas":{source:"iana"},"application/vnd.3gpp.access-transfer-events+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.bsf+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gmop+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gtpc":{source:"iana"},"application/vnd.3gpp.interworking-data":{source:"iana"},"application/vnd.3gpp.lpp":{source:"iana"},"application/vnd.3gpp.mc-signalling-ear":{source:"iana"},"application/vnd.3gpp.mcdata-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-payload":{source:"iana"},"application/vnd.3gpp.mcdata-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-signalling":{source:"iana"},"application/vnd.3gpp.mcdata-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-floor-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-signed+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-init-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-transmission-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mid-call+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ngap":{source:"iana"},"application/vnd.3gpp.pfcp":{source:"iana"},"application/vnd.3gpp.pic-bw-large":{source:"iana",extensions:["plb"]},"application/vnd.3gpp.pic-bw-small":{source:"iana",extensions:["psb"]},"application/vnd.3gpp.pic-bw-var":{source:"iana",extensions:["pvb"]},"application/vnd.3gpp.s1ap":{source:"iana"},"application/vnd.3gpp.sms":{source:"iana"},"application/vnd.3gpp.sms+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-ext+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.state-and-event-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ussd+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.bcmcsinfo+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.sms":{source:"iana"},"application/vnd.3gpp2.tcap":{source:"iana",extensions:["tcap"]},"application/vnd.3lightssoftware.imagescal":{source:"iana"},"application/vnd.3m.post-it-notes":{source:"iana",extensions:["pwn"]},"application/vnd.accpac.simply.aso":{source:"iana",extensions:["aso"]},"application/vnd.accpac.simply.imp":{source:"iana",extensions:["imp"]},"application/vnd.acucobol":{source:"iana",extensions:["acu"]},"application/vnd.acucorp":{source:"iana",extensions:["atc","acutc"]},"application/vnd.adobe.air-application-installer-package+zip":{source:"apache",compressible:!1,extensions:["air"]},"application/vnd.adobe.flash.movie":{source:"iana"},"application/vnd.adobe.formscentral.fcdt":{source:"iana",extensions:["fcdt"]},"application/vnd.adobe.fxp":{source:"iana",extensions:["fxp","fxpl"]},"application/vnd.adobe.partial-upload":{source:"iana"},"application/vnd.adobe.xdp+xml":{source:"iana",compressible:!0,extensions:["xdp"]},"application/vnd.adobe.xfdf":{source:"iana",extensions:["xfdf"]},"application/vnd.aether.imp":{source:"iana"},"application/vnd.afpc.afplinedata":{source:"iana"},"application/vnd.afpc.afplinedata-pagedef":{source:"iana"},"application/vnd.afpc.cmoca-cmresource":{source:"iana"},"application/vnd.afpc.foca-charset":{source:"iana"},"application/vnd.afpc.foca-codedfont":{source:"iana"},"application/vnd.afpc.foca-codepage":{source:"iana"},"application/vnd.afpc.modca":{source:"iana"},"application/vnd.afpc.modca-cmtable":{source:"iana"},"application/vnd.afpc.modca-formdef":{source:"iana"},"application/vnd.afpc.modca-mediummap":{source:"iana"},"application/vnd.afpc.modca-objectcontainer":{source:"iana"},"application/vnd.afpc.modca-overlay":{source:"iana"},"application/vnd.afpc.modca-pagesegment":{source:"iana"},"application/vnd.age":{source:"iana",extensions:["age"]},"application/vnd.ah-barcode":{source:"iana"},"application/vnd.ahead.space":{source:"iana",extensions:["ahead"]},"application/vnd.airzip.filesecure.azf":{source:"iana",extensions:["azf"]},"application/vnd.airzip.filesecure.azs":{source:"iana",extensions:["azs"]},"application/vnd.amadeus+json":{source:"iana",compressible:!0},"application/vnd.amazon.ebook":{source:"apache",extensions:["azw"]},"application/vnd.amazon.mobi8-ebook":{source:"iana"},"application/vnd.americandynamics.acc":{source:"iana",extensions:["acc"]},"application/vnd.amiga.ami":{source:"iana",extensions:["ami"]},"application/vnd.amundsen.maze+xml":{source:"iana",compressible:!0},"application/vnd.android.ota":{source:"iana"},"application/vnd.android.package-archive":{source:"apache",compressible:!1,extensions:["apk"]},"application/vnd.anki":{source:"iana"},"application/vnd.anser-web-certificate-issue-initiation":{source:"iana",extensions:["cii"]},"application/vnd.anser-web-funds-transfer-initiation":{source:"apache",extensions:["fti"]},"application/vnd.antix.game-component":{source:"iana",extensions:["atx"]},"application/vnd.apache.arrow.file":{source:"iana"},"application/vnd.apache.arrow.stream":{source:"iana"},"application/vnd.apache.thrift.binary":{source:"iana"},"application/vnd.apache.thrift.compact":{source:"iana"},"application/vnd.apache.thrift.json":{source:"iana"},"application/vnd.api+json":{source:"iana",compressible:!0},"application/vnd.aplextor.warrp+json":{source:"iana",compressible:!0},"application/vnd.apothekende.reservation+json":{source:"iana",compressible:!0},"application/vnd.apple.installer+xml":{source:"iana",compressible:!0,extensions:["mpkg"]},"application/vnd.apple.keynote":{source:"iana",extensions:["key"]},"application/vnd.apple.mpegurl":{source:"iana",extensions:["m3u8"]},"application/vnd.apple.numbers":{source:"iana",extensions:["numbers"]},"application/vnd.apple.pages":{source:"iana",extensions:["pages"]},"application/vnd.apple.pkpass":{compressible:!1,extensions:["pkpass"]},"application/vnd.arastra.swi":{source:"iana"},"application/vnd.aristanetworks.swi":{source:"iana",extensions:["swi"]},"application/vnd.artisan+json":{source:"iana",compressible:!0},"application/vnd.artsquare":{source:"iana"},"application/vnd.astraea-software.iota":{source:"iana",extensions:["iota"]},"application/vnd.audiograph":{source:"iana",extensions:["aep"]},"application/vnd.autopackage":{source:"iana"},"application/vnd.avalon+json":{source:"iana",compressible:!0},"application/vnd.avistar+xml":{source:"iana",compressible:!0},"application/vnd.balsamiq.bmml+xml":{source:"iana",compressible:!0,extensions:["bmml"]},"application/vnd.balsamiq.bmpr":{source:"iana"},"application/vnd.banana-accounting":{source:"iana"},"application/vnd.bbf.usp.error":{source:"iana"},"application/vnd.bbf.usp.msg":{source:"iana"},"application/vnd.bbf.usp.msg+json":{source:"iana",compressible:!0},"application/vnd.bekitzur-stech+json":{source:"iana",compressible:!0},"application/vnd.bint.med-content":{source:"iana"},"application/vnd.biopax.rdf+xml":{source:"iana",compressible:!0},"application/vnd.blink-idb-value-wrapper":{source:"iana"},"application/vnd.blueice.multipass":{source:"iana",extensions:["mpm"]},"application/vnd.bluetooth.ep.oob":{source:"iana"},"application/vnd.bluetooth.le.oob":{source:"iana"},"application/vnd.bmi":{source:"iana",extensions:["bmi"]},"application/vnd.bpf":{source:"iana"},"application/vnd.bpf3":{source:"iana"},"application/vnd.businessobjects":{source:"iana",extensions:["rep"]},"application/vnd.byu.uapi+json":{source:"iana",compressible:!0},"application/vnd.cab-jscript":{source:"iana"},"application/vnd.canon-cpdl":{source:"iana"},"application/vnd.canon-lips":{source:"iana"},"application/vnd.capasystems-pg+json":{source:"iana",compressible:!0},"application/vnd.cendio.thinlinc.clientconf":{source:"iana"},"application/vnd.century-systems.tcp_stream":{source:"iana"},"application/vnd.chemdraw+xml":{source:"iana",compressible:!0,extensions:["cdxml"]},"application/vnd.chess-pgn":{source:"iana"},"application/vnd.chipnuts.karaoke-mmd":{source:"iana",extensions:["mmd"]},"application/vnd.ciedi":{source:"iana"},"application/vnd.cinderella":{source:"iana",extensions:["cdy"]},"application/vnd.cirpack.isdn-ext":{source:"iana"},"application/vnd.citationstyles.style+xml":{source:"iana",compressible:!0,extensions:["csl"]},"application/vnd.claymore":{source:"iana",extensions:["cla"]},"application/vnd.cloanto.rp9":{source:"iana",extensions:["rp9"]},"application/vnd.clonk.c4group":{source:"iana",extensions:["c4g","c4d","c4f","c4p","c4u"]},"application/vnd.cluetrust.cartomobile-config":{source:"iana",extensions:["c11amc"]},"application/vnd.cluetrust.cartomobile-config-pkg":{source:"iana",extensions:["c11amz"]},"application/vnd.coffeescript":{source:"iana"},"application/vnd.collabio.xodocuments.document":{source:"iana"},"application/vnd.collabio.xodocuments.document-template":{source:"iana"},"application/vnd.collabio.xodocuments.presentation":{source:"iana"},"application/vnd.collabio.xodocuments.presentation-template":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet-template":{source:"iana"},"application/vnd.collection+json":{source:"iana",compressible:!0},"application/vnd.collection.doc+json":{source:"iana",compressible:!0},"application/vnd.collection.next+json":{source:"iana",compressible:!0},"application/vnd.comicbook+zip":{source:"iana",compressible:!1},"application/vnd.comicbook-rar":{source:"iana"},"application/vnd.commerce-battelle":{source:"iana"},"application/vnd.commonspace":{source:"iana",extensions:["csp"]},"application/vnd.contact.cmsg":{source:"iana",extensions:["cdbcmsg"]},"application/vnd.coreos.ignition+json":{source:"iana",compressible:!0},"application/vnd.cosmocaller":{source:"iana",extensions:["cmc"]},"application/vnd.crick.clicker":{source:"iana",extensions:["clkx"]},"application/vnd.crick.clicker.keyboard":{source:"iana",extensions:["clkk"]},"application/vnd.crick.clicker.palette":{source:"iana",extensions:["clkp"]},"application/vnd.crick.clicker.template":{source:"iana",extensions:["clkt"]},"application/vnd.crick.clicker.wordbank":{source:"iana",extensions:["clkw"]},"application/vnd.criticaltools.wbs+xml":{source:"iana",compressible:!0,extensions:["wbs"]},"application/vnd.cryptii.pipe+json":{source:"iana",compressible:!0},"application/vnd.crypto-shade-file":{source:"iana"},"application/vnd.cryptomator.encrypted":{source:"iana"},"application/vnd.cryptomator.vault":{source:"iana"},"application/vnd.ctc-posml":{source:"iana",extensions:["pml"]},"application/vnd.ctct.ws+xml":{source:"iana",compressible:!0},"application/vnd.cups-pdf":{source:"iana"},"application/vnd.cups-postscript":{source:"iana"},"application/vnd.cups-ppd":{source:"iana",extensions:["ppd"]},"application/vnd.cups-raster":{source:"iana"},"application/vnd.cups-raw":{source:"iana"},"application/vnd.curl":{source:"iana"},"application/vnd.curl.car":{source:"apache",extensions:["car"]},"application/vnd.curl.pcurl":{source:"apache",extensions:["pcurl"]},"application/vnd.cyan.dean.root+xml":{source:"iana",compressible:!0},"application/vnd.cybank":{source:"iana"},"application/vnd.cyclonedx+json":{source:"iana",compressible:!0},"application/vnd.cyclonedx+xml":{source:"iana",compressible:!0},"application/vnd.d2l.coursepackage1p0+zip":{source:"iana",compressible:!1},"application/vnd.d3m-dataset":{source:"iana"},"application/vnd.d3m-problem":{source:"iana"},"application/vnd.dart":{source:"iana",compressible:!0,extensions:["dart"]},"application/vnd.data-vision.rdz":{source:"iana",extensions:["rdz"]},"application/vnd.datapackage+json":{source:"iana",compressible:!0},"application/vnd.dataresource+json":{source:"iana",compressible:!0},"application/vnd.dbf":{source:"iana",extensions:["dbf"]},"application/vnd.debian.binary-package":{source:"iana"},"application/vnd.dece.data":{source:"iana",extensions:["uvf","uvvf","uvd","uvvd"]},"application/vnd.dece.ttml+xml":{source:"iana",compressible:!0,extensions:["uvt","uvvt"]},"application/vnd.dece.unspecified":{source:"iana",extensions:["uvx","uvvx"]},"application/vnd.dece.zip":{source:"iana",extensions:["uvz","uvvz"]},"application/vnd.denovo.fcselayout-link":{source:"iana",extensions:["fe_launch"]},"application/vnd.desmume.movie":{source:"iana"},"application/vnd.dir-bi.plate-dl-nosuffix":{source:"iana"},"application/vnd.dm.delegation+xml":{source:"iana",compressible:!0},"application/vnd.dna":{source:"iana",extensions:["dna"]},"application/vnd.document+json":{source:"iana",compressible:!0},"application/vnd.dolby.mlp":{source:"apache",extensions:["mlp"]},"application/vnd.dolby.mobile.1":{source:"iana"},"application/vnd.dolby.mobile.2":{source:"iana"},"application/vnd.doremir.scorecloud-binary-document":{source:"iana"},"application/vnd.dpgraph":{source:"iana",extensions:["dpg"]},"application/vnd.dreamfactory":{source:"iana",extensions:["dfac"]},"application/vnd.drive+json":{source:"iana",compressible:!0},"application/vnd.ds-keypoint":{source:"apache",extensions:["kpxx"]},"application/vnd.dtg.local":{source:"iana"},"application/vnd.dtg.local.flash":{source:"iana"},"application/vnd.dtg.local.html":{source:"iana"},"application/vnd.dvb.ait":{source:"iana",extensions:["ait"]},"application/vnd.dvb.dvbisl+xml":{source:"iana",compressible:!0},"application/vnd.dvb.dvbj":{source:"iana"},"application/vnd.dvb.esgcontainer":{source:"iana"},"application/vnd.dvb.ipdcdftnotifaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess2":{source:"iana"},"application/vnd.dvb.ipdcesgpdd":{source:"iana"},"application/vnd.dvb.ipdcroaming":{source:"iana"},"application/vnd.dvb.iptv.alfec-base":{source:"iana"},"application/vnd.dvb.iptv.alfec-enhancement":{source:"iana"},"application/vnd.dvb.notif-aggregate-root+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-container+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-generic+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-msglist+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-request+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-response+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-init+xml":{source:"iana",compressible:!0},"application/vnd.dvb.pfr":{source:"iana"},"application/vnd.dvb.service":{source:"iana",extensions:["svc"]},"application/vnd.dxr":{source:"iana"},"application/vnd.dynageo":{source:"iana",extensions:["geo"]},"application/vnd.dzr":{source:"iana"},"application/vnd.easykaraoke.cdgdownload":{source:"iana"},"application/vnd.ecdis-update":{source:"iana"},"application/vnd.ecip.rlp":{source:"iana"},"application/vnd.eclipse.ditto+json":{source:"iana",compressible:!0},"application/vnd.ecowin.chart":{source:"iana",extensions:["mag"]},"application/vnd.ecowin.filerequest":{source:"iana"},"application/vnd.ecowin.fileupdate":{source:"iana"},"application/vnd.ecowin.series":{source:"iana"},"application/vnd.ecowin.seriesrequest":{source:"iana"},"application/vnd.ecowin.seriesupdate":{source:"iana"},"application/vnd.efi.img":{source:"iana"},"application/vnd.efi.iso":{source:"iana"},"application/vnd.emclient.accessrequest+xml":{source:"iana",compressible:!0},"application/vnd.enliven":{source:"iana",extensions:["nml"]},"application/vnd.enphase.envoy":{source:"iana"},"application/vnd.eprints.data+xml":{source:"iana",compressible:!0},"application/vnd.epson.esf":{source:"iana",extensions:["esf"]},"application/vnd.epson.msf":{source:"iana",extensions:["msf"]},"application/vnd.epson.quickanime":{source:"iana",extensions:["qam"]},"application/vnd.epson.salt":{source:"iana",extensions:["slt"]},"application/vnd.epson.ssf":{source:"iana",extensions:["ssf"]},"application/vnd.ericsson.quickcall":{source:"iana"},"application/vnd.espass-espass+zip":{source:"iana",compressible:!1},"application/vnd.eszigno3+xml":{source:"iana",compressible:!0,extensions:["es3","et3"]},"application/vnd.etsi.aoc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.asic-e+zip":{source:"iana",compressible:!1},"application/vnd.etsi.asic-s+zip":{source:"iana",compressible:!1},"application/vnd.etsi.cug+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvcommand+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-bc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-cod+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-npvr+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvservice+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsync+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvueprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mcid+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mheg5":{source:"iana"},"application/vnd.etsi.overload-control-policy-dataset+xml":{source:"iana",compressible:!0},"application/vnd.etsi.pstn+xml":{source:"iana",compressible:!0},"application/vnd.etsi.sci+xml":{source:"iana",compressible:!0},"application/vnd.etsi.simservs+xml":{source:"iana",compressible:!0},"application/vnd.etsi.timestamp-token":{source:"iana"},"application/vnd.etsi.tsl+xml":{source:"iana",compressible:!0},"application/vnd.etsi.tsl.der":{source:"iana"},"application/vnd.eu.kasparian.car+json":{source:"iana",compressible:!0},"application/vnd.eudora.data":{source:"iana"},"application/vnd.evolv.ecig.profile":{source:"iana"},"application/vnd.evolv.ecig.settings":{source:"iana"},"application/vnd.evolv.ecig.theme":{source:"iana"},"application/vnd.exstream-empower+zip":{source:"iana",compressible:!1},"application/vnd.exstream-package":{source:"iana"},"application/vnd.ezpix-album":{source:"iana",extensions:["ez2"]},"application/vnd.ezpix-package":{source:"iana",extensions:["ez3"]},"application/vnd.f-secure.mobile":{source:"iana"},"application/vnd.familysearch.gedcom+zip":{source:"iana",compressible:!1},"application/vnd.fastcopy-disk-image":{source:"iana"},"application/vnd.fdf":{source:"iana",extensions:["fdf"]},"application/vnd.fdsn.mseed":{source:"iana",extensions:["mseed"]},"application/vnd.fdsn.seed":{source:"iana",extensions:["seed","dataless"]},"application/vnd.ffsns":{source:"iana"},"application/vnd.ficlab.flb+zip":{source:"iana",compressible:!1},"application/vnd.filmit.zfc":{source:"iana"},"application/vnd.fints":{source:"iana"},"application/vnd.firemonkeys.cloudcell":{source:"iana"},"application/vnd.flographit":{source:"iana",extensions:["gph"]},"application/vnd.fluxtime.clip":{source:"iana",extensions:["ftc"]},"application/vnd.font-fontforge-sfd":{source:"iana"},"application/vnd.framemaker":{source:"iana",extensions:["fm","frame","maker","book"]},"application/vnd.frogans.fnc":{source:"iana",extensions:["fnc"]},"application/vnd.frogans.ltf":{source:"iana",extensions:["ltf"]},"application/vnd.fsc.weblaunch":{source:"iana",extensions:["fsc"]},"application/vnd.fujifilm.fb.docuworks":{source:"iana"},"application/vnd.fujifilm.fb.docuworks.binder":{source:"iana"},"application/vnd.fujifilm.fb.docuworks.container":{source:"iana"},"application/vnd.fujifilm.fb.jfi+xml":{source:"iana",compressible:!0},"application/vnd.fujitsu.oasys":{source:"iana",extensions:["oas"]},"application/vnd.fujitsu.oasys2":{source:"iana",extensions:["oa2"]},"application/vnd.fujitsu.oasys3":{source:"iana",extensions:["oa3"]},"application/vnd.fujitsu.oasysgp":{source:"iana",extensions:["fg5"]},"application/vnd.fujitsu.oasysprs":{source:"iana",extensions:["bh2"]},"application/vnd.fujixerox.art-ex":{source:"iana"},"application/vnd.fujixerox.art4":{source:"iana"},"application/vnd.fujixerox.ddd":{source:"iana",extensions:["ddd"]},"application/vnd.fujixerox.docuworks":{source:"iana",extensions:["xdw"]},"application/vnd.fujixerox.docuworks.binder":{source:"iana",extensions:["xbd"]},"application/vnd.fujixerox.docuworks.container":{source:"iana"},"application/vnd.fujixerox.hbpl":{source:"iana"},"application/vnd.fut-misnet":{source:"iana"},"application/vnd.futoin+cbor":{source:"iana"},"application/vnd.futoin+json":{source:"iana",compressible:!0},"application/vnd.fuzzysheet":{source:"iana",extensions:["fzs"]},"application/vnd.genomatix.tuxedo":{source:"iana",extensions:["txd"]},"application/vnd.gentics.grd+json":{source:"iana",compressible:!0},"application/vnd.geo+json":{source:"iana",compressible:!0},"application/vnd.geocube+xml":{source:"iana",compressible:!0},"application/vnd.geogebra.file":{source:"iana",extensions:["ggb"]},"application/vnd.geogebra.slides":{source:"iana"},"application/vnd.geogebra.tool":{source:"iana",extensions:["ggt"]},"application/vnd.geometry-explorer":{source:"iana",extensions:["gex","gre"]},"application/vnd.geonext":{source:"iana",extensions:["gxt"]},"application/vnd.geoplan":{source:"iana",extensions:["g2w"]},"application/vnd.geospace":{source:"iana",extensions:["g3w"]},"application/vnd.gerber":{source:"iana"},"application/vnd.globalplatform.card-content-mgt":{source:"iana"},"application/vnd.globalplatform.card-content-mgt-response":{source:"iana"},"application/vnd.gmx":{source:"iana",extensions:["gmx"]},"application/vnd.google-apps.document":{compressible:!1,extensions:["gdoc"]},"application/vnd.google-apps.presentation":{compressible:!1,extensions:["gslides"]},"application/vnd.google-apps.spreadsheet":{compressible:!1,extensions:["gsheet"]},"application/vnd.google-earth.kml+xml":{source:"iana",compressible:!0,extensions:["kml"]},"application/vnd.google-earth.kmz":{source:"iana",compressible:!1,extensions:["kmz"]},"application/vnd.gov.sk.e-form+xml":{source:"iana",compressible:!0},"application/vnd.gov.sk.e-form+zip":{source:"iana",compressible:!1},"application/vnd.gov.sk.xmldatacontainer+xml":{source:"iana",compressible:!0},"application/vnd.grafeq":{source:"iana",extensions:["gqf","gqs"]},"application/vnd.gridmp":{source:"iana"},"application/vnd.groove-account":{source:"iana",extensions:["gac"]},"application/vnd.groove-help":{source:"iana",extensions:["ghf"]},"application/vnd.groove-identity-message":{source:"iana",extensions:["gim"]},"application/vnd.groove-injector":{source:"iana",extensions:["grv"]},"application/vnd.groove-tool-message":{source:"iana",extensions:["gtm"]},"application/vnd.groove-tool-template":{source:"iana",extensions:["tpl"]},"application/vnd.groove-vcard":{source:"iana",extensions:["vcg"]},"application/vnd.hal+json":{source:"iana",compressible:!0},"application/vnd.hal+xml":{source:"iana",compressible:!0,extensions:["hal"]},"application/vnd.handheld-entertainment+xml":{source:"iana",compressible:!0,extensions:["zmm"]},"application/vnd.hbci":{source:"iana",extensions:["hbci"]},"application/vnd.hc+json":{source:"iana",compressible:!0},"application/vnd.hcl-bireports":{source:"iana"},"application/vnd.hdt":{source:"iana"},"application/vnd.heroku+json":{source:"iana",compressible:!0},"application/vnd.hhe.lesson-player":{source:"iana",extensions:["les"]},"application/vnd.hl7cda+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.hl7v2+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.hp-hpgl":{source:"iana",extensions:["hpgl"]},"application/vnd.hp-hpid":{source:"iana",extensions:["hpid"]},"application/vnd.hp-hps":{source:"iana",extensions:["hps"]},"application/vnd.hp-jlyt":{source:"iana",extensions:["jlt"]},"application/vnd.hp-pcl":{source:"iana",extensions:["pcl"]},"application/vnd.hp-pclxl":{source:"iana",extensions:["pclxl"]},"application/vnd.httphone":{source:"iana"},"application/vnd.hydrostatix.sof-data":{source:"iana",extensions:["sfd-hdstx"]},"application/vnd.hyper+json":{source:"iana",compressible:!0},"application/vnd.hyper-item+json":{source:"iana",compressible:!0},"application/vnd.hyperdrive+json":{source:"iana",compressible:!0},"application/vnd.hzn-3d-crossword":{source:"iana"},"application/vnd.ibm.afplinedata":{source:"iana"},"application/vnd.ibm.electronic-media":{source:"iana"},"application/vnd.ibm.minipay":{source:"iana",extensions:["mpy"]},"application/vnd.ibm.modcap":{source:"iana",extensions:["afp","listafp","list3820"]},"application/vnd.ibm.rights-management":{source:"iana",extensions:["irm"]},"application/vnd.ibm.secure-container":{source:"iana",extensions:["sc"]},"application/vnd.iccprofile":{source:"iana",extensions:["icc","icm"]},"application/vnd.ieee.1905":{source:"iana"},"application/vnd.igloader":{source:"iana",extensions:["igl"]},"application/vnd.imagemeter.folder+zip":{source:"iana",compressible:!1},"application/vnd.imagemeter.image+zip":{source:"iana",compressible:!1},"application/vnd.immervision-ivp":{source:"iana",extensions:["ivp"]},"application/vnd.immervision-ivu":{source:"iana",extensions:["ivu"]},"application/vnd.ims.imsccv1p1":{source:"iana"},"application/vnd.ims.imsccv1p2":{source:"iana"},"application/vnd.ims.imsccv1p3":{source:"iana"},"application/vnd.ims.lis.v2.result+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolconsumerprofile+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy.id+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings.simple+json":{source:"iana",compressible:!0},"application/vnd.informedcontrol.rms+xml":{source:"iana",compressible:!0},"application/vnd.informix-visionary":{source:"iana"},"application/vnd.infotech.project":{source:"iana"},"application/vnd.infotech.project+xml":{source:"iana",compressible:!0},"application/vnd.innopath.wamp.notification":{source:"iana"},"application/vnd.insors.igm":{source:"iana",extensions:["igm"]},"application/vnd.intercon.formnet":{source:"iana",extensions:["xpw","xpx"]},"application/vnd.intergeo":{source:"iana",extensions:["i2g"]},"application/vnd.intertrust.digibox":{source:"iana"},"application/vnd.intertrust.nncp":{source:"iana"},"application/vnd.intu.qbo":{source:"iana",extensions:["qbo"]},"application/vnd.intu.qfx":{source:"iana",extensions:["qfx"]},"application/vnd.iptc.g2.catalogitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.conceptitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.knowledgeitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsmessage+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.packageitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.planningitem+xml":{source:"iana",compressible:!0},"application/vnd.ipunplugged.rcprofile":{source:"iana",extensions:["rcprofile"]},"application/vnd.irepository.package+xml":{source:"iana",compressible:!0,extensions:["irp"]},"application/vnd.is-xpr":{source:"iana",extensions:["xpr"]},"application/vnd.isac.fcs":{source:"iana",extensions:["fcs"]},"application/vnd.iso11783-10+zip":{source:"iana",compressible:!1},"application/vnd.jam":{source:"iana",extensions:["jam"]},"application/vnd.japannet-directory-service":{source:"iana"},"application/vnd.japannet-jpnstore-wakeup":{source:"iana"},"application/vnd.japannet-payment-wakeup":{source:"iana"},"application/vnd.japannet-registration":{source:"iana"},"application/vnd.japannet-registration-wakeup":{source:"iana"},"application/vnd.japannet-setstore-wakeup":{source:"iana"},"application/vnd.japannet-verification":{source:"iana"},"application/vnd.japannet-verification-wakeup":{source:"iana"},"application/vnd.jcp.javame.midlet-rms":{source:"iana",extensions:["rms"]},"application/vnd.jisp":{source:"iana",extensions:["jisp"]},"application/vnd.joost.joda-archive":{source:"iana",extensions:["joda"]},"application/vnd.jsk.isdn-ngn":{source:"iana"},"application/vnd.kahootz":{source:"iana",extensions:["ktz","ktr"]},"application/vnd.kde.karbon":{source:"iana",extensions:["karbon"]},"application/vnd.kde.kchart":{source:"iana",extensions:["chrt"]},"application/vnd.kde.kformula":{source:"iana",extensions:["kfo"]},"application/vnd.kde.kivio":{source:"iana",extensions:["flw"]},"application/vnd.kde.kontour":{source:"iana",extensions:["kon"]},"application/vnd.kde.kpresenter":{source:"iana",extensions:["kpr","kpt"]},"application/vnd.kde.kspread":{source:"iana",extensions:["ksp"]},"application/vnd.kde.kword":{source:"iana",extensions:["kwd","kwt"]},"application/vnd.kenameaapp":{source:"iana",extensions:["htke"]},"application/vnd.kidspiration":{source:"iana",extensions:["kia"]},"application/vnd.kinar":{source:"iana",extensions:["kne","knp"]},"application/vnd.koan":{source:"iana",extensions:["skp","skd","skt","skm"]},"application/vnd.kodak-descriptor":{source:"iana",extensions:["sse"]},"application/vnd.las":{source:"iana"},"application/vnd.las.las+json":{source:"iana",compressible:!0},"application/vnd.las.las+xml":{source:"iana",compressible:!0,extensions:["lasxml"]},"application/vnd.laszip":{source:"iana"},"application/vnd.leap+json":{source:"iana",compressible:!0},"application/vnd.liberty-request+xml":{source:"iana",compressible:!0},"application/vnd.llamagraphics.life-balance.desktop":{source:"iana",extensions:["lbd"]},"application/vnd.llamagraphics.life-balance.exchange+xml":{source:"iana",compressible:!0,extensions:["lbe"]},"application/vnd.logipipe.circuit+zip":{source:"iana",compressible:!1},"application/vnd.loom":{source:"iana"},"application/vnd.lotus-1-2-3":{source:"iana",extensions:["123"]},"application/vnd.lotus-approach":{source:"iana",extensions:["apr"]},"application/vnd.lotus-freelance":{source:"iana",extensions:["pre"]},"application/vnd.lotus-notes":{source:"iana",extensions:["nsf"]},"application/vnd.lotus-organizer":{source:"iana",extensions:["org"]},"application/vnd.lotus-screencam":{source:"iana",extensions:["scm"]},"application/vnd.lotus-wordpro":{source:"iana",extensions:["lwp"]},"application/vnd.macports.portpkg":{source:"iana",extensions:["portpkg"]},"application/vnd.mapbox-vector-tile":{source:"iana",extensions:["mvt"]},"application/vnd.marlin.drm.actiontoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.conftoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.license+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.mdcf":{source:"iana"},"application/vnd.mason+json":{source:"iana",compressible:!0},"application/vnd.maxar.archive.3tz+zip":{source:"iana",compressible:!1},"application/vnd.maxmind.maxmind-db":{source:"iana"},"application/vnd.mcd":{source:"iana",extensions:["mcd"]},"application/vnd.medcalcdata":{source:"iana",extensions:["mc1"]},"application/vnd.mediastation.cdkey":{source:"iana",extensions:["cdkey"]},"application/vnd.meridian-slingshot":{source:"iana"},"application/vnd.mfer":{source:"iana",extensions:["mwf"]},"application/vnd.mfmp":{source:"iana",extensions:["mfm"]},"application/vnd.micro+json":{source:"iana",compressible:!0},"application/vnd.micrografx.flo":{source:"iana",extensions:["flo"]},"application/vnd.micrografx.igx":{source:"iana",extensions:["igx"]},"application/vnd.microsoft.portable-executable":{source:"iana"},"application/vnd.microsoft.windows.thumbnail-cache":{source:"iana"},"application/vnd.miele+json":{source:"iana",compressible:!0},"application/vnd.mif":{source:"iana",extensions:["mif"]},"application/vnd.minisoft-hp3000-save":{source:"iana"},"application/vnd.mitsubishi.misty-guard.trustweb":{source:"iana"},"application/vnd.mobius.daf":{source:"iana",extensions:["daf"]},"application/vnd.mobius.dis":{source:"iana",extensions:["dis"]},"application/vnd.mobius.mbk":{source:"iana",extensions:["mbk"]},"application/vnd.mobius.mqy":{source:"iana",extensions:["mqy"]},"application/vnd.mobius.msl":{source:"iana",extensions:["msl"]},"application/vnd.mobius.plc":{source:"iana",extensions:["plc"]},"application/vnd.mobius.txf":{source:"iana",extensions:["txf"]},"application/vnd.mophun.application":{source:"iana",extensions:["mpn"]},"application/vnd.mophun.certificate":{source:"iana",extensions:["mpc"]},"application/vnd.motorola.flexsuite":{source:"iana"},"application/vnd.motorola.flexsuite.adsi":{source:"iana"},"application/vnd.motorola.flexsuite.fis":{source:"iana"},"application/vnd.motorola.flexsuite.gotap":{source:"iana"},"application/vnd.motorola.flexsuite.kmr":{source:"iana"},"application/vnd.motorola.flexsuite.ttc":{source:"iana"},"application/vnd.motorola.flexsuite.wem":{source:"iana"},"application/vnd.motorola.iprm":{source:"iana"},"application/vnd.mozilla.xul+xml":{source:"iana",compressible:!0,extensions:["xul"]},"application/vnd.ms-3mfdocument":{source:"iana"},"application/vnd.ms-artgalry":{source:"iana",extensions:["cil"]},"application/vnd.ms-asf":{source:"iana"},"application/vnd.ms-cab-compressed":{source:"iana",extensions:["cab"]},"application/vnd.ms-color.iccprofile":{source:"apache"},"application/vnd.ms-excel":{source:"iana",compressible:!1,extensions:["xls","xlm","xla","xlc","xlt","xlw"]},"application/vnd.ms-excel.addin.macroenabled.12":{source:"iana",extensions:["xlam"]},"application/vnd.ms-excel.sheet.binary.macroenabled.12":{source:"iana",extensions:["xlsb"]},"application/vnd.ms-excel.sheet.macroenabled.12":{source:"iana",extensions:["xlsm"]},"application/vnd.ms-excel.template.macroenabled.12":{source:"iana",extensions:["xltm"]},"application/vnd.ms-fontobject":{source:"iana",compressible:!0,extensions:["eot"]},"application/vnd.ms-htmlhelp":{source:"iana",extensions:["chm"]},"application/vnd.ms-ims":{source:"iana",extensions:["ims"]},"application/vnd.ms-lrm":{source:"iana",extensions:["lrm"]},"application/vnd.ms-office.activex+xml":{source:"iana",compressible:!0},"application/vnd.ms-officetheme":{source:"iana",extensions:["thmx"]},"application/vnd.ms-opentype":{source:"apache",compressible:!0},"application/vnd.ms-outlook":{compressible:!1,extensions:["msg"]},"application/vnd.ms-package.obfuscated-opentype":{source:"apache"},"application/vnd.ms-pki.seccat":{source:"apache",extensions:["cat"]},"application/vnd.ms-pki.stl":{source:"apache",extensions:["stl"]},"application/vnd.ms-playready.initiator+xml":{source:"iana",compressible:!0},"application/vnd.ms-powerpoint":{source:"iana",compressible:!1,extensions:["ppt","pps","pot"]},"application/vnd.ms-powerpoint.addin.macroenabled.12":{source:"iana",extensions:["ppam"]},"application/vnd.ms-powerpoint.presentation.macroenabled.12":{source:"iana",extensions:["pptm"]},"application/vnd.ms-powerpoint.slide.macroenabled.12":{source:"iana",extensions:["sldm"]},"application/vnd.ms-powerpoint.slideshow.macroenabled.12":{source:"iana",extensions:["ppsm"]},"application/vnd.ms-powerpoint.template.macroenabled.12":{source:"iana",extensions:["potm"]},"application/vnd.ms-printdevicecapabilities+xml":{source:"iana",compressible:!0},"application/vnd.ms-printing.printticket+xml":{source:"apache",compressible:!0},"application/vnd.ms-printschematicket+xml":{source:"iana",compressible:!0},"application/vnd.ms-project":{source:"iana",extensions:["mpp","mpt"]},"application/vnd.ms-tnef":{source:"iana"},"application/vnd.ms-windows.devicepairing":{source:"iana"},"application/vnd.ms-windows.nwprinting.oob":{source:"iana"},"application/vnd.ms-windows.printerpairing":{source:"iana"},"application/vnd.ms-windows.wsd.oob":{source:"iana"},"application/vnd.ms-wmdrm.lic-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.lic-resp":{source:"iana"},"application/vnd.ms-wmdrm.meter-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.meter-resp":{source:"iana"},"application/vnd.ms-word.document.macroenabled.12":{source:"iana",extensions:["docm"]},"application/vnd.ms-word.template.macroenabled.12":{source:"iana",extensions:["dotm"]},"application/vnd.ms-works":{source:"iana",extensions:["wps","wks","wcm","wdb"]},"application/vnd.ms-wpl":{source:"iana",extensions:["wpl"]},"application/vnd.ms-xpsdocument":{source:"iana",compressible:!1,extensions:["xps"]},"application/vnd.msa-disk-image":{source:"iana"},"application/vnd.mseq":{source:"iana",extensions:["mseq"]},"application/vnd.msign":{source:"iana"},"application/vnd.multiad.creator":{source:"iana"},"application/vnd.multiad.creator.cif":{source:"iana"},"application/vnd.music-niff":{source:"iana"},"application/vnd.musician":{source:"iana",extensions:["mus"]},"application/vnd.muvee.style":{source:"iana",extensions:["msty"]},"application/vnd.mynfc":{source:"iana",extensions:["taglet"]},"application/vnd.nacamar.ybrid+json":{source:"iana",compressible:!0},"application/vnd.ncd.control":{source:"iana"},"application/vnd.ncd.reference":{source:"iana"},"application/vnd.nearst.inv+json":{source:"iana",compressible:!0},"application/vnd.nebumind.line":{source:"iana"},"application/vnd.nervana":{source:"iana"},"application/vnd.netfpx":{source:"iana"},"application/vnd.neurolanguage.nlu":{source:"iana",extensions:["nlu"]},"application/vnd.nimn":{source:"iana"},"application/vnd.nintendo.nitro.rom":{source:"iana"},"application/vnd.nintendo.snes.rom":{source:"iana"},"application/vnd.nitf":{source:"iana",extensions:["ntf","nitf"]},"application/vnd.noblenet-directory":{source:"iana",extensions:["nnd"]},"application/vnd.noblenet-sealer":{source:"iana",extensions:["nns"]},"application/vnd.noblenet-web":{source:"iana",extensions:["nnw"]},"application/vnd.nokia.catalogs":{source:"iana"},"application/vnd.nokia.conml+wbxml":{source:"iana"},"application/vnd.nokia.conml+xml":{source:"iana",compressible:!0},"application/vnd.nokia.iptv.config+xml":{source:"iana",compressible:!0},"application/vnd.nokia.isds-radio-presets":{source:"iana"},"application/vnd.nokia.landmark+wbxml":{source:"iana"},"application/vnd.nokia.landmark+xml":{source:"iana",compressible:!0},"application/vnd.nokia.landmarkcollection+xml":{source:"iana",compressible:!0},"application/vnd.nokia.n-gage.ac+xml":{source:"iana",compressible:!0,extensions:["ac"]},"application/vnd.nokia.n-gage.data":{source:"iana",extensions:["ngdat"]},"application/vnd.nokia.n-gage.symbian.install":{source:"iana",extensions:["n-gage"]},"application/vnd.nokia.ncd":{source:"iana"},"application/vnd.nokia.pcd+wbxml":{source:"iana"},"application/vnd.nokia.pcd+xml":{source:"iana",compressible:!0},"application/vnd.nokia.radio-preset":{source:"iana",extensions:["rpst"]},"application/vnd.nokia.radio-presets":{source:"iana",extensions:["rpss"]},"application/vnd.novadigm.edm":{source:"iana",extensions:["edm"]},"application/vnd.novadigm.edx":{source:"iana",extensions:["edx"]},"application/vnd.novadigm.ext":{source:"iana",extensions:["ext"]},"application/vnd.ntt-local.content-share":{source:"iana"},"application/vnd.ntt-local.file-transfer":{source:"iana"},"application/vnd.ntt-local.ogw_remote-access":{source:"iana"},"application/vnd.ntt-local.sip-ta_remote":{source:"iana"},"application/vnd.ntt-local.sip-ta_tcp_stream":{source:"iana"},"application/vnd.oasis.opendocument.chart":{source:"iana",extensions:["odc"]},"application/vnd.oasis.opendocument.chart-template":{source:"iana",extensions:["otc"]},"application/vnd.oasis.opendocument.database":{source:"iana",extensions:["odb"]},"application/vnd.oasis.opendocument.formula":{source:"iana",extensions:["odf"]},"application/vnd.oasis.opendocument.formula-template":{source:"iana",extensions:["odft"]},"application/vnd.oasis.opendocument.graphics":{source:"iana",compressible:!1,extensions:["odg"]},"application/vnd.oasis.opendocument.graphics-template":{source:"iana",extensions:["otg"]},"application/vnd.oasis.opendocument.image":{source:"iana",extensions:["odi"]},"application/vnd.oasis.opendocument.image-template":{source:"iana",extensions:["oti"]},"application/vnd.oasis.opendocument.presentation":{source:"iana",compressible:!1,extensions:["odp"]},"application/vnd.oasis.opendocument.presentation-template":{source:"iana",extensions:["otp"]},"application/vnd.oasis.opendocument.spreadsheet":{source:"iana",compressible:!1,extensions:["ods"]},"application/vnd.oasis.opendocument.spreadsheet-template":{source:"iana",extensions:["ots"]},"application/vnd.oasis.opendocument.text":{source:"iana",compressible:!1,extensions:["odt"]},"application/vnd.oasis.opendocument.text-master":{source:"iana",extensions:["odm"]},"application/vnd.oasis.opendocument.text-template":{source:"iana",extensions:["ott"]},"application/vnd.oasis.opendocument.text-web":{source:"iana",extensions:["oth"]},"application/vnd.obn":{source:"iana"},"application/vnd.ocf+cbor":{source:"iana"},"application/vnd.oci.image.manifest.v1+json":{source:"iana",compressible:!0},"application/vnd.oftn.l10n+json":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessdownload+xml":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessstreaming+xml":{source:"iana",compressible:!0},"application/vnd.oipf.cspg-hexbinary":{source:"iana"},"application/vnd.oipf.dae.svg+xml":{source:"iana",compressible:!0},"application/vnd.oipf.dae.xhtml+xml":{source:"iana",compressible:!0},"application/vnd.oipf.mippvcontrolmessage+xml":{source:"iana",compressible:!0},"application/vnd.oipf.pae.gem":{source:"iana"},"application/vnd.oipf.spdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.oipf.spdlist+xml":{source:"iana",compressible:!0},"application/vnd.oipf.ueprofile+xml":{source:"iana",compressible:!0},"application/vnd.oipf.userprofile+xml":{source:"iana",compressible:!0},"application/vnd.olpc-sugar":{source:"iana",extensions:["xo"]},"application/vnd.oma-scws-config":{source:"iana"},"application/vnd.oma-scws-http-request":{source:"iana"},"application/vnd.oma-scws-http-response":{source:"iana"},"application/vnd.oma.bcast.associated-procedure-parameter+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.drm-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.imd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.ltkm":{source:"iana"},"application/vnd.oma.bcast.notification+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.provisioningtrigger":{source:"iana"},"application/vnd.oma.bcast.sgboot":{source:"iana"},"application/vnd.oma.bcast.sgdd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sgdu":{source:"iana"},"application/vnd.oma.bcast.simple-symbol-container":{source:"iana"},"application/vnd.oma.bcast.smartcard-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sprov+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.stkm":{source:"iana"},"application/vnd.oma.cab-address-book+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-feature-handler+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-pcc+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-subs-invite+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-user-prefs+xml":{source:"iana",compressible:!0},"application/vnd.oma.dcd":{source:"iana"},"application/vnd.oma.dcdc":{source:"iana"},"application/vnd.oma.dd2+xml":{source:"iana",compressible:!0,extensions:["dd2"]},"application/vnd.oma.drm.risd+xml":{source:"iana",compressible:!0},"application/vnd.oma.group-usage-list+xml":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+cbor":{source:"iana"},"application/vnd.oma.lwm2m+json":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+tlv":{source:"iana"},"application/vnd.oma.pal+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.detailed-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.final-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.groups+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.invocation-descriptor+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.optimized-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.push":{source:"iana"},"application/vnd.oma.scidm.messages+xml":{source:"iana",compressible:!0},"application/vnd.oma.xcap-directory+xml":{source:"iana",compressible:!0},"application/vnd.omads-email+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-file+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-folder+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omaloc-supl-init":{source:"iana"},"application/vnd.onepager":{source:"iana"},"application/vnd.onepagertamp":{source:"iana"},"application/vnd.onepagertamx":{source:"iana"},"application/vnd.onepagertat":{source:"iana"},"application/vnd.onepagertatp":{source:"iana"},"application/vnd.onepagertatx":{source:"iana"},"application/vnd.openblox.game+xml":{source:"iana",compressible:!0,extensions:["obgx"]},"application/vnd.openblox.game-binary":{source:"iana"},"application/vnd.openeye.oeb":{source:"iana"},"application/vnd.openofficeorg.extension":{source:"apache",extensions:["oxt"]},"application/vnd.openstreetmap.data+xml":{source:"iana",compressible:!0,extensions:["osm"]},"application/vnd.opentimestamps.ots":{source:"iana"},"application/vnd.openxmlformats-officedocument.custom-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.customxmlproperties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawing+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.extended-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{source:"iana",compressible:!1,extensions:["pptx"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slide":{source:"iana",extensions:["sldx"]},"application/vnd.openxmlformats-officedocument.presentationml.slide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideshow":{source:"iana",extensions:["ppsx"]},"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tags+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.template":{source:"iana",extensions:["potx"]},"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{source:"iana",compressible:!1,extensions:["xlsx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.template":{source:"iana",extensions:["xltx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.theme+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.themeoverride+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.vmldrawing":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{source:"iana",compressible:!1,extensions:["docx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.template":{source:"iana",extensions:["dotx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.core-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.relationships+xml":{source:"iana",compressible:!0},"application/vnd.oracle.resource+json":{source:"iana",compressible:!0},"application/vnd.orange.indata":{source:"iana"},"application/vnd.osa.netdeploy":{source:"iana"},"application/vnd.osgeo.mapguide.package":{source:"iana",extensions:["mgp"]},"application/vnd.osgi.bundle":{source:"iana"},"application/vnd.osgi.dp":{source:"iana",extensions:["dp"]},"application/vnd.osgi.subsystem":{source:"iana",extensions:["esa"]},"application/vnd.otps.ct-kip+xml":{source:"iana",compressible:!0},"application/vnd.oxli.countgraph":{source:"iana"},"application/vnd.pagerduty+json":{source:"iana",compressible:!0},"application/vnd.palm":{source:"iana",extensions:["pdb","pqa","oprc"]},"application/vnd.panoply":{source:"iana"},"application/vnd.paos.xml":{source:"iana"},"application/vnd.patentdive":{source:"iana"},"application/vnd.patientecommsdoc":{source:"iana"},"application/vnd.pawaafile":{source:"iana",extensions:["paw"]},"application/vnd.pcos":{source:"iana"},"application/vnd.pg.format":{source:"iana",extensions:["str"]},"application/vnd.pg.osasli":{source:"iana",extensions:["ei6"]},"application/vnd.piaccess.application-licence":{source:"iana"},"application/vnd.picsel":{source:"iana",extensions:["efif"]},"application/vnd.pmi.widget":{source:"iana",extensions:["wg"]},"application/vnd.poc.group-advertisement+xml":{source:"iana",compressible:!0},"application/vnd.pocketlearn":{source:"iana",extensions:["plf"]},"application/vnd.powerbuilder6":{source:"iana",extensions:["pbd"]},"application/vnd.powerbuilder6-s":{source:"iana"},"application/vnd.powerbuilder7":{source:"iana"},"application/vnd.powerbuilder7-s":{source:"iana"},"application/vnd.powerbuilder75":{source:"iana"},"application/vnd.powerbuilder75-s":{source:"iana"},"application/vnd.preminet":{source:"iana"},"application/vnd.previewsystems.box":{source:"iana",extensions:["box"]},"application/vnd.proteus.magazine":{source:"iana",extensions:["mgz"]},"application/vnd.psfs":{source:"iana"},"application/vnd.publishare-delta-tree":{source:"iana",extensions:["qps"]},"application/vnd.pvi.ptid1":{source:"iana",extensions:["ptid"]},"application/vnd.pwg-multiplexed":{source:"iana"},"application/vnd.pwg-xhtml-print+xml":{source:"iana",compressible:!0},"application/vnd.qualcomm.brew-app-res":{source:"iana"},"application/vnd.quarantainenet":{source:"iana"},"application/vnd.quark.quarkxpress":{source:"iana",extensions:["qxd","qxt","qwd","qwt","qxl","qxb"]},"application/vnd.quobject-quoxdocument":{source:"iana"},"application/vnd.radisys.moml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conn+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-stream+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-base+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-detect+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-sendrecv+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-group+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-speech+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-transform+xml":{source:"iana",compressible:!0},"application/vnd.rainstor.data":{source:"iana"},"application/vnd.rapid":{source:"iana"},"application/vnd.rar":{source:"iana",extensions:["rar"]},"application/vnd.realvnc.bed":{source:"iana",extensions:["bed"]},"application/vnd.recordare.musicxml":{source:"iana",extensions:["mxl"]},"application/vnd.recordare.musicxml+xml":{source:"iana",compressible:!0,extensions:["musicxml"]},"application/vnd.renlearn.rlprint":{source:"iana"},"application/vnd.resilient.logic":{source:"iana"},"application/vnd.restful+json":{source:"iana",compressible:!0},"application/vnd.rig.cryptonote":{source:"iana",extensions:["cryptonote"]},"application/vnd.rim.cod":{source:"apache",extensions:["cod"]},"application/vnd.rn-realmedia":{source:"apache",extensions:["rm"]},"application/vnd.rn-realmedia-vbr":{source:"apache",extensions:["rmvb"]},"application/vnd.route66.link66+xml":{source:"iana",compressible:!0,extensions:["link66"]},"application/vnd.rs-274x":{source:"iana"},"application/vnd.ruckus.download":{source:"iana"},"application/vnd.s3sms":{source:"iana"},"application/vnd.sailingtracker.track":{source:"iana",extensions:["st"]},"application/vnd.sar":{source:"iana"},"application/vnd.sbm.cid":{source:"iana"},"application/vnd.sbm.mid2":{source:"iana"},"application/vnd.scribus":{source:"iana"},"application/vnd.sealed.3df":{source:"iana"},"application/vnd.sealed.csf":{source:"iana"},"application/vnd.sealed.doc":{source:"iana"},"application/vnd.sealed.eml":{source:"iana"},"application/vnd.sealed.mht":{source:"iana"},"application/vnd.sealed.net":{source:"iana"},"application/vnd.sealed.ppt":{source:"iana"},"application/vnd.sealed.tiff":{source:"iana"},"application/vnd.sealed.xls":{source:"iana"},"application/vnd.sealedmedia.softseal.html":{source:"iana"},"application/vnd.sealedmedia.softseal.pdf":{source:"iana"},"application/vnd.seemail":{source:"iana",extensions:["see"]},"application/vnd.seis+json":{source:"iana",compressible:!0},"application/vnd.sema":{source:"iana",extensions:["sema"]},"application/vnd.semd":{source:"iana",extensions:["semd"]},"application/vnd.semf":{source:"iana",extensions:["semf"]},"application/vnd.shade-save-file":{source:"iana"},"application/vnd.shana.informed.formdata":{source:"iana",extensions:["ifm"]},"application/vnd.shana.informed.formtemplate":{source:"iana",extensions:["itp"]},"application/vnd.shana.informed.interchange":{source:"iana",extensions:["iif"]},"application/vnd.shana.informed.package":{source:"iana",extensions:["ipk"]},"application/vnd.shootproof+json":{source:"iana",compressible:!0},"application/vnd.shopkick+json":{source:"iana",compressible:!0},"application/vnd.shp":{source:"iana"},"application/vnd.shx":{source:"iana"},"application/vnd.sigrok.session":{source:"iana"},"application/vnd.simtech-mindmapper":{source:"iana",extensions:["twd","twds"]},"application/vnd.siren+json":{source:"iana",compressible:!0},"application/vnd.smaf":{source:"iana",extensions:["mmf"]},"application/vnd.smart.notebook":{source:"iana"},"application/vnd.smart.teacher":{source:"iana",extensions:["teacher"]},"application/vnd.snesdev-page-table":{source:"iana"},"application/vnd.software602.filler.form+xml":{source:"iana",compressible:!0,extensions:["fo"]},"application/vnd.software602.filler.form-xml-zip":{source:"iana"},"application/vnd.solent.sdkm+xml":{source:"iana",compressible:!0,extensions:["sdkm","sdkd"]},"application/vnd.spotfire.dxp":{source:"iana",extensions:["dxp"]},"application/vnd.spotfire.sfs":{source:"iana",extensions:["sfs"]},"application/vnd.sqlite3":{source:"iana"},"application/vnd.sss-cod":{source:"iana"},"application/vnd.sss-dtf":{source:"iana"},"application/vnd.sss-ntf":{source:"iana"},"application/vnd.stardivision.calc":{source:"apache",extensions:["sdc"]},"application/vnd.stardivision.draw":{source:"apache",extensions:["sda"]},"application/vnd.stardivision.impress":{source:"apache",extensions:["sdd"]},"application/vnd.stardivision.math":{source:"apache",extensions:["smf"]},"application/vnd.stardivision.writer":{source:"apache",extensions:["sdw","vor"]},"application/vnd.stardivision.writer-global":{source:"apache",extensions:["sgl"]},"application/vnd.stepmania.package":{source:"iana",extensions:["smzip"]},"application/vnd.stepmania.stepchart":{source:"iana",extensions:["sm"]},"application/vnd.street-stream":{source:"iana"},"application/vnd.sun.wadl+xml":{source:"iana",compressible:!0,extensions:["wadl"]},"application/vnd.sun.xml.calc":{source:"apache",extensions:["sxc"]},"application/vnd.sun.xml.calc.template":{source:"apache",extensions:["stc"]},"application/vnd.sun.xml.draw":{source:"apache",extensions:["sxd"]},"application/vnd.sun.xml.draw.template":{source:"apache",extensions:["std"]},"application/vnd.sun.xml.impress":{source:"apache",extensions:["sxi"]},"application/vnd.sun.xml.impress.template":{source:"apache",extensions:["sti"]},"application/vnd.sun.xml.math":{source:"apache",extensions:["sxm"]},"application/vnd.sun.xml.writer":{source:"apache",extensions:["sxw"]},"application/vnd.sun.xml.writer.global":{source:"apache",extensions:["sxg"]},"application/vnd.sun.xml.writer.template":{source:"apache",extensions:["stw"]},"application/vnd.sus-calendar":{source:"iana",extensions:["sus","susp"]},"application/vnd.svd":{source:"iana",extensions:["svd"]},"application/vnd.swiftview-ics":{source:"iana"},"application/vnd.sycle+xml":{source:"iana",compressible:!0},"application/vnd.syft+json":{source:"iana",compressible:!0},"application/vnd.symbian.install":{source:"apache",extensions:["sis","sisx"]},"application/vnd.syncml+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xsm"]},"application/vnd.syncml.dm+wbxml":{source:"iana",charset:"UTF-8",extensions:["bdm"]},"application/vnd.syncml.dm+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xdm"]},"application/vnd.syncml.dm.notification":{source:"iana"},"application/vnd.syncml.dmddf+wbxml":{source:"iana"},"application/vnd.syncml.dmddf+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["ddf"]},"application/vnd.syncml.dmtnds+wbxml":{source:"iana"},"application/vnd.syncml.dmtnds+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.syncml.ds.notification":{source:"iana"},"application/vnd.tableschema+json":{source:"iana",compressible:!0},"application/vnd.tao.intent-module-archive":{source:"iana",extensions:["tao"]},"application/vnd.tcpdump.pcap":{source:"iana",extensions:["pcap","cap","dmp"]},"application/vnd.think-cell.ppttc+json":{source:"iana",compressible:!0},"application/vnd.tmd.mediaflex.api+xml":{source:"iana",compressible:!0},"application/vnd.tml":{source:"iana"},"application/vnd.tmobile-livetv":{source:"iana",extensions:["tmo"]},"application/vnd.tri.onesource":{source:"iana"},"application/vnd.trid.tpt":{source:"iana",extensions:["tpt"]},"application/vnd.triscape.mxs":{source:"iana",extensions:["mxs"]},"application/vnd.trueapp":{source:"iana",extensions:["tra"]},"application/vnd.truedoc":{source:"iana"},"application/vnd.ubisoft.webplayer":{source:"iana"},"application/vnd.ufdl":{source:"iana",extensions:["ufd","ufdl"]},"application/vnd.uiq.theme":{source:"iana",extensions:["utz"]},"application/vnd.umajin":{source:"iana",extensions:["umj"]},"application/vnd.unity":{source:"iana",extensions:["unityweb"]},"application/vnd.uoml+xml":{source:"iana",compressible:!0,extensions:["uoml"]},"application/vnd.uplanet.alert":{source:"iana"},"application/vnd.uplanet.alert-wbxml":{source:"iana"},"application/vnd.uplanet.bearer-choice":{source:"iana"},"application/vnd.uplanet.bearer-choice-wbxml":{source:"iana"},"application/vnd.uplanet.cacheop":{source:"iana"},"application/vnd.uplanet.cacheop-wbxml":{source:"iana"},"application/vnd.uplanet.channel":{source:"iana"},"application/vnd.uplanet.channel-wbxml":{source:"iana"},"application/vnd.uplanet.list":{source:"iana"},"application/vnd.uplanet.list-wbxml":{source:"iana"},"application/vnd.uplanet.listcmd":{source:"iana"},"application/vnd.uplanet.listcmd-wbxml":{source:"iana"},"application/vnd.uplanet.signal":{source:"iana"},"application/vnd.uri-map":{source:"iana"},"application/vnd.valve.source.material":{source:"iana"},"application/vnd.vcx":{source:"iana",extensions:["vcx"]},"application/vnd.vd-study":{source:"iana"},"application/vnd.vectorworks":{source:"iana"},"application/vnd.vel+json":{source:"iana",compressible:!0},"application/vnd.verimatrix.vcas":{source:"iana"},"application/vnd.veritone.aion+json":{source:"iana",compressible:!0},"application/vnd.veryant.thin":{source:"iana"},"application/vnd.ves.encrypted":{source:"iana"},"application/vnd.vidsoft.vidconference":{source:"iana"},"application/vnd.visio":{source:"iana",extensions:["vsd","vst","vss","vsw"]},"application/vnd.visionary":{source:"iana",extensions:["vis"]},"application/vnd.vividence.scriptfile":{source:"iana"},"application/vnd.vsf":{source:"iana",extensions:["vsf"]},"application/vnd.wap.sic":{source:"iana"},"application/vnd.wap.slc":{source:"iana"},"application/vnd.wap.wbxml":{source:"iana",charset:"UTF-8",extensions:["wbxml"]},"application/vnd.wap.wmlc":{source:"iana",extensions:["wmlc"]},"application/vnd.wap.wmlscriptc":{source:"iana",extensions:["wmlsc"]},"application/vnd.webturbo":{source:"iana",extensions:["wtb"]},"application/vnd.wfa.dpp":{source:"iana"},"application/vnd.wfa.p2p":{source:"iana"},"application/vnd.wfa.wsc":{source:"iana"},"application/vnd.windows.devicepairing":{source:"iana"},"application/vnd.wmc":{source:"iana"},"application/vnd.wmf.bootstrap":{source:"iana"},"application/vnd.wolfram.mathematica":{source:"iana"},"application/vnd.wolfram.mathematica.package":{source:"iana"},"application/vnd.wolfram.player":{source:"iana",extensions:["nbp"]},"application/vnd.wordperfect":{source:"iana",extensions:["wpd"]},"application/vnd.wqd":{source:"iana",extensions:["wqd"]},"application/vnd.wrq-hp3000-labelled":{source:"iana"},"application/vnd.wt.stf":{source:"iana",extensions:["stf"]},"application/vnd.wv.csp+wbxml":{source:"iana"},"application/vnd.wv.csp+xml":{source:"iana",compressible:!0},"application/vnd.wv.ssp+xml":{source:"iana",compressible:!0},"application/vnd.xacml+json":{source:"iana",compressible:!0},"application/vnd.xara":{source:"iana",extensions:["xar"]},"application/vnd.xfdl":{source:"iana",extensions:["xfdl"]},"application/vnd.xfdl.webform":{source:"iana"},"application/vnd.xmi+xml":{source:"iana",compressible:!0},"application/vnd.xmpie.cpkg":{source:"iana"},"application/vnd.xmpie.dpkg":{source:"iana"},"application/vnd.xmpie.plan":{source:"iana"},"application/vnd.xmpie.ppkg":{source:"iana"},"application/vnd.xmpie.xlim":{source:"iana"},"application/vnd.yamaha.hv-dic":{source:"iana",extensions:["hvd"]},"application/vnd.yamaha.hv-script":{source:"iana",extensions:["hvs"]},"application/vnd.yamaha.hv-voice":{source:"iana",extensions:["hvp"]},"application/vnd.yamaha.openscoreformat":{source:"iana",extensions:["osf"]},"application/vnd.yamaha.openscoreformat.osfpvg+xml":{source:"iana",compressible:!0,extensions:["osfpvg"]},"application/vnd.yamaha.remote-setup":{source:"iana"},"application/vnd.yamaha.smaf-audio":{source:"iana",extensions:["saf"]},"application/vnd.yamaha.smaf-phrase":{source:"iana",extensions:["spf"]},"application/vnd.yamaha.through-ngn":{source:"iana"},"application/vnd.yamaha.tunnel-udpencap":{source:"iana"},"application/vnd.yaoweme":{source:"iana"},"application/vnd.yellowriver-custom-menu":{source:"iana",extensions:["cmp"]},"application/vnd.youtube.yt":{source:"iana"},"application/vnd.zul":{source:"iana",extensions:["zir","zirz"]},"application/vnd.zzazz.deck+xml":{source:"iana",compressible:!0,extensions:["zaz"]},"application/voicexml+xml":{source:"iana",compressible:!0,extensions:["vxml"]},"application/voucher-cms+json":{source:"iana",compressible:!0},"application/vq-rtcpxr":{source:"iana"},"application/wasm":{source:"iana",compressible:!0,extensions:["wasm"]},"application/watcherinfo+xml":{source:"iana",compressible:!0,extensions:["wif"]},"application/webpush-options+json":{source:"iana",compressible:!0},"application/whoispp-query":{source:"iana"},"application/whoispp-response":{source:"iana"},"application/widget":{source:"iana",extensions:["wgt"]},"application/winhlp":{source:"apache",extensions:["hlp"]},"application/wita":{source:"iana"},"application/wordperfect5.1":{source:"iana"},"application/wsdl+xml":{source:"iana",compressible:!0,extensions:["wsdl"]},"application/wspolicy+xml":{source:"iana",compressible:!0,extensions:["wspolicy"]},"application/x-7z-compressed":{source:"apache",compressible:!1,extensions:["7z"]},"application/x-abiword":{source:"apache",extensions:["abw"]},"application/x-ace-compressed":{source:"apache",extensions:["ace"]},"application/x-amf":{source:"apache"},"application/x-apple-diskimage":{source:"apache",extensions:["dmg"]},"application/x-arj":{compressible:!1,extensions:["arj"]},"application/x-authorware-bin":{source:"apache",extensions:["aab","x32","u32","vox"]},"application/x-authorware-map":{source:"apache",extensions:["aam"]},"application/x-authorware-seg":{source:"apache",extensions:["aas"]},"application/x-bcpio":{source:"apache",extensions:["bcpio"]},"application/x-bdoc":{compressible:!1,extensions:["bdoc"]},"application/x-bittorrent":{source:"apache",extensions:["torrent"]},"application/x-blorb":{source:"apache",extensions:["blb","blorb"]},"application/x-bzip":{source:"apache",compressible:!1,extensions:["bz"]},"application/x-bzip2":{source:"apache",compressible:!1,extensions:["bz2","boz"]},"application/x-cbr":{source:"apache",extensions:["cbr","cba","cbt","cbz","cb7"]},"application/x-cdlink":{source:"apache",extensions:["vcd"]},"application/x-cfs-compressed":{source:"apache",extensions:["cfs"]},"application/x-chat":{source:"apache",extensions:["chat"]},"application/x-chess-pgn":{source:"apache",extensions:["pgn"]},"application/x-chrome-extension":{extensions:["crx"]},"application/x-cocoa":{source:"nginx",extensions:["cco"]},"application/x-compress":{source:"apache"},"application/x-conference":{source:"apache",extensions:["nsc"]},"application/x-cpio":{source:"apache",extensions:["cpio"]},"application/x-csh":{source:"apache",extensions:["csh"]},"application/x-deb":{compressible:!1},"application/x-debian-package":{source:"apache",extensions:["deb","udeb"]},"application/x-dgc-compressed":{source:"apache",extensions:["dgc"]},"application/x-director":{source:"apache",extensions:["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]},"application/x-doom":{source:"apache",extensions:["wad"]},"application/x-dtbncx+xml":{source:"apache",compressible:!0,extensions:["ncx"]},"application/x-dtbook+xml":{source:"apache",compressible:!0,extensions:["dtb"]},"application/x-dtbresource+xml":{source:"apache",compressible:!0,extensions:["res"]},"application/x-dvi":{source:"apache",compressible:!1,extensions:["dvi"]},"application/x-envoy":{source:"apache",extensions:["evy"]},"application/x-eva":{source:"apache",extensions:["eva"]},"application/x-font-bdf":{source:"apache",extensions:["bdf"]},"application/x-font-dos":{source:"apache"},"application/x-font-framemaker":{source:"apache"},"application/x-font-ghostscript":{source:"apache",extensions:["gsf"]},"application/x-font-libgrx":{source:"apache"},"application/x-font-linux-psf":{source:"apache",extensions:["psf"]},"application/x-font-pcf":{source:"apache",extensions:["pcf"]},"application/x-font-snf":{source:"apache",extensions:["snf"]},"application/x-font-speedo":{source:"apache"},"application/x-font-sunos-news":{source:"apache"},"application/x-font-type1":{source:"apache",extensions:["pfa","pfb","pfm","afm"]},"application/x-font-vfont":{source:"apache"},"application/x-freearc":{source:"apache",extensions:["arc"]},"application/x-futuresplash":{source:"apache",extensions:["spl"]},"application/x-gca-compressed":{source:"apache",extensions:["gca"]},"application/x-glulx":{source:"apache",extensions:["ulx"]},"application/x-gnumeric":{source:"apache",extensions:["gnumeric"]},"application/x-gramps-xml":{source:"apache",extensions:["gramps"]},"application/x-gtar":{source:"apache",extensions:["gtar"]},"application/x-gzip":{source:"apache"},"application/x-hdf":{source:"apache",extensions:["hdf"]},"application/x-httpd-php":{compressible:!0,extensions:["php"]},"application/x-install-instructions":{source:"apache",extensions:["install"]},"application/x-iso9660-image":{source:"apache",extensions:["iso"]},"application/x-iwork-keynote-sffkey":{extensions:["key"]},"application/x-iwork-numbers-sffnumbers":{extensions:["numbers"]},"application/x-iwork-pages-sffpages":{extensions:["pages"]},"application/x-java-archive-diff":{source:"nginx",extensions:["jardiff"]},"application/x-java-jnlp-file":{source:"apache",compressible:!1,extensions:["jnlp"]},"application/x-javascript":{compressible:!0},"application/x-keepass2":{extensions:["kdbx"]},"application/x-latex":{source:"apache",compressible:!1,extensions:["latex"]},"application/x-lua-bytecode":{extensions:["luac"]},"application/x-lzh-compressed":{source:"apache",extensions:["lzh","lha"]},"application/x-makeself":{source:"nginx",extensions:["run"]},"application/x-mie":{source:"apache",extensions:["mie"]},"application/x-mobipocket-ebook":{source:"apache",extensions:["prc","mobi"]},"application/x-mpegurl":{compressible:!1},"application/x-ms-application":{source:"apache",extensions:["application"]},"application/x-ms-shortcut":{source:"apache",extensions:["lnk"]},"application/x-ms-wmd":{source:"apache",extensions:["wmd"]},"application/x-ms-wmz":{source:"apache",extensions:["wmz"]},"application/x-ms-xbap":{source:"apache",extensions:["xbap"]},"application/x-msaccess":{source:"apache",extensions:["mdb"]},"application/x-msbinder":{source:"apache",extensions:["obd"]},"application/x-mscardfile":{source:"apache",extensions:["crd"]},"application/x-msclip":{source:"apache",extensions:["clp"]},"application/x-msdos-program":{extensions:["exe"]},"application/x-msdownload":{source:"apache",extensions:["exe","dll","com","bat","msi"]},"application/x-msmediaview":{source:"apache",extensions:["mvb","m13","m14"]},"application/x-msmetafile":{source:"apache",extensions:["wmf","wmz","emf","emz"]},"application/x-msmoney":{source:"apache",extensions:["mny"]},"application/x-mspublisher":{source:"apache",extensions:["pub"]},"application/x-msschedule":{source:"apache",extensions:["scd"]},"application/x-msterminal":{source:"apache",extensions:["trm"]},"application/x-mswrite":{source:"apache",extensions:["wri"]},"application/x-netcdf":{source:"apache",extensions:["nc","cdf"]},"application/x-ns-proxy-autoconfig":{compressible:!0,extensions:["pac"]},"application/x-nzb":{source:"apache",extensions:["nzb"]},"application/x-perl":{source:"nginx",extensions:["pl","pm"]},"application/x-pilot":{source:"nginx",extensions:["prc","pdb"]},"application/x-pkcs12":{source:"apache",compressible:!1,extensions:["p12","pfx"]},"application/x-pkcs7-certificates":{source:"apache",extensions:["p7b","spc"]},"application/x-pkcs7-certreqresp":{source:"apache",extensions:["p7r"]},"application/x-pki-message":{source:"iana"},"application/x-rar-compressed":{source:"apache",compressible:!1,extensions:["rar"]},"application/x-redhat-package-manager":{source:"nginx",extensions:["rpm"]},"application/x-research-info-systems":{source:"apache",extensions:["ris"]},"application/x-sea":{source:"nginx",extensions:["sea"]},"application/x-sh":{source:"apache",compressible:!0,extensions:["sh"]},"application/x-shar":{source:"apache",extensions:["shar"]},"application/x-shockwave-flash":{source:"apache",compressible:!1,extensions:["swf"]},"application/x-silverlight-app":{source:"apache",extensions:["xap"]},"application/x-sql":{source:"apache",extensions:["sql"]},"application/x-stuffit":{source:"apache",compressible:!1,extensions:["sit"]},"application/x-stuffitx":{source:"apache",extensions:["sitx"]},"application/x-subrip":{source:"apache",extensions:["srt"]},"application/x-sv4cpio":{source:"apache",extensions:["sv4cpio"]},"application/x-sv4crc":{source:"apache",extensions:["sv4crc"]},"application/x-t3vm-image":{source:"apache",extensions:["t3"]},"application/x-tads":{source:"apache",extensions:["gam"]},"application/x-tar":{source:"apache",compressible:!0,extensions:["tar"]},"application/x-tcl":{source:"apache",extensions:["tcl","tk"]},"application/x-tex":{source:"apache",extensions:["tex"]},"application/x-tex-tfm":{source:"apache",extensions:["tfm"]},"application/x-texinfo":{source:"apache",extensions:["texinfo","texi"]},"application/x-tgif":{source:"apache",extensions:["obj"]},"application/x-ustar":{source:"apache",extensions:["ustar"]},"application/x-virtualbox-hdd":{compressible:!0,extensions:["hdd"]},"application/x-virtualbox-ova":{compressible:!0,extensions:["ova"]},"application/x-virtualbox-ovf":{compressible:!0,extensions:["ovf"]},"application/x-virtualbox-vbox":{compressible:!0,extensions:["vbox"]},"application/x-virtualbox-vbox-extpack":{compressible:!1,extensions:["vbox-extpack"]},"application/x-virtualbox-vdi":{compressible:!0,extensions:["vdi"]},"application/x-virtualbox-vhd":{compressible:!0,extensions:["vhd"]},"application/x-virtualbox-vmdk":{compressible:!0,extensions:["vmdk"]},"application/x-wais-source":{source:"apache",extensions:["src"]},"application/x-web-app-manifest+json":{compressible:!0,extensions:["webapp"]},"application/x-www-form-urlencoded":{source:"iana",compressible:!0},"application/x-x509-ca-cert":{source:"iana",extensions:["der","crt","pem"]},"application/x-x509-ca-ra-cert":{source:"iana"},"application/x-x509-next-ca-cert":{source:"iana"},"application/x-xfig":{source:"apache",extensions:["fig"]},"application/x-xliff+xml":{source:"apache",compressible:!0,extensions:["xlf"]},"application/x-xpinstall":{source:"apache",compressible:!1,extensions:["xpi"]},"application/x-xz":{source:"apache",extensions:["xz"]},"application/x-zmachine":{source:"apache",extensions:["z1","z2","z3","z4","z5","z6","z7","z8"]},"application/x400-bp":{source:"iana"},"application/xacml+xml":{source:"iana",compressible:!0},"application/xaml+xml":{source:"apache",compressible:!0,extensions:["xaml"]},"application/xcap-att+xml":{source:"iana",compressible:!0,extensions:["xav"]},"application/xcap-caps+xml":{source:"iana",compressible:!0,extensions:["xca"]},"application/xcap-diff+xml":{source:"iana",compressible:!0,extensions:["xdf"]},"application/xcap-el+xml":{source:"iana",compressible:!0,extensions:["xel"]},"application/xcap-error+xml":{source:"iana",compressible:!0},"application/xcap-ns+xml":{source:"iana",compressible:!0,extensions:["xns"]},"application/xcon-conference-info+xml":{source:"iana",compressible:!0},"application/xcon-conference-info-diff+xml":{source:"iana",compressible:!0},"application/xenc+xml":{source:"iana",compressible:!0,extensions:["xenc"]},"application/xhtml+xml":{source:"iana",compressible:!0,extensions:["xhtml","xht"]},"application/xhtml-voice+xml":{source:"apache",compressible:!0},"application/xliff+xml":{source:"iana",compressible:!0,extensions:["xlf"]},"application/xml":{source:"iana",compressible:!0,extensions:["xml","xsl","xsd","rng"]},"application/xml-dtd":{source:"iana",compressible:!0,extensions:["dtd"]},"application/xml-external-parsed-entity":{source:"iana"},"application/xml-patch+xml":{source:"iana",compressible:!0},"application/xmpp+xml":{source:"iana",compressible:!0},"application/xop+xml":{source:"iana",compressible:!0,extensions:["xop"]},"application/xproc+xml":{source:"apache",compressible:!0,extensions:["xpl"]},"application/xslt+xml":{source:"iana",compressible:!0,extensions:["xsl","xslt"]},"application/xspf+xml":{source:"apache",compressible:!0,extensions:["xspf"]},"application/xv+xml":{source:"iana",compressible:!0,extensions:["mxml","xhvml","xvml","xvm"]},"application/yang":{source:"iana",extensions:["yang"]},"application/yang-data+json":{source:"iana",compressible:!0},"application/yang-data+xml":{source:"iana",compressible:!0},"application/yang-patch+json":{source:"iana",compressible:!0},"application/yang-patch+xml":{source:"iana",compressible:!0},"application/yin+xml":{source:"iana",compressible:!0,extensions:["yin"]},"application/zip":{source:"iana",compressible:!1,extensions:["zip"]},"application/zlib":{source:"iana"},"application/zstd":{source:"iana"},"audio/1d-interleaved-parityfec":{source:"iana"},"audio/32kadpcm":{source:"iana"},"audio/3gpp":{source:"iana",compressible:!1,extensions:["3gpp"]},"audio/3gpp2":{source:"iana"},"audio/aac":{source:"iana"},"audio/ac3":{source:"iana"},"audio/adpcm":{source:"apache",extensions:["adp"]},"audio/amr":{source:"iana",extensions:["amr"]},"audio/amr-wb":{source:"iana"},"audio/amr-wb+":{source:"iana"},"audio/aptx":{source:"iana"},"audio/asc":{source:"iana"},"audio/atrac-advanced-lossless":{source:"iana"},"audio/atrac-x":{source:"iana"},"audio/atrac3":{source:"iana"},"audio/basic":{source:"iana",compressible:!1,extensions:["au","snd"]},"audio/bv16":{source:"iana"},"audio/bv32":{source:"iana"},"audio/clearmode":{source:"iana"},"audio/cn":{source:"iana"},"audio/dat12":{source:"iana"},"audio/dls":{source:"iana"},"audio/dsr-es201108":{source:"iana"},"audio/dsr-es202050":{source:"iana"},"audio/dsr-es202211":{source:"iana"},"audio/dsr-es202212":{source:"iana"},"audio/dv":{source:"iana"},"audio/dvi4":{source:"iana"},"audio/eac3":{source:"iana"},"audio/encaprtp":{source:"iana"},"audio/evrc":{source:"iana"},"audio/evrc-qcp":{source:"iana"},"audio/evrc0":{source:"iana"},"audio/evrc1":{source:"iana"},"audio/evrcb":{source:"iana"},"audio/evrcb0":{source:"iana"},"audio/evrcb1":{source:"iana"},"audio/evrcnw":{source:"iana"},"audio/evrcnw0":{source:"iana"},"audio/evrcnw1":{source:"iana"},"audio/evrcwb":{source:"iana"},"audio/evrcwb0":{source:"iana"},"audio/evrcwb1":{source:"iana"},"audio/evs":{source:"iana"},"audio/flexfec":{source:"iana"},"audio/fwdred":{source:"iana"},"audio/g711-0":{source:"iana"},"audio/g719":{source:"iana"},"audio/g722":{source:"iana"},"audio/g7221":{source:"iana"},"audio/g723":{source:"iana"},"audio/g726-16":{source:"iana"},"audio/g726-24":{source:"iana"},"audio/g726-32":{source:"iana"},"audio/g726-40":{source:"iana"},"audio/g728":{source:"iana"},"audio/g729":{source:"iana"},"audio/g7291":{source:"iana"},"audio/g729d":{source:"iana"},"audio/g729e":{source:"iana"},"audio/gsm":{source:"iana"},"audio/gsm-efr":{source:"iana"},"audio/gsm-hr-08":{source:"iana"},"audio/ilbc":{source:"iana"},"audio/ip-mr_v2.5":{source:"iana"},"audio/isac":{source:"apache"},"audio/l16":{source:"iana"},"audio/l20":{source:"iana"},"audio/l24":{source:"iana",compressible:!1},"audio/l8":{source:"iana"},"audio/lpc":{source:"iana"},"audio/melp":{source:"iana"},"audio/melp1200":{source:"iana"},"audio/melp2400":{source:"iana"},"audio/melp600":{source:"iana"},"audio/mhas":{source:"iana"},"audio/midi":{source:"apache",extensions:["mid","midi","kar","rmi"]},"audio/mobile-xmf":{source:"iana",extensions:["mxmf"]},"audio/mp3":{compressible:!1,extensions:["mp3"]},"audio/mp4":{source:"iana",compressible:!1,extensions:["m4a","mp4a"]},"audio/mp4a-latm":{source:"iana"},"audio/mpa":{source:"iana"},"audio/mpa-robust":{source:"iana"},"audio/mpeg":{source:"iana",compressible:!1,extensions:["mpga","mp2","mp2a","mp3","m2a","m3a"]},"audio/mpeg4-generic":{source:"iana"},"audio/musepack":{source:"apache"},"audio/ogg":{source:"iana",compressible:!1,extensions:["oga","ogg","spx","opus"]},"audio/opus":{source:"iana"},"audio/parityfec":{source:"iana"},"audio/pcma":{source:"iana"},"audio/pcma-wb":{source:"iana"},"audio/pcmu":{source:"iana"},"audio/pcmu-wb":{source:"iana"},"audio/prs.sid":{source:"iana"},"audio/qcelp":{source:"iana"},"audio/raptorfec":{source:"iana"},"audio/red":{source:"iana"},"audio/rtp-enc-aescm128":{source:"iana"},"audio/rtp-midi":{source:"iana"},"audio/rtploopback":{source:"iana"},"audio/rtx":{source:"iana"},"audio/s3m":{source:"apache",extensions:["s3m"]},"audio/scip":{source:"iana"},"audio/silk":{source:"apache",extensions:["sil"]},"audio/smv":{source:"iana"},"audio/smv-qcp":{source:"iana"},"audio/smv0":{source:"iana"},"audio/sofa":{source:"iana"},"audio/sp-midi":{source:"iana"},"audio/speex":{source:"iana"},"audio/t140c":{source:"iana"},"audio/t38":{source:"iana"},"audio/telephone-event":{source:"iana"},"audio/tetra_acelp":{source:"iana"},"audio/tetra_acelp_bb":{source:"iana"},"audio/tone":{source:"iana"},"audio/tsvcis":{source:"iana"},"audio/uemclip":{source:"iana"},"audio/ulpfec":{source:"iana"},"audio/usac":{source:"iana"},"audio/vdvi":{source:"iana"},"audio/vmr-wb":{source:"iana"},"audio/vnd.3gpp.iufp":{source:"iana"},"audio/vnd.4sb":{source:"iana"},"audio/vnd.audiokoz":{source:"iana"},"audio/vnd.celp":{source:"iana"},"audio/vnd.cisco.nse":{source:"iana"},"audio/vnd.cmles.radio-events":{source:"iana"},"audio/vnd.cns.anp1":{source:"iana"},"audio/vnd.cns.inf1":{source:"iana"},"audio/vnd.dece.audio":{source:"iana",extensions:["uva","uvva"]},"audio/vnd.digital-winds":{source:"iana",extensions:["eol"]},"audio/vnd.dlna.adts":{source:"iana"},"audio/vnd.dolby.heaac.1":{source:"iana"},"audio/vnd.dolby.heaac.2":{source:"iana"},"audio/vnd.dolby.mlp":{source:"iana"},"audio/vnd.dolby.mps":{source:"iana"},"audio/vnd.dolby.pl2":{source:"iana"},"audio/vnd.dolby.pl2x":{source:"iana"},"audio/vnd.dolby.pl2z":{source:"iana"},"audio/vnd.dolby.pulse.1":{source:"iana"},"audio/vnd.dra":{source:"iana",extensions:["dra"]},"audio/vnd.dts":{source:"iana",extensions:["dts"]},"audio/vnd.dts.hd":{source:"iana",extensions:["dtshd"]},"audio/vnd.dts.uhd":{source:"iana"},"audio/vnd.dvb.file":{source:"iana"},"audio/vnd.everad.plj":{source:"iana"},"audio/vnd.hns.audio":{source:"iana"},"audio/vnd.lucent.voice":{source:"iana",extensions:["lvp"]},"audio/vnd.ms-playready.media.pya":{source:"iana",extensions:["pya"]},"audio/vnd.nokia.mobile-xmf":{source:"iana"},"audio/vnd.nortel.vbk":{source:"iana"},"audio/vnd.nuera.ecelp4800":{source:"iana",extensions:["ecelp4800"]},"audio/vnd.nuera.ecelp7470":{source:"iana",extensions:["ecelp7470"]},"audio/vnd.nuera.ecelp9600":{source:"iana",extensions:["ecelp9600"]},"audio/vnd.octel.sbc":{source:"iana"},"audio/vnd.presonus.multitrack":{source:"iana"},"audio/vnd.qcelp":{source:"iana"},"audio/vnd.rhetorex.32kadpcm":{source:"iana"},"audio/vnd.rip":{source:"iana",extensions:["rip"]},"audio/vnd.rn-realaudio":{compressible:!1},"audio/vnd.sealedmedia.softseal.mpeg":{source:"iana"},"audio/vnd.vmx.cvsd":{source:"iana"},"audio/vnd.wave":{compressible:!1},"audio/vorbis":{source:"iana",compressible:!1},"audio/vorbis-config":{source:"iana"},"audio/wav":{compressible:!1,extensions:["wav"]},"audio/wave":{compressible:!1,extensions:["wav"]},"audio/webm":{source:"apache",compressible:!1,extensions:["weba"]},"audio/x-aac":{source:"apache",compressible:!1,extensions:["aac"]},"audio/x-aiff":{source:"apache",extensions:["aif","aiff","aifc"]},"audio/x-caf":{source:"apache",compressible:!1,extensions:["caf"]},"audio/x-flac":{source:"apache",extensions:["flac"]},"audio/x-m4a":{source:"nginx",extensions:["m4a"]},"audio/x-matroska":{source:"apache",extensions:["mka"]},"audio/x-mpegurl":{source:"apache",extensions:["m3u"]},"audio/x-ms-wax":{source:"apache",extensions:["wax"]},"audio/x-ms-wma":{source:"apache",extensions:["wma"]},"audio/x-pn-realaudio":{source:"apache",extensions:["ram","ra"]},"audio/x-pn-realaudio-plugin":{source:"apache",extensions:["rmp"]},"audio/x-realaudio":{source:"nginx",extensions:["ra"]},"audio/x-tta":{source:"apache"},"audio/x-wav":{source:"apache",extensions:["wav"]},"audio/xm":{source:"apache",extensions:["xm"]},"chemical/x-cdx":{source:"apache",extensions:["cdx"]},"chemical/x-cif":{source:"apache",extensions:["cif"]},"chemical/x-cmdf":{source:"apache",extensions:["cmdf"]},"chemical/x-cml":{source:"apache",extensions:["cml"]},"chemical/x-csml":{source:"apache",extensions:["csml"]},"chemical/x-pdb":{source:"apache"},"chemical/x-xyz":{source:"apache",extensions:["xyz"]},"font/collection":{source:"iana",extensions:["ttc"]},"font/otf":{source:"iana",compressible:!0,extensions:["otf"]},"font/sfnt":{source:"iana"},"font/ttf":{source:"iana",compressible:!0,extensions:["ttf"]},"font/woff":{source:"iana",extensions:["woff"]},"font/woff2":{source:"iana",extensions:["woff2"]},"image/aces":{source:"iana",extensions:["exr"]},"image/apng":{compressible:!1,extensions:["apng"]},"image/avci":{source:"iana",extensions:["avci"]},"image/avcs":{source:"iana",extensions:["avcs"]},"image/avif":{source:"iana",compressible:!1,extensions:["avif"]},"image/bmp":{source:"iana",compressible:!0,extensions:["bmp"]},"image/cgm":{source:"iana",extensions:["cgm"]},"image/dicom-rle":{source:"iana",extensions:["drle"]},"image/emf":{source:"iana",extensions:["emf"]},"image/fits":{source:"iana",extensions:["fits"]},"image/g3fax":{source:"iana",extensions:["g3"]},"image/gif":{source:"iana",compressible:!1,extensions:["gif"]},"image/heic":{source:"iana",extensions:["heic"]},"image/heic-sequence":{source:"iana",extensions:["heics"]},"image/heif":{source:"iana",extensions:["heif"]},"image/heif-sequence":{source:"iana",extensions:["heifs"]},"image/hej2k":{source:"iana",extensions:["hej2"]},"image/hsj2":{source:"iana",extensions:["hsj2"]},"image/ief":{source:"iana",extensions:["ief"]},"image/jls":{source:"iana",extensions:["jls"]},"image/jp2":{source:"iana",compressible:!1,extensions:["jp2","jpg2"]},"image/jpeg":{source:"iana",compressible:!1,extensions:["jpeg","jpg","jpe"]},"image/jph":{source:"iana",extensions:["jph"]},"image/jphc":{source:"iana",extensions:["jhc"]},"image/jpm":{source:"iana",compressible:!1,extensions:["jpm"]},"image/jpx":{source:"iana",compressible:!1,extensions:["jpx","jpf"]},"image/jxr":{source:"iana",extensions:["jxr"]},"image/jxra":{source:"iana",extensions:["jxra"]},"image/jxrs":{source:"iana",extensions:["jxrs"]},"image/jxs":{source:"iana",extensions:["jxs"]},"image/jxsc":{source:"iana",extensions:["jxsc"]},"image/jxsi":{source:"iana",extensions:["jxsi"]},"image/jxss":{source:"iana",extensions:["jxss"]},"image/ktx":{source:"iana",extensions:["ktx"]},"image/ktx2":{source:"iana",extensions:["ktx2"]},"image/naplps":{source:"iana"},"image/pjpeg":{compressible:!1},"image/png":{source:"iana",compressible:!1,extensions:["png"]},"image/prs.btif":{source:"iana",extensions:["btif"]},"image/prs.pti":{source:"iana",extensions:["pti"]},"image/pwg-raster":{source:"iana"},"image/sgi":{source:"apache",extensions:["sgi"]},"image/svg+xml":{source:"iana",compressible:!0,extensions:["svg","svgz"]},"image/t38":{source:"iana",extensions:["t38"]},"image/tiff":{source:"iana",compressible:!1,extensions:["tif","tiff"]},"image/tiff-fx":{source:"iana",extensions:["tfx"]},"image/vnd.adobe.photoshop":{source:"iana",compressible:!0,extensions:["psd"]},"image/vnd.airzip.accelerator.azv":{source:"iana",extensions:["azv"]},"image/vnd.cns.inf2":{source:"iana"},"image/vnd.dece.graphic":{source:"iana",extensions:["uvi","uvvi","uvg","uvvg"]},"image/vnd.djvu":{source:"iana",extensions:["djvu","djv"]},"image/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"image/vnd.dwg":{source:"iana",extensions:["dwg"]},"image/vnd.dxf":{source:"iana",extensions:["dxf"]},"image/vnd.fastbidsheet":{source:"iana",extensions:["fbs"]},"image/vnd.fpx":{source:"iana",extensions:["fpx"]},"image/vnd.fst":{source:"iana",extensions:["fst"]},"image/vnd.fujixerox.edmics-mmr":{source:"iana",extensions:["mmr"]},"image/vnd.fujixerox.edmics-rlc":{source:"iana",extensions:["rlc"]},"image/vnd.globalgraphics.pgb":{source:"iana"},"image/vnd.microsoft.icon":{source:"iana",compressible:!0,extensions:["ico"]},"image/vnd.mix":{source:"iana"},"image/vnd.mozilla.apng":{source:"iana"},"image/vnd.ms-dds":{compressible:!0,extensions:["dds"]},"image/vnd.ms-modi":{source:"iana",extensions:["mdi"]},"image/vnd.ms-photo":{source:"apache",extensions:["wdp"]},"image/vnd.net-fpx":{source:"iana",extensions:["npx"]},"image/vnd.pco.b16":{source:"iana",extensions:["b16"]},"image/vnd.radiance":{source:"iana"},"image/vnd.sealed.png":{source:"iana"},"image/vnd.sealedmedia.softseal.gif":{source:"iana"},"image/vnd.sealedmedia.softseal.jpg":{source:"iana"},"image/vnd.svf":{source:"iana"},"image/vnd.tencent.tap":{source:"iana",extensions:["tap"]},"image/vnd.valve.source.texture":{source:"iana",extensions:["vtf"]},"image/vnd.wap.wbmp":{source:"iana",extensions:["wbmp"]},"image/vnd.xiff":{source:"iana",extensions:["xif"]},"image/vnd.zbrush.pcx":{source:"iana",extensions:["pcx"]},"image/webp":{source:"apache",extensions:["webp"]},"image/wmf":{source:"iana",extensions:["wmf"]},"image/x-3ds":{source:"apache",extensions:["3ds"]},"image/x-cmu-raster":{source:"apache",extensions:["ras"]},"image/x-cmx":{source:"apache",extensions:["cmx"]},"image/x-freehand":{source:"apache",extensions:["fh","fhc","fh4","fh5","fh7"]},"image/x-icon":{source:"apache",compressible:!0,extensions:["ico"]},"image/x-jng":{source:"nginx",extensions:["jng"]},"image/x-mrsid-image":{source:"apache",extensions:["sid"]},"image/x-ms-bmp":{source:"nginx",compressible:!0,extensions:["bmp"]},"image/x-pcx":{source:"apache",extensions:["pcx"]},"image/x-pict":{source:"apache",extensions:["pic","pct"]},"image/x-portable-anymap":{source:"apache",extensions:["pnm"]},"image/x-portable-bitmap":{source:"apache",extensions:["pbm"]},"image/x-portable-graymap":{source:"apache",extensions:["pgm"]},"image/x-portable-pixmap":{source:"apache",extensions:["ppm"]},"image/x-rgb":{source:"apache",extensions:["rgb"]},"image/x-tga":{source:"apache",extensions:["tga"]},"image/x-xbitmap":{source:"apache",extensions:["xbm"]},"image/x-xcf":{compressible:!1},"image/x-xpixmap":{source:"apache",extensions:["xpm"]},"image/x-xwindowdump":{source:"apache",extensions:["xwd"]},"message/cpim":{source:"iana"},"message/delivery-status":{source:"iana"},"message/disposition-notification":{source:"iana",extensions:["disposition-notification"]},"message/external-body":{source:"iana"},"message/feedback-report":{source:"iana"},"message/global":{source:"iana",extensions:["u8msg"]},"message/global-delivery-status":{source:"iana",extensions:["u8dsn"]},"message/global-disposition-notification":{source:"iana",extensions:["u8mdn"]},"message/global-headers":{source:"iana",extensions:["u8hdr"]},"message/http":{source:"iana",compressible:!1},"message/imdn+xml":{source:"iana",compressible:!0},"message/news":{source:"iana"},"message/partial":{source:"iana",compressible:!1},"message/rfc822":{source:"iana",compressible:!0,extensions:["eml","mime"]},"message/s-http":{source:"iana"},"message/sip":{source:"iana"},"message/sipfrag":{source:"iana"},"message/tracking-status":{source:"iana"},"message/vnd.si.simp":{source:"iana"},"message/vnd.wfa.wsc":{source:"iana",extensions:["wsc"]},"model/3mf":{source:"iana",extensions:["3mf"]},"model/e57":{source:"iana"},"model/gltf+json":{source:"iana",compressible:!0,extensions:["gltf"]},"model/gltf-binary":{source:"iana",compressible:!0,extensions:["glb"]},"model/iges":{source:"iana",compressible:!1,extensions:["igs","iges"]},"model/mesh":{source:"iana",compressible:!1,extensions:["msh","mesh","silo"]},"model/mtl":{source:"iana",extensions:["mtl"]},"model/obj":{source:"iana",extensions:["obj"]},"model/step":{source:"iana"},"model/step+xml":{source:"iana",compressible:!0,extensions:["stpx"]},"model/step+zip":{source:"iana",compressible:!1,extensions:["stpz"]},"model/step-xml+zip":{source:"iana",compressible:!1,extensions:["stpxz"]},"model/stl":{source:"iana",extensions:["stl"]},"model/vnd.collada+xml":{source:"iana",compressible:!0,extensions:["dae"]},"model/vnd.dwf":{source:"iana",extensions:["dwf"]},"model/vnd.flatland.3dml":{source:"iana"},"model/vnd.gdl":{source:"iana",extensions:["gdl"]},"model/vnd.gs-gdl":{source:"apache"},"model/vnd.gs.gdl":{source:"iana"},"model/vnd.gtw":{source:"iana",extensions:["gtw"]},"model/vnd.moml+xml":{source:"iana",compressible:!0},"model/vnd.mts":{source:"iana",extensions:["mts"]},"model/vnd.opengex":{source:"iana",extensions:["ogex"]},"model/vnd.parasolid.transmit.binary":{source:"iana",extensions:["x_b"]},"model/vnd.parasolid.transmit.text":{source:"iana",extensions:["x_t"]},"model/vnd.pytha.pyox":{source:"iana"},"model/vnd.rosette.annotated-data-model":{source:"iana"},"model/vnd.sap.vds":{source:"iana",extensions:["vds"]},"model/vnd.usdz+zip":{source:"iana",compressible:!1,extensions:["usdz"]},"model/vnd.valve.source.compiled-map":{source:"iana",extensions:["bsp"]},"model/vnd.vtu":{source:"iana",extensions:["vtu"]},"model/vrml":{source:"iana",compressible:!1,extensions:["wrl","vrml"]},"model/x3d+binary":{source:"apache",compressible:!1,extensions:["x3db","x3dbz"]},"model/x3d+fastinfoset":{source:"iana",extensions:["x3db"]},"model/x3d+vrml":{source:"apache",compressible:!1,extensions:["x3dv","x3dvz"]},"model/x3d+xml":{source:"iana",compressible:!0,extensions:["x3d","x3dz"]},"model/x3d-vrml":{source:"iana",extensions:["x3dv"]},"multipart/alternative":{source:"iana",compressible:!1},"multipart/appledouble":{source:"iana"},"multipart/byteranges":{source:"iana"},"multipart/digest":{source:"iana"},"multipart/encrypted":{source:"iana",compressible:!1},"multipart/form-data":{source:"iana",compressible:!1},"multipart/header-set":{source:"iana"},"multipart/mixed":{source:"iana"},"multipart/multilingual":{source:"iana"},"multipart/parallel":{source:"iana"},"multipart/related":{source:"iana",compressible:!1},"multipart/report":{source:"iana"},"multipart/signed":{source:"iana",compressible:!1},"multipart/vnd.bint.med-plus":{source:"iana"},"multipart/voice-message":{source:"iana"},"multipart/x-mixed-replace":{source:"iana"},"text/1d-interleaved-parityfec":{source:"iana"},"text/cache-manifest":{source:"iana",compressible:!0,extensions:["appcache","manifest"]},"text/calendar":{source:"iana",extensions:["ics","ifb"]},"text/calender":{compressible:!0},"text/cmd":{compressible:!0},"text/coffeescript":{extensions:["coffee","litcoffee"]},"text/cql":{source:"iana"},"text/cql-expression":{source:"iana"},"text/cql-identifier":{source:"iana"},"text/css":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["css"]},"text/csv":{source:"iana",compressible:!0,extensions:["csv"]},"text/csv-schema":{source:"iana"},"text/directory":{source:"iana"},"text/dns":{source:"iana"},"text/ecmascript":{source:"iana"},"text/encaprtp":{source:"iana"},"text/enriched":{source:"iana"},"text/fhirpath":{source:"iana"},"text/flexfec":{source:"iana"},"text/fwdred":{source:"iana"},"text/gff3":{source:"iana"},"text/grammar-ref-list":{source:"iana"},"text/html":{source:"iana",compressible:!0,extensions:["html","htm","shtml"]},"text/jade":{extensions:["jade"]},"text/javascript":{source:"iana",compressible:!0},"text/jcr-cnd":{source:"iana"},"text/jsx":{compressible:!0,extensions:["jsx"]},"text/less":{compressible:!0,extensions:["less"]},"text/markdown":{source:"iana",compressible:!0,extensions:["markdown","md"]},"text/mathml":{source:"nginx",extensions:["mml"]},"text/mdx":{compressible:!0,extensions:["mdx"]},"text/mizar":{source:"iana"},"text/n3":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["n3"]},"text/parameters":{source:"iana",charset:"UTF-8"},"text/parityfec":{source:"iana"},"text/plain":{source:"iana",compressible:!0,extensions:["txt","text","conf","def","list","log","in","ini"]},"text/provenance-notation":{source:"iana",charset:"UTF-8"},"text/prs.fallenstein.rst":{source:"iana"},"text/prs.lines.tag":{source:"iana",extensions:["dsc"]},"text/prs.prop.logic":{source:"iana"},"text/raptorfec":{source:"iana"},"text/red":{source:"iana"},"text/rfc822-headers":{source:"iana"},"text/richtext":{source:"iana",compressible:!0,extensions:["rtx"]},"text/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"text/rtp-enc-aescm128":{source:"iana"},"text/rtploopback":{source:"iana"},"text/rtx":{source:"iana"},"text/sgml":{source:"iana",extensions:["sgml","sgm"]},"text/shaclc":{source:"iana"},"text/shex":{source:"iana",extensions:["shex"]},"text/slim":{extensions:["slim","slm"]},"text/spdx":{source:"iana",extensions:["spdx"]},"text/strings":{source:"iana"},"text/stylus":{extensions:["stylus","styl"]},"text/t140":{source:"iana"},"text/tab-separated-values":{source:"iana",compressible:!0,extensions:["tsv"]},"text/troff":{source:"iana",extensions:["t","tr","roff","man","me","ms"]},"text/turtle":{source:"iana",charset:"UTF-8",extensions:["ttl"]},"text/ulpfec":{source:"iana"},"text/uri-list":{source:"iana",compressible:!0,extensions:["uri","uris","urls"]},"text/vcard":{source:"iana",compressible:!0,extensions:["vcard"]},"text/vnd.a":{source:"iana"},"text/vnd.abc":{source:"iana"},"text/vnd.ascii-art":{source:"iana"},"text/vnd.curl":{source:"iana",extensions:["curl"]},"text/vnd.curl.dcurl":{source:"apache",extensions:["dcurl"]},"text/vnd.curl.mcurl":{source:"apache",extensions:["mcurl"]},"text/vnd.curl.scurl":{source:"apache",extensions:["scurl"]},"text/vnd.debian.copyright":{source:"iana",charset:"UTF-8"},"text/vnd.dmclientscript":{source:"iana"},"text/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"text/vnd.esmertec.theme-descriptor":{source:"iana",charset:"UTF-8"},"text/vnd.familysearch.gedcom":{source:"iana",extensions:["ged"]},"text/vnd.ficlab.flt":{source:"iana"},"text/vnd.fly":{source:"iana",extensions:["fly"]},"text/vnd.fmi.flexstor":{source:"iana",extensions:["flx"]},"text/vnd.gml":{source:"iana"},"text/vnd.graphviz":{source:"iana",extensions:["gv"]},"text/vnd.hans":{source:"iana"},"text/vnd.hgl":{source:"iana"},"text/vnd.in3d.3dml":{source:"iana",extensions:["3dml"]},"text/vnd.in3d.spot":{source:"iana",extensions:["spot"]},"text/vnd.iptc.newsml":{source:"iana"},"text/vnd.iptc.nitf":{source:"iana"},"text/vnd.latex-z":{source:"iana"},"text/vnd.motorola.reflex":{source:"iana"},"text/vnd.ms-mediapackage":{source:"iana"},"text/vnd.net2phone.commcenter.command":{source:"iana"},"text/vnd.radisys.msml-basic-layout":{source:"iana"},"text/vnd.senx.warpscript":{source:"iana"},"text/vnd.si.uricatalogue":{source:"iana"},"text/vnd.sosi":{source:"iana"},"text/vnd.sun.j2me.app-descriptor":{source:"iana",charset:"UTF-8",extensions:["jad"]},"text/vnd.trolltech.linguist":{source:"iana",charset:"UTF-8"},"text/vnd.wap.si":{source:"iana"},"text/vnd.wap.sl":{source:"iana"},"text/vnd.wap.wml":{source:"iana",extensions:["wml"]},"text/vnd.wap.wmlscript":{source:"iana",extensions:["wmls"]},"text/vtt":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["vtt"]},"text/x-asm":{source:"apache",extensions:["s","asm"]},"text/x-c":{source:"apache",extensions:["c","cc","cxx","cpp","h","hh","dic"]},"text/x-component":{source:"nginx",extensions:["htc"]},"text/x-fortran":{source:"apache",extensions:["f","for","f77","f90"]},"text/x-gwt-rpc":{compressible:!0},"text/x-handlebars-template":{extensions:["hbs"]},"text/x-java-source":{source:"apache",extensions:["java"]},"text/x-jquery-tmpl":{compressible:!0},"text/x-lua":{extensions:["lua"]},"text/x-markdown":{compressible:!0,extensions:["mkd"]},"text/x-nfo":{source:"apache",extensions:["nfo"]},"text/x-opml":{source:"apache",extensions:["opml"]},"text/x-org":{compressible:!0,extensions:["org"]},"text/x-pascal":{source:"apache",extensions:["p","pas"]},"text/x-processing":{compressible:!0,extensions:["pde"]},"text/x-sass":{extensions:["sass"]},"text/x-scss":{extensions:["scss"]},"text/x-setext":{source:"apache",extensions:["etx"]},"text/x-sfv":{source:"apache",extensions:["sfv"]},"text/x-suse-ymp":{compressible:!0,extensions:["ymp"]},"text/x-uuencode":{source:"apache",extensions:["uu"]},"text/x-vcalendar":{source:"apache",extensions:["vcs"]},"text/x-vcard":{source:"apache",extensions:["vcf"]},"text/xml":{source:"iana",compressible:!0,extensions:["xml"]},"text/xml-external-parsed-entity":{source:"iana"},"text/yaml":{compressible:!0,extensions:["yaml","yml"]},"video/1d-interleaved-parityfec":{source:"iana"},"video/3gpp":{source:"iana",extensions:["3gp","3gpp"]},"video/3gpp-tt":{source:"iana"},"video/3gpp2":{source:"iana",extensions:["3g2"]},"video/av1":{source:"iana"},"video/bmpeg":{source:"iana"},"video/bt656":{source:"iana"},"video/celb":{source:"iana"},"video/dv":{source:"iana"},"video/encaprtp":{source:"iana"},"video/ffv1":{source:"iana"},"video/flexfec":{source:"iana"},"video/h261":{source:"iana",extensions:["h261"]},"video/h263":{source:"iana",extensions:["h263"]},"video/h263-1998":{source:"iana"},"video/h263-2000":{source:"iana"},"video/h264":{source:"iana",extensions:["h264"]},"video/h264-rcdo":{source:"iana"},"video/h264-svc":{source:"iana"},"video/h265":{source:"iana"},"video/iso.segment":{source:"iana",extensions:["m4s"]},"video/jpeg":{source:"iana",extensions:["jpgv"]},"video/jpeg2000":{source:"iana"},"video/jpm":{source:"apache",extensions:["jpm","jpgm"]},"video/jxsv":{source:"iana"},"video/mj2":{source:"iana",extensions:["mj2","mjp2"]},"video/mp1s":{source:"iana"},"video/mp2p":{source:"iana"},"video/mp2t":{source:"iana",extensions:["ts"]},"video/mp4":{source:"iana",compressible:!1,extensions:["mp4","mp4v","mpg4"]},"video/mp4v-es":{source:"iana"},"video/mpeg":{source:"iana",compressible:!1,extensions:["mpeg","mpg","mpe","m1v","m2v"]},"video/mpeg4-generic":{source:"iana"},"video/mpv":{source:"iana"},"video/nv":{source:"iana"},"video/ogg":{source:"iana",compressible:!1,extensions:["ogv"]},"video/parityfec":{source:"iana"},"video/pointer":{source:"iana"},"video/quicktime":{source:"iana",compressible:!1,extensions:["qt","mov"]},"video/raptorfec":{source:"iana"},"video/raw":{source:"iana"},"video/rtp-enc-aescm128":{source:"iana"},"video/rtploopback":{source:"iana"},"video/rtx":{source:"iana"},"video/scip":{source:"iana"},"video/smpte291":{source:"iana"},"video/smpte292m":{source:"iana"},"video/ulpfec":{source:"iana"},"video/vc1":{source:"iana"},"video/vc2":{source:"iana"},"video/vnd.cctv":{source:"iana"},"video/vnd.dece.hd":{source:"iana",extensions:["uvh","uvvh"]},"video/vnd.dece.mobile":{source:"iana",extensions:["uvm","uvvm"]},"video/vnd.dece.mp4":{source:"iana"},"video/vnd.dece.pd":{source:"iana",extensions:["uvp","uvvp"]},"video/vnd.dece.sd":{source:"iana",extensions:["uvs","uvvs"]},"video/vnd.dece.video":{source:"iana",extensions:["uvv","uvvv"]},"video/vnd.directv.mpeg":{source:"iana"},"video/vnd.directv.mpeg-tts":{source:"iana"},"video/vnd.dlna.mpeg-tts":{source:"iana"},"video/vnd.dvb.file":{source:"iana",extensions:["dvb"]},"video/vnd.fvt":{source:"iana",extensions:["fvt"]},"video/vnd.hns.video":{source:"iana"},"video/vnd.iptvforum.1dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.1dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.2dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.2dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.ttsavc":{source:"iana"},"video/vnd.iptvforum.ttsmpeg2":{source:"iana"},"video/vnd.motorola.video":{source:"iana"},"video/vnd.motorola.videop":{source:"iana"},"video/vnd.mpegurl":{source:"iana",extensions:["mxu","m4u"]},"video/vnd.ms-playready.media.pyv":{source:"iana",extensions:["pyv"]},"video/vnd.nokia.interleaved-multimedia":{source:"iana"},"video/vnd.nokia.mp4vr":{source:"iana"},"video/vnd.nokia.videovoip":{source:"iana"},"video/vnd.objectvideo":{source:"iana"},"video/vnd.radgamettools.bink":{source:"iana"},"video/vnd.radgamettools.smacker":{source:"iana"},"video/vnd.sealed.mpeg1":{source:"iana"},"video/vnd.sealed.mpeg4":{source:"iana"},"video/vnd.sealed.swf":{source:"iana"},"video/vnd.sealedmedia.softseal.mov":{source:"iana"},"video/vnd.uvvu.mp4":{source:"iana",extensions:["uvu","uvvu"]},"video/vnd.vivo":{source:"iana",extensions:["viv"]},"video/vnd.youtube.yt":{source:"iana"},"video/vp8":{source:"iana"},"video/vp9":{source:"iana"},"video/webm":{source:"apache",compressible:!1,extensions:["webm"]},"video/x-f4v":{source:"apache",extensions:["f4v"]},"video/x-fli":{source:"apache",extensions:["fli"]},"video/x-flv":{source:"apache",compressible:!1,extensions:["flv"]},"video/x-m4v":{source:"apache",extensions:["m4v"]},"video/x-matroska":{source:"apache",compressible:!1,extensions:["mkv","mk3d","mks"]},"video/x-mng":{source:"apache",extensions:["mng"]},"video/x-ms-asf":{source:"apache",extensions:["asf","asx"]},"video/x-ms-vob":{source:"apache",extensions:["vob"]},"video/x-ms-wm":{source:"apache",extensions:["wm"]},"video/x-ms-wmv":{source:"apache",compressible:!1,extensions:["wmv"]},"video/x-ms-wmx":{source:"apache",extensions:["wmx"]},"video/x-ms-wvx":{source:"apache",extensions:["wvx"]},"video/x-msvideo":{source:"apache",extensions:["avi"]},"video/x-sgi-movie":{source:"apache",extensions:["movie"]},"video/x-smv":{source:"apache",extensions:["smv"]},"x-conference/x-cooltalk":{source:"apache",extensions:["ice"]},"x-shader/x-fragment":{compressible:!0},"x-shader/x-vertex":{compressible:!0}}});var Xa=y((ag,Qa)=>{"use strict";Qa.exports=Ja()});var er=y(_e=>{"use strict";var zs=Xa(),vu=k("path").extname,Ya=/^\s*([^;\s]*)(?:;|\s|$)/,bu=/^text\//i;_e.charset=Za;_e.charsets={lookup:Za};_e.contentType=yu;_e.extension=_u;_e.extensions=Object.create(null);_e.lookup=Cu;_e.types=Object.create(null);wu(_e.extensions,_e.types);function Za(s){if(!s||typeof s!="string")return!1;var e=Ya.exec(s),t=e&&zs[e[1].toLowerCase()];return t&&t.charset?t.charset:e&&bu.test(e[1])?"UTF-8":!1}function yu(s){if(!s||typeof s!="string")return!1;var e=s.indexOf("/")===-1?_e.lookup(s):s;if(!e)return!1;if(e.indexOf("charset")===-1){var t=_e.charset(e);t&&(e+="; charset="+t.toLowerCase())}return e}function _u(s){if(!s||typeof s!="string")return!1;var e=Ya.exec(s),t=e&&_e.extensions[e[1].toLowerCase()];return!t||!t.length?!1:t[0]}function Cu(s){if(!s||typeof s!="string")return!1;var e=vu("x."+s).toLowerCase().substr(1);return e&&_e.types[e]||!1}function wu(s,e){var t=["nginx","apache",void 0,"iana"];Object.keys(zs).forEach(function(n){var a=zs[n],r=a.extensions;if(!(!r||!r.length)){s[n]=r;for(var o=0;o<r.length;o++){var l=r[o];if(e[l]){var c=t.indexOf(zs[e[l]].source),p=t.indexOf(a.source);if(e[l]!=="application/octet-stream"&&(c>p||c===p&&e[l].substr(0,12)==="application/"))continue}e[l]=n}}})}});var sr=y((og,tr)=>{"use strict";tr.exports=Eu;function Eu(s){var e=typeof setImmediate=="function"?setImmediate:typeof process=="object"&&typeof process.nextTick=="function"?process.nextTick:null;e?e(s):setTimeout(s,0)}});var ji=y((cg,nr)=>{"use strict";var ir=sr();nr.exports=Su;function Su(s){var e=!1;return ir(function(){e=!0}),function(i,n){e?s(i,n):ir(function(){s(i,n)})}}});var Ni=y((lg,ar)=>{"use strict";ar.exports=Ru;function Ru(s){Object.keys(s.jobs).forEach(Tu.bind(s)),s.jobs={}}function Tu(s){typeof this.jobs[s]=="function"&&this.jobs[s]()}});var Gi=y((pg,or)=>{"use strict";var rr=ji(),ku=Ni();or.exports=Au;function Au(s,e,t,i){var n=t.keyedList?t.keyedList[t.index]:t.index;t.jobs[n]=Iu(e,n,s[n],function(a,r){n in t.jobs&&(delete t.jobs[n],a?ku(t):t.results[n]=r,i(a,t.results))})}function Iu(s,e,t,i){var n;return s.length==2?n=s(t,rr(i)):n=s(t,e,rr(i)),n}});var qi=y((ug,cr)=>{"use strict";cr.exports=Du;function Du(s,e){var t=!Array.isArray(s),i={index:0,keyedList:t||e?Object.keys(s):null,jobs:{},results:t?{}:[],size:t?Object.keys(s).length:s.length};return e&&i.keyedList.sort(t?e:function(n,a){return e(s[n],s[a])}),i}});var Bi=y((dg,lr)=>{"use strict";var Uu=Ni(),Ou=ji();lr.exports=Lu;function Lu(s){Object.keys(this.jobs).length&&(this.index=this.size,Uu(this),Ou(s)(null,this.results))}});var ur=y((mg,pr)=>{"use strict";var Pu=Gi(),Mu=qi(),Fu=Bi();pr.exports=ju;function ju(s,e,t){for(var i=Mu(s);i.index<(i.keyedList||s).length;)Pu(s,e,i,function(n,a){if(n){t(n,a);return}if(Object.keys(i.jobs).length===0){t(null,i.results);return}}),i.index++;return Fu.bind(i,t)}});var $i=y((hg,Ws)=>{"use strict";var dr=Gi(),Nu=qi(),Gu=Bi();Ws.exports=qu;Ws.exports.ascending=mr;Ws.exports.descending=Bu;function qu(s,e,t,i){var n=Nu(s,t);return dr(s,e,n,function a(r,o){if(r){i(r,o);return}if(n.index++,n.index<(n.keyedList||s).length){dr(s,e,n,a);return}i(null,n.results)}),Gu.bind(n,i)}function mr(s,e){return s<e?-1:s>e?1:0}function Bu(s,e){return-1*mr(s,e)}});var fr=y((fg,hr)=>{"use strict";var $u=$i();hr.exports=zu;function zu(s,e,t){return $u(s,e,null,t)}});var xr=y((gg,gr)=>{"use strict";gr.exports={parallel:ur(),serial:fr(),serialOrdered:$i()}});var zi=y((xg,vr)=>{"use strict";vr.exports=Object});var yr=y((vg,br)=>{"use strict";br.exports=Error});var Cr=y((bg,_r)=>{"use strict";_r.exports=EvalError});var Er=y((yg,wr)=>{"use strict";wr.exports=RangeError});var Rr=y((_g,Sr)=>{"use strict";Sr.exports=ReferenceError});var kr=y((Cg,Tr)=>{"use strict";Tr.exports=SyntaxError});var Vs=y((wg,Ar)=>{"use strict";Ar.exports=TypeError});var Dr=y((Eg,Ir)=>{"use strict";Ir.exports=URIError});var Or=y((Sg,Ur)=>{"use strict";Ur.exports=Math.abs});var Pr=y((Rg,Lr)=>{"use strict";Lr.exports=Math.floor});var Fr=y((Tg,Mr)=>{"use strict";Mr.exports=Math.max});var Nr=y((kg,jr)=>{"use strict";jr.exports=Math.min});var qr=y((Ag,Gr)=>{"use strict";Gr.exports=Math.pow});var $r=y((Ig,Br)=>{"use strict";Br.exports=Math.round});var Wr=y((Dg,zr)=>{"use strict";zr.exports=Number.isNaN||function(e){return e!==e}});var Hr=y((Ug,Vr)=>{"use strict";var Wu=Wr();Vr.exports=function(e){return Wu(e)||e===0?e:e<0?-1:1}});var Jr=y((Og,Kr)=>{"use strict";Kr.exports=Object.getOwnPropertyDescriptor});var Wi=y((Lg,Qr)=>{"use strict";var Hs=Jr();if(Hs)try{Hs([],"length")}catch{Hs=null}Qr.exports=Hs});var Yr=y((Pg,Xr)=>{"use strict";var Ks=Object.defineProperty||!1;if(Ks)try{Ks({},"a",{value:1})}catch{Ks=!1}Xr.exports=Ks});var Vi=y((Mg,Zr)=>{"use strict";Zr.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),i=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var n=42;e[t]=n;for(var a in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var r=Object.getOwnPropertySymbols(e);if(r.length!==1||r[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==n||o.enumerable!==!0)return!1}return!0}});var so=y((Fg,to)=>{"use strict";var eo=typeof Symbol<"u"&&Symbol,Vu=Vi();to.exports=function(){return typeof eo!="function"||typeof Symbol!="function"||typeof eo("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Vu()}});var Hi=y((jg,io)=>{"use strict";io.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Ki=y((Ng,no)=>{"use strict";var Hu=zi();no.exports=Hu.getPrototypeOf||null});var oo=y((Gg,ro)=>{"use strict";var Ku="Function.prototype.bind called on incompatible ",Ju=Object.prototype.toString,Qu=Math.max,Xu="[object Function]",ao=function(e,t){for(var i=[],n=0;n<e.length;n+=1)i[n]=e[n];for(var a=0;a<t.length;a+=1)i[a+e.length]=t[a];return i},Yu=function(e,t){for(var i=[],n=t||0,a=0;n<e.length;n+=1,a+=1)i[a]=e[n];return i},Zu=function(s,e){for(var t="",i=0;i<s.length;i+=1)t+=s[i],i+1<s.length&&(t+=e);return t};ro.exports=function(e){var t=this;if(typeof t!="function"||Ju.apply(t)!==Xu)throw new TypeError(Ku+t);for(var i=Yu(arguments,1),n,a=function(){if(this instanceof n){var p=t.apply(this,ao(i,arguments));return Object(p)===p?p:this}return t.apply(e,ao(i,arguments))},r=Qu(0,t.length-i.length),o=[],l=0;l<r;l++)o[l]="$"+l;if(n=Function("binder","return function ("+Zu(o,",")+"){ return binder.apply(this,arguments); }")(a),t.prototype){var c=function(){};c.prototype=t.prototype,n.prototype=new c,c.prototype=null}return n}});var rs=y((qg,co)=>{"use strict";var ed=oo();co.exports=Function.prototype.bind||ed});var Js=y((Bg,lo)=>{"use strict";lo.exports=Function.prototype.call});var Ji=y(($g,po)=>{"use strict";po.exports=Function.prototype.apply});var mo=y((zg,uo)=>{"use strict";uo.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var fo=y((Wg,ho)=>{"use strict";var td=rs(),sd=Ji(),id=Js(),nd=mo();ho.exports=nd||td.call(id,sd)});var xo=y((Vg,go)=>{"use strict";var ad=rs(),rd=Vs(),od=Js(),cd=fo();go.exports=function(e){if(e.length<1||typeof e[0]!="function")throw new rd("a function is required");return cd(ad,od,e)}});var wo=y((Hg,Co)=>{"use strict";var ld=xo(),vo=Wi(),yo;try{yo=[].__proto__===Array.prototype}catch(s){if(!s||typeof s!="object"||!("code"in s)||s.code!=="ERR_PROTO_ACCESS")throw s}var Qi=!!yo&&vo&&vo(Object.prototype,"__proto__"),_o=Object,bo=_o.getPrototypeOf;Co.exports=Qi&&typeof Qi.get=="function"?ld([Qi.get]):typeof bo=="function"?function(e){return bo(e==null?e:_o(e))}:!1});var ko=y((Kg,To)=>{"use strict";var Eo=Hi(),So=Ki(),Ro=wo();To.exports=Eo?function(e){return Eo(e)}:So?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return So(e)}:Ro?function(e){return Ro(e)}:null});var Qs=y((Jg,Ao)=>{"use strict";var pd=Function.prototype.call,ud=Object.prototype.hasOwnProperty,dd=rs();Ao.exports=dd.call(pd,ud)});var Mo=y((Qg,Po)=>{"use strict";var P,md=zi(),hd=yr(),fd=Cr(),gd=Er(),xd=Rr(),Mt=kr(),Pt=Vs(),vd=Dr(),bd=Or(),yd=Pr(),_d=Fr(),Cd=Nr(),wd=qr(),Ed=$r(),Sd=Hr(),Oo=Function,Xi=function(s){try{return Oo('"use strict"; return ('+s+").constructor;")()}catch{}},os=Wi(),Rd=Yr(),Yi=function(){throw new Pt},Td=os?(function(){try{return arguments.callee,Yi}catch{try{return os(arguments,"callee").get}catch{return Yi}}})():Yi,Ot=so()(),ce=ko(),kd=Ki(),Ad=Hi(),Lo=Ji(),cs=Js(),Lt={},Id=typeof Uint8Array>"u"||!ce?P:ce(Uint8Array),dt={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?P:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?P:ArrayBuffer,"%ArrayIteratorPrototype%":Ot&&ce?ce([][Symbol.iterator]()):P,"%AsyncFromSyncIteratorPrototype%":P,"%AsyncFunction%":Lt,"%AsyncGenerator%":Lt,"%AsyncGeneratorFunction%":Lt,"%AsyncIteratorPrototype%":Lt,"%Atomics%":typeof Atomics>"u"?P:Atomics,"%BigInt%":typeof BigInt>"u"?P:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?P:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?P:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?P:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":hd,"%eval%":eval,"%EvalError%":fd,"%Float16Array%":typeof Float16Array>"u"?P:Float16Array,"%Float32Array%":typeof Float32Array>"u"?P:Float32Array,"%Float64Array%":typeof Float64Array>"u"?P:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?P:FinalizationRegistry,"%Function%":Oo,"%GeneratorFunction%":Lt,"%Int8Array%":typeof Int8Array>"u"?P:Int8Array,"%Int16Array%":typeof Int16Array>"u"?P:Int16Array,"%Int32Array%":typeof Int32Array>"u"?P:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ot&&ce?ce(ce([][Symbol.iterator]())):P,"%JSON%":typeof JSON=="object"?JSON:P,"%Map%":typeof Map>"u"?P:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ot||!ce?P:ce(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":md,"%Object.getOwnPropertyDescriptor%":os,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?P:Promise,"%Proxy%":typeof Proxy>"u"?P:Proxy,"%RangeError%":gd,"%ReferenceError%":xd,"%Reflect%":typeof Reflect>"u"?P:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?P:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ot||!ce?P:ce(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?P:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ot&&ce?ce(""[Symbol.iterator]()):P,"%Symbol%":Ot?Symbol:P,"%SyntaxError%":Mt,"%ThrowTypeError%":Td,"%TypedArray%":Id,"%TypeError%":Pt,"%Uint8Array%":typeof Uint8Array>"u"?P:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?P:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?P:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?P:Uint32Array,"%URIError%":vd,"%WeakMap%":typeof WeakMap>"u"?P:WeakMap,"%WeakRef%":typeof WeakRef>"u"?P:WeakRef,"%WeakSet%":typeof WeakSet>"u"?P:WeakSet,"%Function.prototype.call%":cs,"%Function.prototype.apply%":Lo,"%Object.defineProperty%":Rd,"%Object.getPrototypeOf%":kd,"%Math.abs%":bd,"%Math.floor%":yd,"%Math.max%":_d,"%Math.min%":Cd,"%Math.pow%":wd,"%Math.round%":Ed,"%Math.sign%":Sd,"%Reflect.getPrototypeOf%":Ad};if(ce)try{null.error}catch(s){Io=ce(ce(s)),dt["%Error.prototype%"]=Io}var Io,Dd=function s(e){var t;if(e==="%AsyncFunction%")t=Xi("async function () {}");else if(e==="%GeneratorFunction%")t=Xi("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Xi("async function* () {}");else if(e==="%AsyncGenerator%"){var i=s("%AsyncGeneratorFunction%");i&&(t=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var n=s("%AsyncGenerator%");n&&ce&&(t=ce(n.prototype))}return dt[e]=t,t},Do={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ls=rs(),Xs=Qs(),Ud=ls.call(cs,Array.prototype.concat),Od=ls.call(Lo,Array.prototype.splice),Uo=ls.call(cs,String.prototype.replace),Ys=ls.call(cs,String.prototype.slice),Ld=ls.call(cs,RegExp.prototype.exec),Pd=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Md=/\\(\\)?/g,Fd=function(e){var t=Ys(e,0,1),i=Ys(e,-1);if(t==="%"&&i!=="%")throw new Mt("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&t!=="%")throw new Mt("invalid intrinsic syntax, expected opening `%`");var n=[];return Uo(e,Pd,function(a,r,o,l){n[n.length]=o?Uo(l,Md,"$1"):r||a}),n},jd=function(e,t){var i=e,n;if(Xs(Do,i)&&(n=Do[i],i="%"+n[0]+"%"),Xs(dt,i)){var a=dt[i];if(a===Lt&&(a=Dd(i)),typeof a>"u"&&!t)throw new Pt("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:n,name:i,value:a}}throw new Mt("intrinsic "+e+" does not exist!")};Po.exports=function(e,t){if(typeof e!="string"||e.length===0)throw new Pt("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Pt('"allowMissing" argument must be a boolean');if(Ld(/^%?[^%]*%?$/,e)===null)throw new Mt("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=Fd(e),n=i.length>0?i[0]:"",a=jd("%"+n+"%",t),r=a.name,o=a.value,l=!1,c=a.alias;c&&(n=c[0],Od(i,Ud([0,1],c)));for(var p=1,d=!0;p<i.length;p+=1){var u=i[p],f=Ys(u,0,1),h=Ys(u,-1);if((f==='"'||f==="'"||f==="`"||h==='"'||h==="'"||h==="`")&&f!==h)throw new Mt("property names with quotes must have matching quotes");if((u==="constructor"||!d)&&(l=!0),n+="."+u,r="%"+n+"%",Xs(dt,r))o=dt[r];else if(o!=null){if(!(u in o)){if(!t)throw new Pt("base intrinsic for "+e+" exists, but the property is not available.");return}if(os&&p+1>=i.length){var x=os(o,u);d=!!x,d&&"get"in x&&!("originalValue"in x.get)?o=x.get:o=o[u]}else d=Xs(o,u),o=o[u];d&&!l&&(dt[r]=o)}}return o}});var jo=y((Xg,Fo)=>{"use strict";var Nd=Vi();Fo.exports=function(){return Nd()&&!!Symbol.toStringTag}});var qo=y((Yg,Go)=>{"use strict";var Gd=Mo(),No=Gd("%Object.defineProperty%",!0),qd=jo()(),Bd=Qs(),$d=Vs(),Zs=qd?Symbol.toStringTag:null;Go.exports=function(e,t){var i=arguments.length>2&&!!arguments[2]&&arguments[2].force,n=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof i<"u"&&typeof i!="boolean"||typeof n<"u"&&typeof n!="boolean")throw new $d("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Zs&&(i||!Bd(e,Zs))&&(No?No(e,Zs,{configurable:!n,enumerable:!1,value:t,writable:!1}):e[Zs]=t)}});var $o=y((Zg,Bo)=>{"use strict";Bo.exports=function(s,e){return Object.keys(e).forEach(function(t){s[t]=s[t]||e[t]}),s}});var nn=y((ex,zo)=>{"use strict";var sn=Ka(),zd=k("util"),Zi=k("path"),Wd=k("http"),Vd=(Ze(),ts(as)),Hd=k("url").parse,Kd=k("fs"),Jd=k("stream").Stream,Qd=k("crypto"),en=er(),Xd=xr(),Yd=qo(),et=Qs(),tn=$o();function j(s){if(!(this instanceof j))return new j(s);this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],sn.call(this),s=s||{};for(var e in s)this[e]=s[e]}zd.inherits(j,sn);j.LINE_BREAK=`\r
2
- `;j.DEFAULT_CONTENT_TYPE="application/octet-stream";j.prototype.append=function(s,e,t){t=t||{},typeof t=="string"&&(t={filename:t});var i=sn.prototype.append.bind(this);if((typeof e=="number"||e==null)&&(e=String(e)),Array.isArray(e)){this._error(new Error("Arrays are not supported."));return}var n=this._multiPartHeader(s,e,t),a=this._multiPartFooter();i(n),i(e),i(a),this._trackLength(n,e,t)};j.prototype._trackLength=function(s,e,t){var i=0;t.knownLength!=null?i+=Number(t.knownLength):Buffer.isBuffer(e)?i=e.length:typeof e=="string"&&(i=Buffer.byteLength(e)),this._valueLength+=i,this._overheadLength+=Buffer.byteLength(s)+j.LINE_BREAK.length,!(!e||!e.path&&!(e.readable&&et(e,"httpVersion"))&&!(e instanceof Jd))&&(t.knownLength||this._valuesToMeasure.push(e))};j.prototype._lengthRetriever=function(s,e){et(s,"fd")?s.end!=null&&s.end!=1/0&&s.start!=null?e(null,s.end+1-(s.start?s.start:0)):Kd.stat(s.path,function(t,i){if(t){e(t);return}var n=i.size-(s.start?s.start:0);e(null,n)}):et(s,"httpVersion")?e(null,Number(s.headers["content-length"])):et(s,"httpModule")?(s.on("response",function(t){s.pause(),e(null,Number(t.headers["content-length"]))}),s.resume()):e("Unknown stream")};j.prototype._multiPartHeader=function(s,e,t){if(typeof t.header=="string")return t.header;var i=this._getContentDisposition(e,t),n=this._getContentType(e,t),a="",r={"Content-Disposition":["form-data",'name="'+s+'"'].concat(i||[]),"Content-Type":[].concat(n||[])};typeof t.header=="object"&&tn(r,t.header);var o;for(var l in r)if(et(r,l)){if(o=r[l],o==null)continue;Array.isArray(o)||(o=[o]),o.length&&(a+=l+": "+o.join("; ")+j.LINE_BREAK)}return"--"+this.getBoundary()+j.LINE_BREAK+a+j.LINE_BREAK};j.prototype._getContentDisposition=function(s,e){var t;if(typeof e.filepath=="string"?t=Zi.normalize(e.filepath).replace(/\\/g,"/"):e.filename||s&&(s.name||s.path)?t=Zi.basename(e.filename||s&&(s.name||s.path)):s&&s.readable&&et(s,"httpVersion")&&(t=Zi.basename(s.client._httpMessage.path||"")),t)return'filename="'+t+'"'};j.prototype._getContentType=function(s,e){var t=e.contentType;return!t&&s&&s.name&&(t=en.lookup(s.name)),!t&&s&&s.path&&(t=en.lookup(s.path)),!t&&s&&s.readable&&et(s,"httpVersion")&&(t=s.headers["content-type"]),!t&&(e.filepath||e.filename)&&(t=en.lookup(e.filepath||e.filename)),!t&&s&&typeof s=="object"&&(t=j.DEFAULT_CONTENT_TYPE),t};j.prototype._multiPartFooter=function(){return function(s){var e=j.LINE_BREAK,t=this._streams.length===0;t&&(e+=this._lastBoundary()),s(e)}.bind(this)};j.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+j.LINE_BREAK};j.prototype.getHeaders=function(s){var e,t={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(e in s)et(s,e)&&(t[e.toLowerCase()]=s[e]);return t};j.prototype.setBoundary=function(s){if(typeof s!="string")throw new TypeError("FormData boundary must be a string");this._boundary=s};j.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary};j.prototype.getBuffer=function(){for(var s=new Buffer.alloc(0),e=this.getBoundary(),t=0,i=this._streams.length;t<i;t++)typeof this._streams[t]!="function"&&(Buffer.isBuffer(this._streams[t])?s=Buffer.concat([s,this._streams[t]]):s=Buffer.concat([s,Buffer.from(this._streams[t])]),(typeof this._streams[t]!="string"||this._streams[t].substring(2,e.length+2)!==e)&&(s=Buffer.concat([s,Buffer.from(j.LINE_BREAK)])));return Buffer.concat([s,Buffer.from(this._lastBoundary())])};j.prototype._generateBoundary=function(){this._boundary="--------------------------"+Qd.randomBytes(12).toString("hex")};j.prototype.getLengthSync=function(){var s=this._overheadLength+this._valueLength;return this._streams.length&&(s+=this._lastBoundary().length),this.hasKnownLength()||this._error(new Error("Cannot calculate proper length in synchronous way.")),s};j.prototype.hasKnownLength=function(){var s=!0;return this._valuesToMeasure.length&&(s=!1),s};j.prototype.getLength=function(s){var e=this._overheadLength+this._valueLength;if(this._streams.length&&(e+=this._lastBoundary().length),!this._valuesToMeasure.length){process.nextTick(s.bind(this,null,e));return}Xd.parallel(this._valuesToMeasure,this._lengthRetriever,function(t,i){if(t){s(t);return}i.forEach(function(n){e+=n}),s(null,e)})};j.prototype.submit=function(s,e){var t,i,n={method:"post"};return typeof s=="string"?(s=Hd(s),i=tn({port:s.port,path:s.pathname,host:s.hostname,protocol:s.protocol},n)):(i=tn(s,n),i.port||(i.port=i.protocol==="https:"?443:80)),i.headers=this.getHeaders(s.headers),i.protocol==="https:"?t=Vd.request(i):t=Wd.request(i),this.getLength(function(a,r){if(a&&a!=="Unknown stream"){this._error(a);return}if(r&&t.setHeader("Content-Length",r),this.pipe(t),e){var o,l=function(c,p){return t.removeListener("error",l),t.removeListener("response",o),e.call(this,c,p)};o=l.bind(this,null),t.on("error",l),t.on("response",o)}}.bind(this)),t};j.prototype._error=function(s){this.error||(this.error=s,this.pause(),this.emit("error",s))};j.prototype.toString=function(){return"[object FormData]"};Yd(j,"FormData");zo.exports=j});var cc=y(oc=>{"use strict";var gm=k("url").parse,xm={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443},vm=String.prototype.endsWith||function(s){return s.length<=this.length&&this.indexOf(s,this.length-s.length)!==-1};function bm(s){var e=typeof s=="string"?gm(s):s||{},t=e.protocol,i=e.host,n=e.port;if(typeof i!="string"||!i||typeof t!="string"||(t=t.split(":",1)[0],i=i.replace(/:\d*$/,""),n=parseInt(n)||xm[t]||0,!ym(i,n)))return"";var a=Gt("npm_config_"+t+"_proxy")||Gt(t+"_proxy")||Gt("npm_config_proxy")||Gt("all_proxy");return a&&a.indexOf("://")===-1&&(a=t+"://"+a),a}function ym(s,e){var t=(Gt("npm_config_no_proxy")||Gt("no_proxy")).toLowerCase();return t?t==="*"?!1:t.split(/[,\s]/).every(function(i){if(!i)return!0;var n=i.match(/^(.+):(\d+)$/),a=n?n[1]:i,r=n?parseInt(n[2]):0;return r&&r!==e?!0:/^[.*]/.test(a)?(a.charAt(0)==="*"&&(a=a.slice(1)),!vm.call(s,a)):s!==a}):!0}function Gt(s){return process.env[s.toLowerCase()]||process.env[s.toUpperCase()]||""}oc.getProxyForUrl=bm});var pc=y((tv,lc)=>{"use strict";var qt=1e3,Bt=qt*60,$t=Bt*60,ft=$t*24,_m=ft*7,Cm=ft*365.25;lc.exports=function(s,e){e=e||{};var t=typeof s;if(t==="string"&&s.length>0)return wm(s);if(t==="number"&&isFinite(s))return e.long?Sm(s):Em(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))};function wm(s){if(s=String(s),!(s.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(e){var t=parseFloat(e[1]),i=(e[2]||"ms").toLowerCase();switch(i){case"years":case"year":case"yrs":case"yr":case"y":return t*Cm;case"weeks":case"week":case"w":return t*_m;case"days":case"day":case"d":return t*ft;case"hours":case"hour":case"hrs":case"hr":case"h":return t*$t;case"minutes":case"minute":case"mins":case"min":case"m":return t*Bt;case"seconds":case"second":case"secs":case"sec":case"s":return t*qt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Em(s){var e=Math.abs(s);return e>=ft?Math.round(s/ft)+"d":e>=$t?Math.round(s/$t)+"h":e>=Bt?Math.round(s/Bt)+"m":e>=qt?Math.round(s/qt)+"s":s+"ms"}function Sm(s){var e=Math.abs(s);return e>=ft?ii(s,e,ft,"day"):e>=$t?ii(s,e,$t,"hour"):e>=Bt?ii(s,e,Bt,"minute"):e>=qt?ii(s,e,qt,"second"):s+" ms"}function ii(s,e,t,i){var n=e>=t*1.5;return Math.round(s/t)+" "+i+(n?"s":"")}});var xn=y((sv,uc)=>{"use strict";function Rm(s){t.debug=t,t.default=t,t.coerce=l,t.disable=r,t.enable=n,t.enabled=o,t.humanize=pc(),t.destroy=c,Object.keys(s).forEach(p=>{t[p]=s[p]}),t.names=[],t.skips=[],t.formatters={};function e(p){let d=0;for(let u=0;u<p.length;u++)d=(d<<5)-d+p.charCodeAt(u),d|=0;return t.colors[Math.abs(d)%t.colors.length]}t.selectColor=e;function t(p){let d,u=null,f,h;function x(...v){if(!x.enabled)return;let b=x,T=Number(new Date),I=T-(d||T);b.diff=I,b.prev=d,b.curr=T,d=T,v[0]=t.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let M=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(V,Y)=>{if(V==="%%")return"%";M++;let H=t.formatters[Y];if(typeof H=="function"){let de=v[M];V=H.call(b,de),v.splice(M,1),M--}return V}),t.formatArgs.call(b,v),(b.log||t.log).apply(b,v)}return x.namespace=p,x.useColors=t.useColors(),x.color=t.selectColor(p),x.extend=i,x.destroy=t.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>u!==null?u:(f!==t.namespaces&&(f=t.namespaces,h=t.enabled(p)),h),set:v=>{u=v}}),typeof t.init=="function"&&t.init(x),x}function i(p,d){let u=t(this.namespace+(typeof d>"u"?":":d)+p);return u.log=this.log,u}function n(p){t.save(p),t.namespaces=p,t.names=[],t.skips=[];let d=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let u of d)u[0]==="-"?t.skips.push(u.slice(1)):t.names.push(u)}function a(p,d){let u=0,f=0,h=-1,x=0;for(;u<p.length;)if(f<d.length&&(d[f]===p[u]||d[f]==="*"))d[f]==="*"?(h=f,x=u,f++):(u++,f++);else if(h!==-1)f=h+1,x++,u=x;else return!1;for(;f<d.length&&d[f]==="*";)f++;return f===d.length}function r(){let p=[...t.names,...t.skips.map(d=>"-"+d)].join(",");return t.enable(""),p}function o(p){for(let d of t.skips)if(a(p,d))return!1;for(let d of t.names)if(a(p,d))return!0;return!1}function l(p){return p instanceof Error?p.stack||p.message:p}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}uc.exports=Rm});var dc=y((Ce,ni)=>{"use strict";Ce.formatArgs=km;Ce.save=Am;Ce.load=Im;Ce.useColors=Tm;Ce.storage=Dm();Ce.destroy=(()=>{let s=!1;return()=>{s||(s=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Ce.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Tm(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let s;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(s=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(s[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function km(s){if(s[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+s[0]+(this.useColors?"%c ":" ")+"+"+ni.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;s.splice(1,0,e,"color: inherit");let t=0,i=0;s[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(t++,n==="%c"&&(i=t))}),s.splice(i,0,e)}Ce.log=console.debug||console.log||(()=>{});function Am(s){try{s?Ce.storage.setItem("debug",s):Ce.storage.removeItem("debug")}catch{}}function Im(){let s;try{s=Ce.storage.getItem("debug")||Ce.storage.getItem("DEBUG")}catch{}return!s&&typeof process<"u"&&"env"in process&&(s=process.env.DEBUG),s}function Dm(){try{return localStorage}catch{}}ni.exports=xn()(Ce);var{formatters:Um}=ni.exports;Um.j=function(s){try{return JSON.stringify(s)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var hc=y((iv,mc)=>{"use strict";mc.exports=(s,e=process.argv)=>{let t=s.startsWith("-")?"":s.length===1?"-":"--",i=e.indexOf(t+s),n=e.indexOf("--");return i!==-1&&(n===-1||i<n)}});var xc=y((nv,gc)=>{"use strict";var Om=k("os"),fc=k("tty"),Le=hc(),{env:le}=process,ai;Le("no-color")||Le("no-colors")||Le("color=false")||Le("color=never")?ai=0:(Le("color")||Le("colors")||Le("color=true")||Le("color=always"))&&(ai=1);function Lm(){if("FORCE_COLOR"in le)return le.FORCE_COLOR==="true"?1:le.FORCE_COLOR==="false"?0:le.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(le.FORCE_COLOR,10),3)}function Pm(s){return s===0?!1:{level:s,hasBasic:!0,has256:s>=2,has16m:s>=3}}function Mm(s,{streamIsTTY:e,sniffFlags:t=!0}={}){let i=Lm();i!==void 0&&(ai=i);let n=t?ai:i;if(n===0)return 0;if(t){if(Le("color=16m")||Le("color=full")||Le("color=truecolor"))return 3;if(Le("color=256"))return 2}if(s&&!e&&n===void 0)return 0;let a=n||0;if(le.TERM==="dumb")return a;if(process.platform==="win32"){let r=Om.release().split(".");return Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in le)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(r=>r in le)||le.CI_NAME==="codeship"?1:a;if("TEAMCITY_VERSION"in le)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(le.TEAMCITY_VERSION)?1:0;if(le.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in le){let r=Number.parseInt((le.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(le.TERM_PROGRAM){case"iTerm.app":return r>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(le.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(le.TERM)||"COLORTERM"in le?1:a}function vn(s,e={}){let t=Mm(s,{streamIsTTY:s&&s.isTTY,...e});return Pm(t)}gc.exports={supportsColor:vn,stdout:vn({isTTY:fc.isatty(1)}),stderr:vn({isTTY:fc.isatty(2)})}});var bc=y((pe,oi)=>{"use strict";var Fm=k("tty"),ri=k("util");pe.init=zm;pe.log=qm;pe.formatArgs=Nm;pe.save=Bm;pe.load=$m;pe.useColors=jm;pe.destroy=ri.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");pe.colors=[6,2,3,4,5,1];try{let s=xc();s&&(s.stderr||s).level>=2&&(pe.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}pe.inspectOpts=Object.keys(process.env).filter(s=>/^debug_/i.test(s)).reduce((s,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,a)=>a.toUpperCase()),i=process.env[e];return/^(yes|on|true|enabled)$/i.test(i)?i=!0:/^(no|off|false|disabled)$/i.test(i)?i=!1:i==="null"?i=null:i=Number(i),s[t]=i,s},{});function jm(){return"colors"in pe.inspectOpts?!!pe.inspectOpts.colors:Fm.isatty(process.stderr.fd)}function Nm(s){let{namespace:e,useColors:t}=this;if(t){let i=this.color,n="\x1B[3"+(i<8?i:"8;5;"+i),a=` ${n};1m${e} \x1B[0m`;s[0]=a+s[0].split(`
1
+ "use strict";var ErmisChatSDK=(()=>{var hf=Object.create;var Sr=Object.defineProperty;var mf=Object.getOwnPropertyDescriptor;var ff=Object.getOwnPropertyNames;var gf=Object.getPrototypeOf,_f=Object.prototype.hasOwnProperty;var V=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var qc=(n,e)=>()=>(n&&(e=n(n=0)),e);var U=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Rr=(n,e)=>{for(var t in e)Sr(n,t,{get:e[t],enumerable:!0})},zc=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ff(e))!_f.call(n,r)&&r!==t&&Sr(n,r,{get:()=>e[r],enumerable:!(s=mf(e,r))||s.enumerable});return n};var We=(n,e,t)=>(t=n!=null?hf(gf(n)):{},zc(e||!n||!n.__esModule?Sr(t,"default",{value:n,enumerable:!0}):t,n)),un=n=>zc(Sr({},"__esModule",{value:!0}),n);var sl=U((oE,tl)=>{"use strict";var el=V("stream").Stream,ng=V("util");tl.exports=mt;function mt(){this.source=null,this.dataSize=0,this.maxDataSize=1024*1024,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}ng.inherits(mt,el);mt.create=function(n,e){var t=new this;e=e||{};for(var s in e)t[s]=e[s];t.source=n;var r=n.emit;return n.emit=function(){return t._handleEmit(arguments),r.apply(n,arguments)},n.on("error",function(){}),t.pauseStream&&n.pause(),t};Object.defineProperty(mt.prototype,"readable",{configurable:!0,enumerable:!0,get:function(){return this.source.readable}});mt.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)};mt.prototype.resume=function(){this._released||this.release(),this.source.resume()};mt.prototype.pause=function(){this.source.pause()};mt.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(n){this.emit.apply(this,n)}.bind(this)),this._bufferedEvents=[]};mt.prototype.pipe=function(){var n=el.prototype.pipe.apply(this,arguments);return this.resume(),n};mt.prototype._handleEmit=function(n){if(this._released){this.emit.apply(this,n);return}n[0]==="data"&&(this.dataSize+=n[1].length,this._checkIfMaxDataSizeExceeded()),this._bufferedEvents.push(n)};mt.prototype._checkIfMaxDataSizeExceeded=function(){if(!this._maxDataSizeExceeded&&!(this.dataSize<=this.maxDataSize)){this._maxDataSizeExceeded=!0;var n="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this.emit("error",new Error(n))}}});var al=U((cE,il)=>{"use strict";var rg=V("util"),rl=V("stream").Stream,nl=sl();il.exports=we;function we(){this.writable=!1,this.readable=!0,this.dataSize=0,this.maxDataSize=2*1024*1024,this.pauseStreams=!0,this._released=!1,this._streams=[],this._currentStream=null,this._insideLoop=!1,this._pendingNext=!1}rg.inherits(we,rl);we.create=function(n){var e=new this;n=n||{};for(var t in n)e[t]=n[t];return e};we.isStreamLike=function(n){return typeof n!="function"&&typeof n!="string"&&typeof n!="boolean"&&typeof n!="number"&&!Buffer.isBuffer(n)};we.prototype.append=function(n){var e=we.isStreamLike(n);if(e){if(!(n instanceof nl)){var t=nl.create(n,{maxDataSize:1/0,pauseStream:this.pauseStreams});n.on("data",this._checkDataSize.bind(this)),n=t}this._handleErrors(n),this.pauseStreams&&n.pause()}return this._streams.push(n),this};we.prototype.pipe=function(n,e){return rl.prototype.pipe.call(this,n,e),this.resume(),n};we.prototype._getNext=function(){if(this._currentStream=null,this._insideLoop){this._pendingNext=!0;return}this._insideLoop=!0;try{do this._pendingNext=!1,this._realGetNext();while(this._pendingNext)}finally{this._insideLoop=!1}};we.prototype._realGetNext=function(){var n=this._streams.shift();if(typeof n>"u"){this.end();return}if(typeof n!="function"){this._pipeNext(n);return}var e=n;e(function(t){var s=we.isStreamLike(t);s&&(t.on("data",this._checkDataSize.bind(this)),this._handleErrors(t)),this._pipeNext(t)}.bind(this))};we.prototype._pipeNext=function(n){this._currentStream=n;var e=we.isStreamLike(n);if(e){n.on("end",this._getNext.bind(this)),n.pipe(this,{end:!1});return}var t=n;this.write(t),this._getNext()};we.prototype._handleErrors=function(n){var e=this;n.on("error",function(t){e._emitError(t)})};we.prototype.write=function(n){this.emit("data",n)};we.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&typeof this._currentStream.pause=="function"&&this._currentStream.pause(),this.emit("pause"))};we.prototype.resume=function(){this._released||(this._released=!0,this.writable=!0,this._getNext()),this.pauseStreams&&this._currentStream&&typeof this._currentStream.resume=="function"&&this._currentStream.resume(),this.emit("resume")};we.prototype.end=function(){this._reset(),this.emit("end")};we.prototype.destroy=function(){this._reset(),this.emit("close")};we.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null};we.prototype._checkDataSize=function(){if(this._updateDataSize(),!(this.dataSize<=this.maxDataSize)){var n="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this._emitError(new Error(n))}};we.prototype._updateDataSize=function(){this.dataSize=0;var n=this;this._streams.forEach(function(e){e.dataSize&&(n.dataSize+=e.dataSize)}),this._currentStream&&this._currentStream.dataSize&&(this.dataSize+=this._currentStream.dataSize)};we.prototype._emitError=function(n){this._reset(),this.emit("error",n)}});var gn={};Rr(gn,{default:()=>ns});var ns,jt=qc(()=>{"use strict";ns=null});var ol=U((lE,ig)=>{ig.exports={"application/1d-interleaved-parityfec":{source:"iana"},"application/3gpdash-qoe-report+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/3gpp-ims+xml":{source:"iana",compressible:!0},"application/3gpphal+json":{source:"iana",compressible:!0},"application/3gpphalforms+json":{source:"iana",compressible:!0},"application/a2l":{source:"iana"},"application/ace+cbor":{source:"iana"},"application/activemessage":{source:"iana"},"application/activity+json":{source:"iana",compressible:!0},"application/alto-costmap+json":{source:"iana",compressible:!0},"application/alto-costmapfilter+json":{source:"iana",compressible:!0},"application/alto-directory+json":{source:"iana",compressible:!0},"application/alto-endpointcost+json":{source:"iana",compressible:!0},"application/alto-endpointcostparams+json":{source:"iana",compressible:!0},"application/alto-endpointprop+json":{source:"iana",compressible:!0},"application/alto-endpointpropparams+json":{source:"iana",compressible:!0},"application/alto-error+json":{source:"iana",compressible:!0},"application/alto-networkmap+json":{source:"iana",compressible:!0},"application/alto-networkmapfilter+json":{source:"iana",compressible:!0},"application/alto-updatestreamcontrol+json":{source:"iana",compressible:!0},"application/alto-updatestreamparams+json":{source:"iana",compressible:!0},"application/aml":{source:"iana"},"application/andrew-inset":{source:"iana",extensions:["ez"]},"application/applefile":{source:"iana"},"application/applixware":{source:"apache",extensions:["aw"]},"application/at+jwt":{source:"iana"},"application/atf":{source:"iana"},"application/atfx":{source:"iana"},"application/atom+xml":{source:"iana",compressible:!0,extensions:["atom"]},"application/atomcat+xml":{source:"iana",compressible:!0,extensions:["atomcat"]},"application/atomdeleted+xml":{source:"iana",compressible:!0,extensions:["atomdeleted"]},"application/atomicmail":{source:"iana"},"application/atomsvc+xml":{source:"iana",compressible:!0,extensions:["atomsvc"]},"application/atsc-dwd+xml":{source:"iana",compressible:!0,extensions:["dwd"]},"application/atsc-dynamic-event-message":{source:"iana"},"application/atsc-held+xml":{source:"iana",compressible:!0,extensions:["held"]},"application/atsc-rdt+json":{source:"iana",compressible:!0},"application/atsc-rsat+xml":{source:"iana",compressible:!0,extensions:["rsat"]},"application/atxml":{source:"iana"},"application/auth-policy+xml":{source:"iana",compressible:!0},"application/bacnet-xdd+zip":{source:"iana",compressible:!1},"application/batch-smtp":{source:"iana"},"application/bdoc":{compressible:!1,extensions:["bdoc"]},"application/beep+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/calendar+json":{source:"iana",compressible:!0},"application/calendar+xml":{source:"iana",compressible:!0,extensions:["xcs"]},"application/call-completion":{source:"iana"},"application/cals-1840":{source:"iana"},"application/captive+json":{source:"iana",compressible:!0},"application/cbor":{source:"iana"},"application/cbor-seq":{source:"iana"},"application/cccex":{source:"iana"},"application/ccmp+xml":{source:"iana",compressible:!0},"application/ccxml+xml":{source:"iana",compressible:!0,extensions:["ccxml"]},"application/cdfx+xml":{source:"iana",compressible:!0,extensions:["cdfx"]},"application/cdmi-capability":{source:"iana",extensions:["cdmia"]},"application/cdmi-container":{source:"iana",extensions:["cdmic"]},"application/cdmi-domain":{source:"iana",extensions:["cdmid"]},"application/cdmi-object":{source:"iana",extensions:["cdmio"]},"application/cdmi-queue":{source:"iana",extensions:["cdmiq"]},"application/cdni":{source:"iana"},"application/cea":{source:"iana"},"application/cea-2018+xml":{source:"iana",compressible:!0},"application/cellml+xml":{source:"iana",compressible:!0},"application/cfw":{source:"iana"},"application/city+json":{source:"iana",compressible:!0},"application/clr":{source:"iana"},"application/clue+xml":{source:"iana",compressible:!0},"application/clue_info+xml":{source:"iana",compressible:!0},"application/cms":{source:"iana"},"application/cnrp+xml":{source:"iana",compressible:!0},"application/coap-group+json":{source:"iana",compressible:!0},"application/coap-payload":{source:"iana"},"application/commonground":{source:"iana"},"application/conference-info+xml":{source:"iana",compressible:!0},"application/cose":{source:"iana"},"application/cose-key":{source:"iana"},"application/cose-key-set":{source:"iana"},"application/cpl+xml":{source:"iana",compressible:!0,extensions:["cpl"]},"application/csrattrs":{source:"iana"},"application/csta+xml":{source:"iana",compressible:!0},"application/cstadata+xml":{source:"iana",compressible:!0},"application/csvm+json":{source:"iana",compressible:!0},"application/cu-seeme":{source:"apache",extensions:["cu"]},"application/cwt":{source:"iana"},"application/cybercash":{source:"iana"},"application/dart":{compressible:!0},"application/dash+xml":{source:"iana",compressible:!0,extensions:["mpd"]},"application/dash-patch+xml":{source:"iana",compressible:!0,extensions:["mpp"]},"application/dashdelta":{source:"iana"},"application/davmount+xml":{source:"iana",compressible:!0,extensions:["davmount"]},"application/dca-rft":{source:"iana"},"application/dcd":{source:"iana"},"application/dec-dx":{source:"iana"},"application/dialog-info+xml":{source:"iana",compressible:!0},"application/dicom":{source:"iana"},"application/dicom+json":{source:"iana",compressible:!0},"application/dicom+xml":{source:"iana",compressible:!0},"application/dii":{source:"iana"},"application/dit":{source:"iana"},"application/dns":{source:"iana"},"application/dns+json":{source:"iana",compressible:!0},"application/dns-message":{source:"iana"},"application/docbook+xml":{source:"apache",compressible:!0,extensions:["dbk"]},"application/dots+cbor":{source:"iana"},"application/dskpp+xml":{source:"iana",compressible:!0},"application/dssc+der":{source:"iana",extensions:["dssc"]},"application/dssc+xml":{source:"iana",compressible:!0,extensions:["xdssc"]},"application/dvcs":{source:"iana"},"application/ecmascript":{source:"iana",compressible:!0,extensions:["es","ecma"]},"application/edi-consent":{source:"iana"},"application/edi-x12":{source:"iana",compressible:!1},"application/edifact":{source:"iana",compressible:!1},"application/efi":{source:"iana"},"application/elm+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/elm+xml":{source:"iana",compressible:!0},"application/emergencycalldata.cap+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/emergencycalldata.comment+xml":{source:"iana",compressible:!0},"application/emergencycalldata.control+xml":{source:"iana",compressible:!0},"application/emergencycalldata.deviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.ecall.msd":{source:"iana"},"application/emergencycalldata.providerinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.serviceinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.subscriberinfo+xml":{source:"iana",compressible:!0},"application/emergencycalldata.veds+xml":{source:"iana",compressible:!0},"application/emma+xml":{source:"iana",compressible:!0,extensions:["emma"]},"application/emotionml+xml":{source:"iana",compressible:!0,extensions:["emotionml"]},"application/encaprtp":{source:"iana"},"application/epp+xml":{source:"iana",compressible:!0},"application/epub+zip":{source:"iana",compressible:!1,extensions:["epub"]},"application/eshop":{source:"iana"},"application/exi":{source:"iana",extensions:["exi"]},"application/expect-ct-report+json":{source:"iana",compressible:!0},"application/express":{source:"iana",extensions:["exp"]},"application/fastinfoset":{source:"iana"},"application/fastsoap":{source:"iana"},"application/fdt+xml":{source:"iana",compressible:!0,extensions:["fdt"]},"application/fhir+json":{source:"iana",charset:"UTF-8",compressible:!0},"application/fhir+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/fido.trusted-apps+json":{compressible:!0},"application/fits":{source:"iana"},"application/flexfec":{source:"iana"},"application/font-sfnt":{source:"iana"},"application/font-tdpfr":{source:"iana",extensions:["pfr"]},"application/font-woff":{source:"iana",compressible:!1},"application/framework-attributes+xml":{source:"iana",compressible:!0},"application/geo+json":{source:"iana",compressible:!0,extensions:["geojson"]},"application/geo+json-seq":{source:"iana"},"application/geopackage+sqlite3":{source:"iana"},"application/geoxacml+xml":{source:"iana",compressible:!0},"application/gltf-buffer":{source:"iana"},"application/gml+xml":{source:"iana",compressible:!0,extensions:["gml"]},"application/gpx+xml":{source:"apache",compressible:!0,extensions:["gpx"]},"application/gxf":{source:"apache",extensions:["gxf"]},"application/gzip":{source:"iana",compressible:!1,extensions:["gz"]},"application/h224":{source:"iana"},"application/held+xml":{source:"iana",compressible:!0},"application/hjson":{extensions:["hjson"]},"application/http":{source:"iana"},"application/hyperstudio":{source:"iana",extensions:["stk"]},"application/ibe-key-request+xml":{source:"iana",compressible:!0},"application/ibe-pkg-reply+xml":{source:"iana",compressible:!0},"application/ibe-pp-data":{source:"iana"},"application/iges":{source:"iana"},"application/im-iscomposing+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/index":{source:"iana"},"application/index.cmd":{source:"iana"},"application/index.obj":{source:"iana"},"application/index.response":{source:"iana"},"application/index.vnd":{source:"iana"},"application/inkml+xml":{source:"iana",compressible:!0,extensions:["ink","inkml"]},"application/iotp":{source:"iana"},"application/ipfix":{source:"iana",extensions:["ipfix"]},"application/ipp":{source:"iana"},"application/isup":{source:"iana"},"application/its+xml":{source:"iana",compressible:!0,extensions:["its"]},"application/java-archive":{source:"apache",compressible:!1,extensions:["jar","war","ear"]},"application/java-serialized-object":{source:"apache",compressible:!1,extensions:["ser"]},"application/java-vm":{source:"apache",compressible:!1,extensions:["class"]},"application/javascript":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["js","mjs"]},"application/jf2feed+json":{source:"iana",compressible:!0},"application/jose":{source:"iana"},"application/jose+json":{source:"iana",compressible:!0},"application/jrd+json":{source:"iana",compressible:!0},"application/jscalendar+json":{source:"iana",compressible:!0},"application/json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["json","map"]},"application/json-patch+json":{source:"iana",compressible:!0},"application/json-seq":{source:"iana"},"application/json5":{extensions:["json5"]},"application/jsonml+json":{source:"apache",compressible:!0,extensions:["jsonml"]},"application/jwk+json":{source:"iana",compressible:!0},"application/jwk-set+json":{source:"iana",compressible:!0},"application/jwt":{source:"iana"},"application/kpml-request+xml":{source:"iana",compressible:!0},"application/kpml-response+xml":{source:"iana",compressible:!0},"application/ld+json":{source:"iana",compressible:!0,extensions:["jsonld"]},"application/lgr+xml":{source:"iana",compressible:!0,extensions:["lgr"]},"application/link-format":{source:"iana"},"application/load-control+xml":{source:"iana",compressible:!0},"application/lost+xml":{source:"iana",compressible:!0,extensions:["lostxml"]},"application/lostsync+xml":{source:"iana",compressible:!0},"application/lpf+zip":{source:"iana",compressible:!1},"application/lxf":{source:"iana"},"application/mac-binhex40":{source:"iana",extensions:["hqx"]},"application/mac-compactpro":{source:"apache",extensions:["cpt"]},"application/macwriteii":{source:"iana"},"application/mads+xml":{source:"iana",compressible:!0,extensions:["mads"]},"application/manifest+json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["webmanifest"]},"application/marc":{source:"iana",extensions:["mrc"]},"application/marcxml+xml":{source:"iana",compressible:!0,extensions:["mrcx"]},"application/mathematica":{source:"iana",extensions:["ma","nb","mb"]},"application/mathml+xml":{source:"iana",compressible:!0,extensions:["mathml"]},"application/mathml-content+xml":{source:"iana",compressible:!0},"application/mathml-presentation+xml":{source:"iana",compressible:!0},"application/mbms-associated-procedure-description+xml":{source:"iana",compressible:!0},"application/mbms-deregister+xml":{source:"iana",compressible:!0},"application/mbms-envelope+xml":{source:"iana",compressible:!0},"application/mbms-msk+xml":{source:"iana",compressible:!0},"application/mbms-msk-response+xml":{source:"iana",compressible:!0},"application/mbms-protection-description+xml":{source:"iana",compressible:!0},"application/mbms-reception-report+xml":{source:"iana",compressible:!0},"application/mbms-register+xml":{source:"iana",compressible:!0},"application/mbms-register-response+xml":{source:"iana",compressible:!0},"application/mbms-schedule+xml":{source:"iana",compressible:!0},"application/mbms-user-service-description+xml":{source:"iana",compressible:!0},"application/mbox":{source:"iana",extensions:["mbox"]},"application/media-policy-dataset+xml":{source:"iana",compressible:!0,extensions:["mpf"]},"application/media_control+xml":{source:"iana",compressible:!0},"application/mediaservercontrol+xml":{source:"iana",compressible:!0,extensions:["mscml"]},"application/merge-patch+json":{source:"iana",compressible:!0},"application/metalink+xml":{source:"apache",compressible:!0,extensions:["metalink"]},"application/metalink4+xml":{source:"iana",compressible:!0,extensions:["meta4"]},"application/mets+xml":{source:"iana",compressible:!0,extensions:["mets"]},"application/mf4":{source:"iana"},"application/mikey":{source:"iana"},"application/mipc":{source:"iana"},"application/missing-blocks+cbor-seq":{source:"iana"},"application/mmt-aei+xml":{source:"iana",compressible:!0,extensions:["maei"]},"application/mmt-usd+xml":{source:"iana",compressible:!0,extensions:["musd"]},"application/mods+xml":{source:"iana",compressible:!0,extensions:["mods"]},"application/moss-keys":{source:"iana"},"application/moss-signature":{source:"iana"},"application/mosskey-data":{source:"iana"},"application/mosskey-request":{source:"iana"},"application/mp21":{source:"iana",extensions:["m21","mp21"]},"application/mp4":{source:"iana",extensions:["mp4s","m4p"]},"application/mpeg4-generic":{source:"iana"},"application/mpeg4-iod":{source:"iana"},"application/mpeg4-iod-xmt":{source:"iana"},"application/mrb-consumer+xml":{source:"iana",compressible:!0},"application/mrb-publish+xml":{source:"iana",compressible:!0},"application/msc-ivr+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msc-mixer+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/msword":{source:"iana",compressible:!1,extensions:["doc","dot"]},"application/mud+json":{source:"iana",compressible:!0},"application/multipart-core":{source:"iana"},"application/mxf":{source:"iana",extensions:["mxf"]},"application/n-quads":{source:"iana",extensions:["nq"]},"application/n-triples":{source:"iana",extensions:["nt"]},"application/nasdata":{source:"iana"},"application/news-checkgroups":{source:"iana",charset:"US-ASCII"},"application/news-groupinfo":{source:"iana",charset:"US-ASCII"},"application/news-transmission":{source:"iana"},"application/nlsml+xml":{source:"iana",compressible:!0},"application/node":{source:"iana",extensions:["cjs"]},"application/nss":{source:"iana"},"application/oauth-authz-req+jwt":{source:"iana"},"application/oblivious-dns-message":{source:"iana"},"application/ocsp-request":{source:"iana"},"application/ocsp-response":{source:"iana"},"application/octet-stream":{source:"iana",compressible:!1,extensions:["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"]},"application/oda":{source:"iana",extensions:["oda"]},"application/odm+xml":{source:"iana",compressible:!0},"application/odx":{source:"iana"},"application/oebps-package+xml":{source:"iana",compressible:!0,extensions:["opf"]},"application/ogg":{source:"iana",compressible:!1,extensions:["ogx"]},"application/omdoc+xml":{source:"apache",compressible:!0,extensions:["omdoc"]},"application/onenote":{source:"apache",extensions:["onetoc","onetoc2","onetmp","onepkg"]},"application/opc-nodeset+xml":{source:"iana",compressible:!0},"application/oscore":{source:"iana"},"application/oxps":{source:"iana",extensions:["oxps"]},"application/p21":{source:"iana"},"application/p21+zip":{source:"iana",compressible:!1},"application/p2p-overlay+xml":{source:"iana",compressible:!0,extensions:["relo"]},"application/parityfec":{source:"iana"},"application/passport":{source:"iana"},"application/patch-ops-error+xml":{source:"iana",compressible:!0,extensions:["xer"]},"application/pdf":{source:"iana",compressible:!1,extensions:["pdf"]},"application/pdx":{source:"iana"},"application/pem-certificate-chain":{source:"iana"},"application/pgp-encrypted":{source:"iana",compressible:!1,extensions:["pgp"]},"application/pgp-keys":{source:"iana",extensions:["asc"]},"application/pgp-signature":{source:"iana",extensions:["asc","sig"]},"application/pics-rules":{source:"apache",extensions:["prf"]},"application/pidf+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pidf-diff+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/pkcs10":{source:"iana",extensions:["p10"]},"application/pkcs12":{source:"iana"},"application/pkcs7-mime":{source:"iana",extensions:["p7m","p7c"]},"application/pkcs7-signature":{source:"iana",extensions:["p7s"]},"application/pkcs8":{source:"iana",extensions:["p8"]},"application/pkcs8-encrypted":{source:"iana"},"application/pkix-attr-cert":{source:"iana",extensions:["ac"]},"application/pkix-cert":{source:"iana",extensions:["cer"]},"application/pkix-crl":{source:"iana",extensions:["crl"]},"application/pkix-pkipath":{source:"iana",extensions:["pkipath"]},"application/pkixcmp":{source:"iana",extensions:["pki"]},"application/pls+xml":{source:"iana",compressible:!0,extensions:["pls"]},"application/poc-settings+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/postscript":{source:"iana",compressible:!0,extensions:["ai","eps","ps"]},"application/ppsp-tracker+json":{source:"iana",compressible:!0},"application/problem+json":{source:"iana",compressible:!0},"application/problem+xml":{source:"iana",compressible:!0},"application/provenance+xml":{source:"iana",compressible:!0,extensions:["provx"]},"application/prs.alvestrand.titrax-sheet":{source:"iana"},"application/prs.cww":{source:"iana",extensions:["cww"]},"application/prs.cyn":{source:"iana",charset:"7-BIT"},"application/prs.hpub+zip":{source:"iana",compressible:!1},"application/prs.nprend":{source:"iana"},"application/prs.plucker":{source:"iana"},"application/prs.rdf-xml-crypt":{source:"iana"},"application/prs.xsf+xml":{source:"iana",compressible:!0},"application/pskc+xml":{source:"iana",compressible:!0,extensions:["pskcxml"]},"application/pvd+json":{source:"iana",compressible:!0},"application/qsig":{source:"iana"},"application/raml+yaml":{compressible:!0,extensions:["raml"]},"application/raptorfec":{source:"iana"},"application/rdap+json":{source:"iana",compressible:!0},"application/rdf+xml":{source:"iana",compressible:!0,extensions:["rdf","owl"]},"application/reginfo+xml":{source:"iana",compressible:!0,extensions:["rif"]},"application/relax-ng-compact-syntax":{source:"iana",extensions:["rnc"]},"application/remote-printing":{source:"iana"},"application/reputon+json":{source:"iana",compressible:!0},"application/resource-lists+xml":{source:"iana",compressible:!0,extensions:["rl"]},"application/resource-lists-diff+xml":{source:"iana",compressible:!0,extensions:["rld"]},"application/rfc+xml":{source:"iana",compressible:!0},"application/riscos":{source:"iana"},"application/rlmi+xml":{source:"iana",compressible:!0},"application/rls-services+xml":{source:"iana",compressible:!0,extensions:["rs"]},"application/route-apd+xml":{source:"iana",compressible:!0,extensions:["rapd"]},"application/route-s-tsid+xml":{source:"iana",compressible:!0,extensions:["sls"]},"application/route-usd+xml":{source:"iana",compressible:!0,extensions:["rusd"]},"application/rpki-ghostbusters":{source:"iana",extensions:["gbr"]},"application/rpki-manifest":{source:"iana",extensions:["mft"]},"application/rpki-publication":{source:"iana"},"application/rpki-roa":{source:"iana",extensions:["roa"]},"application/rpki-updown":{source:"iana"},"application/rsd+xml":{source:"apache",compressible:!0,extensions:["rsd"]},"application/rss+xml":{source:"apache",compressible:!0,extensions:["rss"]},"application/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"application/rtploopback":{source:"iana"},"application/rtx":{source:"iana"},"application/samlassertion+xml":{source:"iana",compressible:!0},"application/samlmetadata+xml":{source:"iana",compressible:!0},"application/sarif+json":{source:"iana",compressible:!0},"application/sarif-external-properties+json":{source:"iana",compressible:!0},"application/sbe":{source:"iana"},"application/sbml+xml":{source:"iana",compressible:!0,extensions:["sbml"]},"application/scaip+xml":{source:"iana",compressible:!0},"application/scim+json":{source:"iana",compressible:!0},"application/scvp-cv-request":{source:"iana",extensions:["scq"]},"application/scvp-cv-response":{source:"iana",extensions:["scs"]},"application/scvp-vp-request":{source:"iana",extensions:["spq"]},"application/scvp-vp-response":{source:"iana",extensions:["spp"]},"application/sdp":{source:"iana",extensions:["sdp"]},"application/secevent+jwt":{source:"iana"},"application/senml+cbor":{source:"iana"},"application/senml+json":{source:"iana",compressible:!0},"application/senml+xml":{source:"iana",compressible:!0,extensions:["senmlx"]},"application/senml-etch+cbor":{source:"iana"},"application/senml-etch+json":{source:"iana",compressible:!0},"application/senml-exi":{source:"iana"},"application/sensml+cbor":{source:"iana"},"application/sensml+json":{source:"iana",compressible:!0},"application/sensml+xml":{source:"iana",compressible:!0,extensions:["sensmlx"]},"application/sensml-exi":{source:"iana"},"application/sep+xml":{source:"iana",compressible:!0},"application/sep-exi":{source:"iana"},"application/session-info":{source:"iana"},"application/set-payment":{source:"iana"},"application/set-payment-initiation":{source:"iana",extensions:["setpay"]},"application/set-registration":{source:"iana"},"application/set-registration-initiation":{source:"iana",extensions:["setreg"]},"application/sgml":{source:"iana"},"application/sgml-open-catalog":{source:"iana"},"application/shf+xml":{source:"iana",compressible:!0,extensions:["shf"]},"application/sieve":{source:"iana",extensions:["siv","sieve"]},"application/simple-filter+xml":{source:"iana",compressible:!0},"application/simple-message-summary":{source:"iana"},"application/simplesymbolcontainer":{source:"iana"},"application/sipc":{source:"iana"},"application/slate":{source:"iana"},"application/smil":{source:"iana"},"application/smil+xml":{source:"iana",compressible:!0,extensions:["smi","smil"]},"application/smpte336m":{source:"iana"},"application/soap+fastinfoset":{source:"iana"},"application/soap+xml":{source:"iana",compressible:!0},"application/sparql-query":{source:"iana",extensions:["rq"]},"application/sparql-results+xml":{source:"iana",compressible:!0,extensions:["srx"]},"application/spdx+json":{source:"iana",compressible:!0},"application/spirits-event+xml":{source:"iana",compressible:!0},"application/sql":{source:"iana"},"application/srgs":{source:"iana",extensions:["gram"]},"application/srgs+xml":{source:"iana",compressible:!0,extensions:["grxml"]},"application/sru+xml":{source:"iana",compressible:!0,extensions:["sru"]},"application/ssdl+xml":{source:"apache",compressible:!0,extensions:["ssdl"]},"application/ssml+xml":{source:"iana",compressible:!0,extensions:["ssml"]},"application/stix+json":{source:"iana",compressible:!0},"application/swid+xml":{source:"iana",compressible:!0,extensions:["swidtag"]},"application/tamp-apex-update":{source:"iana"},"application/tamp-apex-update-confirm":{source:"iana"},"application/tamp-community-update":{source:"iana"},"application/tamp-community-update-confirm":{source:"iana"},"application/tamp-error":{source:"iana"},"application/tamp-sequence-adjust":{source:"iana"},"application/tamp-sequence-adjust-confirm":{source:"iana"},"application/tamp-status-query":{source:"iana"},"application/tamp-status-response":{source:"iana"},"application/tamp-update":{source:"iana"},"application/tamp-update-confirm":{source:"iana"},"application/tar":{compressible:!0},"application/taxii+json":{source:"iana",compressible:!0},"application/td+json":{source:"iana",compressible:!0},"application/tei+xml":{source:"iana",compressible:!0,extensions:["tei","teicorpus"]},"application/tetra_isi":{source:"iana"},"application/thraud+xml":{source:"iana",compressible:!0,extensions:["tfi"]},"application/timestamp-query":{source:"iana"},"application/timestamp-reply":{source:"iana"},"application/timestamped-data":{source:"iana",extensions:["tsd"]},"application/tlsrpt+gzip":{source:"iana"},"application/tlsrpt+json":{source:"iana",compressible:!0},"application/tnauthlist":{source:"iana"},"application/token-introspection+jwt":{source:"iana"},"application/toml":{compressible:!0,extensions:["toml"]},"application/trickle-ice-sdpfrag":{source:"iana"},"application/trig":{source:"iana",extensions:["trig"]},"application/ttml+xml":{source:"iana",compressible:!0,extensions:["ttml"]},"application/tve-trigger":{source:"iana"},"application/tzif":{source:"iana"},"application/tzif-leap":{source:"iana"},"application/ubjson":{compressible:!1,extensions:["ubj"]},"application/ulpfec":{source:"iana"},"application/urc-grpsheet+xml":{source:"iana",compressible:!0},"application/urc-ressheet+xml":{source:"iana",compressible:!0,extensions:["rsheet"]},"application/urc-targetdesc+xml":{source:"iana",compressible:!0,extensions:["td"]},"application/urc-uisocketdesc+xml":{source:"iana",compressible:!0},"application/vcard+json":{source:"iana",compressible:!0},"application/vcard+xml":{source:"iana",compressible:!0},"application/vemmi":{source:"iana"},"application/vividence.scriptfile":{source:"apache"},"application/vnd.1000minds.decision-model+xml":{source:"iana",compressible:!0,extensions:["1km"]},"application/vnd.3gpp-prose+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-prose-pc3ch+xml":{source:"iana",compressible:!0},"application/vnd.3gpp-v2x-local-service-information":{source:"iana"},"application/vnd.3gpp.5gnas":{source:"iana"},"application/vnd.3gpp.access-transfer-events+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.bsf+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gmop+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.gtpc":{source:"iana"},"application/vnd.3gpp.interworking-data":{source:"iana"},"application/vnd.3gpp.lpp":{source:"iana"},"application/vnd.3gpp.mc-signalling-ear":{source:"iana"},"application/vnd.3gpp.mcdata-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-payload":{source:"iana"},"application/vnd.3gpp.mcdata-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-signalling":{source:"iana"},"application/vnd.3gpp.mcdata-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcdata-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-floor-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-signed+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-ue-init-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcptt-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-command+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-affiliation-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-location-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-mbms-usage-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-service-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-transmission-request+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-ue-config+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mcvideo-user-profile+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.mid-call+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ngap":{source:"iana"},"application/vnd.3gpp.pfcp":{source:"iana"},"application/vnd.3gpp.pic-bw-large":{source:"iana",extensions:["plb"]},"application/vnd.3gpp.pic-bw-small":{source:"iana",extensions:["psb"]},"application/vnd.3gpp.pic-bw-var":{source:"iana",extensions:["pvb"]},"application/vnd.3gpp.s1ap":{source:"iana"},"application/vnd.3gpp.sms":{source:"iana"},"application/vnd.3gpp.sms+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-ext+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.srvcc-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.state-and-event-info+xml":{source:"iana",compressible:!0},"application/vnd.3gpp.ussd+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.bcmcsinfo+xml":{source:"iana",compressible:!0},"application/vnd.3gpp2.sms":{source:"iana"},"application/vnd.3gpp2.tcap":{source:"iana",extensions:["tcap"]},"application/vnd.3lightssoftware.imagescal":{source:"iana"},"application/vnd.3m.post-it-notes":{source:"iana",extensions:["pwn"]},"application/vnd.accpac.simply.aso":{source:"iana",extensions:["aso"]},"application/vnd.accpac.simply.imp":{source:"iana",extensions:["imp"]},"application/vnd.acucobol":{source:"iana",extensions:["acu"]},"application/vnd.acucorp":{source:"iana",extensions:["atc","acutc"]},"application/vnd.adobe.air-application-installer-package+zip":{source:"apache",compressible:!1,extensions:["air"]},"application/vnd.adobe.flash.movie":{source:"iana"},"application/vnd.adobe.formscentral.fcdt":{source:"iana",extensions:["fcdt"]},"application/vnd.adobe.fxp":{source:"iana",extensions:["fxp","fxpl"]},"application/vnd.adobe.partial-upload":{source:"iana"},"application/vnd.adobe.xdp+xml":{source:"iana",compressible:!0,extensions:["xdp"]},"application/vnd.adobe.xfdf":{source:"iana",extensions:["xfdf"]},"application/vnd.aether.imp":{source:"iana"},"application/vnd.afpc.afplinedata":{source:"iana"},"application/vnd.afpc.afplinedata-pagedef":{source:"iana"},"application/vnd.afpc.cmoca-cmresource":{source:"iana"},"application/vnd.afpc.foca-charset":{source:"iana"},"application/vnd.afpc.foca-codedfont":{source:"iana"},"application/vnd.afpc.foca-codepage":{source:"iana"},"application/vnd.afpc.modca":{source:"iana"},"application/vnd.afpc.modca-cmtable":{source:"iana"},"application/vnd.afpc.modca-formdef":{source:"iana"},"application/vnd.afpc.modca-mediummap":{source:"iana"},"application/vnd.afpc.modca-objectcontainer":{source:"iana"},"application/vnd.afpc.modca-overlay":{source:"iana"},"application/vnd.afpc.modca-pagesegment":{source:"iana"},"application/vnd.age":{source:"iana",extensions:["age"]},"application/vnd.ah-barcode":{source:"iana"},"application/vnd.ahead.space":{source:"iana",extensions:["ahead"]},"application/vnd.airzip.filesecure.azf":{source:"iana",extensions:["azf"]},"application/vnd.airzip.filesecure.azs":{source:"iana",extensions:["azs"]},"application/vnd.amadeus+json":{source:"iana",compressible:!0},"application/vnd.amazon.ebook":{source:"apache",extensions:["azw"]},"application/vnd.amazon.mobi8-ebook":{source:"iana"},"application/vnd.americandynamics.acc":{source:"iana",extensions:["acc"]},"application/vnd.amiga.ami":{source:"iana",extensions:["ami"]},"application/vnd.amundsen.maze+xml":{source:"iana",compressible:!0},"application/vnd.android.ota":{source:"iana"},"application/vnd.android.package-archive":{source:"apache",compressible:!1,extensions:["apk"]},"application/vnd.anki":{source:"iana"},"application/vnd.anser-web-certificate-issue-initiation":{source:"iana",extensions:["cii"]},"application/vnd.anser-web-funds-transfer-initiation":{source:"apache",extensions:["fti"]},"application/vnd.antix.game-component":{source:"iana",extensions:["atx"]},"application/vnd.apache.arrow.file":{source:"iana"},"application/vnd.apache.arrow.stream":{source:"iana"},"application/vnd.apache.thrift.binary":{source:"iana"},"application/vnd.apache.thrift.compact":{source:"iana"},"application/vnd.apache.thrift.json":{source:"iana"},"application/vnd.api+json":{source:"iana",compressible:!0},"application/vnd.aplextor.warrp+json":{source:"iana",compressible:!0},"application/vnd.apothekende.reservation+json":{source:"iana",compressible:!0},"application/vnd.apple.installer+xml":{source:"iana",compressible:!0,extensions:["mpkg"]},"application/vnd.apple.keynote":{source:"iana",extensions:["key"]},"application/vnd.apple.mpegurl":{source:"iana",extensions:["m3u8"]},"application/vnd.apple.numbers":{source:"iana",extensions:["numbers"]},"application/vnd.apple.pages":{source:"iana",extensions:["pages"]},"application/vnd.apple.pkpass":{compressible:!1,extensions:["pkpass"]},"application/vnd.arastra.swi":{source:"iana"},"application/vnd.aristanetworks.swi":{source:"iana",extensions:["swi"]},"application/vnd.artisan+json":{source:"iana",compressible:!0},"application/vnd.artsquare":{source:"iana"},"application/vnd.astraea-software.iota":{source:"iana",extensions:["iota"]},"application/vnd.audiograph":{source:"iana",extensions:["aep"]},"application/vnd.autopackage":{source:"iana"},"application/vnd.avalon+json":{source:"iana",compressible:!0},"application/vnd.avistar+xml":{source:"iana",compressible:!0},"application/vnd.balsamiq.bmml+xml":{source:"iana",compressible:!0,extensions:["bmml"]},"application/vnd.balsamiq.bmpr":{source:"iana"},"application/vnd.banana-accounting":{source:"iana"},"application/vnd.bbf.usp.error":{source:"iana"},"application/vnd.bbf.usp.msg":{source:"iana"},"application/vnd.bbf.usp.msg+json":{source:"iana",compressible:!0},"application/vnd.bekitzur-stech+json":{source:"iana",compressible:!0},"application/vnd.bint.med-content":{source:"iana"},"application/vnd.biopax.rdf+xml":{source:"iana",compressible:!0},"application/vnd.blink-idb-value-wrapper":{source:"iana"},"application/vnd.blueice.multipass":{source:"iana",extensions:["mpm"]},"application/vnd.bluetooth.ep.oob":{source:"iana"},"application/vnd.bluetooth.le.oob":{source:"iana"},"application/vnd.bmi":{source:"iana",extensions:["bmi"]},"application/vnd.bpf":{source:"iana"},"application/vnd.bpf3":{source:"iana"},"application/vnd.businessobjects":{source:"iana",extensions:["rep"]},"application/vnd.byu.uapi+json":{source:"iana",compressible:!0},"application/vnd.cab-jscript":{source:"iana"},"application/vnd.canon-cpdl":{source:"iana"},"application/vnd.canon-lips":{source:"iana"},"application/vnd.capasystems-pg+json":{source:"iana",compressible:!0},"application/vnd.cendio.thinlinc.clientconf":{source:"iana"},"application/vnd.century-systems.tcp_stream":{source:"iana"},"application/vnd.chemdraw+xml":{source:"iana",compressible:!0,extensions:["cdxml"]},"application/vnd.chess-pgn":{source:"iana"},"application/vnd.chipnuts.karaoke-mmd":{source:"iana",extensions:["mmd"]},"application/vnd.ciedi":{source:"iana"},"application/vnd.cinderella":{source:"iana",extensions:["cdy"]},"application/vnd.cirpack.isdn-ext":{source:"iana"},"application/vnd.citationstyles.style+xml":{source:"iana",compressible:!0,extensions:["csl"]},"application/vnd.claymore":{source:"iana",extensions:["cla"]},"application/vnd.cloanto.rp9":{source:"iana",extensions:["rp9"]},"application/vnd.clonk.c4group":{source:"iana",extensions:["c4g","c4d","c4f","c4p","c4u"]},"application/vnd.cluetrust.cartomobile-config":{source:"iana",extensions:["c11amc"]},"application/vnd.cluetrust.cartomobile-config-pkg":{source:"iana",extensions:["c11amz"]},"application/vnd.coffeescript":{source:"iana"},"application/vnd.collabio.xodocuments.document":{source:"iana"},"application/vnd.collabio.xodocuments.document-template":{source:"iana"},"application/vnd.collabio.xodocuments.presentation":{source:"iana"},"application/vnd.collabio.xodocuments.presentation-template":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet":{source:"iana"},"application/vnd.collabio.xodocuments.spreadsheet-template":{source:"iana"},"application/vnd.collection+json":{source:"iana",compressible:!0},"application/vnd.collection.doc+json":{source:"iana",compressible:!0},"application/vnd.collection.next+json":{source:"iana",compressible:!0},"application/vnd.comicbook+zip":{source:"iana",compressible:!1},"application/vnd.comicbook-rar":{source:"iana"},"application/vnd.commerce-battelle":{source:"iana"},"application/vnd.commonspace":{source:"iana",extensions:["csp"]},"application/vnd.contact.cmsg":{source:"iana",extensions:["cdbcmsg"]},"application/vnd.coreos.ignition+json":{source:"iana",compressible:!0},"application/vnd.cosmocaller":{source:"iana",extensions:["cmc"]},"application/vnd.crick.clicker":{source:"iana",extensions:["clkx"]},"application/vnd.crick.clicker.keyboard":{source:"iana",extensions:["clkk"]},"application/vnd.crick.clicker.palette":{source:"iana",extensions:["clkp"]},"application/vnd.crick.clicker.template":{source:"iana",extensions:["clkt"]},"application/vnd.crick.clicker.wordbank":{source:"iana",extensions:["clkw"]},"application/vnd.criticaltools.wbs+xml":{source:"iana",compressible:!0,extensions:["wbs"]},"application/vnd.cryptii.pipe+json":{source:"iana",compressible:!0},"application/vnd.crypto-shade-file":{source:"iana"},"application/vnd.cryptomator.encrypted":{source:"iana"},"application/vnd.cryptomator.vault":{source:"iana"},"application/vnd.ctc-posml":{source:"iana",extensions:["pml"]},"application/vnd.ctct.ws+xml":{source:"iana",compressible:!0},"application/vnd.cups-pdf":{source:"iana"},"application/vnd.cups-postscript":{source:"iana"},"application/vnd.cups-ppd":{source:"iana",extensions:["ppd"]},"application/vnd.cups-raster":{source:"iana"},"application/vnd.cups-raw":{source:"iana"},"application/vnd.curl":{source:"iana"},"application/vnd.curl.car":{source:"apache",extensions:["car"]},"application/vnd.curl.pcurl":{source:"apache",extensions:["pcurl"]},"application/vnd.cyan.dean.root+xml":{source:"iana",compressible:!0},"application/vnd.cybank":{source:"iana"},"application/vnd.cyclonedx+json":{source:"iana",compressible:!0},"application/vnd.cyclonedx+xml":{source:"iana",compressible:!0},"application/vnd.d2l.coursepackage1p0+zip":{source:"iana",compressible:!1},"application/vnd.d3m-dataset":{source:"iana"},"application/vnd.d3m-problem":{source:"iana"},"application/vnd.dart":{source:"iana",compressible:!0,extensions:["dart"]},"application/vnd.data-vision.rdz":{source:"iana",extensions:["rdz"]},"application/vnd.datapackage+json":{source:"iana",compressible:!0},"application/vnd.dataresource+json":{source:"iana",compressible:!0},"application/vnd.dbf":{source:"iana",extensions:["dbf"]},"application/vnd.debian.binary-package":{source:"iana"},"application/vnd.dece.data":{source:"iana",extensions:["uvf","uvvf","uvd","uvvd"]},"application/vnd.dece.ttml+xml":{source:"iana",compressible:!0,extensions:["uvt","uvvt"]},"application/vnd.dece.unspecified":{source:"iana",extensions:["uvx","uvvx"]},"application/vnd.dece.zip":{source:"iana",extensions:["uvz","uvvz"]},"application/vnd.denovo.fcselayout-link":{source:"iana",extensions:["fe_launch"]},"application/vnd.desmume.movie":{source:"iana"},"application/vnd.dir-bi.plate-dl-nosuffix":{source:"iana"},"application/vnd.dm.delegation+xml":{source:"iana",compressible:!0},"application/vnd.dna":{source:"iana",extensions:["dna"]},"application/vnd.document+json":{source:"iana",compressible:!0},"application/vnd.dolby.mlp":{source:"apache",extensions:["mlp"]},"application/vnd.dolby.mobile.1":{source:"iana"},"application/vnd.dolby.mobile.2":{source:"iana"},"application/vnd.doremir.scorecloud-binary-document":{source:"iana"},"application/vnd.dpgraph":{source:"iana",extensions:["dpg"]},"application/vnd.dreamfactory":{source:"iana",extensions:["dfac"]},"application/vnd.drive+json":{source:"iana",compressible:!0},"application/vnd.ds-keypoint":{source:"apache",extensions:["kpxx"]},"application/vnd.dtg.local":{source:"iana"},"application/vnd.dtg.local.flash":{source:"iana"},"application/vnd.dtg.local.html":{source:"iana"},"application/vnd.dvb.ait":{source:"iana",extensions:["ait"]},"application/vnd.dvb.dvbisl+xml":{source:"iana",compressible:!0},"application/vnd.dvb.dvbj":{source:"iana"},"application/vnd.dvb.esgcontainer":{source:"iana"},"application/vnd.dvb.ipdcdftnotifaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess":{source:"iana"},"application/vnd.dvb.ipdcesgaccess2":{source:"iana"},"application/vnd.dvb.ipdcesgpdd":{source:"iana"},"application/vnd.dvb.ipdcroaming":{source:"iana"},"application/vnd.dvb.iptv.alfec-base":{source:"iana"},"application/vnd.dvb.iptv.alfec-enhancement":{source:"iana"},"application/vnd.dvb.notif-aggregate-root+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-container+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-generic+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-msglist+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-request+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-ia-registration-response+xml":{source:"iana",compressible:!0},"application/vnd.dvb.notif-init+xml":{source:"iana",compressible:!0},"application/vnd.dvb.pfr":{source:"iana"},"application/vnd.dvb.service":{source:"iana",extensions:["svc"]},"application/vnd.dxr":{source:"iana"},"application/vnd.dynageo":{source:"iana",extensions:["geo"]},"application/vnd.dzr":{source:"iana"},"application/vnd.easykaraoke.cdgdownload":{source:"iana"},"application/vnd.ecdis-update":{source:"iana"},"application/vnd.ecip.rlp":{source:"iana"},"application/vnd.eclipse.ditto+json":{source:"iana",compressible:!0},"application/vnd.ecowin.chart":{source:"iana",extensions:["mag"]},"application/vnd.ecowin.filerequest":{source:"iana"},"application/vnd.ecowin.fileupdate":{source:"iana"},"application/vnd.ecowin.series":{source:"iana"},"application/vnd.ecowin.seriesrequest":{source:"iana"},"application/vnd.ecowin.seriesupdate":{source:"iana"},"application/vnd.efi.img":{source:"iana"},"application/vnd.efi.iso":{source:"iana"},"application/vnd.emclient.accessrequest+xml":{source:"iana",compressible:!0},"application/vnd.enliven":{source:"iana",extensions:["nml"]},"application/vnd.enphase.envoy":{source:"iana"},"application/vnd.eprints.data+xml":{source:"iana",compressible:!0},"application/vnd.epson.esf":{source:"iana",extensions:["esf"]},"application/vnd.epson.msf":{source:"iana",extensions:["msf"]},"application/vnd.epson.quickanime":{source:"iana",extensions:["qam"]},"application/vnd.epson.salt":{source:"iana",extensions:["slt"]},"application/vnd.epson.ssf":{source:"iana",extensions:["ssf"]},"application/vnd.ericsson.quickcall":{source:"iana"},"application/vnd.espass-espass+zip":{source:"iana",compressible:!1},"application/vnd.eszigno3+xml":{source:"iana",compressible:!0,extensions:["es3","et3"]},"application/vnd.etsi.aoc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.asic-e+zip":{source:"iana",compressible:!1},"application/vnd.etsi.asic-s+zip":{source:"iana",compressible:!1},"application/vnd.etsi.cug+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvcommand+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-bc+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-cod+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsad-npvr+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvservice+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvsync+xml":{source:"iana",compressible:!0},"application/vnd.etsi.iptvueprofile+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mcid+xml":{source:"iana",compressible:!0},"application/vnd.etsi.mheg5":{source:"iana"},"application/vnd.etsi.overload-control-policy-dataset+xml":{source:"iana",compressible:!0},"application/vnd.etsi.pstn+xml":{source:"iana",compressible:!0},"application/vnd.etsi.sci+xml":{source:"iana",compressible:!0},"application/vnd.etsi.simservs+xml":{source:"iana",compressible:!0},"application/vnd.etsi.timestamp-token":{source:"iana"},"application/vnd.etsi.tsl+xml":{source:"iana",compressible:!0},"application/vnd.etsi.tsl.der":{source:"iana"},"application/vnd.eu.kasparian.car+json":{source:"iana",compressible:!0},"application/vnd.eudora.data":{source:"iana"},"application/vnd.evolv.ecig.profile":{source:"iana"},"application/vnd.evolv.ecig.settings":{source:"iana"},"application/vnd.evolv.ecig.theme":{source:"iana"},"application/vnd.exstream-empower+zip":{source:"iana",compressible:!1},"application/vnd.exstream-package":{source:"iana"},"application/vnd.ezpix-album":{source:"iana",extensions:["ez2"]},"application/vnd.ezpix-package":{source:"iana",extensions:["ez3"]},"application/vnd.f-secure.mobile":{source:"iana"},"application/vnd.familysearch.gedcom+zip":{source:"iana",compressible:!1},"application/vnd.fastcopy-disk-image":{source:"iana"},"application/vnd.fdf":{source:"iana",extensions:["fdf"]},"application/vnd.fdsn.mseed":{source:"iana",extensions:["mseed"]},"application/vnd.fdsn.seed":{source:"iana",extensions:["seed","dataless"]},"application/vnd.ffsns":{source:"iana"},"application/vnd.ficlab.flb+zip":{source:"iana",compressible:!1},"application/vnd.filmit.zfc":{source:"iana"},"application/vnd.fints":{source:"iana"},"application/vnd.firemonkeys.cloudcell":{source:"iana"},"application/vnd.flographit":{source:"iana",extensions:["gph"]},"application/vnd.fluxtime.clip":{source:"iana",extensions:["ftc"]},"application/vnd.font-fontforge-sfd":{source:"iana"},"application/vnd.framemaker":{source:"iana",extensions:["fm","frame","maker","book"]},"application/vnd.frogans.fnc":{source:"iana",extensions:["fnc"]},"application/vnd.frogans.ltf":{source:"iana",extensions:["ltf"]},"application/vnd.fsc.weblaunch":{source:"iana",extensions:["fsc"]},"application/vnd.fujifilm.fb.docuworks":{source:"iana"},"application/vnd.fujifilm.fb.docuworks.binder":{source:"iana"},"application/vnd.fujifilm.fb.docuworks.container":{source:"iana"},"application/vnd.fujifilm.fb.jfi+xml":{source:"iana",compressible:!0},"application/vnd.fujitsu.oasys":{source:"iana",extensions:["oas"]},"application/vnd.fujitsu.oasys2":{source:"iana",extensions:["oa2"]},"application/vnd.fujitsu.oasys3":{source:"iana",extensions:["oa3"]},"application/vnd.fujitsu.oasysgp":{source:"iana",extensions:["fg5"]},"application/vnd.fujitsu.oasysprs":{source:"iana",extensions:["bh2"]},"application/vnd.fujixerox.art-ex":{source:"iana"},"application/vnd.fujixerox.art4":{source:"iana"},"application/vnd.fujixerox.ddd":{source:"iana",extensions:["ddd"]},"application/vnd.fujixerox.docuworks":{source:"iana",extensions:["xdw"]},"application/vnd.fujixerox.docuworks.binder":{source:"iana",extensions:["xbd"]},"application/vnd.fujixerox.docuworks.container":{source:"iana"},"application/vnd.fujixerox.hbpl":{source:"iana"},"application/vnd.fut-misnet":{source:"iana"},"application/vnd.futoin+cbor":{source:"iana"},"application/vnd.futoin+json":{source:"iana",compressible:!0},"application/vnd.fuzzysheet":{source:"iana",extensions:["fzs"]},"application/vnd.genomatix.tuxedo":{source:"iana",extensions:["txd"]},"application/vnd.gentics.grd+json":{source:"iana",compressible:!0},"application/vnd.geo+json":{source:"iana",compressible:!0},"application/vnd.geocube+xml":{source:"iana",compressible:!0},"application/vnd.geogebra.file":{source:"iana",extensions:["ggb"]},"application/vnd.geogebra.slides":{source:"iana"},"application/vnd.geogebra.tool":{source:"iana",extensions:["ggt"]},"application/vnd.geometry-explorer":{source:"iana",extensions:["gex","gre"]},"application/vnd.geonext":{source:"iana",extensions:["gxt"]},"application/vnd.geoplan":{source:"iana",extensions:["g2w"]},"application/vnd.geospace":{source:"iana",extensions:["g3w"]},"application/vnd.gerber":{source:"iana"},"application/vnd.globalplatform.card-content-mgt":{source:"iana"},"application/vnd.globalplatform.card-content-mgt-response":{source:"iana"},"application/vnd.gmx":{source:"iana",extensions:["gmx"]},"application/vnd.google-apps.document":{compressible:!1,extensions:["gdoc"]},"application/vnd.google-apps.presentation":{compressible:!1,extensions:["gslides"]},"application/vnd.google-apps.spreadsheet":{compressible:!1,extensions:["gsheet"]},"application/vnd.google-earth.kml+xml":{source:"iana",compressible:!0,extensions:["kml"]},"application/vnd.google-earth.kmz":{source:"iana",compressible:!1,extensions:["kmz"]},"application/vnd.gov.sk.e-form+xml":{source:"iana",compressible:!0},"application/vnd.gov.sk.e-form+zip":{source:"iana",compressible:!1},"application/vnd.gov.sk.xmldatacontainer+xml":{source:"iana",compressible:!0},"application/vnd.grafeq":{source:"iana",extensions:["gqf","gqs"]},"application/vnd.gridmp":{source:"iana"},"application/vnd.groove-account":{source:"iana",extensions:["gac"]},"application/vnd.groove-help":{source:"iana",extensions:["ghf"]},"application/vnd.groove-identity-message":{source:"iana",extensions:["gim"]},"application/vnd.groove-injector":{source:"iana",extensions:["grv"]},"application/vnd.groove-tool-message":{source:"iana",extensions:["gtm"]},"application/vnd.groove-tool-template":{source:"iana",extensions:["tpl"]},"application/vnd.groove-vcard":{source:"iana",extensions:["vcg"]},"application/vnd.hal+json":{source:"iana",compressible:!0},"application/vnd.hal+xml":{source:"iana",compressible:!0,extensions:["hal"]},"application/vnd.handheld-entertainment+xml":{source:"iana",compressible:!0,extensions:["zmm"]},"application/vnd.hbci":{source:"iana",extensions:["hbci"]},"application/vnd.hc+json":{source:"iana",compressible:!0},"application/vnd.hcl-bireports":{source:"iana"},"application/vnd.hdt":{source:"iana"},"application/vnd.heroku+json":{source:"iana",compressible:!0},"application/vnd.hhe.lesson-player":{source:"iana",extensions:["les"]},"application/vnd.hl7cda+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.hl7v2+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.hp-hpgl":{source:"iana",extensions:["hpgl"]},"application/vnd.hp-hpid":{source:"iana",extensions:["hpid"]},"application/vnd.hp-hps":{source:"iana",extensions:["hps"]},"application/vnd.hp-jlyt":{source:"iana",extensions:["jlt"]},"application/vnd.hp-pcl":{source:"iana",extensions:["pcl"]},"application/vnd.hp-pclxl":{source:"iana",extensions:["pclxl"]},"application/vnd.httphone":{source:"iana"},"application/vnd.hydrostatix.sof-data":{source:"iana",extensions:["sfd-hdstx"]},"application/vnd.hyper+json":{source:"iana",compressible:!0},"application/vnd.hyper-item+json":{source:"iana",compressible:!0},"application/vnd.hyperdrive+json":{source:"iana",compressible:!0},"application/vnd.hzn-3d-crossword":{source:"iana"},"application/vnd.ibm.afplinedata":{source:"iana"},"application/vnd.ibm.electronic-media":{source:"iana"},"application/vnd.ibm.minipay":{source:"iana",extensions:["mpy"]},"application/vnd.ibm.modcap":{source:"iana",extensions:["afp","listafp","list3820"]},"application/vnd.ibm.rights-management":{source:"iana",extensions:["irm"]},"application/vnd.ibm.secure-container":{source:"iana",extensions:["sc"]},"application/vnd.iccprofile":{source:"iana",extensions:["icc","icm"]},"application/vnd.ieee.1905":{source:"iana"},"application/vnd.igloader":{source:"iana",extensions:["igl"]},"application/vnd.imagemeter.folder+zip":{source:"iana",compressible:!1},"application/vnd.imagemeter.image+zip":{source:"iana",compressible:!1},"application/vnd.immervision-ivp":{source:"iana",extensions:["ivp"]},"application/vnd.immervision-ivu":{source:"iana",extensions:["ivu"]},"application/vnd.ims.imsccv1p1":{source:"iana"},"application/vnd.ims.imsccv1p2":{source:"iana"},"application/vnd.ims.imsccv1p3":{source:"iana"},"application/vnd.ims.lis.v2.result+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolconsumerprofile+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolproxy.id+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings+json":{source:"iana",compressible:!0},"application/vnd.ims.lti.v2.toolsettings.simple+json":{source:"iana",compressible:!0},"application/vnd.informedcontrol.rms+xml":{source:"iana",compressible:!0},"application/vnd.informix-visionary":{source:"iana"},"application/vnd.infotech.project":{source:"iana"},"application/vnd.infotech.project+xml":{source:"iana",compressible:!0},"application/vnd.innopath.wamp.notification":{source:"iana"},"application/vnd.insors.igm":{source:"iana",extensions:["igm"]},"application/vnd.intercon.formnet":{source:"iana",extensions:["xpw","xpx"]},"application/vnd.intergeo":{source:"iana",extensions:["i2g"]},"application/vnd.intertrust.digibox":{source:"iana"},"application/vnd.intertrust.nncp":{source:"iana"},"application/vnd.intu.qbo":{source:"iana",extensions:["qbo"]},"application/vnd.intu.qfx":{source:"iana",extensions:["qfx"]},"application/vnd.iptc.g2.catalogitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.conceptitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.knowledgeitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.newsmessage+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.packageitem+xml":{source:"iana",compressible:!0},"application/vnd.iptc.g2.planningitem+xml":{source:"iana",compressible:!0},"application/vnd.ipunplugged.rcprofile":{source:"iana",extensions:["rcprofile"]},"application/vnd.irepository.package+xml":{source:"iana",compressible:!0,extensions:["irp"]},"application/vnd.is-xpr":{source:"iana",extensions:["xpr"]},"application/vnd.isac.fcs":{source:"iana",extensions:["fcs"]},"application/vnd.iso11783-10+zip":{source:"iana",compressible:!1},"application/vnd.jam":{source:"iana",extensions:["jam"]},"application/vnd.japannet-directory-service":{source:"iana"},"application/vnd.japannet-jpnstore-wakeup":{source:"iana"},"application/vnd.japannet-payment-wakeup":{source:"iana"},"application/vnd.japannet-registration":{source:"iana"},"application/vnd.japannet-registration-wakeup":{source:"iana"},"application/vnd.japannet-setstore-wakeup":{source:"iana"},"application/vnd.japannet-verification":{source:"iana"},"application/vnd.japannet-verification-wakeup":{source:"iana"},"application/vnd.jcp.javame.midlet-rms":{source:"iana",extensions:["rms"]},"application/vnd.jisp":{source:"iana",extensions:["jisp"]},"application/vnd.joost.joda-archive":{source:"iana",extensions:["joda"]},"application/vnd.jsk.isdn-ngn":{source:"iana"},"application/vnd.kahootz":{source:"iana",extensions:["ktz","ktr"]},"application/vnd.kde.karbon":{source:"iana",extensions:["karbon"]},"application/vnd.kde.kchart":{source:"iana",extensions:["chrt"]},"application/vnd.kde.kformula":{source:"iana",extensions:["kfo"]},"application/vnd.kde.kivio":{source:"iana",extensions:["flw"]},"application/vnd.kde.kontour":{source:"iana",extensions:["kon"]},"application/vnd.kde.kpresenter":{source:"iana",extensions:["kpr","kpt"]},"application/vnd.kde.kspread":{source:"iana",extensions:["ksp"]},"application/vnd.kde.kword":{source:"iana",extensions:["kwd","kwt"]},"application/vnd.kenameaapp":{source:"iana",extensions:["htke"]},"application/vnd.kidspiration":{source:"iana",extensions:["kia"]},"application/vnd.kinar":{source:"iana",extensions:["kne","knp"]},"application/vnd.koan":{source:"iana",extensions:["skp","skd","skt","skm"]},"application/vnd.kodak-descriptor":{source:"iana",extensions:["sse"]},"application/vnd.las":{source:"iana"},"application/vnd.las.las+json":{source:"iana",compressible:!0},"application/vnd.las.las+xml":{source:"iana",compressible:!0,extensions:["lasxml"]},"application/vnd.laszip":{source:"iana"},"application/vnd.leap+json":{source:"iana",compressible:!0},"application/vnd.liberty-request+xml":{source:"iana",compressible:!0},"application/vnd.llamagraphics.life-balance.desktop":{source:"iana",extensions:["lbd"]},"application/vnd.llamagraphics.life-balance.exchange+xml":{source:"iana",compressible:!0,extensions:["lbe"]},"application/vnd.logipipe.circuit+zip":{source:"iana",compressible:!1},"application/vnd.loom":{source:"iana"},"application/vnd.lotus-1-2-3":{source:"iana",extensions:["123"]},"application/vnd.lotus-approach":{source:"iana",extensions:["apr"]},"application/vnd.lotus-freelance":{source:"iana",extensions:["pre"]},"application/vnd.lotus-notes":{source:"iana",extensions:["nsf"]},"application/vnd.lotus-organizer":{source:"iana",extensions:["org"]},"application/vnd.lotus-screencam":{source:"iana",extensions:["scm"]},"application/vnd.lotus-wordpro":{source:"iana",extensions:["lwp"]},"application/vnd.macports.portpkg":{source:"iana",extensions:["portpkg"]},"application/vnd.mapbox-vector-tile":{source:"iana",extensions:["mvt"]},"application/vnd.marlin.drm.actiontoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.conftoken+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.license+xml":{source:"iana",compressible:!0},"application/vnd.marlin.drm.mdcf":{source:"iana"},"application/vnd.mason+json":{source:"iana",compressible:!0},"application/vnd.maxar.archive.3tz+zip":{source:"iana",compressible:!1},"application/vnd.maxmind.maxmind-db":{source:"iana"},"application/vnd.mcd":{source:"iana",extensions:["mcd"]},"application/vnd.medcalcdata":{source:"iana",extensions:["mc1"]},"application/vnd.mediastation.cdkey":{source:"iana",extensions:["cdkey"]},"application/vnd.meridian-slingshot":{source:"iana"},"application/vnd.mfer":{source:"iana",extensions:["mwf"]},"application/vnd.mfmp":{source:"iana",extensions:["mfm"]},"application/vnd.micro+json":{source:"iana",compressible:!0},"application/vnd.micrografx.flo":{source:"iana",extensions:["flo"]},"application/vnd.micrografx.igx":{source:"iana",extensions:["igx"]},"application/vnd.microsoft.portable-executable":{source:"iana"},"application/vnd.microsoft.windows.thumbnail-cache":{source:"iana"},"application/vnd.miele+json":{source:"iana",compressible:!0},"application/vnd.mif":{source:"iana",extensions:["mif"]},"application/vnd.minisoft-hp3000-save":{source:"iana"},"application/vnd.mitsubishi.misty-guard.trustweb":{source:"iana"},"application/vnd.mobius.daf":{source:"iana",extensions:["daf"]},"application/vnd.mobius.dis":{source:"iana",extensions:["dis"]},"application/vnd.mobius.mbk":{source:"iana",extensions:["mbk"]},"application/vnd.mobius.mqy":{source:"iana",extensions:["mqy"]},"application/vnd.mobius.msl":{source:"iana",extensions:["msl"]},"application/vnd.mobius.plc":{source:"iana",extensions:["plc"]},"application/vnd.mobius.txf":{source:"iana",extensions:["txf"]},"application/vnd.mophun.application":{source:"iana",extensions:["mpn"]},"application/vnd.mophun.certificate":{source:"iana",extensions:["mpc"]},"application/vnd.motorola.flexsuite":{source:"iana"},"application/vnd.motorola.flexsuite.adsi":{source:"iana"},"application/vnd.motorola.flexsuite.fis":{source:"iana"},"application/vnd.motorola.flexsuite.gotap":{source:"iana"},"application/vnd.motorola.flexsuite.kmr":{source:"iana"},"application/vnd.motorola.flexsuite.ttc":{source:"iana"},"application/vnd.motorola.flexsuite.wem":{source:"iana"},"application/vnd.motorola.iprm":{source:"iana"},"application/vnd.mozilla.xul+xml":{source:"iana",compressible:!0,extensions:["xul"]},"application/vnd.ms-3mfdocument":{source:"iana"},"application/vnd.ms-artgalry":{source:"iana",extensions:["cil"]},"application/vnd.ms-asf":{source:"iana"},"application/vnd.ms-cab-compressed":{source:"iana",extensions:["cab"]},"application/vnd.ms-color.iccprofile":{source:"apache"},"application/vnd.ms-excel":{source:"iana",compressible:!1,extensions:["xls","xlm","xla","xlc","xlt","xlw"]},"application/vnd.ms-excel.addin.macroenabled.12":{source:"iana",extensions:["xlam"]},"application/vnd.ms-excel.sheet.binary.macroenabled.12":{source:"iana",extensions:["xlsb"]},"application/vnd.ms-excel.sheet.macroenabled.12":{source:"iana",extensions:["xlsm"]},"application/vnd.ms-excel.template.macroenabled.12":{source:"iana",extensions:["xltm"]},"application/vnd.ms-fontobject":{source:"iana",compressible:!0,extensions:["eot"]},"application/vnd.ms-htmlhelp":{source:"iana",extensions:["chm"]},"application/vnd.ms-ims":{source:"iana",extensions:["ims"]},"application/vnd.ms-lrm":{source:"iana",extensions:["lrm"]},"application/vnd.ms-office.activex+xml":{source:"iana",compressible:!0},"application/vnd.ms-officetheme":{source:"iana",extensions:["thmx"]},"application/vnd.ms-opentype":{source:"apache",compressible:!0},"application/vnd.ms-outlook":{compressible:!1,extensions:["msg"]},"application/vnd.ms-package.obfuscated-opentype":{source:"apache"},"application/vnd.ms-pki.seccat":{source:"apache",extensions:["cat"]},"application/vnd.ms-pki.stl":{source:"apache",extensions:["stl"]},"application/vnd.ms-playready.initiator+xml":{source:"iana",compressible:!0},"application/vnd.ms-powerpoint":{source:"iana",compressible:!1,extensions:["ppt","pps","pot"]},"application/vnd.ms-powerpoint.addin.macroenabled.12":{source:"iana",extensions:["ppam"]},"application/vnd.ms-powerpoint.presentation.macroenabled.12":{source:"iana",extensions:["pptm"]},"application/vnd.ms-powerpoint.slide.macroenabled.12":{source:"iana",extensions:["sldm"]},"application/vnd.ms-powerpoint.slideshow.macroenabled.12":{source:"iana",extensions:["ppsm"]},"application/vnd.ms-powerpoint.template.macroenabled.12":{source:"iana",extensions:["potm"]},"application/vnd.ms-printdevicecapabilities+xml":{source:"iana",compressible:!0},"application/vnd.ms-printing.printticket+xml":{source:"apache",compressible:!0},"application/vnd.ms-printschematicket+xml":{source:"iana",compressible:!0},"application/vnd.ms-project":{source:"iana",extensions:["mpp","mpt"]},"application/vnd.ms-tnef":{source:"iana"},"application/vnd.ms-windows.devicepairing":{source:"iana"},"application/vnd.ms-windows.nwprinting.oob":{source:"iana"},"application/vnd.ms-windows.printerpairing":{source:"iana"},"application/vnd.ms-windows.wsd.oob":{source:"iana"},"application/vnd.ms-wmdrm.lic-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.lic-resp":{source:"iana"},"application/vnd.ms-wmdrm.meter-chlg-req":{source:"iana"},"application/vnd.ms-wmdrm.meter-resp":{source:"iana"},"application/vnd.ms-word.document.macroenabled.12":{source:"iana",extensions:["docm"]},"application/vnd.ms-word.template.macroenabled.12":{source:"iana",extensions:["dotm"]},"application/vnd.ms-works":{source:"iana",extensions:["wps","wks","wcm","wdb"]},"application/vnd.ms-wpl":{source:"iana",extensions:["wpl"]},"application/vnd.ms-xpsdocument":{source:"iana",compressible:!1,extensions:["xps"]},"application/vnd.msa-disk-image":{source:"iana"},"application/vnd.mseq":{source:"iana",extensions:["mseq"]},"application/vnd.msign":{source:"iana"},"application/vnd.multiad.creator":{source:"iana"},"application/vnd.multiad.creator.cif":{source:"iana"},"application/vnd.music-niff":{source:"iana"},"application/vnd.musician":{source:"iana",extensions:["mus"]},"application/vnd.muvee.style":{source:"iana",extensions:["msty"]},"application/vnd.mynfc":{source:"iana",extensions:["taglet"]},"application/vnd.nacamar.ybrid+json":{source:"iana",compressible:!0},"application/vnd.ncd.control":{source:"iana"},"application/vnd.ncd.reference":{source:"iana"},"application/vnd.nearst.inv+json":{source:"iana",compressible:!0},"application/vnd.nebumind.line":{source:"iana"},"application/vnd.nervana":{source:"iana"},"application/vnd.netfpx":{source:"iana"},"application/vnd.neurolanguage.nlu":{source:"iana",extensions:["nlu"]},"application/vnd.nimn":{source:"iana"},"application/vnd.nintendo.nitro.rom":{source:"iana"},"application/vnd.nintendo.snes.rom":{source:"iana"},"application/vnd.nitf":{source:"iana",extensions:["ntf","nitf"]},"application/vnd.noblenet-directory":{source:"iana",extensions:["nnd"]},"application/vnd.noblenet-sealer":{source:"iana",extensions:["nns"]},"application/vnd.noblenet-web":{source:"iana",extensions:["nnw"]},"application/vnd.nokia.catalogs":{source:"iana"},"application/vnd.nokia.conml+wbxml":{source:"iana"},"application/vnd.nokia.conml+xml":{source:"iana",compressible:!0},"application/vnd.nokia.iptv.config+xml":{source:"iana",compressible:!0},"application/vnd.nokia.isds-radio-presets":{source:"iana"},"application/vnd.nokia.landmark+wbxml":{source:"iana"},"application/vnd.nokia.landmark+xml":{source:"iana",compressible:!0},"application/vnd.nokia.landmarkcollection+xml":{source:"iana",compressible:!0},"application/vnd.nokia.n-gage.ac+xml":{source:"iana",compressible:!0,extensions:["ac"]},"application/vnd.nokia.n-gage.data":{source:"iana",extensions:["ngdat"]},"application/vnd.nokia.n-gage.symbian.install":{source:"iana",extensions:["n-gage"]},"application/vnd.nokia.ncd":{source:"iana"},"application/vnd.nokia.pcd+wbxml":{source:"iana"},"application/vnd.nokia.pcd+xml":{source:"iana",compressible:!0},"application/vnd.nokia.radio-preset":{source:"iana",extensions:["rpst"]},"application/vnd.nokia.radio-presets":{source:"iana",extensions:["rpss"]},"application/vnd.novadigm.edm":{source:"iana",extensions:["edm"]},"application/vnd.novadigm.edx":{source:"iana",extensions:["edx"]},"application/vnd.novadigm.ext":{source:"iana",extensions:["ext"]},"application/vnd.ntt-local.content-share":{source:"iana"},"application/vnd.ntt-local.file-transfer":{source:"iana"},"application/vnd.ntt-local.ogw_remote-access":{source:"iana"},"application/vnd.ntt-local.sip-ta_remote":{source:"iana"},"application/vnd.ntt-local.sip-ta_tcp_stream":{source:"iana"},"application/vnd.oasis.opendocument.chart":{source:"iana",extensions:["odc"]},"application/vnd.oasis.opendocument.chart-template":{source:"iana",extensions:["otc"]},"application/vnd.oasis.opendocument.database":{source:"iana",extensions:["odb"]},"application/vnd.oasis.opendocument.formula":{source:"iana",extensions:["odf"]},"application/vnd.oasis.opendocument.formula-template":{source:"iana",extensions:["odft"]},"application/vnd.oasis.opendocument.graphics":{source:"iana",compressible:!1,extensions:["odg"]},"application/vnd.oasis.opendocument.graphics-template":{source:"iana",extensions:["otg"]},"application/vnd.oasis.opendocument.image":{source:"iana",extensions:["odi"]},"application/vnd.oasis.opendocument.image-template":{source:"iana",extensions:["oti"]},"application/vnd.oasis.opendocument.presentation":{source:"iana",compressible:!1,extensions:["odp"]},"application/vnd.oasis.opendocument.presentation-template":{source:"iana",extensions:["otp"]},"application/vnd.oasis.opendocument.spreadsheet":{source:"iana",compressible:!1,extensions:["ods"]},"application/vnd.oasis.opendocument.spreadsheet-template":{source:"iana",extensions:["ots"]},"application/vnd.oasis.opendocument.text":{source:"iana",compressible:!1,extensions:["odt"]},"application/vnd.oasis.opendocument.text-master":{source:"iana",extensions:["odm"]},"application/vnd.oasis.opendocument.text-template":{source:"iana",extensions:["ott"]},"application/vnd.oasis.opendocument.text-web":{source:"iana",extensions:["oth"]},"application/vnd.obn":{source:"iana"},"application/vnd.ocf+cbor":{source:"iana"},"application/vnd.oci.image.manifest.v1+json":{source:"iana",compressible:!0},"application/vnd.oftn.l10n+json":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessdownload+xml":{source:"iana",compressible:!0},"application/vnd.oipf.contentaccessstreaming+xml":{source:"iana",compressible:!0},"application/vnd.oipf.cspg-hexbinary":{source:"iana"},"application/vnd.oipf.dae.svg+xml":{source:"iana",compressible:!0},"application/vnd.oipf.dae.xhtml+xml":{source:"iana",compressible:!0},"application/vnd.oipf.mippvcontrolmessage+xml":{source:"iana",compressible:!0},"application/vnd.oipf.pae.gem":{source:"iana"},"application/vnd.oipf.spdiscovery+xml":{source:"iana",compressible:!0},"application/vnd.oipf.spdlist+xml":{source:"iana",compressible:!0},"application/vnd.oipf.ueprofile+xml":{source:"iana",compressible:!0},"application/vnd.oipf.userprofile+xml":{source:"iana",compressible:!0},"application/vnd.olpc-sugar":{source:"iana",extensions:["xo"]},"application/vnd.oma-scws-config":{source:"iana"},"application/vnd.oma-scws-http-request":{source:"iana"},"application/vnd.oma-scws-http-response":{source:"iana"},"application/vnd.oma.bcast.associated-procedure-parameter+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.drm-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.imd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.ltkm":{source:"iana"},"application/vnd.oma.bcast.notification+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.provisioningtrigger":{source:"iana"},"application/vnd.oma.bcast.sgboot":{source:"iana"},"application/vnd.oma.bcast.sgdd+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sgdu":{source:"iana"},"application/vnd.oma.bcast.simple-symbol-container":{source:"iana"},"application/vnd.oma.bcast.smartcard-trigger+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.sprov+xml":{source:"iana",compressible:!0},"application/vnd.oma.bcast.stkm":{source:"iana"},"application/vnd.oma.cab-address-book+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-feature-handler+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-pcc+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-subs-invite+xml":{source:"iana",compressible:!0},"application/vnd.oma.cab-user-prefs+xml":{source:"iana",compressible:!0},"application/vnd.oma.dcd":{source:"iana"},"application/vnd.oma.dcdc":{source:"iana"},"application/vnd.oma.dd2+xml":{source:"iana",compressible:!0,extensions:["dd2"]},"application/vnd.oma.drm.risd+xml":{source:"iana",compressible:!0},"application/vnd.oma.group-usage-list+xml":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+cbor":{source:"iana"},"application/vnd.oma.lwm2m+json":{source:"iana",compressible:!0},"application/vnd.oma.lwm2m+tlv":{source:"iana"},"application/vnd.oma.pal+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.detailed-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.final-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.groups+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.invocation-descriptor+xml":{source:"iana",compressible:!0},"application/vnd.oma.poc.optimized-progress-report+xml":{source:"iana",compressible:!0},"application/vnd.oma.push":{source:"iana"},"application/vnd.oma.scidm.messages+xml":{source:"iana",compressible:!0},"application/vnd.oma.xcap-directory+xml":{source:"iana",compressible:!0},"application/vnd.omads-email+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-file+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omads-folder+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.omaloc-supl-init":{source:"iana"},"application/vnd.onepager":{source:"iana"},"application/vnd.onepagertamp":{source:"iana"},"application/vnd.onepagertamx":{source:"iana"},"application/vnd.onepagertat":{source:"iana"},"application/vnd.onepagertatp":{source:"iana"},"application/vnd.onepagertatx":{source:"iana"},"application/vnd.openblox.game+xml":{source:"iana",compressible:!0,extensions:["obgx"]},"application/vnd.openblox.game-binary":{source:"iana"},"application/vnd.openeye.oeb":{source:"iana"},"application/vnd.openofficeorg.extension":{source:"apache",extensions:["oxt"]},"application/vnd.openstreetmap.data+xml":{source:"iana",compressible:!0,extensions:["osm"]},"application/vnd.opentimestamps.ots":{source:"iana"},"application/vnd.openxmlformats-officedocument.custom-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.customxmlproperties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawing+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chart+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.extended-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{source:"iana",compressible:!1,extensions:["pptx"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.presprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slide":{source:"iana",extensions:["sldx"]},"application/vnd.openxmlformats-officedocument.presentationml.slide+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideshow":{source:"iana",extensions:["ppsx"]},"application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.tags+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.template":{source:"iana",extensions:["potx"]},"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{source:"iana",compressible:!1,extensions:["xlsx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.template":{source:"iana",extensions:["xltx"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.theme+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.themeoverride+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.vmldrawing":{source:"iana"},"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{source:"iana",compressible:!1,extensions:["docx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.template":{source:"iana",extensions:["dotx"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.core-properties+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml":{source:"iana",compressible:!0},"application/vnd.openxmlformats-package.relationships+xml":{source:"iana",compressible:!0},"application/vnd.oracle.resource+json":{source:"iana",compressible:!0},"application/vnd.orange.indata":{source:"iana"},"application/vnd.osa.netdeploy":{source:"iana"},"application/vnd.osgeo.mapguide.package":{source:"iana",extensions:["mgp"]},"application/vnd.osgi.bundle":{source:"iana"},"application/vnd.osgi.dp":{source:"iana",extensions:["dp"]},"application/vnd.osgi.subsystem":{source:"iana",extensions:["esa"]},"application/vnd.otps.ct-kip+xml":{source:"iana",compressible:!0},"application/vnd.oxli.countgraph":{source:"iana"},"application/vnd.pagerduty+json":{source:"iana",compressible:!0},"application/vnd.palm":{source:"iana",extensions:["pdb","pqa","oprc"]},"application/vnd.panoply":{source:"iana"},"application/vnd.paos.xml":{source:"iana"},"application/vnd.patentdive":{source:"iana"},"application/vnd.patientecommsdoc":{source:"iana"},"application/vnd.pawaafile":{source:"iana",extensions:["paw"]},"application/vnd.pcos":{source:"iana"},"application/vnd.pg.format":{source:"iana",extensions:["str"]},"application/vnd.pg.osasli":{source:"iana",extensions:["ei6"]},"application/vnd.piaccess.application-licence":{source:"iana"},"application/vnd.picsel":{source:"iana",extensions:["efif"]},"application/vnd.pmi.widget":{source:"iana",extensions:["wg"]},"application/vnd.poc.group-advertisement+xml":{source:"iana",compressible:!0},"application/vnd.pocketlearn":{source:"iana",extensions:["plf"]},"application/vnd.powerbuilder6":{source:"iana",extensions:["pbd"]},"application/vnd.powerbuilder6-s":{source:"iana"},"application/vnd.powerbuilder7":{source:"iana"},"application/vnd.powerbuilder7-s":{source:"iana"},"application/vnd.powerbuilder75":{source:"iana"},"application/vnd.powerbuilder75-s":{source:"iana"},"application/vnd.preminet":{source:"iana"},"application/vnd.previewsystems.box":{source:"iana",extensions:["box"]},"application/vnd.proteus.magazine":{source:"iana",extensions:["mgz"]},"application/vnd.psfs":{source:"iana"},"application/vnd.publishare-delta-tree":{source:"iana",extensions:["qps"]},"application/vnd.pvi.ptid1":{source:"iana",extensions:["ptid"]},"application/vnd.pwg-multiplexed":{source:"iana"},"application/vnd.pwg-xhtml-print+xml":{source:"iana",compressible:!0},"application/vnd.qualcomm.brew-app-res":{source:"iana"},"application/vnd.quarantainenet":{source:"iana"},"application/vnd.quark.quarkxpress":{source:"iana",extensions:["qxd","qxt","qwd","qwt","qxl","qxb"]},"application/vnd.quobject-quoxdocument":{source:"iana"},"application/vnd.radisys.moml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-conn+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-audit-stream+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-conf+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-base+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-detect+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-fax-sendrecv+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-group+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-speech+xml":{source:"iana",compressible:!0},"application/vnd.radisys.msml-dialog-transform+xml":{source:"iana",compressible:!0},"application/vnd.rainstor.data":{source:"iana"},"application/vnd.rapid":{source:"iana"},"application/vnd.rar":{source:"iana",extensions:["rar"]},"application/vnd.realvnc.bed":{source:"iana",extensions:["bed"]},"application/vnd.recordare.musicxml":{source:"iana",extensions:["mxl"]},"application/vnd.recordare.musicxml+xml":{source:"iana",compressible:!0,extensions:["musicxml"]},"application/vnd.renlearn.rlprint":{source:"iana"},"application/vnd.resilient.logic":{source:"iana"},"application/vnd.restful+json":{source:"iana",compressible:!0},"application/vnd.rig.cryptonote":{source:"iana",extensions:["cryptonote"]},"application/vnd.rim.cod":{source:"apache",extensions:["cod"]},"application/vnd.rn-realmedia":{source:"apache",extensions:["rm"]},"application/vnd.rn-realmedia-vbr":{source:"apache",extensions:["rmvb"]},"application/vnd.route66.link66+xml":{source:"iana",compressible:!0,extensions:["link66"]},"application/vnd.rs-274x":{source:"iana"},"application/vnd.ruckus.download":{source:"iana"},"application/vnd.s3sms":{source:"iana"},"application/vnd.sailingtracker.track":{source:"iana",extensions:["st"]},"application/vnd.sar":{source:"iana"},"application/vnd.sbm.cid":{source:"iana"},"application/vnd.sbm.mid2":{source:"iana"},"application/vnd.scribus":{source:"iana"},"application/vnd.sealed.3df":{source:"iana"},"application/vnd.sealed.csf":{source:"iana"},"application/vnd.sealed.doc":{source:"iana"},"application/vnd.sealed.eml":{source:"iana"},"application/vnd.sealed.mht":{source:"iana"},"application/vnd.sealed.net":{source:"iana"},"application/vnd.sealed.ppt":{source:"iana"},"application/vnd.sealed.tiff":{source:"iana"},"application/vnd.sealed.xls":{source:"iana"},"application/vnd.sealedmedia.softseal.html":{source:"iana"},"application/vnd.sealedmedia.softseal.pdf":{source:"iana"},"application/vnd.seemail":{source:"iana",extensions:["see"]},"application/vnd.seis+json":{source:"iana",compressible:!0},"application/vnd.sema":{source:"iana",extensions:["sema"]},"application/vnd.semd":{source:"iana",extensions:["semd"]},"application/vnd.semf":{source:"iana",extensions:["semf"]},"application/vnd.shade-save-file":{source:"iana"},"application/vnd.shana.informed.formdata":{source:"iana",extensions:["ifm"]},"application/vnd.shana.informed.formtemplate":{source:"iana",extensions:["itp"]},"application/vnd.shana.informed.interchange":{source:"iana",extensions:["iif"]},"application/vnd.shana.informed.package":{source:"iana",extensions:["ipk"]},"application/vnd.shootproof+json":{source:"iana",compressible:!0},"application/vnd.shopkick+json":{source:"iana",compressible:!0},"application/vnd.shp":{source:"iana"},"application/vnd.shx":{source:"iana"},"application/vnd.sigrok.session":{source:"iana"},"application/vnd.simtech-mindmapper":{source:"iana",extensions:["twd","twds"]},"application/vnd.siren+json":{source:"iana",compressible:!0},"application/vnd.smaf":{source:"iana",extensions:["mmf"]},"application/vnd.smart.notebook":{source:"iana"},"application/vnd.smart.teacher":{source:"iana",extensions:["teacher"]},"application/vnd.snesdev-page-table":{source:"iana"},"application/vnd.software602.filler.form+xml":{source:"iana",compressible:!0,extensions:["fo"]},"application/vnd.software602.filler.form-xml-zip":{source:"iana"},"application/vnd.solent.sdkm+xml":{source:"iana",compressible:!0,extensions:["sdkm","sdkd"]},"application/vnd.spotfire.dxp":{source:"iana",extensions:["dxp"]},"application/vnd.spotfire.sfs":{source:"iana",extensions:["sfs"]},"application/vnd.sqlite3":{source:"iana"},"application/vnd.sss-cod":{source:"iana"},"application/vnd.sss-dtf":{source:"iana"},"application/vnd.sss-ntf":{source:"iana"},"application/vnd.stardivision.calc":{source:"apache",extensions:["sdc"]},"application/vnd.stardivision.draw":{source:"apache",extensions:["sda"]},"application/vnd.stardivision.impress":{source:"apache",extensions:["sdd"]},"application/vnd.stardivision.math":{source:"apache",extensions:["smf"]},"application/vnd.stardivision.writer":{source:"apache",extensions:["sdw","vor"]},"application/vnd.stardivision.writer-global":{source:"apache",extensions:["sgl"]},"application/vnd.stepmania.package":{source:"iana",extensions:["smzip"]},"application/vnd.stepmania.stepchart":{source:"iana",extensions:["sm"]},"application/vnd.street-stream":{source:"iana"},"application/vnd.sun.wadl+xml":{source:"iana",compressible:!0,extensions:["wadl"]},"application/vnd.sun.xml.calc":{source:"apache",extensions:["sxc"]},"application/vnd.sun.xml.calc.template":{source:"apache",extensions:["stc"]},"application/vnd.sun.xml.draw":{source:"apache",extensions:["sxd"]},"application/vnd.sun.xml.draw.template":{source:"apache",extensions:["std"]},"application/vnd.sun.xml.impress":{source:"apache",extensions:["sxi"]},"application/vnd.sun.xml.impress.template":{source:"apache",extensions:["sti"]},"application/vnd.sun.xml.math":{source:"apache",extensions:["sxm"]},"application/vnd.sun.xml.writer":{source:"apache",extensions:["sxw"]},"application/vnd.sun.xml.writer.global":{source:"apache",extensions:["sxg"]},"application/vnd.sun.xml.writer.template":{source:"apache",extensions:["stw"]},"application/vnd.sus-calendar":{source:"iana",extensions:["sus","susp"]},"application/vnd.svd":{source:"iana",extensions:["svd"]},"application/vnd.swiftview-ics":{source:"iana"},"application/vnd.sycle+xml":{source:"iana",compressible:!0},"application/vnd.syft+json":{source:"iana",compressible:!0},"application/vnd.symbian.install":{source:"apache",extensions:["sis","sisx"]},"application/vnd.syncml+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xsm"]},"application/vnd.syncml.dm+wbxml":{source:"iana",charset:"UTF-8",extensions:["bdm"]},"application/vnd.syncml.dm+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["xdm"]},"application/vnd.syncml.dm.notification":{source:"iana"},"application/vnd.syncml.dmddf+wbxml":{source:"iana"},"application/vnd.syncml.dmddf+xml":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["ddf"]},"application/vnd.syncml.dmtnds+wbxml":{source:"iana"},"application/vnd.syncml.dmtnds+xml":{source:"iana",charset:"UTF-8",compressible:!0},"application/vnd.syncml.ds.notification":{source:"iana"},"application/vnd.tableschema+json":{source:"iana",compressible:!0},"application/vnd.tao.intent-module-archive":{source:"iana",extensions:["tao"]},"application/vnd.tcpdump.pcap":{source:"iana",extensions:["pcap","cap","dmp"]},"application/vnd.think-cell.ppttc+json":{source:"iana",compressible:!0},"application/vnd.tmd.mediaflex.api+xml":{source:"iana",compressible:!0},"application/vnd.tml":{source:"iana"},"application/vnd.tmobile-livetv":{source:"iana",extensions:["tmo"]},"application/vnd.tri.onesource":{source:"iana"},"application/vnd.trid.tpt":{source:"iana",extensions:["tpt"]},"application/vnd.triscape.mxs":{source:"iana",extensions:["mxs"]},"application/vnd.trueapp":{source:"iana",extensions:["tra"]},"application/vnd.truedoc":{source:"iana"},"application/vnd.ubisoft.webplayer":{source:"iana"},"application/vnd.ufdl":{source:"iana",extensions:["ufd","ufdl"]},"application/vnd.uiq.theme":{source:"iana",extensions:["utz"]},"application/vnd.umajin":{source:"iana",extensions:["umj"]},"application/vnd.unity":{source:"iana",extensions:["unityweb"]},"application/vnd.uoml+xml":{source:"iana",compressible:!0,extensions:["uoml"]},"application/vnd.uplanet.alert":{source:"iana"},"application/vnd.uplanet.alert-wbxml":{source:"iana"},"application/vnd.uplanet.bearer-choice":{source:"iana"},"application/vnd.uplanet.bearer-choice-wbxml":{source:"iana"},"application/vnd.uplanet.cacheop":{source:"iana"},"application/vnd.uplanet.cacheop-wbxml":{source:"iana"},"application/vnd.uplanet.channel":{source:"iana"},"application/vnd.uplanet.channel-wbxml":{source:"iana"},"application/vnd.uplanet.list":{source:"iana"},"application/vnd.uplanet.list-wbxml":{source:"iana"},"application/vnd.uplanet.listcmd":{source:"iana"},"application/vnd.uplanet.listcmd-wbxml":{source:"iana"},"application/vnd.uplanet.signal":{source:"iana"},"application/vnd.uri-map":{source:"iana"},"application/vnd.valve.source.material":{source:"iana"},"application/vnd.vcx":{source:"iana",extensions:["vcx"]},"application/vnd.vd-study":{source:"iana"},"application/vnd.vectorworks":{source:"iana"},"application/vnd.vel+json":{source:"iana",compressible:!0},"application/vnd.verimatrix.vcas":{source:"iana"},"application/vnd.veritone.aion+json":{source:"iana",compressible:!0},"application/vnd.veryant.thin":{source:"iana"},"application/vnd.ves.encrypted":{source:"iana"},"application/vnd.vidsoft.vidconference":{source:"iana"},"application/vnd.visio":{source:"iana",extensions:["vsd","vst","vss","vsw"]},"application/vnd.visionary":{source:"iana",extensions:["vis"]},"application/vnd.vividence.scriptfile":{source:"iana"},"application/vnd.vsf":{source:"iana",extensions:["vsf"]},"application/vnd.wap.sic":{source:"iana"},"application/vnd.wap.slc":{source:"iana"},"application/vnd.wap.wbxml":{source:"iana",charset:"UTF-8",extensions:["wbxml"]},"application/vnd.wap.wmlc":{source:"iana",extensions:["wmlc"]},"application/vnd.wap.wmlscriptc":{source:"iana",extensions:["wmlsc"]},"application/vnd.webturbo":{source:"iana",extensions:["wtb"]},"application/vnd.wfa.dpp":{source:"iana"},"application/vnd.wfa.p2p":{source:"iana"},"application/vnd.wfa.wsc":{source:"iana"},"application/vnd.windows.devicepairing":{source:"iana"},"application/vnd.wmc":{source:"iana"},"application/vnd.wmf.bootstrap":{source:"iana"},"application/vnd.wolfram.mathematica":{source:"iana"},"application/vnd.wolfram.mathematica.package":{source:"iana"},"application/vnd.wolfram.player":{source:"iana",extensions:["nbp"]},"application/vnd.wordperfect":{source:"iana",extensions:["wpd"]},"application/vnd.wqd":{source:"iana",extensions:["wqd"]},"application/vnd.wrq-hp3000-labelled":{source:"iana"},"application/vnd.wt.stf":{source:"iana",extensions:["stf"]},"application/vnd.wv.csp+wbxml":{source:"iana"},"application/vnd.wv.csp+xml":{source:"iana",compressible:!0},"application/vnd.wv.ssp+xml":{source:"iana",compressible:!0},"application/vnd.xacml+json":{source:"iana",compressible:!0},"application/vnd.xara":{source:"iana",extensions:["xar"]},"application/vnd.xfdl":{source:"iana",extensions:["xfdl"]},"application/vnd.xfdl.webform":{source:"iana"},"application/vnd.xmi+xml":{source:"iana",compressible:!0},"application/vnd.xmpie.cpkg":{source:"iana"},"application/vnd.xmpie.dpkg":{source:"iana"},"application/vnd.xmpie.plan":{source:"iana"},"application/vnd.xmpie.ppkg":{source:"iana"},"application/vnd.xmpie.xlim":{source:"iana"},"application/vnd.yamaha.hv-dic":{source:"iana",extensions:["hvd"]},"application/vnd.yamaha.hv-script":{source:"iana",extensions:["hvs"]},"application/vnd.yamaha.hv-voice":{source:"iana",extensions:["hvp"]},"application/vnd.yamaha.openscoreformat":{source:"iana",extensions:["osf"]},"application/vnd.yamaha.openscoreformat.osfpvg+xml":{source:"iana",compressible:!0,extensions:["osfpvg"]},"application/vnd.yamaha.remote-setup":{source:"iana"},"application/vnd.yamaha.smaf-audio":{source:"iana",extensions:["saf"]},"application/vnd.yamaha.smaf-phrase":{source:"iana",extensions:["spf"]},"application/vnd.yamaha.through-ngn":{source:"iana"},"application/vnd.yamaha.tunnel-udpencap":{source:"iana"},"application/vnd.yaoweme":{source:"iana"},"application/vnd.yellowriver-custom-menu":{source:"iana",extensions:["cmp"]},"application/vnd.youtube.yt":{source:"iana"},"application/vnd.zul":{source:"iana",extensions:["zir","zirz"]},"application/vnd.zzazz.deck+xml":{source:"iana",compressible:!0,extensions:["zaz"]},"application/voicexml+xml":{source:"iana",compressible:!0,extensions:["vxml"]},"application/voucher-cms+json":{source:"iana",compressible:!0},"application/vq-rtcpxr":{source:"iana"},"application/wasm":{source:"iana",compressible:!0,extensions:["wasm"]},"application/watcherinfo+xml":{source:"iana",compressible:!0,extensions:["wif"]},"application/webpush-options+json":{source:"iana",compressible:!0},"application/whoispp-query":{source:"iana"},"application/whoispp-response":{source:"iana"},"application/widget":{source:"iana",extensions:["wgt"]},"application/winhlp":{source:"apache",extensions:["hlp"]},"application/wita":{source:"iana"},"application/wordperfect5.1":{source:"iana"},"application/wsdl+xml":{source:"iana",compressible:!0,extensions:["wsdl"]},"application/wspolicy+xml":{source:"iana",compressible:!0,extensions:["wspolicy"]},"application/x-7z-compressed":{source:"apache",compressible:!1,extensions:["7z"]},"application/x-abiword":{source:"apache",extensions:["abw"]},"application/x-ace-compressed":{source:"apache",extensions:["ace"]},"application/x-amf":{source:"apache"},"application/x-apple-diskimage":{source:"apache",extensions:["dmg"]},"application/x-arj":{compressible:!1,extensions:["arj"]},"application/x-authorware-bin":{source:"apache",extensions:["aab","x32","u32","vox"]},"application/x-authorware-map":{source:"apache",extensions:["aam"]},"application/x-authorware-seg":{source:"apache",extensions:["aas"]},"application/x-bcpio":{source:"apache",extensions:["bcpio"]},"application/x-bdoc":{compressible:!1,extensions:["bdoc"]},"application/x-bittorrent":{source:"apache",extensions:["torrent"]},"application/x-blorb":{source:"apache",extensions:["blb","blorb"]},"application/x-bzip":{source:"apache",compressible:!1,extensions:["bz"]},"application/x-bzip2":{source:"apache",compressible:!1,extensions:["bz2","boz"]},"application/x-cbr":{source:"apache",extensions:["cbr","cba","cbt","cbz","cb7"]},"application/x-cdlink":{source:"apache",extensions:["vcd"]},"application/x-cfs-compressed":{source:"apache",extensions:["cfs"]},"application/x-chat":{source:"apache",extensions:["chat"]},"application/x-chess-pgn":{source:"apache",extensions:["pgn"]},"application/x-chrome-extension":{extensions:["crx"]},"application/x-cocoa":{source:"nginx",extensions:["cco"]},"application/x-compress":{source:"apache"},"application/x-conference":{source:"apache",extensions:["nsc"]},"application/x-cpio":{source:"apache",extensions:["cpio"]},"application/x-csh":{source:"apache",extensions:["csh"]},"application/x-deb":{compressible:!1},"application/x-debian-package":{source:"apache",extensions:["deb","udeb"]},"application/x-dgc-compressed":{source:"apache",extensions:["dgc"]},"application/x-director":{source:"apache",extensions:["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"]},"application/x-doom":{source:"apache",extensions:["wad"]},"application/x-dtbncx+xml":{source:"apache",compressible:!0,extensions:["ncx"]},"application/x-dtbook+xml":{source:"apache",compressible:!0,extensions:["dtb"]},"application/x-dtbresource+xml":{source:"apache",compressible:!0,extensions:["res"]},"application/x-dvi":{source:"apache",compressible:!1,extensions:["dvi"]},"application/x-envoy":{source:"apache",extensions:["evy"]},"application/x-eva":{source:"apache",extensions:["eva"]},"application/x-font-bdf":{source:"apache",extensions:["bdf"]},"application/x-font-dos":{source:"apache"},"application/x-font-framemaker":{source:"apache"},"application/x-font-ghostscript":{source:"apache",extensions:["gsf"]},"application/x-font-libgrx":{source:"apache"},"application/x-font-linux-psf":{source:"apache",extensions:["psf"]},"application/x-font-pcf":{source:"apache",extensions:["pcf"]},"application/x-font-snf":{source:"apache",extensions:["snf"]},"application/x-font-speedo":{source:"apache"},"application/x-font-sunos-news":{source:"apache"},"application/x-font-type1":{source:"apache",extensions:["pfa","pfb","pfm","afm"]},"application/x-font-vfont":{source:"apache"},"application/x-freearc":{source:"apache",extensions:["arc"]},"application/x-futuresplash":{source:"apache",extensions:["spl"]},"application/x-gca-compressed":{source:"apache",extensions:["gca"]},"application/x-glulx":{source:"apache",extensions:["ulx"]},"application/x-gnumeric":{source:"apache",extensions:["gnumeric"]},"application/x-gramps-xml":{source:"apache",extensions:["gramps"]},"application/x-gtar":{source:"apache",extensions:["gtar"]},"application/x-gzip":{source:"apache"},"application/x-hdf":{source:"apache",extensions:["hdf"]},"application/x-httpd-php":{compressible:!0,extensions:["php"]},"application/x-install-instructions":{source:"apache",extensions:["install"]},"application/x-iso9660-image":{source:"apache",extensions:["iso"]},"application/x-iwork-keynote-sffkey":{extensions:["key"]},"application/x-iwork-numbers-sffnumbers":{extensions:["numbers"]},"application/x-iwork-pages-sffpages":{extensions:["pages"]},"application/x-java-archive-diff":{source:"nginx",extensions:["jardiff"]},"application/x-java-jnlp-file":{source:"apache",compressible:!1,extensions:["jnlp"]},"application/x-javascript":{compressible:!0},"application/x-keepass2":{extensions:["kdbx"]},"application/x-latex":{source:"apache",compressible:!1,extensions:["latex"]},"application/x-lua-bytecode":{extensions:["luac"]},"application/x-lzh-compressed":{source:"apache",extensions:["lzh","lha"]},"application/x-makeself":{source:"nginx",extensions:["run"]},"application/x-mie":{source:"apache",extensions:["mie"]},"application/x-mobipocket-ebook":{source:"apache",extensions:["prc","mobi"]},"application/x-mpegurl":{compressible:!1},"application/x-ms-application":{source:"apache",extensions:["application"]},"application/x-ms-shortcut":{source:"apache",extensions:["lnk"]},"application/x-ms-wmd":{source:"apache",extensions:["wmd"]},"application/x-ms-wmz":{source:"apache",extensions:["wmz"]},"application/x-ms-xbap":{source:"apache",extensions:["xbap"]},"application/x-msaccess":{source:"apache",extensions:["mdb"]},"application/x-msbinder":{source:"apache",extensions:["obd"]},"application/x-mscardfile":{source:"apache",extensions:["crd"]},"application/x-msclip":{source:"apache",extensions:["clp"]},"application/x-msdos-program":{extensions:["exe"]},"application/x-msdownload":{source:"apache",extensions:["exe","dll","com","bat","msi"]},"application/x-msmediaview":{source:"apache",extensions:["mvb","m13","m14"]},"application/x-msmetafile":{source:"apache",extensions:["wmf","wmz","emf","emz"]},"application/x-msmoney":{source:"apache",extensions:["mny"]},"application/x-mspublisher":{source:"apache",extensions:["pub"]},"application/x-msschedule":{source:"apache",extensions:["scd"]},"application/x-msterminal":{source:"apache",extensions:["trm"]},"application/x-mswrite":{source:"apache",extensions:["wri"]},"application/x-netcdf":{source:"apache",extensions:["nc","cdf"]},"application/x-ns-proxy-autoconfig":{compressible:!0,extensions:["pac"]},"application/x-nzb":{source:"apache",extensions:["nzb"]},"application/x-perl":{source:"nginx",extensions:["pl","pm"]},"application/x-pilot":{source:"nginx",extensions:["prc","pdb"]},"application/x-pkcs12":{source:"apache",compressible:!1,extensions:["p12","pfx"]},"application/x-pkcs7-certificates":{source:"apache",extensions:["p7b","spc"]},"application/x-pkcs7-certreqresp":{source:"apache",extensions:["p7r"]},"application/x-pki-message":{source:"iana"},"application/x-rar-compressed":{source:"apache",compressible:!1,extensions:["rar"]},"application/x-redhat-package-manager":{source:"nginx",extensions:["rpm"]},"application/x-research-info-systems":{source:"apache",extensions:["ris"]},"application/x-sea":{source:"nginx",extensions:["sea"]},"application/x-sh":{source:"apache",compressible:!0,extensions:["sh"]},"application/x-shar":{source:"apache",extensions:["shar"]},"application/x-shockwave-flash":{source:"apache",compressible:!1,extensions:["swf"]},"application/x-silverlight-app":{source:"apache",extensions:["xap"]},"application/x-sql":{source:"apache",extensions:["sql"]},"application/x-stuffit":{source:"apache",compressible:!1,extensions:["sit"]},"application/x-stuffitx":{source:"apache",extensions:["sitx"]},"application/x-subrip":{source:"apache",extensions:["srt"]},"application/x-sv4cpio":{source:"apache",extensions:["sv4cpio"]},"application/x-sv4crc":{source:"apache",extensions:["sv4crc"]},"application/x-t3vm-image":{source:"apache",extensions:["t3"]},"application/x-tads":{source:"apache",extensions:["gam"]},"application/x-tar":{source:"apache",compressible:!0,extensions:["tar"]},"application/x-tcl":{source:"apache",extensions:["tcl","tk"]},"application/x-tex":{source:"apache",extensions:["tex"]},"application/x-tex-tfm":{source:"apache",extensions:["tfm"]},"application/x-texinfo":{source:"apache",extensions:["texinfo","texi"]},"application/x-tgif":{source:"apache",extensions:["obj"]},"application/x-ustar":{source:"apache",extensions:["ustar"]},"application/x-virtualbox-hdd":{compressible:!0,extensions:["hdd"]},"application/x-virtualbox-ova":{compressible:!0,extensions:["ova"]},"application/x-virtualbox-ovf":{compressible:!0,extensions:["ovf"]},"application/x-virtualbox-vbox":{compressible:!0,extensions:["vbox"]},"application/x-virtualbox-vbox-extpack":{compressible:!1,extensions:["vbox-extpack"]},"application/x-virtualbox-vdi":{compressible:!0,extensions:["vdi"]},"application/x-virtualbox-vhd":{compressible:!0,extensions:["vhd"]},"application/x-virtualbox-vmdk":{compressible:!0,extensions:["vmdk"]},"application/x-wais-source":{source:"apache",extensions:["src"]},"application/x-web-app-manifest+json":{compressible:!0,extensions:["webapp"]},"application/x-www-form-urlencoded":{source:"iana",compressible:!0},"application/x-x509-ca-cert":{source:"iana",extensions:["der","crt","pem"]},"application/x-x509-ca-ra-cert":{source:"iana"},"application/x-x509-next-ca-cert":{source:"iana"},"application/x-xfig":{source:"apache",extensions:["fig"]},"application/x-xliff+xml":{source:"apache",compressible:!0,extensions:["xlf"]},"application/x-xpinstall":{source:"apache",compressible:!1,extensions:["xpi"]},"application/x-xz":{source:"apache",extensions:["xz"]},"application/x-zmachine":{source:"apache",extensions:["z1","z2","z3","z4","z5","z6","z7","z8"]},"application/x400-bp":{source:"iana"},"application/xacml+xml":{source:"iana",compressible:!0},"application/xaml+xml":{source:"apache",compressible:!0,extensions:["xaml"]},"application/xcap-att+xml":{source:"iana",compressible:!0,extensions:["xav"]},"application/xcap-caps+xml":{source:"iana",compressible:!0,extensions:["xca"]},"application/xcap-diff+xml":{source:"iana",compressible:!0,extensions:["xdf"]},"application/xcap-el+xml":{source:"iana",compressible:!0,extensions:["xel"]},"application/xcap-error+xml":{source:"iana",compressible:!0},"application/xcap-ns+xml":{source:"iana",compressible:!0,extensions:["xns"]},"application/xcon-conference-info+xml":{source:"iana",compressible:!0},"application/xcon-conference-info-diff+xml":{source:"iana",compressible:!0},"application/xenc+xml":{source:"iana",compressible:!0,extensions:["xenc"]},"application/xhtml+xml":{source:"iana",compressible:!0,extensions:["xhtml","xht"]},"application/xhtml-voice+xml":{source:"apache",compressible:!0},"application/xliff+xml":{source:"iana",compressible:!0,extensions:["xlf"]},"application/xml":{source:"iana",compressible:!0,extensions:["xml","xsl","xsd","rng"]},"application/xml-dtd":{source:"iana",compressible:!0,extensions:["dtd"]},"application/xml-external-parsed-entity":{source:"iana"},"application/xml-patch+xml":{source:"iana",compressible:!0},"application/xmpp+xml":{source:"iana",compressible:!0},"application/xop+xml":{source:"iana",compressible:!0,extensions:["xop"]},"application/xproc+xml":{source:"apache",compressible:!0,extensions:["xpl"]},"application/xslt+xml":{source:"iana",compressible:!0,extensions:["xsl","xslt"]},"application/xspf+xml":{source:"apache",compressible:!0,extensions:["xspf"]},"application/xv+xml":{source:"iana",compressible:!0,extensions:["mxml","xhvml","xvml","xvm"]},"application/yang":{source:"iana",extensions:["yang"]},"application/yang-data+json":{source:"iana",compressible:!0},"application/yang-data+xml":{source:"iana",compressible:!0},"application/yang-patch+json":{source:"iana",compressible:!0},"application/yang-patch+xml":{source:"iana",compressible:!0},"application/yin+xml":{source:"iana",compressible:!0,extensions:["yin"]},"application/zip":{source:"iana",compressible:!1,extensions:["zip"]},"application/zlib":{source:"iana"},"application/zstd":{source:"iana"},"audio/1d-interleaved-parityfec":{source:"iana"},"audio/32kadpcm":{source:"iana"},"audio/3gpp":{source:"iana",compressible:!1,extensions:["3gpp"]},"audio/3gpp2":{source:"iana"},"audio/aac":{source:"iana"},"audio/ac3":{source:"iana"},"audio/adpcm":{source:"apache",extensions:["adp"]},"audio/amr":{source:"iana",extensions:["amr"]},"audio/amr-wb":{source:"iana"},"audio/amr-wb+":{source:"iana"},"audio/aptx":{source:"iana"},"audio/asc":{source:"iana"},"audio/atrac-advanced-lossless":{source:"iana"},"audio/atrac-x":{source:"iana"},"audio/atrac3":{source:"iana"},"audio/basic":{source:"iana",compressible:!1,extensions:["au","snd"]},"audio/bv16":{source:"iana"},"audio/bv32":{source:"iana"},"audio/clearmode":{source:"iana"},"audio/cn":{source:"iana"},"audio/dat12":{source:"iana"},"audio/dls":{source:"iana"},"audio/dsr-es201108":{source:"iana"},"audio/dsr-es202050":{source:"iana"},"audio/dsr-es202211":{source:"iana"},"audio/dsr-es202212":{source:"iana"},"audio/dv":{source:"iana"},"audio/dvi4":{source:"iana"},"audio/eac3":{source:"iana"},"audio/encaprtp":{source:"iana"},"audio/evrc":{source:"iana"},"audio/evrc-qcp":{source:"iana"},"audio/evrc0":{source:"iana"},"audio/evrc1":{source:"iana"},"audio/evrcb":{source:"iana"},"audio/evrcb0":{source:"iana"},"audio/evrcb1":{source:"iana"},"audio/evrcnw":{source:"iana"},"audio/evrcnw0":{source:"iana"},"audio/evrcnw1":{source:"iana"},"audio/evrcwb":{source:"iana"},"audio/evrcwb0":{source:"iana"},"audio/evrcwb1":{source:"iana"},"audio/evs":{source:"iana"},"audio/flexfec":{source:"iana"},"audio/fwdred":{source:"iana"},"audio/g711-0":{source:"iana"},"audio/g719":{source:"iana"},"audio/g722":{source:"iana"},"audio/g7221":{source:"iana"},"audio/g723":{source:"iana"},"audio/g726-16":{source:"iana"},"audio/g726-24":{source:"iana"},"audio/g726-32":{source:"iana"},"audio/g726-40":{source:"iana"},"audio/g728":{source:"iana"},"audio/g729":{source:"iana"},"audio/g7291":{source:"iana"},"audio/g729d":{source:"iana"},"audio/g729e":{source:"iana"},"audio/gsm":{source:"iana"},"audio/gsm-efr":{source:"iana"},"audio/gsm-hr-08":{source:"iana"},"audio/ilbc":{source:"iana"},"audio/ip-mr_v2.5":{source:"iana"},"audio/isac":{source:"apache"},"audio/l16":{source:"iana"},"audio/l20":{source:"iana"},"audio/l24":{source:"iana",compressible:!1},"audio/l8":{source:"iana"},"audio/lpc":{source:"iana"},"audio/melp":{source:"iana"},"audio/melp1200":{source:"iana"},"audio/melp2400":{source:"iana"},"audio/melp600":{source:"iana"},"audio/mhas":{source:"iana"},"audio/midi":{source:"apache",extensions:["mid","midi","kar","rmi"]},"audio/mobile-xmf":{source:"iana",extensions:["mxmf"]},"audio/mp3":{compressible:!1,extensions:["mp3"]},"audio/mp4":{source:"iana",compressible:!1,extensions:["m4a","mp4a"]},"audio/mp4a-latm":{source:"iana"},"audio/mpa":{source:"iana"},"audio/mpa-robust":{source:"iana"},"audio/mpeg":{source:"iana",compressible:!1,extensions:["mpga","mp2","mp2a","mp3","m2a","m3a"]},"audio/mpeg4-generic":{source:"iana"},"audio/musepack":{source:"apache"},"audio/ogg":{source:"iana",compressible:!1,extensions:["oga","ogg","spx","opus"]},"audio/opus":{source:"iana"},"audio/parityfec":{source:"iana"},"audio/pcma":{source:"iana"},"audio/pcma-wb":{source:"iana"},"audio/pcmu":{source:"iana"},"audio/pcmu-wb":{source:"iana"},"audio/prs.sid":{source:"iana"},"audio/qcelp":{source:"iana"},"audio/raptorfec":{source:"iana"},"audio/red":{source:"iana"},"audio/rtp-enc-aescm128":{source:"iana"},"audio/rtp-midi":{source:"iana"},"audio/rtploopback":{source:"iana"},"audio/rtx":{source:"iana"},"audio/s3m":{source:"apache",extensions:["s3m"]},"audio/scip":{source:"iana"},"audio/silk":{source:"apache",extensions:["sil"]},"audio/smv":{source:"iana"},"audio/smv-qcp":{source:"iana"},"audio/smv0":{source:"iana"},"audio/sofa":{source:"iana"},"audio/sp-midi":{source:"iana"},"audio/speex":{source:"iana"},"audio/t140c":{source:"iana"},"audio/t38":{source:"iana"},"audio/telephone-event":{source:"iana"},"audio/tetra_acelp":{source:"iana"},"audio/tetra_acelp_bb":{source:"iana"},"audio/tone":{source:"iana"},"audio/tsvcis":{source:"iana"},"audio/uemclip":{source:"iana"},"audio/ulpfec":{source:"iana"},"audio/usac":{source:"iana"},"audio/vdvi":{source:"iana"},"audio/vmr-wb":{source:"iana"},"audio/vnd.3gpp.iufp":{source:"iana"},"audio/vnd.4sb":{source:"iana"},"audio/vnd.audiokoz":{source:"iana"},"audio/vnd.celp":{source:"iana"},"audio/vnd.cisco.nse":{source:"iana"},"audio/vnd.cmles.radio-events":{source:"iana"},"audio/vnd.cns.anp1":{source:"iana"},"audio/vnd.cns.inf1":{source:"iana"},"audio/vnd.dece.audio":{source:"iana",extensions:["uva","uvva"]},"audio/vnd.digital-winds":{source:"iana",extensions:["eol"]},"audio/vnd.dlna.adts":{source:"iana"},"audio/vnd.dolby.heaac.1":{source:"iana"},"audio/vnd.dolby.heaac.2":{source:"iana"},"audio/vnd.dolby.mlp":{source:"iana"},"audio/vnd.dolby.mps":{source:"iana"},"audio/vnd.dolby.pl2":{source:"iana"},"audio/vnd.dolby.pl2x":{source:"iana"},"audio/vnd.dolby.pl2z":{source:"iana"},"audio/vnd.dolby.pulse.1":{source:"iana"},"audio/vnd.dra":{source:"iana",extensions:["dra"]},"audio/vnd.dts":{source:"iana",extensions:["dts"]},"audio/vnd.dts.hd":{source:"iana",extensions:["dtshd"]},"audio/vnd.dts.uhd":{source:"iana"},"audio/vnd.dvb.file":{source:"iana"},"audio/vnd.everad.plj":{source:"iana"},"audio/vnd.hns.audio":{source:"iana"},"audio/vnd.lucent.voice":{source:"iana",extensions:["lvp"]},"audio/vnd.ms-playready.media.pya":{source:"iana",extensions:["pya"]},"audio/vnd.nokia.mobile-xmf":{source:"iana"},"audio/vnd.nortel.vbk":{source:"iana"},"audio/vnd.nuera.ecelp4800":{source:"iana",extensions:["ecelp4800"]},"audio/vnd.nuera.ecelp7470":{source:"iana",extensions:["ecelp7470"]},"audio/vnd.nuera.ecelp9600":{source:"iana",extensions:["ecelp9600"]},"audio/vnd.octel.sbc":{source:"iana"},"audio/vnd.presonus.multitrack":{source:"iana"},"audio/vnd.qcelp":{source:"iana"},"audio/vnd.rhetorex.32kadpcm":{source:"iana"},"audio/vnd.rip":{source:"iana",extensions:["rip"]},"audio/vnd.rn-realaudio":{compressible:!1},"audio/vnd.sealedmedia.softseal.mpeg":{source:"iana"},"audio/vnd.vmx.cvsd":{source:"iana"},"audio/vnd.wave":{compressible:!1},"audio/vorbis":{source:"iana",compressible:!1},"audio/vorbis-config":{source:"iana"},"audio/wav":{compressible:!1,extensions:["wav"]},"audio/wave":{compressible:!1,extensions:["wav"]},"audio/webm":{source:"apache",compressible:!1,extensions:["weba"]},"audio/x-aac":{source:"apache",compressible:!1,extensions:["aac"]},"audio/x-aiff":{source:"apache",extensions:["aif","aiff","aifc"]},"audio/x-caf":{source:"apache",compressible:!1,extensions:["caf"]},"audio/x-flac":{source:"apache",extensions:["flac"]},"audio/x-m4a":{source:"nginx",extensions:["m4a"]},"audio/x-matroska":{source:"apache",extensions:["mka"]},"audio/x-mpegurl":{source:"apache",extensions:["m3u"]},"audio/x-ms-wax":{source:"apache",extensions:["wax"]},"audio/x-ms-wma":{source:"apache",extensions:["wma"]},"audio/x-pn-realaudio":{source:"apache",extensions:["ram","ra"]},"audio/x-pn-realaudio-plugin":{source:"apache",extensions:["rmp"]},"audio/x-realaudio":{source:"nginx",extensions:["ra"]},"audio/x-tta":{source:"apache"},"audio/x-wav":{source:"apache",extensions:["wav"]},"audio/xm":{source:"apache",extensions:["xm"]},"chemical/x-cdx":{source:"apache",extensions:["cdx"]},"chemical/x-cif":{source:"apache",extensions:["cif"]},"chemical/x-cmdf":{source:"apache",extensions:["cmdf"]},"chemical/x-cml":{source:"apache",extensions:["cml"]},"chemical/x-csml":{source:"apache",extensions:["csml"]},"chemical/x-pdb":{source:"apache"},"chemical/x-xyz":{source:"apache",extensions:["xyz"]},"font/collection":{source:"iana",extensions:["ttc"]},"font/otf":{source:"iana",compressible:!0,extensions:["otf"]},"font/sfnt":{source:"iana"},"font/ttf":{source:"iana",compressible:!0,extensions:["ttf"]},"font/woff":{source:"iana",extensions:["woff"]},"font/woff2":{source:"iana",extensions:["woff2"]},"image/aces":{source:"iana",extensions:["exr"]},"image/apng":{compressible:!1,extensions:["apng"]},"image/avci":{source:"iana",extensions:["avci"]},"image/avcs":{source:"iana",extensions:["avcs"]},"image/avif":{source:"iana",compressible:!1,extensions:["avif"]},"image/bmp":{source:"iana",compressible:!0,extensions:["bmp"]},"image/cgm":{source:"iana",extensions:["cgm"]},"image/dicom-rle":{source:"iana",extensions:["drle"]},"image/emf":{source:"iana",extensions:["emf"]},"image/fits":{source:"iana",extensions:["fits"]},"image/g3fax":{source:"iana",extensions:["g3"]},"image/gif":{source:"iana",compressible:!1,extensions:["gif"]},"image/heic":{source:"iana",extensions:["heic"]},"image/heic-sequence":{source:"iana",extensions:["heics"]},"image/heif":{source:"iana",extensions:["heif"]},"image/heif-sequence":{source:"iana",extensions:["heifs"]},"image/hej2k":{source:"iana",extensions:["hej2"]},"image/hsj2":{source:"iana",extensions:["hsj2"]},"image/ief":{source:"iana",extensions:["ief"]},"image/jls":{source:"iana",extensions:["jls"]},"image/jp2":{source:"iana",compressible:!1,extensions:["jp2","jpg2"]},"image/jpeg":{source:"iana",compressible:!1,extensions:["jpeg","jpg","jpe"]},"image/jph":{source:"iana",extensions:["jph"]},"image/jphc":{source:"iana",extensions:["jhc"]},"image/jpm":{source:"iana",compressible:!1,extensions:["jpm"]},"image/jpx":{source:"iana",compressible:!1,extensions:["jpx","jpf"]},"image/jxr":{source:"iana",extensions:["jxr"]},"image/jxra":{source:"iana",extensions:["jxra"]},"image/jxrs":{source:"iana",extensions:["jxrs"]},"image/jxs":{source:"iana",extensions:["jxs"]},"image/jxsc":{source:"iana",extensions:["jxsc"]},"image/jxsi":{source:"iana",extensions:["jxsi"]},"image/jxss":{source:"iana",extensions:["jxss"]},"image/ktx":{source:"iana",extensions:["ktx"]},"image/ktx2":{source:"iana",extensions:["ktx2"]},"image/naplps":{source:"iana"},"image/pjpeg":{compressible:!1},"image/png":{source:"iana",compressible:!1,extensions:["png"]},"image/prs.btif":{source:"iana",extensions:["btif"]},"image/prs.pti":{source:"iana",extensions:["pti"]},"image/pwg-raster":{source:"iana"},"image/sgi":{source:"apache",extensions:["sgi"]},"image/svg+xml":{source:"iana",compressible:!0,extensions:["svg","svgz"]},"image/t38":{source:"iana",extensions:["t38"]},"image/tiff":{source:"iana",compressible:!1,extensions:["tif","tiff"]},"image/tiff-fx":{source:"iana",extensions:["tfx"]},"image/vnd.adobe.photoshop":{source:"iana",compressible:!0,extensions:["psd"]},"image/vnd.airzip.accelerator.azv":{source:"iana",extensions:["azv"]},"image/vnd.cns.inf2":{source:"iana"},"image/vnd.dece.graphic":{source:"iana",extensions:["uvi","uvvi","uvg","uvvg"]},"image/vnd.djvu":{source:"iana",extensions:["djvu","djv"]},"image/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"image/vnd.dwg":{source:"iana",extensions:["dwg"]},"image/vnd.dxf":{source:"iana",extensions:["dxf"]},"image/vnd.fastbidsheet":{source:"iana",extensions:["fbs"]},"image/vnd.fpx":{source:"iana",extensions:["fpx"]},"image/vnd.fst":{source:"iana",extensions:["fst"]},"image/vnd.fujixerox.edmics-mmr":{source:"iana",extensions:["mmr"]},"image/vnd.fujixerox.edmics-rlc":{source:"iana",extensions:["rlc"]},"image/vnd.globalgraphics.pgb":{source:"iana"},"image/vnd.microsoft.icon":{source:"iana",compressible:!0,extensions:["ico"]},"image/vnd.mix":{source:"iana"},"image/vnd.mozilla.apng":{source:"iana"},"image/vnd.ms-dds":{compressible:!0,extensions:["dds"]},"image/vnd.ms-modi":{source:"iana",extensions:["mdi"]},"image/vnd.ms-photo":{source:"apache",extensions:["wdp"]},"image/vnd.net-fpx":{source:"iana",extensions:["npx"]},"image/vnd.pco.b16":{source:"iana",extensions:["b16"]},"image/vnd.radiance":{source:"iana"},"image/vnd.sealed.png":{source:"iana"},"image/vnd.sealedmedia.softseal.gif":{source:"iana"},"image/vnd.sealedmedia.softseal.jpg":{source:"iana"},"image/vnd.svf":{source:"iana"},"image/vnd.tencent.tap":{source:"iana",extensions:["tap"]},"image/vnd.valve.source.texture":{source:"iana",extensions:["vtf"]},"image/vnd.wap.wbmp":{source:"iana",extensions:["wbmp"]},"image/vnd.xiff":{source:"iana",extensions:["xif"]},"image/vnd.zbrush.pcx":{source:"iana",extensions:["pcx"]},"image/webp":{source:"apache",extensions:["webp"]},"image/wmf":{source:"iana",extensions:["wmf"]},"image/x-3ds":{source:"apache",extensions:["3ds"]},"image/x-cmu-raster":{source:"apache",extensions:["ras"]},"image/x-cmx":{source:"apache",extensions:["cmx"]},"image/x-freehand":{source:"apache",extensions:["fh","fhc","fh4","fh5","fh7"]},"image/x-icon":{source:"apache",compressible:!0,extensions:["ico"]},"image/x-jng":{source:"nginx",extensions:["jng"]},"image/x-mrsid-image":{source:"apache",extensions:["sid"]},"image/x-ms-bmp":{source:"nginx",compressible:!0,extensions:["bmp"]},"image/x-pcx":{source:"apache",extensions:["pcx"]},"image/x-pict":{source:"apache",extensions:["pic","pct"]},"image/x-portable-anymap":{source:"apache",extensions:["pnm"]},"image/x-portable-bitmap":{source:"apache",extensions:["pbm"]},"image/x-portable-graymap":{source:"apache",extensions:["pgm"]},"image/x-portable-pixmap":{source:"apache",extensions:["ppm"]},"image/x-rgb":{source:"apache",extensions:["rgb"]},"image/x-tga":{source:"apache",extensions:["tga"]},"image/x-xbitmap":{source:"apache",extensions:["xbm"]},"image/x-xcf":{compressible:!1},"image/x-xpixmap":{source:"apache",extensions:["xpm"]},"image/x-xwindowdump":{source:"apache",extensions:["xwd"]},"message/cpim":{source:"iana"},"message/delivery-status":{source:"iana"},"message/disposition-notification":{source:"iana",extensions:["disposition-notification"]},"message/external-body":{source:"iana"},"message/feedback-report":{source:"iana"},"message/global":{source:"iana",extensions:["u8msg"]},"message/global-delivery-status":{source:"iana",extensions:["u8dsn"]},"message/global-disposition-notification":{source:"iana",extensions:["u8mdn"]},"message/global-headers":{source:"iana",extensions:["u8hdr"]},"message/http":{source:"iana",compressible:!1},"message/imdn+xml":{source:"iana",compressible:!0},"message/news":{source:"iana"},"message/partial":{source:"iana",compressible:!1},"message/rfc822":{source:"iana",compressible:!0,extensions:["eml","mime"]},"message/s-http":{source:"iana"},"message/sip":{source:"iana"},"message/sipfrag":{source:"iana"},"message/tracking-status":{source:"iana"},"message/vnd.si.simp":{source:"iana"},"message/vnd.wfa.wsc":{source:"iana",extensions:["wsc"]},"model/3mf":{source:"iana",extensions:["3mf"]},"model/e57":{source:"iana"},"model/gltf+json":{source:"iana",compressible:!0,extensions:["gltf"]},"model/gltf-binary":{source:"iana",compressible:!0,extensions:["glb"]},"model/iges":{source:"iana",compressible:!1,extensions:["igs","iges"]},"model/mesh":{source:"iana",compressible:!1,extensions:["msh","mesh","silo"]},"model/mtl":{source:"iana",extensions:["mtl"]},"model/obj":{source:"iana",extensions:["obj"]},"model/step":{source:"iana"},"model/step+xml":{source:"iana",compressible:!0,extensions:["stpx"]},"model/step+zip":{source:"iana",compressible:!1,extensions:["stpz"]},"model/step-xml+zip":{source:"iana",compressible:!1,extensions:["stpxz"]},"model/stl":{source:"iana",extensions:["stl"]},"model/vnd.collada+xml":{source:"iana",compressible:!0,extensions:["dae"]},"model/vnd.dwf":{source:"iana",extensions:["dwf"]},"model/vnd.flatland.3dml":{source:"iana"},"model/vnd.gdl":{source:"iana",extensions:["gdl"]},"model/vnd.gs-gdl":{source:"apache"},"model/vnd.gs.gdl":{source:"iana"},"model/vnd.gtw":{source:"iana",extensions:["gtw"]},"model/vnd.moml+xml":{source:"iana",compressible:!0},"model/vnd.mts":{source:"iana",extensions:["mts"]},"model/vnd.opengex":{source:"iana",extensions:["ogex"]},"model/vnd.parasolid.transmit.binary":{source:"iana",extensions:["x_b"]},"model/vnd.parasolid.transmit.text":{source:"iana",extensions:["x_t"]},"model/vnd.pytha.pyox":{source:"iana"},"model/vnd.rosette.annotated-data-model":{source:"iana"},"model/vnd.sap.vds":{source:"iana",extensions:["vds"]},"model/vnd.usdz+zip":{source:"iana",compressible:!1,extensions:["usdz"]},"model/vnd.valve.source.compiled-map":{source:"iana",extensions:["bsp"]},"model/vnd.vtu":{source:"iana",extensions:["vtu"]},"model/vrml":{source:"iana",compressible:!1,extensions:["wrl","vrml"]},"model/x3d+binary":{source:"apache",compressible:!1,extensions:["x3db","x3dbz"]},"model/x3d+fastinfoset":{source:"iana",extensions:["x3db"]},"model/x3d+vrml":{source:"apache",compressible:!1,extensions:["x3dv","x3dvz"]},"model/x3d+xml":{source:"iana",compressible:!0,extensions:["x3d","x3dz"]},"model/x3d-vrml":{source:"iana",extensions:["x3dv"]},"multipart/alternative":{source:"iana",compressible:!1},"multipart/appledouble":{source:"iana"},"multipart/byteranges":{source:"iana"},"multipart/digest":{source:"iana"},"multipart/encrypted":{source:"iana",compressible:!1},"multipart/form-data":{source:"iana",compressible:!1},"multipart/header-set":{source:"iana"},"multipart/mixed":{source:"iana"},"multipart/multilingual":{source:"iana"},"multipart/parallel":{source:"iana"},"multipart/related":{source:"iana",compressible:!1},"multipart/report":{source:"iana"},"multipart/signed":{source:"iana",compressible:!1},"multipart/vnd.bint.med-plus":{source:"iana"},"multipart/voice-message":{source:"iana"},"multipart/x-mixed-replace":{source:"iana"},"text/1d-interleaved-parityfec":{source:"iana"},"text/cache-manifest":{source:"iana",compressible:!0,extensions:["appcache","manifest"]},"text/calendar":{source:"iana",extensions:["ics","ifb"]},"text/calender":{compressible:!0},"text/cmd":{compressible:!0},"text/coffeescript":{extensions:["coffee","litcoffee"]},"text/cql":{source:"iana"},"text/cql-expression":{source:"iana"},"text/cql-identifier":{source:"iana"},"text/css":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["css"]},"text/csv":{source:"iana",compressible:!0,extensions:["csv"]},"text/csv-schema":{source:"iana"},"text/directory":{source:"iana"},"text/dns":{source:"iana"},"text/ecmascript":{source:"iana"},"text/encaprtp":{source:"iana"},"text/enriched":{source:"iana"},"text/fhirpath":{source:"iana"},"text/flexfec":{source:"iana"},"text/fwdred":{source:"iana"},"text/gff3":{source:"iana"},"text/grammar-ref-list":{source:"iana"},"text/html":{source:"iana",compressible:!0,extensions:["html","htm","shtml"]},"text/jade":{extensions:["jade"]},"text/javascript":{source:"iana",compressible:!0},"text/jcr-cnd":{source:"iana"},"text/jsx":{compressible:!0,extensions:["jsx"]},"text/less":{compressible:!0,extensions:["less"]},"text/markdown":{source:"iana",compressible:!0,extensions:["markdown","md"]},"text/mathml":{source:"nginx",extensions:["mml"]},"text/mdx":{compressible:!0,extensions:["mdx"]},"text/mizar":{source:"iana"},"text/n3":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["n3"]},"text/parameters":{source:"iana",charset:"UTF-8"},"text/parityfec":{source:"iana"},"text/plain":{source:"iana",compressible:!0,extensions:["txt","text","conf","def","list","log","in","ini"]},"text/provenance-notation":{source:"iana",charset:"UTF-8"},"text/prs.fallenstein.rst":{source:"iana"},"text/prs.lines.tag":{source:"iana",extensions:["dsc"]},"text/prs.prop.logic":{source:"iana"},"text/raptorfec":{source:"iana"},"text/red":{source:"iana"},"text/rfc822-headers":{source:"iana"},"text/richtext":{source:"iana",compressible:!0,extensions:["rtx"]},"text/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"text/rtp-enc-aescm128":{source:"iana"},"text/rtploopback":{source:"iana"},"text/rtx":{source:"iana"},"text/sgml":{source:"iana",extensions:["sgml","sgm"]},"text/shaclc":{source:"iana"},"text/shex":{source:"iana",extensions:["shex"]},"text/slim":{extensions:["slim","slm"]},"text/spdx":{source:"iana",extensions:["spdx"]},"text/strings":{source:"iana"},"text/stylus":{extensions:["stylus","styl"]},"text/t140":{source:"iana"},"text/tab-separated-values":{source:"iana",compressible:!0,extensions:["tsv"]},"text/troff":{source:"iana",extensions:["t","tr","roff","man","me","ms"]},"text/turtle":{source:"iana",charset:"UTF-8",extensions:["ttl"]},"text/ulpfec":{source:"iana"},"text/uri-list":{source:"iana",compressible:!0,extensions:["uri","uris","urls"]},"text/vcard":{source:"iana",compressible:!0,extensions:["vcard"]},"text/vnd.a":{source:"iana"},"text/vnd.abc":{source:"iana"},"text/vnd.ascii-art":{source:"iana"},"text/vnd.curl":{source:"iana",extensions:["curl"]},"text/vnd.curl.dcurl":{source:"apache",extensions:["dcurl"]},"text/vnd.curl.mcurl":{source:"apache",extensions:["mcurl"]},"text/vnd.curl.scurl":{source:"apache",extensions:["scurl"]},"text/vnd.debian.copyright":{source:"iana",charset:"UTF-8"},"text/vnd.dmclientscript":{source:"iana"},"text/vnd.dvb.subtitle":{source:"iana",extensions:["sub"]},"text/vnd.esmertec.theme-descriptor":{source:"iana",charset:"UTF-8"},"text/vnd.familysearch.gedcom":{source:"iana",extensions:["ged"]},"text/vnd.ficlab.flt":{source:"iana"},"text/vnd.fly":{source:"iana",extensions:["fly"]},"text/vnd.fmi.flexstor":{source:"iana",extensions:["flx"]},"text/vnd.gml":{source:"iana"},"text/vnd.graphviz":{source:"iana",extensions:["gv"]},"text/vnd.hans":{source:"iana"},"text/vnd.hgl":{source:"iana"},"text/vnd.in3d.3dml":{source:"iana",extensions:["3dml"]},"text/vnd.in3d.spot":{source:"iana",extensions:["spot"]},"text/vnd.iptc.newsml":{source:"iana"},"text/vnd.iptc.nitf":{source:"iana"},"text/vnd.latex-z":{source:"iana"},"text/vnd.motorola.reflex":{source:"iana"},"text/vnd.ms-mediapackage":{source:"iana"},"text/vnd.net2phone.commcenter.command":{source:"iana"},"text/vnd.radisys.msml-basic-layout":{source:"iana"},"text/vnd.senx.warpscript":{source:"iana"},"text/vnd.si.uricatalogue":{source:"iana"},"text/vnd.sosi":{source:"iana"},"text/vnd.sun.j2me.app-descriptor":{source:"iana",charset:"UTF-8",extensions:["jad"]},"text/vnd.trolltech.linguist":{source:"iana",charset:"UTF-8"},"text/vnd.wap.si":{source:"iana"},"text/vnd.wap.sl":{source:"iana"},"text/vnd.wap.wml":{source:"iana",extensions:["wml"]},"text/vnd.wap.wmlscript":{source:"iana",extensions:["wmls"]},"text/vtt":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["vtt"]},"text/x-asm":{source:"apache",extensions:["s","asm"]},"text/x-c":{source:"apache",extensions:["c","cc","cxx","cpp","h","hh","dic"]},"text/x-component":{source:"nginx",extensions:["htc"]},"text/x-fortran":{source:"apache",extensions:["f","for","f77","f90"]},"text/x-gwt-rpc":{compressible:!0},"text/x-handlebars-template":{extensions:["hbs"]},"text/x-java-source":{source:"apache",extensions:["java"]},"text/x-jquery-tmpl":{compressible:!0},"text/x-lua":{extensions:["lua"]},"text/x-markdown":{compressible:!0,extensions:["mkd"]},"text/x-nfo":{source:"apache",extensions:["nfo"]},"text/x-opml":{source:"apache",extensions:["opml"]},"text/x-org":{compressible:!0,extensions:["org"]},"text/x-pascal":{source:"apache",extensions:["p","pas"]},"text/x-processing":{compressible:!0,extensions:["pde"]},"text/x-sass":{extensions:["sass"]},"text/x-scss":{extensions:["scss"]},"text/x-setext":{source:"apache",extensions:["etx"]},"text/x-sfv":{source:"apache",extensions:["sfv"]},"text/x-suse-ymp":{compressible:!0,extensions:["ymp"]},"text/x-uuencode":{source:"apache",extensions:["uu"]},"text/x-vcalendar":{source:"apache",extensions:["vcs"]},"text/x-vcard":{source:"apache",extensions:["vcf"]},"text/xml":{source:"iana",compressible:!0,extensions:["xml"]},"text/xml-external-parsed-entity":{source:"iana"},"text/yaml":{compressible:!0,extensions:["yaml","yml"]},"video/1d-interleaved-parityfec":{source:"iana"},"video/3gpp":{source:"iana",extensions:["3gp","3gpp"]},"video/3gpp-tt":{source:"iana"},"video/3gpp2":{source:"iana",extensions:["3g2"]},"video/av1":{source:"iana"},"video/bmpeg":{source:"iana"},"video/bt656":{source:"iana"},"video/celb":{source:"iana"},"video/dv":{source:"iana"},"video/encaprtp":{source:"iana"},"video/ffv1":{source:"iana"},"video/flexfec":{source:"iana"},"video/h261":{source:"iana",extensions:["h261"]},"video/h263":{source:"iana",extensions:["h263"]},"video/h263-1998":{source:"iana"},"video/h263-2000":{source:"iana"},"video/h264":{source:"iana",extensions:["h264"]},"video/h264-rcdo":{source:"iana"},"video/h264-svc":{source:"iana"},"video/h265":{source:"iana"},"video/iso.segment":{source:"iana",extensions:["m4s"]},"video/jpeg":{source:"iana",extensions:["jpgv"]},"video/jpeg2000":{source:"iana"},"video/jpm":{source:"apache",extensions:["jpm","jpgm"]},"video/jxsv":{source:"iana"},"video/mj2":{source:"iana",extensions:["mj2","mjp2"]},"video/mp1s":{source:"iana"},"video/mp2p":{source:"iana"},"video/mp2t":{source:"iana",extensions:["ts"]},"video/mp4":{source:"iana",compressible:!1,extensions:["mp4","mp4v","mpg4"]},"video/mp4v-es":{source:"iana"},"video/mpeg":{source:"iana",compressible:!1,extensions:["mpeg","mpg","mpe","m1v","m2v"]},"video/mpeg4-generic":{source:"iana"},"video/mpv":{source:"iana"},"video/nv":{source:"iana"},"video/ogg":{source:"iana",compressible:!1,extensions:["ogv"]},"video/parityfec":{source:"iana"},"video/pointer":{source:"iana"},"video/quicktime":{source:"iana",compressible:!1,extensions:["qt","mov"]},"video/raptorfec":{source:"iana"},"video/raw":{source:"iana"},"video/rtp-enc-aescm128":{source:"iana"},"video/rtploopback":{source:"iana"},"video/rtx":{source:"iana"},"video/scip":{source:"iana"},"video/smpte291":{source:"iana"},"video/smpte292m":{source:"iana"},"video/ulpfec":{source:"iana"},"video/vc1":{source:"iana"},"video/vc2":{source:"iana"},"video/vnd.cctv":{source:"iana"},"video/vnd.dece.hd":{source:"iana",extensions:["uvh","uvvh"]},"video/vnd.dece.mobile":{source:"iana",extensions:["uvm","uvvm"]},"video/vnd.dece.mp4":{source:"iana"},"video/vnd.dece.pd":{source:"iana",extensions:["uvp","uvvp"]},"video/vnd.dece.sd":{source:"iana",extensions:["uvs","uvvs"]},"video/vnd.dece.video":{source:"iana",extensions:["uvv","uvvv"]},"video/vnd.directv.mpeg":{source:"iana"},"video/vnd.directv.mpeg-tts":{source:"iana"},"video/vnd.dlna.mpeg-tts":{source:"iana"},"video/vnd.dvb.file":{source:"iana",extensions:["dvb"]},"video/vnd.fvt":{source:"iana",extensions:["fvt"]},"video/vnd.hns.video":{source:"iana"},"video/vnd.iptvforum.1dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.1dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.2dparityfec-1010":{source:"iana"},"video/vnd.iptvforum.2dparityfec-2005":{source:"iana"},"video/vnd.iptvforum.ttsavc":{source:"iana"},"video/vnd.iptvforum.ttsmpeg2":{source:"iana"},"video/vnd.motorola.video":{source:"iana"},"video/vnd.motorola.videop":{source:"iana"},"video/vnd.mpegurl":{source:"iana",extensions:["mxu","m4u"]},"video/vnd.ms-playready.media.pyv":{source:"iana",extensions:["pyv"]},"video/vnd.nokia.interleaved-multimedia":{source:"iana"},"video/vnd.nokia.mp4vr":{source:"iana"},"video/vnd.nokia.videovoip":{source:"iana"},"video/vnd.objectvideo":{source:"iana"},"video/vnd.radgamettools.bink":{source:"iana"},"video/vnd.radgamettools.smacker":{source:"iana"},"video/vnd.sealed.mpeg1":{source:"iana"},"video/vnd.sealed.mpeg4":{source:"iana"},"video/vnd.sealed.swf":{source:"iana"},"video/vnd.sealedmedia.softseal.mov":{source:"iana"},"video/vnd.uvvu.mp4":{source:"iana",extensions:["uvu","uvvu"]},"video/vnd.vivo":{source:"iana",extensions:["viv"]},"video/vnd.youtube.yt":{source:"iana"},"video/vp8":{source:"iana"},"video/vp9":{source:"iana"},"video/webm":{source:"apache",compressible:!1,extensions:["webm"]},"video/x-f4v":{source:"apache",extensions:["f4v"]},"video/x-fli":{source:"apache",extensions:["fli"]},"video/x-flv":{source:"apache",compressible:!1,extensions:["flv"]},"video/x-m4v":{source:"apache",extensions:["m4v"]},"video/x-matroska":{source:"apache",compressible:!1,extensions:["mkv","mk3d","mks"]},"video/x-mng":{source:"apache",extensions:["mng"]},"video/x-ms-asf":{source:"apache",extensions:["asf","asx"]},"video/x-ms-vob":{source:"apache",extensions:["vob"]},"video/x-ms-wm":{source:"apache",extensions:["wm"]},"video/x-ms-wmv":{source:"apache",compressible:!1,extensions:["wmv"]},"video/x-ms-wmx":{source:"apache",extensions:["wmx"]},"video/x-ms-wvx":{source:"apache",extensions:["wvx"]},"video/x-msvideo":{source:"apache",extensions:["avi"]},"video/x-sgi-movie":{source:"apache",extensions:["movie"]},"video/x-smv":{source:"apache",extensions:["smv"]},"x-conference/x-cooltalk":{source:"apache",extensions:["ice"]},"x-shader/x-fragment":{compressible:!0},"x-shader/x-vertex":{compressible:!0}}});var ll=U((pE,cl)=>{"use strict";cl.exports=ol()});var ul=U(Ke=>{"use strict";var Tr=ll(),ag=V("path").extname,pl=/^\s*([^;\s]*)(?:;|\s|$)/,og=/^text\//i;Ke.charset=dl;Ke.charsets={lookup:dl};Ke.contentType=cg;Ke.extension=lg;Ke.extensions=Object.create(null);Ke.lookup=pg;Ke.types=Object.create(null);dg(Ke.extensions,Ke.types);function dl(n){if(!n||typeof n!="string")return!1;var e=pl.exec(n),t=e&&Tr[e[1].toLowerCase()];return t&&t.charset?t.charset:e&&og.test(e[1])?"UTF-8":!1}function cg(n){if(!n||typeof n!="string")return!1;var e=n.indexOf("/")===-1?Ke.lookup(n):n;if(!e)return!1;if(e.indexOf("charset")===-1){var t=Ke.charset(e);t&&(e+="; charset="+t.toLowerCase())}return e}function lg(n){if(!n||typeof n!="string")return!1;var e=pl.exec(n),t=e&&Ke.extensions[e[1].toLowerCase()];return!t||!t.length?!1:t[0]}function pg(n){if(!n||typeof n!="string")return!1;var e=ag("x."+n).toLowerCase().substr(1);return e&&Ke.types[e]||!1}function dg(n,e){var t=["nginx","apache",void 0,"iana"];Object.keys(Tr).forEach(function(r){var i=Tr[r],a=i.extensions;if(!(!a||!a.length)){n[r]=a;for(var o=0;o<a.length;o++){var c=a[o];if(e[c]){var l=t.indexOf(Tr[e[c]].source),p=t.indexOf(i.source);if(e[c]!=="application/octet-stream"&&(l>p||l===p&&e[c].substr(0,12)==="application/"))continue}e[c]=r}}})}});var ml=U((uE,hl)=>{"use strict";hl.exports=ug;function ug(n){var e=typeof setImmediate=="function"?setImmediate:typeof process=="object"&&typeof process.nextTick=="function"?process.nextTick:null;e?e(n):setTimeout(n,0)}});var ma=U((hE,gl)=>{"use strict";var fl=ml();gl.exports=hg;function hg(n){var e=!1;return fl(function(){e=!0}),function(s,r){e?n(s,r):fl(function(){n(s,r)})}}});var fa=U((mE,_l)=>{"use strict";_l.exports=mg;function mg(n){Object.keys(n.jobs).forEach(fg.bind(n)),n.jobs={}}function fg(n){typeof this.jobs[n]=="function"&&this.jobs[n]()}});var ga=U((fE,vl)=>{"use strict";var yl=ma(),gg=fa();vl.exports=_g;function _g(n,e,t,s){var r=t.keyedList?t.keyedList[t.index]:t.index;t.jobs[r]=yg(e,r,n[r],function(i,a){r in t.jobs&&(delete t.jobs[r],i?gg(t):t.results[r]=a,s(i,t.results))})}function yg(n,e,t,s){var r;return n.length==2?r=n(t,yl(s)):r=n(t,e,yl(s)),r}});var _a=U((gE,bl)=>{"use strict";bl.exports=vg;function vg(n,e){var t=!Array.isArray(n),s={index:0,keyedList:t||e?Object.keys(n):null,jobs:{},results:t?{}:[],size:t?Object.keys(n).length:n.length};return e&&s.keyedList.sort(t?e:function(r,i){return e(n[r],n[i])}),s}});var ya=U((_E,wl)=>{"use strict";var bg=fa(),wg=ma();wl.exports=xg;function xg(n){Object.keys(this.jobs).length&&(this.index=this.size,bg(this),wg(n)(null,this.results))}});var El=U((yE,xl)=>{"use strict";var Eg=ga(),Cg=_a(),Sg=ya();xl.exports=Rg;function Rg(n,e,t){for(var s=Cg(n);s.index<(s.keyedList||n).length;)Eg(n,e,s,function(r,i){if(r){t(r,i);return}if(Object.keys(s.jobs).length===0){t(null,s.results);return}}),s.index++;return Sg.bind(s,t)}});var va=U((vE,Ur)=>{"use strict";var Cl=ga(),Ag=_a(),kg=ya();Ur.exports=Pg;Ur.exports.ascending=Sl;Ur.exports.descending=Mg;function Pg(n,e,t,s){var r=Ag(n,t);return Cl(n,e,r,function i(a,o){if(a){s(a,o);return}if(r.index++,r.index<(r.keyedList||n).length){Cl(n,e,r,i);return}s(null,r.results)}),kg.bind(r,s)}function Sl(n,e){return n<e?-1:n>e?1:0}function Mg(n,e){return-1*Sl(n,e)}});var Al=U((bE,Rl)=>{"use strict";var Ig=va();Rl.exports=Tg;function Tg(n,e,t){return Ig(n,e,null,t)}});var Pl=U((wE,kl)=>{"use strict";kl.exports={parallel:El(),serial:Al(),serialOrdered:va()}});var ba=U((xE,Ml)=>{"use strict";Ml.exports=Object});var Tl=U((EE,Il)=>{"use strict";Il.exports=Error});var Dl=U((CE,Ul)=>{"use strict";Ul.exports=EvalError});var Ol=U((SE,Ll)=>{"use strict";Ll.exports=RangeError});var Bl=U((RE,Fl)=>{"use strict";Fl.exports=ReferenceError});var Gl=U((AE,jl)=>{"use strict";jl.exports=SyntaxError});var Dr=U((kE,Nl)=>{"use strict";Nl.exports=TypeError});var zl=U((PE,ql)=>{"use strict";ql.exports=URIError});var Wl=U((ME,$l)=>{"use strict";$l.exports=Math.abs});var Kl=U((IE,Vl)=>{"use strict";Vl.exports=Math.floor});var Ql=U((TE,Hl)=>{"use strict";Hl.exports=Math.max});var Yl=U((UE,Jl)=>{"use strict";Jl.exports=Math.min});var Zl=U((DE,Xl)=>{"use strict";Xl.exports=Math.pow});var tp=U((LE,ep)=>{"use strict";ep.exports=Math.round});var np=U((OE,sp)=>{"use strict";sp.exports=Number.isNaN||function(e){return e!==e}});var ip=U((FE,rp)=>{"use strict";var Ug=np();rp.exports=function(e){return Ug(e)||e===0?e:e<0?-1:1}});var op=U((BE,ap)=>{"use strict";ap.exports=Object.getOwnPropertyDescriptor});var wa=U((jE,cp)=>{"use strict";var Lr=op();if(Lr)try{Lr([],"length")}catch{Lr=null}cp.exports=Lr});var pp=U((GE,lp)=>{"use strict";var Or=Object.defineProperty||!1;if(Or)try{Or({},"a",{value:1})}catch{Or=!1}lp.exports=Or});var xa=U((NE,dp)=>{"use strict";dp.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},t=Symbol("test"),s=Object(t);if(typeof t=="string"||Object.prototype.toString.call(t)!=="[object Symbol]"||Object.prototype.toString.call(s)!=="[object Symbol]")return!1;var r=42;e[t]=r;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==r||o.enumerable!==!0)return!1}return!0}});var mp=U((qE,hp)=>{"use strict";var up=typeof Symbol<"u"&&Symbol,Dg=xa();hp.exports=function(){return typeof up!="function"||typeof Symbol!="function"||typeof up("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Dg()}});var Ea=U((zE,fp)=>{"use strict";fp.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var Ca=U(($E,gp)=>{"use strict";var Lg=ba();gp.exports=Lg.getPrototypeOf||null});var vp=U((WE,yp)=>{"use strict";var Og="Function.prototype.bind called on incompatible ",Fg=Object.prototype.toString,Bg=Math.max,jg="[object Function]",_p=function(e,t){for(var s=[],r=0;r<e.length;r+=1)s[r]=e[r];for(var i=0;i<t.length;i+=1)s[i+e.length]=t[i];return s},Gg=function(e,t){for(var s=[],r=t||0,i=0;r<e.length;r+=1,i+=1)s[i]=e[r];return s},Ng=function(n,e){for(var t="",s=0;s<n.length;s+=1)t+=n[s],s+1<n.length&&(t+=e);return t};yp.exports=function(e){var t=this;if(typeof t!="function"||Fg.apply(t)!==jg)throw new TypeError(Og+t);for(var s=Gg(arguments,1),r,i=function(){if(this instanceof r){var p=t.apply(this,_p(s,arguments));return Object(p)===p?p:this}return t.apply(e,_p(s,arguments))},a=Bg(0,t.length-s.length),o=[],c=0;c<a;c++)o[c]="$"+c;if(r=Function("binder","return function ("+Ng(o,",")+"){ return binder.apply(this,arguments); }")(i),t.prototype){var l=function(){};l.prototype=t.prototype,r.prototype=new l,l.prototype=null}return r}});var _n=U((VE,bp)=>{"use strict";var qg=vp();bp.exports=Function.prototype.bind||qg});var Fr=U((KE,wp)=>{"use strict";wp.exports=Function.prototype.call});var Sa=U((HE,xp)=>{"use strict";xp.exports=Function.prototype.apply});var Cp=U((QE,Ep)=>{"use strict";Ep.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var Rp=U((JE,Sp)=>{"use strict";var zg=_n(),$g=Sa(),Wg=Fr(),Vg=Cp();Sp.exports=Vg||zg.call(Wg,$g)});var kp=U((YE,Ap)=>{"use strict";var Kg=_n(),Hg=Dr(),Qg=Fr(),Jg=Rp();Ap.exports=function(e){if(e.length<1||typeof e[0]!="function")throw new Hg("a function is required");return Jg(Kg,Qg,e)}});var Dp=U((XE,Up)=>{"use strict";var Yg=kp(),Pp=wa(),Ip;try{Ip=[].__proto__===Array.prototype}catch(n){if(!n||typeof n!="object"||!("code"in n)||n.code!=="ERR_PROTO_ACCESS")throw n}var Ra=!!Ip&&Pp&&Pp(Object.prototype,"__proto__"),Tp=Object,Mp=Tp.getPrototypeOf;Up.exports=Ra&&typeof Ra.get=="function"?Yg([Ra.get]):typeof Mp=="function"?function(e){return Mp(e==null?e:Tp(e))}:!1});var jp=U((ZE,Bp)=>{"use strict";var Lp=Ea(),Op=Ca(),Fp=Dp();Bp.exports=Lp?function(e){return Lp(e)}:Op?function(e){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("getProto: not an object");return Op(e)}:Fp?function(e){return Fp(e)}:null});var Br=U((eC,Gp)=>{"use strict";var Xg=Function.prototype.call,Zg=Object.prototype.hasOwnProperty,e_=_n();Gp.exports=e_.call(Xg,Zg)});var Kp=U((tC,Vp)=>{"use strict";var ne,t_=ba(),s_=Tl(),n_=Dl(),r_=Ol(),i_=Bl(),Ts=Gl(),Is=Dr(),a_=zl(),o_=Wl(),c_=Kl(),l_=Ql(),p_=Yl(),d_=Zl(),u_=tp(),h_=ip(),$p=Function,Aa=function(n){try{return $p('"use strict"; return ('+n+").constructor;")()}catch{}},yn=wa(),m_=pp(),ka=function(){throw new Is},f_=yn?(function(){try{return arguments.callee,ka}catch{try{return yn(arguments,"callee").get}catch{return ka}}})():ka,Ps=mp()(),Pe=jp(),g_=Ca(),__=Ea(),Wp=Sa(),vn=Fr(),Ms={},y_=typeof Uint8Array>"u"||!Pe?ne:Pe(Uint8Array),rs={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?ne:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?ne:ArrayBuffer,"%ArrayIteratorPrototype%":Ps&&Pe?Pe([][Symbol.iterator]()):ne,"%AsyncFromSyncIteratorPrototype%":ne,"%AsyncFunction%":Ms,"%AsyncGenerator%":Ms,"%AsyncGeneratorFunction%":Ms,"%AsyncIteratorPrototype%":Ms,"%Atomics%":typeof Atomics>"u"?ne:Atomics,"%BigInt%":typeof BigInt>"u"?ne:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?ne:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?ne:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?ne:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":s_,"%eval%":eval,"%EvalError%":n_,"%Float16Array%":typeof Float16Array>"u"?ne:Float16Array,"%Float32Array%":typeof Float32Array>"u"?ne:Float32Array,"%Float64Array%":typeof Float64Array>"u"?ne:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?ne:FinalizationRegistry,"%Function%":$p,"%GeneratorFunction%":Ms,"%Int8Array%":typeof Int8Array>"u"?ne:Int8Array,"%Int16Array%":typeof Int16Array>"u"?ne:Int16Array,"%Int32Array%":typeof Int32Array>"u"?ne:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Ps&&Pe?Pe(Pe([][Symbol.iterator]())):ne,"%JSON%":typeof JSON=="object"?JSON:ne,"%Map%":typeof Map>"u"?ne:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Ps||!Pe?ne:Pe(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":t_,"%Object.getOwnPropertyDescriptor%":yn,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?ne:Promise,"%Proxy%":typeof Proxy>"u"?ne:Proxy,"%RangeError%":r_,"%ReferenceError%":i_,"%Reflect%":typeof Reflect>"u"?ne:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?ne:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Ps||!Pe?ne:Pe(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?ne:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Ps&&Pe?Pe(""[Symbol.iterator]()):ne,"%Symbol%":Ps?Symbol:ne,"%SyntaxError%":Ts,"%ThrowTypeError%":f_,"%TypedArray%":y_,"%TypeError%":Is,"%Uint8Array%":typeof Uint8Array>"u"?ne:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?ne:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?ne:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?ne:Uint32Array,"%URIError%":a_,"%WeakMap%":typeof WeakMap>"u"?ne:WeakMap,"%WeakRef%":typeof WeakRef>"u"?ne:WeakRef,"%WeakSet%":typeof WeakSet>"u"?ne:WeakSet,"%Function.prototype.call%":vn,"%Function.prototype.apply%":Wp,"%Object.defineProperty%":m_,"%Object.getPrototypeOf%":g_,"%Math.abs%":o_,"%Math.floor%":c_,"%Math.max%":l_,"%Math.min%":p_,"%Math.pow%":d_,"%Math.round%":u_,"%Math.sign%":h_,"%Reflect.getPrototypeOf%":__};if(Pe)try{null.error}catch(n){Np=Pe(Pe(n)),rs["%Error.prototype%"]=Np}var Np,v_=function n(e){var t;if(e==="%AsyncFunction%")t=Aa("async function () {}");else if(e==="%GeneratorFunction%")t=Aa("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Aa("async function* () {}");else if(e==="%AsyncGenerator%"){var s=n("%AsyncGeneratorFunction%");s&&(t=s.prototype)}else if(e==="%AsyncIteratorPrototype%"){var r=n("%AsyncGenerator%");r&&Pe&&(t=Pe(r.prototype))}return rs[e]=t,t},qp={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},bn=_n(),jr=Br(),b_=bn.call(vn,Array.prototype.concat),w_=bn.call(Wp,Array.prototype.splice),zp=bn.call(vn,String.prototype.replace),Gr=bn.call(vn,String.prototype.slice),x_=bn.call(vn,RegExp.prototype.exec),E_=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,C_=/\\(\\)?/g,S_=function(e){var t=Gr(e,0,1),s=Gr(e,-1);if(t==="%"&&s!=="%")throw new Ts("invalid intrinsic syntax, expected closing `%`");if(s==="%"&&t!=="%")throw new Ts("invalid intrinsic syntax, expected opening `%`");var r=[];return zp(e,E_,function(i,a,o,c){r[r.length]=o?zp(c,C_,"$1"):a||i}),r},R_=function(e,t){var s=e,r;if(jr(qp,s)&&(r=qp[s],s="%"+r[0]+"%"),jr(rs,s)){var i=rs[s];if(i===Ms&&(i=v_(s)),typeof i>"u"&&!t)throw new Is("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:s,value:i}}throw new Ts("intrinsic "+e+" does not exist!")};Vp.exports=function(e,t){if(typeof e!="string"||e.length===0)throw new Is("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Is('"allowMissing" argument must be a boolean');if(x_(/^%?[^%]*%?$/,e)===null)throw new Ts("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var s=S_(e),r=s.length>0?s[0]:"",i=R_("%"+r+"%",t),a=i.name,o=i.value,c=!1,l=i.alias;l&&(r=l[0],w_(s,b_([0,1],l)));for(var p=1,d=!0;p<s.length;p+=1){var u=s[p],h=Gr(u,0,1),m=Gr(u,-1);if((h==='"'||h==="'"||h==="`"||m==='"'||m==="'"||m==="`")&&h!==m)throw new Ts("property names with quotes must have matching quotes");if((u==="constructor"||!d)&&(c=!0),r+="."+u,a="%"+r+"%",jr(rs,a))o=rs[a];else if(o!=null){if(!(u in o)){if(!t)throw new Is("base intrinsic for "+e+" exists, but the property is not available.");return}if(yn&&p+1>=s.length){var g=yn(o,u);d=!!g,d&&"get"in g&&!("originalValue"in g.get)?o=g.get:o=o[u]}else d=jr(o,u),o=o[u];d&&!c&&(rs[a]=o)}}return o}});var Qp=U((sC,Hp)=>{"use strict";var A_=xa();Hp.exports=function(){return A_()&&!!Symbol.toStringTag}});var Xp=U((nC,Yp)=>{"use strict";var k_=Kp(),Jp=k_("%Object.defineProperty%",!0),P_=Qp()(),M_=Br(),I_=Dr(),Nr=P_?Symbol.toStringTag:null;Yp.exports=function(e,t){var s=arguments.length>2&&!!arguments[2]&&arguments[2].force,r=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof s<"u"&&typeof s!="boolean"||typeof r<"u"&&typeof r!="boolean")throw new I_("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");Nr&&(s||!M_(e,Nr))&&(Jp?Jp(e,Nr,{configurable:!r,enumerable:!1,value:t,writable:!1}):e[Nr]=t)}});var ed=U((rC,Zp)=>{"use strict";Zp.exports=function(n,e){return Object.keys(e).forEach(function(t){n[t]=n[t]||e[t]}),n}});var Ua=U((iC,td)=>{"use strict";var Ta=al(),T_=V("util"),Pa=V("path"),U_=V("http"),D_=(jt(),un(gn)),L_=V("url").parse,O_=V("fs"),F_=V("stream").Stream,B_=V("crypto"),Ma=ul(),j_=Pl(),G_=Xp(),Gt=Br(),Ia=ed();function oe(n){if(!(this instanceof oe))return new oe(n);this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],Ta.call(this),n=n||{};for(var e in n)this[e]=n[e]}T_.inherits(oe,Ta);oe.LINE_BREAK=`\r
2
+ `;oe.DEFAULT_CONTENT_TYPE="application/octet-stream";oe.prototype.append=function(n,e,t){t=t||{},typeof t=="string"&&(t={filename:t});var s=Ta.prototype.append.bind(this);if((typeof e=="number"||e==null)&&(e=String(e)),Array.isArray(e)){this._error(new Error("Arrays are not supported."));return}var r=this._multiPartHeader(n,e,t),i=this._multiPartFooter();s(r),s(e),s(i),this._trackLength(r,e,t)};oe.prototype._trackLength=function(n,e,t){var s=0;t.knownLength!=null?s+=Number(t.knownLength):Buffer.isBuffer(e)?s=e.length:typeof e=="string"&&(s=Buffer.byteLength(e)),this._valueLength+=s,this._overheadLength+=Buffer.byteLength(n)+oe.LINE_BREAK.length,!(!e||!e.path&&!(e.readable&&Gt(e,"httpVersion"))&&!(e instanceof F_))&&(t.knownLength||this._valuesToMeasure.push(e))};oe.prototype._lengthRetriever=function(n,e){Gt(n,"fd")?n.end!=null&&n.end!=1/0&&n.start!=null?e(null,n.end+1-(n.start?n.start:0)):O_.stat(n.path,function(t,s){if(t){e(t);return}var r=s.size-(n.start?n.start:0);e(null,r)}):Gt(n,"httpVersion")?e(null,Number(n.headers["content-length"])):Gt(n,"httpModule")?(n.on("response",function(t){n.pause(),e(null,Number(t.headers["content-length"]))}),n.resume()):e("Unknown stream")};oe.prototype._multiPartHeader=function(n,e,t){if(typeof t.header=="string")return t.header;var s=this._getContentDisposition(e,t),r=this._getContentType(e,t),i="",a={"Content-Disposition":["form-data",'name="'+n+'"'].concat(s||[]),"Content-Type":[].concat(r||[])};typeof t.header=="object"&&Ia(a,t.header);var o;for(var c in a)if(Gt(a,c)){if(o=a[c],o==null)continue;Array.isArray(o)||(o=[o]),o.length&&(i+=c+": "+o.join("; ")+oe.LINE_BREAK)}return"--"+this.getBoundary()+oe.LINE_BREAK+i+oe.LINE_BREAK};oe.prototype._getContentDisposition=function(n,e){var t;if(typeof e.filepath=="string"?t=Pa.normalize(e.filepath).replace(/\\/g,"/"):e.filename||n&&(n.name||n.path)?t=Pa.basename(e.filename||n&&(n.name||n.path)):n&&n.readable&&Gt(n,"httpVersion")&&(t=Pa.basename(n.client._httpMessage.path||"")),t)return'filename="'+t+'"'};oe.prototype._getContentType=function(n,e){var t=e.contentType;return!t&&n&&n.name&&(t=Ma.lookup(n.name)),!t&&n&&n.path&&(t=Ma.lookup(n.path)),!t&&n&&n.readable&&Gt(n,"httpVersion")&&(t=n.headers["content-type"]),!t&&(e.filepath||e.filename)&&(t=Ma.lookup(e.filepath||e.filename)),!t&&n&&typeof n=="object"&&(t=oe.DEFAULT_CONTENT_TYPE),t};oe.prototype._multiPartFooter=function(){return function(n){var e=oe.LINE_BREAK,t=this._streams.length===0;t&&(e+=this._lastBoundary()),n(e)}.bind(this)};oe.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+oe.LINE_BREAK};oe.prototype.getHeaders=function(n){var e,t={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(e in n)Gt(n,e)&&(t[e.toLowerCase()]=n[e]);return t};oe.prototype.setBoundary=function(n){if(typeof n!="string")throw new TypeError("FormData boundary must be a string");this._boundary=n};oe.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary};oe.prototype.getBuffer=function(){for(var n=new Buffer.alloc(0),e=this.getBoundary(),t=0,s=this._streams.length;t<s;t++)typeof this._streams[t]!="function"&&(Buffer.isBuffer(this._streams[t])?n=Buffer.concat([n,this._streams[t]]):n=Buffer.concat([n,Buffer.from(this._streams[t])]),(typeof this._streams[t]!="string"||this._streams[t].substring(2,e.length+2)!==e)&&(n=Buffer.concat([n,Buffer.from(oe.LINE_BREAK)])));return Buffer.concat([n,Buffer.from(this._lastBoundary())])};oe.prototype._generateBoundary=function(){this._boundary="--------------------------"+B_.randomBytes(12).toString("hex")};oe.prototype.getLengthSync=function(){var n=this._overheadLength+this._valueLength;return this._streams.length&&(n+=this._lastBoundary().length),this.hasKnownLength()||this._error(new Error("Cannot calculate proper length in synchronous way.")),n};oe.prototype.hasKnownLength=function(){var n=!0;return this._valuesToMeasure.length&&(n=!1),n};oe.prototype.getLength=function(n){var e=this._overheadLength+this._valueLength;if(this._streams.length&&(e+=this._lastBoundary().length),!this._valuesToMeasure.length){process.nextTick(n.bind(this,null,e));return}j_.parallel(this._valuesToMeasure,this._lengthRetriever,function(t,s){if(t){n(t);return}s.forEach(function(r){e+=r}),n(null,e)})};oe.prototype.submit=function(n,e){var t,s,r={method:"post"};return typeof n=="string"?(n=L_(n),s=Ia({port:n.port,path:n.pathname,host:n.hostname,protocol:n.protocol},r)):(s=Ia(n,r),s.port||(s.port=s.protocol==="https:"?443:80)),s.headers=this.getHeaders(n.headers),s.protocol==="https:"?t=D_.request(s):t=U_.request(s),this.getLength(function(i,a){if(i&&i!=="Unknown stream"){this._error(i);return}if(a&&t.setHeader("Content-Length",a),this.pipe(t),e){var o,c=function(l,p){return t.removeListener("error",c),t.removeListener("response",o),e.call(this,l,p)};o=c.bind(this,null),t.on("error",c),t.on("response",o)}}.bind(this)),t};oe.prototype._error=function(n){this.error||(this.error=n,this.pause(),this.emit("error",n))};oe.prototype.toString=function(){return"[object FormData]"};G_(oe,"FormData");td.exports=oe});var vd=U(yd=>{"use strict";var ry=V("url").parse,iy={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443},ay=String.prototype.endsWith||function(n){return n.length<=this.length&&this.indexOf(n,this.length-n.length)!==-1};function oy(n){var e=typeof n=="string"?ry(n):n||{},t=e.protocol,s=e.host,r=e.port;if(typeof s!="string"||!s||typeof t!="string"||(t=t.split(":",1)[0],s=s.replace(/:\d*$/,""),r=parseInt(r)||iy[t]||0,!cy(s,r)))return"";var i=Os("npm_config_"+t+"_proxy")||Os(t+"_proxy")||Os("npm_config_proxy")||Os("all_proxy");return i&&i.indexOf("://")===-1&&(i=t+"://"+i),i}function cy(n,e){var t=(Os("npm_config_no_proxy")||Os("no_proxy")).toLowerCase();return t?t==="*"?!1:t.split(/[,\s]/).every(function(s){if(!s)return!0;var r=s.match(/^(.+):(\d+)$/),i=r?r[1]:s,a=r?parseInt(r[2]):0;return a&&a!==e?!0:/^[.*]/.test(i)?(i.charAt(0)==="*"&&(i=i.slice(1)),!ay.call(n,i)):n!==i}):!0}function Os(n){return process.env[n.toLowerCase()]||process.env[n.toUpperCase()]||""}yd.getProxyForUrl=oy});var wd=U((a0,bd)=>{"use strict";var Fs=1e3,Bs=Fs*60,js=Bs*60,os=js*24,ly=os*7,py=os*365.25;bd.exports=function(n,e){e=e||{};var t=typeof n;if(t==="string"&&n.length>0)return dy(n);if(t==="number"&&isFinite(n))return e.long?hy(n):uy(n);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(n))};function dy(n){if(n=String(n),!(n.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(n);if(e){var t=parseFloat(e[1]),s=(e[2]||"ms").toLowerCase();switch(s){case"years":case"year":case"yrs":case"yr":case"y":return t*py;case"weeks":case"week":case"w":return t*ly;case"days":case"day":case"d":return t*os;case"hours":case"hour":case"hrs":case"hr":case"h":return t*js;case"minutes":case"minute":case"mins":case"min":case"m":return t*Bs;case"seconds":case"second":case"secs":case"sec":case"s":return t*Fs;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function uy(n){var e=Math.abs(n);return e>=os?Math.round(n/os)+"d":e>=js?Math.round(n/js)+"h":e>=Bs?Math.round(n/Bs)+"m":e>=Fs?Math.round(n/Fs)+"s":n+"ms"}function hy(n){var e=Math.abs(n);return e>=os?Wr(n,e,os,"day"):e>=js?Wr(n,e,js,"hour"):e>=Bs?Wr(n,e,Bs,"minute"):e>=Fs?Wr(n,e,Fs,"second"):n+" ms"}function Wr(n,e,t,s){var r=e>=t*1.5;return Math.round(n/t)+" "+s+(r?"s":"")}});var Va=U((o0,xd)=>{"use strict";function my(n){t.debug=t,t.default=t,t.coerce=c,t.disable=a,t.enable=r,t.enabled=o,t.humanize=wd(),t.destroy=l,Object.keys(n).forEach(p=>{t[p]=n[p]}),t.names=[],t.skips=[],t.formatters={};function e(p){let d=0;for(let u=0;u<p.length;u++)d=(d<<5)-d+p.charCodeAt(u),d|=0;return t.colors[Math.abs(d)%t.colors.length]}t.selectColor=e;function t(p){let d,u=null,h,m;function g(..._){if(!g.enabled)return;let v=g,y=Number(new Date),x=y-(d||y);v.diff=x,v.prev=d,v.curr=y,d=y,_[0]=t.coerce(_[0]),typeof _[0]!="string"&&_.unshift("%O");let C=0;_[0]=_[0].replace(/%([a-zA-Z%])/g,(P,E)=>{if(P==="%%")return"%";C++;let k=t.formatters[E];if(typeof k=="function"){let G=_[C];P=k.call(v,G),_.splice(C,1),C--}return P}),t.formatArgs.call(v,_),(v.log||t.log).apply(v,_)}return g.namespace=p,g.useColors=t.useColors(),g.color=t.selectColor(p),g.extend=s,g.destroy=t.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>u!==null?u:(h!==t.namespaces&&(h=t.namespaces,m=t.enabled(p)),m),set:_=>{u=_}}),typeof t.init=="function"&&t.init(g),g}function s(p,d){let u=t(this.namespace+(typeof d>"u"?":":d)+p);return u.log=this.log,u}function r(p){t.save(p),t.namespaces=p,t.names=[],t.skips=[];let d=(typeof p=="string"?p:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let u of d)u[0]==="-"?t.skips.push(u.slice(1)):t.names.push(u)}function i(p,d){let u=0,h=0,m=-1,g=0;for(;u<p.length;)if(h<d.length&&(d[h]===p[u]||d[h]==="*"))d[h]==="*"?(m=h,g=u,h++):(u++,h++);else if(m!==-1)h=m+1,g++,u=g;else return!1;for(;h<d.length&&d[h]==="*";)h++;return h===d.length}function a(){let p=[...t.names,...t.skips.map(d=>"-"+d)].join(",");return t.enable(""),p}function o(p){for(let d of t.skips)if(i(p,d))return!1;for(let d of t.names)if(i(p,d))return!0;return!1}function c(p){return p instanceof Error?p.stack||p.message:p}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}xd.exports=my});var Ed=U((He,Vr)=>{"use strict";He.formatArgs=gy;He.save=_y;He.load=yy;He.useColors=fy;He.storage=vy();He.destroy=(()=>{let n=!1;return()=>{n||(n=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();He.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function fy(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let n;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(n=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(n[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function gy(n){if(n[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+n[0]+(this.useColors?"%c ":" ")+"+"+Vr.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;n.splice(1,0,e,"color: inherit");let t=0,s=0;n[0].replace(/%[a-zA-Z%]/g,r=>{r!=="%%"&&(t++,r==="%c"&&(s=t))}),n.splice(s,0,e)}He.log=console.debug||console.log||(()=>{});function _y(n){try{n?He.storage.setItem("debug",n):He.storage.removeItem("debug")}catch{}}function yy(){let n;try{n=He.storage.getItem("debug")||He.storage.getItem("DEBUG")}catch{}return!n&&typeof process<"u"&&"env"in process&&(n=process.env.DEBUG),n}function vy(){try{return localStorage}catch{}}Vr.exports=Va()(He);var{formatters:by}=Vr.exports;by.j=function(n){try{return JSON.stringify(n)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Sd=U((c0,Cd)=>{"use strict";Cd.exports=(n,e=process.argv)=>{let t=n.startsWith("-")?"":n.length===1?"-":"--",s=e.indexOf(t+n),r=e.indexOf("--");return s!==-1&&(r===-1||s<r)}});var kd=U((l0,Ad)=>{"use strict";var wy=V("os"),Rd=V("tty"),at=Sd(),{env:Me}=process,Kr;at("no-color")||at("no-colors")||at("color=false")||at("color=never")?Kr=0:(at("color")||at("colors")||at("color=true")||at("color=always"))&&(Kr=1);function xy(){if("FORCE_COLOR"in Me)return Me.FORCE_COLOR==="true"?1:Me.FORCE_COLOR==="false"?0:Me.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Me.FORCE_COLOR,10),3)}function Ey(n){return n===0?!1:{level:n,hasBasic:!0,has256:n>=2,has16m:n>=3}}function Cy(n,{streamIsTTY:e,sniffFlags:t=!0}={}){let s=xy();s!==void 0&&(Kr=s);let r=t?Kr:s;if(r===0)return 0;if(t){if(at("color=16m")||at("color=full")||at("color=truecolor"))return 3;if(at("color=256"))return 2}if(n&&!e&&r===void 0)return 0;let i=r||0;if(Me.TERM==="dumb")return i;if(process.platform==="win32"){let a=wy.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in Me)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(a=>a in Me)||Me.CI_NAME==="codeship"?1:i;if("TEAMCITY_VERSION"in Me)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Me.TEAMCITY_VERSION)?1:0;if(Me.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Me){let a=Number.parseInt((Me.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Me.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Me.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Me.TERM)||"COLORTERM"in Me?1:i}function Ka(n,e={}){let t=Cy(n,{streamIsTTY:n&&n.isTTY,...e});return Ey(t)}Ad.exports={supportsColor:Ka,stdout:Ka({isTTY:Rd.isatty(1)}),stderr:Ka({isTTY:Rd.isatty(2)})}});var Md=U((Ie,Qr)=>{"use strict";var Sy=V("tty"),Hr=V("util");Ie.init=Ty;Ie.log=Py;Ie.formatArgs=Ay;Ie.save=My;Ie.load=Iy;Ie.useColors=Ry;Ie.destroy=Hr.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Ie.colors=[6,2,3,4,5,1];try{let n=kd();n&&(n.stderr||n).level>=2&&(Ie.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}Ie.inspectOpts=Object.keys(process.env).filter(n=>/^debug_/i.test(n)).reduce((n,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(r,i)=>i.toUpperCase()),s=process.env[e];return/^(yes|on|true|enabled)$/i.test(s)?s=!0:/^(no|off|false|disabled)$/i.test(s)?s=!1:s==="null"?s=null:s=Number(s),n[t]=s,n},{});function Ry(){return"colors"in Ie.inspectOpts?!!Ie.inspectOpts.colors:Sy.isatty(process.stderr.fd)}function Ay(n){let{namespace:e,useColors:t}=this;if(t){let s=this.color,r="\x1B[3"+(s<8?s:"8;5;"+s),i=` ${r};1m${e} \x1B[0m`;n[0]=i+n[0].split(`
3
3
  `).join(`
4
- `+a),s.push(n+"m+"+oi.exports.humanize(this.diff)+"\x1B[0m")}else s[0]=Gm()+e+" "+s[0]}function Gm(){return pe.inspectOpts.hideDate?"":new Date().toISOString()+" "}function qm(...s){return process.stderr.write(ri.formatWithOptions(pe.inspectOpts,...s)+`
5
- `)}function Bm(s){s?process.env.DEBUG=s:delete process.env.DEBUG}function $m(){return process.env.DEBUG}function zm(s){s.inspectOpts={};let e=Object.keys(pe.inspectOpts);for(let t=0;t<e.length;t++)s.inspectOpts[e[t]]=pe.inspectOpts[e[t]]}oi.exports=xn()(pe);var{formatters:vc}=oi.exports;vc.o=function(s){return this.inspectOpts.colors=this.useColors,ri.inspect(s,this.inspectOpts).split(`
6
- `).map(e=>e.trim()).join(" ")};vc.O=function(s){return this.inspectOpts.colors=this.useColors,ri.inspect(s,this.inspectOpts)}});var yc=y((av,bn)=>{"use strict";typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?bn.exports=dc():bn.exports=bc()});var Cc=y((rv,_c)=>{"use strict";var ms;_c.exports=function(){if(!ms){try{ms=yc()("follow-redirects")}catch{}typeof ms!="function"&&(ms=function(){})}ms.apply(null,arguments)}});var Tc=y((ov,Dn)=>{"use strict";var fs=k("url"),hs=fs.URL,Wm=k("http"),Vm=(Ze(),ts(as)),En=k("stream").Writable,Sn=k("assert"),wc=Cc();(function(){var e=typeof process<"u",t=typeof window<"u"&&typeof document<"u",i=xt(Error.captureStackTrace);!e&&(t||!i)&&console.warn("The follow-redirects package should be excluded from browser builds.")})();var Rn=!1;try{Sn(new hs(""))}catch(s){Rn=s.code==="ERR_INVALID_URL"}var Hm=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],Tn=["abort","aborted","connect","error","socket","timeout"],kn=Object.create(null);Tn.forEach(function(s){kn[s]=function(e,t,i){this._redirectable.emit(s,e,t,i)}});var _n=gs("ERR_INVALID_URL","Invalid URL",TypeError),Cn=gs("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),Km=gs("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",Cn),Jm=gs("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),Qm=gs("ERR_STREAM_WRITE_AFTER_END","write after end"),Xm=En.prototype.destroy||Sc;function we(s,e){En.call(this),this._sanitizeOptions(s),this._options=s,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],e&&this.on("response",e);var t=this;this._onNativeResponse=function(i){try{t._processResponse(i)}catch(n){t.emit("error",n instanceof Cn?n:new Cn({cause:n}))}},this._performRequest()}we.prototype=Object.create(En.prototype);we.prototype.abort=function(){In(this._currentRequest),this._currentRequest.abort(),this.emit("abort")};we.prototype.destroy=function(s){return In(this._currentRequest,s),Xm.call(this,s),this};we.prototype.write=function(s,e,t){if(this._ending)throw new Qm;if(!gt(s)&&!eh(s))throw new TypeError("data should be a string, Buffer or Uint8Array");if(xt(e)&&(t=e,e=null),s.length===0){t&&t();return}this._requestBodyLength+s.length<=this._options.maxBodyLength?(this._requestBodyLength+=s.length,this._requestBodyBuffers.push({data:s,encoding:e}),this._currentRequest.write(s,e,t)):(this.emit("error",new Jm),this.abort())};we.prototype.end=function(s,e,t){if(xt(s)?(t=s,s=e=null):xt(e)&&(t=e,e=null),!s)this._ended=this._ending=!0,this._currentRequest.end(null,null,t);else{var i=this,n=this._currentRequest;this.write(s,e,function(){i._ended=!0,n.end(null,null,t)}),this._ending=!0}};we.prototype.setHeader=function(s,e){this._options.headers[s]=e,this._currentRequest.setHeader(s,e)};we.prototype.removeHeader=function(s){delete this._options.headers[s],this._currentRequest.removeHeader(s)};we.prototype.setTimeout=function(s,e){var t=this;function i(r){r.setTimeout(s),r.removeListener("timeout",r.destroy),r.addListener("timeout",r.destroy)}function n(r){t._timeout&&clearTimeout(t._timeout),t._timeout=setTimeout(function(){t.emit("timeout"),a()},s),i(r)}function a(){t._timeout&&(clearTimeout(t._timeout),t._timeout=null),t.removeListener("abort",a),t.removeListener("error",a),t.removeListener("response",a),t.removeListener("close",a),e&&t.removeListener("timeout",e),t.socket||t._currentRequest.removeListener("socket",n)}return e&&this.on("timeout",e),this.socket?n(this.socket):this._currentRequest.once("socket",n),this.on("socket",i),this.on("abort",a),this.on("error",a),this.on("response",a),this.on("close",a),this};["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(s){we.prototype[s]=function(e,t){return this._currentRequest[s](e,t)}});["aborted","connection","socket"].forEach(function(s){Object.defineProperty(we.prototype,s,{get:function(){return this._currentRequest[s]}})});we.prototype._sanitizeOptions=function(s){if(s.headers||(s.headers={}),s.host&&(s.hostname||(s.hostname=s.host),delete s.host),!s.pathname&&s.path){var e=s.path.indexOf("?");e<0?s.pathname=s.path:(s.pathname=s.path.substring(0,e),s.search=s.path.substring(e))}};we.prototype._performRequest=function(){var s=this._options.protocol,e=this._options.nativeProtocols[s];if(!e)throw new TypeError("Unsupported protocol "+s);if(this._options.agents){var t=s.slice(0,-1);this._options.agent=this._options.agents[t]}var i=this._currentRequest=e.request(this._options,this._onNativeResponse);i._redirectable=this;for(var n of Tn)i.on(n,kn[n]);if(this._currentUrl=/^\//.test(this._options.path)?fs.format(this._options):this._options.path,this._isRedirect){var a=0,r=this,o=this._requestBodyBuffers;(function l(c){if(i===r._currentRequest)if(c)r.emit("error",c);else if(a<o.length){var p=o[a++];i.finished||i.write(p.data,p.encoding,l)}else r._ended&&i.end()})()}};we.prototype._processResponse=function(s){var e=s.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:s.headers,statusCode:e});var t=s.headers.location;if(!t||this._options.followRedirects===!1||e<300||e>=400){s.responseUrl=this._currentUrl,s.redirects=this._redirects,this.emit("response",s),this._requestBodyBuffers=[];return}if(In(this._currentRequest),s.destroy(),++this._redirectCount>this._options.maxRedirects)throw new Km;var i,n=this._options.beforeRedirect;n&&(i=Object.assign({Host:s.req.getHeader("host")},this._options.headers));var a=this._options.method;((e===301||e===302)&&this._options.method==="POST"||e===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],yn(/^content-/i,this._options.headers));var r=yn(/^host$/i,this._options.headers),o=An(this._currentUrl),l=r||o.host,c=/^\w+:/.test(t)?this._currentUrl:fs.format(Object.assign(o,{host:l})),p=Ym(t,c);if(wc("redirecting to",p.href),this._isRedirect=!0,wn(p,this._options),(p.protocol!==o.protocol&&p.protocol!=="https:"||p.host!==l&&!Zm(p.host,l))&&yn(/^(?:(?:proxy-)?authorization|cookie)$/i,this._options.headers),xt(n)){var d={headers:s.headers,statusCode:e},u={url:c,method:a,headers:i};n(this._options,d,u),this._sanitizeOptions(this._options)}this._performRequest()};function Ec(s){var e={maxRedirects:21,maxBodyLength:10485760},t={};return Object.keys(s).forEach(function(i){var n=i+":",a=t[n]=s[i],r=e[i]=Object.create(a);function o(c,p,d){return th(c)?c=wn(c):gt(c)?c=wn(An(c)):(d=p,p=Rc(c),c={protocol:n}),xt(p)&&(d=p,p=null),p=Object.assign({maxRedirects:e.maxRedirects,maxBodyLength:e.maxBodyLength},c,p),p.nativeProtocols=t,!gt(p.host)&&!gt(p.hostname)&&(p.hostname="::1"),Sn.equal(p.protocol,n,"protocol mismatch"),wc("options",p),new we(p,d)}function l(c,p,d){var u=r.request(c,p,d);return u.end(),u}Object.defineProperties(r,{request:{value:o,configurable:!0,enumerable:!0,writable:!0},get:{value:l,configurable:!0,enumerable:!0,writable:!0}})}),e}function Sc(){}function An(s){var e;if(Rn)e=new hs(s);else if(e=Rc(fs.parse(s)),!gt(e.protocol))throw new _n({input:s});return e}function Ym(s,e){return Rn?new hs(s,e):An(fs.resolve(e,s))}function Rc(s){if(/^\[/.test(s.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(s.hostname))throw new _n({input:s.href||s});if(/^\[/.test(s.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(s.host))throw new _n({input:s.href||s});return s}function wn(s,e){var t=e||{};for(var i of Hm)t[i]=s[i];return t.hostname.startsWith("[")&&(t.hostname=t.hostname.slice(1,-1)),t.port!==""&&(t.port=Number(t.port)),t.path=t.search?t.pathname+t.search:t.pathname,t}function yn(s,e){var t;for(var i in e)s.test(i)&&(t=e[i],delete e[i]);return t===null||typeof t>"u"?void 0:String(t).trim()}function gs(s,e,t){function i(n){xt(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,n||{}),this.code=s,this.message=this.cause?e+": "+this.cause.message:e}return i.prototype=new(t||Error),Object.defineProperties(i.prototype,{constructor:{value:i,enumerable:!1},name:{value:"Error ["+s+"]",enumerable:!1}}),i}function In(s,e){for(var t of Tn)s.removeListener(t,kn[t]);s.on("error",Sc),s.destroy(e)}function Zm(s,e){Sn(gt(s)&&gt(e));var t=s.length-e.length-1;return t>0&&s[t]==="."&&s.endsWith(e)}function gt(s){return typeof s=="string"||s instanceof String}function xt(s){return typeof s=="function"}function eh(s){return typeof s=="object"&&"length"in s}function th(s){return hs&&s instanceof hs}Dn.exports=Ec({http:Wm,https:Vm});Dn.exports.wrap=Ec});var wt=y((r_,yl)=>{"use strict";yl.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}}});var Rs=y((o_,Kn)=>{"use strict";var{EMPTY_BUFFER:jh}=wt();function _l(s,e){if(s.length===0)return jh;if(s.length===1)return s[0];let t=Buffer.allocUnsafe(e),i=0;for(let n=0;n<s.length;n++){let a=s[n];t.set(a,i),i+=a.length}return i<e?t.slice(0,i):t}function Cl(s,e,t,i,n){for(let a=0;a<n;a++)t[i+a]=s[a]^e[a&3]}function wl(s,e){let t=s.length;for(let i=0;i<t;i++)s[i]^=e[i&3]}function El(s){return s.byteLength===s.buffer.byteLength?s.buffer:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function yi(s){if(yi.readOnly=!0,Buffer.isBuffer(s))return s;let e;return s instanceof ArrayBuffer?e=Buffer.from(s):ArrayBuffer.isView(s)?e=Buffer.from(s.buffer,s.byteOffset,s.byteLength):(e=Buffer.from(s),yi.readOnly=!1),e}try{let s=k("bufferutil"),e=s.BufferUtil||s;Kn.exports={concat:_l,mask(t,i,n,a,r){r<48?Cl(t,i,n,a,r):e.mask(t,i,n,a,r)},toArrayBuffer:El,toBuffer:yi,unmask(t,i){t.length<32?wl(t,i):e.unmask(t,i)}}}catch{Kn.exports={concat:_l,mask:Cl,toArrayBuffer:El,toBuffer:yi,unmask:wl}}});var Tl=y((c_,Rl)=>{"use strict";var Sl=Symbol("kDone"),Jn=Symbol("kRun"),Qn=class{constructor(e){this[Sl]=()=>{this.pending--,this[Jn]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Jn]()}[Jn](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Sl])}}};Rl.exports=Qn});var As=y((l_,Dl)=>{"use strict";var Ts=k("zlib"),kl=Rs(),Nh=Tl(),{kStatusCode:Al,NOOP:Gh}=wt(),qh=Buffer.from([0,0,255,255]),wi=Symbol("permessage-deflate"),Qe=Symbol("total-length"),ks=Symbol("callback"),nt=Symbol("buffers"),Ci=Symbol("error"),_i,Xn=class{constructor(e,t,i){if(this._maxPayload=i|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!_i){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;_i=new Nh(n)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[ks];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,i=e.find(n=>!(t.serverNoContextTakeover===!1&&n.server_no_context_takeover||n.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>n.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!n.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(i.server_no_context_takeover=!0),t.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(i.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?i.client_max_window_bits=t.clientMaxWindowBits:(i.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(i=>{let n=t[i];if(n.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(n=n[0],i==="client_max_window_bits"){if(n!==!0){let a=+n;if(!Number.isInteger(a)||a<8||a>15)throw new TypeError(`Invalid value for parameter "${i}": ${n}`);n=a}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${n}`)}else if(i==="server_max_window_bits"){let a=+n;if(!Number.isInteger(a)||a<8||a>15)throw new TypeError(`Invalid value for parameter "${i}": ${n}`);n=a}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(n!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${n}`)}else throw new Error(`Unknown parameter "${i}"`);t[i]=n})}),e}decompress(e,t,i){_i.add(n=>{this._decompress(e,t,(a,r)=>{n(),i(a,r)})})}compress(e,t,i){_i.add(n=>{this._compress(e,t,(a,r)=>{n(),i(a,r)})})}_decompress(e,t,i){let n=this._isServer?"client":"server";if(!this._inflate){let a=`${n}_max_window_bits`,r=typeof this.params[a]!="number"?Ts.Z_DEFAULT_WINDOWBITS:this.params[a];this._inflate=Ts.createInflateRaw({...this._options.zlibInflateOptions,windowBits:r}),this._inflate[wi]=this,this._inflate[Qe]=0,this._inflate[nt]=[],this._inflate.on("error",$h),this._inflate.on("data",Il)}this._inflate[ks]=i,this._inflate.write(e),t&&this._inflate.write(qh),this._inflate.flush(()=>{let a=this._inflate[Ci];if(a){this._inflate.close(),this._inflate=null,i(a);return}let r=kl.concat(this._inflate[nt],this._inflate[Qe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Qe]=0,this._inflate[nt]=[],t&&this.params[`${n}_no_context_takeover`]&&this._inflate.reset()),i(null,r)})}_compress(e,t,i){let n=this._isServer?"server":"client";if(!this._deflate){let a=`${n}_max_window_bits`,r=typeof this.params[a]!="number"?Ts.Z_DEFAULT_WINDOWBITS:this.params[a];this._deflate=Ts.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:r}),this._deflate[Qe]=0,this._deflate[nt]=[],this._deflate.on("error",Gh),this._deflate.on("data",Bh)}this._deflate[ks]=i,this._deflate.write(e),this._deflate.flush(Ts.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let a=kl.concat(this._deflate[nt],this._deflate[Qe]);t&&(a=a.slice(0,a.length-4)),this._deflate[ks]=null,this._deflate[Qe]=0,this._deflate[nt]=[],t&&this.params[`${n}_no_context_takeover`]&&this._deflate.reset(),i(null,a)})}};Dl.exports=Xn;function Bh(s){this[nt].push(s),this[Qe]+=s.length}function Il(s){if(this[Qe]+=s.length,this[wi]._maxPayload<1||this[Qe]<=this[wi]._maxPayload){this[nt].push(s);return}this[Ci]=new RangeError("Max payload size exceeded"),this[Ci].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ci][Al]=1009,this.removeListener("data",Il),this.reset()}function $h(s){this[wi]._inflate=null,s[Al]=1007,this[ks](s)}});var Zn=y((p_,Yn)=>{"use strict";function Ul(s){return s>=1e3&&s<=1014&&s!==1004&&s!==1005&&s!==1006||s>=3e3&&s<=4999}function Ol(s){let e=s.length,t=0;for(;t<e;)if((s[t]&128)===0)t++;else if((s[t]&224)===192){if(t+1===e||(s[t+1]&192)!==128||(s[t]&254)===192)return!1;t+=2}else if((s[t]&240)===224){if(t+2>=e||(s[t+1]&192)!==128||(s[t+2]&192)!==128||s[t]===224&&(s[t+1]&224)===128||s[t]===237&&(s[t+1]&224)===160)return!1;t+=3}else if((s[t]&248)===240){if(t+3>=e||(s[t+1]&192)!==128||(s[t+2]&192)!==128||(s[t+3]&192)!==128||s[t]===240&&(s[t+1]&240)===128||s[t]===244&&s[t+1]>143||s[t]>244)return!1;t+=4}else return!1;return!0}try{let s=k("utf-8-validate");typeof s=="object"&&(s=s.Validation.isValidUTF8),Yn.exports={isValidStatusCode:Ul,isValidUTF8(e){return e.length<150?Ol(e):s(e)}}}catch{Yn.exports={isValidStatusCode:Ul,isValidUTF8:Ol}}});var ia=y((u_,Nl)=>{"use strict";var{Writable:zh}=k("stream"),Ll=As(),{BINARY_TYPES:Wh,EMPTY_BUFFER:Vh,kStatusCode:Hh,kWebSocket:Kh}=wt(),{concat:ea,toArrayBuffer:Jh,unmask:Qh}=Rs(),{isValidStatusCode:Xh,isValidUTF8:Pl}=Zn(),Is=0,Ml=1,Fl=2,jl=3,ta=4,Yh=5,sa=class extends zh{constructor(e,t,i,n){super(),this._binaryType=e||Wh[0],this[Kh]=void 0,this._extensions=t||{},this._isServer=!!i,this._maxPayload=n|0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=Is,this._loop=!1}_write(e,t,i){if(this._opcode===8&&this._state==Is)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=i.slice(e),i.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let i=this._buffers[0],n=t.length-e;e>=i.length?t.set(this._buffers.shift(),n):(t.set(new Uint8Array(i.buffer,i.byteOffset,e),n),this._buffers[0]=i.slice(e)),e-=i.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case Is:t=this.getInfo();break;case Ml:t=this.getPayloadLength16();break;case Fl:t=this.getPayloadLength64();break;case jl:this.getMask();break;case ta:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if((e[0]&48)!==0)return this._loop=!1,re(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[Ll.extensionName])return this._loop=!1,re(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,re(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,re(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,re(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,re(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,re(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,re(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,re(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,re(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,re(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Ml;else if(this._payloadLength===127)this._state=Fl;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,re(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,re(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=jl:this._state=ta}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ta}getData(e){let t=Vh;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&Qh(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=Yh,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Ll.extensionName].decompress(e,this._fin,(n,a)=>{if(n)return t(n);if(a.length){if(this._messageLength+=a.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(re(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(a)}let r=this.dataMessage();if(r)return t(r);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=ea(t,e):this._binaryType==="arraybuffer"?i=Jh(ea(t,e)):i=t,this.emit("message",i)}else{let i=ea(t,e);if(!Pl(i))return this._loop=!1,re(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",i.toString())}}this._state=Is}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,""),this.end();else{if(e.length===1)return re(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!Xh(t))return re(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let i=e.slice(2);if(!Pl(i))return re(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,i.toString()),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=Is}};Nl.exports=sa;function re(s,e,t,i,n){let a=new s(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(a,re),a.code=n,a[Hh]=i,a}});var aa=y((h_,Bl)=>{"use strict";var d_=k("net"),m_=k("tls"),{randomFillSync:Zh}=k("crypto"),Gl=As(),{EMPTY_BUFFER:ef}=wt(),{isValidStatusCode:tf}=Zn(),{mask:ql,toBuffer:Xe}=Rs(),Et=Buffer.alloc(4),na=class s{constructor(e,t){this._extensions=t||{},this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let i=t.mask&&t.readOnly,n=t.mask?6:2,a=e.length;e.length>=65536?(n+=8,a=127):e.length>125&&(n+=2,a=126);let r=Buffer.allocUnsafe(i?e.length+n:n);return r[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(r[0]|=64),r[1]=a,a===126?r.writeUInt16BE(e.length,2):a===127&&(r.writeUInt32BE(0,2),r.writeUInt32BE(e.length,6)),t.mask?(Zh(Et,0,4),r[1]|=128,r[n-4]=Et[0],r[n-3]=Et[1],r[n-2]=Et[2],r[n-1]=Et[3],i?(ql(e,Et,r,n,e.length),[r]):(ql(e,Et,e,0,e.length),[r,e])):[r,e]}close(e,t,i,n){let a;if(e===void 0)a=ef;else{if(typeof e!="number"||!tf(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||t==="")a=Buffer.allocUnsafe(2),a.writeUInt16BE(e,0);else{let r=Buffer.byteLength(t);if(r>123)throw new RangeError("The message must not be greater than 123 bytes");a=Buffer.allocUnsafe(2+r),a.writeUInt16BE(e,0),a.write(t,2)}}this._deflating?this.enqueue([this.doClose,a,i,n]):this.doClose(a,i,n)}doClose(e,t,i){this.sendFrame(s.frame(e,{fin:!0,rsv1:!1,opcode:8,mask:t,readOnly:!1}),i)}ping(e,t,i){let n=Xe(e);if(n.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPing,n,t,Xe.readOnly,i]):this.doPing(n,t,Xe.readOnly,i)}doPing(e,t,i,n){this.sendFrame(s.frame(e,{fin:!0,rsv1:!1,opcode:9,mask:t,readOnly:i}),n)}pong(e,t,i){let n=Xe(e);if(n.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPong,n,t,Xe.readOnly,i]):this.doPong(n,t,Xe.readOnly,i)}doPong(e,t,i,n){this.sendFrame(s.frame(e,{fin:!0,rsv1:!1,opcode:10,mask:t,readOnly:i}),n)}send(e,t,i){let n=Xe(e),a=this._extensions[Gl.extensionName],r=t.binary?2:1,o=t.compress;if(this._firstFragment?(this._firstFragment=!1,o&&a&&(o=n.length>=a._threshold),this._compress=o):(o=!1,r=0),t.fin&&(this._firstFragment=!0),a){let l={fin:t.fin,rsv1:o,opcode:r,mask:t.mask,readOnly:Xe.readOnly};this._deflating?this.enqueue([this.dispatch,n,this._compress,l,i]):this.dispatch(n,this._compress,l,i)}else this.sendFrame(s.frame(n,{fin:t.fin,rsv1:!1,opcode:r,mask:t.mask,readOnly:Xe.readOnly}),i)}dispatch(e,t,i,n){if(!t){this.sendFrame(s.frame(e,i),n);return}let a=this._extensions[Gl.extensionName];this._bufferedBytes+=e.length,this._deflating=!0,a.compress(e,i.fin,(r,o)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");typeof n=="function"&&n(l);for(let c=0;c<this._queue.length;c++){let p=this._queue[c][4];typeof p=="function"&&p(l)}return}this._bufferedBytes-=e.length,this._deflating=!1,i.readOnly=!1,this.sendFrame(s.frame(o,i),n),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[1].length,Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[1].length,this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};Bl.exports=na});var zl=y((f_,$l)=>{"use strict";var Xt=class{constructor(e,t){this.target=t,this.type=e}},ra=class extends Xt{constructor(e,t){super("message",t),this.data=e}},oa=class extends Xt{constructor(e,t,i){super("close",i),this.wasClean=i._closeFrameReceived&&i._closeFrameSent,this.reason=t,this.code=e}},ca=class extends Xt{constructor(e){super("open",e)}},la=class extends Xt{constructor(e,t){super("error",t),this.message=e.message,this.error=e}},sf={addEventListener(s,e,t){if(typeof e!="function")return;function i(l){e.call(this,new ra(l,this))}function n(l,c){e.call(this,new oa(l,c,this))}function a(l){e.call(this,new la(l,this))}function r(){e.call(this,new ca(this))}let o=t&&t.once?"once":"on";s==="message"?(i._listener=e,this[o](s,i)):s==="close"?(n._listener=e,this[o](s,n)):s==="error"?(a._listener=e,this[o](s,a)):s==="open"?(r._listener=e,this[o](s,r)):this[o](s,e)},removeEventListener(s,e){let t=this.listeners(s);for(let i=0;i<t.length;i++)(t[i]===e||t[i]._listener===e)&&this.removeListener(s,t[i])}};$l.exports=sf});var pa=y((g_,Wl)=>{"use strict";var Ds=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function $e(s,e,t){s[e]===void 0?s[e]=[t]:s[e].push(t)}function nf(s){let e=Object.create(null);if(s===void 0||s==="")return e;let t=Object.create(null),i=!1,n=!1,a=!1,r,o,l=-1,c=-1,p=0;for(;p<s.length;p++){let u=s.charCodeAt(p);if(r===void 0)if(c===-1&&Ds[u]===1)l===-1&&(l=p);else if(u===32||u===9)c===-1&&l!==-1&&(c=p);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1&&(c=p);let f=s.slice(l,c);u===44?($e(e,f,t),t=Object.create(null)):r=f,l=c=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(o===void 0)if(c===-1&&Ds[u]===1)l===-1&&(l=p);else if(u===32||u===9)c===-1&&l!==-1&&(c=p);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1&&(c=p),$e(t,s.slice(l,c),!0),u===44&&($e(e,r,t),t=Object.create(null),r=void 0),l=c=-1}else if(u===61&&l!==-1&&c===-1)o=s.slice(l,p),l=c=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(n){if(Ds[u]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);l===-1?l=p:i||(i=!0),n=!1}else if(a)if(Ds[u]===1)l===-1&&(l=p);else if(u===34&&l!==-1)a=!1,c=p;else if(u===92)n=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(u===34&&s.charCodeAt(p-1)===61)a=!0;else if(c===-1&&Ds[u]===1)l===-1&&(l=p);else if(l!==-1&&(u===32||u===9))c===-1&&(c=p);else if(u===59||u===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1&&(c=p);let f=s.slice(l,c);i&&(f=f.replace(/\\/g,""),i=!1),$e(t,o,f),u===44&&($e(e,r,t),t=Object.create(null),r=void 0),o=void 0,l=c=-1}else throw new SyntaxError(`Unexpected character at index ${p}`)}if(l===-1||a)throw new SyntaxError("Unexpected end of input");c===-1&&(c=p);let d=s.slice(l,c);return r===void 0?$e(e,d,t):(o===void 0?$e(t,d,!0):i?$e(t,o,d.replace(/\\/g,"")):$e(t,o,d),$e(e,r,t)),e}function af(s){return Object.keys(s).map(e=>{let t=s[e];return Array.isArray(t)||(t=[t]),t.map(i=>[e].concat(Object.keys(i).map(n=>{let a=i[n];return Array.isArray(a)||(a=[a]),a.map(r=>r===!0?n:`${n}=${r}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Wl.exports={format:af,parse:nf}});var ga=y((v_,tp)=>{"use strict";var rf=k("events"),of=(Ze(),ts(as)),cf=k("http"),Kl=k("net"),lf=k("tls"),{randomBytes:pf,createHash:uf}=k("crypto"),{Readable:x_}=k("stream"),{URL:ua}=k("url"),at=As(),df=ia(),mf=aa(),{BINARY_TYPES:Vl,EMPTY_BUFFER:da,GUID:hf,kStatusCode:ff,kWebSocket:me,NOOP:Jl}=wt(),{addEventListener:gf,removeEventListener:xf}=zl(),{format:vf,parse:bf}=pa(),{toBuffer:yf}=Rs(),Ye=["CONNECTING","OPEN","CLOSING","CLOSED"],ma=[8,13],_f=30*1e3,se=class s extends rf{constructor(e,t,i){super(),this._binaryType=Vl[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._extensions={},this._protocol="",this._readyState=s.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(t)?t=t.join(", "):typeof t=="object"&&t!==null&&(i=t,t=void 0),Ql(this,e,t,i)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){Vl.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get onclose(){}set onclose(e){}get onerror(){}set onerror(e){}get onopen(){}set onopen(e){}get onmessage(){}set onmessage(e){}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,i){let n=new df(this.binaryType,this._extensions,this._isServer,i);this._sender=new mf(e,this._extensions),this._receiver=n,this._socket=e,n[me]=this,e[me]=this,n.on("conclude",Ef),n.on("drain",Sf),n.on("error",Rf),n.on("message",Tf),n.on("ping",kf),n.on("pong",Af),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Yl),e.on("data",Ei),e.on("end",Zl),e.on("error",ep),this._readyState=s.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=s.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[at.extensionName]&&this._extensions[at.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=s.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==s.CLOSED){if(this.readyState===s.CONNECTING)return Ie(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===s.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=s.CLOSING,this._sender.close(e,t,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),_f)}}ping(e,t,i){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=t=void 0):typeof t=="function"&&(i=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){fa(this,e,i);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||da,t,i)}pong(e,t,i){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=t=void 0):typeof t=="function"&&(i=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){fa(this,e,i);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||da,t,i)}send(e,t,i){if(this.readyState===s.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(i=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==s.OPEN){fa(this,e,i);return}let n={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[at.extensionName]||(n.compress=!1),this._sender.send(e||da,n,i)}terminate(){if(this.readyState!==s.CLOSED){if(this.readyState===s.CONNECTING)return Ie(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=s.CLOSING,this._socket.destroy())}}};Object.defineProperty(se,"CONNECTING",{enumerable:!0,value:Ye.indexOf("CONNECTING")});Object.defineProperty(se.prototype,"CONNECTING",{enumerable:!0,value:Ye.indexOf("CONNECTING")});Object.defineProperty(se,"OPEN",{enumerable:!0,value:Ye.indexOf("OPEN")});Object.defineProperty(se.prototype,"OPEN",{enumerable:!0,value:Ye.indexOf("OPEN")});Object.defineProperty(se,"CLOSING",{enumerable:!0,value:Ye.indexOf("CLOSING")});Object.defineProperty(se.prototype,"CLOSING",{enumerable:!0,value:Ye.indexOf("CLOSING")});Object.defineProperty(se,"CLOSED",{enumerable:!0,value:Ye.indexOf("CLOSED")});Object.defineProperty(se.prototype,"CLOSED",{enumerable:!0,value:Ye.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(s=>{Object.defineProperty(se.prototype,s,{enumerable:!0})});["open","error","close","message"].forEach(s=>{Object.defineProperty(se.prototype,`on${s}`,{enumerable:!0,get(){let e=this.listeners(s);for(let t=0;t<e.length;t++)if(e[t]._listener)return e[t]._listener},set(e){let t=this.listeners(s);for(let i=0;i<t.length;i++)t[i]._listener&&this.removeListener(s,t[i]);this.addEventListener(s,e)}})});se.prototype.addEventListener=gf;se.prototype.removeEventListener=xf;tp.exports=se;function Ql(s,e,t,i){let n={protocolVersion:ma[1],maxPayload:104857600,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,host:void 0,path:void 0,port:void 0};if(!ma.includes(n.protocolVersion))throw new RangeError(`Unsupported protocol version: ${n.protocolVersion} (supported versions: ${ma.join(", ")})`);let a;e instanceof ua?(a=e,s._url=e.href):(a=new ua(e),s._url=e);let r=a.protocol==="ws+unix:";if(!a.host&&(!r||!a.pathname)){let f=new Error(`Invalid URL: ${s.url}`);if(s._redirects===0)throw f;ha(s,f);return}let o=a.protocol==="wss:"||a.protocol==="https:",l=o?443:80,c=pf(16).toString("base64"),p=o?of.get:cf.get,d;if(n.createConnection=o?wf:Cf,n.defaultPort=n.defaultPort||l,n.port=a.port||l,n.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,n.headers={"Sec-WebSocket-Version":n.protocolVersion,"Sec-WebSocket-Key":c,Connection:"Upgrade",Upgrade:"websocket",...n.headers},n.path=a.pathname+a.search,n.timeout=n.handshakeTimeout,n.perMessageDeflate&&(d=new at(n.perMessageDeflate!==!0?n.perMessageDeflate:{},!1,n.maxPayload),n.headers["Sec-WebSocket-Extensions"]=vf({[at.extensionName]:d.offer()})),t&&(n.headers["Sec-WebSocket-Protocol"]=t),n.origin&&(n.protocolVersion<13?n.headers["Sec-WebSocket-Origin"]=n.origin:n.headers.Origin=n.origin),(a.username||a.password)&&(n.auth=`${a.username}:${a.password}`),r){let f=n.path.split(":");n.socketPath=f[0],n.path=f[1]}if(n.followRedirects){if(s._redirects===0){s._originalUnixSocket=r,s._originalSecure=o,s._originalHostOrSocketPath=r?n.socketPath:a.host;let f=i&&i.headers;if(i={...i,headers:{}},f)for(let[h,x]of Object.entries(f))i.headers[h.toLowerCase()]=x}else{let f=r?s._originalUnixSocket?n.socketPath===s._originalHostOrSocketPath:!1:s._originalUnixSocket?!1:a.host===s._originalHostOrSocketPath;(!f||s._originalSecure&&!o)&&(delete n.headers.authorization,delete n.headers.cookie,f||delete n.headers.host,n.auth=void 0)}n.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(n.auth).toString("base64"))}let u=s._req=p(n);n.timeout&&u.on("timeout",()=>{Ie(s,u,"Opening handshake has timed out")}),u.on("error",f=>{u===null||u.aborted||(u=s._req=null,ha(s,f))}),u.on("response",f=>{let h=f.headers.location,x=f.statusCode;if(h&&n.followRedirects&&x>=300&&x<400){if(++s._redirects>n.maxRedirects){Ie(s,u,"Maximum redirects exceeded");return}u.abort();let v;try{v=new ua(h,e)}catch(b){ha(s,b);return}Ql(s,v,t,i)}else s.emit("unexpected-response",u,f)||Ie(s,u,`Unexpected server response: ${f.statusCode}`)}),u.on("upgrade",(f,h,x)=>{if(s.emit("upgrade",f),s.readyState!==se.CONNECTING)return;u=s._req=null;let v=f.headers.upgrade;if(v===void 0||v.toLowerCase()!=="websocket"){Ie(s,h,"Invalid Upgrade header");return}let b=uf("sha1").update(c+hf).digest("base64");if(f.headers["sec-websocket-accept"]!==b){Ie(s,h,"Invalid Sec-WebSocket-Accept header");return}let T=f.headers["sec-websocket-protocol"],I=(t||"").split(/, */),M;if(!t&&T?M="Server sent a subprotocol but none was requested":t&&!T?M="Server sent no subprotocol":T&&!I.includes(T)&&(M="Server sent an invalid subprotocol"),M){Ie(s,h,M);return}T&&(s._protocol=T);let O=f.headers["sec-websocket-extensions"];if(O!==void 0){if(!d){Ie(s,h,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let V;try{V=bf(O)}catch{Ie(s,h,"Invalid Sec-WebSocket-Extensions header");return}let Y=Object.keys(V);if(Y.length){if(Y.length!==1||Y[0]!==at.extensionName){Ie(s,h,"Server indicated an extension that was not requested");return}try{d.accept(V[at.extensionName])}catch{Ie(s,h,"Invalid Sec-WebSocket-Extensions header");return}s._extensions[at.extensionName]=d}}s.setSocket(h,x,n.maxPayload)})}function ha(s,e){s._readyState=se.CLOSING,s.emit("error",e),s.emitClose()}function Cf(s){return s.path=s.socketPath,Kl.connect(s)}function wf(s){return s.path=void 0,!s.servername&&s.servername!==""&&(s.servername=Kl.isIP(s.host)?"":s.host),lf.connect(s)}function Ie(s,e,t){s._readyState=se.CLOSING;let i=new Error(t);Error.captureStackTrace(i,Ie),e.setHeader?(e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),e.once("abort",s.emitClose.bind(s)),s.emit("error",i)):(e.destroy(i),e.once("error",s.emit.bind(s,"error")),e.once("close",s.emitClose.bind(s)))}function fa(s,e,t){if(e){let i=yf(e).length;s._socket?s._sender._bufferedBytes+=i:s._bufferedAmount+=i}if(t){let i=new Error(`WebSocket is not open: readyState ${s.readyState} (${Ye[s.readyState]})`);t(i)}}function Ef(s,e){let t=this[me];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=s,t._socket[me]!==void 0&&(t._socket.removeListener("data",Ei),process.nextTick(Xl,t._socket),s===1005?t.close():t.close(s,e))}function Sf(){this[me]._socket.resume()}function Rf(s){let e=this[me];e._socket[me]!==void 0&&(e._socket.removeListener("data",Ei),process.nextTick(Xl,e._socket),e.close(s[ff])),e.emit("error",s)}function Hl(){this[me].emitClose()}function Tf(s){this[me].emit("message",s)}function kf(s){let e=this[me];e.pong(s,!e._isServer,Jl),e.emit("ping",s)}function Af(s){this[me].emit("pong",s)}function Xl(s){s.resume()}function Yl(){let s=this[me];this.removeListener("close",Yl),this.removeListener("data",Ei),this.removeListener("end",Zl),s._readyState=se.CLOSING;let e;!this._readableState.endEmitted&&!s._closeFrameReceived&&!s._receiver._writableState.errorEmitted&&(e=s._socket.read())!==null&&s._receiver.write(e),s._receiver.end(),this[me]=void 0,clearTimeout(s._closeTimer),s._receiver._writableState.finished||s._receiver._writableState.errorEmitted?s.emitClose():(s._receiver.on("error",Hl),s._receiver.on("finish",Hl))}function Ei(s){this[me]._receiver.write(s)||this.pause()}function Zl(){let s=this[me];s._readyState=se.CLOSING,s._receiver.end(),this.end()}function ep(){let s=this[me];this.removeListener("error",ep),this.on("error",Jl),s&&(s._readyState=se.CLOSING,this.destroy())}});var ap=y((b_,np)=>{"use strict";var{Duplex:If}=k("stream");function sp(s){s.emit("close")}function Df(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ip(s){this.removeListener("error",ip),this.destroy(),this.listenerCount("error")===0&&this.emit("error",s)}function Uf(s,e){let t=!0,i=!0;function n(){t&&s._socket.resume()}s.readyState===s.CONNECTING?s.once("open",function(){s._receiver.removeAllListeners("drain"),s._receiver.on("drain",n)}):(s._receiver.removeAllListeners("drain"),s._receiver.on("drain",n));let a=new If({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return s.on("message",function(o){a.push(o)||(t=!1,s._socket.pause())}),s.once("error",function(o){a.destroyed||(i=!1,a.destroy(o))}),s.once("close",function(){a.destroyed||a.push(null)}),a._destroy=function(r,o){if(s.readyState===s.CLOSED){o(r),process.nextTick(sp,a);return}let l=!1;s.once("error",function(p){l=!0,o(p)}),s.once("close",function(){l||o(r),process.nextTick(sp,a)}),i&&s.terminate()},a._final=function(r){if(s.readyState===s.CONNECTING){s.once("open",function(){a._final(r)});return}s._socket!==null&&(s._socket._writableState.finished?(r(),a._readableState.endEmitted&&a.destroy()):(s._socket.once("finish",function(){r()}),s.close()))},a._read=function(){(s.readyState===s.OPEN||s.readyState===s.CLOSING)&&!t&&(t=!0,s._receiver._writableState.needDrain||s._socket.resume())},a._write=function(r,o,l){if(s.readyState===s.CONNECTING){s.once("open",function(){a._write(r,o,l)});return}s.send(r,l)},a.on("end",Df),a.on("error",ip),a}np.exports=Uf});var pp=y((w_,lp)=>{"use strict";var Of=k("events"),Si=k("http"),y_=(Ze(),ts(as)),__=k("net"),C_=k("tls"),{createHash:Lf}=k("crypto"),St=As(),Pf=ga(),{format:Mf,parse:Ff}=pa(),{GUID:jf,kWebSocket:Nf}=wt(),Gf=/^[+/0-9A-Za-z]{22}==$/,rp=0,op=1,cp=2,va=class extends Of{constructor(e,t){if(super(),e={maxPayload:100*1024*1024,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Si.createServer((i,n)=>{let a=Si.STATUS_CODES[426];n.writeHead(426,{"Content-Length":a.length,"Content-Type":"text/plain"}),n.end(a)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=qf(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(n,a,r)=>{this.handleUpgrade(n,a,r,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set),this.options=e,this._state=rp}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(e&&this.once("close",e),this._state===cp){process.nextTick(xa,this);return}if(this._state===op)return;if(this._state=op,this.clients)for(let i of this.clients)i.terminate();let t=this._server;if(t&&(this._removeListeners(),this._removeListeners=this._server=null,this.options.port!=null)){t.close(xa.bind(void 0,this));return}process.nextTick(xa,this)}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,i,n){t.on("error",ba);let a=e.headers["sec-websocket-key"]!==void 0?e.headers["sec-websocket-key"].trim():!1,r=e.headers.upgrade,o=+e.headers["sec-websocket-version"],l={};if(e.method!=="GET"||r===void 0||r.toLowerCase()!=="websocket"||!a||!Gf.test(a)||o!==8&&o!==13||!this.shouldHandle(e))return Us(t,400);if(this.options.perMessageDeflate){let c=new St(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let p=Ff(e.headers["sec-websocket-extensions"]);p[St.extensionName]&&(c.accept(p[St.extensionName]),l[St.extensionName]=c)}catch{return Us(t,400)}}if(this.options.verifyClient){let c={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(c,(p,d,u,f)=>{if(!p)return Us(t,d||401,u,f);this.completeUpgrade(a,l,e,t,i,n)});return}if(!this.options.verifyClient(c))return Us(t,401)}this.completeUpgrade(a,l,e,t,i,n)}completeUpgrade(e,t,i,n,a,r){if(!n.readable||!n.writable)return n.destroy();if(n[Nf])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>rp)return Us(n,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Lf("sha1").update(e+jf).digest("base64")}`],c=new Pf(null),p=i.headers["sec-websocket-protocol"];if(p&&(p=p.split(",").map(Bf),this.options.handleProtocols?p=this.options.handleProtocols(p,i):p=p[0],p&&(l.push(`Sec-WebSocket-Protocol: ${p}`),c._protocol=p)),t[St.extensionName]){let d=t[St.extensionName].params,u=Mf({[St.extensionName]:[d]});l.push(`Sec-WebSocket-Extensions: ${u}`),c._extensions=t}this.emit("headers",l,i),n.write(l.concat(`\r
4
+ `+i),n.push(r+"m+"+Qr.exports.humanize(this.diff)+"\x1B[0m")}else n[0]=ky()+e+" "+n[0]}function ky(){return Ie.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Py(...n){return process.stderr.write(Hr.formatWithOptions(Ie.inspectOpts,...n)+`
5
+ `)}function My(n){n?process.env.DEBUG=n:delete process.env.DEBUG}function Iy(){return process.env.DEBUG}function Ty(n){n.inspectOpts={};let e=Object.keys(Ie.inspectOpts);for(let t=0;t<e.length;t++)n.inspectOpts[e[t]]=Ie.inspectOpts[e[t]]}Qr.exports=Va()(Ie);var{formatters:Pd}=Qr.exports;Pd.o=function(n){return this.inspectOpts.colors=this.useColors,Hr.inspect(n,this.inspectOpts).split(`
6
+ `).map(e=>e.trim()).join(" ")};Pd.O=function(n){return this.inspectOpts.colors=this.useColors,Hr.inspect(n,this.inspectOpts)}});var Id=U((p0,Ha)=>{"use strict";typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?Ha.exports=Ed():Ha.exports=Md()});var Ud=U((d0,Td)=>{"use strict";var Cn;Td.exports=function(){if(!Cn){try{Cn=Id()("follow-redirects")}catch{}typeof Cn!="function"&&(Cn=function(){})}Cn.apply(null,arguments)}});var Bd=U((u0,ao)=>{"use strict";var Rn=V("url"),Sn=Rn.URL,Uy=V("http"),Dy=(jt(),un(gn)),Za=V("stream").Writable,eo=V("assert"),Dd=Ud();(function(){var e=typeof process<"u",t=typeof window<"u"&&typeof document<"u",s=ls(Error.captureStackTrace);!e&&(t||!s)&&console.warn("The follow-redirects package should be excluded from browser builds.")})();var to=!1;try{eo(new Sn(""))}catch(n){to=n.code==="ERR_INVALID_URL"}var Ly=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],so=["abort","aborted","connect","error","socket","timeout"],no=Object.create(null);so.forEach(function(n){no[n]=function(e,t,s){this._redirectable.emit(n,e,t,s)}});var Ja=An("ERR_INVALID_URL","Invalid URL",TypeError),Ya=An("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),Oy=An("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",Ya),Fy=An("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),By=An("ERR_STREAM_WRITE_AFTER_END","write after end"),jy=Za.prototype.destroy||Od;function Qe(n,e){Za.call(this),this._sanitizeOptions(n),this._options=n,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],e&&this.on("response",e);var t=this;this._onNativeResponse=function(s){try{t._processResponse(s)}catch(r){t.emit("error",r instanceof Ya?r:new Ya({cause:r}))}},this._performRequest()}Qe.prototype=Object.create(Za.prototype);Qe.prototype.abort=function(){io(this._currentRequest),this._currentRequest.abort(),this.emit("abort")};Qe.prototype.destroy=function(n){return io(this._currentRequest,n),jy.call(this,n),this};Qe.prototype.write=function(n,e,t){if(this._ending)throw new By;if(!cs(n)&&!qy(n))throw new TypeError("data should be a string, Buffer or Uint8Array");if(ls(e)&&(t=e,e=null),n.length===0){t&&t();return}this._requestBodyLength+n.length<=this._options.maxBodyLength?(this._requestBodyLength+=n.length,this._requestBodyBuffers.push({data:n,encoding:e}),this._currentRequest.write(n,e,t)):(this.emit("error",new Fy),this.abort())};Qe.prototype.end=function(n,e,t){if(ls(n)?(t=n,n=e=null):ls(e)&&(t=e,e=null),!n)this._ended=this._ending=!0,this._currentRequest.end(null,null,t);else{var s=this,r=this._currentRequest;this.write(n,e,function(){s._ended=!0,r.end(null,null,t)}),this._ending=!0}};Qe.prototype.setHeader=function(n,e){this._options.headers[n]=e,this._currentRequest.setHeader(n,e)};Qe.prototype.removeHeader=function(n){delete this._options.headers[n],this._currentRequest.removeHeader(n)};Qe.prototype.setTimeout=function(n,e){var t=this;function s(a){a.setTimeout(n),a.removeListener("timeout",a.destroy),a.addListener("timeout",a.destroy)}function r(a){t._timeout&&clearTimeout(t._timeout),t._timeout=setTimeout(function(){t.emit("timeout"),i()},n),s(a)}function i(){t._timeout&&(clearTimeout(t._timeout),t._timeout=null),t.removeListener("abort",i),t.removeListener("error",i),t.removeListener("response",i),t.removeListener("close",i),e&&t.removeListener("timeout",e),t.socket||t._currentRequest.removeListener("socket",r)}return e&&this.on("timeout",e),this.socket?r(this.socket):this._currentRequest.once("socket",r),this.on("socket",s),this.on("abort",i),this.on("error",i),this.on("response",i),this.on("close",i),this};["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(n){Qe.prototype[n]=function(e,t){return this._currentRequest[n](e,t)}});["aborted","connection","socket"].forEach(function(n){Object.defineProperty(Qe.prototype,n,{get:function(){return this._currentRequest[n]}})});Qe.prototype._sanitizeOptions=function(n){if(n.headers||(n.headers={}),n.host&&(n.hostname||(n.hostname=n.host),delete n.host),!n.pathname&&n.path){var e=n.path.indexOf("?");e<0?n.pathname=n.path:(n.pathname=n.path.substring(0,e),n.search=n.path.substring(e))}};Qe.prototype._performRequest=function(){var n=this._options.protocol,e=this._options.nativeProtocols[n];if(!e)throw new TypeError("Unsupported protocol "+n);if(this._options.agents){var t=n.slice(0,-1);this._options.agent=this._options.agents[t]}var s=this._currentRequest=e.request(this._options,this._onNativeResponse);s._redirectable=this;for(var r of so)s.on(r,no[r]);if(this._currentUrl=/^\//.test(this._options.path)?Rn.format(this._options):this._options.path,this._isRedirect){var i=0,a=this,o=this._requestBodyBuffers;(function c(l){if(s===a._currentRequest)if(l)a.emit("error",l);else if(i<o.length){var p=o[i++];s.finished||s.write(p.data,p.encoding,c)}else a._ended&&s.end()})()}};Qe.prototype._processResponse=function(n){var e=n.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:n.headers,statusCode:e});var t=n.headers.location;if(!t||this._options.followRedirects===!1||e<300||e>=400){n.responseUrl=this._currentUrl,n.redirects=this._redirects,this.emit("response",n),this._requestBodyBuffers=[];return}if(io(this._currentRequest),n.destroy(),++this._redirectCount>this._options.maxRedirects)throw new Oy;var s,r=this._options.beforeRedirect;r&&(s=Object.assign({Host:n.req.getHeader("host")},this._options.headers));var i=this._options.method;((e===301||e===302)&&this._options.method==="POST"||e===303&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],Qa(/^content-/i,this._options.headers));var a=Qa(/^host$/i,this._options.headers),o=ro(this._currentUrl),c=a||o.host,l=/^\w+:/.test(t)?this._currentUrl:Rn.format(Object.assign(o,{host:c})),p=Gy(t,l);if(Dd("redirecting to",p.href),this._isRedirect=!0,Xa(p,this._options),(p.protocol!==o.protocol&&p.protocol!=="https:"||p.host!==c&&!Ny(p.host,c))&&Qa(/^(?:(?:proxy-)?authorization|cookie)$/i,this._options.headers),ls(r)){var d={headers:n.headers,statusCode:e},u={url:l,method:i,headers:s};r(this._options,d,u),this._sanitizeOptions(this._options)}this._performRequest()};function Ld(n){var e={maxRedirects:21,maxBodyLength:10485760},t={};return Object.keys(n).forEach(function(s){var r=s+":",i=t[r]=n[s],a=e[s]=Object.create(i);function o(l,p,d){return zy(l)?l=Xa(l):cs(l)?l=Xa(ro(l)):(d=p,p=Fd(l),l={protocol:r}),ls(p)&&(d=p,p=null),p=Object.assign({maxRedirects:e.maxRedirects,maxBodyLength:e.maxBodyLength},l,p),p.nativeProtocols=t,!cs(p.host)&&!cs(p.hostname)&&(p.hostname="::1"),eo.equal(p.protocol,r,"protocol mismatch"),Dd("options",p),new Qe(p,d)}function c(l,p,d){var u=a.request(l,p,d);return u.end(),u}Object.defineProperties(a,{request:{value:o,configurable:!0,enumerable:!0,writable:!0},get:{value:c,configurable:!0,enumerable:!0,writable:!0}})}),e}function Od(){}function ro(n){var e;if(to)e=new Sn(n);else if(e=Fd(Rn.parse(n)),!cs(e.protocol))throw new Ja({input:n});return e}function Gy(n,e){return to?new Sn(n,e):ro(Rn.resolve(e,n))}function Fd(n){if(/^\[/.test(n.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(n.hostname))throw new Ja({input:n.href||n});if(/^\[/.test(n.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(n.host))throw new Ja({input:n.href||n});return n}function Xa(n,e){var t=e||{};for(var s of Ly)t[s]=n[s];return t.hostname.startsWith("[")&&(t.hostname=t.hostname.slice(1,-1)),t.port!==""&&(t.port=Number(t.port)),t.path=t.search?t.pathname+t.search:t.pathname,t}function Qa(n,e){var t;for(var s in e)n.test(s)&&(t=e[s],delete e[s]);return t===null||typeof t>"u"?void 0:String(t).trim()}function An(n,e,t){function s(r){ls(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,r||{}),this.code=n,this.message=this.cause?e+": "+this.cause.message:e}return s.prototype=new(t||Error),Object.defineProperties(s.prototype,{constructor:{value:s,enumerable:!1},name:{value:"Error ["+n+"]",enumerable:!1}}),s}function io(n,e){for(var t of so)n.removeListener(t,no[t]);n.on("error",Od),n.destroy(e)}function Ny(n,e){eo(cs(n)&&cs(e));var t=n.length-e.length-1;return t>0&&n[t]==="."&&n.endsWith(e)}function cs(n){return typeof n=="string"||n instanceof String}function ls(n){return typeof n=="function"}function qy(n){return typeof n=="object"&&"length"in n}function zy(n){return Sn&&n instanceof Sn}ao.exports=Ld({http:Uy,https:Dy});ao.exports.wrap=Ld});var fs=U((fA,ju)=>{"use strict";ju.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}}});var Bn=U((gA,ko)=>{"use strict";var{EMPTY_BUFFER:Fv}=fs();function Gu(n,e){if(n.length===0)return Fv;if(n.length===1)return n[0];let t=Buffer.allocUnsafe(e),s=0;for(let r=0;r<n.length;r++){let i=n[r];t.set(i,s),s+=i.length}return s<e?t.slice(0,s):t}function Nu(n,e,t,s,r){for(let i=0;i<r;i++)t[s+i]=n[i]^e[i&3]}function qu(n,e){let t=n.length;for(let s=0;s<t;s++)n[s]^=e[s&3]}function zu(n){return n.byteLength===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}function hi(n){if(hi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=Buffer.from(n):ArrayBuffer.isView(n)?e=Buffer.from(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),hi.readOnly=!1),e}try{let n=V("bufferutil"),e=n.BufferUtil||n;ko.exports={concat:Gu,mask(t,s,r,i,a){a<48?Nu(t,s,r,i,a):e.mask(t,s,r,i,a)},toArrayBuffer:zu,toBuffer:hi,unmask(t,s){t.length<32?qu(t,s):e.unmask(t,s)}}}catch{ko.exports={concat:Gu,mask:Nu,toArrayBuffer:zu,toBuffer:hi,unmask:qu}}});var Vu=U((_A,Wu)=>{"use strict";var $u=Symbol("kDone"),Po=Symbol("kRun"),Mo=class{constructor(e){this[$u]=()=>{this.pending--,this[Po]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Po]()}[Po](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[$u])}}};Wu.exports=Mo});var Nn=U((yA,Ju)=>{"use strict";var jn=V("zlib"),Ku=Bn(),Bv=Vu(),{kStatusCode:Hu,NOOP:jv}=fs(),Gv=Buffer.from([0,0,255,255]),gi=Symbol("permessage-deflate"),Dt=Symbol("total-length"),Gn=Symbol("callback"),zt=Symbol("buffers"),fi=Symbol("error"),mi,Io=class{constructor(e,t,s){if(this._maxPayload=s|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!mi){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;mi=new Bv(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Gn];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,s=e.find(r=>!(t.serverNoContextTakeover===!1&&r.server_no_context_takeover||r.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>r.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!r.client_max_window_bits));if(!s)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(s.server_no_context_takeover=!0),t.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(s.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?s.client_max_window_bits=t.clientMaxWindowBits:(s.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(s=>{let r=t[s];if(r.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(r=r[0],s==="client_max_window_bits"){if(r!==!0){let i=+r;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${s}": ${r}`);r=i}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${r}`)}else if(s==="server_max_window_bits"){let i=+r;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${s}": ${r}`);r=i}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(r!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${r}`)}else throw new Error(`Unknown parameter "${s}"`);t[s]=r})}),e}decompress(e,t,s){mi.add(r=>{this._decompress(e,t,(i,a)=>{r(),s(i,a)})})}compress(e,t,s){mi.add(r=>{this._compress(e,t,(i,a)=>{r(),s(i,a)})})}_decompress(e,t,s){let r=this._isServer?"client":"server";if(!this._inflate){let i=`${r}_max_window_bits`,a=typeof this.params[i]!="number"?jn.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=jn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[gi]=this,this._inflate[Dt]=0,this._inflate[zt]=[],this._inflate.on("error",qv),this._inflate.on("data",Qu)}this._inflate[Gn]=s,this._inflate.write(e),t&&this._inflate.write(Gv),this._inflate.flush(()=>{let i=this._inflate[fi];if(i){this._inflate.close(),this._inflate=null,s(i);return}let a=Ku.concat(this._inflate[zt],this._inflate[Dt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Dt]=0,this._inflate[zt]=[],t&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),s(null,a)})}_compress(e,t,s){let r=this._isServer?"server":"client";if(!this._deflate){let i=`${r}_max_window_bits`,a=typeof this.params[i]!="number"?jn.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=jn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[Dt]=0,this._deflate[zt]=[],this._deflate.on("error",jv),this._deflate.on("data",Nv)}this._deflate[Gn]=s,this._deflate.write(e),this._deflate.flush(jn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=Ku.concat(this._deflate[zt],this._deflate[Dt]);t&&(i=i.slice(0,i.length-4)),this._deflate[Gn]=null,this._deflate[Dt]=0,this._deflate[zt]=[],t&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),s(null,i)})}};Ju.exports=Io;function Nv(n){this[zt].push(n),this[Dt]+=n.length}function Qu(n){if(this[Dt]+=n.length,this[gi]._maxPayload<1||this[Dt]<=this[gi]._maxPayload){this[zt].push(n);return}this[fi]=new RangeError("Max payload size exceeded"),this[fi].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[fi][Hu]=1009,this.removeListener("data",Qu),this.reset()}function qv(n){this[gi]._inflate=null,n[Hu]=1007,this[Gn](n)}});var Uo=U((vA,To)=>{"use strict";function Yu(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Xu(n){let e=n.length,t=0;for(;t<e;)if((n[t]&128)===0)t++;else if((n[t]&224)===192){if(t+1===e||(n[t+1]&192)!==128||(n[t]&254)===192)return!1;t+=2}else if((n[t]&240)===224){if(t+2>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return!1;t+=3}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return!1;t+=4}else return!1;return!0}try{let n=V("utf-8-validate");typeof n=="object"&&(n=n.Validation.isValidUTF8),To.exports={isValidStatusCode:Yu,isValidUTF8(e){return e.length<150?Xu(e):n(e)}}}catch{To.exports={isValidStatusCode:Yu,isValidUTF8:Xu}}});var Fo=U((bA,rh)=>{"use strict";var{Writable:zv}=V("stream"),Zu=Nn(),{BINARY_TYPES:$v,EMPTY_BUFFER:Wv,kStatusCode:Vv,kWebSocket:Kv}=fs(),{concat:Do,toArrayBuffer:Hv,unmask:Qv}=Bn(),{isValidStatusCode:Jv,isValidUTF8:eh}=Uo(),qn=0,th=1,sh=2,nh=3,Lo=4,Yv=5,Oo=class extends zv{constructor(e,t,s,r){super(),this._binaryType=e||$v[0],this[Kv]=void 0,this._extensions=t||{},this._isServer=!!s,this._maxPayload=r|0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=qn,this._loop=!1}_write(e,t,s){if(this._opcode===8&&this._state==qn)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=s.slice(e),s.slice(0,e)}let t=Buffer.allocUnsafe(e);do{let s=this._buffers[0],r=t.length-e;e>=s.length?t.set(this._buffers.shift(),r):(t.set(new Uint8Array(s.buffer,s.byteOffset,e),r),this._buffers[0]=s.slice(e)),e-=s.length}while(e>0);return t}startLoop(e){let t;this._loop=!0;do switch(this._state){case qn:t=this.getInfo();break;case th:t=this.getPayloadLength16();break;case sh:t=this.getPayloadLength64();break;case nh:this.getMask();break;case Lo:t=this.getData(e);break;default:this._loop=!1;return}while(this._loop);e(t)}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let e=this.consume(2);if((e[0]&48)!==0)return this._loop=!1,Se(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let t=(e[0]&64)===64;if(t&&!this._extensions[Zu.extensionName])return this._loop=!1,Se(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(e[0]&128)===128,this._opcode=e[0]&15,this._payloadLength=e[1]&127,this._opcode===0){if(t)return this._loop=!1,Se(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,Se(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,Se(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=t}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,Se(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(t)return this._loop=!1,Se(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,Se(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,Se(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(e[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,Se(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,Se(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=th;else if(this._payloadLength===127)this._state=sh;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let e=this.consume(8),t=e.readUInt32BE(0);return t>Math.pow(2,21)-1?(this._loop=!1,Se(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=t*Math.pow(2,32)+e.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,Se(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=nh:this._state=Lo}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Lo}getData(e){let t=Wv;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&Qv(t,this._mask)}if(this._opcode>7)return this.controlMessage(t);if(this._compressed){this._state=Yv,this.decompress(t,e);return}return t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage()}decompress(e,t){this._extensions[Zu.extensionName].decompress(e,this._fin,(r,i)=>{if(r)return t(r);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return t(Se(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(i)}let a=this.dataMessage();if(a)return t(a);this.startLoop(t)})}dataMessage(){if(this._fin){let e=this._messageLength,t=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=Do(t,e):this._binaryType==="arraybuffer"?s=Hv(Do(t,e)):s=t,this.emit("message",s)}else{let s=Do(t,e);if(!eh(s))return this._loop=!1,Se(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",s.toString())}}this._state=qn}controlMessage(e){if(this._opcode===8)if(this._loop=!1,e.length===0)this.emit("conclude",1005,""),this.end();else{if(e.length===1)return Se(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let t=e.readUInt16BE(0);if(!Jv(t))return Se(RangeError,`invalid status code ${t}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let s=e.slice(2);if(!eh(s))return Se(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",t,s.toString()),this.end()}}else this._opcode===9?this.emit("ping",e):this.emit("pong",e);this._state=qn}};rh.exports=Oo;function Se(n,e,t,s,r){let i=new n(t?`Invalid WebSocket frame: ${e}`:e);return Error.captureStackTrace(i,Se),i.code=r,i[Vv]=s,i}});var jo=U((EA,oh)=>{"use strict";var wA=V("net"),xA=V("tls"),{randomFillSync:Xv}=V("crypto"),ih=Nn(),{EMPTY_BUFFER:Zv}=fs(),{isValidStatusCode:eb}=Uo(),{mask:ah,toBuffer:Lt}=Bn(),gs=Buffer.alloc(4),Bo=class n{constructor(e,t){this._extensions=t||{},this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let s=t.mask&&t.readOnly,r=t.mask?6:2,i=e.length;e.length>=65536?(r+=8,i=127):e.length>125&&(r+=2,i=126);let a=Buffer.allocUnsafe(s?e.length+r:r);return a[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(a[0]|=64),a[1]=i,i===126?a.writeUInt16BE(e.length,2):i===127&&(a.writeUInt32BE(0,2),a.writeUInt32BE(e.length,6)),t.mask?(Xv(gs,0,4),a[1]|=128,a[r-4]=gs[0],a[r-3]=gs[1],a[r-2]=gs[2],a[r-1]=gs[3],s?(ah(e,gs,a,r,e.length),[a]):(ah(e,gs,e,0,e.length),[a,e])):[a,e]}close(e,t,s,r){let i;if(e===void 0)i=Zv;else{if(typeof e!="number"||!eb(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||t==="")i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else{let a=Buffer.byteLength(t);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+a),i.writeUInt16BE(e,0),i.write(t,2)}}this._deflating?this.enqueue([this.doClose,i,s,r]):this.doClose(i,s,r)}doClose(e,t,s){this.sendFrame(n.frame(e,{fin:!0,rsv1:!1,opcode:8,mask:t,readOnly:!1}),s)}ping(e,t,s){let r=Lt(e);if(r.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPing,r,t,Lt.readOnly,s]):this.doPing(r,t,Lt.readOnly,s)}doPing(e,t,s,r){this.sendFrame(n.frame(e,{fin:!0,rsv1:!1,opcode:9,mask:t,readOnly:s}),r)}pong(e,t,s){let r=Lt(e);if(r.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPong,r,t,Lt.readOnly,s]):this.doPong(r,t,Lt.readOnly,s)}doPong(e,t,s,r){this.sendFrame(n.frame(e,{fin:!0,rsv1:!1,opcode:10,mask:t,readOnly:s}),r)}send(e,t,s){let r=Lt(e),i=this._extensions[ih.extensionName],a=t.binary?2:1,o=t.compress;if(this._firstFragment?(this._firstFragment=!1,o&&i&&(o=r.length>=i._threshold),this._compress=o):(o=!1,a=0),t.fin&&(this._firstFragment=!0),i){let c={fin:t.fin,rsv1:o,opcode:a,mask:t.mask,readOnly:Lt.readOnly};this._deflating?this.enqueue([this.dispatch,r,this._compress,c,s]):this.dispatch(r,this._compress,c,s)}else this.sendFrame(n.frame(r,{fin:t.fin,rsv1:!1,opcode:a,mask:t.mask,readOnly:Lt.readOnly}),s)}dispatch(e,t,s,r){if(!t){this.sendFrame(n.frame(e,s),r);return}let i=this._extensions[ih.extensionName];this._bufferedBytes+=e.length,this._deflating=!0,i.compress(e,s.fin,(a,o)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof r=="function"&&r(c);for(let l=0;l<this._queue.length;l++){let p=this._queue[l][4];typeof p=="function"&&p(c)}return}this._bufferedBytes-=e.length,this._deflating=!1,s.readOnly=!1,this.sendFrame(n.frame(o,s),r),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[1].length,Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[1].length,this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};oh.exports=Bo});var lh=U((CA,ch)=>{"use strict";var Qs=class{constructor(e,t){this.target=t,this.type=e}},Go=class extends Qs{constructor(e,t){super("message",t),this.data=e}},No=class extends Qs{constructor(e,t,s){super("close",s),this.wasClean=s._closeFrameReceived&&s._closeFrameSent,this.reason=t,this.code=e}},qo=class extends Qs{constructor(e){super("open",e)}},zo=class extends Qs{constructor(e,t){super("error",t),this.message=e.message,this.error=e}},tb={addEventListener(n,e,t){if(typeof e!="function")return;function s(c){e.call(this,new Go(c,this))}function r(c,l){e.call(this,new No(c,l,this))}function i(c){e.call(this,new zo(c,this))}function a(){e.call(this,new qo(this))}let o=t&&t.once?"once":"on";n==="message"?(s._listener=e,this[o](n,s)):n==="close"?(r._listener=e,this[o](n,r)):n==="error"?(i._listener=e,this[o](n,i)):n==="open"?(a._listener=e,this[o](n,a)):this[o](n,e)},removeEventListener(n,e){let t=this.listeners(n);for(let s=0;s<t.length;s++)(t[s]===e||t[s]._listener===e)&&this.removeListener(n,t[s])}};ch.exports=tb});var $o=U((SA,ph)=>{"use strict";var zn=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Et(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t)}function sb(n){let e=Object.create(null);if(n===void 0||n==="")return e;let t=Object.create(null),s=!1,r=!1,i=!1,a,o,c=-1,l=-1,p=0;for(;p<n.length;p++){let u=n.charCodeAt(p);if(a===void 0)if(l===-1&&zn[u]===1)c===-1&&(c=p);else if(u===32||u===9)l===-1&&c!==-1&&(l=p);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);l===-1&&(l=p);let h=n.slice(c,l);u===44?(Et(e,h,t),t=Object.create(null)):a=h,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${p}`);else if(o===void 0)if(l===-1&&zn[u]===1)c===-1&&(c=p);else if(u===32||u===9)l===-1&&c!==-1&&(l=p);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);l===-1&&(l=p),Et(t,n.slice(c,l),!0),u===44&&(Et(e,a,t),t=Object.create(null),a=void 0),c=l=-1}else if(u===61&&c!==-1&&l===-1)o=n.slice(c,p),c=l=-1;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(r){if(zn[u]!==1)throw new SyntaxError(`Unexpected character at index ${p}`);c===-1?c=p:s||(s=!0),r=!1}else if(i)if(zn[u]===1)c===-1&&(c=p);else if(u===34&&c!==-1)i=!1,l=p;else if(u===92)r=!0;else throw new SyntaxError(`Unexpected character at index ${p}`);else if(u===34&&n.charCodeAt(p-1)===61)i=!0;else if(l===-1&&zn[u]===1)c===-1&&(c=p);else if(c!==-1&&(u===32||u===9))l===-1&&(l=p);else if(u===59||u===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${p}`);l===-1&&(l=p);let h=n.slice(c,l);s&&(h=h.replace(/\\/g,""),s=!1),Et(t,o,h),u===44&&(Et(e,a,t),t=Object.create(null),a=void 0),o=void 0,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${p}`)}if(c===-1||i)throw new SyntaxError("Unexpected end of input");l===-1&&(l=p);let d=n.slice(c,l);return a===void 0?Et(e,d,t):(o===void 0?Et(t,d,!0):s?Et(t,o,d.replace(/\\/g,"")):Et(t,o,d),Et(e,a,t)),e}function nb(n){return Object.keys(n).map(e=>{let t=n[e];return Array.isArray(t)||(t=[t]),t.map(s=>[e].concat(Object.keys(s).map(r=>{let i=s[r];return Array.isArray(i)||(i=[i]),i.map(a=>a===!0?r:`${r}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}ph.exports={format:nb,parse:sb}});var Jo=U((AA,bh)=>{"use strict";var rb=V("events"),ib=(jt(),un(gn)),ab=V("http"),hh=V("net"),ob=V("tls"),{randomBytes:cb,createHash:lb}=V("crypto"),{Readable:RA}=V("stream"),{URL:Wo}=V("url"),$t=Nn(),pb=Fo(),db=jo(),{BINARY_TYPES:dh,EMPTY_BUFFER:Vo,GUID:ub,kStatusCode:hb,kWebSocket:Ne,NOOP:mh}=fs(),{addEventListener:mb,removeEventListener:fb}=lh(),{format:gb,parse:_b}=$o(),{toBuffer:yb}=Bn(),Ot=["CONNECTING","OPEN","CLOSING","CLOSED"],Ko=[8,13],vb=30*1e3,xe=class n extends rb{constructor(e,t,s){super(),this._binaryType=dh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._extensions={},this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(t)?t=t.join(", "):typeof t=="object"&&t!==null&&(s=t,t=void 0),fh(this,e,t,s)):this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(e){dh.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get onclose(){}set onclose(e){}get onerror(){}set onerror(e){}get onopen(){}set onopen(e){}get onmessage(){}set onmessage(e){}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,s){let r=new pb(this.binaryType,this._extensions,this._isServer,s);this._sender=new db(e,this._extensions),this._receiver=r,this._socket=e,r[Ne]=this,e[Ne]=this,r.on("conclude",xb),r.on("drain",Eb),r.on("error",Cb),r.on("message",Sb),r.on("ping",Rb),r.on("pong",Ab),e.setTimeout(0),e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",_h),e.on("data",_i),e.on("end",yh),e.on("error",vh),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[$t.extensionName]&&this._extensions[$t.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING)return st(this,this._req,"WebSocket was closed before the connection was established");if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,t,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),vb)}}ping(e,t,s){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=t=void 0):typeof t=="function"&&(s=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Qo(this,e,s);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Vo,t,s)}pong(e,t,s){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=t=void 0):typeof t=="function"&&(s=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Qo(this,e,s);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Vo,t,s)}send(e,t,s){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(s=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Qo(this,e,s);return}let r={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[$t.extensionName]||(r.compress=!1),this._sender.send(e||Vo,r,s)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING)return st(this,this._req,"WebSocket was closed before the connection was established");this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(xe,"CONNECTING",{enumerable:!0,value:Ot.indexOf("CONNECTING")});Object.defineProperty(xe.prototype,"CONNECTING",{enumerable:!0,value:Ot.indexOf("CONNECTING")});Object.defineProperty(xe,"OPEN",{enumerable:!0,value:Ot.indexOf("OPEN")});Object.defineProperty(xe.prototype,"OPEN",{enumerable:!0,value:Ot.indexOf("OPEN")});Object.defineProperty(xe,"CLOSING",{enumerable:!0,value:Ot.indexOf("CLOSING")});Object.defineProperty(xe.prototype,"CLOSING",{enumerable:!0,value:Ot.indexOf("CLOSING")});Object.defineProperty(xe,"CLOSED",{enumerable:!0,value:Ot.indexOf("CLOSED")});Object.defineProperty(xe.prototype,"CLOSED",{enumerable:!0,value:Ot.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(n=>{Object.defineProperty(xe.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(xe.prototype,`on${n}`,{enumerable:!0,get(){let e=this.listeners(n);for(let t=0;t<e.length;t++)if(e[t]._listener)return e[t]._listener},set(e){let t=this.listeners(n);for(let s=0;s<t.length;s++)t[s]._listener&&this.removeListener(n,t[s]);this.addEventListener(n,e)}})});xe.prototype.addEventListener=mb;xe.prototype.removeEventListener=fb;bh.exports=xe;function fh(n,e,t,s){let r={protocolVersion:Ko[1],maxPayload:104857600,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,host:void 0,path:void 0,port:void 0};if(!Ko.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${Ko.join(", ")})`);let i;e instanceof Wo?(i=e,n._url=e.href):(i=new Wo(e),n._url=e);let a=i.protocol==="ws+unix:";if(!i.host&&(!a||!i.pathname)){let h=new Error(`Invalid URL: ${n.url}`);if(n._redirects===0)throw h;Ho(n,h);return}let o=i.protocol==="wss:"||i.protocol==="https:",c=o?443:80,l=cb(16).toString("base64"),p=o?ib.get:ab.get,d;if(r.createConnection=o?wb:bb,r.defaultPort=r.defaultPort||c,r.port=i.port||c,r.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,r.headers={"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket",...r.headers},r.path=i.pathname+i.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(d=new $t(r.perMessageDeflate!==!0?r.perMessageDeflate:{},!1,r.maxPayload),r.headers["Sec-WebSocket-Extensions"]=gb({[$t.extensionName]:d.offer()})),t&&(r.headers["Sec-WebSocket-Protocol"]=t),r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(i.username||i.password)&&(r.auth=`${i.username}:${i.password}`),a){let h=r.path.split(":");r.socketPath=h[0],r.path=h[1]}if(r.followRedirects){if(n._redirects===0){n._originalUnixSocket=a,n._originalSecure=o,n._originalHostOrSocketPath=a?r.socketPath:i.host;let h=s&&s.headers;if(s={...s,headers:{}},h)for(let[m,g]of Object.entries(h))s.headers[m.toLowerCase()]=g}else{let h=a?n._originalUnixSocket?r.socketPath===n._originalHostOrSocketPath:!1:n._originalUnixSocket?!1:i.host===n._originalHostOrSocketPath;(!h||n._originalSecure&&!o)&&(delete r.headers.authorization,delete r.headers.cookie,h||delete r.headers.host,r.auth=void 0)}r.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64"))}let u=n._req=p(r);r.timeout&&u.on("timeout",()=>{st(n,u,"Opening handshake has timed out")}),u.on("error",h=>{u===null||u.aborted||(u=n._req=null,Ho(n,h))}),u.on("response",h=>{let m=h.headers.location,g=h.statusCode;if(m&&r.followRedirects&&g>=300&&g<400){if(++n._redirects>r.maxRedirects){st(n,u,"Maximum redirects exceeded");return}u.abort();let _;try{_=new Wo(m,e)}catch(v){Ho(n,v);return}fh(n,_,t,s)}else n.emit("unexpected-response",u,h)||st(n,u,`Unexpected server response: ${h.statusCode}`)}),u.on("upgrade",(h,m,g)=>{if(n.emit("upgrade",h),n.readyState!==xe.CONNECTING)return;u=n._req=null;let _=h.headers.upgrade;if(_===void 0||_.toLowerCase()!=="websocket"){st(n,m,"Invalid Upgrade header");return}let v=lb("sha1").update(l+ub).digest("base64");if(h.headers["sec-websocket-accept"]!==v){st(n,m,"Invalid Sec-WebSocket-Accept header");return}let y=h.headers["sec-websocket-protocol"],x=(t||"").split(/, */),C;if(!t&&y?C="Server sent a subprotocol but none was requested":t&&!y?C="Server sent no subprotocol":y&&!x.includes(y)&&(C="Server sent an invalid subprotocol"),C){st(n,m,C);return}y&&(n._protocol=y);let S=h.headers["sec-websocket-extensions"];if(S!==void 0){if(!d){st(n,m,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;try{P=_b(S)}catch{st(n,m,"Invalid Sec-WebSocket-Extensions header");return}let E=Object.keys(P);if(E.length){if(E.length!==1||E[0]!==$t.extensionName){st(n,m,"Server indicated an extension that was not requested");return}try{d.accept(P[$t.extensionName])}catch{st(n,m,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[$t.extensionName]=d}}n.setSocket(m,g,r.maxPayload)})}function Ho(n,e){n._readyState=xe.CLOSING,n.emit("error",e),n.emitClose()}function bb(n){return n.path=n.socketPath,hh.connect(n)}function wb(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=hh.isIP(n.host)?"":n.host),ob.connect(n)}function st(n,e,t){n._readyState=xe.CLOSING;let s=new Error(t);Error.captureStackTrace(s,st),e.setHeader?(e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),e.once("abort",n.emitClose.bind(n)),n.emit("error",s)):(e.destroy(s),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Qo(n,e,t){if(e){let s=yb(e).length;n._socket?n._sender._bufferedBytes+=s:n._bufferedAmount+=s}if(t){let s=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ot[n.readyState]})`);t(s)}}function xb(n,e){let t=this[Ne];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=n,t._socket[Ne]!==void 0&&(t._socket.removeListener("data",_i),process.nextTick(gh,t._socket),n===1005?t.close():t.close(n,e))}function Eb(){this[Ne]._socket.resume()}function Cb(n){let e=this[Ne];e._socket[Ne]!==void 0&&(e._socket.removeListener("data",_i),process.nextTick(gh,e._socket),e.close(n[hb])),e.emit("error",n)}function uh(){this[Ne].emitClose()}function Sb(n){this[Ne].emit("message",n)}function Rb(n){let e=this[Ne];e.pong(n,!e._isServer,mh),e.emit("ping",n)}function Ab(n){this[Ne].emit("pong",n)}function gh(n){n.resume()}function _h(){let n=this[Ne];this.removeListener("close",_h),this.removeListener("data",_i),this.removeListener("end",yh),n._readyState=xe.CLOSING;let e;!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&(e=n._socket.read())!==null&&n._receiver.write(e),n._receiver.end(),this[Ne]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",uh),n._receiver.on("finish",uh))}function _i(n){this[Ne]._receiver.write(n)||this.pause()}function yh(){let n=this[Ne];n._readyState=xe.CLOSING,n._receiver.end(),this.end()}function vh(){let n=this[Ne];this.removeListener("error",vh),this.on("error",mh),n&&(n._readyState=xe.CLOSING,this.destroy())}});var Ch=U((kA,Eh)=>{"use strict";var{Duplex:kb}=V("stream");function wh(n){n.emit("close")}function Pb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function xh(n){this.removeListener("error",xh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function Mb(n,e){let t=!0,s=!0;function r(){t&&n._socket.resume()}n.readyState===n.CONNECTING?n.once("open",function(){n._receiver.removeAllListeners("drain"),n._receiver.on("drain",r)}):(n._receiver.removeAllListeners("drain"),n._receiver.on("drain",r));let i=new kb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(o){i.push(o)||(t=!1,n._socket.pause())}),n.once("error",function(o){i.destroyed||(s=!1,i.destroy(o))}),n.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(a,o){if(n.readyState===n.CLOSED){o(a),process.nextTick(wh,i);return}let c=!1;n.once("error",function(p){c=!0,o(p)}),n.once("close",function(){c||o(a),process.nextTick(wh,i)}),s&&n.terminate()},i._final=function(a){if(n.readyState===n.CONNECTING){n.once("open",function(){i._final(a)});return}n._socket!==null&&(n._socket._writableState.finished?(a(),i._readableState.endEmitted&&i.destroy()):(n._socket.once("finish",function(){a()}),n.close()))},i._read=function(){(n.readyState===n.OPEN||n.readyState===n.CLOSING)&&!t&&(t=!0,n._receiver._writableState.needDrain||n._socket.resume())},i._write=function(a,o,c){if(n.readyState===n.CONNECTING){n.once("open",function(){i._write(a,o,c)});return}n.send(a,c)},i.on("end",Pb),i.on("error",xh),i}Eh.exports=Mb});var Ph=U((TA,kh)=>{"use strict";var Ib=V("events"),yi=V("http"),PA=(jt(),un(gn)),MA=V("net"),IA=V("tls"),{createHash:Tb}=V("crypto"),_s=Nn(),Ub=Jo(),{format:Db,parse:Lb}=$o(),{GUID:Ob,kWebSocket:Fb}=fs(),Bb=/^[+/0-9A-Za-z]{22}==$/,Sh=0,Rh=1,Ah=2,Xo=class extends Ib{constructor(e,t){if(super(),e={maxPayload:100*1024*1024,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=yi.createServer((s,r)=>{let i=yi.STATUS_CODES[426];r.writeHead(426,{"Content-Length":i.length,"Content-Type":"text/plain"}),r.end(i)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=jb(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(r,i,a)=>{this.handleUpgrade(r,i,a,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set),this.options=e,this._state=Sh}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(e&&this.once("close",e),this._state===Ah){process.nextTick(Yo,this);return}if(this._state===Rh)return;if(this._state=Rh,this.clients)for(let s of this.clients)s.terminate();let t=this._server;if(t&&(this._removeListeners(),this._removeListeners=this._server=null,this.options.port!=null)){t.close(Yo.bind(void 0,this));return}process.nextTick(Yo,this)}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,s,r){t.on("error",Zo);let i=e.headers["sec-websocket-key"]!==void 0?e.headers["sec-websocket-key"].trim():!1,a=e.headers.upgrade,o=+e.headers["sec-websocket-version"],c={};if(e.method!=="GET"||a===void 0||a.toLowerCase()!=="websocket"||!i||!Bb.test(i)||o!==8&&o!==13||!this.shouldHandle(e))return $n(t,400);if(this.options.perMessageDeflate){let l=new _s(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let p=Lb(e.headers["sec-websocket-extensions"]);p[_s.extensionName]&&(l.accept(p[_s.extensionName]),c[_s.extensionName]=l)}catch{return $n(t,400)}}if(this.options.verifyClient){let l={origin:e.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(l,(p,d,u,h)=>{if(!p)return $n(t,d||401,u,h);this.completeUpgrade(i,c,e,t,s,r)});return}if(!this.options.verifyClient(l))return $n(t,401)}this.completeUpgrade(i,c,e,t,s,r)}completeUpgrade(e,t,s,r,i,a){if(!r.readable||!r.writable)return r.destroy();if(r[Fb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Sh)return $n(r,503);let c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Tb("sha1").update(e+Ob).digest("base64")}`],l=new Ub(null),p=s.headers["sec-websocket-protocol"];if(p&&(p=p.split(",").map(Gb),this.options.handleProtocols?p=this.options.handleProtocols(p,s):p=p[0],p&&(c.push(`Sec-WebSocket-Protocol: ${p}`),l._protocol=p)),t[_s.extensionName]){let d=t[_s.extensionName].params,u=Db({[_s.extensionName]:[d]});c.push(`Sec-WebSocket-Extensions: ${u}`),l._extensions=t}this.emit("headers",c,s),r.write(c.concat(`\r
7
7
  `).join(`\r
8
- `)),n.removeListener("error",ba),c.setSocket(n,a,this.options.maxPayload),this.clients&&(this.clients.add(c),c.on("close",()=>this.clients.delete(c))),r(c,i)}};lp.exports=va;function qf(s,e){for(let t of Object.keys(e))s.on(t,e[t]);return function(){for(let i of Object.keys(e))s.removeListener(i,e[i])}}function xa(s){s._state=cp,s.emit("close")}function ba(){this.destroy()}function Us(s,e,t,i){s.writable&&(t=t||Si.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...i},s.write(`HTTP/1.1 ${e} ${Si.STATUS_CODES[e]}\r
9
- `+Object.keys(i).map(n=>`${n}: ${i[n]}`).join(`\r
8
+ `)),r.removeListener("error",Zo),l.setSocket(r,i,this.options.maxPayload),this.clients&&(this.clients.add(l),l.on("close",()=>this.clients.delete(l))),a(l,s)}};kh.exports=Xo;function jb(n,e){for(let t of Object.keys(e))n.on(t,e[t]);return function(){for(let s of Object.keys(e))n.removeListener(s,e[s])}}function Yo(n){n._state=Ah,n.emit("close")}function Zo(){this.destroy()}function $n(n,e,t,s){n.writable&&(t=t||yi.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...s},n.write(`HTTP/1.1 ${e} ${yi.STATUS_CODES[e]}\r
9
+ `+Object.keys(s).map(r=>`${r}: ${s[r]}`).join(`\r
10
10
  `)+`\r
11
11
  \r
12
- `+t)),s.removeListener("error",ba),s.destroy()}function Bf(s){return s.trim()}});var dp=y((E_,up)=>{"use strict";var Os=ga();Os.createWebSocketStream=ap();Os.Server=pp();Os.Receiver=ia();Os.Sender=aa();up.exports=Os});var hp=y((S_,mp)=>{"use strict";mp.exports=dp()});var gp=y((ya,Ti)=>{"use strict";(function(s){"use strict";var e=s.setTimeout,t=s.clearTimeout,i=s.XMLHttpRequest,n=s.XDomainRequest,a=s.ActiveXObject,r=s.EventSource,o=s.document,l=s.Promise,c=s.fetch,p=s.Response,d=s.TextDecoder,u=s.TextEncoder,f=s.AbortController;if(typeof window<"u"&&typeof o<"u"&&!("readyState"in o)&&o.body==null&&(o.readyState="loading",window.addEventListener("load",function(g){o.readyState="complete"},!1)),i==null&&a!=null&&(i=function(){return new a("Microsoft.XMLHTTP")}),Object.create==null&&(Object.create=function(g){function w(){}return w.prototype=g,new w}),Date.now||(Date.now=function(){return new Date().getTime()}),f==null){var h=c;c=function(g,w){var S=w.signal;return h(g,{headers:w.headers,credentials:w.credentials,cache:w.cache}).then(function(C){var D=C.body.getReader();return S._reader=D,S._aborted&&S._reader.cancel(),{status:C.status,statusText:C.statusText,headers:C.headers,body:{getReader:function(){return D}}}})},f=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){this.signal._reader!=null&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function x(){this.bitsNeeded=0,this.codePoint=0}x.prototype.decode=function(g){function w(B,W,U){if(U===1)return B>=128>>W&&B<<W<=2047;if(U===2)return B>=2048>>W&&B<<W<=55295||B>=57344>>W&&B<<W<=65535;if(U===3)return B>=65536>>W&&B<<W<=1114111;throw new Error}function S(B,W){if(B===6)return W>>6>15?3:W>31?2:1;if(B===12)return W>15?3:2;if(B===18)return 3;throw new Error}for(var C=65533,D="",A=this.bitsNeeded,L=this.codePoint,J=0;J<g.length;J+=1){var F=g[J];A!==0&&(F<128||F>191||!w(L<<6|F&63,A-6,S(A,L)))&&(A=0,L=C,D+=String.fromCharCode(L)),A===0?(F>=0&&F<=127?(A=0,L=F):F>=192&&F<=223?(A=6,L=F&31):F>=224&&F<=239?(A=12,L=F&15):F>=240&&F<=247?(A=18,L=F&7):(A=0,L=C),A!==0&&!w(L,A,S(A,L))&&(A=0,L=C)):(A-=6,L=L<<6|F&63),A===0&&(L<=65535?D+=String.fromCharCode(L):(D+=String.fromCharCode(55296+(L-65535-1>>10)),D+=String.fromCharCode(56320+(L-65535-1&1023))))}return this.bitsNeeded=A,this.codePoint=L,D};var v=function(){try{return new d().decode(new u().encode("test"),{stream:!0})==="test"}catch(g){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+g)}return!1};(d==null||u==null||!v())&&(d=x);var b=function(){};function T(g){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=b,this.onload=b,this.onerror=b,this.onreadystatechange=b,this._contentType="",this._xhr=g,this._sendTimeout=0,this._abort=b}T.prototype.open=function(g,w){this._abort(!0);var S=this,C=this._xhr,D=1,A=0;this._abort=function(U){S._sendTimeout!==0&&(t(S._sendTimeout),S._sendTimeout=0),(D===1||D===2||D===3)&&(D=4,C.onload=b,C.onerror=b,C.onabort=b,C.onprogress=b,C.onreadystatechange=b,C.abort(),A!==0&&(t(A),A=0),U||(S.readyState=4,S.onabort(null),S.onreadystatechange())),D=0};var L=function(){if(D===1){var U=0,Q="",ze=void 0;if("contentType"in C)U=200,Q="OK",ze=C.contentType;else try{U=C.status,Q=C.statusText,ze=C.getResponseHeader("Content-Type")}catch{U=0,Q="",ze=void 0}U!==0&&(D=2,S.readyState=2,S.status=U,S.statusText=Q,S._contentType=ze,S.onreadystatechange())}},J=function(){if(L(),D===2||D===3){D=3;var U="";try{U=C.responseText}catch{}S.readyState=3,S.responseText=U,S.onprogress()}},F=function(U,Q){if((Q==null||Q.preventDefault==null)&&(Q={preventDefault:b}),J(),D===1||D===2||D===3){if(D=4,A!==0&&(t(A),A=0),S.readyState=4,U==="load")S.onload(Q);else if(U==="error")S.onerror(Q);else if(U==="abort")S.onabort(Q);else throw new TypeError;S.onreadystatechange()}},B=function(U){C!=null&&(C.readyState===4?(!("onload"in C)||!("onerror"in C)||!("onabort"in C))&&F(C.responseText===""?"error":"load",U):C.readyState===3?"onprogress"in C||J():C.readyState===2&&L())},W=function(){A=e(function(){W()},500),C.readyState===3&&J()};"onload"in C&&(C.onload=function(U){F("load",U)}),"onerror"in C&&(C.onerror=function(U){F("error",U)}),"onabort"in C&&(C.onabort=function(U){F("abort",U)}),"onprogress"in C&&(C.onprogress=J),"onreadystatechange"in C&&(C.onreadystatechange=function(U){B(U)}),("contentType"in C||!("ontimeout"in i.prototype))&&(w+=(w.indexOf("?")===-1?"?":"&")+"padding=true"),C.open(g,w,!0),"readyState"in C&&(A=e(function(){W()},0))},T.prototype.abort=function(){this._abort(!1)},T.prototype.getResponseHeader=function(g){return this._contentType},T.prototype.setRequestHeader=function(g,w){var S=this._xhr;"setRequestHeader"in S&&S.setRequestHeader(g,w)},T.prototype.getAllResponseHeaders=function(){return this._xhr.getAllResponseHeaders!=null&&this._xhr.getAllResponseHeaders()||""},T.prototype.send=function(){if((!("ontimeout"in i.prototype)||!("sendAsBinary"in i.prototype)&&!("mozAnon"in i.prototype))&&o!=null&&o.readyState!=null&&o.readyState!=="complete"){var g=this;g._sendTimeout=e(function(){g._sendTimeout=0,g.send()},4);return}var w=this._xhr;"withCredentials"in w&&(w.withCredentials=this.withCredentials);try{w.send(void 0)}catch(S){throw S}};function I(g){return g.replace(/[A-Z]/g,function(w){return String.fromCharCode(w.charCodeAt(0)+32)})}function M(g){for(var w=Object.create(null),S=g.split(`\r
13
- `),C=0;C<S.length;C+=1){var D=S[C],A=D.split(": "),L=A.shift(),J=A.join(": ");w[I(L)]=J}this._map=w}M.prototype.get=function(g){return this._map[I(g)]},i!=null&&i.HEADERS_RECEIVED==null&&(i.HEADERS_RECEIVED=2);function O(){}O.prototype.open=function(g,w,S,C,D,A,L){g.open("GET",D);var J=0;g.onprogress=function(){var B=g.responseText,W=B.slice(J);J+=W.length,S(W)},g.onerror=function(B){B.preventDefault(),C(new Error("NetworkError"))},g.onload=function(){C(null)},g.onabort=function(){C(null)},g.onreadystatechange=function(){if(g.readyState===i.HEADERS_RECEIVED){var B=g.status,W=g.statusText,U=g.getResponseHeader("Content-Type"),Q=g.getAllResponseHeaders();w(B,W,U,new M(Q))}},g.withCredentials=A;for(var F in L)Object.prototype.hasOwnProperty.call(L,F)&&g.setRequestHeader(F,L[F]);return g.send(),g};function V(g){this._headers=g}V.prototype.get=function(g){return this._headers.get(g)};function Y(){}Y.prototype.open=function(g,w,S,C,D,A,L){var J=null,F=new f,B=F.signal,W=new d;return c(D,{headers:L,credentials:A?"include":"same-origin",signal:B,cache:"no-store"}).then(function(U){return J=U.body.getReader(),w(U.status,U.statusText,U.headers.get("Content-Type"),new V(U.headers)),new l(function(Q,ze){var Zt=function(){J.read().then(function(Re){if(Re.done)Q(void 0);else{var he=W.decode(Re.value,{stream:!0});S(he),Zt()}}).catch(function(Re){ze(Re)})};Zt()})}).catch(function(U){if(U.name!=="AbortError")return U}).then(function(U){C(U)}),{abort:function(){J?.cancel(),F.abort()}}};function H(){this._listeners=Object.create(null)}function de(g){e(function(){throw g},0)}H.prototype.dispatchEvent=function(g){g.target=this;var w=this._listeners[g.type];if(w!=null)for(var S=w.length,C=0;C<S;C+=1){var D=w[C];try{typeof D.handleEvent=="function"?D.handleEvent(g):D.call(this,g)}catch(A){de(A)}}},H.prototype.addEventListener=function(g,w){g=String(g);var S=this._listeners,C=S[g];C==null&&(C=[],S[g]=C);for(var D=!1,A=0;A<C.length;A+=1)C[A]===w&&(D=!0);D||C.push(w)},H.prototype.removeEventListener=function(g,w){g=String(g);var S=this._listeners,C=S[g];if(C!=null){for(var D=[],A=0;A<C.length;A+=1)C[A]!==w&&D.push(C[A]);D.length===0?delete S[g]:S[g]=D}};function Se(g){this.type=g,this.target=void 0}function Tt(g,w){Se.call(this,g),this.data=w.data,this.lastEventId=w.lastEventId}Tt.prototype=Object.create(Se.prototype);function De(g,w){Se.call(this,g),this.status=w.status,this.statusText=w.statusText,this.headers=w.headers}De.prototype=Object.create(Se.prototype);function rt(g,w){Se.call(this,g),this.error=w.error}rt.prototype=Object.create(Se.prototype);var te=-1,G=0,ie=1,E=2,R=-1,z=0,ve=1,K=2,Ue=3,ot=/^text\/event\-stream(;.*)?$/i,Oe=1e3,be=18e6,kt=function(g,w){var S=g==null?w:parseInt(g,10);return S!==S&&(S=w),ct(S)},ct=function(g){return Math.min(Math.max(g,Oe),be)},Z=function(g,w,S){try{typeof w=="function"&&w.call(g,S)}catch(C){de(C)}};function Me(g,w){H.call(this),w=w||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,_p(this,g,w)}function bp(){return i!=null&&"withCredentials"in i.prototype||n==null?new i:new n}var yp=c!=null&&p!=null&&"body"in p.prototype;function _p(g,w,S){w=String(w);var C=!!S.withCredentials,D=S.lastEventIdQueryParameterName||"lastEventId",A=ct(1e3),L=kt(S.heartbeatTimeout,45e3),J="",F=A,B=!1,W=0,U=S.headers||{},Q=S.Transport,ze=yp&&Q==null?void 0:new T(Q!=null?new Q:bp()),Zt=Q!=null&&typeof Q!="string"?new Q:ze==null?new Y:new O,Re=void 0,he=0,Fe=te,At="",Ms="",We="",Fs="",fe=z,Oi=0,lt=0,Cp=function(oe,ae,Te,ke){if(Fe===G)if(oe===200&&Te!=null&&ot.test(Te)){Fe=ie,B=Date.now(),F=A,g.readyState=ie;var ge=new De("open",{status:oe,statusText:ae,headers:ke});g.dispatchEvent(ge),Z(g,g.onopen,ge)}else{var ue="";oe!==200?(ae&&(ae=ae.replace(/\s+/g," ")),ue="EventSource's response has a status "+oe+" "+ae+" that is not 200. Aborting the connection."):ue="EventSource's response has a Content-Type specifying an unsupported type: "+(Te==null?"-":Te.replace(/\s+/g," "))+". Aborting the connection.",Li();var ge=new De("error",{status:oe,statusText:ae,headers:ke});g.dispatchEvent(ge),Z(g,g.onerror,ge),console.error(ue)}},wp=function(oe){if(Fe===ie){for(var ae=-1,Te=0;Te<oe.length;Te+=1){var ke=oe.charCodeAt(Te);(ke===10||ke===13)&&(ae=Te)}var ge=(ae!==-1?Fs:"")+oe.slice(0,ae+1);Fs=(ae===-1?Fs:"")+oe.slice(ae+1),oe!==""&&(B=Date.now(),W+=oe.length);for(var ue=0;ue<ge.length;ue+=1){var ke=ge.charCodeAt(ue);if(fe===R&&ke===10)fe=z;else if(fe===R&&(fe=z),ke===13||ke===10){if(fe!==z){fe===ve&&(lt=ue+1);var Ve=ge.slice(Oi,lt-1),He=ge.slice(lt+(lt<ue&&ge.charCodeAt(lt)===32?1:0),ue);Ve==="data"?(At+=`
14
- `,At+=He):Ve==="id"?Ms=He:Ve==="event"?We=He:Ve==="retry"?(A=kt(He,A),F=A):Ve==="heartbeatTimeout"&&(L=kt(He,L),he!==0&&(t(he),he=e(function(){es()},L)))}if(fe===z){if(At!==""){J=Ms,We===""&&(We="message");var It=new Tt(We,{data:At.slice(1),lastEventId:Ms});if(g.dispatchEvent(It),We==="open"?Z(g,g.onopen,It):We==="message"?Z(g,g.onmessage,It):We==="error"&&Z(g,g.onerror,It),Fe===E)return}At="",We=""}fe=ke===13?R:z}else fe===z&&(Oi=ue,fe=ve),fe===ve?ke===58&&(lt=ue+1,fe=K):fe===K&&(fe=Ue)}}},Ia=function(oe){if(Fe===ie||Fe===G){Fe=te,he!==0&&(t(he),he=0),he=e(function(){es()},F),F=ct(Math.min(A*16,F*2)),g.readyState=G;var ae=new rt("error",{error:oe});g.dispatchEvent(ae),Z(g,g.onerror,ae),oe!=null&&console.error(oe)}},Li=function(){Fe=E,Re!=null&&(Re.abort(),Re=void 0),he!==0&&(t(he),he=0),g.readyState=E},es=function(){if(he=0,Fe!==te){if(!B&&Re!=null)Ia(new Error("No activity within "+L+" milliseconds. "+(Fe===G?"No response received.":W+" chars received.")+" Reconnecting.")),Re!=null&&(Re.abort(),Re=void 0);else{var oe=Math.max((B||Date.now())+L-Date.now(),1);B=!1,he=e(function(){es()},oe)}return}B=!1,W=0,he=e(function(){es()},L),Fe=G,At="",We="",Ms=J,Fs="",Oi=0,lt=0,fe=z;var ae=w;if(w.slice(0,5)!=="data:"&&w.slice(0,5)!=="blob:"&&J!==""){var Te=w.indexOf("?");ae=Te===-1?w:w.slice(0,Te+1)+w.slice(Te+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(He,It){return It===D?"":He}),ae+=(w.indexOf("?")===-1?"?":"&")+D+"="+encodeURIComponent(J)}var ke=g.withCredentials,ge={};ge.Accept="text/event-stream";var ue=g.headers;if(ue!=null)for(var Ve in ue)Object.prototype.hasOwnProperty.call(ue,Ve)&&(ge[Ve]=ue[Ve]);try{Re=Zt.open(ze,Cp,wp,Ia,ae,ke,ge)}catch(He){throw Li(),He}};g.url=w,g.readyState=G,g.withCredentials=C,g.headers=U,g._close=Li,es()}Me.prototype=Object.create(H.prototype),Me.prototype.CONNECTING=G,Me.prototype.OPEN=ie,Me.prototype.CLOSED=E,Me.prototype.close=function(){this._close()},Me.CONNECTING=G,Me.OPEN=ie,Me.CLOSED=E,Me.prototype.withCredentials=void 0;var Aa=r;i!=null&&(r==null||!("withCredentials"in r.prototype))&&(Aa=Me),(function(g){if(typeof Ti=="object"&&typeof Ti.exports=="object"){var w=g(ya);w!==void 0&&(Ti.exports=w)}else typeof define=="function"&&define.amd?define(["exports"],g):g(s)})(function(g){g.EventSourcePolyfill=Me,g.NativeEventSource=r,g.EventSource=Aa})})(typeof globalThis>"u"?typeof window<"u"?window:typeof self<"u"?self:ya:globalThis)});var Jf={};Pi(Jf,{CallAction:()=>_a,CallStatus:()=>Ca,CallType:()=>Pe,Channel:()=>Jt,ChannelState:()=>Es,ClientState:()=>Qt,EVENT_MAP:()=>Vf,ErmisAuthProvider:()=>Ta,ErmisCallNode:()=>Ra,ErmisChat:()=>Ea,ErrorFromResponse:()=>Rt,FRAME_TYPE:()=>wa,StableWSConnection:()=>Ls,TokenManager:()=>Ps,buildAttachmentPayload:()=>bi,chatCodes:()=>st,createForwardMessagePayload:()=>vl,formatMessage:()=>fl,getAttachmentCategory:()=>Hn,isHeicFile:()=>bl,isVideoFile:()=>vi,logChatPromiseExecution:()=>fi,normalizeFileName:()=>Ss,parseSignalMessage:()=>vp,parseSystemMessage:()=>xp});function ss(s,e){return function(){return s.apply(e,arguments)}}var{toString:Ip}=Object.prototype,{getPrototypeOf:Fi}=Object,{iterator:Gs,toStringTag:Oa}=Symbol,qs=(s=>e=>{let t=Ip.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),je=s=>(s=s.toLowerCase(),e=>qs(e)===s),Bs=s=>e=>typeof e===s,{isArray:Dt}=Array,is=Bs("undefined");function Dp(s){return s!==null&&!is(s)&&s.constructor!==null&&!is(s.constructor)&&ye(s.constructor.isBuffer)&&s.constructor.isBuffer(s)}var La=je("ArrayBuffer");function Up(s){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(s):e=s&&s.buffer&&La(s.buffer),e}var Op=Bs("string"),ye=Bs("function"),Pa=Bs("number"),$s=s=>s!==null&&typeof s=="object",Lp=s=>s===!0||s===!1,Ns=s=>{if(qs(s)!=="object")return!1;let e=Fi(s);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Oa in s)&&!(Gs in s)},Pp=je("Date"),Mp=je("File"),Fp=je("Blob"),jp=je("FileList"),Np=s=>$s(s)&&ye(s.pipe),Gp=s=>{let e;return s&&(typeof FormData=="function"&&s instanceof FormData||ye(s.append)&&((e=qs(s))==="formdata"||e==="object"&&ye(s.toString)&&s.toString()==="[object FormData]"))},qp=je("URLSearchParams"),[Bp,$p,zp,Wp]=["ReadableStream","Request","Response","Headers"].map(je),Vp=s=>s.trim?s.trim():s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ns(s,e,{allOwnKeys:t=!1}={}){if(s===null||typeof s>"u")return;let i,n;if(typeof s!="object"&&(s=[s]),Dt(s))for(i=0,n=s.length;i<n;i++)e.call(null,s[i],i,s);else{let a=t?Object.getOwnPropertyNames(s):Object.keys(s),r=a.length,o;for(i=0;i<r;i++)o=a[i],e.call(null,s[o],o,s)}}function Ma(s,e){e=e.toLowerCase();let t=Object.keys(s),i=t.length,n;for(;i-- >0;)if(n=t[i],e===n.toLowerCase())return n;return null}var pt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Fa=s=>!is(s)&&s!==pt;function Mi(){let{caseless:s}=Fa(this)&&this||{},e={},t=(i,n)=>{let a=s&&Ma(e,n)||n;Ns(e[a])&&Ns(i)?e[a]=Mi(e[a],i):Ns(i)?e[a]=Mi({},i):Dt(i)?e[a]=i.slice():e[a]=i};for(let i=0,n=arguments.length;i<n;i++)arguments[i]&&ns(arguments[i],t);return e}var Hp=(s,e,t,{allOwnKeys:i}={})=>(ns(e,(n,a)=>{t&&ye(n)?s[a]=ss(n,t):s[a]=n},{allOwnKeys:i}),s),Kp=s=>(s.charCodeAt(0)===65279&&(s=s.slice(1)),s),Jp=(s,e,t,i)=>{s.prototype=Object.create(e.prototype,i),s.prototype.constructor=s,Object.defineProperty(s,"super",{value:e.prototype}),t&&Object.assign(s.prototype,t)},Qp=(s,e,t,i)=>{let n,a,r,o={};if(e=e||{},s==null)return e;do{for(n=Object.getOwnPropertyNames(s),a=n.length;a-- >0;)r=n[a],(!i||i(r,s,e))&&!o[r]&&(e[r]=s[r],o[r]=!0);s=t!==!1&&Fi(s)}while(s&&(!t||t(s,e))&&s!==Object.prototype);return e},Xp=(s,e,t)=>{s=String(s),(t===void 0||t>s.length)&&(t=s.length),t-=e.length;let i=s.indexOf(e,t);return i!==-1&&i===t},Yp=s=>{if(!s)return null;if(Dt(s))return s;let e=s.length;if(!Pa(e))return null;let t=new Array(e);for(;e-- >0;)t[e]=s[e];return t},Zp=(s=>e=>s&&e instanceof s)(typeof Uint8Array<"u"&&Fi(Uint8Array)),eu=(s,e)=>{let i=(s&&s[Gs]).call(s),n;for(;(n=i.next())&&!n.done;){let a=n.value;e.call(s,a[0],a[1])}},tu=(s,e)=>{let t,i=[];for(;(t=s.exec(e))!==null;)i.push(t);return i},su=je("HTMLFormElement"),iu=s=>s.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,i,n){return i.toUpperCase()+n}),Ua=(({hasOwnProperty:s})=>(e,t)=>s.call(e,t))(Object.prototype),nu=je("RegExp"),ja=(s,e)=>{let t=Object.getOwnPropertyDescriptors(s),i={};ns(t,(n,a)=>{let r;(r=e(n,a,s))!==!1&&(i[a]=r||n)}),Object.defineProperties(s,i)},au=s=>{ja(s,(e,t)=>{if(ye(s)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;let i=s[t];if(ye(i)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},ru=(s,e)=>{let t={},i=n=>{n.forEach(a=>{t[a]=!0})};return Dt(s)?i(s):i(String(s).split(e)),t},ou=()=>{},cu=(s,e)=>s!=null&&Number.isFinite(s=+s)?s:e;function lu(s){return!!(s&&ye(s.append)&&s[Oa]==="FormData"&&s[Gs])}var pu=s=>{let e=new Array(10),t=(i,n)=>{if($s(i)){if(e.indexOf(i)>=0)return;if(!("toJSON"in i)){e[n]=i;let a=Dt(i)?[]:{};return ns(i,(r,o)=>{let l=t(r,n+1);!is(l)&&(a[o]=l)}),e[n]=void 0,a}}return i};return t(s,0)},uu=je("AsyncFunction"),du=s=>s&&($s(s)||ye(s))&&ye(s.then)&&ye(s.catch),Na=((s,e)=>s?setImmediate:e?((t,i)=>(pt.addEventListener("message",({source:n,data:a})=>{n===pt&&a===t&&i.length&&i.shift()()},!1),n=>{i.push(n),pt.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",ye(pt.postMessage)),mu=typeof queueMicrotask<"u"?queueMicrotask.bind(pt):typeof process<"u"&&process.nextTick||Na,hu=s=>s!=null&&ye(s[Gs]),m={isArray:Dt,isArrayBuffer:La,isBuffer:Dp,isFormData:Gp,isArrayBufferView:Up,isString:Op,isNumber:Pa,isBoolean:Lp,isObject:$s,isPlainObject:Ns,isReadableStream:Bp,isRequest:$p,isResponse:zp,isHeaders:Wp,isUndefined:is,isDate:Pp,isFile:Mp,isBlob:Fp,isRegExp:nu,isFunction:ye,isStream:Np,isURLSearchParams:qp,isTypedArray:Zp,isFileList:jp,forEach:ns,merge:Mi,extend:Hp,trim:Vp,stripBOM:Kp,inherits:Jp,toFlatObject:Qp,kindOf:qs,kindOfTest:je,endsWith:Xp,toArray:Yp,forEachEntry:eu,matchAll:tu,isHTMLForm:su,hasOwnProperty:Ua,hasOwnProp:Ua,reduceDescriptors:ja,freezeMethods:au,toObjectSet:ru,toCamelCase:iu,noop:ou,toFiniteNumber:cu,findKey:Ma,global:pt,isContextDefined:Fa,isSpecCompliantForm:lu,toJSONObject:pu,isAsyncFn:uu,isThenable:du,setImmediate:Na,asap:mu,isIterable:hu};function Ut(s,e,t,i,n){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=s,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),i&&(this.request=i),n&&(this.response=n,this.status=n.status?n.status:null)}m.inherits(Ut,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:m.toJSONObject(this.config),code:this.code,status:this.status}}});var Ga=Ut.prototype,qa={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(s=>{qa[s]={value:s}});Object.defineProperties(Ut,qa);Object.defineProperty(Ga,"isAxiosError",{value:!0});Ut.from=(s,e,t,i,n,a)=>{let r=Object.create(Ga);return m.toFlatObject(s,r,function(l){return l!==Error.prototype},o=>o!=="isAxiosError"),Ut.call(r,s.message,e,t,i,n),r.cause=s,r.name=s.name,a&&Object.assign(r,a),r};var _=Ut;var Wo=xe(nn(),1),ei=Wo.default;function an(s){return m.isPlainObject(s)||m.isArray(s)}function Ho(s){return m.endsWith(s,"[]")?s.slice(0,-2):s}function Vo(s,e,t){return s?s.concat(e).map(function(n,a){return n=Ho(n),!t&&a?"["+n+"]":n}).join(t?".":""):e}function Zd(s){return m.isArray(s)&&!s.some(an)}var em=m.toFlatObject(m,{},null,function(e){return/^is[A-Z]/.test(e)});function tm(s,e,t){if(!m.isObject(s))throw new TypeError("target must be an object");e=e||new(ei||FormData),t=m.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(x,v){return!m.isUndefined(v[x])});let i=t.metaTokens,n=t.visitor||p,a=t.dots,r=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&m.isSpecCompliantForm(e);if(!m.isFunction(n))throw new TypeError("visitor must be a function");function c(h){if(h===null)return"";if(m.isDate(h))return h.toISOString();if(m.isBoolean(h))return h.toString();if(!l&&m.isBlob(h))throw new _("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(h)||m.isTypedArray(h)?l&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function p(h,x,v){let b=h;if(h&&!v&&typeof h=="object"){if(m.endsWith(x,"{}"))x=i?x:x.slice(0,-2),h=JSON.stringify(h);else if(m.isArray(h)&&Zd(h)||(m.isFileList(h)||m.endsWith(x,"[]"))&&(b=m.toArray(h)))return x=Ho(x),b.forEach(function(I,M){!(m.isUndefined(I)||I===null)&&e.append(r===!0?Vo([x],M,a):r===null?x:x+"[]",c(I))}),!1}return an(h)?!0:(e.append(Vo(v,x,a),c(h)),!1)}let d=[],u=Object.assign(em,{defaultVisitor:p,convertValue:c,isVisitable:an});function f(h,x){if(!m.isUndefined(h)){if(d.indexOf(h)!==-1)throw Error("Circular reference detected in "+x.join("."));d.push(h),m.forEach(h,function(b,T){(!(m.isUndefined(b)||b===null)&&n.call(e,b,m.isString(T)?T.trim():T,x,u))===!0&&f(b,x?x.concat(T):[T])}),d.pop()}}if(!m.isObject(s))throw new TypeError("data must be an object");return f(s),e}var tt=tm;function Ko(s){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(s).replace(/[!'()~]|%20|%00/g,function(i){return e[i]})}function Jo(s,e){this._pairs=[],s&&tt(s,this,e)}var Qo=Jo.prototype;Qo.append=function(e,t){this._pairs.push([e,t])};Qo.toString=function(e){let t=e?function(i){return e.call(this,i,Ko)}:Ko;return this._pairs.map(function(n){return t(n[0])+"="+t(n[1])},"").join("&")};var Xo=Jo;function sm(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function mt(s,e,t){if(!e)return s;let i=t&&t.encode||sm;m.isFunction(t)&&(t={serialize:t});let n=t&&t.serialize,a;if(n?a=n(e,t):a=m.isURLSearchParams(e)?e.toString():new Xo(e,t).toString(i),a){let r=s.indexOf("#");r!==-1&&(s=s.slice(0,r)),s+=(s.indexOf("?")===-1?"?":"&")+a}return s}var rn=class{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){m.forEach(this.handlers,function(i){i!==null&&e(i)})}},on=rn;var Ft={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var tc=xe(k("crypto"),1);var Yo=xe(k("url"),1),Zo=Yo.default.URLSearchParams;var cn="abcdefghijklmnopqrstuvwxyz",ec="0123456789",sc={DIGIT:ec,ALPHA:cn,ALPHA_DIGIT:cn+cn.toUpperCase()+ec},im=(s=16,e=sc.ALPHA_DIGIT)=>{let t="",{length:i}=e,n=new Uint32Array(s);tc.default.randomFillSync(n);for(let a=0;a<s;a++)t+=e[n[a]%i];return t},ic={isNode:!0,classes:{URLSearchParams:Zo,FormData:ei,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:sc,generateString:im,protocols:["http","https","file","data"]};var un={};Pi(un,{hasBrowserEnv:()=>pn,hasStandardBrowserEnv:()=>nm,hasStandardBrowserWebWorkerEnv:()=>am,navigator:()=>ln,origin:()=>rm});var pn=typeof window<"u"&&typeof document<"u",ln=typeof navigator=="object"&&navigator||void 0,nm=pn&&(!ln||["ReactNative","NativeScript","NS"].indexOf(ln.product)<0),am=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",rm=pn&&window.location.href||"http://localhost";var N={...un,...ic};function dn(s,e){return tt(s,new N.classes.URLSearchParams,Object.assign({visitor:function(t,i,n,a){return N.isNode&&m.isBuffer(t)?(this.append(i,t.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)}},e))}function om(s){return m.matchAll(/\w+|\[(\w*)]/g,s).map(e=>e[0]==="[]"?"":e[1]||e[0])}function cm(s){let e={},t=Object.keys(s),i,n=t.length,a;for(i=0;i<n;i++)a=t[i],e[a]=s[a];return e}function lm(s){function e(t,i,n,a){let r=t[a++];if(r==="__proto__")return!0;let o=Number.isFinite(+r),l=a>=t.length;return r=!r&&m.isArray(n)?n.length:r,l?(m.hasOwnProp(n,r)?n[r]=[n[r],i]:n[r]=i,!o):((!n[r]||!m.isObject(n[r]))&&(n[r]=[]),e(t,i,n[r],a)&&m.isArray(n[r])&&(n[r]=cm(n[r])),!o)}if(m.isFormData(s)&&m.isFunction(s.entries)){let t={};return m.forEachEntry(s,(i,n)=>{e(om(i),n,t,0)}),t}return null}var ti=lm;function pm(s,e,t){if(m.isString(s))try{return(e||JSON.parse)(s),m.trim(s)}catch(i){if(i.name!=="SyntaxError")throw i}return(t||JSON.stringify)(s)}var mn={transitional:Ft,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){let i=t.getContentType()||"",n=i.indexOf("application/json")>-1,a=m.isObject(e);if(a&&m.isHTMLForm(e)&&(e=new FormData(e)),m.isFormData(e))return n?JSON.stringify(ti(e)):e;if(m.isArrayBuffer(e)||m.isBuffer(e)||m.isStream(e)||m.isFile(e)||m.isBlob(e)||m.isReadableStream(e))return e;if(m.isArrayBufferView(e))return e.buffer;if(m.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(i.indexOf("application/x-www-form-urlencoded")>-1)return dn(e,this.formSerializer).toString();if((o=m.isFileList(e))||i.indexOf("multipart/form-data")>-1){let l=this.env&&this.env.FormData;return tt(o?{"files[]":e}:e,l&&new l,this.formSerializer)}}return a||n?(t.setContentType("application/json",!1),pm(e)):e}],transformResponse:[function(e){let t=this.transitional||mn.transitional,i=t&&t.forcedJSONParsing,n=this.responseType==="json";if(m.isResponse(e)||m.isReadableStream(e))return e;if(e&&m.isString(e)&&(i&&!this.responseType||n)){let r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(o){if(r)throw o.name==="SyntaxError"?_.from(o,_.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:N.classes.FormData,Blob:N.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};m.forEach(["delete","get","head","post","put","patch"],s=>{mn.headers[s]={}});var jt=mn;var um=m.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),nc=s=>{let e={},t,i,n;return s&&s.split(`
15
- `).forEach(function(r){n=r.indexOf(":"),t=r.substring(0,n).trim().toLowerCase(),i=r.substring(n+1).trim(),!(!t||e[t]&&um[t])&&(t==="set-cookie"?e[t]?e[t].push(i):e[t]=[i]:e[t]=e[t]?e[t]+", "+i:i)}),e};var ac=Symbol("internals");function ps(s){return s&&String(s).trim().toLowerCase()}function si(s){return s===!1||s==null?s:m.isArray(s)?s.map(si):String(s)}function dm(s){let e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,i;for(;i=t.exec(s);)e[i[1]]=i[2];return e}var mm=s=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(s.trim());function hn(s,e,t,i,n){if(m.isFunction(i))return i.call(this,e,t);if(n&&(e=t),!!m.isString(e)){if(m.isString(i))return e.indexOf(i)!==-1;if(m.isRegExp(i))return i.test(e)}}function hm(s){return s.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,i)=>t.toUpperCase()+i)}function fm(s,e){let t=m.toCamelCase(" "+e);["get","set","has"].forEach(i=>{Object.defineProperty(s,i+t,{value:function(n,a,r){return this[i].call(this,e,n,a,r)},configurable:!0})})}var Nt=class{constructor(e){e&&this.set(e)}set(e,t,i){let n=this;function a(o,l,c){let p=ps(l);if(!p)throw new Error("header name must be a non-empty string");let d=m.findKey(n,p);(!d||n[d]===void 0||c===!0||c===void 0&&n[d]!==!1)&&(n[d||l]=si(o))}let r=(o,l)=>m.forEach(o,(c,p)=>a(c,p,l));if(m.isPlainObject(e)||e instanceof this.constructor)r(e,t);else if(m.isString(e)&&(e=e.trim())&&!mm(e))r(nc(e),t);else if(m.isObject(e)&&m.isIterable(e)){let o={},l,c;for(let p of e){if(!m.isArray(p))throw TypeError("Object iterator must return a key-value pair");o[c=p[0]]=(l=o[c])?m.isArray(l)?[...l,p[1]]:[l,p[1]]:p[1]}r(o,t)}else e!=null&&a(t,e,i);return this}get(e,t){if(e=ps(e),e){let i=m.findKey(this,e);if(i){let n=this[i];if(!t)return n;if(t===!0)return dm(n);if(m.isFunction(t))return t.call(this,n,i);if(m.isRegExp(t))return t.exec(n);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ps(e),e){let i=m.findKey(this,e);return!!(i&&this[i]!==void 0&&(!t||hn(this,this[i],i,t)))}return!1}delete(e,t){let i=this,n=!1;function a(r){if(r=ps(r),r){let o=m.findKey(i,r);o&&(!t||hn(i,i[o],o,t))&&(delete i[o],n=!0)}}return m.isArray(e)?e.forEach(a):a(e),n}clear(e){let t=Object.keys(this),i=t.length,n=!1;for(;i--;){let a=t[i];(!e||hn(this,this[a],a,e,!0))&&(delete this[a],n=!0)}return n}normalize(e){let t=this,i={};return m.forEach(this,(n,a)=>{let r=m.findKey(i,a);if(r){t[r]=si(n),delete t[a];return}let o=e?hm(a):String(a).trim();o!==a&&delete t[a],t[o]=si(n),i[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return m.forEach(this,(i,n)=>{i!=null&&i!==!1&&(t[n]=e&&m.isArray(i)?i.join(", "):i)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
16
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let i=new this(e);return t.forEach(n=>i.set(n)),i}static accessor(e){let i=(this[ac]=this[ac]={accessors:{}}).accessors,n=this.prototype;function a(r){let o=ps(r);i[o]||(fm(n,r),i[o]=!0)}return m.isArray(e)?e.forEach(a):a(e),this}};Nt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);m.reduceDescriptors(Nt.prototype,({value:s},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(i){this[t]=i}}});m.freezeMethods(Nt);var X=Nt;function us(s,e){let t=this||jt,i=e||t,n=X.from(i.headers),a=i.data;return m.forEach(s,function(o){a=o.call(t,a,n.normalize(),e?e.status:void 0)}),n.normalize(),a}function ds(s){return!!(s&&s.__CANCEL__)}function rc(s,e,t){_.call(this,s??"canceled",_.ERR_CANCELED,e,t),this.name="CanceledError"}m.inherits(rc,_,{__CANCEL__:!0});var Ae=rc;function qe(s,e,t){let i=t.config.validateStatus;!t.status||!i||i(t.status)?s(t):e(new _("Request failed with status code "+t.status,[_.ERR_BAD_REQUEST,_.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function fn(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function gn(s,e){return e?s.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):s}function ht(s,e,t){let i=!fn(e);return s&&(i||t==!1)?gn(s,e):e}var $c=xe(cc(),1),zc=xe(k("http"),1);Ze();var Wc=xe(k("util"),1),Vc=xe(Tc(),1),Je=xe(k("zlib"),1);var vt="1.10.0";function xs(s){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return e&&e[1]||""}var sh=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function Un(s,e,t){let i=t&&t.Blob||N.classes.Blob,n=xs(s);if(e===void 0&&i&&(e=!0),n==="data"){s=n.length?s.slice(n.length+1):s;let a=sh.exec(s);if(!a)throw new _("Invalid URL",_.ERR_INVALID_URL);let r=a[1],o=a[2],l=a[3],c=Buffer.from(decodeURIComponent(l),o?"base64":"utf8");if(e){if(!i)throw new _("Blob is not supported",_.ERR_NOT_SUPPORT);return new i([c],{type:r})}return c}throw new _("Unsupported protocol "+n,_.ERR_NOT_SUPPORT)}var yt=xe(k("stream"),1);var kc=xe(k("stream"),1);var On=Symbol("internals"),Ln=class extends kc.default.Transform{constructor(e){e=m.toFlatObject(e,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(i,n)=>!m.isUndefined(n[i])),super({readableHighWaterMark:e.chunkSize});let t=this[On]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",i=>{i==="progress"&&(t.isCaptured||(t.isCaptured=!0))})}_read(e){let t=this[On];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,i){let n=this[On],a=n.maxRate,r=this.readableHighWaterMark,o=n.timeWindow,l=1e3/o,c=a/l,p=n.minChunkSize!==!1?Math.max(n.minChunkSize,c*.01):0,d=(f,h)=>{let x=Buffer.byteLength(f);n.bytesSeen+=x,n.bytes+=x,n.isCaptured&&this.emit("progress",n.bytesSeen),this.push(f)?process.nextTick(h):n.onReadCallback=()=>{n.onReadCallback=null,process.nextTick(h)}},u=(f,h)=>{let x=Buffer.byteLength(f),v=null,b=r,T,I=0;if(a){let M=Date.now();(!n.ts||(I=M-n.ts)>=o)&&(n.ts=M,T=c-n.bytes,n.bytes=T<0?-T:0,I=0),T=c-n.bytes}if(a){if(T<=0)return setTimeout(()=>{h(null,f)},o-I);T<b&&(b=T)}b&&x>b&&x-b>p&&(v=f.subarray(b),f=f.subarray(0,b)),d(f,v?()=>{process.nextTick(h,null,v)}:h)};u(e,function f(h,x){if(h)return i(h);x?u(x,f):i(null)})}},Pn=Ln;var Hc=k("events");var Ic=xe(k("util"),1),Dc=k("stream");var{asyncIterator:Ac}=Symbol,ih=async function*(s){s.stream?yield*s.stream():s.arrayBuffer?yield await s.arrayBuffer():s[Ac]?yield*s[Ac]():yield s},ci=ih;var nh=N.ALPHABET.ALPHA_DIGIT+"-_",vs=typeof TextEncoder=="function"?new TextEncoder:new Ic.default.TextEncoder,bt=`\r
17
- `,ah=vs.encode(bt),rh=2,Mn=class{constructor(e,t){let{escapeName:i}=this.constructor,n=m.isString(t),a=`Content-Disposition: form-data; name="${i(e)}"${!n&&t.name?`; filename="${i(t.name)}"`:""}${bt}`;n?t=vs.encode(String(t).replace(/\r?\n|\r\n?/g,bt)):a+=`Content-Type: ${t.type||"application/octet-stream"}${bt}`,this.headers=vs.encode(a+bt),this.contentLength=n?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+rh,this.name=e,this.value=t}async*encode(){yield this.headers;let{value:e}=this;m.isTypedArray(e)?yield e:yield*ci(e),yield ah}static escapeName(e){return String(e).replace(/[\r\n"]/g,t=>({"\r":"%0D","\n":"%0A",'"':"%22"})[t])}},oh=(s,e,t)=>{let{tag:i="form-data-boundary",size:n=25,boundary:a=i+"-"+N.generateString(n,nh)}=t||{};if(!m.isFormData(s))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let r=vs.encode("--"+a+bt),o=vs.encode("--"+a+"--"+bt),l=o.byteLength,c=Array.from(s.entries()).map(([d,u])=>{let f=new Mn(d,u);return l+=f.size,f});l+=r.byteLength*c.length,l=m.toFiniteNumber(l);let p={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(l)&&(p["Content-Length"]=l),e&&e(p),Dc.Readable.from((async function*(){for(let d of c)yield r,yield*d.encode();yield o})())},Uc=oh;var Oc=xe(k("stream"),1),Fn=class extends Oc.default.Transform{__transform(e,t,i){this.push(e),i()}_transform(e,t,i){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let n=Buffer.alloc(2);n[0]=120,n[1]=156,this.push(n,t)}this.__transform(e,t,i)}},Lc=Fn;var ch=(s,e)=>m.isAsyncFn(s)?function(...t){let i=t.pop();s.apply(this,t).then(n=>{try{e?i(null,...e(n)):i(null,n)}catch(a){i(a)}},i)}:s,Pc=ch;function lh(s,e){s=s||10;let t=new Array(s),i=new Array(s),n=0,a=0,r;return e=e!==void 0?e:1e3,function(l){let c=Date.now(),p=i[a];r||(r=c),t[n]=l,i[n]=c;let d=a,u=0;for(;d!==n;)u+=t[d++],d=d%s;if(n=(n+1)%s,n===a&&(a=(a+1)%s),c-r<e)return;let f=p&&c-p;return f?Math.round(u*1e3/f):void 0}}var Mc=lh;function ph(s,e){let t=0,i=1e3/e,n,a,r=(c,p=Date.now())=>{t=p,n=null,a&&(clearTimeout(a),a=null),s.apply(null,c)};return[(...c)=>{let p=Date.now(),d=p-t;d>=i?r(c,p):(n=c,a||(a=setTimeout(()=>{a=null,r(n)},i-d)))},()=>n&&r(n)]}var Fc=ph;var Ke=(s,e,t=3)=>{let i=0,n=Mc(50,250);return Fc(a=>{let r=a.loaded,o=a.lengthComputable?a.total:void 0,l=r-i,c=n(l),p=r<=o;i=r;let d={loaded:r,total:o,progress:o?r/o:void 0,bytes:l,rate:c||void 0,estimated:c&&o&&p?(o-r)/c:void 0,event:a,lengthComputable:o!=null,[e?"download":"upload"]:!0};s(d)},t)},zt=(s,e)=>{let t=s!=null;return[i=>e[0]({lengthComputable:t,total:s,loaded:i}),e[1]]},Wt=s=>(...e)=>m.asap(()=>s(...e));var jc={flush:Je.default.constants.Z_SYNC_FLUSH,finishFlush:Je.default.constants.Z_SYNC_FLUSH},uh={flush:Je.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Je.default.constants.BROTLI_OPERATION_FLUSH},Nc=m.isFunction(Je.default.createBrotliDecompress),{http:dh,https:mh}=Vc.default,hh=/https:?/,Gc=N.protocols.map(s=>s+":"),qc=(s,[e,t])=>(s.on("end",t).on("error",t),e);function fh(s,e){s.beforeRedirects.proxy&&s.beforeRedirects.proxy(s),s.beforeRedirects.config&&s.beforeRedirects.config(s,e)}function Kc(s,e,t){let i=e;if(!i&&i!==!1){let n=$c.default.getProxyForUrl(t);n&&(i=new URL(n))}if(i){if(i.username&&(i.auth=(i.username||"")+":"+(i.password||"")),i.auth){(i.auth.username||i.auth.password)&&(i.auth=(i.auth.username||"")+":"+(i.auth.password||""));let a=Buffer.from(i.auth,"utf8").toString("base64");s.headers["Proxy-Authorization"]="Basic "+a}s.headers.host=s.hostname+(s.port?":"+s.port:"");let n=i.hostname||i.host;s.hostname=n,s.host=n,s.port=i.port,s.path=t,i.protocol&&(s.protocol=i.protocol.includes(":")?i.protocol:`${i.protocol}:`)}s.beforeRedirects.proxy=function(a){Kc(a,e,a.href)}}var gh=typeof process<"u"&&m.kindOf(process)==="process",xh=s=>new Promise((e,t)=>{let i,n,a=(l,c)=>{n||(n=!0,i&&i(l,c))},r=l=>{a(l),e(l)},o=l=>{a(l,!0),t(l)};s(r,o,l=>i=l).catch(o)}),vh=({address:s,family:e})=>{if(!m.isString(s))throw TypeError("address must be a string");return{address:s,family:e||(s.indexOf(".")<0?6:4)}},Bc=(s,e)=>vh(m.isObject(s)?s:{address:s,family:e}),Jc=gh&&function(e){return xh(async function(i,n,a){let{data:r,lookup:o,family:l}=e,{responseType:c,responseEncoding:p}=e,d=e.method.toUpperCase(),u,f=!1,h;if(o){let E=Pc(o,R=>m.isArray(R)?R:[R]);o=(R,z,ve)=>{E(R,z,(K,Ue,ot)=>{if(K)return ve(K);let Oe=m.isArray(Ue)?Ue.map(be=>Bc(be)):[Bc(Ue,ot)];z.all?ve(K,Oe):ve(K,Oe[0].address,Oe[0].family)})}}let x=new Hc.EventEmitter,v=()=>{e.cancelToken&&e.cancelToken.unsubscribe(b),e.signal&&e.signal.removeEventListener("abort",b),x.removeAllListeners()};a((E,R)=>{u=!0,R&&(f=!0,v())});function b(E){x.emit("abort",!E||E.type?new Ae(null,e,h):E)}x.once("abort",n),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(b),e.signal&&(e.signal.aborted?b():e.signal.addEventListener("abort",b)));let T=ht(e.baseURL,e.url,e.allowAbsoluteUrls),I=new URL(T,N.hasBrowserEnv?N.origin:void 0),M=I.protocol||Gc[0];if(M==="data:"){let E;if(d!=="GET")return qe(i,n,{status:405,statusText:"method not allowed",headers:{},config:e});try{E=Un(e.url,c==="blob",{Blob:e.env&&e.env.Blob})}catch(R){throw _.from(R,_.ERR_BAD_REQUEST,e)}return c==="text"?(E=E.toString(p),(!p||p==="utf8")&&(E=m.stripBOM(E))):c==="stream"&&(E=yt.default.Readable.from(E)),qe(i,n,{data:E,status:200,statusText:"OK",headers:new X,config:e})}if(Gc.indexOf(M)===-1)return n(new _("Unsupported protocol "+M,_.ERR_BAD_REQUEST,e));let O=X.from(e.headers).normalize();O.set("User-Agent","axios/"+vt,!1);let{onUploadProgress:V,onDownloadProgress:Y}=e,H=e.maxRate,de,Se;if(m.isSpecCompliantForm(r)){let E=O.getContentType(/boundary=([-_\w\d]{10,70})/i);r=Uc(r,R=>{O.set(R)},{tag:`axios-${vt}-boundary`,boundary:E&&E[1]||void 0})}else if(m.isFormData(r)&&m.isFunction(r.getHeaders)){if(O.set(r.getHeaders()),!O.hasContentLength())try{let E=await Wc.default.promisify(r.getLength).call(r);Number.isFinite(E)&&E>=0&&O.setContentLength(E)}catch{}}else if(m.isBlob(r)||m.isFile(r))r.size&&O.setContentType(r.type||"application/octet-stream"),O.setContentLength(r.size||0),r=yt.default.Readable.from(ci(r));else if(r&&!m.isStream(r)){if(!Buffer.isBuffer(r))if(m.isArrayBuffer(r))r=Buffer.from(new Uint8Array(r));else if(m.isString(r))r=Buffer.from(r,"utf-8");else return n(new _("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",_.ERR_BAD_REQUEST,e));if(O.setContentLength(r.length,!1),e.maxBodyLength>-1&&r.length>e.maxBodyLength)return n(new _("Request body larger than maxBodyLength limit",_.ERR_BAD_REQUEST,e))}let Tt=m.toFiniteNumber(O.getContentLength());m.isArray(H)?(de=H[0],Se=H[1]):de=Se=H,r&&(V||de)&&(m.isStream(r)||(r=yt.default.Readable.from(r,{objectMode:!1})),r=yt.default.pipeline([r,new Pn({maxRate:m.toFiniteNumber(de)})],m.noop),V&&r.on("progress",qc(r,zt(Tt,Ke(Wt(V),!1,3)))));let De;if(e.auth){let E=e.auth.username||"",R=e.auth.password||"";De=E+":"+R}if(!De&&I.username){let E=I.username,R=I.password;De=E+":"+R}De&&O.delete("authorization");let rt;try{rt=mt(I.pathname+I.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(E){let R=new Error(E.message);return R.config=e,R.url=e.url,R.exists=!0,n(R)}O.set("Accept-Encoding","gzip, compress, deflate"+(Nc?", br":""),!1);let te={path:rt,method:d,headers:O.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:De,protocol:M,family:l,beforeRedirect:fh,beforeRedirects:{}};!m.isUndefined(o)&&(te.lookup=o),e.socketPath?te.socketPath=e.socketPath:(te.hostname=I.hostname.startsWith("[")?I.hostname.slice(1,-1):I.hostname,te.port=I.port,Kc(te,e.proxy,M+"//"+I.hostname+(I.port?":"+I.port:"")+te.path));let G,ie=hh.test(te.protocol);if(te.agent=ie?e.httpsAgent:e.httpAgent,e.transport?G=e.transport:e.maxRedirects===0?G=ie?ut:zc.default:(e.maxRedirects&&(te.maxRedirects=e.maxRedirects),e.beforeRedirect&&(te.beforeRedirects.config=e.beforeRedirect),G=ie?mh:dh),e.maxBodyLength>-1?te.maxBodyLength=e.maxBodyLength:te.maxBodyLength=1/0,e.insecureHTTPParser&&(te.insecureHTTPParser=e.insecureHTTPParser),h=G.request(te,function(R){if(h.destroyed)return;let z=[R],ve=+R.headers["content-length"];if(Y||Se){let be=new Pn({maxRate:m.toFiniteNumber(Se)});Y&&be.on("progress",qc(be,zt(ve,Ke(Wt(Y),!0,3)))),z.push(be)}let K=R,Ue=R.req||h;if(e.decompress!==!1&&R.headers["content-encoding"])switch((d==="HEAD"||R.statusCode===204)&&delete R.headers["content-encoding"],(R.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":z.push(Je.default.createUnzip(jc)),delete R.headers["content-encoding"];break;case"deflate":z.push(new Lc),z.push(Je.default.createUnzip(jc)),delete R.headers["content-encoding"];break;case"br":Nc&&(z.push(Je.default.createBrotliDecompress(uh)),delete R.headers["content-encoding"])}K=z.length>1?yt.default.pipeline(z,m.noop):z[0];let ot=yt.default.finished(K,()=>{ot(),v()}),Oe={status:R.statusCode,statusText:R.statusMessage,headers:new X(R.headers),config:e,request:Ue};if(c==="stream")Oe.data=K,qe(i,n,Oe);else{let be=[],kt=0;K.on("data",function(Z){be.push(Z),kt+=Z.length,e.maxContentLength>-1&&kt>e.maxContentLength&&(f=!0,K.destroy(),n(new _("maxContentLength size of "+e.maxContentLength+" exceeded",_.ERR_BAD_RESPONSE,e,Ue)))}),K.on("aborted",function(){if(f)return;let Z=new _("stream has been aborted",_.ERR_BAD_RESPONSE,e,Ue);K.destroy(Z),n(Z)}),K.on("error",function(Z){h.destroyed||n(_.from(Z,null,e,Ue))}),K.on("end",function(){try{let Z=be.length===1?be[0]:Buffer.concat(be);c!=="arraybuffer"&&(Z=Z.toString(p),(!p||p==="utf8")&&(Z=m.stripBOM(Z))),Oe.data=Z}catch(Z){return n(_.from(Z,null,e,Oe.request,Oe))}qe(i,n,Oe)})}x.once("abort",be=>{K.destroyed||(K.emit("error",be),K.destroy())})}),x.once("abort",E=>{n(E),h.destroy(E)}),h.on("error",function(R){n(_.from(R,null,e,h))}),h.on("socket",function(R){R.setKeepAlive(!0,1e3*60)}),e.timeout){let E=parseInt(e.timeout,10);if(Number.isNaN(E)){n(new _("error trying to parse `config.timeout` to int",_.ERR_BAD_OPTION_VALUE,e,h));return}h.setTimeout(E,function(){if(u)return;let z=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",ve=e.transitional||Ft;e.timeoutErrorMessage&&(z=e.timeoutErrorMessage),n(new _(z,ve.clarifyTimeoutError?_.ETIMEDOUT:_.ECONNABORTED,e,h)),b()})}if(m.isStream(r)){let E=!1,R=!1;r.on("end",()=>{E=!0}),r.once("error",z=>{R=!0,h.destroy(z)}),r.on("close",()=>{!E&&!R&&b(new Ae("Request stream has been aborted",e,h))}),r.pipe(h)}else h.end(r)})};var Qc=N.hasStandardBrowserEnv?((s,e)=>t=>(t=new URL(t,N.origin),s.protocol===t.protocol&&s.host===t.host&&(e||s.port===t.port)))(new URL(N.origin),N.navigator&&/(msie|trident)/i.test(N.navigator.userAgent)):()=>!0;var Xc=N.hasStandardBrowserEnv?{write(s,e,t,i,n,a){let r=[s+"="+encodeURIComponent(e)];m.isNumber(t)&&r.push("expires="+new Date(t).toGMTString()),m.isString(i)&&r.push("path="+i),m.isString(n)&&r.push("domain="+n),a===!0&&r.push("secure"),document.cookie=r.join("; ")},read(s){let e=document.cookie.match(new RegExp("(^|;\\s*)("+s+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(s){this.write(s,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var Yc=s=>s instanceof X?{...s}:s;function Ge(s,e){e=e||{};let t={};function i(c,p,d,u){return m.isPlainObject(c)&&m.isPlainObject(p)?m.merge.call({caseless:u},c,p):m.isPlainObject(p)?m.merge({},p):m.isArray(p)?p.slice():p}function n(c,p,d,u){if(m.isUndefined(p)){if(!m.isUndefined(c))return i(void 0,c,d,u)}else return i(c,p,d,u)}function a(c,p){if(!m.isUndefined(p))return i(void 0,p)}function r(c,p){if(m.isUndefined(p)){if(!m.isUndefined(c))return i(void 0,c)}else return i(void 0,p)}function o(c,p,d){if(d in e)return i(c,p);if(d in s)return i(void 0,c)}let l={url:a,method:a,data:a,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,responseEncoding:r,validateStatus:o,headers:(c,p,d)=>n(Yc(c),Yc(p),d,!0)};return m.forEach(Object.keys(Object.assign({},s,e)),function(p){let d=l[p]||n,u=d(s[p],e[p],p);m.isUndefined(u)&&d!==o||(t[p]=u)}),t}var li=s=>{let e=Ge({},s),{data:t,withXSRFToken:i,xsrfHeaderName:n,xsrfCookieName:a,headers:r,auth:o}=e;e.headers=r=X.from(r),e.url=mt(ht(e.baseURL,e.url,e.allowAbsoluteUrls),s.params,s.paramsSerializer),o&&r.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let l;if(m.isFormData(t)){if(N.hasStandardBrowserEnv||N.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if((l=r.getContentType())!==!1){let[c,...p]=l?l.split(";").map(d=>d.trim()).filter(Boolean):[];r.setContentType([c||"multipart/form-data",...p].join("; "))}}if(N.hasStandardBrowserEnv&&(i&&m.isFunction(i)&&(i=i(e)),i||i!==!1&&Qc(e.url))){let c=n&&a&&Xc.read(a);c&&r.set(n,c)}return e};var bh=typeof XMLHttpRequest<"u",Zc=bh&&function(s){return new Promise(function(t,i){let n=li(s),a=n.data,r=X.from(n.headers).normalize(),{responseType:o,onUploadProgress:l,onDownloadProgress:c}=n,p,d,u,f,h;function x(){f&&f(),h&&h(),n.cancelToken&&n.cancelToken.unsubscribe(p),n.signal&&n.signal.removeEventListener("abort",p)}let v=new XMLHttpRequest;v.open(n.method.toUpperCase(),n.url,!0),v.timeout=n.timeout;function b(){if(!v)return;let I=X.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),O={data:!o||o==="text"||o==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:I,config:s,request:v};qe(function(Y){t(Y),x()},function(Y){i(Y),x()},O),v=null}"onloadend"in v?v.onloadend=b:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(b)},v.onabort=function(){v&&(i(new _("Request aborted",_.ECONNABORTED,s,v)),v=null)},v.onerror=function(){i(new _("Network Error",_.ERR_NETWORK,s,v)),v=null},v.ontimeout=function(){let M=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded",O=n.transitional||Ft;n.timeoutErrorMessage&&(M=n.timeoutErrorMessage),i(new _(M,O.clarifyTimeoutError?_.ETIMEDOUT:_.ECONNABORTED,s,v)),v=null},a===void 0&&r.setContentType(null),"setRequestHeader"in v&&m.forEach(r.toJSON(),function(M,O){v.setRequestHeader(O,M)}),m.isUndefined(n.withCredentials)||(v.withCredentials=!!n.withCredentials),o&&o!=="json"&&(v.responseType=n.responseType),c&&([u,h]=Ke(c,!0),v.addEventListener("progress",u)),l&&v.upload&&([d,f]=Ke(l),v.upload.addEventListener("progress",d),v.upload.addEventListener("loadend",f)),(n.cancelToken||n.signal)&&(p=I=>{v&&(i(!I||I.type?new Ae(null,s,v):I),v.abort(),v=null)},n.cancelToken&&n.cancelToken.subscribe(p),n.signal&&(n.signal.aborted?p():n.signal.addEventListener("abort",p)));let T=xs(n.url);if(T&&N.protocols.indexOf(T)===-1){i(new _("Unsupported protocol "+T+":",_.ERR_BAD_REQUEST,s));return}v.send(a||null)})};var yh=(s,e)=>{let{length:t}=s=s?s.filter(Boolean):[];if(e||t){let i=new AbortController,n,a=function(c){if(!n){n=!0,o();let p=c instanceof Error?c:this.reason;i.abort(p instanceof _?p:new Ae(p instanceof Error?p.message:p))}},r=e&&setTimeout(()=>{r=null,a(new _(`timeout ${e} of ms exceeded`,_.ETIMEDOUT))},e),o=()=>{s&&(r&&clearTimeout(r),r=null,s.forEach(c=>{c.unsubscribe?c.unsubscribe(a):c.removeEventListener("abort",a)}),s=null)};s.forEach(c=>c.addEventListener("abort",a));let{signal:l}=i;return l.unsubscribe=()=>m.asap(o),l}},el=yh;var _h=function*(s,e){let t=s.byteLength;if(!e||t<e){yield s;return}let i=0,n;for(;i<t;)n=i+e,yield s.slice(i,n),i=n},Ch=async function*(s,e){for await(let t of wh(s))yield*_h(t,e)},wh=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}let e=s.getReader();try{for(;;){let{done:t,value:i}=await e.read();if(t)break;yield i}}finally{await e.cancel()}},jn=(s,e,t,i)=>{let n=Ch(s,e),a=0,r,o=l=>{r||(r=!0,i&&i(l))};return new ReadableStream({async pull(l){try{let{done:c,value:p}=await n.next();if(c){o(),l.close();return}let d=p.byteLength;if(t){let u=a+=d;t(u)}l.enqueue(new Uint8Array(p))}catch(c){throw o(c),c}},cancel(l){return o(l),n.return()}},{highWaterMark:2})};var ui=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",sl=ui&&typeof ReadableStream=="function",Eh=ui&&(typeof TextEncoder=="function"?(s=>e=>s.encode(e))(new TextEncoder):async s=>new Uint8Array(await new Response(s).arrayBuffer())),il=(s,...e)=>{try{return!!s(...e)}catch{return!1}},Sh=sl&&il(()=>{let s=!1,e=new Request(N.origin,{body:new ReadableStream,method:"POST",get duplex(){return s=!0,"half"}}).headers.has("Content-Type");return s&&!e}),tl=64*1024,Nn=sl&&il(()=>m.isReadableStream(new Response("").body)),pi={stream:Nn&&(s=>s.body)};ui&&(s=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!pi[e]&&(pi[e]=m.isFunction(s[e])?t=>t[e]():(t,i)=>{throw new _(`Response type '${e}' is not supported`,_.ERR_NOT_SUPPORT,i)})})})(new Response);var Rh=async s=>{if(s==null)return 0;if(m.isBlob(s))return s.size;if(m.isSpecCompliantForm(s))return(await new Request(N.origin,{method:"POST",body:s}).arrayBuffer()).byteLength;if(m.isArrayBufferView(s)||m.isArrayBuffer(s))return s.byteLength;if(m.isURLSearchParams(s)&&(s=s+""),m.isString(s))return(await Eh(s)).byteLength},Th=async(s,e)=>{let t=m.toFiniteNumber(s.getContentLength());return t??Rh(e)},nl=ui&&(async s=>{let{url:e,method:t,data:i,signal:n,cancelToken:a,timeout:r,onDownloadProgress:o,onUploadProgress:l,responseType:c,headers:p,withCredentials:d="same-origin",fetchOptions:u}=li(s);c=c?(c+"").toLowerCase():"text";let f=el([n,a&&a.toAbortSignal()],r),h,x=f&&f.unsubscribe&&(()=>{f.unsubscribe()}),v;try{if(l&&Sh&&t!=="get"&&t!=="head"&&(v=await Th(p,i))!==0){let O=new Request(e,{method:"POST",body:i,duplex:"half"}),V;if(m.isFormData(i)&&(V=O.headers.get("content-type"))&&p.setContentType(V),O.body){let[Y,H]=zt(v,Ke(Wt(l)));i=jn(O.body,tl,Y,H)}}m.isString(d)||(d=d?"include":"omit");let b="credentials"in Request.prototype;h=new Request(e,{...u,signal:f,method:t.toUpperCase(),headers:p.normalize().toJSON(),body:i,duplex:"half",credentials:b?d:void 0});let T=await fetch(h,u),I=Nn&&(c==="stream"||c==="response");if(Nn&&(o||I&&x)){let O={};["status","statusText","headers"].forEach(de=>{O[de]=T[de]});let V=m.toFiniteNumber(T.headers.get("content-length")),[Y,H]=o&&zt(V,Ke(Wt(o),!0))||[];T=new Response(jn(T.body,tl,Y,()=>{H&&H(),x&&x()}),O)}c=c||"text";let M=await pi[m.findKey(pi,c)||"text"](T,s);return!I&&x&&x(),await new Promise((O,V)=>{qe(O,V,{data:M,headers:X.from(T.headers),status:T.status,statusText:T.statusText,config:s,request:h})})}catch(b){throw x&&x(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new _("Network Error",_.ERR_NETWORK,s,h),{cause:b.cause||b}):_.from(b,b&&b.code,s,h)}});var Gn={http:Jc,xhr:Zc,fetch:nl};m.forEach(Gn,(s,e)=>{if(s){try{Object.defineProperty(s,"name",{value:e})}catch{}Object.defineProperty(s,"adapterName",{value:e})}});var al=s=>`- ${s}`,kh=s=>m.isFunction(s)||s===null||s===!1,di={getAdapter:s=>{s=m.isArray(s)?s:[s];let{length:e}=s,t,i,n={};for(let a=0;a<e;a++){t=s[a];let r;if(i=t,!kh(t)&&(i=Gn[(r=String(t)).toLowerCase()],i===void 0))throw new _(`Unknown adapter '${r}'`);if(i)break;n[r||"#"+a]=i}if(!i){let a=Object.entries(n).map(([o,l])=>`adapter ${o} `+(l===!1?"is not supported by the environment":"is not available in the build")),r=e?a.length>1?`since :
18
- `+a.map(al).join(`
19
- `):" "+al(a[0]):"as no adapter specified";throw new _("There is no suitable adapter to dispatch the request "+r,"ERR_NOT_SUPPORT")}return i},adapters:Gn};function qn(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Ae(null,s)}function mi(s){return qn(s),s.headers=X.from(s.headers),s.data=us.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),di.getAdapter(s.adapter||jt.adapter)(s).then(function(i){return qn(s),i.data=us.call(s,s.transformResponse,i),i.headers=X.from(i.headers),i},function(i){return ds(i)||(qn(s),i&&i.response&&(i.response.data=us.call(s,s.transformResponse,i.response),i.response.headers=X.from(i.response.headers))),Promise.reject(i)})}var hi={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{hi[s]=function(i){return typeof i===s||"a"+(e<1?"n ":" ")+s}});var rl={};hi.transitional=function(e,t,i){function n(a,r){return"[Axios v"+vt+"] Transitional option '"+a+"'"+r+(i?". "+i:"")}return(a,r,o)=>{if(e===!1)throw new _(n(r," has been removed"+(t?" in "+t:"")),_.ERR_DEPRECATED);return t&&!rl[r]&&(rl[r]=!0,console.warn(n(r," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,r,o):!0}};hi.spelling=function(e){return(t,i)=>(console.warn(`${i} is likely a misspelling of ${e}`),!0)};function Ah(s,e,t){if(typeof s!="object")throw new _("options must be an object",_.ERR_BAD_OPTION_VALUE);let i=Object.keys(s),n=i.length;for(;n-- >0;){let a=i[n],r=e[a];if(r){let o=s[a],l=o===void 0||r(o,a,s);if(l!==!0)throw new _("option "+a+" must be "+l,_.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new _("Unknown option "+a,_.ERR_BAD_OPTION)}}var bs={assertOptions:Ah,validators:hi};var Be=bs.validators,Vt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new on,response:new on}}async request(e,t){try{return await this._request(e,t)}catch(i){if(i instanceof Error){let n={};Error.captureStackTrace?Error.captureStackTrace(n):n=new Error;let a=n.stack?n.stack.replace(/^.+\n/,""):"";try{i.stack?a&&!String(i.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(i.stack+=`
20
- `+a):i.stack=a}catch{}}throw i}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Ge(this.defaults,t);let{transitional:i,paramsSerializer:n,headers:a}=t;i!==void 0&&bs.assertOptions(i,{silentJSONParsing:Be.transitional(Be.boolean),forcedJSONParsing:Be.transitional(Be.boolean),clarifyTimeoutError:Be.transitional(Be.boolean)},!1),n!=null&&(m.isFunction(n)?t.paramsSerializer={serialize:n}:bs.assertOptions(n,{encode:Be.function,serialize:Be.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),bs.assertOptions(t,{baseUrl:Be.spelling("baseURL"),withXsrfToken:Be.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=a&&m.merge(a.common,a[t.method]);a&&m.forEach(["delete","get","head","post","put","patch","common"],h=>{delete a[h]}),t.headers=X.concat(r,a);let o=[],l=!0;this.interceptors.request.forEach(function(x){typeof x.runWhen=="function"&&x.runWhen(t)===!1||(l=l&&x.synchronous,o.unshift(x.fulfilled,x.rejected))});let c=[];this.interceptors.response.forEach(function(x){c.push(x.fulfilled,x.rejected)});let p,d=0,u;if(!l){let h=[mi.bind(this),void 0];for(h.unshift.apply(h,o),h.push.apply(h,c),u=h.length,p=Promise.resolve(t);d<u;)p=p.then(h[d++],h[d++]);return p}u=o.length;let f=t;for(d=0;d<u;){let h=o[d++],x=o[d++];try{f=h(f)}catch(v){x.call(this,v);break}}try{p=mi.call(this,f)}catch(h){return Promise.reject(h)}for(d=0,u=c.length;d<u;)p=p.then(c[d++],c[d++]);return p}getUri(e){e=Ge(this.defaults,e);let t=ht(e.baseURL,e.url,e.allowAbsoluteUrls);return mt(t,e.params,e.paramsSerializer)}};m.forEach(["delete","get","head","options"],function(e){Vt.prototype[e]=function(t,i){return this.request(Ge(i||{},{method:e,url:t,data:(i||{}).data}))}});m.forEach(["post","put","patch"],function(e){function t(i){return function(a,r,o){return this.request(Ge(o||{},{method:e,headers:i?{"Content-Type":"multipart/form-data"}:{},url:a,data:r}))}}Vt.prototype[e]=t(),Vt.prototype[e+"Form"]=t(!0)});var ys=Vt;var Bn=class s{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(a){t=a});let i=this;this.promise.then(n=>{if(!i._listeners)return;let a=i._listeners.length;for(;a-- >0;)i._listeners[a](n);i._listeners=null}),this.promise.then=n=>{let a,r=new Promise(o=>{i.subscribe(o),a=o}).then(n);return r.cancel=function(){i.unsubscribe(a)},r},e(function(a,r,o){i.reason||(i.reason=new Ae(a,r,o),t(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=i=>{e.abort(i)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new s(function(n){e=n}),cancel:e}}},ol=Bn;function $n(s){return function(t){return s.apply(null,t)}}function zn(s){return m.isObject(s)&&s.isAxiosError===!0}var Wn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Wn).forEach(([s,e])=>{Wn[e]=s});var cl=Wn;function ll(s){let e=new ys(s),t=ss(ys.prototype.request,e);return m.extend(t,ys.prototype,e,{allOwnKeys:!0}),m.extend(t,e,null,{allOwnKeys:!0}),t.create=function(n){return ll(Ge(s,n))},t}var ne=ll(jt);ne.Axios=ys;ne.CanceledError=Ae;ne.CancelToken=ol;ne.isCancel=ds;ne.VERSION=vt;ne.toFormData=tt;ne.AxiosError=_;ne.Cancel=ne.CanceledError;ne.all=function(e){return Promise.all(e)};ne.spread=$n;ne.isAxiosError=zn;ne.mergeConfig=Ge;ne.AxiosHeaders=X;ne.formToJSON=s=>ti(m.isHTMLForm(s)?new FormData(s):s);ne.getAdapter=di.getAdapter;ne.HttpStatusCode=cl;ne.default=ne;var Ht=ne;var{Axios:Ly,AxiosError:Py,CanceledError:My,isCancel:Fy,CancelToken:jy,VERSION:Ny,all:Gy,Cancel:qy,isAxiosError:By,spread:$y,toFormData:zy,AxiosHeaders:Wy,HttpStatusCode:Vy,formToJSON:Hy,getAdapter:Ky,mergeConfig:Jy}=Ht;Ze();var pl=xe(nn());function fi(s,e){s.then().catch(t=>{console.warn(`failed to do ${e}, ran into error: `,t)})}var Kt=s=>new Promise(e=>setTimeout(e,s));function gi(s){return s&&(Object.prototype.toString.call(s)==="[object Function]"||typeof s=="function"||s instanceof Function)}var st={TOKEN_EXPIRED:40,WS_CLOSED_SUCCESS:1e3};function Ih(s){return s!==null&&typeof s=="object"&&(s.readable||typeof s._read=="function")}function Dh(s){return s!=null&&s.constructor!=null&&typeof s.constructor.isBuffer=="function"&&s.constructor.isBuffer(s)}function Uh(s){return typeof window<"u"&&"File"in window&&s instanceof File}function Oh(s){return typeof window<"u"&&"Blob"in window&&s instanceof Blob}function ul(s,e,t){let i=new pl.default;return Ih(s)||Dh(s)||Uh(s)||Oh(s)?e?i.append("file",s,e):i.append("file",s):i.append("file",{uri:s,name:e||s.split("/").reverse()[0],contentType:t||void 0,type:t||void 0}),i}function xi(s){let e=Math.min(500+s*2e3,25e3),t=Math.min(Math.max(250,(s-1)*2e3),25e3);return Math.floor(Math.random()*(e-t)+t)}function Ee(){return Lh()}function _s(s){let e="";for(let t=0;t<s.length;t++)e+=s[t].toString(16).padStart(2,"0");return e}function Lh(){let s=Fh(16);return s[6]=s[6]&15|64,s[8]=s[8]&191|128,_s(s.subarray(0,4))+"-"+_s(s.subarray(4,6))+"-"+_s(s.subarray(6,8))+"-"+_s(s.subarray(8,10))+"-"+_s(s.subarray(10,16))}function Ph(s){let e=Math.pow(2,8*s.byteLength/s.length);for(let t=0;t<s.length;t++)s[t]=Math.random()*e}var Mh=typeof crypto<"u"&&typeof crypto?.getRandomValues<"u"?crypto.getRandomValues.bind(crypto):typeof msCrypto<"u"?msCrypto.getRandomValues.bind(msCrypto):Ph;function Fh(s){let e=new Uint8Array(s);return Mh(e),e}function dl(s){typeof window<"u"&&window.addEventListener&&(window.addEventListener("offline",s),window.addEventListener("online",s))}function ml(s){typeof window<"u"&&window.removeEventListener&&(window.removeEventListener("offline",s),window.removeEventListener("online",s))}var hl=s=>{let e=[];for(let t in s)s[t]!==void 0&&(Array.isArray(s[t])||typeof s[t]=="object"?e.push(`${t}=${encodeURIComponent(JSON.stringify(s[t]))}`):e.push(`${t}=${encodeURIComponent(s[t])}`));return e.join("&")};function fl(s){return{...s,__html:s.html,pinned_at:s.pinned_at?new Date(s.pinned_at):null,created_at:s.created_at?new Date(s.created_at):new Date,updated_at:s.updated_at?new Date(s.updated_at):new Date,status:s.status||"received"}}function gl(s,e,t=!1,i="created_at",n=!0){let a=n||t,r=s;t&&(r=r.filter(x=>!(x.id&&e.id===x.id)));let o=r.length;if(o===0&&a)return r.concat(e);if(o===0)return[...r];if(i==="pinned_at")return r.concat(e);let l=e[i].getTime(),c=r[o-1][i].getTime()<l;if(c&&a)return r.concat(e);if(c)return[...r];let p=0,d=0,u=o-1;for(;p<=u;)d=Math.floor((u+p)/2),r[d][i].getTime()<=l?p=d+1:u=d-1;if(!t&&e.id){if(r[p]&&e.id===r[p].id){let v={...r[p]};return Object.keys(e).forEach(b=>{e[b]!==void 0&&(v[b]=e[b])}),r[p]=v,[...r]}if(r[p-1]&&e.id===r[p-1].id){let v={...r[p-1]};return Object.keys(e).forEach(b=>{e[b]!==void 0&&(v[b]=e[b])}),r[p-1]=v,[...r]}}a&&r.splice(p,0,e);let f=new Map,h=[];for(let x of r)f.has(x.id)||(f.set(x.id,!0),h.push(x));return h}var $=(s,e)=>s.length===0?[]:e.length===0?s.map(t=>(t.user={id:t.user?.id,name:t.user?.id,avatar:""},t)):s.map(t=>{let i=t.user?.id,n=t?.latest_reactions,a=t?.quoted_message,r=e.find(o=>o.id===i);if(r&&(t.user={id:r.id,name:r.name||r.id,avatar:r.avatar||""}),n&&(t.latest_reactions=n.map(o=>{let l=e.find(c=>c.id===o.user_id);return{...o,user:{id:l?.id||o.user_id,name:l?.name||o.user_id,avatar:l?.avatar||""}}})),a){let o=e.find(l=>l.id===a.user?.id);t.quoted_message.user={id:o?.id||a.user?.id,name:o?.name||a.user?.id,avatar:o?.avatar||""}}return t}),q=(s,e)=>{if(e.length===0)return{id:s,name:s,avatar:""};let t=e.find(i=>i.id===s);return{id:s,name:t?.name||s,avatar:t?.avatar||""}},_t=(s,e)=>{if(s.length===0)return"Empty channel";let t=s.find(i=>i.user.id!==e);return t?t.user.name||t.user.id:"Empty channel"},Cs=(s,e)=>{if(s.length===0)return"";let t=s.find(i=>i.user.id!==e);return t&&t.user.avatar||""};async function ws(s,e){let t=(e||[]).map(a=>a.user?.id).filter(a=>!!a),i=s.state.users,n=t.filter(a=>!i[a]);n.length>0&&await s.getBatchUsers(n)}var Ct=(s=[])=>s.length>0?Math.max(...s.map(e=>new Date(e.created_at).getTime())):0,it=(s,e,t,i)=>{let n,a;if(["videoConfig","audioConfig","transciverState"].includes(t)&&i){n=1;let l=JSON.stringify(i);a=new TextEncoder().encode(l)}else t==="connected"||t==="healthCall"?(n=1,a=new Uint8Array(0)):(n=9,a=new Uint8Array(s));let r=new Uint8Array(n+a.byteLength),o=0;switch(t){case"videoConfig":o=0;break;case"audioConfig":o=1;break;case"video-key":o=2;break;case"video-delta":o=3;break;case"audio":o=4;break;case"connected":o=6;break;case"transciverState":o=7;break;case"healthCall":o=11;break}return r[0]=o,e!==null&&new DataView(r.buffer).setBigUint64(1,BigInt(e),!1),r.set(a,n),r},Vn=s=>{let e="",t=new Uint8Array(s),i=t.byteLength;for(let n=0;n<i;n++)e+=String.fromCharCode(t[n]);return btoa(e)},xl=s=>{let e={2048:"123",4096:"153",8192:"156",16384:"183",32768:"186"},t=/2048|4096|8192|16384|32768/g;return s.match(t)?s.replace(t,i=>e[i]):"hev1.1.6.L123.B0"},vl=(s,e,t)=>{let i={cid:e,forward_cid:t,forward_message_id:s.id};return s.sticker_url&&(!s.text||s.text==="")&&(!s.attachments||Array.isArray(s.attachments)&&s.attachments.length===0)?(i.sticker_url=s.sticker_url,i.text=s.text):(i.text=s.text||"",s.attachments&&s.attachments.length>0&&(i.attachments=s.attachments.filter(n=>n.type!=="linkPreview"))),i};var Es=class{_channel;watcher_count;typing;read;pinnedMessages;watchers;members;unreadCount;membership;last_message_at;isUpToDate;messageSets=[];topics=[];constructor(e){this._channel=e,this.watcher_count=0,this.typing={},this.read={},this.initMessages(),this.pinnedMessages=[],this.watchers={},this.members={},this.membership={},this.unreadCount=0,this.isUpToDate=!0,this.last_message_at=e?.state?.last_message_at!=null?new Date(e.state.last_message_at):null}get messages(){return this.messageSets.find(e=>e.isCurrent)?.messages||[]}set messages(e){let t=this.messageSets.findIndex(i=>i.isCurrent);this.messageSets[t].messages=e}get latestMessages(){return this.messageSets.find(e=>e.isLatest)?.messages||[]}set latestMessages(e){let t=this.messageSets.findIndex(i=>i.isLatest);this.messageSets[t].messages=e}addMessageSorted(e,t=!1,i=!0,n="latest"){return this.addMessagesSorted([e],t,!1,i,n)}formatMessage(e){return{...e,__html:e.html,pinned_at:e.pinned_at?new Date(e.pinned_at):null,created_at:e.created_at?new Date(e.created_at):new Date,updated_at:e.updated_at?new Date(e.updated_at):null,status:e.status||"received"}}addMessagesSorted(e,t=!1,i=!1,n=!0,a="current"){let{messagesToAdd:r,targetMessageSetIndex:o}=this.findTargetMessageSet(e,n,a);for(let l=0;l<r.length;l+=1){let c=r[l].created_at instanceof Date,p;if(c?p=r[l]:(p=this.formatMessage(r[l]),p.user&&this._channel?.cid&&this._channel.getClient().state.updateUserReference(p.user,this._channel.cid),this.last_message_at||(this.last_message_at=new Date(p.created_at.getTime())),p.created_at.getTime()>this.last_message_at.getTime()&&(this.last_message_at=new Date(p.created_at.getTime()))),!p.pinned){let u=this.pinnedMessages.find(f=>f.id===p.id);u&&(p.pinned=!0,p.pinned_at=u.pinned_at||new Date)}!p.parent_id&&o!==-1&&(this.messageSets[o].messages=this._addToMessageList(this.messageSets[o].messages,p,t,"created_at",n))}return{messageSet:this.messageSets[o]}}addPinnedMessages(e){for(let t=0;t<e.length;t+=1)this.addPinnedMessage(e[t]);this.pinnedMessages.sort((t,i)=>{let n=t.pinned_at?new Date(t.pinned_at).getTime():0;return(i.pinned_at?new Date(i.pinned_at).getTime():0)-n})}addPinnedMessage(e){let t=this.formatMessage(e);this.pinnedMessages=this.pinnedMessages.filter(i=>i.id!==t.id),this.pinnedMessages=[t,...this.pinnedMessages]}removePinnedMessage(e){let{result:t}=this.removeMessageFromArray(this.pinnedMessages,e);this.pinnedMessages=t}addReaction(e,t,i){if(!t)return;let n=t;return this._updateMessage(t,a=>(n.own_reactions=this._addOwnReactionToMessage(a.own_reactions,e,i),this.formatMessage(n))),n}_addOwnReactionToMessage(e,t,i){return i?e=[]:e=this._removeOwnReactionFromMessage(e,t),e=e||[],this._channel.getClient().userID===t.user_id&&e.push(t),e}_removeOwnReactionFromMessage(e,t){return e&&e.filter(i=>i.user_id!==t.user_id||i.type!==t.type)}removeReaction(e,t){if(!t)return;let i=t;return this._updateMessage(t,n=>(i.own_reactions=this._removeOwnReactionFromMessage(n.own_reactions,e),this.formatMessage(i))),i}removeQuotedMessageReferences(e){let t=i=>({...i,created_at:i.created_at.toISOString(),pinned_at:i.pinned_at?.toISOString(),updated_at:i.updated_at?.toISOString()});this.messageSets.forEach(i=>{let n=i.messages.filter(a=>a.quoted_message_id===e.id).map(t).map(a=>({...a,quoted_message:{...e,attachments:[]}}));this.addMessagesSorted(n,!0)})}_updateMessage(e,t){let{parent_id:i,pinned:n}=e;if(!i){let a=this.findMessageSetIndex(e);if(a!==-1){let r=this.messageSets[a].messages.findIndex(o=>o.id===e.id);r!==-1&&(this.messageSets[a].messages[r]=t(this.messageSets[a].messages[r]))}}if(n){let a=this.pinnedMessages.findIndex(r=>r.id===e.id);a!==-1&&(this.pinnedMessages[a]=t(this.pinnedMessages[a]))}}setIsUpToDate=e=>{this.isUpToDate=e};updateMessageStatus(e,t){this._updateMessage({id:e},i=>({...i,status:t}))}_addToMessageList(e,t,i=!1,n="created_at",a=!0){return gl(e,t,i,n,a)}removeMessage(e){let t=!1,i=e.messageSetIndex??this.findMessageSetIndex(e);if(i!==-1){let{removed:n,result:a}=this.removeMessageFromArray(this.messageSets[i].messages,e);this.messageSets[i].messages=a,t=n}return t}removeMessageFromArray=(e,t)=>{let i=e.filter(n=>!(n.id&&t.id&&n.id===t.id));return{removed:i.length<e.length,result:i}};updateUserMessages=e=>{let t=(i,n)=>{for(let a=0;a<i.length;a++){let r=i[a],o=r?.latest_reactions||[];r.user?.id===n.id&&(i[a]={...r,user:r.user?.id===n.id?n:r.user}),o&&o.some(l=>l.user?.id===n.id)&&(i[a]={...r,latest_reactions:o.map(l=>l.user?.id===n.id?{...l,user:n}:l)})}};this.messageSets.forEach(i=>{t(i.messages,e),i.messages=[...i.messages]}),t(this.pinnedMessages,e),this.pinnedMessages=[...this.pinnedMessages]};deleteUserMessages=(e,t=!1)=>{let i=(n,a,r=!1)=>{for(let o=0;o<n.length;o++){let l=n[o];l.user?.id===a.id&&(r?n[o]={cid:l.cid,created_at:l.created_at,deleted_at:new Date().toISOString(),id:l.id,latest_reactions:[],mentioned_users:[],own_reactions:[],parent_id:l.parent_id,reply_count:l.reply_count,status:l.status,type:"deleted",updated_at:l.updated_at,user:l.user}:n[o]={...l,type:"deleted",deleted_at:new Date().toISOString()})}};this.messageSets.forEach(n=>i(n.messages,e,t)),i(this.pinnedMessages,e,t)};filterErrorMessages(){let e=this.latestMessages.filter(t=>t.type!=="error");this.latestMessages=e}clean(){let e=new Date;for(let[t,i]of Object.entries(this.typing)){let n=typeof i.received_at=="string"?new Date(i.received_at):i.received_at||new Date;e.getTime()-n.getTime()>7e3&&(delete this.typing[t],this._channel.getClient().dispatchEvent({cid:this._channel.cid,type:"typing.stop",user:{id:t}}))}}clearMessages(){this.initMessages(),this.pinnedMessages=[]}initMessages(){this.messageSets=[{messages:[],isLatest:!0,isCurrent:!0}]}async loadMessageIntoState(e,t,i=25){let n,a=!1,r=t||e;if(e==="latest"){if(this.messages===this.latestMessages)return;n=this.messageSets.findIndex(o=>o.isLatest)}else n=this.findMessageSetIndex({id:r});n!==-1&&(this.switchToMessageSet(n),a=!0),a||await this._channel.query({messages:{id_around:r,limit:i}},"new"),n=this.findMessageSetIndex({id:r}),n!==-1&&this.switchToMessageSet(n)}findMessage(e,t){let i=this.findMessageSetIndex({id:e});if(i!==-1)return this.messageSets[i].messages.find(n=>n.id===e)}switchToMessageSet(e){let t=this.messageSets.find(i=>i.isCurrent);t&&(t.isCurrent=!1,this.messageSets[e].isCurrent=!0)}areMessageSetsOverlap(e,t){return e.some(i=>t.find(n=>i.id===n.id))}findMessageSetIndex(e){return this.messageSets.findIndex(t=>!!t.messages.find(i=>i.id===e.id))}findTargetMessageSet(e,t=!0,i="current"){let n=e,a;if(t){let r=this.messageSets.map((c,p)=>p).filter(c=>this.areMessageSetsOverlap(this.messageSets[c].messages,e));switch(i){case"new":r.length>0?a=r[0]:e.some(c=>!c.parent_id)&&(this.messageSets.push({messages:[],isCurrent:!1,isLatest:!1}),a=this.messageSets.length-1);break;case"current":a=this.messageSets.findIndex(c=>c.isCurrent);break;case"latest":a=this.messageSets.findIndex(c=>c.isLatest);break;default:a=-1}let o=r.splice(0,1)[0],l=[...r];if(o!==void 0&&o!==a&&l.push(a),l.length>0){let c=this.messageSets[o],p=this.messageSets.filter((u,f)=>l.indexOf(f)!==-1);p.forEach(u=>{c.isLatest=c.isLatest||u.isLatest,c.isCurrent=c.isCurrent||u.isCurrent,n=[...n,...u.messages]}),p.forEach(u=>this.messageSets.splice(this.messageSets.indexOf(u),1)),a=this.messageSets.findIndex(u=>this.areMessageSetsOverlap(u.messages,e))}}else a=this.findMessageSetIndex(e[0]);return{targetMessageSetIndex:a,messagesToAdd:n}}};function Ss(s){let e=s.lastIndexOf("."),t=e>0?s.slice(0,e):s,i=e>0?s.slice(e):"";return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d").replace(/Đ/g,"D").replace(/\s+/g,"_")+i}function bl(s){let e=s.type.toLowerCase(),t=s.name.toLowerCase().split(".").pop()||"";return e==="image/heic"||e==="image/heif"||t==="heic"||t==="heif"}function Hn(s,e){let t=s.toLowerCase(),i=(e||"").toLowerCase().split(".").pop()||"";return t==="image/heic"||t==="image/heif"||i==="heic"||i==="heif"?"file":t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function vi(s){return s.type==="video/mp4"||s.type==="video/webm"||s.type==="video/quicktime"}function bi(s,e,t,i){let n=Ss(s.name),a=s.type||"",r=Hn(a,s.name);if(i)return{type:"voiceRecording",asset_url:e,title:n,file_size:s.size,mime_type:a,waveform_data:i.waveform_data,duration:i.duration};switch(r){case"image":return{type:"image",image_url:e,title:n,file_size:s.size,mime_type:a};case"video":return{type:"video",asset_url:e,title:n,file_size:s.size,mime_type:a,thumb_url:t||""};case"audio":return{type:"file",asset_url:e,title:n,file_size:s.size,mime_type:a};default:return{type:"file",asset_url:e,title:n,file_size:s.size,mime_type:a||""}}}var Jt=class{_client;type;id;data;_data;cid;listeners;state;initialized;offlineMode;lastKeyStroke;lastTypingEvent;isTyping;disconnected;constructor(e,t,i,n){let a=/^[\w_-]+$/,r=/^[\w!:_-]+$/;if(!a.test(t))throw new Error(`Invalid chat type ${t}, letters, numbers and "_-" are allowed`);if(typeof i=="string"&&!r.test(i))throw new Error(`Invalid chat id ${i}, letters, numbers and "!-_" are allowed`);this._client=e,this.type=t,this.id=i,this.data=n,this._data={...n},this.cid=`${t}:${i}`,this.listeners={},this.state=new Es(this),this.initialized=!1,this.offlineMode=!1,this.lastTypingEvent=null,this.isTyping=!1,this.disconnected=!1}getClient(){return this._client}async sendMessage(e){e.id||(e={...e,id:Ee()});let t=e.id,i={...e,id:t,status:"sending",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),user:this.getClient().user,user_id:this.getClient().userID,type:"regular"};this.state.addMessageSorted(i);try{return await this.getClient().post(this._channelURL()+"/message",{message:{...e}})}catch(n){let r=!n.response||n.code==="ERR_NETWORK"||n.isWSFailure||!this.getClient().wsConnection?.isHealthy?"failed_offline":"error";throw this.state.updateMessageStatus(t,r),n}}async retryMessage(e){let t=this.state.messages.find(n=>n.id===e);if(!t)throw new Error(`Message ${e} not found in state`);this.state.updateMessageStatus(e,"sending");let i={id:t.id,text:t.text,attachments:t.attachments,mentioned_users:t.mentioned_users,parent_id:t.parent_id,quoted_message_id:t.quoted_message_id,sticker_url:t.sticker_url};t.show_in_channel!==void 0&&(i.show_in_channel=t.show_in_channel);try{return await this.getClient().post(this._channelURL()+"/message",{message:i})}catch(n){let a=!n.response||n.code==="ERR_NETWORK"||n.isWSFailure||!this.getClient().wsConnection?.isHealthy;throw this.state.updateMessageStatus(e,a?"failed_offline":"error"),n}}async createPoll(e){let t=Ee();return e={...e,id:t},await this.getClient().post(this._channelURL()+"/message",{message:{...e}})}async votePoll(e,t){if(!e)throw Error("Message id is missing");return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/poll/${t}`)}async forwardMessage(e,t){return e.id||(e={...e,id:Ee()}),await this.getClient().post(`${this.getClient().baseURL}/channels/${t.type}/${t.channelID}/message`,{message:{...e}})}async pinMessage(e){return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/pin`)}async unpinMessage(e){return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/unpin`)}async pin(){this.data&&(this.data.is_pinned=!0),this.getClient().dispatchEvent({type:"channel.pinned",cid:this.cid,channel:this.data});try{return await this.getClient().pinChannel(this.type,this.id)}catch(e){throw this.data&&(this.data.is_pinned=!1),this.getClient().dispatchEvent({type:"channel.unpinned",cid:this.cid,channel:this.data}),e}}async unpin(){this.data&&(this.data.is_pinned=!1),this.getClient().dispatchEvent({type:"channel.unpinned",cid:this.cid,channel:this.data});try{return await this.getClient().unpinChannel(this.type,this.id)}catch(e){throw this.data&&(this.data.is_pinned=!0),this.getClient().dispatchEvent({type:"channel.pinned",cid:this.cid,channel:this.data}),e}}async editMessage(e,t){return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}`,{message:t})}sendFile(e,t,i,n){return this.getClient().sendFile(`${this._channelURL()}/file`,e,t,i,n)}async uploadAndPrepareAttachments(e,t){let i=[],n=e.map(c=>{let p=Ss(c.name);return p!==c.name?new File([c],p,{type:c.type,lastModified:c.lastModified}):c}),a=await Promise.allSettled(n.map(c=>this.sendFile(c,c.name,c.type))),r=new Map,o=[];for(let c=0;c<n.length;c++)a[c].status==="fulfilled"&&vi(n[c])&&o.push((async()=>{try{let d=await this.getThumbBlobVideo(e[c]);if(d){let u=new File([d],`thumb_${n[c].name}.jpg`,{type:"image/jpeg"}),f=await this.sendFile(u,u.name,"image/jpeg");r.set(c,f.file)}}catch{}})());await Promise.allSettled(o);let l=[];for(let c=0;c<n.length;c++){let p=a[c];if(p.status==="fulfilled"){let d=p.value.file,u=r.get(c),f=t?.voiceMetadata?.get(c);l.push(bi(n[c],d,u,f))}else i.push({file:e[c],error:p.reason instanceof Error?p.reason:new Error(String(p.reason))})}return{attachments:l,failedFiles:i}}async sendEvent(e){return await this.getClient().post(this._channelURL()+"/event",{event:e})}async sendReaction(e,t){if(!e)throw Error("Message id is missing");return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/reaction/${t}`)}deleteReaction(e,t){if(!t||!e)throw Error("Deleting a reaction requires specifying both the message and reaction type");let i=this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/reaction/${t}`;return this.getClient().delete(i,{})}async update(e={},t){return["config","cid","created_by","id","member_count","type","created_at","updated_at","last_message_at","own_capabilities"].forEach(n=>{delete e[n]}),await this._update({message:t,data:e})}async delete(){return await this.getClient().delete(this._channelURL())}async truncate(){return await this.getClient().delete(this._channelURL()+"/truncate")}async blockUser(){return await this.getClient().post(this._channelURL(),{action:"block"})}async unblockUser(){return await this.getClient().post(this._channelURL(),{action:"unblock"})}async acceptInvite(e){let t=this.id,i=this.getClient().userBaseURL+`/token_gate/join_channel/${this.type}`;return this.getClient().post(i,{},{channel_id:t,action:e})}async rejectInvite(){let e=this.getClient().baseURL+`/invites/${this.type}/${this.id}/reject`;return this.getClient().post(e)}async skipInvite(){let e=this.getClient().baseURL+`/invites/${this.type}/${this.id}/skip`;return this.getClient().post(e)}async addMembers(e){return await this._update({add_members:e})}async addModerators(e){return await this._update({promote_members:e})}async banMembers(e){return await this._update({ban_members:e})}async unbanMembers(e){return await this._update({unban_members:e})}async updateCapabilities(e){return await this._update({capabilities:e})}async setSlowMode(e){let t=[0,1e4,3e4,6e4,3e5,9e5,36e5];if(!t.includes(e))throw new Error(`Invalid cooldown value: ${e}. Allowed values are: ${t.join(", ")} (milliseconds).`);return await this.update({member_message_cooldown:e})}async queryAttachmentMessages(){let e=await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/attachment`,{attachment_types:["image","video","file","voiceRecording","linkPreview"]});return e.attachments&&e.attachments.sort((t,i)=>new Date(i.created_at).getTime()-new Date(t.created_at).getTime()),e}async searchMessage(e,t){let i=await this.getClient().post(this.getClient().baseURL+"/channels/search",{cid:this.cid,search_term:e,offset:t,limit:25});return!i||i?.search_result?.messages.length===0?null:{...i?.search_result,messages:i?.search_result?.messages.map(n=>{let a=q(n.user_id,Object.values(this.getClient().state.users))||n.user;return{...n,user:a}})}}async removeMembers(e){return await this._update({remove_members:e})}async demoteModerators(e){return await this._update({demote_members:e})}async _update(e){let t=await this.getClient().post(this._channelURL(),e);return this.data={...this.data,...t.channel},t}_processTopics(e,t){let i=e.map(a=>(a.channel&&a.channel.members&&(a.channel.members=$(a.channel.members,t)),a.messages&&(a.messages=$(a.messages,t)),a.pinned_messages&&(a.pinned_messages=$(a.pinned_messages,t)),a.read&&(a.read=$(a.read,t)),a)),{channels:n}=this.getClient().hydrateChannels(i,{});this.state.topics=n}async muteNotification(e){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/muted`,{mute:!0,duration:e})}async unMuteNotification(){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/muted`,{mute:!1})}async keystroke(e,t){let i=new Date,n=this.lastTypingEvent&&i.getTime()-this.lastTypingEvent.getTime();this.lastKeyStroke=i,this.isTyping=!0,(n===null||n>2e3)&&(this.lastTypingEvent=new Date,await this.sendEvent({type:"typing.start",parent_id:e,...t||{}}))}async stopTyping(e,t){this.isTyping&&(this.lastTypingEvent=null,this.isTyping=!1,await this.sendEvent({type:"typing.stop",parent_id:e,...t||{}}))}_isTypingIndicatorsEnabled(){return!0}lastMessage(){let e=this.state.latestMessages.length-5;e<0&&(e=0);let t=this.state.latestMessages.length+1,i=this.state.latestMessages.slice(e,t);return i.sort((n,a)=>a.created_at.getTime()-n.created_at.getTime()),i[0]}async markRead(){return await this.getClient().post(this._channelURL()+"/read")}clean(){this.lastKeyStroke&&new Date().getTime()-this.lastKeyStroke.getTime()>1e3&&this.isTyping&&fi(this.stopTyping(),"stop typing event"),this.state.clean()}async watch(e){await this.getClient().wsPromise;let t={...e},i=await this.query(t,"latest");this.initialized=!0,await ws(this.getClient(),i.channel.members);let n=Object.values(this.getClient().state.users);if(i.channel.members=$(i.channel.members,n),i.channel.name=i.channel.type==="messaging"?_t(i.channel.members,this.getClient().userID||""):i.channel.name,i.channel.image=i.channel.type==="messaging"?Cs(i.channel.members,this.getClient().userID||""):i.channel.image,i.messages=$(i.messages,n),i.pinned_messages=i.pinned_messages?$(i.pinned_messages,n):[],i.read=$(i.read||[],n),this.type==="team"&&i.channel.topics_enabled){let a={filter_conditions:{type:["topic"],parent_cid:this.cid,project_id:this.getClient().projectId},sort:[],message_limit:25},r=await this.getClient().post(this.getClient().baseURL+"/channels",a);this._processTopics(r.channels||[],n)}return this.data=i.channel,this._client.logger("info",`channel:watch() - started watching channel ${this.cid}`,{tags:["channel"],channel:this}),i}lastRead(){let{userID:e}=this.getClient();if(e)return this.state.read[e]?this.state.read[e].last_read:null}_countMessageAsUnread(e){return!(e.parent_id&&!e.show_in_channel||e.user?.id===this.getClient().userID||e.type==="system"||Array.isArray(this.data?.own_capabilities)&&!this.data?.own_capabilities.includes("read-events"))}countUnread(e){if(!e)return this.state.unreadCount;let t=0;for(let i=0;i<this.state.latestMessages.length;i+=1){let n=this.state.latestMessages[i];n.created_at>e&&this._countMessageAsUnread(n)&&t++}return t}getUnreadMemberCount(){return this.state.read?Object.values(this.state.read):[]}getCapabilitiesMember(){return this.data?this.data.member_capabilities:[]}create=async()=>this.type==="messaging"?await this.createDirectChannel("latest"):await this.query({},"latest");async createTopic(e){let t=this._client.projectId,i=Ee(),n=`${t}:${i}`,a=`${this.getClient().baseURL}/channels/topic/${n}`,r={project_id:t,parent_cid:this.cid,data:{...e}};return await this.getClient().post(a+"/query",r)}async query(e,t="current"){await this.getClient().wsPromise;let i=this._client.projectId,n={...e,project_id:i},a=`${this.getClient().baseURL}/channels/${this.type}`;if(this.id)a+=`/${this.id}`;else if(this.type==="team"||this.type==="meeting"){let u=Ee();this.id=`${i}:${u}`,a+=`/${this.id}`}let r={state:!0,...n};this._data&&Object.keys(this._data).length>0&&(r.data=this._data);let o=await this.getClient().post(a+"/query",r);await ws(this.getClient(),o.channel.members);let l=Object.values(this.getClient().state.users);o.channel.members=$(o.channel.members,l),o.channel.name=o.channel.type==="messaging"?_t(o.channel.members,this.getClient().userID||""):o.channel.name,o.channel.image=o.channel.type==="messaging"?Cs(o.channel.members,this.getClient().userID||""):o.channel.image,o.messages=$(o.messages,l),o.pinned_messages=o.pinned_messages?$(o.pinned_messages,l):[],o.read=$(o.read||[],l),o.channel.is_pinned=o.is_pinned||!1;let c=this.cid;if(c!==o.channel.cid){this.id=o.channel.id,this.cid=o.channel.cid,c in this.getClient().activeChannels&&delete this.getClient().activeChannels[c];let u=o.channel.members.map(h=>h.user_id||h.user?.id).sort().join(","),f=`${this.type}:!members-${u}`;f in this.getClient().activeChannels&&delete this.getClient().activeChannels[f],this.cid in this.getClient().activeChannels||(this.getClient().activeChannels[this.cid]=this)}else this.cid in this.getClient().activeChannels||(this.getClient().activeChannels[this.cid]=this);let{messageSet:p}=this._initializeState(o,t),d=[...o.channel.own_capabilities||[]].sort().join()!==[...Array.isArray(this.data?.own_capabilities)?this.data?.own_capabilities:[]].sort().join();return this.data=o.channel,this.offlineMode=!1,d&&this.getClient().dispatchEvent({type:"capabilities.changed",cid:this.cid,own_capabilities:o.channel.own_capabilities}),o}async createDirectChannel(e="current"){await this.getClient().wsPromise;let t=this._client.projectId,i=`${this.getClient().baseURL}/channels/${this.type}`,n={project_id:t};this._data&&Object.keys(this._data).length>0&&(n.data=this._data);let a=await this.getClient().post(i+"/query",n),r=Object.values(this.getClient().state.users);a.channel.members=$(a.channel.members,r),a.channel.name=a.channel.type==="messaging"?_t(a.channel.members,this.getClient().userID||""):a.channel.name,a.messages=$(a.messages,r),a.pinned_messages=a.pinned_messages?$(a.pinned_messages,r):[],a.read=$(a.read||[],r);let{messageSet:o}=this._initializeState(a,e),l=[...a.channel.own_capabilities||[]].sort().join()!==[...Array.isArray(this.data?.own_capabilities)?this.data?.own_capabilities:[]].sort().join();return this.data=a.channel,this.offlineMode=!1,l&&this.getClient().dispatchEvent({type:"capabilities.changed",cid:a.channel.cid,own_capabilities:a.channel.own_capabilities}),a}async queryMessagesLessThanId(e,t=25){await this.getClient().wsPromise;let i=this._client.projectId,n=`${this.getClient().baseURL}/channels/${this.type}/${this.id}`,a=await this.getClient().post(n+"/query",{state:!0,project_id:i,messages:{limit:t,id_lt:e}}),r=Object.values(this.getClient().state.users);if(a.messages=$(a.messages,r),a.messages&&a.messages.length>0){for(let o of a.messages)if(!o.pinned){let l=this.state.pinnedMessages?.find(c=>c.id===o.id);if(l){o.pinned=!0;let c=l.pinned_at||new Date;o.pinned_at=typeof c=="string"?c:c.toISOString()}}this.state.addMessagesSorted(a.messages,!1,!0,!0,"current")}return a.messages}async queryMessagesGreaterThanId(e,t=25){await this.getClient().wsPromise;let i=this._client.projectId,n=`${this.getClient().baseURL}/channels/${this.type}/${this.id}`,a=await this.getClient().post(n+"/query",{state:!0,project_id:i,messages:{limit:t,id_gt:e}}),r=Object.values(this.getClient().state.users);if(a.messages=$(a.messages,r),a.messages&&a.messages.length>0){for(let o of a.messages)if(!o.pinned){let l=this.state.pinnedMessages?.find(c=>c.id===o.id);if(l){o.pinned=!0;let c=l.pinned_at||new Date;o.pinned_at=typeof c=="string"?c:c.toISOString()}}this.state.addMessagesSorted(a.messages,!1,!0,!0,"current")}return a.messages}async queryMessagesAroundId(e,t=25){await this.getClient().wsPromise;let i=this._client.projectId,n=`${this.getClient().baseURL}/channels/${this.type}/${this.id}`,a=await this.getClient().post(n+"/query",{state:!0,project_id:i,messages:{limit:t,id_around:e}}),r=Object.values(this.getClient().state.users);if(a.messages=$(a.messages,r),a.messages&&a.messages.length>0){for(let o of a.messages)if(!o.pinned){let l=this.state.pinnedMessages?.find(c=>c.id===o.id);if(l){o.pinned=!0;let c=l.pinned_at||new Date;o.pinned_at=typeof c=="string"?c:c.toISOString()}}this.state.addMessagesSorted(a.messages,!1,!0,!0,"current")}return a.messages}async deleteMessage(e){return await this.getClient().delete(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}`)}async deleteMessageForMe(e){return await this.getClient().delete(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}`,{for_me:!0})}async getThumbBlobVideo(e){return new Promise(t=>{let i=document.createElement("video");i.src=URL.createObjectURL(e),i.crossOrigin="anonymous",i.muted=!0,i.load();let n=0,a=5,r=1,o=()=>{URL.revokeObjectURL(i.src),i.remove()};i.addEventListener("error",()=>{console.error("Error when loading video file."),o(),t(null)});let l=()=>{try{let c=document.createElement("canvas");c.width=i.videoWidth,c.height=i.videoHeight;let p=c.getContext("2d",{willReadFrequently:!0});if(!p){console.error("Failed to create canvas context."),o(),t(null);return}p.drawImage(i,0,0,c.width,c.height);let u=p.getImageData(0,0,c.width,c.height).data,f=0,h=40,x=0;for(let b=0;b<u.length;b+=h*4){let T=u[b],I=u[b+1],M=u[b+2];f+=.2126*T+.7152*I+.0722*M,x++}if(f/x<15&&n<a&&i.currentTime+r<i.duration){n++,i.currentTime+=r;return}c.toBlob(b=>{if(o(),!b){console.error("Failed to generate thumbnail."),t(null);return}t(b)},"image/jpeg",.75)}catch(c){console.error("Error while extracting thumbnail:",c),o(),t(null)}};i.addEventListener("loadedmetadata",()=>{i.currentTime=Math.min(.5,i.duration)}),i.addEventListener("seeked",l)})}async enableTopics(){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics/enable`,{project_id:this.getClient().projectId,messages:{limit:25}})}async disableTopics(){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics/disable`,{project_id:this.getClient().projectId})}async closeTopic(e){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics/close`,{project_id:this.getClient().projectId,topic_cid:e})}async reopenTopic(e){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics/reopen`,{project_id:this.getClient().projectId,topic_cid:e})}async editTopic(e,t){let i=await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics`,{project_id:this.getClient().projectId,topic_cid:e,data:t});if(i){let n=this.getClient().activeChannels[e];return n?(n.data=i.channel,n.data):i.channel}}on(e,t){let i=t?e:"all",n=t||e;return i in this.listeners||(this.listeners[i]=[]),this._client.logger("info",`Attaching listener for ${i} event on channel ${this.cid}`,{tags:["event","channel"],channel:this}),this.listeners[i].push(n),{unsubscribe:()=>{this._client.logger("info",`Removing listener for ${i} event from channel ${this.cid}`,{tags:["event","channel"],channel:this}),this.listeners[i]=this.listeners[i].filter(a=>a!==n)}}}off(e,t){let i=t?e:"all",n=t||e;i in this.listeners||(this.listeners[i]=[]),this._client.logger("info",`Removing listener for ${i} event from channel ${this.cid}`,{tags:["event","channel"],channel:this}),this.listeners[i]=this.listeners[i].filter(a=>a!==n)}async _handleChannelEvent(e){let t=this;this._client.logger("info",`channel:_handleChannelEvent - Received event of type { ${e.type} } on ${this.cid}`,{tags:["event","channel"],channel:this});let i=t.state,n=Object.values(this.getClient().state.users);switch(e.type){case"typing.start":if(e.user?.id){let c=q(e.user.id||"",n);e.user=c,i.typing[e.user.id]=e}break;case"typing.stop":e.user?.id&&delete i.typing[e.user.id];break;case"message.read":if(e.user?.id&&e.created_at){let c=q(e.user.id||"",n);e.user=c,i.read[e.user.id]={last_read:new Date(e.created_at),last_read_message_id:e.last_read_message_id,user:c,unread_messages:0},e.user?.id===this.getClient().user?.id&&(i.unreadCount=0)}break;case"user.watching.start":e.user?.id&&(i.watchers[e.user.id]=e.user);break;case"user.watching.stop":e.user?.id&&delete i.watchers[e.user.id];break;case"message.deleted":if(e.message){this._extendEventWithOwnReactions(e),i.removeMessage(e.message),i.latestMessages.length===0&&this.query({messages:{limit:1}}).then(()=>{this._callChannelListeners({type:"channel.updated",cid:this.cid,channel:this.data})}).catch(p=>{this._client.logger("error","Failed to query for new last message after deletion",{err:p})}),i.removeQuotedMessageReferences(e.message),[...i.pinnedMessages].some(p=>p.id===e.message?.id)&&i.removePinnedMessage(e.message);let c=e.message.created_at?new Date(e.message.created_at):null;for(let p in i.read){p!==e.user?.id&&e.message.id===i.read[p].last_read_message_id&&(i.read[p]={...i.read[p],last_read_message_id:void 0});let d=i.read[p],u=d.last_read?new Date(d.last_read):new Date(0);if(c&&c>u){let f=e.message.user?.id===p||e.message.user_id===p,h=e.message.type==="system";!f&&!h&&(d.unread_messages=Math.max(0,d.unread_messages-1),p===this.getClient().userID&&(i.unreadCount=Math.max(0,i.unreadCount-1)))}}}break;case"message.deleted_for_me":e.message&&(delete e.message.user,delete e.message.user_id,e.message.display_type="deleted",e.message.pinned_at=null,e.message.updated_at=null,e.message.status="received",i.addMessageSorted(e.message),i.removeQuotedMessageReferences(e.message),[...i.pinnedMessages].some(c=>c.id===e.message?.id)&&i.removePinnedMessage(e.message));break;case"message.new":if(e.message){let c=e.user?.id===this.getClient().user?.id,p=!!e.message.parent_id;if(!n.find(h=>h.id===e.user?.id)&&e.user?.id){let h=await this.getClient().queryUser(e.user.id);n.push(h)}let u=q(e.user?.id||"",n);if(e.message.user=u,e.message?.quoted_message){let h=q(e.message.quoted_message.user?.id||"",n);e.message.quoted_message.user=h}if(e.user=u,(this.state.isUpToDate||p)&&i.addMessageSorted(e.message,c),c||p)break;if(e.user?.id)for(let h in i.read)h===e.user.id?i.read[e.user.id]={last_read:new Date(e.created_at),user:e.user,unread_messages:0}:i.read[h].unread_messages+=1;this._countMessageAsUnread(e.message)&&(i.unreadCount=i.unreadCount+1)}break;case"message.updated":if(e.message){let c=q(e.user?.id||"",n),p=q(e.message.user?.id||"",n);if(e.user=c,e.message.user=p,e.message?.quoted_message){let d=q(e.message.quoted_message.user?.id||"",n);e.message.quoted_message.user=d}e.message?.latest_reactions&&(e.message.latest_reactions=$(e.message.latest_reactions||[],n)),this._extendEventWithOwnReactions(e),i.addMessageSorted(e.message,!1,!1),e.message.pinned?i.addPinnedMessage(e.message):i.removePinnedMessage(e.message)}break;case"message.pinned":if(e.message){let c=q(e.message.user?.id||"",n);e.message.user=c,i.addPinnedMessage(e.message),i.addMessageSorted(e.message,!1,!1)}break;case"message.unpinned":if(e.message){let c=q(e.message.user?.id||"",n);e.message.user=c,i.removePinnedMessage(e.message),i.addMessageSorted(e.message,!1,!1)}break;case"channel.truncate":{let c=e.channel?.created_at||e.created_at;if(c){let p=+new Date(c);i.messageSets.forEach((d,u)=>{d.messages.forEach(({created_at:f,id:h})=>{p>+f&&i.removeMessage({id:h,messageSetIndex:u})})}),i.pinnedMessages.forEach(({id:d,created_at:u})=>{p>+u&&i.removePinnedMessage({id:d})})}else i.clearMessages();i.unreadCount=0,e.message&&(i.addMessageSorted(e.message),e.message.pinned&&i.addPinnedMessage(e.message));break}case"member.added":if(e.member?.user_id){let c=q(e.member.user_id,n);e.member.user=c,i.members[e.member.user_id]=e.member,e.member.user?.id===this.getClient().user?.id&&(i.membership=e.member)}break;case"member.updated":if(e.member?.user_id){let c=q(e.member.user_id,n);e.member.user=c,i.members[e.member.user_id]=e.member,i.membership=e.member}break;case"member.removed":e.member?.user_id?delete i.members[e.member.user_id]:e.user?.id&&delete i.members[e.user.id];break;case"channel.topic.enabled":t.data&&(t.data.topics_enabled=!0),i.topics=i.topics||[],e.user=q(e.user?.id||"",n);break;case"channel.topic.disabled":t.data&&(t.data.topics_enabled=!1),i.topics=[],e.user=q(e.user?.id||"",n);break;case"channel.updated":e.channel&&(t.data={...t.data,...e.channel,own_capabilities:e.channel?.own_capabilities??t.data?.own_capabilities});break;case"pollchoice.new":if(e.message){let c=q(e.message.user?.id||"",n);e.message.user=c,i.addMessageSorted(e.message,!1,!1)}break;case"reaction.new":if(e.message&&e.reaction){let c=q(e.message.user?.id||"",n),p=q(e.reaction.user?.id||"",n);if(e.message.user=c,e.message.latest_reactions=$(e.message.latest_reactions||[],n),e.reaction.user=p,e.message?.quoted_message){let d=q(e.message.quoted_message.user?.id||"",n);e.message.quoted_message.user=d}e.message=i.addReaction(e.reaction,e.message)}break;case"reaction.deleted":if(e.user=q(e.user?.id||"",n),e.message){if(e.message?.quoted_message){let c=q(e.message.quoted_message.user?.id||"",n);e.message.quoted_message.user=c}e.message.user=q(e.message.user?.id||"",n),e.message.latest_reactions?.map(c=>(c.user=q(c.user?.id||"",n),c))}e.reaction&&(e.reaction.user=q(e.reaction.user?.id||"",n),e.message=i.removeReaction(e.reaction,e.message));break;case"member.joined":case"notification.invite_accepted":if(e.member?.user_id){if(!n.find(d=>d.id===e.member?.user_id)){let d=await this.getClient().queryUser(e.member?.user_id);n.push(d)}let p=q(e.member.user_id,n);e.member.user=p,e.member.user_id===this.getClient().user?.id&&(i.membership=e.member,this.state.membership=e.member),i.members[e.member.user_id]=e.member,t.data={...t.data,member_count:Number(t.data?.member_count)+1,members:t.data?.members?[...t.data.members,e.member]:[e.member]},this.offlineMode=!0,this.initialized=!0}break;case"notification.invite_rejected":e.member?.user_id&&delete i.members[e.member.user_id];break;case"notification.invite_messaging_skipped":if(e.member?.user_id){let c=q(e.member.user_id,n);e.member.user=c,e.member.user_id===this.getClient().user?.id&&(i.membership=e.member,this.state.membership=e.member),i.members[e.member.user_id]=e.member}break;case"member.promoted":case"member.demoted":case"member.banned":case"member.unbanned":case"member.blocked":case"member.unblocked":if(e.member?.user_id){let c=q(e.member.user_id,n);e.member.user=c,i.members[e.member.user_id]=e.member,e.member.user_id===this.getClient().user?.id&&(i.membership=e.member,this.state.membership=e.member)}break;case"channel.pinned":t.data&&(t.data.is_pinned=!0);break;case"channel.unpinned":t.data&&(t.data.is_pinned=!1);break;case"channel.topic.created":let a=e.channel?.members||[],r=$(a,n),o={channel:e.channel,members:r,messages:[],pinned_messages:[]},l=this.getClient().channel(e.channel_type||"",e.channel_id||"");l.data=e.channel,l._initializeState(o,"latest"),i.topics||(i.topics=[]),i.topics.some(c=>c.cid===l.cid)||i.topics.push(l);break;case"channel.topic.closed":t.data&&(t.data.is_closed_topic=!0),e.user=q(e.user?.id||"",n);break;case"channel.topic.reopen":t.data&&(t.data.is_closed_topic=!1),e.user=q(e.user?.id||"",n);break;case"channel.topic.updated":t.data&&(t.data.name=e.channel?.name,t.data.image=e.channel?.image,t.data.description=e.channel?.description),e.user=q(e.user?.id||"",n);break;default:}e.watcher_count!==void 0&&(t.state.watcher_count=e.watcher_count)}_callChannelListeners=e=>{let t=this,i=[];t.listeners.all&&i.push(...t.listeners.all),t.listeners[e.type]&&i.push(...t.listeners[e.type]);for(let n of i)typeof n!="string"&&n(e)};_channelURL=()=>{if(!this.id)throw new Error("channel id is not defined");return`${this.getClient().baseURL}/channels/${this.type}/${this.id}`};_checkInitialized(){if(!this.initialized&&!this.offlineMode)throw Error(`Channel ${this.cid} hasn't been initialized yet. Make sure to call .watch() and wait for it to resolve`)}_initializeState(e,t="latest",i){let{state:n,user:a,userID:r}=this.getClient();if(e.channel.members)for(let d of e.channel.members)d.user&&(i&&i(d.user.id),n.updateUserReference(d.user,this.cid));this.state.membership=e.membership||{};let o=new Map,l=[];e.messages||(e.messages=[]);for(let d of e.messages)o.has(d.id)||(o.set(d.id,!0),l.push(d));this.state.pinnedMessages&&(this.state.pinnedMessages=[]),this.state.addPinnedMessages(e.pinned_messages||[]);let c=l||[];this.state.messages||this.state.initMessages();let{messageSet:p}=this.state.addMessagesSorted(c,!1,!0,!0,t);if(e.watcher_count!==void 0&&(this.state.watcher_count=e.watcher_count),e.watchers)for(let d of e.watchers)d&&(n.updateUserReference(d,this.cid),this.state.watchers[d.id]=d);if(r!=null){let d=this.state.last_message_at||new Date;a&&(this.state.read[a.id]={user:a,last_read:d,unread_messages:0})}if(e.read)for(let d of e.read)this.state.read[d.user.id]={last_read:new Date(d.last_read),last_read_message_id:d.last_read_message_id,unread_messages:d.unread_messages??0,user:d.user,last_send:d.last_send},d.user.id===a?.id&&(this.state.unreadCount=this.state.read[d.user.id].unread_messages);if(e.channel.members&&(this.state.members=e.channel.members.reduce((d,u)=>(u.user&&(d[u.user.id]=u),d),{})),e.channel.type==="team"&&e.channel.topics_enabled&&e.topics){let d=Object.values(this.getClient().state.users);this._processTopics(e.topics,d)}return{messageSet:p}}_extendEventWithOwnReactions(e){if(!e.message)return;let t=this.state.findMessage(e.message.id,e.message.parent_id);t&&(e.message.own_reactions=t.own_reactions)}_disconnect(){this._client.logger("info",`channel:disconnect() - Disconnecting the channel ${this.cid}`,{tags:["connection","channel"],channel:this}),this.disconnected=!0,this.state.setIsUpToDate(!1)}};var Qt=class{users;userChannelReferences;constructor(){this.users={},this.userChannelReferences={}}updateUsers(e){for(let t of e)this.updateUser(t)}updateUser(e){if(e!=null)if(this.users[e.id]){let t={...this.users[e.id],...e};this.users[e.id]=t}else this.users[e.id]=e}updateUserReference(e,t){e!=null&&(this.userChannelReferences[e.id]||(this.userChannelReferences[e.id]={}),this.userChannelReferences[e.id][t]=!0)}deleteAllChannelReference(e){for(let t in this.userChannelReferences)delete this.userChannelReferences[t][e]}};var fp=xe(hp());var $f=s=>s.code!==void 0,zf=s=>s.error!==void 0,Ls=class{client;connectionOpen;consecutiveFailures;pingInterval;healthCheckTimeoutRef;isConnecting;isDisconnected;isHealthy;isResolved;lastEvent;connectionCheckTimeout;connectionCheckTimeoutRef;rejectPromise;requestID;resolvePromise;totalFailures;ws;wsID;constructor({client:e}){this.client=e,this.consecutiveFailures=0,this.totalFailures=0,this.isConnecting=!1,this.isDisconnected=!1,this.isResolved=!1,this.isHealthy=!1,this.wsID=1,this.lastEvent=null,this.pingInterval=25*1e3,this.connectionCheckTimeout=this.pingInterval+10*1e3,dl(this.onlineStatusChanged)}_log(e,t={},i="info"){this.client.logger(i,"connection:"+e,{tags:["connection"],...t})}setClient(e){this.client=e}async connect(e=15e3){if(this.isConnecting)throw Error("You've called connect twice, can only attempt 1 connection at the time");this.isDisconnected=!1;try{let t=await this._connect();this.consecutiveFailures=0,this._log(`connect() - Established ws connection with healthcheck: ${t}`)}catch(t){if(this.isHealthy=!1,this.consecutiveFailures+=1,t.code===st.TOKEN_EXPIRED)this._log("connect() - WS failure due to expired token");else if(!t.isWSFailure)throw new Error(JSON.stringify({code:t.code,StatusCode:t.StatusCode,message:t.message,isWSFailure:t.isWSFailure}))}return await this._waitForHealthy(e)}async _waitForHealthy(e=15e3){return Promise.race([(async()=>{for(let i=0;i<=e;i+=50)try{return await this.connectionOpen}catch(n){if(i===e)throw new Error(JSON.stringify({code:n.code,StatusCode:n.StatusCode,message:n.message,isWSFailure:n.isWSFailure}));await Kt(50)}})(),(async()=>{throw await Kt(e),this.isConnecting=!1,new Error(JSON.stringify({code:"",StatusCode:"",message:"initial WS connection could not be established",isWSFailure:!0}))})()])}_buildUrl=()=>{let e=encodeURIComponent(this.client._buildWSPayload(this.requestID)),t=this.client.tokenManager.getToken(),i=`${this.client.wsBaseURL}/connect?json=${e}&api_key=${this.client.apiKey}&authorization=${t}&stream-auth-type=${this.client.getAuthType()}&X-Stream-Client=${this.client.getUserAgent()}`;return i=encodeURI(i),i};disconnect(e){this._log(`disconnect() - Closing the websocket connection for wsID ${this.wsID}`),this.wsID+=1,this.isConnecting=!1,this.isDisconnected=!0,this.healthCheckTimeoutRef&&clearInterval(this.healthCheckTimeoutRef),this.connectionCheckTimeoutRef&&clearInterval(this.connectionCheckTimeoutRef),ml(this.onlineStatusChanged),this.isHealthy=!1,this.ws&&this.ws.removeAllListeners&&this.ws.removeAllListeners();let t,{ws:i}=this;return i&&i.close&&i.readyState===i.OPEN?(t=new Promise(n=>{let a=r=>{this._log(`disconnect() - resolving isClosedPromise ${r?"with":"without"} close frame`,{event:r}),n()};i.onclose=a,setTimeout(a,e??1e3)}),this._log("disconnect() - Manually closed connection by calling client.disconnect()"),i.close(st.WS_CLOSED_SUCCESS,"Manually closed connection by calling client.disconnect()")):(this._log("disconnect() - ws connection doesn't exist or it is already closed."),t=Promise.resolve()),delete this.ws,t}async _connect(){if(this.isConnecting)return;this.isConnecting=!0,this.requestID=Ee();let e=!1;try{this._log("_connect() - waiting for token"),await this.client.tokenManager.tokenReady(),e=!0}catch{}try{this._setupConnectionPromise();let t=this._buildUrl();this._log(`_connect() - Connecting to ${t}`,{wsURL:t,requestID:this.requestID}),this.ws=new fp.default(t),this.ws.onopen=this.onopen.bind(this,this.wsID),this.ws.onclose=this.onclose.bind(this,this.wsID),this.ws.onerror=this.onerror.bind(this,this.wsID),this.ws.onmessage=this.onmessage.bind(this,this.wsID);let i=await this.connectionOpen;if(this.isConnecting=!1,i)return i}catch(t){throw this.isConnecting=!1,this._log("_connect() - Error - ",t),t}}async _reconnect(e={}){if(this._log("_reconnect() - Initiating the reconnect"),this.isConnecting||this.isHealthy){this._log("_reconnect() - Abort (1) since already connecting or healthy");return}let t=e.interval;if(t||(t=xi(this.consecutiveFailures)),await Kt(t),this.isConnecting||this.isHealthy){this._log("_reconnect() - Abort (2) since already connecting or healthy");return}if(this.isDisconnected){this._log("_reconnect() - Abort (3) since disconnect() is called");return}this._log("_reconnect() - Destroying current WS connection"),this._destroyCurrentWSConnection();try{await this._connect(),this._log("_reconnect() - Waiting for recoverCallBack"),await this.client.recoverState(),this._log("_reconnect() - Finished recoverCallBack"),this.consecutiveFailures=0}catch(i){this.isHealthy=!1,this.consecutiveFailures+=1,i.isWSFailure&&(this._log("_reconnect() - WS failure, so going to try to reconnect"),this._reconnect())}this._log("_reconnect() - == END ==")}onlineStatusChanged=e=>{e.type==="offline"?(this._log("onlineStatusChanged() - Status changing to offline"),this._setHealth(!1)):e.type==="online"&&(this._log(`onlineStatusChanged() - Status changing to online. isHealthy: ${this.isHealthy}`),this.isHealthy||this._reconnect({interval:10}))};onopen=e=>{this.wsID===e&&this._log("onopen() - onopen callback",{wsID:e})};onmessage=(e,t)=>{if(this.wsID!==e)return;this._log("onmessage() - onmessage callback",{event:t,wsID:e});let i=typeof t.data=="string"?JSON.parse(t.data):null;if(!this.isResolved&&i){if(this.isResolved=!0,i.error){this.rejectPromise?.(this._errorFromWSEvent(i,!1));return}this.resolvePromise?.(i),this._setHealth(!0)}this.lastEvent=new Date,i&&i.type==="health.check"&&this.scheduleNextPing(),this.client.handleEvent(t),this.scheduleConnectionCheck()};onclose=(e,t)=>{if(this.wsID===e)if(this._log("onclose() - onclose callback - "+t.code,{event:t,wsID:e}),t.code===st.WS_CLOSED_SUCCESS){let i=new Error(`WS connection reject with error ${t.reason}`);i.reason=t.reason,i.code=t.code,i.wasClean=t.wasClean,i.target=t.target,this.rejectPromise?.(i),this._log(`onclose() - WS connection reject with error ${t.reason}`,{event:t})}else this.consecutiveFailures+=1,this.totalFailures+=1,this._setHealth(!1),this.isConnecting=!1,this.rejectPromise?.(this._errorFromWSEvent(t)),this._log("onclose() - WS connection closed. Calling reconnect ...",{event:t}),this._reconnect()};onerror=(e,t)=>{this.wsID===e&&(this.consecutiveFailures+=1,this.totalFailures+=1,this._setHealth(!1),this.isConnecting=!1,this.rejectPromise?.(this._errorFromWSEvent(t)),this._log("onerror() - WS connection resulted into error",{event:t}),this._reconnect())};_setHealth=e=>{if(e!==this.isHealthy){if(this.isHealthy=e,this.isHealthy){this.client.dispatchEvent({type:"connection.changed",online:this.isHealthy});return}setTimeout(()=>{this.isHealthy||this.client.dispatchEvent({type:"connection.changed",online:this.isHealthy})},1e3)}};_errorFromWSEvent=(e,t=!0)=>{let i,n,a;$f(e)&&(i=e.code,n="unknown",a=e.reason),zf(e)&&(i=e.error.code,n=e.error.StatusCode,a=e.error.message),this._log(`_errorFromWSEvent() - WS failed with code ${i}`,{event:e},"warn");let r=new Error(`WS failed with code ${i} and reason - ${a}`);return r.code=i,r.StatusCode=n,r.isWSFailure=t,r};_destroyCurrentWSConnection(){this.wsID+=1;try{this?.ws?.removeAllListeners(),this?.ws?.close()}catch{}}_setupConnectionPromise=()=>{this.isResolved=!1,this.connectionOpen=new Promise((e,t)=>{this.resolvePromise=e,this.rejectPromise=t})};scheduleNextPing=()=>{this.healthCheckTimeoutRef&&clearTimeout(this.healthCheckTimeoutRef),this.healthCheckTimeoutRef=setTimeout(()=>{let e=[{type:"health.check",client_id:this.client.clientID}];try{this.ws?.send(JSON.stringify(e))}catch{}},this.pingInterval)};scheduleConnectionCheck=()=>{this.connectionCheckTimeoutRef&&clearTimeout(this.connectionCheckTimeoutRef),this.connectionCheckTimeoutRef=setTimeout(()=>{let e=new Date;this.lastEvent&&e.getTime()-this.lastEvent.getTime()>this.connectionCheckTimeout&&(this._log("scheduleConnectionCheck - going to reconnect"),this._setHealth(!1),this._reconnect())},this.connectionCheckTimeout)}};var Ps=class{loadTokenPromise;token;user;constructor(){this.loadTokenPromise=null}setTokenOrProvider=async(e,t)=>{this.user=t,typeof e=="string"&&(this.token=e),this.loadTokenPromise=Promise.resolve(this.token)};reset=()=>{this.token=void 0,this.user=void 0,this.loadTokenPromise=null};tokenReady=()=>this.loadTokenPromise;getToken=()=>this.token};function Ri(s){return!s.status||s.status<200||300<=s.status}var ki=xe(gp());var Rt=class extends Error{code;response;status},_a=(c=>(c.CREATE_CALL="create-call",c.ACCEPT_CALL="accept-call",c.SIGNAL_CALL="signal-call",c.CONNECT_CALL="connect-call",c.HEALTH_CALL="health-call",c.END_CALL="end-call",c.REJECT_CALL="reject-call",c.MISS_CALL="miss-call",c.UPGRADE_CALL="upgrade-call",c))(_a||{}),Ca=(a=>(a.PREPARING="preparing",a.RINGING="ringing",a.ENDED="ended",a.CONNECTED="connected",a.ERROR="error",a))(Ca||{}),wa=(u=>(u[u.VIDEO_CONFIG=0]="VIDEO_CONFIG",u[u.AUDIO_CONFIG=1]="AUDIO_CONFIG",u[u.VIDEO_KEY=2]="VIDEO_KEY",u[u.VIDEO_DELTA=3]="VIDEO_DELTA",u[u.AUDIO=4]="AUDIO",u[u.ORIENTATION=5]="ORIENTATION",u[u.CONNECTED=6]="CONNECTED",u[u.TRANSCEIVER_STATE=7]="TRANSCEIVER_STATE",u[u.REQUEST_CONFIG=8]="REQUEST_CONFIG",u[u.REQUEST_KEY_FRAME=9]="REQUEST_KEY_FRAME",u[u.END_CALL=10]="END_CALL",u[u.HEALTH_CALL=11]="HEALTH_CALL",u))(wa||{});function Wf(s){return typeof s=="string"||s instanceof String}var Ea=class s{static _instance;activeChannels;axiosInstance;baseURL;userBaseURL;browser;cleaningIntervalRef;clientID;apiKey;projectId;listeners;logger;recoverStateOnReconnect;node;options;setUserPromise;state;tokenManager;user;userAgent;userID;wsBaseURL;wsConnection;wsPromise;consecutiveFailures;defaultWSTimeout;eventSource=null;constructor(e,t,i,n){this.apiKey=e,this.projectId=t,this.listeners={},this.state=new Qt;let a=n||{};this.browser=typeof a.browser<"u"?a.browser:typeof window<"u",this.node=!this.browser,this.options={withCredentials:!1,warmUp:!1,recoverStateOnReconnect:!0,...a},this.node&&!this.options.httpsAgent&&(this.options.httpsAgent=new ut.Agent({keepAlive:!0,keepAliveMsecs:3e3})),this.axiosInstance=Ht.create(this.options),this.setBaseURL(i),this.wsConnection=null,this.wsPromise=null,this.setUserPromise=null,this.activeChannels={},this.tokenManager=new Ps,this.consecutiveFailures=0,this.defaultWSTimeout=15e3,this.axiosInstance.defaults.paramsSerializer=hl,this.logger=gi(a.logger)?a.logger:()=>null,this.recoverStateOnReconnect=this.options.recoverStateOnReconnect}static getInstance(e,t,i,n){return s._instance||(s._instance=new s(e,t,i,n)),s._instance}async refreshNewToken(e){return await this.post(this.userBaseURL+"/refresh_token",{refresh_token:e})}getAuthType(){return"jwt"}setBaseURL(e){this.baseURL=e,this.userBaseURL=this.options.userBaseURL||e+"/uss/v1",this.wsBaseURL=this.baseURL.replace("http","ws").replace(":3030",":8800")}async getExternalAuthToken(e,t){let i={apikey:this.apiKey,name:e.name};e.avatar&&(i.avatar=e.avatar);let n=this.userBaseURL+"/get_token/external_auth",a={"Content-Type":"application/json"};if(t){let r=typeof t=="string"&&t.startsWith("Bearer ")?t:`Bearer ${t}`;a.Authorization=r}try{return(await this.axiosInstance.get(n,{params:i,headers:a})).data}catch(r){let o="Failed to fetch external auth token";throw r.response&&r.response.data?o=r.response.data.message||JSON.stringify(r.response.data):r.message&&(o=r.message),new Error(o)}}connectUser=async(e,t,i)=>{if(this.logger("info","client:connectUser() - started",{tags:["connection","client"]}),!e.id)throw new Error('The "id" field on the user is missing');let n=e,a=t;if(i){let l=await this.getExternalAuthToken(e,t);a=l.token,n={...e,id:l.user_id}}if(this.userID===n.id&&this.setUserPromise)return console.warn("Consecutive calls to connectUser is detected, ideally you should only call this function once in your app."),this.setUserPromise;if(this.userID)throw new Error("Use client.disconnect() before trying to connect as a different user. connectUser was called twice.");this.node&&!this.options.allowServerSideConnect&&console.warn('Please do not use connectUser server side. connectUser impacts MAU and concurrent connection usage and thus your bill. If you have a valid use-case, add "allowServerSideConnect: true" to the client options to disable this warning.'),this.userID=n.id;let r=this._setToken(n,a);this._setUser(n),this.state.updateUser({id:n.id,name:n?.name||n.id,avatar:n?.avatar||""});let o=this.openConnection();this.setUserPromise=Promise.all([r,o]).then(l=>l[1]);try{let l=await this.setUserPromise;return await this.connectToSSE(),this.queryUser(n.id).then(c=>{this.user={...this.user,...c},this.state.updateUser(this.user),this.dispatchEvent({type:"user.updated",me:this.user})}).catch(c=>{this.logger("error","client:connectUser() - failed to fetch full user profile",{err:c})}),l}catch(l){throw this.disconnectUser(),l}};setUser=this.connectUser;_setToken=(e,t)=>this.tokenManager.setTokenOrProvider(t,e);_setUser(e){this.user={...e},this.userID=e.id}closeConnection=async e=>(this.cleaningIntervalRef!=null&&(clearInterval(this.cleaningIntervalRef),this.cleaningIntervalRef=void 0),await this.wsConnection?.disconnect(e),Promise.resolve());openConnection=async()=>{if(!this.userID)throw Error("User is not set on client, use client.connectUser instead");return this.wsConnection?.isConnecting&&this.wsPromise?(this.logger("info","client:openConnection() - connection already in progress",{tags:["connection","client"]}),this.wsPromise):this.wsConnection?.isHealthy?(this.logger("info","client:openConnection() - openConnection called twice, healthy connection already exists",{tags:["connection","client"]}),Promise.resolve()):(this.clientID=`${this.userID}--${Ee()}`,this.wsPromise=this.connect(),this._startCleaning(),this.wsPromise)};_setupConnection=this.openConnection;disconnectUser=async e=>{this.logger("info","client:disconnect() - Disconnecting the client",{tags:["connection","client"]}),delete this.user,delete this.userID;let t=this.closeConnection(e);for(let i of Object.values(this.activeChannels))i._disconnect();return this.activeChannels={},this.state=new Qt,setTimeout(this.tokenManager.reset),t};disconnect=this.disconnectUser;on(e,t){let i=t?e:"all",n=t||e;return i in this.listeners||(this.listeners[i]=[]),this.logger("info",`Attaching listener for ${i} event`,{tags:["event","client"]}),this.listeners[i].push(n),{unsubscribe:()=>{this.logger("info",`Removing listener for ${i} event`,{tags:["event","client"]}),this.listeners[i]=this.listeners[i].filter(a=>a!==n)}}}off(e,t){let i=t?e:"all",n=t||e;i in this.listeners||(this.listeners[i]=[]),this.logger("info",`Removing listener for ${i} event`,{tags:["event","client"]}),this.listeners[i]=this.listeners[i].filter(a=>a!==n)}_logApiRequest(e,t,i,n){this.logger("info",`client: ${e} - Request - ${t}- ${JSON.stringify(i)} - ${JSON.stringify(n.params)}`,{tags:["api","api_request","client"],url:t,payload:i,config:n})}_logApiResponse(e,t,i){this.logger("info",`client:${e} - Response - url: ${t} > status ${i.status}`,{tags:["api","api_response","client"],url:t,response:i})}_logApiError(e,t,i,n){this.logger("error",`client:${e} - Error: ${JSON.stringify(i)} - url: ${t} - options: ${JSON.stringify(n)}`,{tags:["api","api_response","client"],url:t,error:i})}doAxiosRequest=async(e,t,i,n={})=>{await this.tokenManager.tokenReady();let a=this._enrichAxiosOptions(n);try{let r;switch(this._logApiRequest(e,t,i,a),e){case"get":r=await this.axiosInstance.get(t,a);break;case"delete":r=await this.axiosInstance.delete(t,a);break;case"post":r=await this.axiosInstance.post(t,i,a);break;case"postForm":r=await this.axiosInstance.postForm(t,i,a);break;case"put":r=await this.axiosInstance.put(t,i,a);break;case"patch":r=await this.axiosInstance.patch(t,i,a);break;case"options":r=await this.axiosInstance.options(t,a);break;default:throw new Error("Invalid request type")}return this._logApiResponse(e,t,r),this.consecutiveFailures=0,this.handleResponse(r)}catch(r){if(r.client_request_id=a.headers?.["x-client-request-id"],this._logApiError(e,t,r,n),this.consecutiveFailures+=1,r.response)return this.handleResponse(r.response);throw r}};get(e,t){return this.doAxiosRequest("get",e,null,{params:t})}put(e,t){return this.doAxiosRequest("put",e,t)}post(e,t,i){return this.doAxiosRequest("post",e,t,{params:i})}patch(e,t){return this.doAxiosRequest("patch",e,t)}delete(e,t){return this.doAxiosRequest("delete",e,null,{params:t})}sendFile(e,t,i,n,a){let r=ul(t,i,n||"multipart/form-data");return a!=null&&r.append("user",JSON.stringify(a)),this.doAxiosRequest("postForm",e,r,{headers:r.getHeaders?r.getHeaders():{},config:{timeout:0,maxContentLength:1/0,maxBodyLength:1/0}})}async downloadMedia(e){let t=await fetch(e,{cache:"no-store"});if(!t.ok)throw new Error(`Failed to download media: ${t.statusText}`);return await t.blob()}errorFromResponse(e){let t;return t=new Rt(`ErmisChat error HTTP code: ${e.status}`),e.data&&e.data.code&&(t=new Error(`ErmisChat error code ${e.data.code}: ${e.data.message}`),t.code=e.data.code),t.response=e,t.status=e.status,t}handleResponse(e){let t=e.data;if(Ri(e))throw this.errorFromResponse(e);return t}dispatchEvent=e=>{if(e.received_at||(e.received_at=new Date),e.type==="channel.created"||e.type==="channel.topic.created")this._handleChannelCreatedEvent(e).then(()=>{this._afterDispatchEvent(e)});else{let t=this._handleClientEvent(e),i=e.cid,n=i?this.activeChannels[i]:void 0;n&&n._handleChannelEvent(e),this._callClientListeners(e),n&&n._callChannelListeners(e),t.forEach(a=>a())}};_afterDispatchEvent(e){let t=this._handleClientEvent(e),i=e.cid,n=i?this.activeChannels[i]:void 0;n&&n._handleChannelEvent(e),this._callClientListeners(e),n&&n._callChannelListeners(e),t.forEach(a=>a())}async _handleChannelCreatedEvent(e){let t=e.channel?.members||[];await ws(this,t);let i=Object.values(this.state.users),n=$(t,i),a=e.channel_type==="messaging"?_t(n,this.userID||""):e.channel?.name,r={...e.channel,members:n,name:a},o={channel:r,members:n,messages:[],pinned_messages:[]},l=this.channel(e.channel_type||"",e.channel_id||"");l.data=r,l._initializeState(o,"latest")}handleEvent=e=>{let t=e.data,i=JSON.parse(t);this.dispatchEvent(i)};_updateMemberWatcherReferences=e=>{Object.values(this.activeChannels).forEach(t=>{if(t?.state){let i=!1;if(t.state.members[e.id]&&(t.state.members={...t.state.members,[e.id]:{...t.state.members[e.id],user:e}},i=!0,t.data?.type==="messaging")){let n=Object.values(t.state.members);if(n.length===2){let a=n.find(r=>r.user?.id!==this.userID);a&&a.user?.id===e.id&&(t.data.name=e.name||e.id,t.data.image=e.avatar||"")}}t.state.watchers[e.id]&&(t.state.watchers={...t.state.watchers,[e.id]:e},i=!0),t.state.read[e.id]&&(t.state.read={...t.state.read,[e.id]:{...t.state.read[e.id],user:e}},i=!0),i&&(t._callChannelListeners({type:"channel.updated",channel:t.data,cid:t.cid}),t.state.members[e.id]&&t._callChannelListeners({type:"member.updated",member:t.state.members[e.id],cid:t.cid}),t._callChannelListeners({type:"user.updated",user:e,cid:t.cid}))}})};_updateUserReferences=this._updateMemberWatcherReferences;_updateUserMessageReferences=e=>{let t=this.state.userChannelReferences[e.id]||{};for(let i in t){let n=this.activeChannels[i];if(!n)continue;let a=n.state;a?.updateUserMessages(e),n._callChannelListeners({type:"channel.updated",channel:n.data,cid:n.cid});let r=a?.messages[a.messages.length-1];r&&n._callChannelListeners({type:"message.updated",message:r,cid:n.cid})}};_deleteUserMessageReference=(e,t=!1)=>{let i=this.state.userChannelReferences[e.id]||{};for(let n in i)this.activeChannels[n].state?.deleteUserMessages(e,t)};_handleClientEvent(e){let t=this,i=[];if(this.logger("info",`client:_handleClientEvent - Received event of type { ${e.type} }`,{tags:["event","client"],event:e}),e.type==="health.check"&&e.me,(e.type==="channel.deleted"||e.type==="notification.channel_deleted")&&e.cid){t.state.deleteAllChannelReference(e.cid),this.activeChannels[e.cid]?._disconnect(),i.push(()=>{e.cid&&delete this.activeChannels[e.cid]});for(let n of Object.values(this.activeChannels))n.type==="team"&&n.state.topics?.some(a=>a.cid===e.cid)&&(n.state.topics=n.state.topics.filter(a=>a.cid!==e.cid))}return e.type==="notification.invite_rejected"&&e.member?.user_id===this.userID&&e.cid&&(t.state.deleteAllChannelReference(e.cid),this.activeChannels[e.cid]?._disconnect(),i.push(()=>{e.cid&&delete this.activeChannels[e.cid]})),e.type,e.type==="member.added"&&e.member?.user_id===this.userID&&this.channel(e.channel_type||"",e.channel_id||"").watch().catch(a=>{this.logger("error","Failed to watch channel after member.added",{err:a,event:e})}),e.type==="message.new"&&e.channel_type==="topic"&&i.push(()=>{let n=e.parent_cid||e.channel?.parent_cid;if(n&&this.activeChannels[n]){let a=this.activeChannels[n];a.state.topics&&(a.state.topics.sort((r,o)=>{let l=r.state?.latestMessages?.[r.state.latestMessages.length-1]?.created_at,c=o.state?.latestMessages?.[o.state.latestMessages.length-1]?.created_at,p=l?new Date(l).getTime():0;return(c?new Date(c).getTime():0)-p}),a._callChannelListeners({...e,type:"channel.updated",channel:a.data}))}}),e.type==="channel.topic.updated"&&i.push(()=>{let n=e.parent_cid||e.channel?.parent_cid;if(n&&this.activeChannels[n]){let a=this.activeChannels[n];if(a.state?.topics&&e.channel){let r=a.state.topics.findIndex(o=>o.cid===e.cid||o.channel?.cid===e.cid);if(r!==-1){let o=a.state.topics[r];o.data?o.data={...o.data,...e.channel}:o.channel?o.channel={...o.channel,...e.channel}:Object.assign(o,e.channel)}a._callChannelListeners({...e,type:"channel.updated",channel:a.data})}}if(e.cid&&this.activeChannels[e.cid]){let a=this.activeChannels[e.cid];e.channel&&(a.data={...a.data,...e.channel},a._callChannelListeners({...e,type:"channel.updated",channel:a.data}))}}),(e.type==="channel.topic.closed"||e.type==="channel.topic.reopen")&&i.push(()=>{let n=e.type==="channel.topic.closed",a=e.parent_cid;if(a&&this.activeChannels[a]){let r=this.activeChannels[a];if(r.state?.topics){let o=r.state.topics.findIndex(l=>l.cid===e.cid||l.channel?.cid===e.cid);if(o!==-1){let l=r.state.topics[o];l.data?l.data.is_closed_topic=n:l.channel?l.channel.is_closed_topic=n:l.is_closed_topic=n}r._callChannelListeners({...e,type:"channel.updated",channel:r.data})}}if(e.cid&&this.activeChannels[e.cid]){let r=this.activeChannels[e.cid];r.data&&(r.data.is_closed_topic=n),r._callChannelListeners({...e,type:"channel.updated",channel:r.data})}}),e.type==="connection.recovered"&&i.push(()=>{Object.values(this.activeChannels).forEach(n=>{if(!n.state?.messages)return;n.state.messages.filter(r=>r.status==="failed_offline"&&r.user?.id===this.userID&&(!r.attachments||r.attachments.length===0)).forEach(r=>{r.id&&n.retryMessage(r.id).catch(o=>{this.logger("error",`Failed to auto-resend offline message ${r.id}`,{tags:["offline","retry"],err:o})})})})}),i}_callClientListeners=e=>{let t=this,i=[];t.listeners.all&&i.push(...t.listeners.all),t.listeners[e.type]&&i.push(...t.listeners[e.type]);for(let n of i)n(e)};recoverState=async()=>{this.logger("info","client:recoverState() - Start of recoverState",{tags:["connection"]});let e=Object.keys(this.activeChannels);if(e.length&&this.recoverStateOnReconnect){this.logger("info",`client:recoverState() - Start the querying of ${e.length} channels`,{tags:["connection","client"]});let{filter:t={type:["messaging","team","meeting"]},sort:i=[],options:n={message_limit:1}}=this.options.recoveryConfig||{};await this.queryChannels(t,i,n),this.logger("info","client:recoverState() - Querying channels finished",{tags:["connection","client"]}),this.dispatchEvent({type:"connection.recovered"})}else this.dispatchEvent({type:"connection.recovered"});this.wsPromise=Promise.resolve(),this.setUserPromise=Promise.resolve()};async connect(){if(!this.userID||!this.user)throw Error("Call connectUser before starting the connection");if(!this.wsBaseURL)throw Error("Websocket base url not set");if(!this.clientID)throw Error("clientID is not set");this.options.wsConnection&&this.node?(this.options.wsConnection.setClient(this),this.wsConnection=this.options.wsConnection):this.wsConnection=new Ls({client:this});try{return await this.wsConnection.connect(this.defaultWSTimeout)}catch(e){throw e}}async connectToSSE(e){if(this.eventSource){this.logger("info","client:connectToSSE() - SSE connection already established",{});return}let t=this._getToken();t?.startsWith("Bearer ")||(t=`Bearer ${t}`);let i={method:"GET",Authorization:t};this.eventSource=new ki.EventSourcePolyfill(this.userBaseURL+"/sse/subscribe",{headers:i,heartbeatTimeout:6e4}),this.eventSource.onopen=()=>{this.logger("info","client:connectToSSE() - SSE connection established",{})},this.eventSource.onmessage=n=>{let a=JSON.parse(n.data);if(this.logger("info",`client:connectToSSE() - SSE message received event : ${JSON.stringify(a)}`,{event:n}),a.type==="AccountUserChainProjects"){let r={id:a.id,name:a.name,avatar:a.avatar,about_me:a.about_me,project_id:a.project_id};this.user?.id===r.id&&(this.user={...this.user,...r}),this.state.updateUser(r);let o={id:r.id,name:r.name||r.id,avatar:r.avatar||""};this._updateMemberWatcherReferences(o),this._updateUserMessageReferences(o),e&&e(a),this.dispatchEvent({type:"user.updated",user:r,me:this.user?.id===r.id?this.user:void 0})}},this.eventSource.onerror=n=>{this.logger("error",`client:connectToSSE() - SSE connection error : ${JSON.stringify(n.data)} `,{event:n}),n.status===401?(this.logger("error","client:connectToSSE() - Unauthorized (401). Aborting the connection.",{}),this.disconnectFromSSE()):(this.eventSource?.readyState===ki.EventSourcePolyfill.CLOSED||this.eventSource?.readyState===ki.EventSourcePolyfill.CONNECTING)&&(this.eventSource.close(),setTimeout(()=>{this.logger("info","client:connectToSSE() - Reconnecting to SSE",{}),this.connectToSSE(e)},3e3))}}async disconnectFromSSE(){this.eventSource?(this.eventSource.close(),this.eventSource=null,this.logger("info","client:disconnectFromSSE() - SSE connection closed",{})):this.logger("info","client:disconnectFromSSE() - SSE connection already closed",{})}async queryUsers(e,t){let i={presence:!1};await this.wsPromise;let n=this.projectId,a=await this.get(this.userBaseURL+"/users",{project_id:n,page:t,page_size:e});return this.state.updateUsers(a.data),a}async queryUser(e){let t=this.projectId,i=await this.get(this.userBaseURL+"/users/"+e,{project_id:t});return this.state.updateUser(i),i}async getBatchUsers(e,t,i){let n=this.projectId,a=await this.post(this.userBaseURL+"/users/batch?page=1&page_size=10000",{users:e,project_id:n},{page:t,page_size:i});return this.state.updateUsers(a.data),a.data||[]}async searchUsers(e,t,i){let n=this.projectId;return await this.post(this.userBaseURL+"/users/search",void 0,{page:e,page_size:t,name:i,project_id:n})}async queryContacts(){let e=this.projectId,i=(await this.post(this.baseURL+"/contacts/list",{project_id:e})).project_id_user_ids[e],n=[],a=[];return i.forEach(r=>{let o=r.other_id,l=this.state.users[o],c=l||{id:o};switch(r.relation_status){case"blocked":a.push(c);break;case"normal":n.push(c);break;default:}}),{contact_users:n,block_users:a}}_updateProjectID(e){this.projectId=e}async uploadAvatar(e){let t=new FormData;t.append("avatar",e);let i=await this.post(this.userBaseURL+"/users/upload",t,{headers:{"Content-Type":"multipart/form-data"}});if(this.user){this.user.avatar=i.avatar;let n={...this.user,avatar:i.avatar};this.state.updateUser(n);let a={id:this.user.id,name:this.user.name?this.user.name:this.user.id,avatar:this.user?.avatar||""};this._updateMemberWatcherReferences(a),this._updateUserMessageReferences(a),this.dispatchEvent({type:"user.updated",me:this.user})}return i}async updateProfile(e){let t=await this.patch(this.userBaseURL+"/users/update",e);if(this.user=t,this.state.updateUser(t),this.user){let i={id:this.user.id,name:this.user.name?this.user.name:this.user.id,avatar:this.user?.avatar||""};this._updateMemberWatcherReferences(i),this._updateUserMessageReferences(i),this.dispatchEvent({type:"user.updated",me:this.user})}return t}async queryChannels(e,t=[],i={},n={}){await this.wsPromise;let a=this.projectId,r={filter_conditions:{...e,project_id:a},sort:t,...i},o=await this.post(this.baseURL+"/channels",r);o.channels.sort((u,f)=>{let h=Ct(u.messages);if(u.channel.type==="team"&&Array.isArray(u.topics))for(let v of u.topics)h=Math.max(h,Ct(v.messages));let x=Ct(f.messages);if(f.channel.type==="team"&&Array.isArray(f.topics))for(let v of f.topics)x=Math.max(x,Ct(v.messages));return x-h});let l=Array.from(new Set(o.channels.flatMap(u=>(u.channel.members||[]).map(f=>f.user.id))))||[],c=e.parent_cid?Object.values(this.state.users):await this.getBatchUsers(l);o.channels.forEach(u=>{u.channel.members=$(u.channel.members,c),u.messages=$(u.messages,c),u.read=$(u.read||[],c),u.channel.name=u.channel.type==="messaging"?_t(u.channel.members,this.userID||""):u.channel.name,u.channel.image=u.channel.type==="messaging"?Cs(u.channel.members,this.userID||""):u.channel.image,u.channel.type==="team"&&Array.isArray(u.topics)&&u.topics.sort((f,h)=>{let x=Ct(f.messages);return Ct(h.messages)-x}),u.pinned_messages&&(u.pinned_messages=$(u.pinned_messages||[],c))});let{channels:p,userIds:d}=this.hydrateChannels(o.channels,n);return console.log("---channels---",p),this.dispatchEvent({type:"channels.queried"}),p}hydrateChannels(e=[],t={}){let{skipInitialization:i,offlineMode:n=!1}=t,a=[],r=[];for(let o of e){let l=this.channel(o.channel.type,o.channel.id);l.data={...o.channel,is_pinned:o.is_pinned||!1},l.offlineMode=n,l.initialized=!n,i===void 0?l._initializeState(o,"latest",c=>{r.includes(c)||r.push(c)}):i.includes(o.channel.id)||(l.state.clearMessages(),l._initializeState(o,"latest",c=>{r.includes(c)||r.push(c)})),a.push(l)}return{channels:a,userIds:r}}async searchPublicChannel(e,t=0,i=25){let n=this.projectId;return await this.post(this.baseURL+"/channels/public/search",{project_id:n,search_term:e,limit:i,offset:t})}async pinChannel(e,t){return await this.post(this.baseURL+`/channels/${e}/${t}/pin`)}async unpinChannel(e,t){return await this.post(this.baseURL+`/channels/${e}/${t}/unpin`)}channel(e,t,i){if(!this.userID)throw Error("Call connectUser before creating a channel");if(~e.indexOf(":"))throw Error(`Invalid channel group ${e}, can't contain the : character`);let n,a=i||{};return typeof t=="string"?n=t:typeof t=="object"&&t!==null&&(a=t),this.getChannelById(e,n,a)}getChannelById=(e,t,i)=>{let n=`${e}:${t||""}`;if(n in this.activeChannels&&!this.activeChannels[n].disconnected){let r=this.activeChannels[n];return Object.keys(i).length>0&&(r.data=i,r._data=i),r}let a=new Jt(this,e,t,i);return this.activeChannels[a.cid]=a,a};getChannel=(e,t)=>{let i=Ee(),n=`${this.projectId}:${i}`,a=`${e}:${n}`;if(a in this.activeChannels&&!this.activeChannels[a].disconnected){let o=this.activeChannels[a];return Object.keys(t).length>0&&(o.data=t,o._data=t),o}let r=new Jt(this,e,n,t);return this.activeChannels[r.cid]=r,r};async createQuickChannel(e){if(!this.userID)throw Error("Call connectUser before creating a channel");let t=new Date,i=new Intl.DateTimeFormat("en-US",{month:"short",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(t),n={name:e||`Quick Channel - ${i}`,members:[this.userID],public:!0},a=this.channel("meeting",n);return await a.create(),a}async joinQuickChannel(e){if(!this.userID)throw Error("Call connectUser before joining a channel");let t=this.channel("meeting",e);return await t.watch(),t.state.members&&t.state.members[this.userID]||(await t.acceptInvite("join"),await t.watch()),t}_normalizeExpiration(e){let t=null;if(typeof e=="number"){let i=new Date;i.setSeconds(i.getSeconds()+e),t=i.toISOString()}else Wf(e)?t=e:e instanceof Date&&(t=e.toISOString());return t}getUserAgent(){return this.userAgent||`ermis-chat-sdk-javascript-client-${this.node?"node":"browser"}-2.0.0`}setUserAgent(e){this.userAgent=e}_enrichAxiosOptions(e={params:{},headers:{},config:{}}){let t=this._getToken();t?.startsWith("Bearer ")||(t=`Bearer ${t}`);let i=t?{Authorization:t}:void 0;e.headers?.["x-client-request-id"]||(e.headers={...e.headers,"x-client-request-id":Ee()});let{params:n,headers:a,...r}=this.options.axiosRequestConfig||{};return{params:{...e.params,...n||{}},headers:{...i,"stream-auth-type":this.getAuthType(),"X-Stream-Client":this.getUserAgent(),...e.headers,...a||{}},...e.config,...r||{}}}_getToken(){return this.tokenManager?this.tokenManager.getToken():null}_startCleaning(){let e=this;this.cleaningIntervalRef==null&&(this.cleaningIntervalRef=setInterval(()=>{for(let t of Object.values(e.activeChannels))t.clean()},500))}_buildWSPayload=e=>JSON.stringify({user_id:this.userID,user_details:this.user,client_request_id:e})};var Vf={"channel.created":!0,"channel.deleted":!0,"channel.truncate":!0,"channel.updated":!0,"channel.pinned":!0,"channel.unpinned":!0,"health.check":!0,"member.added":!0,"member.removed":!0,"member.updated":!0,"member.joined":!0,"member.promoted":!0,"member.demoted":!0,"member.banned":!0,"member.unbanned":!0,"member.blocked":!0,"member.unblocked":!0,"message.deleted":!0,"message.deleted_for_me":!0,"message.new":!0,"message.read":!0,"message.updated":!0,"message.pinned":!0,"message.unpinned":!0,"notification.channel_deleted":!0,"notification.invite_accepted":!0,"notification.invite_rejected":!0,"notification.invite_messaging_skipped":!0,"pollchoice.new":!0,"reaction.deleted":!0,"reaction.new":!0,"typing.start":!0,"typing.stop":!0,"user.watching.start":!0,"user.watching.stop":!0,"connection.changed":!0,"connection.recovered":!0,"capabilities.changed":!0,"channel.topic.disabled":!0,"channel.topic.enabled":!0,"channel.topic.created":!0,"channel.topic.closed":!0,"channel.topic.reopen":!0,"channel.topic.updated":!0};var Ai=class s{worker;nextId=0;pendingCalls=new Map;recvResolveQueue=[];recvDataQueue=[];recvErrorQueue=[];static cachedBlobUrl=null;static cachedWasmBytes=null;constructor(e){if(!s.cachedBlobUrl){let t=e.toString(),i=new XMLHttpRequest;if(i.open("GET",t,!1),i.send(),i.status===200){let n=new Blob([i.responseText],{type:"application/javascript"});s.cachedBlobUrl=URL.createObjectURL(n)}}s.cachedBlobUrl?this.worker=new Worker(s.cachedBlobUrl,{type:"module"}):this.worker=new Worker(e,{type:"module"}),this.worker.onmessage=t=>this.handleMessage(t.data),this.worker.onerror=t=>{console.error("\u{1F534} WASM Worker error:",t.message),this.pendingCalls.forEach(({reject:i})=>i(new Error(`Worker error: ${t.message}`))),this.pendingCalls.clear()}}async init(e){if(!s.cachedWasmBytes){let i=new URL(e||"/ermis_call_node_wasm_bg.wasm",window.location.origin).href,n=await fetch(i);s.cachedWasmBytes=await n.arrayBuffer()}let t=s.cachedWasmBytes.slice(0);await this.call("init",{wasmBytes:t},[t])}async spawn(e){await this.call("spawn",{relayUrls:e})}async getLocalEndpointAddr(){return await this.call("getLocalEndpointAddr")}async connect(e){await this.call("connect",{address:e})}async acceptConnection(){await this.call("acceptConnection")}async sendFrame(e){await this.call("sendFrame",{data:e},[e.buffer])}async beginWithGop(e){await this.call("beginWithGop",{data:e},[e.buffer])}async sendAudioFrame(e){await this.call("sendAudioFrame",{data:e},[e.buffer])}async sendControlFrame(e){await this.call("sendControlFrame",{data:e})}async asyncRecv(){return this.recvDataQueue.length>0?this.recvDataQueue.shift():new Promise((e,t)=>{this.recvResolveQueue.push(e),this.recvErrorQueue.push(t)})}async startRecvLoop(){await this.call("startRecvLoop")}async stopRecvLoop(){await this.call("stopRecvLoop")}async closeEndpoint(){await this.call("closeEndpoint")}closeConnection(){let e=this.nextId++;this.worker.postMessage({id:e,type:"closeConnection"})}networkChange(){let e=this.nextId++;this.worker.postMessage({id:e,type:"networkChange"})}async getStats(){return await this.call("getStats")}async terminate(){try{await this.call("terminate")}catch{}this.worker.terminate(),this.recvResolveQueue=[],this.recvErrorQueue.forEach(e=>e(new Error("Worker terminated"))),this.recvErrorQueue=[],this.recvDataQueue=[]}handleMessage(e){if(e.type==="recv_data"){let n=e.data;if(this.recvResolveQueue.length>0){let a=this.recvResolveQueue.shift();this.recvErrorQueue.shift(),a(n)}else this.recvDataQueue.push(n);return}if(e.type==="recv_error"){let n=new Error(e.error);if(this.recvErrorQueue.length>0){let a=this.recvErrorQueue.shift();this.recvResolveQueue.shift(),a(n)}return}let{id:t}=e,i=this.pendingCalls.get(t);i&&(this.pendingCalls.delete(t),e.type==="error"?i.reject(new Error(e.error)):i.resolve(e.data))}call(e,t,i){let n=this.nextId++;return new Promise((a,r)=>{this.pendingCalls.set(n,{resolve:a,reject:r});let o={id:n,type:e,...t};i&&i.length>0?this.worker.postMessage(o,i):this.worker.postMessage(o)})}};var Ii=class{videoEncoder=null;audioEncoder=null;videoReader=null;audioReader=null;localStream=null;videoConfig=null;audioConfig=null;videoConfigSent=!1;audioConfigSent=!1;hasVideo=!1;hasAudio=!1;forceKeyFrame=!1;isSendingVideo=!1;isSendingAudio=!1;nodeCall;healthCallInterval=null;constructor(e){this.nodeCall=e}async connect(e){try{await this.nodeCall.connect(e),await this.sendConnected(),await this.sendConfigs(),this.startHealthCallInterval()}catch(t){console.error("Error starting MediaStreamSender:",t)}}async sendConfigs(){try{await this.sendTransceiverState(this.hasAudio,this.hasVideo),await this.sendAudioConfig(),this.localStream?.getVideoTracks()[0]&&await this.sendVideoConfig()}catch(e){console.error("Error sending configs:",e)}}stop=()=>{if(this.healthCallInterval&&(clearInterval(this.healthCallInterval),this.healthCallInterval=null),this.videoReader){try{this.videoReader.cancel("Stream stopped").catch(()=>{})}catch{}this.videoReader=null}if(this.videoEncoder){try{this.videoEncoder.state!=="closed"&&(this.videoEncoder.reset(),this.videoEncoder.close())}catch{}this.videoEncoder=null}if(this.audioEncoder){try{this.audioEncoder.state!=="closed"&&(this.audioEncoder.reset(),this.audioEncoder.close())}catch{}this.audioEncoder=null}if(this.audioReader){try{this.audioReader.cancel("Stream stopped").catch(()=>{})}catch{}this.audioReader=null}this.videoConfig=null,this.audioConfig=null,this.videoConfigSent=!1,this.audioConfigSent=!1,this.hasVideo=!1,this.hasAudio=!1,this.localStream&&(this.localStream.getTracks().forEach(e=>e.stop()),this.localStream=null)};initAudioEncoder=e=>{this.localStream=new MediaStream([e]),this.audioConfigSent=!1,this.hasAudio=!!e;let t=new AudioEncoder({output:(i,n)=>{if(n?.decoderConfig&&!this.audioConfigSent){let a;n.decoderConfig.description&&(a=Vn(n.decoderConfig.description)),this.audioConfig={codec:n.decoderConfig.codec??"opus",sampleRate:n.decoderConfig.sampleRate??48e3,numberOfChannels:n.decoderConfig.numberOfChannels??1,...a&&{description:a}},this.sendAudioConfig()}if(i&&this.isReadyToSendData("audio")){if(this.isSendingAudio)return;this.isSendingAudio=!0;let a=new ArrayBuffer(i.byteLength);i.copyTo(a);let r=i.timestamp,o=it(a,r,"audio",null);this.sendPacketOrQueue(o,"audio",null).finally(()=>{this.isSendingAudio=!1})}},error:i=>console.error("AudioEncoder error:",i)});t.configure({codec:"mp4a.40.2",sampleRate:48e3,numberOfChannels:1,bitrate:128e3}),this.audioEncoder=t,this.processAudioFrames(e)};initVideoEncoder(e){this.localStream&&this.localStream.addTrack(e),this.videoConfigSent=!1,this.hasVideo=!!e;let t=e.getSettings(),i=t.width||1280,n=t.height||720,a=new VideoEncoder({output:async(r,o)=>{if(o?.decoderConfig&&!this.videoConfigSent){let l;o.decoderConfig.description&&(l=Vn(o.decoderConfig.description)),this.videoConfig={codec:o.decoderConfig.codec??"hev1.1.6.L93.B0",codedWidth:o.decoderConfig.codedWidth??i,codedHeight:o.decoderConfig.codedHeight??n,frameRate:30,orientation:0,...l&&{description:l}},await this.sendVideoConfig()}if(r&&this.isReadyToSendData("video")){if(this.isSendingVideo)return;this.isSendingVideo=!0;let l=new ArrayBuffer(r.byteLength);r.copyTo(l);let c=r.type==="key"?"video-key":"video-delta",p=r.timestamp,d=it(l,p,c,null);this.sendPacketOrQueue(d,"video",c).finally(()=>{this.isSendingVideo=!1})}},error:r=>console.error("VideoEncoder error:",r)});a.configure({codec:"hev1.1.6.L93.B0",width:i,height:n,bitrate:5e5,framerate:30,latencyMode:"realtime",hardwareAcceleration:"prefer-hardware"}),this.videoEncoder=a,this.processVideoFrames(e)}initEncoders=e=>{let t=e.getVideoTracks()[0],i=e.getAudioTracks()[0];i&&this.initAudioEncoder(i),t&&this.initVideoEncoder(t)};sendTransceiverState=async(e,t)=>{let n=it(null,null,"transciverState",{audio_enable:!!e,video_enable:!!t});await this.nodeCall.sendControlFrame(n)};async replaceVideoTrack(e){if(this.videoReader){try{await this.videoReader.cancel("Replacing track")}catch{}this.videoReader=null}e&&this.processVideoFrames(e)}async replaceAudioTrack(e){if(this.audioReader){try{await this.audioReader.cancel("Replacing audio track")}catch{}this.audioReader=null}e&&this.processAudioFrames(e)}requestKeyFrame=()=>{console.log("\u{1F4E5} KeyFrame requested"),this.forceKeyFrame=!0};processVideoFrames=async e=>{try{let t=new MediaStreamTrackProcessor({track:e});this.videoReader=t.readable.getReader();let i=0;for(;this.videoReader;){let{done:n,value:a}=await this.videoReader.read();if(n)break;if(!this.videoEncoder){a?.close();break}if(a){i+=1;let r=i%60===0||this.forceKeyFrame;this.forceKeyFrame&&(console.log("\u{1F4E4} Sending forced KeyFrame"),this.forceKeyFrame=!1);try{this.videoEncoder.encode(a,{keyFrame:r})}catch(o){console.error("Encode error:",o)}finally{a.close()}}}}catch(t){console.error(`Error processing video frames: ${t.message}`)}finally{if(this.videoReader)try{this.videoReader.releaseLock()}catch{}}};processAudioFrames=async e=>{let t=new MediaStreamTrackProcessor({track:e});this.audioReader=t.readable.getReader();try{for(;this.audioReader;){let{done:i,value:n}=await this.audioReader.read();if(i)break;if(!this.audioEncoder){n?.close();break}if(n)try{this.audioEncoder.encode(n)}catch(a){console.error("Audio Encoding error:",a)}finally{n.close()}}}catch(i){console.error(`Error processing audio frames: ${i.message}`)}finally{if(this.audioReader)try{this.audioReader.releaseLock()}catch{}}};isReadyToSendData=e=>{let t=!this.hasVideo||this.videoConfigSent,i=!this.hasAudio||this.audioConfigSent,n=t&&i;return e==="video"?n&&this.videoConfigSent:e==="audio"?n&&this.audioConfigSent:!1};sendVideoConfig=async()=>{if(this.videoConfig&&!this.videoConfigSent)try{let e=it(null,null,"videoConfig",this.videoConfig);await this.nodeCall.sendControlFrame(e),this.videoConfigSent=!0}catch(e){console.error("Error sending video config:",e)}};sendAudioConfig=async()=>{if(this.audioConfig&&!this.audioConfigSent)try{let e=it(null,null,"audioConfig",this.audioConfig);await this.nodeCall.sendControlFrame(e),this.audioConfigSent=!0}catch(e){console.error("Error sending audio config:",e)}};sendConnected=async()=>{let e=it(null,null,"connected",null);await this.nodeCall.sendControlFrame(e)};startHealthCallInterval=()=>{this.healthCallInterval&&clearInterval(this.healthCallInterval),this.healthCallInterval=setInterval(()=>{this.sendHealthCall().catch(()=>{})},5e3)};sendHealthCall=async()=>{try{let e=it(null,null,"healthCall",null);await this.nodeCall.sendControlFrame(e)}catch{}};sendPacketOrQueue=async(e,t,i)=>{this.isReadyToSendData(t)&&(t==="audio"?await this.nodeCall.sendAudioFrame(e):t==="video"&&(i==="video-key"?await this.nodeCall.beginWithGop(e):i==="video-delta"&&await this.nodeCall.sendFrame(e)))}};var Yt={VPS_NUT:32,SPS_NUT:33,PPS_NUT:34,PREFIX_SEI_NUT:39,SUFFIX_SEI_NUT:40,fromValue(s){return{32:"VPS_NUT",33:"SPS_NUT",34:"PPS_NUT",39:"PREFIX_SEI_NUT",40:"SUFFIX_SEI_NUT"}[s]||s}},Di=class s{generalProfileSpace=0;generalTierFlag=!1;generalProfileIdc=0;generalProfileCompatibilityFlags=0;generalConstraintIndicatorFlags=0;generalLevelIdc=0;minSpatialSegmentationIdc=0;parallelismType=0;chromaFormatIdc=0;bitDepthLumaMinus8=0;bitDepthChromaMinus8=0;avgFrameRate=0;constantFrameRate=0;numTemporalLayers=0;temporalIdNested=!1;lengthSizeMinusOne=0;arrays=[];constructor(e){Object.assign(this,e)}static demux(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),i=new DataView(t.buffer,t.byteOffset,t.byteLength),n=0,a=0,r=G=>{let ie=0;for(let E=0;E<G;E++){if(n>=t.length)throw new Error("End of buffer");let R=t[n]>>7-a&1;ie=ie<<1|R,a++,a===8&&(a=0,n++)}return ie},o=()=>{if(a!==0)return r(8);if(n>=t.length)throw new Error("End of buffer");return t[n++]},l=()=>{if(a!==0)return r(16);let G=i.getUint16(n,!1);return n+=2,G},c=()=>{if(a!==0)return r(32);let G=i.getUint32(n,!1);return n+=4,G},p=()=>{let G=l(),ie=c();return G*4294967296+ie},d=G=>{if(a!==0){let E=new Uint8Array(G);for(let R=0;R<G;R++)E[R]=r(8);return E}if(n+G>t.length)throw new Error("End of buffer");let ie=t.slice(n,n+G);return n+=G,ie};if(o()!==1)throw new Error("Invalid configuration version");let f=r(2),h=r(1)===1,x=r(5),v=c(),b=p(),T=o();r(4);let I=r(12);r(6);let M=r(2);r(6);let O=r(2);r(5);let V=r(3);r(5);let Y=r(3),H=l(),de=r(2),Se=r(3),Tt=r(1)===1,De=r(2);if(De===2)throw new Error("length_size_minus_one must be 0, 1, or 3");let rt=o(),te=[];for(let G=0;G<rt;G++){let ie=r(1)===1;r(1);let E=r(6),R=Yt.fromValue(E);E!==Yt.VPS_NUT&&E!==Yt.SPS_NUT&&E!==Yt.PPS_NUT&&E!==Yt.PREFIX_SEI_NUT&&Yt.SUFFIX_SEI_NUT;let z=l(),ve=[];for(let K=0;K<z;K++){let Ue=l(),ot=d(Ue);ve.push(ot)}te.push({arrayCompleteness:ie,nalUnitType:R,nalus:ve})}return new s({generalProfileSpace:f,generalTierFlag:h,generalProfileIdc:x,generalProfileCompatibilityFlags:v,generalConstraintIndicatorFlags:b,generalLevelIdc:T,minSpatialSegmentationIdc:I,parallelismType:M,chromaFormatIdc:O,bitDepthLumaMinus8:V,bitDepthChromaMinus8:Y,avgFrameRate:H,constantFrameRate:de,numTemporalLayers:Se,temporalIdNested:Tt,lengthSizeMinusOne:De,arrays:te})}toCodecString(){let t={0:"",1:"A",2:"B",3:"C"}[this.generalProfileSpace];if(t===void 0)throw new Error("Unknown profile space");let i=`${t}${this.generalProfileIdc}`,n=this.generalProfileCompatibilityFlags.toString(16).padStart(8,"0").split("").reverse().join(""),a="";for(let d=0;d<n.length;d++){let u=n[d];(u!=="0"||d===0)&&(a+=u)}let o=`${this.generalTierFlag?"H":"L"}${this.generalLevelIdc}`,l="",c=this.generalConstraintIndicatorFlags,p=[Math.floor(c/1099511627776)&255,Math.floor(c/4294967296)&255,Math.floor(c/16777216)&255,Math.floor(c/65536)&255,Math.floor(c/256)&255,c&255];for(let d=2;d<6;d++)p[d]!==0&&(l+=`.${p[d].toString(16).padStart(2,"0")}`);return`hev1.${i}.${a}.${o}${l}`}};var Hf=.5,Sa=.05,Ui=class{videoDecoder=null;audioDecoder=null;videoWriter=null;audioContext=null;mediaDestination=null;scheduledAudioNodes=[];isWaitingForKeyFrame=!0;nextStartTime=0;lastVideoConfig=null;lastVideoConfigStr="";lastAudioConfigStr="";nodeCall;events;generatedStream=null;constructor(e,t={}){this.nodeCall=e,this.events=t}async acceptConnection(){try{await this.nodeCall.acceptConnection()}catch(e){console.error("\u274C Error starting MediaStreamReceiver:",e)}}getRemoteStream=()=>this.generatedStream;stop=()=>{this.resetDecoders()};initAudioContext=async()=>{if(!this.audioContext||this.audioContext.state==="closed"){let e=window.AudioContext||window.webkitAudioContext;this.audioContext=new e({sampleRate:48e3,latencyHint:"interactive"}),this.mediaDestination=this.audioContext.createMediaStreamDestination(),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.nextStartTime=this.audioContext.currentTime+Sa}};initDecoders=e=>{if(this.audioDecoder&&this.audioDecoder.close(),this.initAudioContext(),this.mediaDestination){let t=this.mediaDestination.stream.getAudioTracks()[0];this.generatedStream=new MediaStream([t])}this.isWaitingForKeyFrame=!0,this.audioDecoder=new AudioDecoder({output:t=>this.playDecodedAudio(t),error:t=>console.error("AudioDecoder error:",t)}),e==="video"&&this.setupVideoDecoder(),this.receiveLoop()};setupVideoDecoder=()=>{if(!this.videoWriter)return;if(this.videoDecoder)try{this.videoDecoder.state!=="closed"&&this.videoDecoder.close()}catch{}let e=new VideoDecoder({output:async t=>{try{if(!this.videoWriter){t.close();return}if(this.videoWriter.desiredSize<=0){t.close();return}await this.videoWriter.write(t)}catch{t.close()}finally{t.close()}},error:t=>{console.error("\u274C VideoDecoder CRASHED:",t),this.isWaitingForKeyFrame=!0,this.videoWriter&&(console.log("\u267B\uFE0F Scheduled VideoDecoder respawn in 1000ms..."),setTimeout(()=>{if(this.videoWriter&&(this.setupVideoDecoder(),this.lastVideoConfig&&this.videoDecoder))try{this.videoDecoder.configure(this.lastVideoConfig)}catch{}},1e3))}});this.videoDecoder=e};playDecodedAudio=e=>{try{if(!this.audioContext||!this.mediaDestination){e.close();return}let{numberOfChannels:t,numberOfFrames:i,sampleRate:n}=e,a=i/n,r=this.audioContext.currentTime;this.nextStartTime<r?this.nextStartTime=r+Sa:this.nextStartTime>r+Hf&&(this.nextStartTime=r+Sa,this.scheduledAudioNodes.forEach(c=>{try{c.stop()}catch{}}),this.scheduledAudioNodes=[]);let o=this.audioContext.createBuffer(t,i,n);for(let c=0;c<t;c++){let p=new Float32Array(i);e.copyTo(p,{planeIndex:c,format:"f32-planar"}),o.copyToChannel(p,c)}let l=this.audioContext.createBufferSource();if(l.buffer=o,l.connect(this.mediaDestination),this.scheduledAudioNodes.push(l),this.scheduledAudioNodes.length>100){let c=this.scheduledAudioNodes.shift();try{c?.stop(),c?.disconnect()}catch{}}l.onended=()=>{this.scheduledAudioNodes=this.scheduledAudioNodes.filter(c=>c!==l)},l.start(this.nextStartTime),this.nextStartTime+=a,e.close()}catch(t){console.error("Error in playDecodedAudio:",t),e?.close()}};newCodecFromDescription=(e,t)=>{if(!t.toLowerCase().includes("hvc")&&!t.toLowerCase().includes("hev"))return"";try{return Di.demux(e).toCodecString()}catch{return""}};receiveLoop=async()=>{let e=new TextDecoder,t=Date.now();for(;;){Date.now()-t>16&&(await new Promise(i=>setTimeout(i,0)),t=Date.now());try{if(!this.nodeCall)break;let i=await this.nodeCall.asyncRecv(),n=new DataView(i.buffer,i.byteOffset,i.byteLength),a=n.getUint8(0),r=[0,1,6,7,5,8,9,10,11].includes(a)?1:9,o=new Uint8Array(i.buffer,i.byteOffset+r,i.byteLength-r);switch(a){case 0:{try{let c=e.decode(o);if(this.lastVideoConfigStr===c&&this.videoDecoder?.state==="configured")break;this.lastVideoConfigStr=c;let p=JSON.parse(c);if(console.log("videoConfig",p),!this.videoWriter){let h=new MediaStreamTrackGenerator({kind:"video"});this.videoWriter=h.writable.getWriter(),this.generatedStream&&this.generatedStream.addTrack(h)}this.videoDecoder||this.setupVideoDecoder(),this.isWaitingForKeyFrame=!0;let d;if(p.description)try{let h=atob(p.description),x=new Uint8Array(h.length);for(let v=0;v<h.length;v++)x[v]=h.charCodeAt(v);d=x.buffer}catch{}let u="";d&&(u=this.newCodecFromDescription(d,p.codec)||xl(p.codec));let f={codec:u,frameRate:p.frameRate,codedWidth:p.codedWidth,codedHeight:p.codedHeight,...p.orientation&&{rotation:p.orientation},...d&&{description:d}};this.lastVideoConfig=f,this.videoDecoder&&this.videoDecoder.state!=="closed"&&((await VideoDecoder.isConfigSupported(f)).supported?(this.videoDecoder.configure(f),this.isWaitingForKeyFrame=!0):console.error("\u274C Browser does not support this video config:",f))}catch(c){console.error("\u274C Error processing VIDEO_CONFIG:",c)}break}case 1:{try{let c=e.decode(o);if(this.lastAudioConfigStr===c&&this.audioDecoder?.state==="configured")break;this.lastAudioConfigStr=c;let p=JSON.parse(c);console.log("audioConfig",p),this.audioDecoder?.state!=="closed"&&this.audioDecoder?.configure({codec:p.codec,sampleRate:p.sampleRate,numberOfChannels:p.numberOfChannels})}catch(c){console.error("\u274C Error processing AUDIO_CONFIG:",c)}break}case 2:case 3:{if(!this.videoDecoder||this.videoDecoder.state!=="configured")break;let c=a===2;if(this.isWaitingForKeyFrame){if(!c)break;this.isWaitingForKeyFrame=!1}if(!c&&this.videoDecoder.decodeQueueSize>5){this.isWaitingForKeyFrame=!0;break}let p=n.getBigUint64(1,!1),d=Number(p);try{this.videoDecoder.decode(new EncodedVideoChunk({type:c?"key":"delta",timestamp:d,data:o}))}catch(u){console.error("Video decode failed:",u),this.videoDecoder.state==="closed"&&(this.isWaitingForKeyFrame=!0)}break}case 4:{if(this.audioDecoder?.state==="configured"){let c=n.getBigUint64(1,!1),p=Number(c);this.audioDecoder.decode(new EncodedAudioChunk({type:"key",timestamp:p,data:o}))}break}case 6:this.events.onConnected&&this.events.onConnected();break;case 7:let l=JSON.parse(e.decode(o));this.events.onTransceiverState&&this.events.onTransceiverState(l);break;case 5:{let c=n.getInt32(1,!1);if(this.videoDecoder&&this.lastVideoConfig&&this.lastVideoConfig.rotation!==c){this.lastVideoConfig.rotation=c;try{this.videoDecoder.configure(this.lastVideoConfig),this.isWaitingForKeyFrame=!0,console.log("\u{1F504} Reconfigured rotation to",c,"- Waiting for next KeyFrame")}catch(p){console.error("Error reconfiguring VideoDecoder with new orientation:",p)}}break}case 8:console.log("\u{1F4E5} Received REQUEST_CONFIG"),this.events.onRequestConfig&&this.events.onRequestConfig();break;case 9:console.log("\u{1F4E5} Received REQUEST_KEY_FRAME"),this.events.onRequestKeyFrame&&this.events.onRequestKeyFrame();break;case 10:console.log("\u{1F4E5} Received END_CALL"),this.events.onEndCall&&this.events.onEndCall();break;case 11:break;default:break}}catch{await new Promise(n=>setTimeout(n,200))}}};resetDecoders=()=>{if(this.videoWriter){try{this.videoWriter.abort("Stream stopped").catch(()=>{}),this.videoWriter.releaseLock()}catch(e){console.warn("Error closing video writer:",e)}this.videoWriter=null}if(this.videoDecoder){try{this.videoDecoder.state!=="closed"&&(this.videoDecoder.reset(),this.videoDecoder.close())}catch{}this.videoDecoder=null}if(this.audioDecoder){try{this.audioDecoder.state!=="closed"&&(this.audioDecoder.reset(),this.audioDecoder.close())}catch{}this.audioDecoder=null}if(this.audioContext){try{this.audioContext.close()}catch(e){console.warn("Error closing audio context:",e)}this.audioContext=null}this.scheduledAudioNodes.forEach(e=>{try{e.stop()}catch{}}),this.scheduledAudioNodes=[],this.isWaitingForKeyFrame=!0,this.mediaDestination=null,this.nextStartTime=0,this.lastVideoConfig=null,this.generatedStream&&(this.generatedStream.getTracks().forEach(e=>e.stop()),this.generatedStream=null)}};var Ra=class{wasmPath;workerPath;relayUrl="https://test-iroh.ermis.network.:8443";_client;sessionID;cid;callType;get userID(){return this._client?.userID}callStatus="";metadata;callNode=null;localStream=null;remoteStream=null;callerInfo;receiverInfo;onCallEvent;onLocalStream;onRemoteStream;onConnectionMessageChange;onCallStatus;onDataChannelMessage;onUpgradeCall;onScreenShareChange;onError;onDeviceChange;availableAudioDevices=[];availableVideoDevices=[];selectedAudioDeviceId;selectedVideoDeviceId;missCallTimeout=null;healthCallInterval=null;healthCallServerInterval=null;healthCallTimeout=null;healthCallWarningTimeout=null;signalHandler;connectionChangedHandler;messageUpdatedHandler;isOffline=!1;isDestroyed=!1;mediaSender=null;mediaReceiver=null;constructor(e,t,i,n,a){this._client=e,this.cid="",this.callType="",this.sessionID=t,this.metadata={},this.wasmPath=i,this.relayUrl=n,this.workerPath=a||"/wasm_worker.worker.mjs",this.listenSocketEvents(),this.setupDeviceChangeListener(),this.loadWasm()}async loadWasm(){try{this.callNode=new Ai(new URL(this.workerPath,window.location.origin)),await this.callNode.init(this.wasmPath)}catch(e){throw console.error("Failed to load ErmisCall WASM Worker:",e),e}}async initialize(){try{this.callNode||await this.loadWasm();let e=this.callNode;return await e.spawn([this.relayUrl]),this.mediaSender=new Ii(e),this.mediaReceiver=new Ui(e,{onConnected:()=>{this.setCallStatus("connected"),this.connectCall(),this.missCallTimeout&&(clearTimeout(this.missCallTimeout),this.missCallTimeout=null),this.healthCallServerInterval&&clearInterval(this.healthCallServerInterval),this.healthCallServerInterval=setInterval(()=>{this.healthCall()},1e4);let t=this.mediaReceiver?.getRemoteStream();t&&this.onRemoteStream&&this.onRemoteStream(t)},onTransceiverState:t=>{typeof this.onDataChannelMessage=="function"&&this.onDataChannelMessage(t)},onRequestConfig:()=>{console.log("\u{1F4E4} Responding to REQUEST_CONFIG by sending configs"),this.mediaSender?.sendConfigs()},onRequestKeyFrame:()=>{console.log("\u{1F4E4} Responding to REQUEST_KEY_FRAME by forcing key frame"),this.mediaSender?.requestKeyFrame()},onEndCall:()=>{console.log("\u{1F4E5} Received END_CALL from remote peer"),this.destroy()}}),await e.startRecvLoop(),e}catch(e){throw console.error("Failed to initialize Ermis SDK:",e),e}}async getLocalEndpointAddr(){try{if(await this.initialize(),!this.callNode)return console.error("ErmisCall is not initialized."),null;let e=await this.callNode.getLocalEndpointAddr();return this.metadata&&(this.metadata.address=e),e}catch(e){return console.error("Failed to get address from ErmisCall:",e),null}}getClient(){return this._client}async _sendSignal(e){try{return await this.getClient().post(this.getClient().baseURL+"/signal",{...e,cid:this.cid||e.cid,is_video:this.callType==="video"||e.is_video,ios:!1,session_id:this.sessionID})}catch(t){let i=e.action;if(i==="health-call")return;if(typeof this.onError=="function")if(t.code==="ERR_NETWORK")i==="create-call"&&this.onError("call_network_error");else if(t.response.data.ermis_code===20)this.onError("call_recipient_busy");else{let n=t.response.data?.message?t.response.data?.message:"call_failed";this.onError(n)}}}async getAvailableDevices(){try{let e=await navigator.mediaDevices.enumerateDevices(),t=e.filter(n=>n.kind==="audioinput"),i=e.filter(n=>n.kind==="videoinput");return this.availableAudioDevices=t,this.availableVideoDevices=i,{audioDevices:t,videoDevices:i}}catch(e){return console.error("Error enumerating devices:",e),{audioDevices:[],videoDevices:[]}}}async getMediaConstraints(){let{audioDevices:e,videoDevices:t}=await this.getAvailableDevices();this.onDeviceChange&&this.onDeviceChange(e,t),!this.selectedAudioDeviceId&&e.length>0&&(this.selectedAudioDeviceId=e[0].deviceId),!this.selectedVideoDeviceId&&t.length>0&&(this.selectedVideoDeviceId=t[0].deviceId);let i={deviceId:this.selectedAudioDeviceId?{exact:this.selectedAudioDeviceId}:void 0,echoCancellation:!0,noiseSuppression:!0,sampleRate:48e3},n=this.callType==="video"?{deviceId:this.selectedVideoDeviceId?{exact:this.selectedVideoDeviceId}:void 0,width:640,height:360}:!1;return{audio:i,video:n}}async startLocalStream(){let e=await this.getMediaConstraints();try{let t=await navigator.mediaDevices.getUserMedia(e);return this.applyLocalStream(t)}catch(t){if(console.warn("Error getting user media:",t?.message),this.callType==="video"&&e.video)try{let i=await navigator.mediaDevices.getUserMedia({audio:e.audio,video:!1});return this.setConnectionMessage("Camera not available, using audio only"),this.applyLocalStream(i)}catch{}return typeof this.onError=="function"&&this.onError("call_no_devices"),null}}applyLocalStream(e){if(this.callStatus==="ended"){e.getTracks().forEach(t=>t.stop()),this.destroy();return}return this.onLocalStream&&this.onLocalStream(e),this.localStream=e,e}setConnectionMessage(e){typeof this.onConnectionMessageChange=="function"&&this.onConnectionMessageChange(e)}setCallStatus(e){this.callStatus=e,typeof this.onCallStatus=="function"&&this.onCallStatus(e)}setUserInfo(e,t){if(!e||!t)return;let i=e?this.getClient().activeChannels[e]:void 0,n=i?.state?.members||{},a=Object.keys(n),r=t||"",o=a.find(u=>u!==r)||"",l=i?.data?.members||[],c=u=>l.find(h=>h.user_id===u||h.user?.id===u)?.user,p=c(r)||n[r]?.user||this.getClient().state.users[r],d=c(o)||n[o]?.user||this.getClient().state.users[o];this.callerInfo={id:r,name:p?.name||r,avatar:p?.avatar||""},this.receiverInfo={id:o,name:d?.name||o,avatar:d?.avatar||""}}listenSocketEvents(){this.signalHandler=async e=>{let{action:t,user_id:i,session_id:n,cid:a,is_video:r,signal:o,metadata:l}=e;switch(t){case"create-call":if(i===this.userID&&n!==this.sessionID){this.isDestroyed=!0,this.destroy();return}if(this.isDestroyed=!1,this.callStatus="",this.callType=r?"video":"audio",this.setUserInfo(a,i),this.cid=a||"",this.metadata=l||{},typeof this.onCallEvent=="function"&&this.onCallEvent({type:i!==this.userID?"incoming":"outgoing",callType:r?"video":"audio",cid:a||"",callerInfo:this.callerInfo,receiverInfo:this.receiverInfo,metadata:this.metadata}),this.setCallStatus("ringing"),await this.startLocalStream(),this.callStatus==="ended")return;i!==this.userID&&await this.initialize(),i===this.userID&&(this.missCallTimeout&&clearTimeout(this.missCallTimeout),this.missCallTimeout=setTimeout(async()=>{await this.missCall()},6e4));break;case"accept-call":if(i===this.userID&&n!==this.sessionID){this.isDestroyed=!0,this.destroy();return}i!==this.userID&&!this.isDestroyed&&(this.mediaReceiver&&this.mediaSender&&(await this.mediaReceiver.acceptConnection(),await this.mediaSender.sendConnected()),this.localStream&&this.mediaSender&&this.mediaReceiver&&this.callType&&(this.mediaSender?.initEncoders(this.localStream),this.mediaReceiver?.initDecoders(this.callType)),this.mediaSender&&await this.mediaSender.sendConfigs());break;case"end-call":case"reject-call":case"miss-call":await this.destroy();break}},this.connectionChangedHandler=e=>{let t=e.online;this.isOffline=!t,t?(this.setConnectionMessage(null),this.callStatus==="connected"&&(this.healthCallServerInterval||(this.healthCallServerInterval=setInterval(()=>{this.healthCall()},1e4)))):(this.setConnectionMessage("Your network connection is unstable"),this.healthCallInterval&&(clearInterval(this.healthCallInterval),this.healthCallInterval=null),this.healthCallServerInterval&&(clearInterval(this.healthCallServerInterval),this.healthCallServerInterval=null))},this.messageUpdatedHandler=e=>{if(this.callStatus==="connected"&&e.cid===this.cid){let t=e.user?.id,i;t===this.callerInfo?.id?i=this.callerInfo:t===this.receiverInfo?.id&&(i=this.receiverInfo),i&&typeof this.onUpgradeCall=="function"&&this.onUpgradeCall(i)}},this._client.on("signal",this.signalHandler),this._client.on("connection.changed",this.connectionChangedHandler),this._client.on("message.updated",this.messageUpdatedHandler)}async cleanupCall(){if(this.mediaSender&&(this.mediaSender?.stop(),this.mediaSender=null),this.mediaReceiver&&(this.mediaReceiver.stop(),this.mediaReceiver=null),this.callNode){try{await Promise.race([this.callNode.terminate(),new Promise(e=>setTimeout(e,1e3))])}catch{}this.callNode=null}this.missCallTimeout&&(clearTimeout(this.missCallTimeout),this.missCallTimeout=null),this.healthCallInterval&&(clearInterval(this.healthCallInterval),this.healthCallInterval=null),this.healthCallServerInterval&&(clearInterval(this.healthCallServerInterval),this.healthCallServerInterval=null),this.healthCallTimeout&&(clearTimeout(this.healthCallTimeout),this.healthCallTimeout=null),this.healthCallWarningTimeout&&(clearTimeout(this.healthCallWarningTimeout),this.healthCallWarningTimeout=null),this.setConnectionMessage(null),this.cid="",this.callType="",this.metadata={},this.localStream&&(this.localStream.getTracks().forEach(e=>e.stop()),this.localStream=null),this.remoteStream&&(this.remoteStream.getTracks().forEach(e=>e.stop()),this.remoteStream=null),this.setCallStatus("ended")}async destroy(){await this.cleanupCall()}async getDevices(){return this.availableAudioDevices.length>0||this.availableVideoDevices.length>0?{audioDevices:this.availableAudioDevices,videoDevices:this.availableVideoDevices}:await this.getAvailableDevices()}getSelectedDevices(){let e=this.selectedAudioDeviceId?this.availableAudioDevices.find(i=>i.deviceId===this.selectedAudioDeviceId):void 0,t=this.selectedVideoDeviceId?this.availableVideoDevices.find(i=>i.deviceId===this.selectedVideoDeviceId):void 0;return{audioDevice:e,videoDevice:t}}getDefaultDevices(){return{audioDevice:this.availableAudioDevices[0],videoDevice:this.availableVideoDevices[0]}}prefillUserInfo(e){this.setUserInfo(e,this.userID)}async createCall(e,t){try{this.cid=t,this.callType=e,this.prefillUserInfo(t);let i=await this.getLocalEndpointAddr();await this._sendSignal({action:"create-call",cid:t,is_video:e==="video",metadata:{address:i}})}catch(i){throw console.error("Failed to create call:",i),i}}async acceptCall(){try{if(await this._sendSignal({action:"accept-call"}),this.mediaSender){let e=this.metadata?.address||"";await this.mediaSender.connect(e)}this.localStream&&this.mediaSender&&this.mediaReceiver&&(this.mediaSender?.initEncoders(this.localStream),this.mediaReceiver?.initDecoders(this.callType||"audio")),this.mediaSender&&await this.mediaSender.sendConfigs()}catch(e){throw console.error("Failed to accept call:",e),e}}async endCall(){await this._sendSignal({action:"end-call"}),this.destroy()}async rejectCall(){await this._sendSignal({action:"reject-call"}),this.destroy()}async missCall(){await this._sendSignal({action:"miss-call"}),this.destroy()}async connectCall(){return await this._sendSignal({action:"connect-call"})}async healthCall(){return await this._sendSignal({action:"health-call"})}async addVideoTrackToLocalStream(){let e=await this.getMediaConstraints(),t=await navigator.mediaDevices.getUserMedia(e),i=t.getVideoTracks()[0];this.localStream?(this.localStream.addTrack(i),this.onLocalStream&&this.onLocalStream(this.localStream)):(this.localStream=t,this.onLocalStream&&this.onLocalStream(this.localStream))}async upgradeCall(){try{if(this.callType="video",await this.addVideoTrackToLocalStream(),await this._sendSignal({action:"upgrade-call"}),this.localStream){this.mediaSender?.initVideoEncoder(this.localStream?.getVideoTracks()[0]);let e=!!this.localStream?.getAudioTracks().some(i=>i.enabled),t=!!this.localStream?.getVideoTracks().some(i=>i.enabled);await this.mediaSender?.sendTransceiverState(e,t)}}catch(e){throw console.error("Failed to upgrade call:",e),e}}async requestUpgradeCall(e){if(e&&(this.callType="video",await this.addVideoTrackToLocalStream(),this.localStream)){this.mediaSender?.initVideoEncoder(this.localStream?.getVideoTracks()[0]);let t=!!this.localStream?.getAudioTracks().some(n=>n.enabled),i=!!this.localStream?.getVideoTracks().some(n=>n.enabled);await this.mediaSender?.sendTransceiverState(t,i)}}async startScreenShare(){if(!navigator.mediaDevices.getDisplayMedia)throw new Error("Screen sharing is not supported in this browser.");let e=await navigator.mediaDevices.getDisplayMedia({video:!0}),t=e.getVideoTracks()[0];this.localStream?(this.localStream.getVideoTracks().forEach(i=>i.stop()),this.localStream.removeTrack(this.localStream.getVideoTracks()[0]),this.localStream.addTrack(t)):this.localStream=e,t.onended=()=>{this.stopScreenShare()},this.onLocalStream&&(this.onLocalStream(this.localStream),this.mediaSender?.replaceVideoTrack(this.localStream.getVideoTracks()[0])),typeof this.onScreenShareChange=="function"&&this.onScreenShareChange(!0)}async stopScreenShare(){let e=await this.getMediaConstraints();try{let t=await navigator.mediaDevices.getUserMedia({video:e.video,audio:!1}),i=t.getVideoTracks()[0];this.localStream?(this.localStream.getVideoTracks().forEach(n=>{n.stop(),this.localStream?.removeTrack(n)}),this.localStream.addTrack(i)):this.localStream=t,this.onLocalStream&&(this.onLocalStream(this.localStream),this.mediaSender?.replaceVideoTrack(this.localStream.getVideoTracks()[0])),typeof this.onScreenShareChange=="function"&&this.onScreenShareChange(!1)}catch(t){console.error("Error stopping screen share and reverting to camera:",t)}}async toggleMic(e){if(this.localStream){this.localStream.getAudioTracks().forEach(n=>{n.enabled=e});let t=e,i=this.localStream.getVideoTracks().some(n=>n.enabled);await this.mediaSender?.sendTransceiverState(t,i)}}async toggleCamera(e){if(this.localStream){this.localStream.getVideoTracks().forEach(n=>{n.enabled=e});let t=this.localStream.getAudioTracks().some(n=>n.enabled),i=e;await this.mediaSender?.sendTransceiverState(t,i)}}async switchAudioDevice(e){try{if(!this.availableAudioDevices.find(o=>o.deviceId===e))return console.error("Audio device not found:",e),this.onError&&this.onError("Selected microphone not found"),!1;if(this.selectedAudioDeviceId=e,!this.localStream)return!1;let i=await this.getMediaConstraints(),a=(await navigator.mediaDevices.getUserMedia({audio:i.audio,video:!1})).getAudioTracks()[0],r=this.localStream.getAudioTracks()[0];return this.mediaSender&&a&&await this.mediaSender.replaceAudioTrack(a),r&&(this.localStream.removeTrack(r),r.stop()),this.localStream.addTrack(a),this.onLocalStream&&this.onLocalStream(this.localStream),!0}catch(t){return console.error("Error switching audio device:",t),this.onError&&this.onError("Failed to switch microphone"),!1}}async switchVideoDevice(e){try{if(!this.availableVideoDevices.find(o=>o.deviceId===e))return console.error("Video device not found:",e),this.onError&&this.onError("Selected camera not found"),!1;if(this.selectedVideoDeviceId=e,!this.localStream)return!1;let i=await this.getMediaConstraints(),a=(await navigator.mediaDevices.getUserMedia({audio:!1,video:i.video})).getVideoTracks()[0],r=this.localStream.getVideoTracks()[0];return this.mediaSender&&a&&await this.mediaSender.replaceVideoTrack(a),r&&(this.localStream.removeTrack(r),r.stop()),this.localStream.addTrack(a),this.onLocalStream&&this.onLocalStream(this.localStream),!0}catch(t){return console.error("Error switching video device:",t),this.onError&&this.onError("Failed to switch camera"),!1}}setupDeviceChangeListener(){navigator.mediaDevices.addEventListener("devicechange",async()=>{let{audioDevices:e,videoDevices:t}=await this.getAvailableDevices();this.onDeviceChange&&this.onDeviceChange(e,t)})}};Ze();var Ta=class{apiKey;baseURL;options;axiosInstance;disconnected;browser;node;logger;consecutiveFailures;userAgent;lastIdentifier;lastMethod;address;constructor(e,t,i){let n=i||{};this.apiKey=e,this.baseURL=i?.userBaseURL||t+"/uss/v1",this.browser=typeof n.browser<"u"?n.browser:typeof window<"u",this.node=!this.browser,this.options={withCredentials:!1,warmUp:!1,recoverStateOnReconnect:!0,...n},this.node&&!this.options.httpsAgent&&(this.options.httpsAgent=new ut.Agent({keepAlive:!0,keepAliveMsecs:3e3})),this.axiosInstance=Ht.create(this.options),this.logger=gi(n.logger)?n.logger:()=>null,this.consecutiveFailures=0,this.disconnected=!1}_logApiRequest(e,t,i,n){this.logger("info",`client: ${e} - Request - ${t}- ${JSON.stringify(i)} - ${JSON.stringify(n.params)}`,{tags:["api","api_request","client"],url:t,payload:i,config:n})}_logApiResponse(e,t,i){this.logger("info",`client:${e} - Response - url: ${t} > status ${i.status}`,{tags:["api","api_response","client"],url:t,response:i})}_logApiError(e,t,i,n){this.logger("error",`client:${e} - Error: ${JSON.stringify(i)} - url: ${t} - options: ${JSON.stringify(n)}`,{tags:["api","api_response","client"],url:t,error:i})}doAxiosRequest=async(e,t,i,n={})=>{let a=this._enrichAxiosOptions(n);try{let r;switch(this._logApiRequest(e,t,i,a),e){case"get":r=await this.axiosInstance.get(t,a);break;case"delete":r=await this.axiosInstance.delete(t,a);break;case"post":r=await this.axiosInstance.post(t,i,a);break;case"postForm":r=await this.axiosInstance.postForm(t,i,a);break;case"put":r=await this.axiosInstance.put(t,i,a);break;case"patch":r=await this.axiosInstance.patch(t,i,a);break;case"options":r=await this.axiosInstance.options(t,a);break;default:throw new Error("Invalid request type")}return this._logApiResponse(e,t,r),this.consecutiveFailures=0,this.handleResponse(r)}catch(r){if(r.client_request_id=a.headers?.["x-client-request-id"],this._logApiError(e,t,r,n),this.consecutiveFailures+=1,r.response)return r.response.data.code===st.TOKEN_EXPIRED?(this.consecutiveFailures>1&&await Kt(xi(this.consecutiveFailures)),await this.doAxiosRequest(e,t,i,a)):this.handleResponse(r.response);throw r}};get(e,t){return this.doAxiosRequest("get",e,null,{params:t})}put(e,t){return this.doAxiosRequest("put",e,t)}post(e,t,i){return this.doAxiosRequest("post",e,t,{params:i})}patch(e,t){return this.doAxiosRequest("patch",e,t)}delete(e,t){return this.doAxiosRequest("delete",e,null,{params:t})}errorFromResponse(e){let t;return t=new Rt(`ErmisChat error HTTP code: ${e.status}`),e.data&&e.data.code&&(t=new Error(`ErmisChat error code ${e.data.code}: ${e.data.message}`),t.code=e.data.code),t.response=e,t.status=e.status,t}handleResponse(e){let t=e.data;if(Ri(e))throw this.errorFromResponse(e);return t}getUserAgent(){return this.userAgent||`ermis-chat-sdk-javascript-client-${this.node?"node":"browser"}-2.0.0`}setUserAgent(e){this.userAgent=e}_enrichAxiosOptions(e={params:{},headers:{},config:{}}){let t=null;e.headers?.["x-client-request-id"]||(e.headers={...e.headers,"x-client-request-id":Ee()});let{params:i,headers:n,...a}=this.options?.axiosRequestConfig||{};return{params:{...e.params,...i||{}},headers:{"X-Stream-Client":this.getUserAgent(),...e.headers,...n||{}},...t?{signal:t}:{},...e.config,...a||{}}}async sendOtpToPhone(e,t){this.lastIdentifier=e,this.lastMethod=t;let i={apikey:this.apiKey,identifier:e,language:"Vi",method:t,otp_type:"Login"};return this.post(this.baseURL+"/auth/get_otp_new",i)}async sendOtpToEmail(e){this.lastIdentifier=e,this.lastMethod="Email";let t={apikey:this.apiKey,identifier:e,language:"Vi",method:"Email",otp_type:"Login"};return this.post(this.baseURL+"/auth/get_otp_new",t)}async verifyOtp(e){let t={identifier:this.lastIdentifier,method:this.lastMethod,apikey:this.apiKey,otp:e};return this.post(this.baseURL+"/auth/otp_login",t)}async loginWithGoogle(e){let t={token:e,apikey:this.apiKey};return this.post(this.baseURL+"/auth/google_login",t)}async getWalletChallenge(e){this.address=e;let t=await this.post(this.baseURL+"/auth/get_challenge",{address:e,apikey:this.apiKey});return JSON.parse(t.challenge)}createNonce(e){let t="",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=i.length;for(let a=0;a<e;a++)t+=i.charAt(Math.floor(Math.random()*n));return t}async verifyWalletSignature(e){let t={address:this.address,signature:e,nonce:this.createNonce(20),apikey:this.apiKey};return this.post(this.baseURL+"/auth/verify_signature",t)}};function ka(s,e){return e[s]??s}function xp(s,e,t){if(!s||typeof s!="string")return s??"";let i=s.trim();if(!i)return"";let n=i.split(" "),a=n[0],r=n[1]??"",o=r?ka(r,e):t?.userFallback??"User";switch(a){case"1":{let l=n.slice(2).join(" "),c=t?.["1"]??t?.changeName;return c?c.replace("{{user}}",o).replace("{{channel}}",l):`${o} changed the channel name to ${l}.`}case"2":{let l=t?.["2"]??t?.changeAvatar;return l?l.replace("{{user}}",o):`${o} changed the channel avatar.`}case"3":{let l=t?.["3"]??t?.changeDescription;return l?l.replace("{{user}}",o):`${o} changed the channel description.`}case"4":{let l=t?.["4"]??t?.removed;return l?l.replace("{{user}}",o):`${o} was removed from the channel.`}case"5":{let l=t?.["5"]??t?.banned;return l?l.replace("{{user}}",o):`${o} was banned.`}case"6":{let l=t?.["6"]??t?.unbanned;return l?l.replace("{{user}}",o):`${o} was unbanned.`}case"7":{let l=t?.["7"]??t?.promoted;return l?l.replace("{{user}}",o):`${o} was promoted to moderator.`}case"8":{let l=t?.["8"]??t?.demoted;return l?l.replace("{{user}}",o):`${o} was demoted from moderator.`}case"9":{let l=t?.["9"]??t?.permissionsUpdated;return l?l.replace("{{user}}",o):`${o}'s permissions were updated.`}case"10":{let l=t?.["10"]??t?.joined;return l?l.replace("{{user}}",o):`${o} joined the channel.`}case"11":{let l=t?.["11"]??t?.declined;return l?l.replace("{{user}}",o):`${o} declined the channel invitation.`}case"12":{let l=t?.["12"]??t?.left;return l?l.replace("{{user}}",o):`${o} left the channel.`}case"13":{let l=t?.["13"]??t?.clearedHistory;return l?l.replace("{{user}}",o):`${o} cleared the chat history.`}case"14":{let c=(n[2]??"")==="true"?"public":"private",p=t?.[c]??c,d=t?.["14"]??t?.changeType;return d?d.replace("{{user}}",o).replace("{{type}}",p):`${o} changed the channel to ${p}.`}case"15":{let l=n[2]??"0";if(l==="0"){let f=t?.["15_off"]??t?.cooldownOff;return f?f.replace("{{user}}",o):`${o} disabled cooldown.`}let c=`${l}ms`,p=t?.durationUnitMin??"minute",d=t?.durationUnitSec??"seconds";l==="10000"?c=`10 ${d}`:l==="30000"?c=`30 ${d}`:l==="60000"?c=`1 ${p}`:l==="300000"?c=`5 ${p}`:l==="900000"?c=`15 ${p}`:l==="3600000"&&(c=`60 ${p}`);let u=t?.["15_on"]??t?.cooldownOn;return u?u.replace("{{user}}",o).replace("{{duration}}",c):`${o} enabled cooldown for ${c}.`}case"16":{let l=t?.["16"]??t?.bannedWordsUpdated;return l?l.replace("{{user}}",o):`${o} updated the banned words.`}case"17":{let l=t?.["17"]??t?.added;return l?l.replace("{{user}}",o):`${o} was added to the channel.`}case"18":{let l=n[1]??"",c=n[2]??"",p=l?ka(l,e):t?.userFallback??"User",d=c?ka(c,e):t?.userFallback??"User",u=t?.adminFallback??"Admin",f=t?.["18"]??t?.adminTransfer;return f?f.replace("{{user}}",p).replace("{{targetUser}}",d).replace("{{admin}}",u):`${u} ${p} left and assigned ${d} as the new admin.`}case"19":{let l=t?.["19"]??t?.pinned;return l?l.replace("{{user}}",o):`${o} pinned a message.`}case"20":{let l=t?.["20"]??t?.unpinned;return l?l.replace("{{user}}",o):`${o} unpinned a message.`}default:return i}}var Pe={AUDIO:"audio",VIDEO:"video"};function Kf(s,e){if(!s)return"";let t=parseInt(s,10);if(isNaN(t)||t<=0)return"";let i=Math.floor(t/1e3),n=Math.floor(i/60),a=i%60,r=e?.durationUnitMin??"min",o=e?.durationUnitSec??"sec";return`${n} ${r}, ${a} ${o}`}function vp(s,e,t){if(!s||typeof s!="string")return null;let i=s.trim();if(!i)return null;let n=i.split(" "),a=parseInt(n[0],10),r=n[1]??"",o=e===r,l="",c="",p="",d="";(a===3||a===6)&&(l=n[2]??"",c=n[3]==="0"?"":n[3]??"");let u;switch(a){case 1:u=o?t?.calling??"Calling...":t?.incomingAudioCall??"Incoming audio call...",p=Pe.AUDIO,d="#54D62C";break;case 2:u=o?t?.outgoingAudioCall??"Outgoing audio call":t?.missedAudioCall??"You missed audio call",p=Pe.AUDIO,d="#FF4842";break;case 3:c?(u=o?t?.outgoingAudioCall??"Outgoing audio call":t?.incomingAudioCall??"Incoming audio call",d="#54D62C"):(l===e?u=t?.cancelAudioCall??"You cancel audio call":u=t?.missedAudioCall??"You missed audio call",d="#FF4842"),p=Pe.AUDIO;break;case 4:u=o?t?.calling??"Calling...":t?.incomingVideoCall??"Incoming video call...",p=Pe.VIDEO,d="#54D62C";break;case 5:u=o?t?.outgoingVideoCall??"Outgoing video call":t?.missedVideoCall??"You missed video call",p=Pe.VIDEO,d="#FF4842";break;case 6:c?(u=o?t?.outgoingVideoCall??"Outgoing video call":t?.incomingVideoCall??"Incoming video call",d="#54D62C"):(l===e?u=t?.cancelVideoCall??"You cancel video call":u=t?.missedVideoCall??"You missed video call",d="#FF4842"),p=Pe.VIDEO;break;case 7:u=o?t?.rejectedAudioCallRecipient??"Recipient rejected audio call":t?.rejectedAudioCallYou??"You rejected audio call",p=Pe.AUDIO,d="#FF4842";break;case 8:u=o?t?.rejectedVideoCallRecipient??"Recipient rejected video call":t?.rejectedVideoCallYou??"You rejected video call",p=Pe.VIDEO,d="#FF4842";break;case 9:u=o?t?.busyRecipient??"Recipient was busy":t?.missedAudioCall??"You missed audio call",p=Pe.AUDIO,d="#FF4842";break;case 10:u=o?t?.busyRecipient??"Recipient was busy":t?.missedVideoCall??"You missed video call",p=Pe.VIDEO,d="#FF4842";break;default:u=i,p="",d=""}return{text:u,duration:Kf(c,t),callType:p,color:d}}return ts(Jf);})();
12
+ `+t)),n.removeListener("error",Zo),n.destroy()}function Gb(n){return n.trim()}});var Ih=U((UA,Mh)=>{"use strict";var Wn=Jo();Wn.createWebSocketStream=Ch();Wn.Server=Ph();Wn.Receiver=Fo();Wn.Sender=jo();Mh.exports=Wn});var Uh=U((DA,Th)=>{"use strict";Th.exports=Ih()});var Zh=U((pc,Ri)=>{"use strict";(function(n){"use strict";var e=n.setTimeout,t=n.clearTimeout,s=n.XMLHttpRequest,r=n.XDomainRequest,i=n.ActiveXObject,a=n.EventSource,o=n.document,c=n.Promise,l=n.fetch,p=n.Response,d=n.TextDecoder,u=n.TextEncoder,h=n.AbortController;if(typeof window<"u"&&typeof o<"u"&&!("readyState"in o)&&o.body==null&&(o.readyState="loading",window.addEventListener("load",function(R){o.readyState="complete"},!1)),s==null&&i!=null&&(s=function(){return new i("Microsoft.XMLHTTP")}),Object.create==null&&(Object.create=function(R){function O(){}return O.prototype=R,new O}),Date.now||(Date.now=function(){return new Date().getTime()}),h==null){var m=l;l=function(R,O){var N=O.signal;return m(R,{headers:O.headers,credentials:O.credentials,cache:O.cache}).then(function(L){var J=L.body.getReader();return N._reader=J,N._aborted&&N._reader.cancel(),{status:L.status,statusText:L.statusText,headers:L.headers,body:{getReader:function(){return J}}}})},h=function(){this.signal={_reader:null,_aborted:!1},this.abort=function(){this.signal._reader!=null&&this.signal._reader.cancel(),this.signal._aborted=!0}}}function g(){this.bitsNeeded=0,this.codePoint=0}g.prototype.decode=function(R){function O(pe,fe,Y){if(Y===1)return pe>=128>>fe&&pe<<fe<=2047;if(Y===2)return pe>=2048>>fe&&pe<<fe<=55295||pe>=57344>>fe&&pe<<fe<=65535;if(Y===3)return pe>=65536>>fe&&pe<<fe<=1114111;throw new Error}function N(pe,fe){if(pe===6)return fe>>6>15?3:fe>31?2:1;if(pe===12)return fe>15?3:2;if(pe===18)return 3;throw new Error}for(var L=65533,J="",K=this.bitsNeeded,se=this.codePoint,ye=0;ye<R.length;ye+=1){var ae=R[ye];K!==0&&(ae<128||ae>191||!O(se<<6|ae&63,K-6,N(K,se)))&&(K=0,se=L,J+=String.fromCharCode(se)),K===0?(ae>=0&&ae<=127?(K=0,se=ae):ae>=192&&ae<=223?(K=6,se=ae&31):ae>=224&&ae<=239?(K=12,se=ae&15):ae>=240&&ae<=247?(K=18,se=ae&7):(K=0,se=L),K!==0&&!O(se,K,N(K,se))&&(K=0,se=L)):(K-=6,se=se<<6|ae&63),K===0&&(se<=65535?J+=String.fromCharCode(se):(J+=String.fromCharCode(55296+(se-65535-1>>10)),J+=String.fromCharCode(56320+(se-65535-1&1023))))}return this.bitsNeeded=K,this.codePoint=se,J};var _=function(){try{return new d().decode(new u().encode("test"),{stream:!0})==="test"}catch(R){console.debug("TextDecoder does not support streaming option. Using polyfill instead: "+R)}return!1};(d==null||u==null||!_())&&(d=g);var v=function(){};function y(R){this.withCredentials=!1,this.readyState=0,this.status=0,this.statusText="",this.responseText="",this.onprogress=v,this.onload=v,this.onerror=v,this.onreadystatechange=v,this._contentType="",this._xhr=R,this._sendTimeout=0,this._abort=v}y.prototype.open=function(R,O){this._abort(!0);var N=this,L=this._xhr,J=1,K=0;this._abort=function(Y){N._sendTimeout!==0&&(t(N._sendTimeout),N._sendTimeout=0),(J===1||J===2||J===3)&&(J=4,L.onload=v,L.onerror=v,L.onabort=v,L.onprogress=v,L.onreadystatechange=v,L.abort(),K!==0&&(t(K),K=0),Y||(N.readyState=4,N.onabort(null),N.onreadystatechange())),J=0};var se=function(){if(J===1){var Y=0,ve="",kt=void 0;if("contentType"in L)Y=200,ve="OK",kt=L.contentType;else try{Y=L.status,ve=L.statusText,kt=L.getResponseHeader("Content-Type")}catch{Y=0,ve="",kt=void 0}Y!==0&&(J=2,N.readyState=2,N.status=Y,N.statusText=ve,N._contentType=kt,N.onreadystatechange())}},ye=function(){if(se(),J===2||J===3){J=3;var Y="";try{Y=L.responseText}catch{}N.readyState=3,N.responseText=Y,N.onprogress()}},ae=function(Y,ve){if((ve==null||ve.preventDefault==null)&&(ve={preventDefault:v}),ye(),J===1||J===2||J===3){if(J=4,K!==0&&(t(K),K=0),N.readyState=4,Y==="load")N.onload(ve);else if(Y==="error")N.onerror(ve);else if(Y==="abort")N.onabort(ve);else throw new TypeError;N.onreadystatechange()}},pe=function(Y){L!=null&&(L.readyState===4?(!("onload"in L)||!("onerror"in L)||!("onabort"in L))&&ae(L.responseText===""?"error":"load",Y):L.readyState===3?"onprogress"in L||ye():L.readyState===2&&se())},fe=function(){K=e(function(){fe()},500),L.readyState===3&&ye()};"onload"in L&&(L.onload=function(Y){ae("load",Y)}),"onerror"in L&&(L.onerror=function(Y){ae("error",Y)}),"onabort"in L&&(L.onabort=function(Y){ae("abort",Y)}),"onprogress"in L&&(L.onprogress=ye),"onreadystatechange"in L&&(L.onreadystatechange=function(Y){pe(Y)}),("contentType"in L||!("ontimeout"in s.prototype))&&(O+=(O.indexOf("?")===-1?"?":"&")+"padding=true"),L.open(R,O,!0),"readyState"in L&&(K=e(function(){fe()},0))},y.prototype.abort=function(){this._abort(!1)},y.prototype.getResponseHeader=function(R){return this._contentType},y.prototype.setRequestHeader=function(R,O){var N=this._xhr;"setRequestHeader"in N&&N.setRequestHeader(R,O)},y.prototype.getAllResponseHeaders=function(){return this._xhr.getAllResponseHeaders!=null&&this._xhr.getAllResponseHeaders()||""},y.prototype.send=function(){if((!("ontimeout"in s.prototype)||!("sendAsBinary"in s.prototype)&&!("mozAnon"in s.prototype))&&o!=null&&o.readyState!=null&&o.readyState!=="complete"){var R=this;R._sendTimeout=e(function(){R._sendTimeout=0,R.send()},4);return}var O=this._xhr;"withCredentials"in O&&(O.withCredentials=this.withCredentials);try{O.send(void 0)}catch(N){throw N}};function x(R){return R.replace(/[A-Z]/g,function(O){return String.fromCharCode(O.charCodeAt(0)+32)})}function C(R){for(var O=Object.create(null),N=R.split(`\r
13
+ `),L=0;L<N.length;L+=1){var J=N[L],K=J.split(": "),se=K.shift(),ye=K.join(": ");O[x(se)]=ye}this._map=O}C.prototype.get=function(R){return this._map[x(R)]},s!=null&&s.HEADERS_RECEIVED==null&&(s.HEADERS_RECEIVED=2);function S(){}S.prototype.open=function(R,O,N,L,J,K,se){R.open("GET",J);var ye=0;R.onprogress=function(){var pe=R.responseText,fe=pe.slice(ye);ye+=fe.length,N(fe)},R.onerror=function(pe){pe.preventDefault(),L(new Error("NetworkError"))},R.onload=function(){L(null)},R.onabort=function(){L(null)},R.onreadystatechange=function(){if(R.readyState===s.HEADERS_RECEIVED){var pe=R.status,fe=R.statusText,Y=R.getResponseHeader("Content-Type"),ve=R.getAllResponseHeaders();O(pe,fe,Y,new C(ve))}},R.withCredentials=K;for(var ae in se)Object.prototype.hasOwnProperty.call(se,ae)&&R.setRequestHeader(ae,se[ae]);return R.send(),R};function P(R){this._headers=R}P.prototype.get=function(R){return this._headers.get(R)};function E(){}E.prototype.open=function(R,O,N,L,J,K,se){var ye=null,ae=new h,pe=ae.signal,fe=new d;return l(J,{headers:se,credentials:K?"include":"same-origin",signal:pe,cache:"no-store"}).then(function(Y){return ye=Y.body.getReader(),O(Y.status,Y.statusText,Y.headers.get("Content-Type"),new P(Y.headers)),new c(function(ve,kt){var pn=function(){ye.read().then(function(Xe){if(Xe.done)ve(void 0);else{var qe=fe.decode(Xe.value,{stream:!0});N(qe),pn()}}).catch(function(Xe){kt(Xe)})};pn()})}).catch(function(Y){if(Y.name!=="AbortError")return Y}).then(function(Y){L(Y)}),{abort:function(){ye?.cancel(),ae.abort()}}};function k(){this._listeners=Object.create(null)}function G(R){e(function(){throw R},0)}k.prototype.dispatchEvent=function(R){R.target=this;var O=this._listeners[R.type];if(O!=null)for(var N=O.length,L=0;L<N;L+=1){var J=O[L];try{typeof J.handleEvent=="function"?J.handleEvent(R):J.call(this,R)}catch(K){G(K)}}},k.prototype.addEventListener=function(R,O){R=String(R);var N=this._listeners,L=N[R];L==null&&(L=[],N[R]=L);for(var J=!1,K=0;K<L.length;K+=1)L[K]===O&&(J=!0);J||L.push(O)},k.prototype.removeEventListener=function(R,O){R=String(R);var N=this._listeners,L=N[R];if(L!=null){for(var J=[],K=0;K<L.length;K+=1)L[K]!==O&&J.push(L[K]);J.length===0?delete N[R]:N[R]=J}};function Q(R){this.type=R,this.target=void 0}function ce(R,O){Q.call(this,R),this.data=O.data,this.lastEventId=O.lastEventId}ce.prototype=Object.create(Q.prototype);function q(R,O){Q.call(this,R),this.status=O.status,this.statusText=O.statusText,this.headers=O.headers}q.prototype=Object.create(Q.prototype);function _e(R,O){Q.call(this,R),this.error=O.error}_e.prototype=Object.create(Q.prototype);var F=-1,W=0,X=1,M=2,A=-1,z=0,re=1,ie=2,Re=3,dt=/^text\/event\-stream(;.*)?$/i,Le=1e3,Oe=18e6,Ae=function(R,O){var N=R==null?O:parseInt(R,10);return N!==N&&(N=O),it(N)},it=function(R){return Math.min(Math.max(R,Le),Oe)},ge=function(R,O,N){try{typeof O=="function"&&O.call(R,N)}catch(L){G(L)}};function Ge(R,O){k.call(this),O=O||{},this.onopen=void 0,this.onmessage=void 0,this.onerror=void 0,this.url=void 0,this.readyState=void 0,this.withCredentials=void 0,this.headers=void 0,this._close=void 0,xr(this,R,O)}function br(){return s!=null&&"withCredentials"in s.prototype||r==null?new s:new r}var wr=l!=null&&p!=null&&"body"in p.prototype;function xr(R,O,N){O=String(O);var L=!!N.withCredentials,J=N.lastEventIdQueryParameterName||"lastEventId",K=it(1e3),se=Ae(N.heartbeatTimeout,45e3),ye="",ae=K,pe=!1,fe=0,Y=N.headers||{},ve=N.Transport,kt=wr&&ve==null?void 0:new y(ve!=null?new ve:br()),pn=ve!=null&&typeof ve!="string"?new ve:kt==null?new E:new S,Xe=void 0,qe=0,ut=F,Ss="",Er="",Pt="",Cr="",ze=z,pa=0,ts=0,df=function(ke,Ce,Ze,et){if(ut===W)if(ke===200&&Ze!=null&&dt.test(Ze)){ut=X,pe=Date.now(),ae=K,R.readyState=X;var $e=new q("open",{status:ke,statusText:Ce,headers:et});R.dispatchEvent($e),ge(R,R.onopen,$e)}else{var Fe="";ke!==200?(Ce&&(Ce=Ce.replace(/\s+/g," ")),Fe="EventSource's response has a status "+ke+" "+Ce+" that is not 200. Aborting the connection."):Fe="EventSource's response has a Content-Type specifying an unsupported type: "+(Ze==null?"-":Ze.replace(/\s+/g," "))+". Aborting the connection.",da();var $e=new q("error",{status:ke,statusText:Ce,headers:et});R.dispatchEvent($e),ge(R,R.onerror,$e),console.error(Fe)}},uf=function(ke){if(ut===X){for(var Ce=-1,Ze=0;Ze<ke.length;Ze+=1){var et=ke.charCodeAt(Ze);(et===10||et===13)&&(Ce=Ze)}var $e=(Ce!==-1?Cr:"")+ke.slice(0,Ce+1);Cr=(Ce===-1?Cr:"")+ke.slice(Ce+1),ke!==""&&(pe=Date.now(),fe+=ke.length);for(var Fe=0;Fe<$e.length;Fe+=1){var et=$e.charCodeAt(Fe);if(ze===A&&et===10)ze=z;else if(ze===A&&(ze=z),et===13||et===10){if(ze!==z){ze===re&&(ts=Fe+1);var Mt=$e.slice(pa,ts-1),It=$e.slice(ts+(ts<Fe&&$e.charCodeAt(ts)===32?1:0),Fe);Mt==="data"?(Ss+=`
14
+ `,Ss+=It):Mt==="id"?Er=It:Mt==="event"?Pt=It:Mt==="retry"?(K=Ae(It,K),ae=K):Mt==="heartbeatTimeout"&&(se=Ae(It,se),qe!==0&&(t(qe),qe=e(function(){dn()},se)))}if(ze===z){if(Ss!==""){ye=Er,Pt===""&&(Pt="message");var Rs=new ce(Pt,{data:Ss.slice(1),lastEventId:Er});if(R.dispatchEvent(Rs),Pt==="open"?ge(R,R.onopen,Rs):Pt==="message"?ge(R,R.onmessage,Rs):Pt==="error"&&ge(R,R.onerror,Rs),ut===M)return}Ss="",Pt=""}ze=et===13?A:z}else ze===z&&(pa=Fe,ze=re),ze===re?et===58&&(ts=Fe+1,ze=ie):ze===ie&&(ze=Re)}}},Nc=function(ke){if(ut===X||ut===W){ut=F,qe!==0&&(t(qe),qe=0),qe=e(function(){dn()},ae),ae=it(Math.min(K*16,ae*2)),R.readyState=W;var Ce=new _e("error",{error:ke});R.dispatchEvent(Ce),ge(R,R.onerror,Ce),ke!=null&&console.error(ke)}},da=function(){ut=M,Xe!=null&&(Xe.abort(),Xe=void 0),qe!==0&&(t(qe),qe=0),R.readyState=M},dn=function(){if(qe=0,ut!==F){if(!pe&&Xe!=null)Nc(new Error("No activity within "+se+" milliseconds. "+(ut===W?"No response received.":fe+" chars received.")+" Reconnecting.")),Xe!=null&&(Xe.abort(),Xe=void 0);else{var ke=Math.max((pe||Date.now())+se-Date.now(),1);pe=!1,qe=e(function(){dn()},ke)}return}pe=!1,fe=0,qe=e(function(){dn()},se),ut=W,Ss="",Pt="",Er=ye,Cr="",pa=0,ts=0,ze=z;var Ce=O;if(O.slice(0,5)!=="data:"&&O.slice(0,5)!=="blob:"&&ye!==""){var Ze=O.indexOf("?");Ce=Ze===-1?O:O.slice(0,Ze+1)+O.slice(Ze+1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g,function(It,Rs){return Rs===J?"":It}),Ce+=(O.indexOf("?")===-1?"?":"&")+J+"="+encodeURIComponent(ye)}var et=R.withCredentials,$e={};$e.Accept="text/event-stream";var Fe=R.headers;if(Fe!=null)for(var Mt in Fe)Object.prototype.hasOwnProperty.call(Fe,Mt)&&($e[Mt]=Fe[Mt]);try{Xe=pn.open(kt,df,uf,Nc,Ce,et,$e)}catch(It){throw da(),It}};R.url=O,R.readyState=W,R.withCredentials=L,R.headers=Y,R._close=da,dn()}Ge.prototype=Object.create(k.prototype),Ge.prototype.CONNECTING=W,Ge.prototype.OPEN=X,Ge.prototype.CLOSED=M,Ge.prototype.close=function(){this._close()},Ge.CONNECTING=W,Ge.OPEN=X,Ge.CLOSED=M,Ge.prototype.withCredentials=void 0;var Gc=a;s!=null&&(a==null||!("withCredentials"in a.prototype))&&(Gc=Ge),(function(R){if(typeof Ri=="object"&&typeof Ri.exports=="object"){var O=R(pc);O!==void 0&&(Ri.exports=O)}else typeof define=="function"&&define.amd?define(["exports"],R):R(n)})(function(R){R.EventSourcePolyfill=Ge,R.NativeEventSource=a,R.EventSource=Gc})})(typeof globalThis>"u"?typeof window<"u"?window:typeof self<"u"?self:pc:globalThis)});var af={};Rr(af,{AddMessages:()=>ea,ArchiveBlobAad:()=>ta,ArchiveKeyWrapInfo:()=>sa,ArchivedMessage:()=>fr,ArchivedSenderData:()=>na,CommitBundle:()=>Je,EncryptedArchiveBlob:()=>ra,ExportedEpochArchiveV2:()=>ia,ExternalJoinResult:()=>aa,Group:()=>oa,HpkeWrappedArchiveDataKey:()=>gr,Identity:()=>he,KeyPackage:()=>es,MemberInfo:()=>_r,MessageType:()=>Mx,MlsError:()=>Fc,MlsErrorCode:()=>Ix,ProcessedMessage:()=>ca,ProposalMessage:()=>Zt,Provider:()=>$,RatchetTree:()=>xs,RecoveryKeypair:()=>la,WrappedRecoveryKey:()=>yr,decrypt_archive_blob:()=>_x,decrypt_with_epoch_archive:()=>Px,decrypt_with_epoch_archive_v2:()=>Ax,default:()=>Dx,encrypt_archive_blob:()=>yx,generate_recovery_keypair:()=>gx,greet:()=>Cx,hash_channel_id:()=>Rx,init:()=>Sx,initSync:()=>Ux,peek_sender_data_from_archive:()=>kx,unwrap_archive_data_key:()=>xx,unwrap_archive_data_key_from_parts:()=>vx,unwrap_recovery_private_key:()=>Ex,validate_key_package_bytes:()=>fx,wrap_archive_data_key:()=>bx,wrap_recovery_private_key:()=>wx});function ln(){return(ur===null||ur.byteLength===0)&&(ur=new Uint8Array(f.memory.buffer)),ur}function Ye(n,e){return n=n>>>0,tf.decode(ln().subarray(n,n+e))}function cn(n){let e=f.__externref_table_alloc();return f.__wbindgen_export_2.set(e,n),e}function dr(n,e){try{return n.apply(this,e)}catch(t){let s=cn(t);f.__wbindgen_exn_store(s)}}function me(n,e,t){if(t===void 0){let o=Zi.encode(n),c=e(o.length,1)>>>0;return ln().subarray(c,c+o.length).set(o),T=o.length,c}let s=n.length,r=e(s,1)>>>0,i=ln(),a=0;for(;a<s;a++){let o=n.charCodeAt(a);if(o>127)break;i[r+a]=o}if(a!==s){a!==0&&(n=n.slice(a)),r=t(r,s,s=a+n.length*3,1)>>>0;let o=ln().subarray(r+a,r+s),c=ux(n,o);a+=c.written,r=t(r,s,a,1)>>>0}return T=a,r}function Xt(){return(bs===null||bs.buffer.detached===!0||bs.buffer.detached===void 0&&bs.buffer!==f.memory.buffer)&&(bs=new DataView(f.memory.buffer)),bs}function ws(n){return n==null}function Oc(n){let e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){let r=n.description;return r==null?"Symbol":`Symbol(${r})`}if(e=="function"){let r=n.name;return typeof r=="string"&&r.length>0?`Function(${r})`:"Function"}if(Array.isArray(n)){let r=n.length,i="[";r>0&&(i+=Oc(n[0]));for(let a=1;a<r;a++)i+=", "+Oc(n[a]);return i+="]",i}let t=/\[object ([^\]]+)\]/.exec(toString.call(n)),s;if(t&&t.length>1)s=t[1];else return toString.call(n);if(s=="Object")try{return"Object("+JSON.stringify(n)+")"}catch{return"Object"}return n instanceof Error?`${n.name}: ${n.message}
15
+ ${n.stack}`:s}function H(n,e){return n=n>>>0,ln().subarray(n/1,n/1+e)}function I(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`)}function j(n){let e=f.__wbindgen_export_2.get(n);return f.__externref_table_dealloc(n),e}function te(n,e){let t=e(n.length*1,1)>>>0;return ln().set(n,t/1),T=n.length,t}function hr(n,e){n=n>>>0;let t=Xt(),s=[];for(let r=n;r<n+4*e;r+=4)s.push(f.__wbindgen_export_2.get(t.getUint32(r,!0)));return f.__externref_drop_slice(n,e),s}function yt(n,e){let t=e(n.length*4,4)>>>0;for(let s=0;s<n.length;s++){let r=cn(n[s]);Xt().setUint32(t+4*s,r,!0)}return T=n.length,t}function hx(){return(mr===null||mr.byteLength===0)&&(mr=new Uint32Array(f.memory.buffer)),mr}function mx(n,e){let t=e(n.length*4,4)>>>0;return hx().set(n,t/4),T=n.length,t}function fx(n){let e=te(n,f.__wbindgen_malloc),t=T;return f.validate_key_package_bytes(e,t)!==0}function gx(n){I(n,$);let e=f.generate_recovery_keypair(n.__wbg_ptr);if(e[2])throw j(e[1]);return la.__wrap(e[0])}function _x(n,e,t,s,r){I(n,$);let i=te(e,f.__wbindgen_malloc),a=T,o=te(t,f.__wbindgen_malloc),c=T,l=te(s,f.__wbindgen_malloc),p=T,d=te(r,f.__wbindgen_malloc),u=T,h=f.decrypt_archive_blob(n.__wbg_ptr,i,a,o,c,l,p,d,u);if(h[3])throw j(h[2]);var m=H(h[0],h[1]).slice();return f.__wbindgen_free(h[0],h[1]*1,1),m}function yx(n,e,t){I(n,$);let s=te(e,f.__wbindgen_malloc),r=T;I(t,ta);let i=f.encrypt_archive_blob(n.__wbg_ptr,s,r,t.__wbg_ptr);if(i[2])throw j(i[1]);return ra.__wrap(i[0])}function vx(n,e,t,s,r){I(n,$);let i=te(e,f.__wbindgen_malloc),a=T,o=te(t,f.__wbindgen_malloc),c=T,l=te(s,f.__wbindgen_malloc),p=T,d=te(r,f.__wbindgen_malloc),u=T,h=f.unwrap_archive_data_key_from_parts(n.__wbg_ptr,i,a,o,c,l,p,d,u);if(h[3])throw j(h[2]);var m=H(h[0],h[1]).slice();return f.__wbindgen_free(h[0],h[1]*1,1),m}function bx(n,e,t,s){I(n,$);let r=te(e,f.__wbindgen_malloc),i=T,a=te(t,f.__wbindgen_malloc),o=T;I(s,sa);let c=f.wrap_archive_data_key(n.__wbg_ptr,r,i,a,o,s.__wbg_ptr);if(c[2])throw j(c[1]);return gr.__wrap(c[0])}function wx(n,e,t,s,r,i,a){I(n,$);let o=me(e,f.__wbindgen_malloc,f.__wbindgen_realloc),c=T,l=te(t,f.__wbindgen_malloc),p=T,d=te(s,f.__wbindgen_malloc),u=T,h=me(r,f.__wbindgen_malloc,f.__wbindgen_realloc),m=T,g=f.wrap_recovery_private_key(n.__wbg_ptr,o,c,l,p,d,u,h,m,i,a);if(g[2])throw j(g[1]);return yr.__wrap(g[0])}function xx(n,e,t){I(n,$);let s=te(e,f.__wbindgen_malloc),r=T;I(t,gr);let i=f.unwrap_archive_data_key(n.__wbg_ptr,s,r,t.__wbg_ptr);if(i[3])throw j(i[2]);var a=H(i[0],i[1]).slice();return f.__wbindgen_free(i[0],i[1]*1,1),a}function Ex(n,e,t){I(n,$);let s=me(e,f.__wbindgen_malloc,f.__wbindgen_realloc),r=T;I(t,yr);let i=f.unwrap_recovery_private_key(n.__wbg_ptr,s,r,t.__wbg_ptr);if(i[3])throw j(i[2]);var a=H(i[0],i[1]).slice();return f.__wbindgen_free(i[0],i[1]*1,1),a}function Cx(){f.greet()}function Sx(){f.init()}function Rx(n,e){let t,s;try{let r=me(n,f.__wbindgen_malloc,f.__wbindgen_realloc),i=T,a=yt(e,f.__wbindgen_malloc),o=T,c=f.hash_channel_id(r,i,a,o);return t=c[0],s=c[1],Ye(c[0],c[1])}finally{f.__wbindgen_free(t,s,1)}}function Ax(n,e,t,s,r,i){I(n,$);let a=te(e,f.__wbindgen_malloc),o=T,c=te(t,f.__wbindgen_malloc),l=T,p=te(s,f.__wbindgen_malloc),d=T,u=f.decrypt_with_epoch_archive_v2(n.__wbg_ptr,a,o,c,l,p,d,r,i);if(u[2])throw j(u[1]);return fr.__wrap(u[0])}function kx(n,e,t){I(n,$);let s=te(e,f.__wbindgen_malloc),r=T,i=te(t,f.__wbindgen_malloc),a=T,o=f.peek_sender_data_from_archive(n.__wbg_ptr,s,r,i,a);if(o[2])throw j(o[1]);return na.__wrap(o[0])}function Px(n,e,t,s,r){I(n,$);let i=te(e,f.__wbindgen_malloc),a=T,o=te(t,f.__wbindgen_malloc),c=T,l=f.decrypt_with_epoch_archive(n.__wbg_ptr,i,a,o,c,s,r);if(l[2])throw j(l[1]);return fr.__wrap(l[0])}async function Tx(n,e){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(s){if(n.headers.get("Content-Type")!="application/wasm")globalThis.__ermisSdkLog?.("warn","`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",s);else throw s}let t=await n.arrayBuffer();return await WebAssembly.instantiate(t,e)}else{let t=await WebAssembly.instantiate(n,e);return t instanceof WebAssembly.Instance?{instance:t,module:n}:t}}function sf(){let n={};return n.wbg={},n.wbg.__wbg_alert_28f254ad01ccf9c4=function(e,t){alert(Ye(e,t))},n.wbg.__wbg_buffer_609cc3eee51ed158=function(e){return e.buffer},n.wbg.__wbg_call_672a4d21634d4a24=function(){return dr(function(e,t){return e.call(t)},arguments)},n.wbg.__wbg_call_7cccdd69e0791ae2=function(){return dr(function(e,t,s){return e.call(t,s)},arguments)},n.wbg.__wbg_crypto_574e78ad8b13b65f=function(e){return e.crypto},n.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,t){let s,r;try{s=e,r=t,globalThis.__ermisSdkLog?.("error",Ye(e,t))}finally{f.__wbindgen_free(s,r,1)}},n.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e=function(){return dr(function(e,t){e.getRandomValues(t)},arguments)},n.wbg.__wbg_keypackage_new=function(e){return es.__wrap(e)},n.wbg.__wbg_keypackage_unwrap=function(e){return es.__unwrap(e)},n.wbg.__wbg_memberinfo_new=function(e){return _r.__wrap(e)},n.wbg.__wbg_msCrypto_a61aeb35a24c1329=function(e){return e.msCrypto},n.wbg.__wbg_new_8a6f238a6ece86ea=function(){return new Error},n.wbg.__wbg_new_a12002a7f91c75be=function(e){return new Uint8Array(e)},n.wbg.__wbg_newnoargs_105ed471475aaf50=function(e,t){return new Function(Ye(e,t))},n.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a=function(e,t,s){return new Uint8Array(e,t>>>0,s>>>0)},n.wbg.__wbg_newwithlength_a381634e90c276d4=function(e){return new Uint8Array(e>>>0)},n.wbg.__wbg_node_905d3e251edff8a2=function(e){return e.node},n.wbg.__wbg_now_807e54c39636c349=function(){return Date.now()},n.wbg.__wbg_process_dc0fbacc7c1c06f7=function(e){return e.process},n.wbg.__wbg_proposalmessage_new=function(e){return Zt.__wrap(e)},n.wbg.__wbg_randomFillSync_ac0988aba3254290=function(){return dr(function(e,t){e.randomFillSync(t)},arguments)},n.wbg.__wbg_require_60cc747a6bc5215a=function(){return dr(function(){return module.require},arguments)},n.wbg.__wbg_set_65595bdd868b3009=function(e,t,s){e.set(t,s>>>0)},n.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,t){let s=t.stack,r=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),i=T;Xt().setInt32(e+4,i,!0),Xt().setInt32(e+0,r,!0)},n.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07=function(){let e=typeof global>"u"?null:global;return ws(e)?0:cn(e)},n.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0=function(){let e=typeof globalThis>"u"?null:globalThis;return ws(e)?0:cn(e)},n.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819=function(){let e=typeof self>"u"?null:self;return ws(e)?0:cn(e)},n.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40=function(){let e=typeof window>"u"?null:window;return ws(e)?0:cn(e)},n.wbg.__wbg_subarray_aa9065fa9dc5df96=function(e,t,s){return e.subarray(t>>>0,s>>>0)},n.wbg.__wbg_versions_c01dfd4722a88165=function(e){return e.versions},n.wbg.__wbindgen_debug_string=function(e,t){let s=Oc(t),r=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),i=T;Xt().setInt32(e+4,i,!0),Xt().setInt32(e+0,r,!0)},n.wbg.__wbindgen_error_new=function(e,t){return new Error(Ye(e,t))},n.wbg.__wbindgen_init_externref_table=function(){let e=f.__wbindgen_export_2,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)},n.wbg.__wbindgen_is_function=function(e){return typeof e=="function"},n.wbg.__wbindgen_is_object=function(e){let t=e;return typeof t=="object"&&t!==null},n.wbg.__wbindgen_is_string=function(e){return typeof e=="string"},n.wbg.__wbindgen_is_undefined=function(e){return e===void 0},n.wbg.__wbindgen_memory=function(){return f.memory},n.wbg.__wbindgen_string_get=function(e,t){let s=t,r=typeof s=="string"?s:void 0;var i=ws(r)?0:me(r,f.__wbindgen_malloc,f.__wbindgen_realloc),a=T;Xt().setInt32(e+4,a,!0),Xt().setInt32(e+0,i,!0)},n.wbg.__wbindgen_string_new=function(e,t){return Ye(e,t)},n.wbg.__wbindgen_throw=function(e,t){throw new Error(Ye(e,t))},n}function nf(n,e){return f=n.exports,rf.__wbindgen_wasm_module=e,bs=null,mr=null,ur=null,f.__wbindgen_start(),f}function Ux(n){if(f!==void 0)return f;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:globalThis.__ermisSdkLog?.("warn","using deprecated parameters for `initSync()`; pass a single object instead"));let e=sf();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));let t=new WebAssembly.Instance(n,e);return nf(t,n)}async function rf(n){if(f!==void 0)return f;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:globalThis.__ermisSdkLog?.("warn","using deprecated parameters for the initialization function; pass a single object instead")),typeof n>"u"&&(n=new URL("openmls_wasm_bg.wasm",Lx.url));let e=sf();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:t,module:s}=await Tx(await n,e);return nf(t,s)}var Lx,f,tf,ur,T,Zi,ux,bs,mr,Mx,Ix,Om,ea,Fm,ta,Bm,sa,jm,fr,Gm,na,Nm,Je,qm,ra,zm,ia,$m,aa,Wm,oa,Vm,gr,Dc,he,Km,es,Hm,_r,Qm,Fc,Jm,ca,Ym,Zt,Lc,$,Xm,xs,Zm,la,ef,yr,Dx,of=qc(()=>{"use strict";Lx={},tf=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&tf.decode();ur=null;T=0,Zi=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},ux=typeof Zi.encodeInto=="function"?function(n,e){return Zi.encodeInto(n,e)}:function(n,e){let t=Zi.encode(n);return e.set(t),{read:n.length,written:t.length}};bs=null;mr=null;Mx=Object.freeze({ApplicationMessage:0,0:"ApplicationMessage",Proposal:1,1:"Proposal",Commit:2,2:"Commit"}),Ix=Object.freeze({SerializationError:0,0:"SerializationError",DeserializationError:1,1:"DeserializationError",GroupNotOperational:2,2:"GroupNotOperational",MemberNotFound:3,3:"MemberNotFound",InvalidMessage:4,4:"InvalidMessage",NoWelcome:5,5:"NoWelcome",InvalidCid:6,6:"InvalidCid",StorageError:7,7:"StorageError",CryptoError:8,8:"CryptoError",InvalidState:9,9:"InvalidState",ExternalCommitError:10,10:"ExternalCommitError"}),Om=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_addmessages_free(n>>>0,1)),ea=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Om.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Om.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_addmessages_free(e,0)}get group_info(){let e=f.addmessages_group_info(this.__wbg_ptr),t;return e[0]!==0&&(t=H(e[0],e[1]).slice(),f.__wbindgen_free(e[0],e[1]*1,1)),t}get commit(){return f.addmessages_commit(this.__wbg_ptr)}get welcome(){return f.addmessages_welcome(this.__wbg_ptr)}get proposal(){return f.addmessages_proposal(this.__wbg_ptr)}},Fm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_archiveblobaad_free(n>>>0,1)),ta=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Fm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_archiveblobaad_free(e,0)}constructor(e,t,s,r,i){let a=me(e,f.__wbindgen_malloc,f.__wbindgen_realloc),o=T,c=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),l=T,p=me(r,f.__wbindgen_malloc,f.__wbindgen_realloc),d=T,u=me(i,f.__wbindgen_malloc,f.__wbindgen_realloc),h=T,m=f.archiveblobaad_new(a,o,t,c,l,p,d,u,h);return this.__wbg_ptr=m>>>0,Fm.register(this,this.__wbg_ptr,this),this}to_bytes(){let e=f.archiveblobaad_to_bytes(this.__wbg_ptr);if(e[3])throw j(e[2]);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Bm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_archivekeywrapinfo_free(n>>>0,1)),sa=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Bm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_archivekeywrapinfo_free(e,0)}constructor(e,t,s,r,i,a){let o=me(e,f.__wbindgen_malloc,f.__wbindgen_realloc),c=T,l=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),p=T,d=me(r,f.__wbindgen_malloc,f.__wbindgen_realloc),u=T,h=me(i,f.__wbindgen_malloc,f.__wbindgen_realloc),m=T,g=me(a,f.__wbindgen_malloc,f.__wbindgen_realloc),_=T,v=f.archivekeywrapinfo_new(o,c,t,l,p,d,u,h,m,g,_);return this.__wbg_ptr=v>>>0,Bm.register(this,this.__wbg_ptr,this),this}to_bytes(){let e=f.archivekeywrapinfo_to_bytes(this.__wbg_ptr);if(e[3])throw j(e[2]);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},jm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_archivedmessage_free(n>>>0,1)),fr=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,jm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,jm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_archivedmessage_free(e,0)}get generation(){return f.archivedmessage_generation(this.__wbg_ptr)>>>0}get own_message(){return f.archivedmessage_own_message(this.__wbg_ptr)!==0}get sender_index(){return f.archivedmessage_sender_index(this.__wbg_ptr)>>>0}get aad(){let e=f.archivedmessage_aad(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get epoch(){let e=f.archivedmessage_epoch(this.__wbg_ptr);return BigInt.asUintN(64,e)}get content(){let e=f.archivedmessage_content(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Gm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_archivedsenderdata_free(n>>>0,1)),na=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Gm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Gm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_archivedsenderdata_free(e,0)}get generation(){return f.archivedsenderdata_generation(this.__wbg_ptr)>>>0}get own_message(){return f.archivedsenderdata_own_message(this.__wbg_ptr)!==0}get content_type(){let e,t;try{let s=f.archivedsenderdata_content_type(this.__wbg_ptr);return e=s[0],t=s[1],Ye(s[0],s[1])}finally{f.__wbindgen_free(e,t,1)}}get sender_index(){return f.archivedsenderdata_sender_index(this.__wbg_ptr)>>>0}get epoch(){let e=f.archivedmessage_epoch(this.__wbg_ptr);return BigInt.asUintN(64,e)}},Nm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_commitbundle_free(n>>>0,1)),Je=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Nm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Nm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_commitbundle_free(e,0)}get group_info(){let e=f.commitbundle_group_info(this.__wbg_ptr),t;return e[0]!==0&&(t=H(e[0],e[1]).slice(),f.__wbindgen_free(e[0],e[1]*1,1)),t}has_welcome(){return f.commitbundle_has_welcome(this.__wbg_ptr)!==0}commit_as_uint8array(){return f.commitbundle_commit_as_uint8array(this.__wbg_ptr)}welcome_as_uint8array(){return f.commitbundle_welcome_as_uint8array(this.__wbg_ptr)}get commit(){let e=f.commitbundle_commit(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get welcome(){let e=f.commitbundle_welcome(this.__wbg_ptr),t;return e[0]!==0&&(t=H(e[0],e[1]).slice(),f.__wbindgen_free(e[0],e[1]*1,1)),t}},qm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_encryptedarchiveblob_free(n>>>0,1)),ra=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,qm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,qm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_encryptedarchiveblob_free(e,0)}get ciphertext(){let e=f.encryptedarchiveblob_ciphertext(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get adk(){let e=f.encryptedarchiveblob_adk(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get nonce(){let e=f.encryptedarchiveblob_nonce(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get aead_aad(){let e=f.encryptedarchiveblob_aead_aad(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},zm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_exportedepocharchivev2_free(n>>>0,1)),ia=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,zm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,zm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_exportedepocharchivev2_free(e,0)}get archive_bytes(){let e=f.exportedepocharchivev2_archive_bytes(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get snapshot_hash(){let e=f.exportedepocharchivev2_snapshot_hash(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get snapshot_bytes(){let e=f.exportedepocharchivev2_snapshot_bytes(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},$m=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_externaljoinresult_free(n>>>0,1)),aa=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,$m.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,$m.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_externaljoinresult_free(e,0)}get group(){let e=f.externaljoinresult_group(this.__wbg_ptr);return e===0?void 0:oa.__wrap(e)}get commit(){let e=f.externaljoinresult_commit(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Wm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_group_free(n>>>0,1)),oa=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Wm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Wm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_group_free(e,0)}static create_new(e,t,s){I(e,$),I(t,he);let r=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),i=T,a=f.group_create_new(e.__wbg_ptr,t.__wbg_ptr,r,i);return n.__wrap(a)}save_state(e){I(e,$);let t=f.group_save_state(this.__wbg_ptr,e.__wbg_ptr);if(t[1])throw j(t[0])}delete_state(e){I(e,$);let t=f.group_delete_state(this.__wbg_ptr,e.__wbg_ptr);if(t[1])throw j(t[0])}static join_external(e,t,s,r){I(e,$),I(t,he);let i=te(s,f.__wbindgen_malloc),a=T,o=0;ws(r)||(I(r,xs),o=r.__destroy_into_raw());let c=f.group_join_external(e.__wbg_ptr,t.__wbg_ptr,i,a,o);if(c[2])throw j(c[1]);return aa.__wrap(c[0])}static create_with_cid(e,t,s){I(e,$),I(t,he);let r=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),i=T,a=f.group_create_with_cid(e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return n.__wrap(a[0])}static join_with_welcome(e,t,s){I(e,$);let r=te(t,f.__wbindgen_malloc),i=T,a=0;ws(s)||(I(s,xs),a=s.__destroy_into_raw());let o=f.group_join_with_welcome(e.__wbg_ptr,r,i,a);if(o[2])throw j(o[1]);return n.__wrap(o[0])}static join(e,t,s){I(e,$);let r=te(t,f.__wbindgen_malloc),i=T;I(s,xs);var a=s.__destroy_into_raw();let o=f.group_join(e.__wbg_ptr,r,i,a);if(o[2])throw j(o[1]);return n.__wrap(o[0])}static load(e,t){I(e,$);let s=me(t,f.__wbindgen_malloc,f.__wbindgen_realloc),r=T,i=f.group_load(e.__wbg_ptr,s,r);if(i[2])throw j(i[1]);return n.__wrap(i[0])}export_key(e,t,s,r){I(e,$);let i=me(t,f.__wbindgen_malloc,f.__wbindgen_realloc),a=T,o=te(s,f.__wbindgen_malloc),c=T,l=f.group_export_key(this.__wbg_ptr,e.__wbg_ptr,i,a,o,c,r);if(l[3])throw j(l[2]);var p=H(l[0],l[1]).slice();return f.__wbindgen_free(l[0],l[1]*1,1),p}is_operational(){return f.group_is_operational(this.__wbg_ptr)!==0}own_leaf_index(){return f.group_own_leaf_index(this.__wbg_ptr)>>>0}archive_epoch_v2(){let e=f.group_archive_epoch_v2(this.__wbg_ptr);if(e[2])throw j(e[1]);return ia.__wrap(e[0])}export_group_info(e,t,s){I(e,$),I(t,he);let r=f.group_export_group_info(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,s);if(r[3])throw j(r[2]);var i=H(r[0],r[1]).slice();return f.__wbindgen_free(r[0],r[1]*1,1),i}member_by_user_id(e){let t=me(e,f.__wbindgen_malloc,f.__wbindgen_realloc),s=T,r=f.group_member_by_user_id(this.__wbg_ptr,t,s);return r===0?void 0:_r.__wrap(r)}has_pending_commit(){return f.group_has_pending_commit(this.__wbg_ptr)!==0}members_by_user_id(e){let t=me(e,f.__wbindgen_malloc,f.__wbindgen_realloc),s=T,r=f.group_members_by_user_id(this.__wbg_ptr,t,s);var i=hr(r[0],r[1]).slice();return f.__wbindgen_free(r[0],r[1]*4,4),i}export_ratchet_tree(){let e=f.group_export_ratchet_tree(this.__wbg_ptr);return xs.__wrap(e)}archive_current_epoch(){let e=f.group_archive_current_epoch(this.__wbg_ptr);if(e[3])throw j(e[2]);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}cid(){let e,t;try{let i=f.group_cid(this.__wbg_ptr);var s=i[0],r=i[1];if(i[3])throw s=0,r=0,j(i[2]);return e=s,t=r,Ye(s,r)}finally{f.__wbindgen_free(e,t,1)}}epoch(){let e=f.group_epoch(this.__wbg_ptr);return BigInt.asUintN(64,e)}members(){let e=f.group_members(this.__wbg_ptr);var t=hr(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*4,4),t}group_id(){let e=f.group_group_id(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}add_members(e,t,s){I(e,$),I(t,he);let r=yt(s,f.__wbindgen_malloc),i=T,a=f.group_add_members(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return Je.__wrap(a[0])}remove_user(e,t,s){I(e,$),I(t,he);let r=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),i=T,a=f.group_remove_user(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return Je.__wrap(a[0])}self_update(e,t){I(e,$),I(t,he);let s=f.group_self_update(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr);if(s[2])throw j(s[1]);return Je.__wrap(s[0])}remove_users(e,t,s){I(e,$),I(t,he);let r=yt(s,f.__wbindgen_malloc),i=T,a=f.group_remove_users(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return Je.__wrap(a[0])}remove_members(e,t,s){I(e,$),I(t,he);let r=mx(s,f.__wbindgen_malloc),i=T,a=f.group_remove_members(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return Je.__wrap(a[0])}clear_pending_commit(e){I(e,$);let t=f.group_clear_pending_commit(this.__wbg_ptr,e.__wbg_ptr);if(t[1])throw j(t[0])}commit_group_changes(e,t,s,r,i){I(e,$),I(t,he);let a=yt(s,f.__wbindgen_malloc),o=T,c=yt(r,f.__wbindgen_malloc),l=T,p=f.group_commit_group_changes(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,a,o,c,l,i);if(p[2])throw j(p[1]);return Je.__wrap(p[0])}merge_pending_commit(e){I(e,$);let t=f.group_merge_pending_commit(this.__wbg_ptr,e.__wbg_ptr);if(t[1])throw j(t[0])}commit_member_removals(e,t,s){I(e,$),I(t,he);let r=yt(s,f.__wbindgen_malloc),i=T,a=f.group_commit_member_removals(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return Je.__wrap(a[0])}propose_and_commit_add(e,t,s){I(e,$),I(t,he),I(s,es);let r=f.group_propose_and_commit_add(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,s.__wbg_ptr);if(r[2])throw j(r[1]);return ea.__wrap(r[0])}commit_pending_proposals(e,t){I(e,$),I(t,he);let s=f.group_commit_pending_proposals(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr);if(s[2])throw j(s[1]);return Je.__wrap(s[0])}commit_member_add_with_removals(e,t,s,r){I(e,$),I(t,he);let i=yt(s,f.__wbindgen_malloc),a=T,o=yt(r,f.__wbindgen_malloc),c=T,l=f.group_commit_member_add_with_removals(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i,a,o,c);if(l[2])throw j(l[1]);return Je.__wrap(l[0])}commit_self_update_with_removals(e,t,s){I(e,$),I(t,he);let r=yt(s,f.__wbindgen_malloc),i=T,a=f.group_commit_self_update_with_removals(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return Je.__wrap(a[0])}add_user(e,t,s){I(e,$),I(t,he);let r=yt(s,f.__wbindgen_malloc),i=T,a=f.group_add_user(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return Je.__wrap(a[0])}leave_group(e,t){I(e,$),I(t,he);let s=f.group_leave_group(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr);if(s[3])throw j(s[2]);var r=H(s[0],s[1]).slice();return f.__wbindgen_free(s[0],s[1]*1,1),r}propose_add_user(e,t,s){I(e,$),I(t,he);let r=yt(s,f.__wbindgen_malloc),i=T,a=f.group_propose_add_user(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[3])throw j(a[2]);var o=hr(a[0],a[1]).slice();return f.__wbindgen_free(a[0],a[1]*4,4),o}propose_add_member(e,t,s){I(e,$),I(t,he),I(s,es);let r=f.group_propose_add_member(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,s.__wbg_ptr);if(r[2])throw j(r[1]);return Zt.__wrap(r[0])}propose_remove_user(e,t,s){I(e,$),I(t,he);let r=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),i=T,a=f.group_propose_remove_user(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[3])throw j(a[2]);var o=hr(a[0],a[1]).slice();return f.__wbindgen_free(a[0],a[1]*4,4),o}propose_self_update(e,t){I(e,$),I(t,he);let s=f.group_propose_self_update(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr);if(s[2])throw j(s[1]);return Zt.__wrap(s[0])}propose_remove_member(e,t,s){I(e,$),I(t,he);let r=f.group_propose_remove_member(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,s);if(r[2])throw j(r[1]);return Zt.__wrap(r[0])}clear_pending_proposals(e){I(e,$);let t=f.group_clear_pending_proposals(this.__wbg_ptr,e.__wbg_ptr);if(t[1])throw j(t[0])}pending_proposals_count(){return f.group_pending_proposals_count(this.__wbg_ptr)>>>0}propose_remove_member_by_user_id(e,t,s){I(e,$),I(t,he);let r=me(s,f.__wbindgen_malloc,f.__wbindgen_realloc),i=T,a=f.group_propose_remove_member_by_user_id(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw j(a[1]);return Zt.__wrap(a[0])}create_message(e,t,s){I(e,$),I(t,he);let r=te(s,f.__wbindgen_malloc),i=T,a=f.group_create_message(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[3])throw j(a[2]);var o=H(a[0],a[1]).slice();return f.__wbindgen_free(a[0],a[1]*1,1),o}process_message(e,t){I(e,$);let s=te(t,f.__wbindgen_malloc),r=T,i=f.group_process_message(this.__wbg_ptr,e.__wbg_ptr,s,r);if(i[2])throw j(i[1]);return ca.__wrap(i[0])}process_message_raw(e,t){I(e,$);let s=te(t,f.__wbindgen_malloc),r=T,i=f.group_process_message_raw(this.__wbg_ptr,e.__wbg_ptr,s,r);if(i[3])throw j(i[2]);var a=H(i[0],i[1]).slice();return f.__wbindgen_free(i[0],i[1]*1,1),a}create_message_with_aad(e,t,s,r){I(e,$),I(t,he);let i=te(s,f.__wbindgen_malloc),a=T,o=te(r,f.__wbindgen_malloc),c=T,l=f.group_create_message_with_aad(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,i,a,o,c);if(l[3])throw j(l[2]);var p=H(l[0],l[1]).slice();return f.__wbindgen_free(l[0],l[1]*1,1),p}set_aad(e){let t=te(e,f.__wbindgen_malloc),s=T;f.group_set_aad(this.__wbg_ptr,t,s)}},Vm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_hpkewrappedarchivedatakey_free(n>>>0,1)),gr=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Vm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Vm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_hpkewrappedarchivedatakey_free(e,0)}get ciphertext(){let e=f.hpkewrappedarchivedatakey_ciphertext(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}static from_bytes(e){let t=te(e,f.__wbindgen_malloc),s=T,r=f.hpkewrappedarchivedatakey_from_bytes(t,s);if(r[2])throw j(r[1]);return n.__wrap(r[0])}get kem_output(){let e=f.hpkewrappedarchivedatakey_kem_output(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get ciphersuite(){return f.hpkewrappedarchivedatakey_ciphersuite(this.__wbg_ptr)}to_bytes(){let e=f.hpkewrappedarchivedatakey_to_bytes(this.__wbg_ptr);if(e[3])throw j(e[2]);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get hpke_info(){let e=f.hpkewrappedarchivedatakey_hpke_info(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Dc=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_identity_free(n>>>0,1)),he=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Dc.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Dc.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_identity_free(e,0)}static from_bytes(e,t){I(e,$);let s=te(t,f.__wbindgen_malloc),r=T,i=f.identity_from_bytes(e.__wbg_ptr,s,r);if(i[2])throw j(i[1]);return n.__wrap(i[0])}key_package(e){I(e,$);let t=f.identity_key_package(this.__wbg_ptr,e.__wbg_ptr);return es.__wrap(t)}key_packages(e,t){I(e,$);let s=f.identity_key_packages(this.__wbg_ptr,e.__wbg_ptr,t);var r=hr(s[0],s[1]).slice();return f.__wbindgen_free(s[0],s[1]*4,4),r}constructor(e,t){I(e,$);let s=me(t,f.__wbindgen_malloc,f.__wbindgen_realloc),r=T,i=f.identity_new(e.__wbg_ptr,s,r);if(i[2])throw j(i[1]);return this.__wbg_ptr=i[0]>>>0,Dc.register(this,this.__wbg_ptr,this),this}get user_id(){let e,t;try{let s=f.identity_user_id(this.__wbg_ptr);return e=s[0],t=s[1],Ye(s[0],s[1])}finally{f.__wbindgen_free(e,t,1)}}to_bytes(){let e=f.identity_to_bytes(this.__wbg_ptr);if(e[3])throw j(e[2]);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Km=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_keypackage_free(n>>>0,1)),es=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Km.register(t,t.__wbg_ptr,t),t}static __unwrap(e){return e instanceof n?e.__destroy_into_raw():0}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Km.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_keypackage_free(e,0)}static from_bytes(e){let t=te(e,f.__wbindgen_malloc),s=T,r=f.keypackage_from_bytes(t,s);if(r[2])throw j(r[1]);return n.__wrap(r[0])}hash_ref(e){I(e,$);let t=f.keypackage_hash_ref(this.__wbg_ptr,e.__wbg_ptr);if(t[3])throw j(t[2]);var s=H(t[0],t[1]).slice();return f.__wbindgen_free(t[0],t[1]*1,1),s}to_bytes(){let e=f.keypackage_to_bytes(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Hm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_memberinfo_free(n>>>0,1)),_r=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Hm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Hm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_memberinfo_free(e,0)}get signature_key(){let e=f.memberinfo_signature_key(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get encryption_key(){let e=f.memberinfo_encryption_key(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get index(){return f.memberinfo_index(this.__wbg_ptr)>>>0}get user_id(){let e,t;try{let s=f.memberinfo_user_id(this.__wbg_ptr);return e=s[0],t=s[1],Ye(s[0],s[1])}finally{f.__wbindgen_free(e,t,1)}}},Qm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_mlserror_free(n>>>0,1)),Fc=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Qm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_mlserror_free(e,0)}constructor(e,t){let s=me(t,f.__wbindgen_malloc,f.__wbindgen_realloc),r=T,i=f.mlserror_new(e,s,r);return this.__wbg_ptr=i>>>0,Qm.register(this,this.__wbg_ptr,this),this}get code(){return f.mlserror_code(this.__wbg_ptr)}get message(){let e,t;try{let s=f.mlserror_message(this.__wbg_ptr);return e=s[0],t=s[1],Ye(s[0],s[1])}finally{f.__wbindgen_free(e,t,1)}}},Jm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_processedmessage_free(n>>>0,1)),ca=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Jm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Jm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_processedmessage_free(e,0)}is_proposal(){return f.processedmessage_is_proposal(this.__wbg_ptr)!==0}get message_type(){return f.processedmessage_message_type(this.__wbg_ptr)}get sender_index(){return f.archivedmessage_sender_index(this.__wbg_ptr)>>>0}is_application_message(){return f.processedmessage_is_application_message(this.__wbg_ptr)!==0}get aad(){let e=f.processedmessage_aad(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get epoch(){let e=f.archivedmessage_epoch(this.__wbg_ptr);return BigInt.asUintN(64,e)}get content(){let e=f.processedmessage_content(this.__wbg_ptr),t;return e[0]!==0&&(t=H(e[0],e[1]).slice(),f.__wbindgen_free(e[0],e[1]*1,1)),t}is_commit(){return f.processedmessage_is_commit(this.__wbg_ptr)!==0}},Ym=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_proposalmessage_free(n>>>0,1)),Zt=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Ym.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ym.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_proposalmessage_free(e,0)}get proposal_ref(){let e=f.proposalmessage_proposal_ref(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}bytes_as_uint8array(){return f.proposalmessage_bytes_as_uint8array(this.__wbg_ptr)}get bytes(){let e=f.proposalmessage_bytes(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Lc=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_provider_free(n>>>0,1)),$=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Lc.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Lc.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_provider_free(e,0)}static from_bytes(e){let t=te(e,f.__wbindgen_malloc),s=T,r=f.provider_from_bytes(t,s);if(r[2])throw j(r[1]);return n.__wrap(r[0])}constructor(){let e=f.provider_new();return this.__wbg_ptr=e>>>0,Lc.register(this,this.__wbg_ptr,this),this}to_bytes(){let e=f.provider_to_bytes(this.__wbg_ptr);if(e[3])throw j(e[2]);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Xm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_ratchettree_free(n>>>0,1)),xs=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Xm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Xm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_ratchettree_free(e,0)}static from_bytes(e){let t=te(e,f.__wbindgen_malloc),s=T,r=f.ratchettree_from_bytes(t,s);if(r[2])throw j(r[1]);return n.__wrap(r[0])}to_bytes(){let e=f.ratchettree_to_bytes(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}},Zm=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_recoverykeypair_free(n>>>0,1)),la=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Zm.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Zm.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_recoverykeypair_free(e,0)}get public_key(){let e=f.recoverykeypair_public_key(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get ciphersuite(){return f.hpkewrappedarchivedatakey_ciphersuite(this.__wbg_ptr)}get private_key(){let e=f.recoverykeypair_private_key(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get key_id(){let e,t;try{let s=f.recoverykeypair_key_id(this.__wbg_ptr);return e=s[0],t=s[1],Ye(s[0],s[1])}finally{f.__wbindgen_free(e,t,1)}}},ef=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>f.__wbg_wrappedrecoverykey_free(n>>>0,1)),yr=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,ef.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ef.unregister(this),e}free(){let e=this.__destroy_into_raw();f.__wbg_wrappedrecoverykey_free(e,0)}static from_bytes(e){let t=te(e,f.__wbindgen_malloc),s=T,r=f.wrappedrecoverykey_from_bytes(t,s);if(r[2])throw j(r[1]);return n.__wrap(r[0])}get public_key(){let e=f.wrappedrecoverykey_public_key(this.__wbg_ptr);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}get ciphersuite(){return f.wrappedrecoverykey_ciphersuite(this.__wbg_ptr)}get key_id(){let e,t;try{let s=f.wrappedrecoverykey_key_id(this.__wbg_ptr);return e=s[0],t=s[1],Ye(s[0],s[1])}finally{f.__wbindgen_free(e,t,1)}}to_bytes(){let e=f.wrappedrecoverykey_to_bytes(this.__wbg_ptr);if(e[3])throw j(e[2]);var t=H(e[0],e[1]).slice();return f.__wbindgen_free(e[0],e[1]*1,1),t}};Dx=rf});var eE={};Rr(eE,{BrowserEncryptionStorage:()=>Ht,CallAction:()=>dc,CallStatus:()=>uc,CallType:()=>pt,Channel:()=>Ks,ChannelState:()=>Dn,ClientState:()=>Hs,E2EE_ATTACHMENT_FRAME_SIZE:()=>ir,E2EE_ATTACHMENT_MULTIPART_UPLOAD_DEFAULT_CONCURRENCY:()=>Cc,E2EE_ATTACHMENT_MULTIPART_UPLOAD_MAX_CONCURRENCY:()=>vm,E2EE_ATTACHMENT_MULTIPART_UPLOAD_URL_EXPIRY_SAFETY_MARGIN_MS:()=>bm,E2EE_ATTACHMENT_PREVIEW_JPEG_QUALITY:()=>ym,E2EE_ATTACHMENT_PREVIEW_MAX_SIDE:()=>_m,E2EE_ATTACHMENT_VIDEO_PREVIEW_TIMEOUT_MS:()=>tr,E2EE_MEDIA_STREAM_BASE_SESSION_CACHE_LIMIT:()=>Kx,E2EE_MEDIA_STREAM_FULL_REPLAY_CACHE_LIMIT:()=>Hx,E2EE_MEDIA_STREAM_GLOBAL_CACHE_LIMIT:()=>Qx,E2EE_MEDIA_STREAM_PREFETCH_FRAMES:()=>$x,E2EE_MEDIA_STREAM_PREFETCH_THRESHOLD_FRAMES:()=>Wx,E2EE_MEDIA_STREAM_SEQUENTIAL_PREFETCH_HITS:()=>Vx,E2eeClient:()=>en,EVENT_MAP:()=>rw,EncryptionApiClient:()=>en,EncryptionManager:()=>Xi,ErmisAuthProvider:()=>_c,ErmisCallNode:()=>gc,ErmisChat:()=>mc,ErrorFromResponse:()=>ys,FRAME_TYPE:()=>hc,IndexedDBEncryptionStorage:()=>Ht,IndexedDBUserCache:()=>Jn,Sha256:()=>sn,StableWSConnection:()=>Vn,TokenManager:()=>Yn,base64ToBytes:()=>Rc,buildAttachmentManifest:()=>Wi,buildAttachmentPayload:()=>li,buildE2eeMessageAadV1:()=>Ui,buildManifestAsset:()=>or,bytesEqual:()=>bc,bytesToBase64:()=>rr,canonicalAttachmentIds:()=>Xn,chatCodes:()=>wt,ciphertextSha256:()=>cr,compareUuidRaw:()=>im,createE2eeAttachmentStreamUrl:()=>Uc,createForwardMessagePayload:()=>Uu,decryptE2eeAsset:()=>Mc,defaultE2eeAttachmentCryptoProvider:()=>Rt,disposeAllE2eeAttachmentStreamSessions:()=>Yw,disposeE2eeAttachmentStreamUrl:()=>Mm,downloadEncryptedAsset:()=>Tc,e2eeAttachmentMultipartUploadUrlExpiresAtMs:()=>Em,e2eeMediaFramePlainLength:()=>Yx,e2eeMediaSessionCacheLimit:()=>Xx,encryptAndUploadE2eeAssetMultipart:()=>Pc,encryptE2eeAsset:()=>$i,ensureE2eeMediaStreamWorker:()=>Pm,estimateE2eeEncryptedAssetSize:()=>zi,formatMessage:()=>Mu,generateE2eeAttachmentPreview:()=>Ac,getAttachmentCategory:()=>So,hasE2eeAadMetadata:()=>Di,isE2eeMediaMsePlaybackAllowed:()=>zw,isE2eeMediaMsePlaybackEnabled:()=>km,isHeicFile:()=>Du,isVideoFile:()=>ci,loadOpenMlsWasm:()=>Ox,logChatPromiseExecution:()=>ai,newUuid:()=>rn,normalizeFileName:()=>Ln,parseSignalMessage:()=>pf,parseSystemMessage:()=>lf,planE2eeMediaFrameBatch:()=>Jx,probeE2eeMediaMp4ForMse:()=>zx,putPresignedObject:()=>Vi,putPresignedObjectWithResult:()=>Ic,resolveE2eeAttachmentMultipartUploadConcurrency:()=>ar,sha256Hex:()=>Cw,uuidToRawBytes:()=>tn,verifyEncryptedAssetHash:()=>Cm,webE2eeAttachmentCryptoProvider:()=>hm});function hn(n,e){return function(){return n.apply(e,arguments)}}var{toString:yf}=Object.prototype,{getPrototypeOf:ha}=Object,{iterator:kr,toStringTag:Wc}=Symbol,Pr=(n=>e=>{let t=yf.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),ht=n=>(n=n.toLowerCase(),e=>Pr(e)===n),Mr=n=>e=>typeof e===n,{isArray:As}=Array,mn=Mr("undefined");function vf(n){return n!==null&&!mn(n)&&n.constructor!==null&&!mn(n.constructor)&&Ve(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}var Vc=ht("ArrayBuffer");function bf(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&Vc(n.buffer),e}var wf=Mr("string"),Ve=Mr("function"),Kc=Mr("number"),Ir=n=>n!==null&&typeof n=="object",xf=n=>n===!0||n===!1,Ar=n=>{if(Pr(n)!=="object")return!1;let e=ha(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Wc in n)&&!(kr in n)},Ef=ht("Date"),Cf=ht("File"),Sf=ht("Blob"),Rf=ht("FileList"),Af=n=>Ir(n)&&Ve(n.pipe),kf=n=>{let e;return n&&(typeof FormData=="function"&&n instanceof FormData||Ve(n.append)&&((e=Pr(n))==="formdata"||e==="object"&&Ve(n.toString)&&n.toString()==="[object FormData]"))},Pf=ht("URLSearchParams"),[Mf,If,Tf,Uf]=["ReadableStream","Request","Response","Headers"].map(ht),Df=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function fn(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let s,r;if(typeof n!="object"&&(n=[n]),As(n))for(s=0,r=n.length;s<r;s++)e.call(null,n[s],s,n);else{let i=t?Object.getOwnPropertyNames(n):Object.keys(n),a=i.length,o;for(s=0;s<a;s++)o=i[s],e.call(null,n[o],o,n)}}function Hc(n,e){e=e.toLowerCase();let t=Object.keys(n),s=t.length,r;for(;s-- >0;)if(r=t[s],e===r.toLowerCase())return r;return null}var ss=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Qc=n=>!mn(n)&&n!==ss;function ua(){let{caseless:n}=Qc(this)&&this||{},e={},t=(s,r)=>{let i=n&&Hc(e,r)||r;Ar(e[i])&&Ar(s)?e[i]=ua(e[i],s):Ar(s)?e[i]=ua({},s):As(s)?e[i]=s.slice():e[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&fn(arguments[s],t);return e}var Lf=(n,e,t,{allOwnKeys:s}={})=>(fn(e,(r,i)=>{t&&Ve(r)?n[i]=hn(r,t):n[i]=r},{allOwnKeys:s}),n),Of=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Ff=(n,e,t,s)=>{n.prototype=Object.create(e.prototype,s),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},Bf=(n,e,t,s)=>{let r,i,a,o={};if(e=e||{},n==null)return e;do{for(r=Object.getOwnPropertyNames(n),i=r.length;i-- >0;)a=r[i],(!s||s(a,n,e))&&!o[a]&&(e[a]=n[a],o[a]=!0);n=t!==!1&&ha(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},jf=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;let s=n.indexOf(e,t);return s!==-1&&s===t},Gf=n=>{if(!n)return null;if(As(n))return n;let e=n.length;if(!Kc(e))return null;let t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},Nf=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&ha(Uint8Array)),qf=(n,e)=>{let s=(n&&n[kr]).call(n),r;for(;(r=s.next())&&!r.done;){let i=r.value;e.call(n,i[0],i[1])}},zf=(n,e)=>{let t,s=[];for(;(t=n.exec(e))!==null;)s.push(t);return s},$f=ht("HTMLFormElement"),Wf=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),$c=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Vf=ht("RegExp"),Jc=(n,e)=>{let t=Object.getOwnPropertyDescriptors(n),s={};fn(t,(r,i)=>{let a;(a=e(r,i,n))!==!1&&(s[i]=a||r)}),Object.defineProperties(n,s)},Kf=n=>{Jc(n,(e,t)=>{if(Ve(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;let s=n[t];if(Ve(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Hf=(n,e)=>{let t={},s=r=>{r.forEach(i=>{t[i]=!0})};return As(n)?s(n):s(String(n).split(e)),t},Qf=()=>{},Jf=(n,e)=>n!=null&&Number.isFinite(n=+n)?n:e;function Yf(n){return!!(n&&Ve(n.append)&&n[Wc]==="FormData"&&n[kr])}var Xf=n=>{let e=new Array(10),t=(s,r)=>{if(Ir(s)){if(e.indexOf(s)>=0)return;if(!("toJSON"in s)){e[r]=s;let i=As(s)?[]:{};return fn(s,(a,o)=>{let c=t(a,r+1);!mn(c)&&(i[o]=c)}),e[r]=void 0,i}}return s};return t(n,0)},Zf=ht("AsyncFunction"),eg=n=>n&&(Ir(n)||Ve(n))&&Ve(n.then)&&Ve(n.catch),Yc=((n,e)=>n?setImmediate:e?((t,s)=>(ss.addEventListener("message",({source:r,data:i})=>{r===ss&&i===t&&s.length&&s.shift()()},!1),r=>{s.push(r),ss.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ve(ss.postMessage)),tg=typeof queueMicrotask<"u"?queueMicrotask.bind(ss):typeof process<"u"&&process.nextTick||Yc,sg=n=>n!=null&&Ve(n[kr]),w={isArray:As,isArrayBuffer:Vc,isBuffer:vf,isFormData:kf,isArrayBufferView:bf,isString:wf,isNumber:Kc,isBoolean:xf,isObject:Ir,isPlainObject:Ar,isReadableStream:Mf,isRequest:If,isResponse:Tf,isHeaders:Uf,isUndefined:mn,isDate:Ef,isFile:Cf,isBlob:Sf,isRegExp:Vf,isFunction:Ve,isStream:Af,isURLSearchParams:Pf,isTypedArray:Nf,isFileList:Rf,forEach:fn,merge:ua,extend:Lf,trim:Df,stripBOM:Of,inherits:Ff,toFlatObject:Bf,kindOf:Pr,kindOfTest:ht,endsWith:jf,toArray:Gf,forEachEntry:qf,matchAll:zf,isHTMLForm:$f,hasOwnProperty:$c,hasOwnProp:$c,reduceDescriptors:Jc,freezeMethods:Kf,toObjectSet:Hf,toCamelCase:Wf,noop:Qf,toFiniteNumber:Jf,findKey:Hc,global:ss,isContextDefined:Qc,isSpecCompliantForm:Yf,toJSONObject:Xf,isAsyncFn:Zf,isThenable:eg,setImmediate:Yc,asap:tg,isIterable:sg};function ks(n,e,t,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}w.inherits(ks,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:w.toJSONObject(this.config),code:this.code,status:this.status}}});var Xc=ks.prototype,Zc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{Zc[n]={value:n}});Object.defineProperties(ks,Zc);Object.defineProperty(Xc,"isAxiosError",{value:!0});ks.from=(n,e,t,s,r,i)=>{let a=Object.create(Xc);return w.toFlatObject(n,a,function(c){return c!==Error.prototype},o=>o!=="isAxiosError"),ks.call(a,n.message,e,t,s,r),a.cause=n,a.name=n.name,i&&Object.assign(a,i),a};var D=ks;var sd=We(Ua(),1),qr=sd.default;function Da(n){return w.isPlainObject(n)||w.isArray(n)}function rd(n){return w.endsWith(n,"[]")?n.slice(0,-2):n}function nd(n,e,t){return n?n.concat(e).map(function(r,i){return r=rd(r),!t&&i?"["+r+"]":r}).join(t?".":""):e}function N_(n){return w.isArray(n)&&!n.some(Da)}var q_=w.toFlatObject(w,{},null,function(e){return/^is[A-Z]/.test(e)});function z_(n,e,t){if(!w.isObject(n))throw new TypeError("target must be an object");e=e||new(qr||FormData),t=w.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,_){return!w.isUndefined(_[g])});let s=t.metaTokens,r=t.visitor||p,i=t.dots,a=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&w.isSpecCompliantForm(e);if(!w.isFunction(r))throw new TypeError("visitor must be a function");function l(m){if(m===null)return"";if(w.isDate(m))return m.toISOString();if(w.isBoolean(m))return m.toString();if(!c&&w.isBlob(m))throw new D("Blob is not supported. Use a Buffer instead.");return w.isArrayBuffer(m)||w.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function p(m,g,_){let v=m;if(m&&!_&&typeof m=="object"){if(w.endsWith(g,"{}"))g=s?g:g.slice(0,-2),m=JSON.stringify(m);else if(w.isArray(m)&&N_(m)||(w.isFileList(m)||w.endsWith(g,"[]"))&&(v=w.toArray(m)))return g=rd(g),v.forEach(function(x,C){!(w.isUndefined(x)||x===null)&&e.append(a===!0?nd([g],C,i):a===null?g:g+"[]",l(x))}),!1}return Da(m)?!0:(e.append(nd(_,g,i),l(m)),!1)}let d=[],u=Object.assign(q_,{defaultVisitor:p,convertValue:l,isVisitable:Da});function h(m,g){if(!w.isUndefined(m)){if(d.indexOf(m)!==-1)throw Error("Circular reference detected in "+g.join("."));d.push(m),w.forEach(m,function(v,y){(!(w.isUndefined(v)||v===null)&&r.call(e,v,w.isString(y)?y.trim():y,g,u))===!0&&h(v,g?g.concat(y):[y])}),d.pop()}}if(!w.isObject(n))throw new TypeError("data must be an object");return h(n),e}var Nt=z_;function id(n){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function ad(n,e){this._pairs=[],n&&Nt(n,this,e)}var od=ad.prototype;od.append=function(e,t){this._pairs.push([e,t])};od.toString=function(e){let t=e?function(s){return e.call(this,s,id)}:id;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};var cd=ad;function $_(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function is(n,e,t){if(!e)return n;let s=t&&t.encode||$_;w.isFunction(t)&&(t={serialize:t});let r=t&&t.serialize,i;if(r?i=r(e,t):i=w.isURLSearchParams(e)?e.toString():new cd(e,t).toString(s),i){let a=n.indexOf("#");a!==-1&&(n=n.slice(0,a)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}var La=class{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){w.forEach(this.handlers,function(s){s!==null&&e(s)})}},Oa=La;var Us={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var ud=We(V("crypto"),1);var ld=We(V("url"),1),pd=ld.default.URLSearchParams;var Fa="abcdefghijklmnopqrstuvwxyz",dd="0123456789",hd={DIGIT:dd,ALPHA:Fa,ALPHA_DIGIT:Fa+Fa.toUpperCase()+dd},W_=(n=16,e=hd.ALPHA_DIGIT)=>{let t="",{length:s}=e,r=new Uint32Array(n);ud.default.randomFillSync(r);for(let i=0;i<n;i++)t+=e[r[i]%s];return t},md={isNode:!0,classes:{URLSearchParams:pd,FormData:qr,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:hd,generateString:W_,protocols:["http","https","file","data"]};var Ga={};Rr(Ga,{hasBrowserEnv:()=>ja,hasStandardBrowserEnv:()=>V_,hasStandardBrowserWebWorkerEnv:()=>K_,navigator:()=>Ba,origin:()=>H_});var ja=typeof window<"u"&&typeof document<"u",Ba=typeof navigator=="object"&&navigator||void 0,V_=ja&&(!Ba||["ReactNative","NativeScript","NS"].indexOf(Ba.product)<0),K_=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",H_=ja&&window.location.href||"http://localhost";var le={...Ga,...md};function Na(n,e){return Nt(n,new le.classes.URLSearchParams,Object.assign({visitor:function(t,s,r,i){return le.isNode&&w.isBuffer(t)?(this.append(s,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function Q_(n){return w.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function J_(n){let e={},t=Object.keys(n),s,r=t.length,i;for(s=0;s<r;s++)i=t[s],e[i]=n[i];return e}function Y_(n){function e(t,s,r,i){let a=t[i++];if(a==="__proto__")return!0;let o=Number.isFinite(+a),c=i>=t.length;return a=!a&&w.isArray(r)?r.length:a,c?(w.hasOwnProp(r,a)?r[a]=[r[a],s]:r[a]=s,!o):((!r[a]||!w.isObject(r[a]))&&(r[a]=[]),e(t,s,r[a],i)&&w.isArray(r[a])&&(r[a]=J_(r[a])),!o)}if(w.isFormData(n)&&w.isFunction(n.entries)){let t={};return w.forEachEntry(n,(s,r)=>{e(Q_(s),r,t,0)}),t}return null}var zr=Y_;function X_(n,e,t){if(w.isString(n))try{return(e||JSON.parse)(n),w.trim(n)}catch(s){if(s.name!=="SyntaxError")throw s}return(t||JSON.stringify)(n)}var qa={transitional:Us,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){let s=t.getContentType()||"",r=s.indexOf("application/json")>-1,i=w.isObject(e);if(i&&w.isHTMLForm(e)&&(e=new FormData(e)),w.isFormData(e))return r?JSON.stringify(zr(e)):e;if(w.isArrayBuffer(e)||w.isBuffer(e)||w.isStream(e)||w.isFile(e)||w.isBlob(e)||w.isReadableStream(e))return e;if(w.isArrayBufferView(e))return e.buffer;if(w.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return Na(e,this.formSerializer).toString();if((o=w.isFileList(e))||s.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return Nt(o?{"files[]":e}:e,c&&new c,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),X_(e)):e}],transformResponse:[function(e){let t=this.transitional||qa.transitional,s=t&&t.forcedJSONParsing,r=this.responseType==="json";if(w.isResponse(e)||w.isReadableStream(e))return e;if(e&&w.isString(e)&&(s&&!this.responseType||r)){let a=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(o){if(a)throw o.name==="SyntaxError"?D.from(o,D.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:le.classes.FormData,Blob:le.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};w.forEach(["delete","get","head","post","put","patch"],n=>{qa.headers[n]={}});var Ds=qa;var Z_=w.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),fd=n=>{let e={},t,s,r;return n&&n.split(`
16
+ `).forEach(function(a){r=a.indexOf(":"),t=a.substring(0,r).trim().toLowerCase(),s=a.substring(r+1).trim(),!(!t||e[t]&&Z_[t])&&(t==="set-cookie"?e[t]?e[t].push(s):e[t]=[s]:e[t]=e[t]?e[t]+", "+s:s)}),e};var gd=Symbol("internals");function wn(n){return n&&String(n).trim().toLowerCase()}function $r(n){return n===!1||n==null?n:w.isArray(n)?n.map($r):String(n)}function ey(n){let e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,s;for(;s=t.exec(n);)e[s[1]]=s[2];return e}var ty=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function za(n,e,t,s,r){if(w.isFunction(s))return s.call(this,e,t);if(r&&(e=t),!!w.isString(e)){if(w.isString(s))return e.indexOf(s)!==-1;if(w.isRegExp(s))return s.test(e)}}function sy(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}function ny(n,e){let t=w.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(n,s+t,{value:function(r,i,a){return this[s].call(this,e,r,i,a)},configurable:!0})})}var Ls=class{constructor(e){e&&this.set(e)}set(e,t,s){let r=this;function i(o,c,l){let p=wn(c);if(!p)throw new Error("header name must be a non-empty string");let d=w.findKey(r,p);(!d||r[d]===void 0||l===!0||l===void 0&&r[d]!==!1)&&(r[d||c]=$r(o))}let a=(o,c)=>w.forEach(o,(l,p)=>i(l,p,c));if(w.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(w.isString(e)&&(e=e.trim())&&!ty(e))a(fd(e),t);else if(w.isObject(e)&&w.isIterable(e)){let o={},c,l;for(let p of e){if(!w.isArray(p))throw TypeError("Object iterator must return a key-value pair");o[l=p[0]]=(c=o[l])?w.isArray(c)?[...c,p[1]]:[c,p[1]]:p[1]}a(o,t)}else e!=null&&i(t,e,s);return this}get(e,t){if(e=wn(e),e){let s=w.findKey(this,e);if(s){let r=this[s];if(!t)return r;if(t===!0)return ey(r);if(w.isFunction(t))return t.call(this,r,s);if(w.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=wn(e),e){let s=w.findKey(this,e);return!!(s&&this[s]!==void 0&&(!t||za(this,this[s],s,t)))}return!1}delete(e,t){let s=this,r=!1;function i(a){if(a=wn(a),a){let o=w.findKey(s,a);o&&(!t||za(s,s[o],o,t))&&(delete s[o],r=!0)}}return w.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),s=t.length,r=!1;for(;s--;){let i=t[s];(!e||za(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,s={};return w.forEach(this,(r,i)=>{let a=w.findKey(s,i);if(a){t[a]=$r(r),delete t[i];return}let o=e?sy(i):String(i).trim();o!==i&&delete t[i],t[o]=$r(r),s[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return w.forEach(this,(s,r)=>{s!=null&&s!==!1&&(t[r]=e&&w.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
17
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let s=new this(e);return t.forEach(r=>s.set(r)),s}static accessor(e){let s=(this[gd]=this[gd]={accessors:{}}).accessors,r=this.prototype;function i(a){let o=wn(a);s[o]||(ny(r,a),s[o]=!0)}return w.isArray(e)?e.forEach(i):i(e),this}};Ls.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);w.reduceDescriptors(Ls.prototype,({value:n},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>n,set(s){this[t]=s}}});w.freezeMethods(Ls);var be=Ls;function xn(n,e){let t=this||Ds,s=e||t,r=be.from(s.headers),i=s.data;return w.forEach(n,function(o){i=o.call(t,i,r.normalize(),e?e.status:void 0)}),r.normalize(),i}function En(n){return!!(n&&n.__CANCEL__)}function _d(n,e,t){D.call(this,n??"canceled",D.ERR_CANCELED,e,t),this.name="CanceledError"}w.inherits(_d,D,{__CANCEL__:!0});var tt=_d;function vt(n,e,t){let s=t.config.validateStatus;!t.status||!s||s(t.status)?n(t):e(new D("Request failed with status code "+t.status,[D.ERR_BAD_REQUEST,D.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function $a(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Wa(n,e){return e?n.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):n}function as(n,e,t){let s=!$a(e);return n&&(s||t==!1)?Wa(n,e):e}var eu=We(vd(),1),tu=We(V("http"),1);jt();var su=We(V("util"),1),nu=We(Bd(),1),Ut=We(V("zlib"),1);var ps="1.10.0";function kn(n){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}var $y=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function oo(n,e,t){let s=t&&t.Blob||le.classes.Blob,r=kn(n);if(e===void 0&&s&&(e=!0),r==="data"){n=r.length?n.slice(r.length+1):n;let i=$y.exec(n);if(!i)throw new D("Invalid URL",D.ERR_INVALID_URL);let a=i[1],o=i[2],c=i[3],l=Buffer.from(decodeURIComponent(c),o?"base64":"utf8");if(e){if(!s)throw new D("Blob is not supported",D.ERR_NOT_SUPPORT);return new s([l],{type:a})}return l}throw new D("Unsupported protocol "+r,D.ERR_NOT_SUPPORT)}var us=We(V("stream"),1);var jd=We(V("stream"),1);var co=Symbol("internals"),lo=class extends jd.default.Transform{constructor(e){e=w.toFlatObject(e,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(s,r)=>!w.isUndefined(r[s])),super({readableHighWaterMark:e.chunkSize});let t=this[co]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",s=>{s==="progress"&&(t.isCaptured||(t.isCaptured=!0))})}_read(e){let t=this[co];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,s){let r=this[co],i=r.maxRate,a=this.readableHighWaterMark,o=r.timeWindow,c=1e3/o,l=i/c,p=r.minChunkSize!==!1?Math.max(r.minChunkSize,l*.01):0,d=(h,m)=>{let g=Buffer.byteLength(h);r.bytesSeen+=g,r.bytes+=g,r.isCaptured&&this.emit("progress",r.bytesSeen),this.push(h)?process.nextTick(m):r.onReadCallback=()=>{r.onReadCallback=null,process.nextTick(m)}},u=(h,m)=>{let g=Buffer.byteLength(h),_=null,v=a,y,x=0;if(i){let C=Date.now();(!r.ts||(x=C-r.ts)>=o)&&(r.ts=C,y=l-r.bytes,r.bytes=y<0?-y:0,x=0),y=l-r.bytes}if(i){if(y<=0)return setTimeout(()=>{m(null,h)},o-x);y<v&&(v=y)}v&&g>v&&g-v>p&&(_=h.subarray(v),h=h.subarray(0,v)),d(h,_?()=>{process.nextTick(m,null,_)}:m)};u(e,function h(m,g){if(m)return s(m);g?u(g,h):s(null)})}},po=lo;var ru=V("events");var Nd=We(V("util"),1),qd=V("stream");var{asyncIterator:Gd}=Symbol,Wy=async function*(n){n.stream?yield*n.stream():n.arrayBuffer?yield await n.arrayBuffer():n[Gd]?yield*n[Gd]():yield n},Jr=Wy;var Vy=le.ALPHABET.ALPHA_DIGIT+"-_",Pn=typeof TextEncoder=="function"?new TextEncoder:new Nd.default.TextEncoder,ds=`\r
18
+ `,Ky=Pn.encode(ds),Hy=2,uo=class{constructor(e,t){let{escapeName:s}=this.constructor,r=w.isString(t),i=`Content-Disposition: form-data; name="${s(e)}"${!r&&t.name?`; filename="${s(t.name)}"`:""}${ds}`;r?t=Pn.encode(String(t).replace(/\r?\n|\r\n?/g,ds)):i+=`Content-Type: ${t.type||"application/octet-stream"}${ds}`,this.headers=Pn.encode(i+ds),this.contentLength=r?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+Hy,this.name=e,this.value=t}async*encode(){yield this.headers;let{value:e}=this;w.isTypedArray(e)?yield e:yield*Jr(e),yield Ky}static escapeName(e){return String(e).replace(/[\r\n"]/g,t=>({"\r":"%0D","\n":"%0A",'"':"%22"})[t])}},Qy=(n,e,t)=>{let{tag:s="form-data-boundary",size:r=25,boundary:i=s+"-"+le.generateString(r,Vy)}=t||{};if(!w.isFormData(n))throw TypeError("FormData instance required");if(i.length<1||i.length>70)throw Error("boundary must be 10-70 characters long");let a=Pn.encode("--"+i+ds),o=Pn.encode("--"+i+"--"+ds),c=o.byteLength,l=Array.from(n.entries()).map(([d,u])=>{let h=new uo(d,u);return c+=h.size,h});c+=a.byteLength*l.length,c=w.toFiniteNumber(c);let p={"Content-Type":`multipart/form-data; boundary=${i}`};return Number.isFinite(c)&&(p["Content-Length"]=c),e&&e(p),qd.Readable.from((async function*(){for(let d of l)yield a,yield*d.encode();yield o})())},zd=Qy;var $d=We(V("stream"),1),ho=class extends $d.default.Transform{__transform(e,t,s){this.push(e),s()}_transform(e,t,s){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let r=Buffer.alloc(2);r[0]=120,r[1]=156,this.push(r,t)}this.__transform(e,t,s)}},Wd=ho;var Jy=(n,e)=>w.isAsyncFn(n)?function(...t){let s=t.pop();n.apply(this,t).then(r=>{try{e?s(null,...e(r)):s(null,r)}catch(i){s(i)}},s)}:n,Vd=Jy;function Yy(n,e){n=n||10;let t=new Array(n),s=new Array(n),r=0,i=0,a;return e=e!==void 0?e:1e3,function(c){let l=Date.now(),p=s[i];a||(a=l),t[r]=c,s[r]=l;let d=i,u=0;for(;d!==r;)u+=t[d++],d=d%n;if(r=(r+1)%n,r===i&&(i=(i+1)%n),l-a<e)return;let h=p&&l-p;return h?Math.round(u*1e3/h):void 0}}var Kd=Yy;function Xy(n,e){let t=0,s=1e3/e,r,i,a=(l,p=Date.now())=>{t=p,r=null,i&&(clearTimeout(i),i=null),n.apply(null,l)};return[(...l)=>{let p=Date.now(),d=p-t;d>=s?a(l,p):(r=l,i||(i=setTimeout(()=>{i=null,a(r)},s-d)))},()=>r&&a(r)]}var Hd=Xy;var Tt=(n,e,t=3)=>{let s=0,r=Kd(50,250);return Hd(i=>{let a=i.loaded,o=i.lengthComputable?i.total:void 0,c=a-s,l=r(c),p=a<=o;s=a;let d={loaded:a,total:o,progress:o?a/o:void 0,bytes:c,rate:l||void 0,estimated:l&&o&&p?(o-a)/l:void 0,event:i,lengthComputable:o!=null,[e?"download":"upload"]:!0};n(d)},t)},Gs=(n,e)=>{let t=n!=null;return[s=>e[0]({lengthComputable:t,total:n,loaded:s}),e[1]]},Ns=n=>(...e)=>w.asap(()=>n(...e));var Qd={flush:Ut.default.constants.Z_SYNC_FLUSH,finishFlush:Ut.default.constants.Z_SYNC_FLUSH},Zy={flush:Ut.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:Ut.default.constants.BROTLI_OPERATION_FLUSH},Jd=w.isFunction(Ut.default.createBrotliDecompress),{http:ev,https:tv}=nu.default,sv=/https:?/,Yd=le.protocols.map(n=>n+":"),Xd=(n,[e,t])=>(n.on("end",t).on("error",t),e);function nv(n,e){n.beforeRedirects.proxy&&n.beforeRedirects.proxy(n),n.beforeRedirects.config&&n.beforeRedirects.config(n,e)}function iu(n,e,t){let s=e;if(!s&&s!==!1){let r=eu.default.getProxyForUrl(t);r&&(s=new URL(r))}if(s){if(s.username&&(s.auth=(s.username||"")+":"+(s.password||"")),s.auth){(s.auth.username||s.auth.password)&&(s.auth=(s.auth.username||"")+":"+(s.auth.password||""));let i=Buffer.from(s.auth,"utf8").toString("base64");n.headers["Proxy-Authorization"]="Basic "+i}n.headers.host=n.hostname+(n.port?":"+n.port:"");let r=s.hostname||s.host;n.hostname=r,n.host=r,n.port=s.port,n.path=t,s.protocol&&(n.protocol=s.protocol.includes(":")?s.protocol:`${s.protocol}:`)}n.beforeRedirects.proxy=function(i){iu(i,e,i.href)}}var rv=typeof process<"u"&&w.kindOf(process)==="process",iv=n=>new Promise((e,t)=>{let s,r,i=(c,l)=>{r||(r=!0,s&&s(c,l))},a=c=>{i(c),e(c)},o=c=>{i(c,!0),t(c)};n(a,o,c=>s=c).catch(o)}),av=({address:n,family:e})=>{if(!w.isString(n))throw TypeError("address must be a string");return{address:n,family:e||(n.indexOf(".")<0?6:4)}},Zd=(n,e)=>av(w.isObject(n)?n:{address:n,family:e}),au=rv&&function(e){return iv(async function(s,r,i){let{data:a,lookup:o,family:c}=e,{responseType:l,responseEncoding:p}=e,d=e.method.toUpperCase(),u,h=!1,m;if(o){let M=Vd(o,A=>w.isArray(A)?A:[A]);o=(A,z,re)=>{M(A,z,(ie,Re,dt)=>{if(ie)return re(ie);let Le=w.isArray(Re)?Re.map(Oe=>Zd(Oe)):[Zd(Re,dt)];z.all?re(ie,Le):re(ie,Le[0].address,Le[0].family)})}}let g=new ru.EventEmitter,_=()=>{e.cancelToken&&e.cancelToken.unsubscribe(v),e.signal&&e.signal.removeEventListener("abort",v),g.removeAllListeners()};i((M,A)=>{u=!0,A&&(h=!0,_())});function v(M){g.emit("abort",!M||M.type?new tt(null,e,m):M)}g.once("abort",r),(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(v),e.signal&&(e.signal.aborted?v():e.signal.addEventListener("abort",v)));let y=as(e.baseURL,e.url,e.allowAbsoluteUrls),x=new URL(y,le.hasBrowserEnv?le.origin:void 0),C=x.protocol||Yd[0];if(C==="data:"){let M;if(d!=="GET")return vt(s,r,{status:405,statusText:"method not allowed",headers:{},config:e});try{M=oo(e.url,l==="blob",{Blob:e.env&&e.env.Blob})}catch(A){throw D.from(A,D.ERR_BAD_REQUEST,e)}return l==="text"?(M=M.toString(p),(!p||p==="utf8")&&(M=w.stripBOM(M))):l==="stream"&&(M=us.default.Readable.from(M)),vt(s,r,{data:M,status:200,statusText:"OK",headers:new be,config:e})}if(Yd.indexOf(C)===-1)return r(new D("Unsupported protocol "+C,D.ERR_BAD_REQUEST,e));let S=be.from(e.headers).normalize();S.set("User-Agent","axios/"+ps,!1);let{onUploadProgress:P,onDownloadProgress:E}=e,k=e.maxRate,G,Q;if(w.isSpecCompliantForm(a)){let M=S.getContentType(/boundary=([-_\w\d]{10,70})/i);a=zd(a,A=>{S.set(A)},{tag:`axios-${ps}-boundary`,boundary:M&&M[1]||void 0})}else if(w.isFormData(a)&&w.isFunction(a.getHeaders)){if(S.set(a.getHeaders()),!S.hasContentLength())try{let M=await su.default.promisify(a.getLength).call(a);Number.isFinite(M)&&M>=0&&S.setContentLength(M)}catch{}}else if(w.isBlob(a)||w.isFile(a))a.size&&S.setContentType(a.type||"application/octet-stream"),S.setContentLength(a.size||0),a=us.default.Readable.from(Jr(a));else if(a&&!w.isStream(a)){if(!Buffer.isBuffer(a))if(w.isArrayBuffer(a))a=Buffer.from(new Uint8Array(a));else if(w.isString(a))a=Buffer.from(a,"utf-8");else return r(new D("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",D.ERR_BAD_REQUEST,e));if(S.setContentLength(a.length,!1),e.maxBodyLength>-1&&a.length>e.maxBodyLength)return r(new D("Request body larger than maxBodyLength limit",D.ERR_BAD_REQUEST,e))}let ce=w.toFiniteNumber(S.getContentLength());w.isArray(k)?(G=k[0],Q=k[1]):G=Q=k,a&&(P||G)&&(w.isStream(a)||(a=us.default.Readable.from(a,{objectMode:!1})),a=us.default.pipeline([a,new po({maxRate:w.toFiniteNumber(G)})],w.noop),P&&a.on("progress",Xd(a,Gs(ce,Tt(Ns(P),!1,3)))));let q;if(e.auth){let M=e.auth.username||"",A=e.auth.password||"";q=M+":"+A}if(!q&&x.username){let M=x.username,A=x.password;q=M+":"+A}q&&S.delete("authorization");let _e;try{_e=is(x.pathname+x.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(M){let A=new Error(M.message);return A.config=e,A.url=e.url,A.exists=!0,r(A)}S.set("Accept-Encoding","gzip, compress, deflate"+(Jd?", br":""),!1);let F={path:_e,method:d,headers:S.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:q,protocol:C,family:c,beforeRedirect:nv,beforeRedirects:{}};!w.isUndefined(o)&&(F.lookup=o),e.socketPath?F.socketPath=e.socketPath:(F.hostname=x.hostname.startsWith("[")?x.hostname.slice(1,-1):x.hostname,F.port=x.port,iu(F,e.proxy,C+"//"+x.hostname+(x.port?":"+x.port:"")+F.path));let W,X=sv.test(F.protocol);if(F.agent=X?e.httpsAgent:e.httpAgent,e.transport?W=e.transport:e.maxRedirects===0?W=X?ns:tu.default:(e.maxRedirects&&(F.maxRedirects=e.maxRedirects),e.beforeRedirect&&(F.beforeRedirects.config=e.beforeRedirect),W=X?tv:ev),e.maxBodyLength>-1?F.maxBodyLength=e.maxBodyLength:F.maxBodyLength=1/0,e.insecureHTTPParser&&(F.insecureHTTPParser=e.insecureHTTPParser),m=W.request(F,function(A){if(m.destroyed)return;let z=[A],re=+A.headers["content-length"];if(E||Q){let Oe=new po({maxRate:w.toFiniteNumber(Q)});E&&Oe.on("progress",Xd(Oe,Gs(re,Tt(Ns(E),!0,3)))),z.push(Oe)}let ie=A,Re=A.req||m;if(e.decompress!==!1&&A.headers["content-encoding"])switch((d==="HEAD"||A.statusCode===204)&&delete A.headers["content-encoding"],(A.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":z.push(Ut.default.createUnzip(Qd)),delete A.headers["content-encoding"];break;case"deflate":z.push(new Wd),z.push(Ut.default.createUnzip(Qd)),delete A.headers["content-encoding"];break;case"br":Jd&&(z.push(Ut.default.createBrotliDecompress(Zy)),delete A.headers["content-encoding"])}ie=z.length>1?us.default.pipeline(z,w.noop):z[0];let dt=us.default.finished(ie,()=>{dt(),_()}),Le={status:A.statusCode,statusText:A.statusMessage,headers:new be(A.headers),config:e,request:Re};if(l==="stream")Le.data=ie,vt(s,r,Le);else{let Oe=[],Ae=0;ie.on("data",function(ge){Oe.push(ge),Ae+=ge.length,e.maxContentLength>-1&&Ae>e.maxContentLength&&(h=!0,ie.destroy(),r(new D("maxContentLength size of "+e.maxContentLength+" exceeded",D.ERR_BAD_RESPONSE,e,Re)))}),ie.on("aborted",function(){if(h)return;let ge=new D("stream has been aborted",D.ERR_BAD_RESPONSE,e,Re);ie.destroy(ge),r(ge)}),ie.on("error",function(ge){m.destroyed||r(D.from(ge,null,e,Re))}),ie.on("end",function(){try{let ge=Oe.length===1?Oe[0]:Buffer.concat(Oe);l!=="arraybuffer"&&(ge=ge.toString(p),(!p||p==="utf8")&&(ge=w.stripBOM(ge))),Le.data=ge}catch(ge){return r(D.from(ge,null,e,Le.request,Le))}vt(s,r,Le)})}g.once("abort",Oe=>{ie.destroyed||(ie.emit("error",Oe),ie.destroy())})}),g.once("abort",M=>{r(M),m.destroy(M)}),m.on("error",function(A){r(D.from(A,null,e,m))}),m.on("socket",function(A){A.setKeepAlive(!0,1e3*60)}),e.timeout){let M=parseInt(e.timeout,10);if(Number.isNaN(M)){r(new D("error trying to parse `config.timeout` to int",D.ERR_BAD_OPTION_VALUE,e,m));return}m.setTimeout(M,function(){if(u)return;let z=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",re=e.transitional||Us;e.timeoutErrorMessage&&(z=e.timeoutErrorMessage),r(new D(z,re.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,e,m)),v()})}if(w.isStream(a)){let M=!1,A=!1;a.on("end",()=>{M=!0}),a.once("error",z=>{A=!0,m.destroy(z)}),a.on("close",()=>{!M&&!A&&v(new tt("Request stream has been aborted",e,m))}),a.pipe(m)}else m.end(a)})};var ou=le.hasStandardBrowserEnv?((n,e)=>t=>(t=new URL(t,le.origin),n.protocol===t.protocol&&n.host===t.host&&(e||n.port===t.port)))(new URL(le.origin),le.navigator&&/(msie|trident)/i.test(le.navigator.userAgent)):()=>!0;var cu=le.hasStandardBrowserEnv?{write(n,e,t,s,r,i){let a=[n+"="+encodeURIComponent(e)];w.isNumber(t)&&a.push("expires="+new Date(t).toGMTString()),w.isString(s)&&a.push("path="+s),w.isString(r)&&a.push("domain="+r),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(n){let e=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(n){this.write(n,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};var lu=n=>n instanceof be?{...n}:n;function ft(n,e){e=e||{};let t={};function s(l,p,d,u){return w.isPlainObject(l)&&w.isPlainObject(p)?w.merge.call({caseless:u},l,p):w.isPlainObject(p)?w.merge({},p):w.isArray(p)?p.slice():p}function r(l,p,d,u){if(w.isUndefined(p)){if(!w.isUndefined(l))return s(void 0,l,d,u)}else return s(l,p,d,u)}function i(l,p){if(!w.isUndefined(p))return s(void 0,p)}function a(l,p){if(w.isUndefined(p)){if(!w.isUndefined(l))return s(void 0,l)}else return s(void 0,p)}function o(l,p,d){if(d in e)return s(l,p);if(d in n)return s(void 0,l)}let c={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(l,p,d)=>r(lu(l),lu(p),d,!0)};return w.forEach(Object.keys(Object.assign({},n,e)),function(p){let d=c[p]||r,u=d(n[p],e[p],p);w.isUndefined(u)&&d!==o||(t[p]=u)}),t}var Yr=n=>{let e=ft({},n),{data:t,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:i,headers:a,auth:o}=e;e.headers=a=be.from(a),e.url=is(as(e.baseURL,e.url,e.allowAbsoluteUrls),n.params,n.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let c;if(w.isFormData(t)){if(le.hasStandardBrowserEnv||le.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((c=a.getContentType())!==!1){let[l,...p]=c?c.split(";").map(d=>d.trim()).filter(Boolean):[];a.setContentType([l||"multipart/form-data",...p].join("; "))}}if(le.hasStandardBrowserEnv&&(s&&w.isFunction(s)&&(s=s(e)),s||s!==!1&&ou(e.url))){let l=r&&i&&cu.read(i);l&&a.set(r,l)}return e};var ov=typeof XMLHttpRequest<"u",pu=ov&&function(n){return new Promise(function(t,s){let r=Yr(n),i=r.data,a=be.from(r.headers).normalize(),{responseType:o,onUploadProgress:c,onDownloadProgress:l}=r,p,d,u,h,m;function g(){h&&h(),m&&m(),r.cancelToken&&r.cancelToken.unsubscribe(p),r.signal&&r.signal.removeEventListener("abort",p)}let _=new XMLHttpRequest;_.open(r.method.toUpperCase(),r.url,!0),_.timeout=r.timeout;function v(){if(!_)return;let x=be.from("getAllResponseHeaders"in _&&_.getAllResponseHeaders()),S={data:!o||o==="text"||o==="json"?_.responseText:_.response,status:_.status,statusText:_.statusText,headers:x,config:n,request:_};vt(function(E){t(E),g()},function(E){s(E),g()},S),_=null}"onloadend"in _?_.onloadend=v:_.onreadystatechange=function(){!_||_.readyState!==4||_.status===0&&!(_.responseURL&&_.responseURL.indexOf("file:")===0)||setTimeout(v)},_.onabort=function(){_&&(s(new D("Request aborted",D.ECONNABORTED,n,_)),_=null)},_.onerror=function(){s(new D("Network Error",D.ERR_NETWORK,n,_)),_=null},_.ontimeout=function(){let C=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded",S=r.transitional||Us;r.timeoutErrorMessage&&(C=r.timeoutErrorMessage),s(new D(C,S.clarifyTimeoutError?D.ETIMEDOUT:D.ECONNABORTED,n,_)),_=null},i===void 0&&a.setContentType(null),"setRequestHeader"in _&&w.forEach(a.toJSON(),function(C,S){_.setRequestHeader(S,C)}),w.isUndefined(r.withCredentials)||(_.withCredentials=!!r.withCredentials),o&&o!=="json"&&(_.responseType=r.responseType),l&&([u,m]=Tt(l,!0),_.addEventListener("progress",u)),c&&_.upload&&([d,h]=Tt(c),_.upload.addEventListener("progress",d),_.upload.addEventListener("loadend",h)),(r.cancelToken||r.signal)&&(p=x=>{_&&(s(!x||x.type?new tt(null,n,_):x),_.abort(),_=null)},r.cancelToken&&r.cancelToken.subscribe(p),r.signal&&(r.signal.aborted?p():r.signal.addEventListener("abort",p)));let y=kn(r.url);if(y&&le.protocols.indexOf(y)===-1){s(new D("Unsupported protocol "+y+":",D.ERR_BAD_REQUEST,n));return}_.send(i||null)})};var cv=(n,e)=>{let{length:t}=n=n?n.filter(Boolean):[];if(e||t){let s=new AbortController,r,i=function(l){if(!r){r=!0,o();let p=l instanceof Error?l:this.reason;s.abort(p instanceof D?p:new tt(p instanceof Error?p.message:p))}},a=e&&setTimeout(()=>{a=null,i(new D(`timeout ${e} of ms exceeded`,D.ETIMEDOUT))},e),o=()=>{n&&(a&&clearTimeout(a),a=null,n.forEach(l=>{l.unsubscribe?l.unsubscribe(i):l.removeEventListener("abort",i)}),n=null)};n.forEach(l=>l.addEventListener("abort",i));let{signal:c}=s;return c.unsubscribe=()=>w.asap(o),c}},du=cv;var lv=function*(n,e){let t=n.byteLength;if(!e||t<e){yield n;return}let s=0,r;for(;s<t;)r=s+e,yield n.slice(s,r),s=r},pv=async function*(n,e){for await(let t of dv(n))yield*lv(t,e)},dv=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}let e=n.getReader();try{for(;;){let{done:t,value:s}=await e.read();if(t)break;yield s}}finally{await e.cancel()}},mo=(n,e,t,s)=>{let r=pv(n,e),i=0,a,o=c=>{a||(a=!0,s&&s(c))};return new ReadableStream({async pull(c){try{let{done:l,value:p}=await r.next();if(l){o(),c.close();return}let d=p.byteLength;if(t){let u=i+=d;t(u)}c.enqueue(new Uint8Array(p))}catch(l){throw o(l),l}},cancel(c){return o(c),r.return()}},{highWaterMark:2})};var Zr=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",hu=Zr&&typeof ReadableStream=="function",uv=Zr&&(typeof TextEncoder=="function"?(n=>e=>n.encode(e))(new TextEncoder):async n=>new Uint8Array(await new Response(n).arrayBuffer())),mu=(n,...e)=>{try{return!!n(...e)}catch{return!1}},hv=hu&&mu(()=>{let n=!1,e=new Request(le.origin,{body:new ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type");return n&&!e}),uu=64*1024,fo=hu&&mu(()=>w.isReadableStream(new Response("").body)),Xr={stream:fo&&(n=>n.body)};Zr&&(n=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!Xr[e]&&(Xr[e]=w.isFunction(n[e])?t=>t[e]():(t,s)=>{throw new D(`Response type '${e}' is not supported`,D.ERR_NOT_SUPPORT,s)})})})(new Response);var mv=async n=>{if(n==null)return 0;if(w.isBlob(n))return n.size;if(w.isSpecCompliantForm(n))return(await new Request(le.origin,{method:"POST",body:n}).arrayBuffer()).byteLength;if(w.isArrayBufferView(n)||w.isArrayBuffer(n))return n.byteLength;if(w.isURLSearchParams(n)&&(n=n+""),w.isString(n))return(await uv(n)).byteLength},fv=async(n,e)=>{let t=w.toFiniteNumber(n.getContentLength());return t??mv(e)},fu=Zr&&(async n=>{let{url:e,method:t,data:s,signal:r,cancelToken:i,timeout:a,onDownloadProgress:o,onUploadProgress:c,responseType:l,headers:p,withCredentials:d="same-origin",fetchOptions:u}=Yr(n);l=l?(l+"").toLowerCase():"text";let h=du([r,i&&i.toAbortSignal()],a),m,g=h&&h.unsubscribe&&(()=>{h.unsubscribe()}),_;try{if(c&&hv&&t!=="get"&&t!=="head"&&(_=await fv(p,s))!==0){let S=new Request(e,{method:"POST",body:s,duplex:"half"}),P;if(w.isFormData(s)&&(P=S.headers.get("content-type"))&&p.setContentType(P),S.body){let[E,k]=Gs(_,Tt(Ns(c)));s=mo(S.body,uu,E,k)}}w.isString(d)||(d=d?"include":"omit");let v="credentials"in Request.prototype;m=new Request(e,{...u,signal:h,method:t.toUpperCase(),headers:p.normalize().toJSON(),body:s,duplex:"half",credentials:v?d:void 0});let y=await fetch(m,u),x=fo&&(l==="stream"||l==="response");if(fo&&(o||x&&g)){let S={};["status","statusText","headers"].forEach(G=>{S[G]=y[G]});let P=w.toFiniteNumber(y.headers.get("content-length")),[E,k]=o&&Gs(P,Tt(Ns(o),!0))||[];y=new Response(mo(y.body,uu,E,()=>{k&&k(),g&&g()}),S)}l=l||"text";let C=await Xr[w.findKey(Xr,l)||"text"](y,n);return!x&&g&&g(),await new Promise((S,P)=>{vt(S,P,{data:C,headers:be.from(y.headers),status:y.status,statusText:y.statusText,config:n,request:m})})}catch(v){throw g&&g(),v&&v.name==="TypeError"&&/Load failed|fetch/i.test(v.message)?Object.assign(new D("Network Error",D.ERR_NETWORK,n,m),{cause:v.cause||v}):D.from(v,v&&v.code,n,m)}});var go={http:au,xhr:pu,fetch:fu};w.forEach(go,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});var gu=n=>`- ${n}`,gv=n=>w.isFunction(n)||n===null||n===!1,ei={getAdapter:n=>{n=w.isArray(n)?n:[n];let{length:e}=n,t,s,r={};for(let i=0;i<e;i++){t=n[i];let a;if(s=t,!gv(t)&&(s=go[(a=String(t)).toLowerCase()],s===void 0))throw new D(`Unknown adapter '${a}'`);if(s)break;r[a||"#"+i]=s}if(!s){let i=Object.entries(r).map(([o,c])=>`adapter ${o} `+(c===!1?"is not supported by the environment":"is not available in the build")),a=e?i.length>1?`since :
19
+ `+i.map(gu).join(`
20
+ `):" "+gu(i[0]):"as no adapter specified";throw new D("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return s},adapters:go};function _o(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new tt(null,n)}function ti(n){return _o(n),n.headers=be.from(n.headers),n.data=xn.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),ei.getAdapter(n.adapter||Ds.adapter)(n).then(function(s){return _o(n),s.data=xn.call(n,n.transformResponse,s),s.headers=be.from(s.headers),s},function(s){return En(s)||(_o(n),s&&s.response&&(s.response.data=xn.call(n,n.transformResponse,s.response),s.response.headers=be.from(s.response.headers))),Promise.reject(s)})}var si={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{si[n]=function(s){return typeof s===n||"a"+(e<1?"n ":" ")+n}});var _u={};si.transitional=function(e,t,s){function r(i,a){return"[Axios v"+ps+"] Transitional option '"+i+"'"+a+(s?". "+s:"")}return(i,a,o)=>{if(e===!1)throw new D(r(a," has been removed"+(t?" in "+t:"")),D.ERR_DEPRECATED);return t&&!_u[a]&&(_u[a]=!0,console.warn(r(a," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,a,o):!0}};si.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function _v(n,e,t){if(typeof n!="object")throw new D("options must be an object",D.ERR_BAD_OPTION_VALUE);let s=Object.keys(n),r=s.length;for(;r-- >0;){let i=s[r],a=e[i];if(a){let o=n[i],c=o===void 0||a(o,i,n);if(c!==!0)throw new D("option "+i+" must be "+c,D.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new D("Unknown option "+i,D.ERR_BAD_OPTION)}}var Mn={assertOptions:_v,validators:si};var bt=Mn.validators,qs=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Oa,response:new Oa}}async request(e,t){try{return await this._request(e,t)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;let i=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?i&&!String(s.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(s.stack+=`
21
+ `+i):s.stack=i}catch{}}throw s}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=ft(this.defaults,t);let{transitional:s,paramsSerializer:r,headers:i}=t;s!==void 0&&Mn.assertOptions(s,{silentJSONParsing:bt.transitional(bt.boolean),forcedJSONParsing:bt.transitional(bt.boolean),clarifyTimeoutError:bt.transitional(bt.boolean)},!1),r!=null&&(w.isFunction(r)?t.paramsSerializer={serialize:r}:Mn.assertOptions(r,{encode:bt.function,serialize:bt.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Mn.assertOptions(t,{baseUrl:bt.spelling("baseURL"),withXsrfToken:bt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=i&&w.merge(i.common,i[t.method]);i&&w.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),t.headers=be.concat(a,i);let o=[],c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(c=c&&g.synchronous,o.unshift(g.fulfilled,g.rejected))});let l=[];this.interceptors.response.forEach(function(g){l.push(g.fulfilled,g.rejected)});let p,d=0,u;if(!c){let m=[ti.bind(this),void 0];for(m.unshift.apply(m,o),m.push.apply(m,l),u=m.length,p=Promise.resolve(t);d<u;)p=p.then(m[d++],m[d++]);return p}u=o.length;let h=t;for(d=0;d<u;){let m=o[d++],g=o[d++];try{h=m(h)}catch(_){g.call(this,_);break}}try{p=ti.call(this,h)}catch(m){return Promise.reject(m)}for(d=0,u=l.length;d<u;)p=p.then(l[d++],l[d++]);return p}getUri(e){e=ft(this.defaults,e);let t=as(e.baseURL,e.url,e.allowAbsoluteUrls);return is(t,e.params,e.paramsSerializer)}};w.forEach(["delete","get","head","options"],function(e){qs.prototype[e]=function(t,s){return this.request(ft(s||{},{method:e,url:t,data:(s||{}).data}))}});w.forEach(["post","put","patch"],function(e){function t(s){return function(i,a,o){return this.request(ft(o||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}qs.prototype[e]=t(),qs.prototype[e+"Form"]=t(!0)});var In=qs;var yo=class n{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});let s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i,a=new Promise(o=>{s.subscribe(o),i=o}).then(r);return a.cancel=function(){s.unsubscribe(i)},a},e(function(i,a,o){s.reason||(s.reason=new tt(i,a,o),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=s=>{e.abort(s)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new n(function(r){e=r}),cancel:e}}},yu=yo;function vo(n){return function(t){return n.apply(null,t)}}function bo(n){return w.isObject(n)&&n.isAxiosError===!0}var wo={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(wo).forEach(([n,e])=>{wo[e]=n});var vu=wo;function bu(n){let e=new In(n),t=hn(In.prototype.request,e);return w.extend(t,In.prototype,e,{allOwnKeys:!0}),w.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return bu(ft(n,r))},t}var Ee=bu(Ds);Ee.Axios=In;Ee.CanceledError=tt;Ee.CancelToken=yu;Ee.isCancel=En;Ee.VERSION=ps;Ee.toFormData=Nt;Ee.AxiosError=D;Ee.Cancel=Ee.CanceledError;Ee.all=function(e){return Promise.all(e)};Ee.spread=vo;Ee.isAxiosError=bo;Ee.mergeConfig=ft;Ee.AxiosHeaders=be;Ee.formToJSON=n=>zr(w.isHTMLForm(n)?new FormData(n):n);Ee.getAdapter=ei.getAdapter;Ee.HttpStatusCode=vu;Ee.default=Ee;var zs=Ee;var{Axios:jR,AxiosError:GR,CanceledError:NR,isCancel:qR,CancelToken:zR,VERSION:$R,all:WR,Cancel:VR,isAxiosError:KR,spread:HR,toFormData:QR,AxiosHeaders:JR,HttpStatusCode:YR,formToJSON:XR,getAdapter:ZR,mergeConfig:eA}=zs;jt();var Su=We(Ua());var wu=()=>null,ni;function yv(n){if(typeof n=="string")return n;if(n instanceof Error)return n.stack||n.message;try{let e=JSON.stringify(n);return typeof e=="string"?e:String(n)}catch{return String(n)}}function vv(n){return n.map(yv).join(" ")}function bv(n){return n.length>1?{args:n}:void 0}function wv(n){return n==="info"||n==="warn"||n==="error"}function xv(n){let e=new Set(n.filter(wv));if(e.size!==0)return(t,s,r)=>{let i=t==="error"?"error":t==="warn"?"warn":"log";if(!e.has(t)||typeof globalThis>"u")return;let o=globalThis.console,c=o?.[i]||o?.log;if(typeof c=="function"){if(r){c.call(o,`[SDK:${t}] ${s}`,r);return}c.call(o,`[SDK:${t}] ${s}`)}}}function xu(n){if(typeof n=="function"&&n!==wu)return n;if(Array.isArray(n))return xv(n)}function Eu(){if(!(typeof globalThis>"u")){if(!ni){globalThis.__ermisSdkLog=void 0;return}globalThis.__ermisSdkLog=(n,...e)=>{b(n,...e)}}}function ri(n){return xu(n)||wu}function $s(n){ni=xu(n),Eu()}function b(n,...e){ni&&ni(n,vv(e),bv(e))}Eu();function ai(n,e){n.then().catch(t=>{b("warn",`failed to do ${e}, ran into error: `,t)})}var Ws=n=>new Promise(e=>setTimeout(e,n));var wt={TOKEN_EXPIRED:40,WS_CLOSED_SUCCESS:1e3};function Ev(n){return n!==null&&typeof n=="object"&&(n.readable||typeof n._read=="function")}function Cv(n){return n!=null&&n.constructor!=null&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Sv(n){return typeof window<"u"&&"File"in window&&n instanceof File}function Rv(n){return typeof window<"u"&&"Blob"in window&&n instanceof Blob}function Ru(n,e,t){let s=new Su.default;return Ev(n)||Cv(n)||Sv(n)||Rv(n)?e?s.append("file",n,e):s.append("file",n):s.append("file",{uri:n,name:e||n.split("/").reverse()[0],contentType:t||void 0,type:t||void 0}),s}function oi(n){let e=Math.min(500+n*2e3,25e3),t=Math.min(Math.max(250,(n-1)*2e3),25e3);return Math.floor(Math.random()*(e-t)+t)}function Te(){return Av()}function Tn(n){let e="";for(let t=0;t<n.length;t++)e+=n[t].toString(16).padStart(2,"0");return e}function Av(){let n=Mv(16);return n[6]=n[6]&15|64,n[8]=n[8]&191|128,Tn(n.subarray(0,4))+"-"+Tn(n.subarray(4,6))+"-"+Tn(n.subarray(6,8))+"-"+Tn(n.subarray(8,10))+"-"+Tn(n.subarray(10,16))}function kv(n){let e=Math.pow(2,8*n.byteLength/n.length);for(let t=0;t<n.length;t++)n[t]=Math.random()*e}var Pv=typeof crypto<"u"&&typeof crypto?.getRandomValues<"u"?crypto.getRandomValues.bind(crypto):typeof msCrypto<"u"?msCrypto.getRandomValues.bind(msCrypto):kv;function Mv(n){let e=new Uint8Array(n);return Pv(e),e}function Au(n){typeof window<"u"&&window.addEventListener&&(window.addEventListener("offline",n),window.addEventListener("online",n))}function ku(n){typeof window<"u"&&window.removeEventListener&&(window.removeEventListener("offline",n),window.removeEventListener("online",n))}var Pu=n=>{let e=[];for(let t in n)n[t]!==void 0&&(Array.isArray(n[t])||typeof n[t]=="object"?e.push(`${t}=${encodeURIComponent(JSON.stringify(n[t]))}`):e.push(`${t}=${encodeURIComponent(n[t])}`));return e.join("&")};function Mu(n){return{...n,__html:n.html,pinned_at:n.pinned_at?new Date(n.pinned_at):null,created_at:n.created_at?new Date(n.created_at):new Date,updated_at:n.updated_at?new Date(n.updated_at):new Date,status:n.status||"received"}}function Iu(n,e,t=!1,s="created_at",r=!0){let i=r||t,a=n,o=(_,v)=>{let y=v,x=_,C=y.content_type==="mls"||!!y.mls_ciphertext,S=x.content_type==="standard"||!!x.text||!!x.attachments?.length||!!x.sticker_url,P=new Set(["content_type","text","attachments","sticker_url","poll_type","poll_choice_counts","latest_poll_choices"]),E={..._};return Object.keys(v).forEach(k=>{v[k]!==void 0&&(C&&S&&P.has(String(k))||(E[k]=v[k]))}),C&&S&&(E.content_type="standard"),E};t&&(a=a.filter(_=>!(_.id&&e.id===_.id)));let c=a.length;if(c===0&&i)return a.concat(e);if(c===0)return[...a];if(s==="pinned_at")return a.concat(e);let l=e[s].getTime(),p=a[c-1][s].getTime()<l;if(p&&i)return a.concat(e);if(p)return[...a];let d=0,u=0,h=c-1;for(;d<=h;)u=Math.floor((h+d)/2),a[u][s].getTime()<=l?d=u+1:h=u-1;if(!t&&e.id){if(a[d]&&e.id===a[d].id)return a[d]=o(a[d],e),[...a];if(a[d-1]&&e.id===a[d-1].id)return a[d-1]=o(a[d-1],e),[...a]}i&&a.splice(d,0,e);let m=new Map,g=[];for(let _ of a)m.has(_.id)||(m.set(_.id,!0),g.push(_));return g}var de=(n,e)=>n.length===0?[]:e.length===0?n.map(t=>(t.user={id:t.user?.id,name:t.user?.id,avatar:""},t)):n.map(t=>{let s=t.user?.id,r=t?.latest_reactions,i=t?.quoted_message,a=e.find(o=>o.id===s);if(a&&(t.user={id:a.id,name:a.name||a.id,avatar:a.avatar||""}),r&&(t.latest_reactions=r.map(o=>{let c=e.find(l=>l.id===o.user_id);return{...o,user:{id:c?.id||o.user_id,name:c?.name||o.user_id,avatar:c?.avatar||""}}})),i){let o=e.find(c=>c.id===i.user?.id);t.quoted_message.user={id:o?.id||i.user?.id,name:o?.name||i.user?.id,avatar:o?.avatar||""}}return t}),Z=(n,e)=>{if(e.length===0)return{id:n,name:n,avatar:""};let t=e.filter(r=>r?.id===n),s=t.find(r=>{let i=typeof r?.name=="string"?r.name.trim():"";return!!(i&&i!==n)})||t.find(r=>r?.avatar||r?.image)||t[0];return{id:n,name:s?.name||n,avatar:s?.avatar||""}},Ue=(n,...e)=>{let t=n||e.find(i=>typeof i?.id=="string"&&i.id)?.id,s=e.filter(i=>!i||typeof i!="object"?!1:!t||!i.id?!0:i.id===t),r=i=>{let a=typeof i?.name=="string"?i.name.trim():"",o=i?.id||t;return!!(a&&a!==o)};return s.find(r)||s.find(i=>i.avatar||i.image)||s[0]||(t?Z(t,[]):void 0)},hs=(n,e)=>{if(n.length===0)return"Empty channel";let t=n.find(s=>s.user.id!==e);return t?t.user.name||t.user.id:"Empty channel"},Un=(n,e)=>{if(n.length===0)return"";let t=n.find(s=>s.user.id!==e);return t&&t.user.avatar||""},xo=new Set,ii=null,Eo=null,Cu=new Set;async function xt(n,e){let t=(e||[]).map(i=>i.user?.id).filter(i=>!!i),s=n.state.users,r=t.filter(i=>{if(Cu.has(i))return!1;let a=s[i];return!a||!a.name||a.name===a.id});r.length>0&&(r.forEach(i=>{Cu.add(i),xo.add(i)}),ii||(ii=new Promise(i=>{Eo=i}),setTimeout(async()=>{let i=Array.from(xo);xo.clear();let a=Eo;if(ii=null,Eo=null,i.length>0)try{await n.getBatchUsers(i)}catch(o){n.logger("error","utils:ensureMembersUserInfoLoaded() - Failed to get batch users",{err:o})}a&&a()},50)),await ii)}var ms=(n=[])=>n.length>0?Math.max(...n.map(e=>new Date(e.created_at).getTime())):0,qt=(n,e,t,s)=>{let r,i;if(["videoConfig","audioConfig","transciverState"].includes(t)&&s){r=1;let c=JSON.stringify(s);i=new TextEncoder().encode(c)}else t==="connected"||t==="healthCall"?(r=1,i=new Uint8Array(0)):(r=9,i=new Uint8Array(n));let a=new Uint8Array(r+i.byteLength),o=0;switch(t){case"videoConfig":o=0;break;case"audioConfig":o=1;break;case"video-key":o=2;break;case"video-delta":o=3;break;case"audio":o=4;break;case"connected":o=6;break;case"transciverState":o=7;break;case"healthCall":o=11;break}return a[0]=o,e!==null&&new DataView(a.buffer).setBigUint64(1,BigInt(e),!1),a.set(i,r),a},Co=n=>{let e="",t=new Uint8Array(n),s=t.byteLength;for(let r=0;r<s;r++)e+=String.fromCharCode(t[r]);return btoa(e)},Tu=n=>{let e={2048:"123",4096:"153",8192:"156",16384:"183",32768:"186"},t=/2048|4096|8192|16384|32768/g;return n.match(t)?n.replace(t,s=>e[s]):"hev1.1.6.L123.B0"},Uu=(n,e,t)=>{let s={cid:e,forward_cid:t,forward_message_id:n.id,forward_parent_cid:n.parent_cid||n.cid};return n.sticker_url&&(!n.text||n.text==="")&&(!n.attachments||Array.isArray(n.attachments)&&n.attachments.length===0)?(s.sticker_url=n.sticker_url,s.text=n.text):(s.text=n.text||"",n.attachments&&n.attachments.length>0&&(s.attachments=n.attachments.filter(r=>r.type!=="linkPreview"))),s};var Dn=class{_channel;watcher_count;typing;read;pinnedMessages;watchers;members;unreadCount;membership;last_message_at;isUpToDate;messageSets=[];topics=[];constructor(e){this._channel=e,this.watcher_count=0,this.typing={},this.read={},this.initMessages(),this.pinnedMessages=[],this.watchers={},this.members={},this.membership={},this.unreadCount=0,this.isUpToDate=!0,this.last_message_at=e?.state?.last_message_at!=null?new Date(e.state.last_message_at):null}get messages(){return this.messageSets.find(e=>e.isCurrent)?.messages||[]}set messages(e){let t=this.messageSets.findIndex(s=>s.isCurrent);this.messageSets[t].messages=e}get latestMessages(){return this.messageSets.find(e=>e.isLatest)?.messages||[]}set latestMessages(e){let t=this.messageSets.findIndex(s=>s.isLatest);this.messageSets[t].messages=e}addMessageSorted(e,t=!1,s=!0,r="latest"){return this.addMessagesSorted([e],t,!1,s,r)}formatMessage(e){return{...e,__html:e.html,pinned_at:e.pinned_at?new Date(e.pinned_at):null,created_at:e.created_at?new Date(e.created_at):new Date,updated_at:e.updated_at?new Date(e.updated_at):null,status:e.status||"received"}}addMessagesSorted(e,t=!1,s=!1,r=!0,i="current"){let{messagesToAdd:a,targetMessageSetIndex:o}=this.findTargetMessageSet(e,r,i);for(let c=0;c<a.length;c+=1){let l=a[c].created_at instanceof Date,p;if(l?p=a[c]:(p=this.formatMessage(a[c]),p.user&&this._channel?.cid&&this._channel.getClient().state.updateUserReference(p.user,this._channel.cid),this.last_message_at||(this.last_message_at=new Date(p.created_at.getTime())),p.created_at.getTime()>this.last_message_at.getTime()&&(this.last_message_at=new Date(p.created_at.getTime()))),!p.pinned){let u=this.pinnedMessages.find(h=>h.id===p.id);u&&(p.pinned=!0,p.pinned_at=u.pinned_at||new Date)}!p.parent_id&&o!==-1&&(this.messageSets[o].messages=this._addToMessageList(this.messageSets[o].messages,p,t,"created_at",r))}return{messageSet:this.messageSets[o]}}addPinnedMessages(e){for(let t=0;t<e.length;t+=1)this.addPinnedMessage(e[t]);this.pinnedMessages.sort((t,s)=>{let r=t.pinned_at?new Date(t.pinned_at).getTime():0;return(s.pinned_at?new Date(s.pinned_at).getTime():0)-r})}addPinnedMessage(e){let t=this.formatMessage(e);this.pinnedMessages=this.pinnedMessages.filter(s=>s.id!==t.id),this.pinnedMessages=[t,...this.pinnedMessages]}removePinnedMessage(e){let{result:t}=this.removeMessageFromArray(this.pinnedMessages,e);this.pinnedMessages=t}addReaction(e,t,s){if(!t)return;let r=t;return this._updateMessage(t,i=>i.content_type==="mls"||r.content_type==="mls"?{...i,latest_reactions:r.latest_reactions??i.latest_reactions,reaction_counts:r.reaction_counts??i.reaction_counts,reaction_groups:r.reaction_groups??i.reaction_groups,own_reactions:this._addOwnReactionToMessage(i.own_reactions,e,s)}:(r.own_reactions=this._addOwnReactionToMessage(i.own_reactions,e,s),this.formatMessage(r))),r}_addOwnReactionToMessage(e,t,s){return s?e=[]:e=this._removeOwnReactionFromMessage(e,t),e=e||[],this._channel.getClient().userID===t.user_id&&e.push(t),e}_removeOwnReactionFromMessage(e,t){return e&&e.filter(s=>s.user_id!==t.user_id||s.type!==t.type)}removeReaction(e,t){if(!t)return;let s=t;return this._updateMessage(t,r=>r.content_type==="mls"||s.content_type==="mls"?{...r,latest_reactions:s.latest_reactions??r.latest_reactions,reaction_counts:s.reaction_counts??r.reaction_counts,reaction_groups:s.reaction_groups??r.reaction_groups,own_reactions:this._removeOwnReactionFromMessage(r.own_reactions,e)}:(s.own_reactions=this._removeOwnReactionFromMessage(r.own_reactions,e),this.formatMessage(s))),s}removeQuotedMessageReferences(e){let t=s=>({...s,created_at:s.created_at.toISOString(),pinned_at:s.pinned_at?.toISOString(),updated_at:s.updated_at?.toISOString()});this.messageSets.forEach(s=>{let r=s.messages.filter(i=>i.quoted_message_id===e.id).map(t).map(i=>({...i,quoted_message:{...e,attachments:[]}}));this.addMessagesSorted(r,!0)})}_updateMessage(e,t){let{parent_id:s,pinned:r}=e;if(!s){let i=this.findMessageSetIndex(e);if(i!==-1){let a=this.messageSets[i].messages.findIndex(o=>o.id===e.id);a!==-1&&(this.messageSets[i].messages[a]=t(this.messageSets[i].messages[a]))}}if(r){let i=this.pinnedMessages.findIndex(a=>a.id===e.id);i!==-1&&(this.pinnedMessages[i]=t(this.pinnedMessages[i]))}}setIsUpToDate=e=>{this.isUpToDate=e};updateMessageStatus(e,t){this._updateMessage({id:e},s=>({...s,status:t}))}updateMessageById(e,t){this._updateMessage({id:e},t)}_addToMessageList(e,t,s=!1,r="created_at",i=!0){return Iu(e,t,s,r,i)}removeMessage(e){let t=!1,s=e.messageSetIndex??this.findMessageSetIndex(e);if(s!==-1){let{removed:r,result:i}=this.removeMessageFromArray(this.messageSets[s].messages,e);this.messageSets[s].messages=i,t=r}return t}removeMessageFromArray=(e,t)=>{let s=e.filter(r=>!(r.id&&t.id&&r.id===t.id));return{removed:s.length<e.length,result:s}};updateUserMessages=e=>{let t=(s,r)=>{for(let i=0;i<s.length;i++){let a=s[i],o=a?.latest_reactions||[];a.user?.id===r.id&&(s[i]={...a,user:a.user?.id===r.id?r:a.user}),o&&o.some(c=>c.user?.id===r.id)&&(s[i]={...a,latest_reactions:o.map(c=>c.user?.id===r.id?{...c,user:r}:c)})}};this.messageSets.forEach(s=>{t(s.messages,e),s.messages=[...s.messages]}),t(this.pinnedMessages,e),this.pinnedMessages=[...this.pinnedMessages]};deleteUserMessages=(e,t=!1)=>{let s=(r,i,a=!1)=>{for(let o=0;o<r.length;o++){let c=r[o];c.user?.id===i.id&&(a?r[o]={cid:c.cid,created_at:c.created_at,deleted_at:new Date().toISOString(),id:c.id,latest_reactions:[],mentioned_users:[],own_reactions:[],parent_id:c.parent_id,reply_count:c.reply_count,status:c.status,type:"deleted",updated_at:c.updated_at,user:c.user}:r[o]={...c,type:"deleted",deleted_at:new Date().toISOString()})}};this.messageSets.forEach(r=>s(r.messages,e,t)),s(this.pinnedMessages,e,t)};filterErrorMessages(){let e=this.latestMessages.filter(t=>t.type!=="error");this.latestMessages=e}clean(){let e=new Date;for(let[t,s]of Object.entries(this.typing)){let r=typeof s.received_at=="string"?new Date(s.received_at):s.received_at||new Date;e.getTime()-r.getTime()>7e3&&(delete this.typing[t],this._channel.getClient().dispatchEvent({cid:this._channel.cid,type:"typing.stop",user:{id:t}}))}}clearMessages(){this.initMessages(),this.pinnedMessages=[]}initMessages(){this.messageSets=[{messages:[],isLatest:!0,isCurrent:!0}]}async loadMessageIntoState(e,t,s=25){let r,i=!1,a=t||e;if(e==="latest"){if(this.messages===this.latestMessages)return;r=this.messageSets.findIndex(o=>o.isLatest)}else r=this.findMessageSetIndex({id:a});r!==-1&&(this.switchToMessageSet(r),i=!0),i||await this._channel.query({messages:{id_around:a,limit:s}},"new"),r=this.findMessageSetIndex({id:a}),r!==-1&&this.switchToMessageSet(r)}findMessage(e,t){let s=this.findMessageSetIndex({id:e});if(s!==-1)return this.messageSets[s].messages.find(r=>r.id===e)}switchToMessageSet(e){let t=this.messageSets.find(s=>s.isCurrent);t&&(t.isCurrent=!1,this.messageSets[e].isCurrent=!0)}areMessageSetsOverlap(e,t){return e.some(s=>t.find(r=>s.id===r.id))}findMessageSetIndex(e){return this.messageSets.findIndex(t=>!!t.messages.find(s=>s.id===e.id))}findTargetMessageSet(e,t=!0,s="current"){let r=e,i;if(t){let a=this.messageSets.map((l,p)=>p).filter(l=>this.areMessageSetsOverlap(this.messageSets[l].messages,e));switch(s){case"new":a.length>0?i=a[0]:e.some(l=>!l.parent_id)&&(this.messageSets.push({messages:[],isCurrent:!1,isLatest:!1}),i=this.messageSets.length-1);break;case"current":i=this.messageSets.findIndex(l=>l.isCurrent);break;case"latest":i=this.messageSets.findIndex(l=>l.isLatest);break;default:i=-1}let o=a.splice(0,1)[0],c=[...a];if(o!==void 0&&o!==i&&c.push(i),c.length>0){let l=this.messageSets[o],p=this.messageSets.filter((u,h)=>c.indexOf(h)!==-1);p.forEach(u=>{l.isLatest=l.isLatest||u.isLatest,l.isCurrent=l.isCurrent||u.isCurrent,r=[...r,...u.messages]}),p.forEach(u=>this.messageSets.splice(this.messageSets.indexOf(u),1)),i=this.messageSets.findIndex(u=>this.areMessageSetsOverlap(u.messages,e))}}else i=this.findMessageSetIndex(e[0]);return{targetMessageSetIndex:i,messagesToAdd:r}}};function Ln(n){let e=n.lastIndexOf("."),t=e>0?n.slice(0,e):n,s=e>0?n.slice(e):"";return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d").replace(/Đ/g,"D").replace(/\s+/g,"_")+s}function Du(n){let e=n.type.toLowerCase(),t=n.name.toLowerCase().split(".").pop()||"";return e==="image/heic"||e==="image/heif"||t==="heic"||t==="heif"}function So(n,e){let t=n.toLowerCase(),s=(e||"").toLowerCase().split(".").pop()||"";return t==="image/heic"||t==="image/heif"||s==="heic"||s==="heif"?"file":t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"file"}function ci(n){return n.type==="video/mp4"||n.type==="video/webm"||n.type==="video/quicktime"}function li(n,e,t,s){let r=Ln(n.name),i=n.type||"",a=So(i,n.name);if(s)return{type:"voiceRecording",asset_url:e,title:r,file_size:n.size,mime_type:i,waveform_data:s.waveform_data,duration:s.duration};switch(a){case"image":return{type:"image",image_url:e,title:r,file_size:n.size,mime_type:i};case"video":return{type:"video",asset_url:e,title:r,file_size:n.size,mime_type:i,thumb_url:t||""};case"audio":return{type:"file",asset_url:e,title:r,file_size:n.size,mime_type:i};default:return{type:"file",asset_url:e,title:r,file_size:n.size,mime_type:i||""}}}var gt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Iv=(()=>{let n=new Int16Array(256);n.fill(-1);for(let e=0;e<gt.length;e+=1)n[gt.charCodeAt(e)]=e;return n})(),Tv=["commit","welcome","ratchet_tree","group_info"],Uv=["commit","welcome","ratchet_tree","proposal"],di="X-Ermis-E2EE-Bytes",Vs="base64",Ou="e2ee_bytes";function ui(n){if(!(n instanceof Uint8Array))throw new TypeError("expected Uint8Array");let e="",t=0;for(;t+2<n.length;t+=3){let r=n[t]<<16|n[t+1]<<8|n[t+2];e+=gt[r>>18&63],e+=gt[r>>12&63],e+=gt[r>>6&63],e+=gt[r&63]}let s=n.length-t;if(s===1){let r=n[t]<<16;e+=gt[r>>18&63],e+=gt[r>>12&63],e+="=="}else if(s===2){let r=n[t]<<16|n[t+1]<<8;e+=gt[r>>18&63],e+=gt[r>>12&63],e+=gt[r>>6&63],e+="="}return e}function Dv(n){if(typeof n!="string")throw new TypeError("expected base64 string");if(n.length%4!==0)throw new Error("invalid standard base64 length");if(/[^A-Za-z0-9+/=]/.test(n))throw new Error("invalid standard base64 character");let e=n.indexOf("=");if(e!==-1&&e<n.length-(n.endsWith("==")?2:1))throw new Error("invalid standard base64 padding");let t=n.endsWith("==")?2:n.endsWith("=")?1:0,s=new Uint8Array(n.length/4*3-t),r=0;for(let i=0;i<n.length;i+=4){let a=pi(n.charCodeAt(i)),o=pi(n.charCodeAt(i+1)),c=n[i+2]==="="?0:pi(n.charCodeAt(i+2)),l=n[i+3]==="="?0:pi(n.charCodeAt(i+3)),p=a<<18|o<<12|c<<6|l;r<s.length&&(s[r++]=p>>16&255),r<s.length&&(s[r++]=p>>8&255),r<s.length&&(s[r++]=p&255)}if(ui(s)!==n)throw new Error("non-canonical standard base64");return s}function Be(n,e="bytes"){let t=Lv(n,e);if(!t)throw new TypeError(`${e} is required`);return t}function Lv(n,e="bytes"){if(n!=null){if(n instanceof Uint8Array)return n;if(typeof n=="string")return Dv(n);if(Array.isArray(n)){let t=new Uint8Array(n.length);for(let s=0;s<n.length;s+=1){let r=n[s];if(!Number.isInteger(r)||r<0||r>255)throw new TypeError(`${e} contains invalid byte at index ${s}`);t[s]=r}return t}throw new TypeError(`${e} must be Uint8Array, base64 string, or legacy byte array`)}}function Ro(n){let e={...n};for(let t of Tv)Ov(e[t])&&(e[t]=ui(Be(e[t],t)));return e}function Fu(n){let e=n;return Fn(e.message),On(e.protocol_data),On(e.message),On(e),Lu(e),Lu(e.data),n}function Ao(n){let e=n,t=e.data;return t&&(e.type==="application"?Fn(t):e.type==="protocol"?On(t):(e.type==="message_updated"||e.type==="message_pin")&&Fn(t.message)),n}function Bu(n){let t=n.channels;if(!t)return n;for(let s of Object.values(t))if(Array.isArray(s?.events))for(let r of s.events){let i=r,a=i.data;a&&(i.type==="application"?Fn(a):i.type==="protocol"?On(a):(i.type==="message_updated"||i.type==="message_pin")&&Fn(a.message))}return n}function Fn(n){!n||n.mls_ciphertext==null||(n.mls_ciphertext=Be(n.mls_ciphertext,"mls_ciphertext"))}function On(n){if(n)for(let e of Uv)n[e]!=null&&(n[e]=Be(n[e],e))}function Lu(n){!n||n.key_package_ref==null||(n.key_package_ref=Be(n.key_package_ref,"key_package_ref"))}function pi(n){let e=Iv[n];if(e<0)throw new Error("invalid standard base64 character");return e}function Ov(n){return n instanceof Uint8Array?!0:Array.isArray(n)&&n.every(e=>Number.isInteger(e)&&e>=0&&e<=255)}var Ks=class{_client;type;id;data;_data;cid;listeners;state;initialized;offlineMode;lastKeyStroke;lastTypingEvent;isTyping;disconnected;constructor(e,t,s,r){let i=/^[\w_-]+$/,a=/^[\w!:_-]+$/;if(!i.test(t))throw new Error(`Invalid chat type ${t}, letters, numbers and "_-" are allowed`);if(typeof s=="string"&&!a.test(s))throw new Error(`Invalid chat id ${s}, letters, numbers and "!-_" are allowed`);this._client=e,this.type=t,this.id=s,this.data=r,this._data={...r},this.cid=`${t}:${s}`,this.listeners={},this.state=new Dn(this),this.initialized=!1,this.offlineMode=!1,this.lastTypingEvent=null,this.isTyping=!1,this.disconnected=!1}getClient(){return this._client}_isE2eeQuery(){return this._isEffectiveE2ee()}_isE2eeChannelData(e){let t=e||this.data||this._data;if(t?.mls_enabled===!0)return!0;let s=typeof t?.parent_cid=="string"?t.parent_cid:void 0;if(!s)return!1;let r=this.getClient().activeChannels?.[s];return r?.data?.mls_enabled===!0||r?._data?.mls_enabled===!0}_isEffectiveE2ee(){return this._isE2eeChannelData(this.data)||this._isE2eeChannelData(this._data)}_queryDataPayload(){if(!this._data||Object.keys(this._data).length===0)return;let e={...this._data};return delete e.messages,Object.keys(e).length>0?e:void 0}_encodeE2eeChannelPayload(e){let t=Ro(e);return t.data&&typeof t.data=="object"&&(t.data=Ro(t.data)),t}async sendMessage(e){e.id||(e={...e,id:Te()});let t=e.id,s=e.quoted_message||(e.quoted_message_id?this.state.findMessage(e.quoted_message_id):void 0),r={...e,id:t,quoted_message:s,status:"sending",created_at:new Date().toISOString(),updated_at:new Date().toISOString(),user:this.getClient().user,user_id:this.getClient().userID,type:e.sticker_url?"sticker":e.type||"regular"};this.state.addMessageSorted(r);let i=this._isEffectiveE2ee(),a=this.getClient().encryptionManager;if(i&&a?.initialized)try{let o=await a.sendMessage(this.type,this.id,this.cid,e.text||"",t,{parent_id:e.parent_id,quoted_message_id:e.quoted_message_id,mentioned_users:e.mentioned_users,mentioned_all:e.mentioned_all,forward_cid:e.forward_cid,forward_message_id:e.forward_message_id,forward_parent_cid:e.forward_parent_cid,e2ee_attachment_ids:e.e2ee_attachment_ids,attachments:e.attachments,sticker_url:e.sticker_url,poll_type:e.poll_type});if(o?.message){let c=o.message.user?.id||o.message.user_id||this.getClient().userID||"";this.state.addMessageSorted({...o.message,status:"received",user:Ue(c,o.message.user,this.getClient().state.users[c],this.getClient().user)},!0,!1)}return o}catch(o){let c=!o.response||o.code==="ERR_NETWORK"||o.isWSFailure||!this.getClient().wsConnection?.isHealthy;throw this.state.updateMessageStatus(t,c?"failed_offline":"error"),o}try{return await this.getClient().post(this._channelURL()+"/message",{message:{...e}})}catch(o){let l=!o.response||o.code==="ERR_NETWORK"||o.isWSFailure||!this.getClient().wsConnection?.isHealthy?"failed_offline":"error";throw this.state.updateMessageStatus(t,l),o}}_buildPendingE2eeLocalAttachments(e,t){return e.map((s,r)=>{let i=s,a=i.name||`attachment-${r+1}`,o=i.type||"application/octet-stream",c=t?.get(r)||{},l=typeof URL<"u"&&typeof URL.createObjectURL=="function"?URL.createObjectURL(s):"",p={id:Te(),title:a,file_name:a,file_size:s.size,mime_type:o,upload_status:"uploading",upload_progress:0,local_object_url:l,...c};return c.attachment_type==="voiceRecording"||o.startsWith("audio/")?{...p,type:"voiceRecording",attachment_type:"voiceRecording",asset_url:l,url:l}:o.startsWith("image/")?{...p,type:"image",image_url:l,thumb_url:l,url:l}:o.startsWith("video/")?{...p,type:"video",asset_url:l,url:l,thumb_url:l}:{...p,type:"file",url:l,asset_url:l}})}_revokePendingE2eeLocalAttachments(e){typeof URL>"u"||typeof URL.revokeObjectURL!="function"||e.forEach(t=>{let s=t?.local_object_url;typeof s=="string"&&s.startsWith("blob:")&&URL.revokeObjectURL(s)})}_findLocalMessageById(e){return this.state.findMessage(e)||this.state.messages.find(t=>t.id===e)}_removeLocalMessageById(e){let t=!1;for(;this.state.removeMessage({id:e});)t=!0;return t}_dispatchLocalMessageStateEvent(e,t){if(!t)return;let s=t.user||this.getClient().user,r={type:e,cid:this.cid,channel_type:this.type,channel_id:this.id,channel:this.data,created_at:new Date().toISOString(),message:t,user:s};this._callChannelListeners(r),this.getClient().dispatchEvent(r)}async enqueueE2eeAttachmentMessage(e,t,s={}){if(!this._isEffectiveE2ee())return await this.sendMessage(e);let r=this.getClient().encryptionManager;if(!r?.initialized)throw new Error("E2EE attachment queue requires an initialized encryption manager");e.id||(e={...e,id:Te()});let i=e.id,a=e.quoted_message||(e.quoted_message_id?this.state.findMessage(e.quoted_message_id):void 0),o=this._buildPendingE2eeLocalAttachments(t,s.displayOverrides),c=new Date().toISOString(),l={...e,id:i,attachments:o,quoted_message:a,status:"sending",created_at:c,updated_at:c,user:this.getClient().user,user_id:this.getClient().userID,type:e.type||"regular"};return this.state.addMessageSorted(l),this._dispatchLocalMessageStateEvent("message.new",this._findLocalMessageById(i)),r.enqueueE2eeAttachmentMessage({channelType:this.type,channelId:this.id,cid:this.cid,text:e.text||"",messageId:i,files:t,options:{parent_id:e.parent_id,quoted_message_id:e.quoted_message_id,mentioned_users:e.mentioned_users,mentioned_all:e.mentioned_all,forward_cid:e.forward_cid,forward_message_id:e.forward_message_id,forward_parent_cid:e.forward_parent_cid},displayOverrides:s.displayOverrides,localAttachments:o,onProgress:p=>{let d=Number.isInteger(p?.fileIndex)?p.fileIndex:void 0,u=d===void 0&&o.length>1,h=d??0,m=Math.max(0,Math.min(100,Math.round(p.percentage)));this.state.updateMessageById(i,g=>({...g,status:"sending",attachments:(g.attachments||[]).map((_,v)=>u||v===h?{..._,upload_status:p.phase,upload_progress:m}:_)})),this._dispatchLocalMessageStateEvent("message.updated",this._findLocalMessageById(i))},onSuccess:p=>{if(this._revokePendingE2eeLocalAttachments(o),p?.message){let d=p.message.user?.id||p.message.user_id||this.getClient().userID||"",u={...p.message,status:"received",user:Ue(d,p.message.user,this.getClient().state.users[d],this.getClient().user)};this._removeLocalMessageById(i),this.state.addMessageSorted(u,!0,!0,"current"),this._dispatchLocalMessageStateEvent("message.new",this._findLocalMessageById(i))}},onError:()=>{this.state.updateMessageById(i,p=>({...p,status:"error",attachments:(p.attachments||[]).map(d=>({...d,upload_status:"failed"}))})),this._dispatchLocalMessageStateEvent("message.updated",this._findLocalMessageById(i))}}),{message:l}}async cancelPendingE2eeSend(e){let t=this.state.messages.find(s=>s.id===e);this._revokePendingE2eeLocalAttachments(t?.attachments||[]),await this.getClient().encryptionManager?.cancelPendingE2eeSend(e),t&&(this._removeLocalMessageById(e),this._dispatchLocalMessageStateEvent("message.deleted",t))}async retryMessage(e){let t=this.state.messages.find(r=>r.id===e);if(!t)throw new Error(`Message ${e} not found in state`);this.state.updateMessageStatus(e,"sending");let s={id:t.id,text:t.text,attachments:t.attachments,mentioned_users:t.mentioned_users,parent_id:t.parent_id,quoted_message_id:t.quoted_message_id,sticker_url:t.sticker_url};t.show_in_channel!==void 0&&(s.show_in_channel=t.show_in_channel);try{return await this.getClient().post(this._channelURL()+"/message",{message:s})}catch(r){let i=!r.response||r.code==="ERR_NETWORK"||r.isWSFailure||!this.getClient().wsConnection?.isHealthy;throw this.state.updateMessageStatus(e,i?"failed_offline":"error"),r}}async createPoll(e){let t=Te();return e={...e,id:t},await this.getClient().post(this._channelURL()+"/message",{message:{...e}})}async votePoll(e,t){if(!e)throw Error("Message id is missing");return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/poll/${t}`)}async forwardMessage(e,t){e.id||(e={...e,id:Te()});let s=this.getClient().activeChannels[e.cid];if(!!s&&(typeof s._isEffectiveE2ee=="function"?s._isEffectiveE2ee():s.data?.mls_enabled===!0)){let i=this.getClient().encryptionManager;if(!i?.initialized)throw new Error("E2EE forward target is encrypted but encryption manager is not initialized");if((e.attachments?.length||0)>0&&!e.e2ee_attachment_ids?.length)throw new Error("E2EE forward with attachments requires freshly uploaded E2EE attachment IDs");return await i.sendMessage(t.type,t.channelID,e.cid,e.text||"",e.id,{forward_cid:e.forward_cid,forward_message_id:e.forward_message_id,forward_parent_cid:e.forward_parent_cid,e2ee_attachment_ids:e.e2ee_attachment_ids,attachments:e.attachments,sticker_url:e.sticker_url})}return await this.getClient().post(`${this.getClient().baseURL}/channels/${t.type}/${t.channelID}/message`,{message:{...e}})}async pinMessage(e){return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/pin`)}async unpinMessage(e){return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/unpin`)}async pin(){this.data&&(this.data.is_pinned=!0),this.getClient().dispatchEvent({type:"channel.pinned",cid:this.cid,channel:this.data});try{return await this.getClient().pinChannel(this.type,this.id)}catch(e){throw this.data&&(this.data.is_pinned=!1),this.getClient().dispatchEvent({type:"channel.unpinned",cid:this.cid,channel:this.data}),e}}async unpin(){this.data&&(this.data.is_pinned=!1),this.getClient().dispatchEvent({type:"channel.unpinned",cid:this.cid,channel:this.data});try{return await this.getClient().unpinChannel(this.type,this.id)}catch(e){throw this.data&&(this.data.is_pinned=!0),this.getClient().dispatchEvent({type:"channel.pinned",cid:this.cid,channel:this.data}),e}}async editMessage(e,t){let s=this._isEffectiveE2ee(),r=this.getClient().encryptionManager;if(s&&r?.initialized){let i=await r.updateMessage(this.type,this.id,this.cid,e,t.text,{mentioned_all:t.mentioned_all,mentioned_users:t.mentioned_users}),a=await r.storage?.loadE2eeMessage(e).catch(()=>null);if(a){let o=a.user_id?this.getClient().state.users[a.user_id]:void 0;this.state.addMessageSorted({...a,content_type:"standard",user:Ue(a.user_id,o,a.user,this.getClient().user)},!1,!1)}return i}return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}`,{message:t})}sendFile(e,t,s,r){return this.getClient().sendFile(`${this._channelURL()}/file`,e,t,s,r)}async uploadFilePresigned(e,t,s,r){let i=await this.getClient().post(`${this._channelURL()}/file/presign`,{file_name:t,content_type:s});return await new Promise((o,c)=>{if(typeof XMLHttpRequest<"u"){let l=new XMLHttpRequest;l.open("PUT",i.upload_url),l.setRequestHeader("Content-Type",s),l.upload.onprogress=({loaded:p,total:d})=>{d>0&&r&&r({loaded:p,total:d,percentage:Math.round(p/d*100)})},l.onload=()=>{l.status<300?o():c(new Error(`Upload failed: HTTP ${l.status}`))},l.onerror=()=>c(new Error("Network error")),l.send(e)}else fetch(i.upload_url,{method:"PUT",headers:{"Content-Type":s},body:e}).then(l=>{l.ok?o():c(new Error(`Upload failed: HTTP ${l.status}`))}).catch(c)}),await this.getClient().post(`${this._channelURL()}/file/confirm`,{attachment_id:i.attachment_id,file_name:t,content_type:s})}async uploadAndPrepareAttachments(e,t){let s=[],r=e.map(l=>{let p=Ln(l.name);return p!==l.name?new File([l],p,{type:l.type,lastModified:l.lastModified}):l}),i=await Promise.allSettled(r.map(l=>this.uploadFilePresigned(l,l.name,l.type||"application/octet-stream"))),a=new Map,o=[];for(let l=0;l<r.length;l++)i[l].status==="fulfilled"&&ci(r[l])&&o.push((async()=>{try{let d=await this.getThumbBlobVideo(e[l]);if(d){let u=new File([d],`thumb_${r[l].name}.jpg`,{type:"image/jpeg"}),h=await this.uploadFilePresigned(u,u.name,"image/jpeg");a.set(l,h.file)}}catch{}})());await Promise.allSettled(o);let c=[];for(let l=0;l<r.length;l++){let p=i[l];if(p.status==="fulfilled"){let d=p.value.file,u=a.get(l),h=t?.voiceMetadata?.get(l);c.push(li(r[l],d,u,h))}else s.push({file:e[l],error:p.reason instanceof Error?p.reason:new Error(String(p.reason))})}return{attachments:c,failedFiles:s}}async sendEvent(e){return await this.getClient().post(this._channelURL()+"/event",{event:e})}async sendReaction(e,t){if(!e)throw Error("Message id is missing");return await this.getClient().post(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/reaction/${t}`)}deleteReaction(e,t){if(!t||!e)throw Error("Deleting a reaction requires specifying both the message and reaction type");let s=this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}/reaction/${t}`;return this.getClient().delete(s,{})}async update(e={},t){return["config","cid","created_by","id","member_count","type","created_at","updated_at","last_message_at","own_capabilities"].forEach(r=>{delete e[r]}),await this._update({message:t,data:e})}async delete(){return await this.getClient().delete(this._channelURL())}async truncate(e){let t=e?.for_me?"?for_me=true":"",s=await this.getClient().delete(this._channelURL()+"/chat"+t),r=s?.channel?.truncated_at||new Date().toISOString();this.state.clearMessages(),this.data&&(this.data.truncated_at=r);let a={type:e?.for_me?"channel.truncate_for_me":"channel.truncate",channel:s?.channel||this.data,created_at:r,cid:this.cid,channel_type:this.type,channel_id:this.id};return this._handleChannelEvent(a),this._callChannelListeners(a),this.getClient().dispatchEvent(a),s}async blockUser(){return await this.getClient().post(this._channelURL(),{action:"block"})}async unblockUser(){return await this.getClient().post(this._channelURL(),{action:"unblock"})}async acceptInvite(e){let t=this.id,s=this.getClient().userBaseURL+`/token_gate/join_channel/${this.type}`;return this.getClient().post(s,{},{channel_id:t,action:e})}async rejectInvite(){let e=this.getClient().baseURL+`/invites/${this.type}/${this.id}/reject`;return this.getClient().post(e)}async skipInvite(){let e=this.getClient().baseURL+`/invites/${this.type}/${this.id}/skip`;return this.getClient().post(e)}async addMembers(e){return await this._update({add_members:e})}async addMembersE2ee(e,t){return await this._update({add_members:e,...t})}async addModerators(e){return await this._update({promote_members:e})}async banMembers(e){return await this._update({ban_members:e})}async unbanMembers(e){return await this._update({unban_members:e})}async updateCapabilities(e){return await this._update({capabilities:e})}async setSlowMode(e){let t=[0,1e4,3e4,6e4,3e5,9e5,36e5];if(!t.includes(e))throw new Error(`Invalid cooldown value: ${e}. Allowed values are: ${t.join(", ")} (milliseconds).`);return await this.update({member_message_cooldown:e})}async queryAttachmentMessages(){if(this._isEffectiveE2ee()){let t=this.getClient().encryptionManager;return t?.initialized?await t.queryE2eeAttachmentMessages(this.type,this.id,{limit:50}):{attachments:[]}}let e=await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/attachment`,{attachment_types:["image","video","file","voiceRecording","linkPreview"]});return e.attachments&&e.attachments.sort((t,s)=>new Date(s.created_at).getTime()-new Date(t.created_at).getTime()),e}async searchMessage(e,t){let s=this._isEffectiveE2ee(),r=this.data?.mls_enabled_at;if(!s)return this._searchServerMessages(e,t);if(!r)return this._searchLocalE2eeMessages(e,t);let[i,a]=await Promise.allSettled([this._searchServerMessages(e,0).catch(()=>null),this._searchLocalE2eeMessages(e,0)]),o=i.status==="fulfilled"&&i.value?i.value.messages||[]:[],c=a.status==="fulfilled"&&a.value?a.value.messages||[]:[],l=new Set,p=[...o,...c].filter(d=>l.has(d.id)?!1:(l.add(d.id),!0)).sort((d,u)=>new Date(u.created_at).getTime()-new Date(d.created_at).getTime());return p.length===0?null:{total:p.length,messages:p.slice(t,t+25)}}async _searchServerMessages(e,t){let s=await this.getClient().post(this.getClient().baseURL+"/channels/search",{cid:this.cid,search_term:e,offset:t,limit:25});if(!s||s?.search_result?.messages.length===0)return null;let r=Object.values(this.getClient().state.users),i=s?.search_result?.messages.map(a=>{let o=Ue(a.user_id,this.getClient().state.users[a.user_id],a.user,Z(a.user_id,r),a.user_id===this.getClient().userID?this.getClient().user:void 0);return{...a,user:o}});return{...s?.search_result,messages:await this._hydrateE2eeMessagesFromLocalCache(i)}}async _searchLocalE2eeMessages(e,t){let s=this.getClient().encryptionManager;if(!s?.storage)return null;let r=await s.storage.searchE2eeMessagesByCid(this.cid,e,100);if(!r||r.length===0)return null;let i=Object.values(this.getClient().state.users),a=r.slice(t,t+25).map(o=>{let c=Ue(o.user_id,this.getClient().state.users[o.user_id],o.user,Z(o.user_id,i),o.user_id===this.getClient().userID?this.getClient().user:void 0);return{...o,user:c}});return{total:r.length,messages:a}}async removeMembers(e){return await this._update({remove_members:e})}async removeMembersE2ee(e,t){return await this._update({remove_members:e,...t,self_remove:!1})}async leaveChannelE2ee(e){let t=this.getClient().user?.id;if(t&&e!==t)throw new Error("[E2EE] leaveChannelE2ee can only remove the current user");let s=await this._update({remove_members:[e],self_remove:!0}),r=this.getClient().encryptionManager;return r?.initialized&&this.cid&&r.leaveGroup(this.cid,Date.now()),s}async demoteModerators(e){return await this._update({demote_members:e})}async _update(e){let t=await this.getClient().post(this._channelURL(),this._encodeE2eeChannelPayload(e));return this.data={...this.data,...t.channel},t}_processTopics(e,t){let s=e.map(i=>(i.channel&&i.channel.members&&(i.channel.members=de(i.channel.members,t)),i.messages&&(i.messages=de(i.messages,t)),i.pinned_messages&&(i.pinned_messages=de(i.pinned_messages,t)),i.read&&(i.read=de(i.read,t)),i)),{channels:r}=this.getClient().hydrateChannels(s,{});this.state.topics=r}async muteNotification(e){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/muted`,{mute:!0,duration:e})}async unMuteNotification(){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/muted`,{mute:!1})}async keystroke(e,t){let s=new Date,r=this.lastTypingEvent&&s.getTime()-this.lastTypingEvent.getTime();this.lastKeyStroke=s,this.isTyping=!0,(r===null||r>2e3)&&(this.lastTypingEvent=new Date,await this.sendEvent({type:"typing.start",parent_id:e,...t||{}}))}async stopTyping(e,t){this.isTyping&&(this.lastTypingEvent=null,this.isTyping=!1,await this.sendEvent({type:"typing.stop",parent_id:e,...t||{}}))}_isTypingIndicatorsEnabled(){return!0}lastMessage(){let e=this.state.latestMessages.length-5;e<0&&(e=0);let t=this.state.latestMessages.length+1,s=this.state.latestMessages.slice(e,t);return s.sort((r,i)=>i.created_at.getTime()-r.created_at.getTime()),s[0]}async markRead(){return this.state.unreadCount>0&&(this.state.unreadCount=0,this.getClient().dispatchEvent({type:"message.read",cid:this.cid,channel_id:this.id,channel_type:this.type,user:this.getClient().user,created_at:new Date().toISOString()})),await this.getClient().post(this._channelURL()+"/read")}clean(){this.lastKeyStroke&&new Date().getTime()-this.lastKeyStroke.getTime()>1e3&&this.isTyping&&ai(this.stopTyping(),"stop typing event"),this.state.clean()}async watch(e){await this.getClient().wsPromise;let t={...e},s=await this.query(t,"latest");this.initialized=!0,await xt(this.getClient(),s.channel.members);let r=Object.values(this.getClient().state.users);return s.channel.members=de(s.channel.members,r),s.channel.name=s.channel.type==="messaging"?hs(s.channel.members,this.getClient().userID||""):s.channel.name,s.channel.image=s.channel.type==="messaging"?Un(s.channel.members,this.getClient().userID||""):s.channel.image,s.messages=de(s.messages,r),s.pinned_messages=s.pinned_messages?de(s.pinned_messages,r):[],s.read=de(s.read||[],r),this.data=s.channel,this._client.logger("info",`channel:watch() - started watching channel ${this.cid}`,{tags:["channel"],channel:this}),s}lastRead(){let{userID:e}=this.getClient();if(e)return this.state.read[e]?this.state.read[e].last_read:null}_countMessageAsUnread(e){return!(e.parent_id&&!e.show_in_channel||e.user?.id===this.getClient().userID||e.type==="system"||Array.isArray(this.data?.own_capabilities)&&!this.data?.own_capabilities.includes("read-events"))}countUnread(e){if(!e)return this.state.unreadCount;let t=0;for(let s=0;s<this.state.latestMessages.length;s+=1){let r=this.state.latestMessages[s];r.created_at>e&&this._countMessageAsUnread(r)&&t++}return t}getUnreadMemberCount(){return this.state.read?Object.values(this.state.read):[]}getCapabilitiesMember(){return this.data?this.data.member_capabilities:[]}create=async()=>this.type==="messaging"?await this.createDirectChannel("latest"):await this.query({},"latest");async createTopic(e){let t=this._client.projectId,s=Te(),r=`${t}:${s}`,i=`topic:${r}`,a=`${this.getClient().baseURL}/channels/topic/${r}`,o={project_id:t,parent_cid:this.cid,data:{...e}},c=this._isEffectiveE2ee(),l=e?.mls_enabled===!0,d=e?.gate===!0||!c&&l;if(c||l){let h=this.getClient().encryptionManager;if(o.data.mls_enabled=!0,d?o.data.e2ee_recovery_policy=e?.e2ee_recovery_policy||"member_assisted":delete o.data.e2ee_recovery_policy,d&&h?.initialized)try{let m=Object.keys(this.state?.members||{}),g=await h.createE2eeTopic(i,m);o.data.commit=g.commit,o.data.welcome=g.welcome,o.data.ratchet_tree=g.ratchet_tree,o.data.group_info=g.group_info,o.data.epoch=g.epoch}catch(m){this.getClient().logger("error","[Encryption] createTopic: failed to prepare E2EE bundle",{err:m,cid:i})}}return await this.getClient().post(a+"/query",this._encodeE2eeChannelPayload(o))}async query(e,t="current"){await this.getClient().wsPromise,this._seedE2eeStateFromLocalCache(e,t);let s=this._client.projectId,r=this._isE2eeQuery()?{project_id:s}:{...e,project_id:s},i=`${this.getClient().baseURL}/channels/${this.type}`;if(this.id)i+=`/${this.id}`;else if(this.type==="team"||this.type==="meeting"){let h=Te();this.id=`${s}:${h}`,i+=`/${this.id}`}let a={state:!0,...r},o=this._queryDataPayload();o&&(a.data=o);let c=await this.getClient().post(i+"/query",this._encodeE2eeChannelPayload(a));await xt(this.getClient(),c.channel.members);let l=Object.values(this.getClient().state.users);c.channel.members=de(c.channel.members,l),c.channel.name=c.channel.type==="messaging"?hs(c.channel.members,this.getClient().userID||""):c.channel.name,c.channel.image=c.channel.type==="messaging"?Un(c.channel.members,this.getClient().userID||""):c.channel.image,c.messages=de(c.messages,l),c.pinned_messages=c.pinned_messages?de(c.pinned_messages,l):[],c.read=de(c.read||[],l),c.channel.is_pinned=c.is_pinned||!1,c.messages=await this._hydrateE2eeMessagesFromLocalCache(c.messages,c.channel),c.pinned_messages=await this._hydrateE2eeMessagesFromLocalCache(c.pinned_messages||[],c.channel);let p=this.cid;if(p!==c.channel.cid){this.id=c.channel.id,this.cid=c.channel.cid,p in this.getClient().activeChannels&&delete this.getClient().activeChannels[p];let h=c.channel.members.map(g=>g.user_id||g.user?.id).sort().join(","),m=`${this.type}:!members-${h}`;m in this.getClient().activeChannels&&delete this.getClient().activeChannels[m],this.cid in this.getClient().activeChannels||(this.getClient().activeChannels[this.cid]=this)}else this.cid in this.getClient().activeChannels||(this.getClient().activeChannels[this.cid]=this);let{messageSet:d}=this._initializeState(c,t),u=[...c.channel.own_capabilities||[]].sort().join()!==[...Array.isArray(this.data?.own_capabilities)?this.data?.own_capabilities:[]].sort().join();return this.data=c.channel,this.offlineMode=!1,u&&this.getClient().dispatchEvent({type:"capabilities.changed",cid:this.cid,own_capabilities:c.channel.own_capabilities}),c}async createDirectChannel(e="current"){await this.getClient().wsPromise;let t=this._client.projectId,s=`${this.getClient().baseURL}/channels/${this.type}`,r={project_id:t},i=this._queryDataPayload();i&&(r.data=i);let a=await this.getClient().post(s+"/query",this._encodeE2eeChannelPayload(r));await xt(this.getClient(),a.channel.members);let o=Object.values(this.getClient().state.users);a.channel.members=de(a.channel.members,o),a.channel.name=a.channel.type==="messaging"?hs(a.channel.members,this.getClient().userID||""):a.channel.name,a.messages=de(a.messages,o),a.pinned_messages=a.pinned_messages?de(a.pinned_messages,o):[],a.read=de(a.read||[],o),a.messages=await this._hydrateE2eeMessagesFromLocalCache(a.messages,a.channel),a.pinned_messages=await this._hydrateE2eeMessagesFromLocalCache(a.pinned_messages||[],a.channel);let{messageSet:c}=this._initializeState(a,e),l=[...a.channel.own_capabilities||[]].sort().join()!==[...Array.isArray(this.data?.own_capabilities)?this.data?.own_capabilities:[]].sort().join();return this.data=a.channel,this.offlineMode=!1,l&&this.getClient().dispatchEvent({type:"capabilities.changed",cid:a.channel.cid,own_capabilities:a.channel.own_capabilities}),a}async queryMessagesLessThanId(e,t=25){await this.getClient().wsPromise;let s=this._client.projectId,r=`${this.getClient().baseURL}/channels/${this.type}/${this.id}`,i=await this.getClient().post(r+"/query",{state:!0,project_id:s,messages:{limit:t,id_lt:e}}),a=(i.messages||[]).filter(c=>c.user_id||c.user?.id).map(c=>({user:{id:c.user?.id||c.user_id}}));await xt(this.getClient(),a);let o=Object.values(this.getClient().state.users);if(i.messages=de(i.messages,o),i.messages=await this._hydrateE2eeMessagesFromLocalCache(i.messages),i.messages&&i.messages.length>0){for(let c of i.messages)if(!c.pinned){let l=this.state.pinnedMessages?.find(p=>p.id===c.id);if(l){c.pinned=!0;let p=l.pinned_at||new Date;c.pinned_at=typeof p=="string"?p:p.toISOString()}}this.state.addMessagesSorted(i.messages,!1,!0,!0,"current")}return i.messages}async queryMessagesGreaterThanId(e,t=25){await this.getClient().wsPromise;let s=this._client.projectId,r=`${this.getClient().baseURL}/channels/${this.type}/${this.id}`,i=await this.getClient().post(r+"/query",{state:!0,project_id:s,messages:{limit:t,id_gt:e}}),a=(i.messages||[]).filter(c=>c.user_id||c.user?.id).map(c=>({user:{id:c.user?.id||c.user_id}}));await xt(this.getClient(),a);let o=Object.values(this.getClient().state.users);if(i.messages=de(i.messages,o),i.messages=await this._hydrateE2eeMessagesFromLocalCache(i.messages),i.messages&&i.messages.length>0){for(let c of i.messages)if(!c.pinned){let l=this.state.pinnedMessages?.find(p=>p.id===c.id);if(l){c.pinned=!0;let p=l.pinned_at||new Date;c.pinned_at=typeof p=="string"?p:p.toISOString()}}this.state.addMessagesSorted(i.messages,!1,!0,!0,"current")}return i.messages}async queryMessagesAroundId(e,t=25){await this.getClient().wsPromise;let s=this._client.projectId,r=`${this.getClient().baseURL}/channels/${this.type}/${this.id}`,i=await this.getClient().post(r+"/query",{state:!0,project_id:s,messages:{limit:t,id_around:e}}),a=(i.messages||[]).filter(c=>c.user_id||c.user?.id).map(c=>({user:{id:c.user?.id||c.user_id}}));await xt(this.getClient(),a);let o=Object.values(this.getClient().state.users);if(i.messages=de(i.messages,o),i.messages=await this._hydrateE2eeMessagesFromLocalCache(i.messages),i.messages&&i.messages.length>0){for(let c of i.messages)if(!c.pinned){let l=this.state.pinnedMessages?.find(p=>p.id===c.id);if(l){c.pinned=!0;let p=l.pinned_at||new Date;c.pinned_at=typeof p=="string"?p:p.toISOString()}}this.state.addMessagesSorted(i.messages,!1,!0,!0,"current")}return i.messages}async deleteMessage(e){return await this.getClient().delete(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}`)}async deleteMessageForMe(e){return await this.getClient().delete(this.getClient().baseURL+`/messages/${this.type}/${this.id}/${e}`,{for_me:!0})}async getThumbBlobVideo(e){return new Promise(t=>{let s=null,r=()=>{s&&clearTimeout(s),i.src&&URL.revokeObjectURL(i.src),i.remove()};s=window.setTimeout(()=>{this._client.logger("warn","channel:getThumbBlobVideo() - Timeout extracting video thumbnail",{cid:this.cid}),r(),t(null)},5e3);let i=document.createElement("video");i.src=URL.createObjectURL(e),i.crossOrigin="anonymous",i.muted=!0,i.load();let a=0,o=5,c=1;i.addEventListener("error",()=>{this._client.logger("error","channel:getThumbBlobVideo() - Error when loading video file",{cid:this.cid}),r(),t(null)});let l=()=>{try{let p=document.createElement("canvas");p.width=i.videoWidth,p.height=i.videoHeight;let d=p.getContext("2d",{willReadFrequently:!0});if(!d){this._client.logger("error","channel:getThumbBlobVideo() - Failed to create canvas context",{cid:this.cid}),r(),t(null);return}d.drawImage(i,0,0,p.width,p.height);let h=d.getImageData(0,0,p.width,p.height).data,m=0,g=40,_=0;for(let y=0;y<h.length;y+=g*4){let x=h[y],C=h[y+1],S=h[y+2];m+=.2126*x+.7152*C+.0722*S,_++}if(m/_<15&&a<o&&i.currentTime+c<i.duration){a++,i.currentTime+=c;return}p.toBlob(y=>{if(r(),!y){this._client.logger("error","channel:getThumbBlobVideo() - Failed to generate thumbnail",{cid:this.cid}),t(null);return}t(y)},"image/jpeg",.75)}catch(p){this._client.logger("error","channel:getThumbBlobVideo() - Error while extracting thumbnail",{cid:this.cid,error:p}),r(),t(null)}};i.addEventListener("loadedmetadata",()=>{i.currentTime=Math.min(.5,i.duration)}),i.addEventListener("seeked",l)})}async enableTopics(){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics/enable`,{project_id:this.getClient().projectId,messages:{limit:25}})}async disableTopics(){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics/disable`,{project_id:this.getClient().projectId})}async closeTopic(e){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics/close`,{project_id:this.getClient().projectId,topic_cid:e})}async reopenTopic(e){return await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics/reopen`,{project_id:this.getClient().projectId,topic_cid:e})}async editTopic(e,t){let s=await this.getClient().post(this.getClient().baseURL+`/channels/${this.type}/${this.id}/topics`,{project_id:this.getClient().projectId,topic_cid:e,data:t});if(s){let r=this.getClient().activeChannels[e];return r?(r.data=s.channel,r.data):s.channel}}on(e,t){let s=t?e:"all",r=t||e;return s in this.listeners||(this.listeners[s]=[]),this._client.logger("info",`Attaching listener for ${s} event on channel ${this.cid}`,{tags:["event","channel"],channel:this}),this.listeners[s].push(r),{unsubscribe:()=>{this._client.logger("info",`Removing listener for ${s} event from channel ${this.cid}`,{tags:["event","channel"],channel:this}),this.listeners[s]=this.listeners[s].filter(i=>i!==r)}}}off(e,t){let s=t?e:"all",r=t||e;s in this.listeners||(this.listeners[s]=[]),this._client.logger("info",`Removing listener for ${s} event from channel ${this.cid}`,{tags:["event","channel"],channel:this}),this.listeners[s]=this.listeners[s].filter(i=>i!==r)}async _handleChannelEvent(e){let t=this;this._client.logger("info",`channel:_handleChannelEvent - Received event of type { ${e.type} } on ${this.cid}`,{tags:["event","channel"],channel:this});let s=t.state,r=Object.values(this.getClient().state.users);switch(e.type){case"typing.start":if(e.user?.id){let l=Z(e.user.id||"",r);e.user=l,s.typing[e.user.id]=e}break;case"typing.stop":e.user?.id&&delete s.typing[e.user.id];break;case"message.read":if(e.user?.id&&e.created_at){let l=Z(e.user.id||"",r);e.user=l,s.read[e.user.id]={last_read:new Date(e.created_at),last_read_message_id:e.last_read_message_id,user:l,unread_messages:0},e.user?.id===this.getClient().user?.id&&(s.unreadCount=0)}break;case"user.watching.start":e.user?.id&&(s.watchers[e.user.id]=e.user);break;case"user.watching.stop":e.user?.id&&delete s.watchers[e.user.id];break;case"message.deleted":if(e.message){this._extendEventWithOwnReactions(e),s.removeMessage(e.message),s.latestMessages.length===0&&this.query({messages:{limit:1}}).then(()=>{this._callChannelListeners({type:"channel.updated",cid:this.cid,channel:this.data})}).catch(u=>{this._client.logger("error","Failed to query for new last message after deletion",{err:u})}),s.removeQuotedMessageReferences(e.message),[...s.pinnedMessages].some(u=>u.id===e.message?.id)&&s.removePinnedMessage(e.message);let l=e.message.created_at?new Date(e.message.created_at):null;for(let u in s.read){u!==e.user?.id&&e.message.id===s.read[u].last_read_message_id&&(s.read[u]={...s.read[u],last_read_message_id:void 0});let h=s.read[u],m=h.last_read?new Date(h.last_read):new Date(0);if(l&&l>m){let g=e.message.user?.id===u||e.message.user_id===u,_=e.message.type==="system";!g&&!_&&(h.unread_messages=Math.max(0,h.unread_messages-1),u===this.getClient().userID&&(s.unreadCount=Math.max(0,s.unreadCount-1)))}}let p=this.getClient().encryptionManager;if(this._isEffectiveE2ee()&&p?.initialized&&e.message.id)try{await p.storage.deleteE2eeMessage(e.message.id)}catch(u){this.getClient().logger("warn","[Encryption] Failed to delete message from local DB",{err:u,message_id:e.message.id})}}break;case"message.deleted_for_me":e.message&&(delete e.message.user,delete e.message.user_id,e.message.display_type="deleted",e.message.pinned_at=null,e.message.updated_at=null,e.message.status="received",s.addMessageSorted(e.message),s.removeQuotedMessageReferences(e.message),[...s.pinnedMessages].some(l=>l.id===e.message?.id)&&s.removePinnedMessage(e.message));break;case"message.new":if(e.message){let l=e.user?.id===this.getClient().user?.id,p=!!e.message.parent_id,d=r.find(y=>y.id===e.user?.id),u=d&&d.name&&d.name!==d.id;if((!d||!u)&&e.user?.id)try{let y=await this.getClient().queryUser(e.user.id);d?Object.assign(d,y):r.push(y)}catch(y){this._client.logger("warn","Failed to query user for new message, using event user fallback",{err:y}),d||r.push(e.user)}let h=Z(e.user?.id||"",r);if(e.message.user=h,e.message?.quoted_message){let y=Z(e.message.quoted_message.user?.id||"",r);e.message.quoted_message.user=y}e.user=h;let m=this.getClient().encryptionManager,g=e.message.content_type==="mls"&&!!e.message.mls_ciphertext,_=l&&(!m?.deviceId||e.message.device_id===m.deviceId);if((this.state.isUpToDate||p)&&(g&&_||s.addMessageSorted(e.message,l)),!_&&m?.initialized&&g&&this.cid&&m.processE2eeMessage(this.cid,e.message).then(y=>{if(y){let x={...e.message,...y,content_type:"standard"};s.addMessageSorted(x,!1,!1),this.getClient().dispatchEvent({type:"e2ee.message_decrypted",message:x,cid:this.cid})}else this.getClient().dispatchEvent({type:"e2ee.message_decrypted",message:{id:e.message.id,e2ee_status:"failed",text:""},cid:this.cid})}).catch(y=>{this.getClient().logger("error","[E2EE] Failed to decrypt message",{err:y,cid:this.cid})}),l||p)break;if(e.user?.id)for(let y in s.read)y===e.user.id?s.read[e.user.id]={last_read:new Date(e.created_at),user:e.user,unread_messages:0}:s.read[y].unread_messages+=1;this._countMessageAsUnread(e.message)&&(s.unreadCount=s.unreadCount+1)}break;case"message.updated":if(e.message){let l=Z(e.user?.id||"",r),p=Z(e.message.user?.id||"",r);if(e.user=l,e.message.user=p,e.message?.quoted_message){let g=Z(e.message.quoted_message.user?.id||"",r);e.message.quoted_message.user=g}e.message?.latest_reactions&&(e.message.latest_reactions=de(e.message.latest_reactions||[],r));let d=this.getClient().encryptionManager,u=e.user?.id===this.getClient().user?.id,h=e.message.content_type==="mls"&&!!e.message.mls_ciphertext,m=u&&(!d?.deviceId||e.message.device_id===d.deviceId);if(!m&&d?.initialized&&h&&this.cid){d.processE2eeMessage(this.cid,e.message).then(g=>{if(g){let _={...g,content_type:"standard"};s.addMessageSorted(_,!1,!1),this.getClient().dispatchEvent({type:"e2ee.message_decrypted",message:_,cid:this.cid})}else this.getClient().dispatchEvent({type:"e2ee.message_decrypted",message:{id:e.message.id,e2ee_status:"failed",text:""},cid:this.cid})}).catch(g=>{this.getClient().logger("error","[E2EE] Failed to decrypt updated message",{err:g,cid:this.cid})});break}if(h&&m)break;this._extendEventWithOwnReactions(e),s.addMessageSorted(e.message,!1,!1),e.message.pinned?s.addPinnedMessage(e.message):s.removePinnedMessage(e.message)}break;case"message.pinned":if(e.message){let l=Z(e.message.user?.id||"",r);e.message.user=l,s.addPinnedMessage(e.message),s.addMessageSorted(e.message,!1,!1)}break;case"message.unpinned":if(e.message){let l=Z(e.message.user?.id||"",r);e.message.user=l,s.removePinnedMessage(e.message),s.addMessageSorted(e.message,!1,!1)}break;case"channel.truncate":case"channel.truncate_for_me":{let l=e.channel?.truncated_at||e.created_at;if(l){let p=new Date(l).getTime();s.messageSets.forEach((u,h)=>{[...u.messages].forEach(({created_at:g,id:_})=>{let v=new Date(g||"").getTime();p>=v&&s.removeMessage({id:_,messageSetIndex:h})})}),[...s.pinnedMessages].forEach(({id:u,created_at:h})=>{let m=new Date(h||"").getTime();p>=m&&s.removePinnedMessage({id:u})})}else s.clearMessages();s.unreadCount=0,e.message&&(s.addMessageSorted(e.message),e.message.pinned&&s.addPinnedMessage(e.message));break}case"member.added":if(e.member?.user_id){let l=Z(e.member.user_id,r);e.member.user=l,s.members[e.member.user_id]=e.member,e.member.user?.id===this.getClient().user?.id&&(s.membership=e.member)}break;case"member.updated":if(e.member?.user_id){let l=Z(e.member.user_id,r);e.member.user=l,s.members[e.member.user_id]=e.member,s.membership=e.member}break;case"member.removed":{let l=e.member?.user_id||e.user?.id;if(l){delete s.members[l];let p=this.getClient().encryptionManager,d=e.user?.id,u=this.getClient().user?.id,h=l===u,m=e.self_remove===!0||e.self_remove===void 0&&!!d&&l===d,g=e.created_at||e.createdAt||e.message?.created_at;if(h){if(p?.initialized&&this.cid&&(p.leaveGroup(this.cid,g),Array.isArray(e.topic_cids)))for(let _ of e.topic_cids)p.ownsE2eeGroup(_)&&p.leaveGroup(_,g)}else if(m&&e.mls_enabled&&p?.initialized&&this.cid&&this.type&&this.id&&p.isDesignatedEvictor(t)&&(p.evictMember(this.type,this.id,this.cid,l,!0).catch(_=>{this.getClient().logger("error","[Encryption Event] evictMember after member.removed failed",{err:_,cid:this.cid,user_id:l})}),Array.isArray(e.topic_cids)))for(let _ of e.topic_cids){if(!p.ownsE2eeGroup(_))continue;let v=_.indexOf(":"),y=_.substring(0,v),x=_.substring(v+1);p.evictMember(y,x,_,l,!0).catch(C=>{this.getClient().logger("error","[Encryption Event] topic evictMember after member.removed failed",{err:C,cid:_,user_id:l})})}}break}case"channel.topic.enabled":t.data&&(t.data.topics_enabled=!0),s.topics=s.topics||[],e.user=Z(e.user?.id||"",r);break;case"channel.topic.disabled":t.data&&(t.data.topics_enabled=!1),s.topics=[],e.user=Z(e.user?.id||"",r);break;case"channel.updated":if(e.channel){t.data={...t.data,...e.channel,own_capabilities:e.channel?.own_capabilities??t.data?.own_capabilities};let l=this.getClient().encryptionManager,p=e.channel;l?.initialized&&p?.mls_enabled&&p?.mls_enabled_at&&this.cid&&!l.isChannelEncryptionSyncBlocked(this.cid)&&l.ensureChannelReady(this.type,this.id,this.cid,{source:"channel_updated"}).catch(d=>{this.getClient().logger("error","[Encryption Event] Failed to ensure channel after channel.updated",{err:d,cid:this.cid})})}break;case"pollchoice.new":if(e.message){let l=Z(e.message.user?.id||"",r);e.message.user=l,s.addMessageSorted(e.message,!1,!1)}break;case"reaction.new":if(e.message&&e.reaction){let l=Z(e.message.user?.id||"",r),p=Z(e.reaction.user?.id||"",r);if(e.message.user=l,e.message.latest_reactions=de(e.message.latest_reactions||[],r),e.reaction.user=p,e.message?.quoted_message){let h=Z(e.message.quoted_message.user?.id||"",r);e.message.quoted_message.user=h}e.message=s.addReaction(e.reaction,e.message);let d=this.getClient().encryptionManager;this._isEffectiveE2ee()&&d?.initialized&&e.message?.id&&d.storage.loadE2eeMessage(e.message.id).then(h=>{h&&d.storage.saveE2eeMessage({...h,latest_reactions:e.message?.latest_reactions,reaction_counts:e.message?.reaction_counts})}).catch(h=>{this.getClient().logger("warn","[Encryption] Failed to update E2EE cache for reaction.new",{err:h})})}break;case"reaction.deleted":if(e.user=Z(e.user?.id||"",r),e.message){if(e.message?.quoted_message){let l=Z(e.message.quoted_message.user?.id||"",r);e.message.quoted_message.user=l}e.message.user=Z(e.message.user?.id||"",r),e.message.latest_reactions?.map(l=>(l.user=Z(l.user?.id||"",r),l))}e.reaction&&(e.reaction.user=Z(e.reaction.user?.id||"",r),e.message=s.removeReaction(e.reaction,e.message));{let l=this.getClient().encryptionManager;this._isEffectiveE2ee()&&l?.initialized&&e.message?.id&&l.storage.loadE2eeMessage(e.message.id).then(d=>{d&&l.storage.saveE2eeMessage({...d,latest_reactions:e.message?.latest_reactions,reaction_counts:e.message?.reaction_counts})}).catch(d=>{this.getClient().logger("warn","[Encryption] Failed to update E2EE cache for reaction.deleted",{err:d})})}break;case"member.joined":case"notification.invite_accepted":if(e.member?.user_id){if(!r.find(u=>u.id===e.member?.user_id))try{let u=await this.getClient().queryUser(e.member?.user_id);r.push(u)}catch(u){this._client.logger("warn","Failed to query user for member joined, using event member fallback",{err:u}),e.member?.user&&r.push(e.member.user)}let p=Z(e.member.user_id,r);e.member.user=p,e.member.user_id===this.getClient().user?.id&&(s.membership=e.member,this.state.membership=e.member),s.members[e.member.user_id]=e.member,t.data={...t.data,member_count:Number(t.data?.member_count)+1,members:t.data?.members?[...t.data.members,e.member]:[e.member]},this.offlineMode=!0,this.initialized=!0;let d=this.getClient().encryptionManager;e.mls_enabled&&d?.initialized&&e.member.user_id===this.getClient().user?.id&&this.cid&&d.ensureChannelReady(this.type,this.id,this.cid,{source:"invite_accepted"}).then(async()=>{d.isRecoveryVaultUnlocked()&&await d.repairRecoveryChannel(this.type,this.id,{mode:"recheck_channel"})}).catch(u=>{this.getClient().logger("error","[Encryption Event] Failed to prepare recovery after invite_accepted",{err:u,cid:this.cid})})}break;case"notification.invite_rejected":if(e.member?.user_id){delete s.members[e.member.user_id];let l=this.getClient().encryptionManager;if(e.mls_enabled&&l?.initialized&&this.cid&&this.type==="team"&&this.id){let p=e.member.user_id;if(l.queuePendingEviction(this.cid,p).catch(d=>{this.getClient().logger("error","[Encryption Event] Failed to queue pending eviction after invite_rejected",{err:d,cid:this.cid,user_id:p})}),Array.isArray(e.topic_cids))for(let d of e.topic_cids)d.indexOf(":")<=0||l.ownsE2eeGroup(d)&&l.queuePendingEviction(d,p).catch(h=>{this.getClient().logger("error","[Encryption Event] Failed to queue topic pending eviction after invite_rejected",{err:h,cid:d,user_id:p})})}}break;case"notification.invite_messaging_skipped":if(e.member?.user_id){let l=Z(e.member.user_id,r);e.member.user=l,e.member.user_id===this.getClient().user?.id&&(s.membership=e.member,this.state.membership=e.member),s.members[e.member.user_id]=e.member;let p=this.getClient().encryptionManager;if(e.mls_enabled&&p?.initialized&&this.cid&&this.type&&this.id&&p.isDesignatedEvictor(t)){let d=e.member.user_id;p.evictMember(this.type,this.id,this.cid,d).catch(u=>{this.getClient().logger("error","[Encryption Event] Failed to evictMember after invite_messaging_skipped",{err:u,cid:this.cid,user_id:d})})}}break;case"member.promoted":case"member.demoted":case"member.banned":case"member.unbanned":case"member.blocked":case"member.unblocked":if(e.member?.user_id){let l=Z(e.member.user_id,r);e.member.user=l,s.members[e.member.user_id]=e.member,e.member.user_id===this.getClient().user?.id&&(s.membership=e.member,this.state.membership=e.member)}break;case"channel.pinned":t.data&&(t.data.is_pinned=!0);break;case"channel.unpinned":t.data&&(t.data.is_pinned=!1);break;case"channel.topic.created":let i=e.channel?.members||[],a=de(i,r),o={channel:e.channel,members:a,messages:[],pinned_messages:[]},c=this.getClient().channel(e.channel_type||"",e.channel_id||"");c.data=e.channel,c._initializeState(o,"latest"),s.topics||(s.topics=[]),s.topics.some(l=>l.cid===c.cid)||s.topics.push(c);break;case"channel.topic.closed":t.data&&(t.data.is_closed_topic=!0),e.user=Z(e.user?.id||"",r);break;case"channel.topic.reopen":t.data&&(t.data.is_closed_topic=!1),e.user=Z(e.user?.id||"",r);break;case"channel.topic.updated":t.data&&(t.data.name=e.channel?.name,t.data.image=e.channel?.image,t.data.description=e.channel?.description),e.user=Z(e.user?.id||"",r);break;case"protocol":{let l=this.getClient().encryptionManager;if(!l?.initialized||!this.cid)break;if(l.isScopeRepairing(this.cid)){l.requestScopeSyncAfterRepair(this.cid);break}let p=e.protocol_data||e.message||e,d=p.type||p.type_field,u=p.user?.id||p.user_id,h=p.device_id;switch(d){case"welcome":{(p.target_user_ids||[]).includes(l.userId)&&!l.getGroup(this.cid)&&!l.isChannelEncryptionSyncBlocked(this.cid)&&l.joinGroup(p.welcome,p.ratchet_tree).catch(g=>{this.getClient().logger("error","[Encryption Event] Failed to process welcome",{err:g,cid:this.cid})});break}case"commit":case"external_commit":{if(u===l.userId&&!!h&&h===l.deviceId)break;l.processCommit(this.cid,p.commit,p.epoch).catch(g=>{this.getClient().logger("error","[Encryption Event] Failed to process protocol commit",{err:g,cid:this.cid,protocol_type:d}),l.sync().catch(_=>{this.getClient().logger("error","[Encryption Event] Recovery sync failed after protocol commit",{err:_,cid:this.cid})})});break}default:break}break}default:}e.watcher_count!==void 0&&(t.state.watcher_count=e.watcher_count)}_callChannelListeners=e=>{let t=this,s=[];t.listeners.all&&s.push(...t.listeners.all),t.listeners[e.type]&&s.push(...t.listeners[e.type]);for(let r of s)typeof r!="string"&&r(e)};_channelURL=()=>{if(!this.id)throw new Error("channel id is not defined");return`${this.getClient().baseURL}/channels/${this.type}/${this.id}`};_checkInitialized(){if(!this.initialized&&!this.offlineMode)throw Error(`Channel ${this.cid} hasn't been initialized yet. Make sure to call .watch() and wait for it to resolve`)}async _hydrateE2eeMessagesFromLocalCache(e=[],t){let s=this._isE2eeChannelData(t),r=this.getClient().encryptionManager?.storage;if(!s||!r||e.length===0)return e;let i=e.flatMap(m=>{let g=m.content_type==="mls"||!!m.mls_ciphertext,_=[];return g&&m.id&&_.push(m.id),m.quoted_message_id&&_.push(m.quoted_message_id),_}),a=i.length>0?r.loadE2eeMessages?await r.loadE2eeMessages(i).catch(()=>new Map):new Map((await Promise.all(Array.from(new Set(i)).map(m=>r.loadE2eeMessage(m).catch(()=>null)))).filter(Boolean).map(m=>[m.id,m])):new Map,o=this.state.messageSets?.flatMap(m=>m.messages)||[],c=new Map(o.map(m=>[m.id,m])),l=Object.values(this.getClient().state.users),p=m=>{if(!m?.id)return;let g=m.user_id||m.user?.id||"";return{...m,content_type:m.content_type||"standard",type:m.type||"regular",user:Ue(g,this.getClient().state.users[g],m.user,Z(g,l)),attachments:m.attachments||[]}},d=m=>m?!!(typeof m.text=="string"&&m.text.trim()||Array.isArray(m.attachments)&&m.attachments.length>0||typeof m.sticker_url=="string"&&m.sticker_url||m.type==="sticker"):!1,u=m=>{let g=p(m.quoted_message);if(d(g))return g;if(!m.quoted_message_id)return;let _=p(c.get(m.quoted_message_id)||a.get(m.quoted_message_id));return d(_)?_:g},h=[];for(let m of e){let g=m;if(!(g.content_type==="mls"||!!g.mls_ciphertext)){h.push(m);continue}let v=a.get(m.id),y=c.get(m.id);if(!v&&y){let k=y;if(k.content_type==="standard"||!!k.text||!!k.attachments?.length||!!k.sticker_url){let Q={...m,...y,content_type:"standard",latest_reactions:g.latest_reactions??k.latest_reactions,reaction_counts:g.reaction_counts??k.reaction_counts,reaction_groups:g.reaction_groups??k.reaction_groups,own_reactions:g.own_reactions??k.own_reactions,pinned:m.pinned??k.pinned,pinned_at:m.pinned_at??k.pinned_at},ce=u(Q);ce&&(Q.quoted_message=ce),h.push(Q);continue}}if(!v){h.push(m);continue}let x=v.user_id||v.user?.id||m.user_id||m.user?.id||"",C=this.getClient().state.users[x],S=Ue(x,C,m.user,v.user,Z(x,l),x===this.getClient().userID?this.getClient().user:void 0),P={...m,...v,content_type:"standard",user:S,latest_reactions:g.latest_reactions??v.latest_reactions,reaction_counts:g.reaction_counts??v.reaction_counts,reaction_groups:g.reaction_groups??v.reaction_groups,own_reactions:g.own_reactions??v.own_reactions,pinned:m.pinned??v.pinned,pinned_at:m.pinned_at??v.pinned_at,status:m.status},E=u(P);E&&(P.quoted_message=E),h.push(P)}return h}_seedE2eeStateFromLocalCache(e,t){let s=this._isEffectiveE2ee(),r=this.getClient().encryptionManager?.storage,i=e?.messages,a=!!(i?.id_lt||i?.id_gt||i?.id_around);if(!s||!r||!this.cid||a)return;let o=typeof i?.limit=="number"?i.limit:25;r.getE2eeMessages(this.cid,o).then(c=>{if(!c.length)return;let l=Object.values(this.getClient().state.users),p=new Map(c.map(g=>[g.id,g])),d=new Map((this.state.messageSets?.flatMap(g=>g.messages)||[]).map(g=>[g.id,g])),u=g=>{if(!g?.id)return;let _=g.user_id||g.user?.id||"";return{...g,content_type:g.content_type||"standard",type:g.type||"regular",user:Ue(_,this.getClient().state.users[_],g.user,Z(_,l)),attachments:g.attachments||[]}},h=g=>g?!!(typeof g.text=="string"&&g.text.trim()||Array.isArray(g.attachments)&&g.attachments.length>0||typeof g.sticker_url=="string"&&g.sticker_url||g.type==="sticker"):!1,m=c.map(g=>{let _=this.getClient().state.users[g.user_id],v=u(g.quoted_message),y=u(d.get(g.quoted_message_id)||p.get(g.quoted_message_id)),x=(h(v)?v:void 0)||(h(y)?y:void 0)||v;return{...g,content_type:"standard",user:Ue(g.user_id,_,g.user,Z(g.user_id,l),g.user_id===this.getClient().userID?this.getClient().user:void 0),quoted_message:x,status:"received"}}).sort((g,_)=>new Date(g.created_at||0).getTime()-new Date(_.created_at||0).getTime());this.state.addMessagesSorted(m,!1,!0,!0,t),this.getClient().dispatchEvent({type:"e2ee.local_messages_loaded",cid:this.cid,messages:m})}).catch(c=>this.getClient().logger("warn","[E2EE] Failed to seed messages from local cache",{err:c}))}_initializeState(e,t="latest",s){let{state:r,user:i,userID:a}=this.getClient();if(e.channel.members)for(let d of e.channel.members)d.user&&(s&&s(d.user.id),r.updateUserReference(d.user,this.cid));this.state.membership=e.membership||{};let o=new Map,c=[];e.messages||(e.messages=[]);for(let d of e.messages)o.has(d.id)||(o.set(d.id,!0),c.push(d));this.state.pinnedMessages&&(this.state.pinnedMessages=[]),this.state.addPinnedMessages(e.pinned_messages||[]);let l=c||[];this.state.messages||this.state.initMessages();let{messageSet:p}=this.state.addMessagesSorted(l,!1,!0,!0,t);if(e.watcher_count!==void 0&&(this.state.watcher_count=e.watcher_count),e.watchers)for(let d of e.watchers)d&&(r.updateUserReference(d,this.cid),this.state.watchers[d.id]=d);if(a!=null){let d=this.state.last_message_at||new Date;i&&(this.state.read[i.id]={user:i,last_read:d,unread_messages:0})}if(e.read)for(let d of e.read)this.state.read[d.user.id]={last_read:new Date(d.last_read),last_read_message_id:d.last_read_message_id,unread_messages:d.unread_messages??0,user:d.user,last_send:d.last_send},d.user.id===i?.id&&(this.state.unreadCount=this.state.read[d.user.id].unread_messages);if(e.channel.members&&(this.state.members=e.channel.members.reduce((d,u)=>(u.user&&(d[u.user.id]=u),d),{})),e.channel.type==="team"&&e.channel.topics_enabled&&e.topics){let d=Object.values(this.getClient().state.users);this._processTopics(e.topics,d)}return{messageSet:p}}_extendEventWithOwnReactions(e){if(!e.message)return;let t=this.state.findMessage(e.message.id,e.message.parent_id);t&&(e.message.own_reactions=t.own_reactions)}_disconnect(){this._client.logger("info",`channel:disconnect() - Disconnecting the channel ${this.cid}`,{tags:["connection","channel"],channel:this}),this.disconnected=!0,this.state.setIsUpToDate(!1)}};var Hs=class{users;userChannelReferences;constructor(){this.users={},this.userChannelReferences={}}updateUsers(e){for(let t of e)this.updateUser(t)}updateUser(e){if(e!=null)if(this.users[e.id]){let t={...this.users[e.id],...e};this.users[e.id]=t}else this.users[e.id]=e}updateUserReference(e,t){e!=null&&(this.userChannelReferences[e.id]||(this.userChannelReferences[e.id]={}),this.userChannelReferences[e.id][t]=!0)}deleteAllChannelReference(e){for(let t in this.userChannelReferences)delete this.userChannelReferences[t][e]}};var Dh=We(Uh());var Nb=n=>n.code!==void 0,qb=n=>n.error!==void 0,Vn=class{client;connectionOpen;consecutiveFailures;pingInterval;healthCheckTimeoutRef;isConnecting;isDisconnected;isHealthy;isResolved;lastEvent;connectionCheckTimeout;connectionCheckTimeoutRef;rejectPromise;requestID;resolvePromise;totalFailures;ws;wsID;_onVisibilityChange;constructor({client:e}){this.client=e,this.consecutiveFailures=0,this.totalFailures=0,this.isConnecting=!1,this.isDisconnected=!1,this.isResolved=!1,this.isHealthy=!1,this.wsID=1,this.lastEvent=null,this.pingInterval=25*1e3,this.connectionCheckTimeout=this.pingInterval+10*1e3,Au(this.onlineStatusChanged),this._addVisibilityChangeListener()}_log(e,t={},s="info"){this.client.logger(s,"connection:"+e,{tags:["connection"],...t})}setClient(e){this.client=e}async connect(e=15e3){if(this.isConnecting)throw Error("You've called connect twice, can only attempt 1 connection at the time");this.isDisconnected=!1;try{let t=await this._connect();this.consecutiveFailures=0,this._log(`connect() - Established ws connection with healthcheck: ${t}`)}catch(t){if(this.isHealthy=!1,this.consecutiveFailures+=1,t.code===wt.TOKEN_EXPIRED)this._log("connect() - WS failure due to expired token");else if(!t.isWSFailure)throw new Error(JSON.stringify({code:t.code,StatusCode:t.StatusCode,message:t.message,isWSFailure:t.isWSFailure}))}return await this._waitForHealthy(e)}async _waitForHealthy(e=15e3){return Promise.race([(async()=>{for(let s=0;s<=e;s+=50)try{return await this.connectionOpen}catch(r){if(s===e)throw new Error(JSON.stringify({code:r.code,StatusCode:r.StatusCode,message:r.message,isWSFailure:r.isWSFailure}));await Ws(50)}})(),(async()=>{throw await Ws(e),this.isConnecting=!1,new Error(JSON.stringify({code:"",StatusCode:"",message:"initial WS connection could not be established",isWSFailure:!0}))})()])}_buildUrl=()=>{let e=encodeURIComponent(this.client._buildWSPayload(this.requestID)),t=this.client.tokenManager.getToken(),s=`${this.client.wsBaseURL}/connect?json=${e}&api_key=${this.client.apiKey}&authorization=${t}&stream-auth-type=${this.client.getAuthType()}&X-Stream-Client=${this.client.getUserAgent()}&${Ou}=${Vs}`;return this.client.deviceId&&(s+=`&device_id=${encodeURIComponent(this.client.deviceId)}`),s=encodeURI(s),s};disconnect(e){this._log(`disconnect() - Closing the websocket connection for wsID ${this.wsID}`),this.wsID+=1,this.isConnecting=!1,this.isDisconnected=!0,this.healthCheckTimeoutRef&&clearInterval(this.healthCheckTimeoutRef),this.connectionCheckTimeoutRef&&clearInterval(this.connectionCheckTimeoutRef),ku(this.onlineStatusChanged),this._removeVisibilityChangeListener(),this.isHealthy=!1,this.ws&&this.ws.removeAllListeners&&this.ws.removeAllListeners();let t,{ws:s}=this;return s&&s.close&&s.readyState===s.OPEN?(t=new Promise(r=>{let i=a=>{this._log(`disconnect() - resolving isClosedPromise ${a?"with":"without"} close frame`,{event:a}),r()};s.onclose=i,setTimeout(i,e??1e3)}),this._log("disconnect() - Manually closed connection by calling client.disconnect()"),s.close(wt.WS_CLOSED_SUCCESS,"Manually closed connection by calling client.disconnect()")):(this._log("disconnect() - ws connection doesn't exist or it is already closed."),t=Promise.resolve()),delete this.ws,t}async _connect(){if(this.isConnecting)return;this.isConnecting=!0,this.requestID=Te();let e=!1;try{this._log("_connect() - waiting for token"),await this.client.tokenManager.tokenReady(),e=!0}catch{}try{this._setupConnectionPromise();let t=this._buildUrl();this._log(`_connect() - Connecting to ${t}`,{wsURL:t,requestID:this.requestID}),this.ws=new Dh.default(t),this.ws.onopen=this.onopen.bind(this,this.wsID),this.ws.onclose=this.onclose.bind(this,this.wsID),this.ws.onerror=this.onerror.bind(this,this.wsID),this.ws.onmessage=this.onmessage.bind(this,this.wsID);let s=await Promise.race([this.connectionOpen,new Promise((r,i)=>setTimeout(()=>{let a=new Error("WS connection timeout");a.isWSFailure=!0,i(a)},5e3))]);if(this.isConnecting=!1,s)return s}catch(t){if(this.isConnecting=!1,this._log("_connect() - Error - ",t),this.rejectPromise?.(t),this.ws)try{this.ws.close(wt.WS_CLOSED_SUCCESS,"WS connection timeout")}catch{}throw t}}async _reconnect(e={}){if(this._log("_reconnect() - Initiating the reconnect"),this.isConnecting||this.isHealthy){this._log("_reconnect() - Abort (1) since already connecting or healthy");return}let t=e.interval;if(t||(t=oi(this.consecutiveFailures)),await Ws(t),this.isConnecting||this.isHealthy){this._log("_reconnect() - Abort (2) since already connecting or healthy");return}if(this.isDisconnected){this._log("_reconnect() - Abort (3) since disconnect() is called");return}this._log("_reconnect() - Destroying current WS connection"),this._destroyCurrentWSConnection();try{this.client.encryptionManager?.initialized&&this.client.encryptionManager.markSyncStart(),await this._connect(),this._log("_reconnect() - Waiting for recoverCallBack"),await this.client.recoverState(),this._log("_reconnect() - Finished recoverCallBack"),this.consecutiveFailures=0}catch(s){this.isHealthy=!1,this.consecutiveFailures+=1,s.isWSFailure&&(this._log("_reconnect() - WS failure, so going to try to reconnect"),this._reconnect())}this._log("_reconnect() - == END ==")}onlineStatusChanged=e=>{e.type==="offline"?(this._log("onlineStatusChanged() - Status changing to offline"),this._setHealth(!1)):e.type==="online"&&(this._log(`onlineStatusChanged() - Status changing to online. isHealthy: ${this.isHealthy}`),this.isHealthy||this._reconnect({interval:10}))};onopen=e=>{this.wsID===e&&this._log("onopen() - onopen callback",{wsID:e})};onmessage=(e,t)=>{if(this.wsID!==e)return;this._log("onmessage() - onmessage callback",{event:t,wsID:e});let s=typeof t.data=="string"?JSON.parse(t.data):null;if(!this.isResolved&&s){if(this.isResolved=!0,s.error){this.rejectPromise?.(this._errorFromWSEvent(s,!1));return}this.resolvePromise?.(s),this._setHealth(!0)}this.lastEvent=new Date,s&&s.type==="health.check"&&this.scheduleNextPing(),this.client.handleEvent(t),this.scheduleConnectionCheck()};onclose=(e,t)=>{if(this.wsID===e){if(this._log("onclose() - onclose callback - "+t.code,{event:t,wsID:e}),t.code===wt.WS_CLOSED_SUCCESS){this._log(`onclose() - WS closed normally (1000). reason: ${t.reason}`,{event:t});return}this.consecutiveFailures+=1,this.totalFailures+=1,this._setHealth(!1),this.isConnecting=!1,this.rejectPromise?.(this._errorFromWSEvent(t)),this._log(`onclose() - WS connection closed abnormally (code ${t.code}). Calling reconnect ...`,{event:t}),this._reconnect()}};onerror=(e,t)=>{this.wsID===e&&(this.consecutiveFailures+=1,this.totalFailures+=1,this._setHealth(!1),this.isConnecting=!1,this.rejectPromise?.(this._errorFromWSEvent(t)),this._log("onerror() - WS connection resulted into error",{event:t}),this._reconnect())};_setHealth=e=>{if(e!==this.isHealthy){if(this.isHealthy=e,this.isHealthy){this.client.dispatchEvent({type:"connection.changed",online:this.isHealthy});return}setTimeout(()=>{this.isHealthy||this.client.dispatchEvent({type:"connection.changed",online:this.isHealthy})},1e3)}};_errorFromWSEvent=(e,t=!0)=>{let s,r,i;Nb(e)&&(s=e.code,r="unknown",i=e.reason),qb(e)&&(s=e.error.code,r=e.error.StatusCode,i=e.error.message),this._log(`_errorFromWSEvent() - WS failed with code ${s}`,{event:e},"warn");let a=new Error(`WS failed with code ${s} and reason - ${i}`);return a.code=s,a.StatusCode=r,a.isWSFailure=t,a};_destroyCurrentWSConnection(){this.wsID+=1;try{this?.ws?.removeAllListeners(),this?.ws?.close(wt.WS_CLOSED_SUCCESS,"Destroying current WS connection")}catch{}}_setupConnectionPromise=()=>{this.isResolved=!1,this.connectionOpen=new Promise((e,t)=>{this.resolvePromise=e,this.rejectPromise=t})};scheduleNextPing=()=>{this.healthCheckTimeoutRef&&clearTimeout(this.healthCheckTimeoutRef),this.healthCheckTimeoutRef=setTimeout(()=>{let e=[{type:"health.check",client_id:this.client.clientID}];try{this.ws?.send(JSON.stringify(e))}catch{}},this.pingInterval)};scheduleConnectionCheck=()=>{this.connectionCheckTimeoutRef&&clearTimeout(this.connectionCheckTimeoutRef),this.connectionCheckTimeoutRef=setTimeout(()=>{let e=new Date;this.lastEvent&&e.getTime()-this.lastEvent.getTime()>this.connectionCheckTimeout&&(this._log("scheduleConnectionCheck - going to reconnect"),this._setHealth(!1),this._reconnect())},this.connectionCheckTimeout)};_addVisibilityChangeListener(){typeof document>"u"||(this._onVisibilityChange=()=>{if(document.visibilityState!=="visible")return;let e=new Date,t=this.lastEvent?e.getTime()-this.lastEvent.getTime():1/0;if(this._log(`_onVisibilityChange() - Page became visible. Last event ${t}ms ago. isHealthy: ${this.isHealthy}`),this.healthCheckTimeoutRef&&clearTimeout(this.healthCheckTimeoutRef),this.connectionCheckTimeoutRef&&clearTimeout(this.connectionCheckTimeoutRef),!this.isHealthy||t>this.connectionCheckTimeout)this._log("_onVisibilityChange() - Connection unhealthy or stale, fast reconnecting"),this.consecutiveFailures=0,this.isConnecting=!1,this._setHealth(!1),this._reconnect({interval:10});else{try{let s=[{type:"health.check",client_id:this.client.clientID}];this.ws?.send(JSON.stringify(s))}catch{this._log("_onVisibilityChange() - Health check send failed, reconnecting"),this.consecutiveFailures=0,this.isConnecting=!1,this._setHealth(!1),this._reconnect({interval:10})}this.scheduleConnectionCheck()}},document.addEventListener("visibilitychange",this._onVisibilityChange))}_removeVisibilityChangeListener(){typeof document>"u"||!this._onVisibilityChange||(document.removeEventListener("visibilitychange",this._onVisibilityChange),this._onVisibilityChange=void 0)}};var zb="ENTRIES",jh="KEYS",Gh="VALUES";var Kn=class{constructor(e,t){let s=e._tree,r=Array.from(s.keys());this.set=e,this._type=t,this._path=r.length>0?[{node:s,keys:r}]:[]}next(){let e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return{done:!0,value:void 0};let{node:e,keys:t}=Js(this._path);if(Js(t)==="")return{done:!1,value:this.result()};let s=e.get(Js(t));return this._path.push({node:s,keys:Array.from(s.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;let e=Js(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack())}key(){return this.set._prefix+this._path.map(({keys:e})=>Js(e)).filter(e=>e!=="").join("")}value(){return Js(this._path).node.get("")}result(){switch(this._type){case Gh:return this.value();case jh:return this.key();default:return[this.key(),this.value()]}}[Symbol.iterator](){return this}},Js=n=>n[n.length-1],$b=(n,e,t)=>{let s=new Map;if(e===void 0)return s;let r=e.length+1,i=r+t,a=new Uint8Array(i*r).fill(t+1);for(let o=0;o<r;++o)a[o]=o;for(let o=1;o<i;++o)a[o*r]=o;return Nh(n,e,t,s,a,1,r,""),s},Nh=(n,e,t,s,r,i,a,o)=>{let c=i*a;e:for(let l of n.keys())if(l===""){let p=r[c-1];p<=t&&s.set(o,[n.get(l),p])}else{let p=i;for(let d=0;d<l.length;++d,++p){let u=l[d],h=a*p,m=h-a,g=r[h],_=Math.max(0,p-t-1),v=Math.min(a-1,p+t);for(let y=_;y<v;++y){let x=u!==e[y],C=r[m+y]+ +x,S=r[m+y+1]+1,P=r[h+y]+1,E=r[h+y+1]=Math.min(C,S,P);E<g&&(g=E)}if(g>t)continue e}Nh(n.get(l),e,t,s,r,p,a,o+l)}},Hn=class n{constructor(e=new Map,t=""){this._size=void 0,this._tree=e,this._prefix=t}atPrefix(e){if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");let[t,s]=wi(this._tree,e.slice(this._prefix.length));if(t===void 0){let[r,i]=oc(s);for(let a of r.keys())if(a!==""&&a.startsWith(i)){let o=new Map;return o.set(a.slice(i.length),r.get(a)),new n(o,e)}}return new n(t,e)}clear(){this._size=void 0,this._tree.clear()}delete(e){return this._size=void 0,Wb(this._tree,e)}entries(){return new Kn(this,zb)}forEach(e){for(let[t,s]of this)e(t,s,this)}fuzzyGet(e,t){return $b(this._tree,e,t)}get(e){let t=rc(this._tree,e);return t!==void 0?t.get(""):void 0}has(e){let t=rc(this._tree,e);return t!==void 0&&t.has("")}keys(){return new Kn(this,jh)}set(e,t){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,ec(this._tree,e).set("",t),this}get size(){if(this._size)return this._size;this._size=0;let e=this.entries();for(;!e.next().done;)this._size+=1;return this._size}update(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;let s=ec(this._tree,e);return s.set("",t(s.get(""))),this}fetch(e,t){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;let s=ec(this._tree,e),r=s.get("");return r===void 0&&s.set("",r=t()),r}values(){return new Kn(this,Gh)}[Symbol.iterator](){return this.entries()}static from(e){let t=new n;for(let[s,r]of e)t.set(s,r);return t}static fromObject(e){return n.from(Object.entries(e))}},wi=(n,e,t=[])=>{if(e.length===0||n==null)return[n,t];for(let s of n.keys())if(s!==""&&e.startsWith(s))return t.push([n,s]),wi(n.get(s),e.slice(s.length),t);return t.push([n,e]),wi(void 0,"",t)},rc=(n,e)=>{if(e.length===0||n==null)return n;for(let t of n.keys())if(t!==""&&e.startsWith(t))return rc(n.get(t),e.slice(t.length))},ec=(n,e)=>{let t=e.length;e:for(let s=0;n&&s<t;){for(let i of n.keys())if(i!==""&&e[s]===i[0]){let a=Math.min(t-s,i.length),o=1;for(;o<a&&e[s+o]===i[o];)++o;let c=n.get(i);if(o===i.length)n=c;else{let l=new Map;l.set(i.slice(o),c),n.set(e.slice(s,s+o),l),n.delete(i),n=l}s+=o;continue e}let r=new Map;return n.set(e.slice(s),r),r}return n},Wb=(n,e)=>{let[t,s]=wi(n,e);if(t!==void 0){if(t.delete(""),t.size===0)qh(s);else if(t.size===1){let[r,i]=t.entries().next().value;zh(s,r,i)}}},qh=n=>{if(n.length===0)return;let[e,t]=oc(n);if(e.delete(t),e.size===0)qh(n.slice(0,-1));else if(e.size===1){let[s,r]=e.entries().next().value;s!==""&&zh(n.slice(0,-1),s,r)}},zh=(n,e,t)=>{if(n.length===0)return;let[s,r]=oc(n);s.set(r+e,t),s.delete(r)},oc=n=>n[n.length-1],cc="or",$h="and",Vb="and_not",Qn=class n{constructor(e){if(e?.fields==null)throw new Error('MiniSearch: option "fields" must be provided');let t=e.autoVacuum==null||e.autoVacuum===!0?nc:e.autoVacuum;this._options={...sc,...e,autoVacuum:t,searchOptions:{...Lh,...e.searchOptions||{}},autoSuggestOptions:{...Yb,...e.autoSuggestOptions||{}}},this._index=new Hn,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=ac,this.addFields(this._options.fields)}add(e){let{extractField:t,stringifyField:s,tokenize:r,processTerm:i,fields:a,idField:o}=this._options,c=t(e,o);if(c==null)throw new Error(`MiniSearch: document does not have ID field "${o}"`);if(this._idToShortId.has(c))throw new Error(`MiniSearch: duplicate ID ${c}`);let l=this.addDocumentId(c);this.saveStoredFields(l,e);for(let p of a){let d=t(e,p);if(d==null)continue;let u=r(s(d,p),p),h=this._fieldIds[p],m=new Set(u).size;this.addFieldLength(l,h,this._documentCount-1,m);for(let g of u){let _=i(g,p);if(Array.isArray(_))for(let v of _)this.addTerm(h,l,v);else _&&this.addTerm(h,l,_)}}}addAll(e){for(let t of e)this.add(t)}addAllAsync(e,t={}){let{chunkSize:s=10}=t,r={chunk:[],promise:Promise.resolve()},{chunk:i,promise:a}=e.reduce(({chunk:o,promise:c},l,p)=>(o.push(l),(p+1)%s===0?{chunk:[],promise:c.then(()=>new Promise(d=>setTimeout(d,0))).then(()=>this.addAll(o))}:{chunk:o,promise:c}),r);return a.then(()=>this.addAll(i))}remove(e){let{tokenize:t,processTerm:s,extractField:r,stringifyField:i,fields:a,idField:o}=this._options,c=r(e,o);if(c==null)throw new Error(`MiniSearch: document does not have ID field "${o}"`);let l=this._idToShortId.get(c);if(l==null)throw new Error(`MiniSearch: cannot remove document with ID ${c}: it is not in the index`);for(let p of a){let d=r(e,p);if(d==null)continue;let u=t(i(d,p),p),h=this._fieldIds[p],m=new Set(u).size;this.removeFieldLength(l,h,this._documentCount,m);for(let g of u){let _=s(g,p);if(Array.isArray(_))for(let v of _)this.removeTerm(h,l,v);else _&&this.removeTerm(h,l,_)}}this._storedFields.delete(l),this._documentIds.delete(l),this._idToShortId.delete(c),this._fieldLength.delete(l),this._documentCount-=1}removeAll(e){if(e)for(let t of e)this.remove(t);else{if(arguments.length>0)throw new Error("Expected documents to be present. Omit the argument to remove all documents.");this._index=new Hn,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldLength=new Map,this._avgFieldLength=[],this._storedFields=new Map,this._nextId=0}}discard(e){let t=this._idToShortId.get(e);if(t==null)throw new Error(`MiniSearch: cannot discard document with ID ${e}: it is not in the index`);this._idToShortId.delete(e),this._documentIds.delete(t),this._storedFields.delete(t),(this._fieldLength.get(t)||[]).forEach((s,r)=>{this.removeFieldLength(t,r,this._documentCount,s)}),this._fieldLength.delete(t),this._documentCount-=1,this._dirtCount+=1,this.maybeAutoVacuum()}maybeAutoVacuum(){if(this._options.autoVacuum===!1)return;let{minDirtFactor:e,minDirtCount:t,batchSize:s,batchWait:r}=this._options.autoVacuum;this.conditionalVacuum({batchSize:s,batchWait:r},{minDirtCount:t,minDirtFactor:e})}discardAll(e){let t=this._options.autoVacuum;try{this._options.autoVacuum=!1;for(let s of e)this.discard(s)}finally{this._options.autoVacuum=t}this.maybeAutoVacuum()}replace(e){let{idField:t,extractField:s}=this._options,r=s(e,t);this.discard(r),this.add(e)}vacuum(e={}){return this.conditionalVacuum(e)}conditionalVacuum(e,t){return this._currentVacuum?(this._enqueuedVacuumConditions=this._enqueuedVacuumConditions&&t,this._enqueuedVacuum!=null?this._enqueuedVacuum:(this._enqueuedVacuum=this._currentVacuum.then(()=>{let s=this._enqueuedVacuumConditions;return this._enqueuedVacuumConditions=ac,this.performVacuuming(e,s)}),this._enqueuedVacuum)):this.vacuumConditionsMet(t)===!1?Promise.resolve():(this._currentVacuum=this.performVacuuming(e),this._currentVacuum)}async performVacuuming(e,t){let s=this._dirtCount;if(this.vacuumConditionsMet(t)){let r=e.batchSize||ic.batchSize,i=e.batchWait||ic.batchWait,a=1;for(let[o,c]of this._index){for(let[l,p]of c)for(let[d]of p)this._documentIds.has(d)||(p.size<=1?c.delete(l):p.delete(d));this._index.get(o).size===0&&this._index.delete(o),a%r===0&&await new Promise(l=>setTimeout(l,i)),a+=1}this._dirtCount-=s}await null,this._currentVacuum=this._enqueuedVacuum,this._enqueuedVacuum=null}vacuumConditionsMet(e){if(e==null)return!0;let{minDirtCount:t,minDirtFactor:s}=e;return t=t||nc.minDirtCount,s=s||nc.minDirtFactor,this.dirtCount>=t&&this.dirtFactor>=s}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}has(e){return this._idToShortId.has(e)}getStoredFields(e){let t=this._idToShortId.get(e);if(t!=null)return this._storedFields.get(t)}search(e,t={}){let{searchOptions:s}=this._options,r={...s,...t},i=this.executeQuery(e,t),a=[];for(let[o,{score:c,terms:l,match:p}]of i){let d=l.length||1,u={id:this._documentIds.get(o),score:c*d,terms:Object.keys(p),queryTerms:l,match:p};Object.assign(u,this._storedFields.get(o)),(r.filter==null||r.filter(u))&&a.push(u)}return e===n.wildcard&&r.boostDocument==null||a.sort(Fh),a}autoSuggest(e,t={}){t={...this._options.autoSuggestOptions,...t};let s=new Map;for(let{score:i,terms:a}of this.search(e,t)){let o=a.join(" "),c=s.get(o);c!=null?(c.score+=i,c.count+=1):s.set(o,{score:i,terms:a,count:1})}let r=[];for(let[i,{score:a,terms:o,count:c}]of s)r.push({suggestion:i,terms:o,score:a/c});return r.sort(Fh),r}get documentCount(){return this._documentCount}get termCount(){return this._index.size}static loadJSON(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJS(JSON.parse(e),t)}static async loadJSONAsync(e,t){if(t==null)throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");return this.loadJSAsync(JSON.parse(e),t)}static getDefault(e){if(sc.hasOwnProperty(e))return tc(sc,e);throw new Error(`MiniSearch: unknown option "${e}"`)}static loadJS(e,t){let{index:s,documentIds:r,fieldLength:i,storedFields:a,serializationVersion:o}=e,c=this.instantiateMiniSearch(e,t);c._documentIds=vi(r),c._fieldLength=vi(i),c._storedFields=vi(a);for(let[l,p]of c._documentIds)c._idToShortId.set(p,l);for(let[l,p]of s){let d=new Map;for(let u of Object.keys(p)){let h=p[u];o===1&&(h=h.ds),d.set(parseInt(u,10),vi(h))}c._index.set(l,d)}return c}static async loadJSAsync(e,t){let{index:s,documentIds:r,fieldLength:i,storedFields:a,serializationVersion:o}=e,c=this.instantiateMiniSearch(e,t);c._documentIds=await bi(r),c._fieldLength=await bi(i),c._storedFields=await bi(a);for(let[p,d]of c._documentIds)c._idToShortId.set(d,p);let l=0;for(let[p,d]of s){let u=new Map;for(let h of Object.keys(d)){let m=d[h];o===1&&(m=m.ds),u.set(parseInt(h,10),await bi(m))}++l%1e3===0&&await Wh(0),c._index.set(p,u)}return c}static instantiateMiniSearch(e,t){let{documentCount:s,nextId:r,fieldIds:i,averageFieldLength:a,dirtCount:o,serializationVersion:c}=e;if(c!==1&&c!==2)throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");let l=new n(t);return l._documentCount=s,l._nextId=r,l._idToShortId=new Map,l._fieldIds=i,l._avgFieldLength=a,l._dirtCount=o||0,l._index=new Hn,l}executeQuery(e,t={}){if(e===n.wildcard)return this.executeWildcardQuery(t);if(typeof e!="string"){let u={...t,...e,queries:void 0},h=e.queries.map(m=>this.executeQuery(m,u));return this.combineResults(h,u.combineWith)}let{tokenize:s,processTerm:r,searchOptions:i}=this._options,a={tokenize:s,processTerm:r,...i,...t},{tokenize:o,processTerm:c}=a,d=o(e).flatMap(u=>c(u)).filter(u=>!!u).map(Jb(a)).map(u=>this.executeQuerySpec(u,a));return this.combineResults(d,a.combineWith)}executeQuerySpec(e,t){let s={...this._options.searchOptions,...t},r=(s.fields||this._options.fields).reduce((g,_)=>({...g,[_]:tc(s.boost,_)||1}),{}),{boostDocument:i,weights:a,maxFuzzy:o,bm25:c}=s,{fuzzy:l,prefix:p}={...Lh.weights,...a},d=this._index.get(e.term),u=this.termResults(e.term,e.term,1,e.termBoost,d,r,i,c),h,m;if(e.prefix&&(h=this._index.atPrefix(e.term)),e.fuzzy){let g=e.fuzzy===!0?.2:e.fuzzy,_=g<1?Math.min(o,Math.round(e.term.length*g)):g;_&&(m=this._index.fuzzyGet(e.term,_))}if(h)for(let[g,_]of h){let v=g.length-e.term.length;if(!v)continue;m?.delete(g);let y=p*g.length/(g.length+.3*v);this.termResults(e.term,g,y,e.termBoost,_,r,i,c,u)}if(m)for(let g of m.keys()){let[_,v]=m.get(g);if(!v)continue;let y=l*g.length/(g.length+v);this.termResults(e.term,g,y,e.termBoost,_,r,i,c,u)}return u}executeWildcardQuery(e){let t=new Map,s={...this._options.searchOptions,...e};for(let[r,i]of this._documentIds){let a=s.boostDocument?s.boostDocument(i,"",this._storedFields.get(r)):1;t.set(r,{score:a,terms:[],match:{}})}return t}combineResults(e,t=cc){if(e.length===0)return new Map;let s=t.toLowerCase(),r=Kb[s];if(!r)throw new Error(`Invalid combination operator: ${t}`);return e.reduce(r)||new Map}toJSON(){let e=[];for(let[t,s]of this._index){let r={};for(let[i,a]of s)r[i]=Object.fromEntries(a);e.push([t,r])}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:e,serializationVersion:2}}termResults(e,t,s,r,i,a,o,c,l=new Map){if(i==null)return l;for(let p of Object.keys(a)){let d=a[p],u=this._fieldIds[p],h=i.get(u);if(h==null)continue;let m=h.size,g=this._avgFieldLength[u];for(let _ of h.keys()){if(!this._documentIds.has(_)){this.removeTerm(u,_,t),m-=1;continue}let v=o?o(this._documentIds.get(_),t,this._storedFields.get(_)):1;if(!v)continue;let y=h.get(_),x=this._fieldLength.get(_)[u],C=Qb(y,m,this._documentCount,x,g,c),S=s*r*d*v*C,P=l.get(_);if(P){P.score+=S,Xb(P.terms,e);let E=tc(P.match,t);E?E.push(p):P.match[t]=[p]}else l.set(_,{score:S,terms:[e],match:{[t]:[p]}})}}return l}addTerm(e,t,s){let r=this._index.fetch(s,Bh),i=r.get(e);if(i==null)i=new Map,i.set(t,1),r.set(e,i);else{let a=i.get(t);i.set(t,(a||0)+1)}}removeTerm(e,t,s){if(!this._index.has(s)){this.warnDocumentChanged(t,e,s);return}let r=this._index.fetch(s,Bh),i=r.get(e);i==null||i.get(t)==null?this.warnDocumentChanged(t,e,s):i.get(t)<=1?i.size<=1?r.delete(e):i.delete(t):i.set(t,i.get(t)-1),this._index.get(s).size===0&&this._index.delete(s)}warnDocumentChanged(e,t,s){for(let r of Object.keys(this._fieldIds))if(this._fieldIds[r]===t){this._options.logger("warn",`MiniSearch: document with ID ${this._documentIds.get(e)} has changed before removal: term "${s}" was not present in field "${r}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}}addDocumentId(e){let t=this._nextId;return this._idToShortId.set(e,t),this._documentIds.set(t,e),this._documentCount+=1,this._nextId+=1,t}addFields(e){for(let t=0;t<e.length;t++)this._fieldIds[e[t]]=t}addFieldLength(e,t,s,r){let i=this._fieldLength.get(e);i==null&&this._fieldLength.set(e,i=[]),i[t]=r;let o=(this._avgFieldLength[t]||0)*s+r;this._avgFieldLength[t]=o/(s+1)}removeFieldLength(e,t,s,r){if(s===1){this._avgFieldLength[t]=0;return}let i=this._avgFieldLength[t]*s-r;this._avgFieldLength[t]=i/(s-1)}saveStoredFields(e,t){let{storeFields:s,extractField:r}=this._options;if(s==null||s.length===0)return;let i=this._storedFields.get(e);i==null&&this._storedFields.set(e,i={});for(let a of s){let o=r(t,a);o!==void 0&&(i[a]=o)}}};Qn.wildcard=Symbol("*");var tc=(n,e)=>Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0,Kb={[cc]:(n,e)=>{for(let t of e.keys()){let s=n.get(t);if(s==null)n.set(t,e.get(t));else{let{score:r,terms:i,match:a}=e.get(t);s.score=s.score+r,s.match=Object.assign(s.match,a),Oh(s.terms,i)}}return n},[$h]:(n,e)=>{let t=new Map;for(let s of e.keys()){let r=n.get(s);if(r==null)continue;let{score:i,terms:a,match:o}=e.get(s);Oh(r.terms,a),t.set(s,{score:r.score+i,terms:r.terms,match:Object.assign(r.match,o)})}return t},[Vb]:(n,e)=>{for(let t of e.keys())n.delete(t);return n}},Hb={k:1.2,b:.7,d:.5},Qb=(n,e,t,s,r,i)=>{let{k:a,b:o,d:c}=i;return Math.log(1+(t-e+.5)/(e+.5))*(c+n*(a+1)/(n+a*(1-o+o*s/r)))},Jb=n=>(e,t,s)=>{let r=typeof n.fuzzy=="function"?n.fuzzy(e,t,s):n.fuzzy||!1,i=typeof n.prefix=="function"?n.prefix(e,t,s):n.prefix===!0,a=typeof n.boostTerm=="function"?n.boostTerm(e,t,s):1;return{term:e,fuzzy:r,prefix:i,termBoost:a}},sc={idField:"id",extractField:(n,e)=>n[e],stringifyField:(n,e)=>n.toString(),tokenize:n=>n.split(Zb),processTerm:n=>n.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(n,e)=>{typeof console?.[n]=="function"&&console[n](e)},autoVacuum:!0},Lh={combineWith:cc,prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Hb},Yb={combineWith:$h,prefix:(n,e,t)=>e===t.length-1},ic={batchSize:1e3,batchWait:10},ac={minDirtFactor:.1,minDirtCount:20},nc={...ic,...ac},Xb=(n,e)=>{n.includes(e)||n.push(e)},Oh=(n,e)=>{for(let t of e)n.includes(t)||n.push(t)},Fh=({score:n},{score:e})=>e-n,Bh=()=>new Map,vi=n=>{let e=new Map;for(let t of Object.keys(n))e.set(parseInt(t,10),n[t]);return e},bi=async n=>{let e=new Map,t=0;for(let s of Object.keys(n))e.set(parseInt(s,10),n[s]),++t%1e3===0&&await Wh(0);return e},Wh=n=>new Promise(e=>setTimeout(e,n)),Zb=/[\n\r\p{Z}\p{P}]+/u;var ew="ermis_mls",Vh="ermis_mls",Kh=6,Wt="identity",De="messages",ot="pending_sends",B="meta",ct="groups",Ct="archive_uploads",St="deferred_archives",Vt="archive_acks",lt="restore_progress",Hh="archive_stash_key",Kt="sync:",Ys="scope_sync:",xi="channel_repair:",Qh="channel_repair_lock:",Ei="epoch_archive_checkpoint:",Jh="00000000-0000-0000-0000-000000000000",lc="ermis_device_id";function tw(n){return{...n,encrypted_archive:{ciphertext:Be(n.encrypted_archive.ciphertext,"encrypted_archive.ciphertext"),nonce:Be(n.encrypted_archive.nonce,"encrypted_archive.nonce"),aead_aad:Be(n.encrypted_archive.aead_aad,"encrypted_archive.aead_aad")},snapshot:{...n.snapshot,snapshot_bytes:Be(n.snapshot.snapshot_bytes,"snapshot.snapshot_bytes")},encrypted_adk:{ciphertext:Be(n.encrypted_adk.ciphertext,"encrypted_adk.ciphertext"),nonce:Be(n.encrypted_adk.nonce,"encrypted_adk.nonce")}}}function Yh(n){return{...n,encrypted_archive_bytes:{ciphertext:Be(n.encrypted_archive_bytes.ciphertext,"encrypted_archive_bytes.ciphertext"),nonce:Be(n.encrypted_archive_bytes.nonce,"encrypted_archive_bytes.nonce")},snapshot:{...n.snapshot,snapshot_bytes:Be(n.snapshot.snapshot_bytes,"snapshot.snapshot_bytes")}}}function Ci(n){return n?typeof n=="object"&&typeof n.created_at=="string"&&typeof n.event_id=="string"?n:typeof n=="string"&&n.length>0?{created_at:n,event_id:Jh}:typeof n=="number"&&Number.isFinite(n)&&n>0?{created_at:new Date(n).toISOString(),event_id:Jh}:null:null}var Ht=class{dbPromise=null;dbName;constructor(e="",t){t&&$s(t),e?this.dbName=`${ew}_${e}`:this.dbName=Vh}openDB(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,t)=>{let s=indexedDB.open(this.dbName,Kh);s.onupgradeneeded=r=>{let i=r.target.result;if(i.objectStoreNames.contains(Wt)||i.createObjectStore(Wt),!i.objectStoreNames.contains(De)){let a=i.createObjectStore(De,{keyPath:"id"});a.createIndex("cid","cid",{unique:!1}),a.createIndex("cid_created",["cid","created_at"],{unique:!1})}if(!i.objectStoreNames.contains(ot)){let a=i.createObjectStore(ot,{keyPath:"message_id"});a.createIndex("status","status",{unique:!1}),a.createIndex("cid","cid",{unique:!1}),a.createIndex("updated_at","updated_at",{unique:!1})}if(i.objectStoreNames.contains(B)||i.createObjectStore(B),i.objectStoreNames.contains(ct)||i.createObjectStore(ct),i.objectStoreNames.contains(Ct)||i.createObjectStore(Ct),i.objectStoreNames.contains(St)||i.createObjectStore(St),i.objectStoreNames.contains(Vt)||i.createObjectStore(Vt),!i.objectStoreNames.contains(lt)){let a=i.createObjectStore(lt,{keyPath:["device_id","cid"]});a.createIndex("status","status",{unique:!1}),a.createIndex("device_id","device_id",{unique:!1}),a.createIndex("device_status",["device_id","status"],{unique:!1})}},s.onsuccess=()=>e(s.result),s.onerror=()=>{this.dbPromise=null,t(s.error)}}),this.dbPromise)}async getDeviceId(){if(typeof localStorage<"u"){let t=localStorage.getItem(lc);if(t)return t}try{let t=await this._migrateLegacyDeviceId();if(t)return t}catch{}let e=`web-${Te()}`;return typeof localStorage<"u"&&localStorage.setItem(lc,e),e}async _migrateLegacyDeviceId(){return new Promise(e=>{let t=indexedDB.open(Vh,Kh);t.onupgradeneeded=s=>{let r=s.target.result;if(r.objectStoreNames.contains(B)||r.createObjectStore(B),r.objectStoreNames.contains(Wt)||r.createObjectStore(Wt),!r.objectStoreNames.contains(De)){let i=r.createObjectStore(De,{keyPath:"id"});i.createIndex("cid","cid",{unique:!1}),i.createIndex("cid_created",["cid","created_at"],{unique:!1})}if(!r.objectStoreNames.contains(ot)){let i=r.createObjectStore(ot,{keyPath:"message_id"});i.createIndex("status","status",{unique:!1}),i.createIndex("cid","cid",{unique:!1}),i.createIndex("updated_at","updated_at",{unique:!1})}if(r.objectStoreNames.contains(ct)||r.createObjectStore(ct),r.objectStoreNames.contains(Ct)||r.createObjectStore(Ct),r.objectStoreNames.contains(St)||r.createObjectStore(St),r.objectStoreNames.contains(Vt)||r.createObjectStore(Vt),!r.objectStoreNames.contains(lt)){let i=r.createObjectStore(lt,{keyPath:["device_id","cid"]});i.createIndex("status","status",{unique:!1}),i.createIndex("device_id","device_id",{unique:!1}),i.createIndex("device_status",["device_id","status"],{unique:!1})}},t.onsuccess=()=>{let s=t.result;try{if(!s.objectStoreNames.contains(B)){s.close(),e(null);return}let a=s.transaction(B,"readonly").objectStore(B).get("device_id");a.onsuccess=()=>{let o=a.result;s.close(),o&&typeof localStorage<"u"?(localStorage.setItem(lc,o),b("info","[Encryption Storage] Migrated device_id from IndexedDB to localStorage:",o),e(o)):e(null)},a.onerror=()=>{s.close(),e(null)}}catch{s.close(),e(null)}},t.onerror=()=>e(null)})}async saveIdentity(e,t,s){let r=await this.openDB();return new Promise((i,a)=>{let o=r.transaction(Wt,"readwrite");o.objectStore(Wt).put(s,`${e}:${t}`),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async loadIdentity(e,t){let s=await this.openDB();return new Promise((r,i)=>{let c=s.transaction(Wt,"readonly").objectStore(Wt).get(`${e}:${t}`);c.onsuccess=()=>r(c.result||null),c.onerror=()=>i(c.error)})}async saveE2eeMessage(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(De,"readwrite");i.objectStore(De).put(e),i.oncomplete=()=>{this._indexMessage(e),s()},i.onerror=()=>r(i.error)})}async loadE2eeMessage(e){let t=await this.openDB();return new Promise((s,r)=>{let o=t.transaction(De,"readonly").objectStore(De).get(e);o.onsuccess=()=>s(o.result||null),o.onerror=()=>r(o.error)})}async loadE2eeMessages(e){let t=Array.from(new Set(e.filter(Boolean)));if(t.length===0)return new Map;let s=await this.openDB();return new Promise((r,i)=>{let a=s.transaction(De,"readonly"),o=a.objectStore(De),c=new Map;for(let l of t){let p=o.get(l);p.onsuccess=()=>{p.result&&c.set(l,p.result)},p.onerror=()=>i(p.error)}a.oncomplete=()=>r(c),a.onerror=()=>i(a.error)})}async deleteE2eeMessage(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(De,"readwrite");i.objectStore(De).delete(e),i.oncomplete=()=>{if(this._searchIndex&&this._indexReady){try{this._searchIndex.discard(e)}catch{}this._indexedIds.delete(e)}s()},i.onerror=()=>r(i.error)})}async getE2eeMessages(e,t=50){let s=await this.openDB();return new Promise((r,i)=>{let l=s.transaction(De,"readonly").objectStore(De).index("cid").getAll(e);l.onsuccess=()=>{let p=l.result||[];p.sort((d,u)=>new Date(u.created_at).getTime()-new Date(d.created_at).getTime()),r(p.slice(0,t))},l.onerror=()=>i(l.error)})}async clearE2eeMessages(e){let t=await this.openDB(),s=[];return new Promise((r,i)=>{let a=t.transaction(De,"readwrite"),l=a.objectStore(De).index("cid").openCursor(e);l.onsuccess=p=>{let d=p.target.result;d&&(s.push(d.value.id),d.delete(),d.continue())},a.oncomplete=()=>{if(this._searchIndex&&this._indexReady)for(let p of s)try{this._searchIndex.discard(p),this._indexedIds.delete(p)}catch{}r()},a.onerror=()=>i(a.error)})}async savePendingE2eeSend(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(ot,"readwrite");i.objectStore(ot).put(e),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadPendingE2eeSend(e){let t=await this.openDB();return new Promise((s,r)=>{let a=t.transaction(ot,"readonly").objectStore(ot).get(e);a.onsuccess=()=>s(a.result||null),a.onerror=()=>r(a.error)})}async listPendingE2eeSends(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(ot,"readonly"),a=i.objectStore(ot),o=[],c=e&&e.length>0?new Set(e):null,l=a.openCursor();l.onsuccess=p=>{let d=p.target.result;if(d){let u=d.value;(!c||c.has(u.status))&&o.push(u),d.continue()}},i.oncomplete=()=>{o.sort((p,d)=>p.updated_at-d.updated_at),s(o)},i.onerror=()=>r(i.error)})}async deletePendingE2eeSend(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(ot,"readwrite");i.objectStore(ot).delete(e),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}_searchIndex=null;_indexedIds=new Set;_indexReady=!1;_indexBuildPromise=null;_createSearchIndex(){return new Qn({fields:["text"],storeFields:["id","cid","text","user_id","user","created_at","type","content_type","parent_id","quoted_message_id","mentioned_users","mentioned_all","attachments","sticker_url","pinned","reaction_counts","latest_reactions","poll_type","poll_choice_counts","latest_poll_choices","quoted_message"],idField:"id",processTerm:e=>e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d"):null,searchOptions:{processTerm:e=>e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/đ/g,"d"):null,prefix:!0,fuzzy:.2,combineWith:"AND"}})}async _ensureIndex(){if(!this._indexReady)return this._indexBuildPromise?this._indexBuildPromise:(this._indexBuildPromise=(async()=>{let e=await this.openDB(),t=await new Promise((r,i)=>{let c=e.transaction(De,"readonly").objectStore(De).getAll();c.onsuccess=()=>r(c.result||[]),c.onerror=()=>i(c.error)});this._searchIndex=this._createSearchIndex(),this._indexedIds=new Set;let s=t.filter(r=>r.text&&r.text.length>0);if(s.length>0){this._searchIndex.addAll(s);for(let r of s)this._indexedIds.add(r.id)}this._indexReady=!0,this._indexBuildPromise=null,b("info",`[Encryption Storage] Search index built: ${s.length} messages indexed`)})(),this._indexBuildPromise)}_indexMessage(e){if(!(!this._searchIndex||!this._indexReady)&&!(!e.text||e.text.length===0))try{this._indexedIds.has(e.id)&&this._searchIndex.discard(e.id),this._searchIndex.add(e),this._indexedIds.add(e.id)}catch(t){b("warn","[Encryption Storage] Failed to index message:",e.id,t)}}async searchE2eeMessages(e,t=25){return await this._ensureIndex(),this._searchIndex?this._searchIndex.search(e).sort((i,a)=>new Date(a.created_at).getTime()-new Date(i.created_at).getTime()).slice(0,t):[]}async searchE2eeMessagesByCid(e,t,s=25){return await this._ensureIndex(),this._searchIndex?this._searchIndex.search(t,{filter:a=>a.cid===e}).sort((a,o)=>new Date(o.created_at).getTime()-new Date(a.created_at).getTime()).slice(0,s):[]}async saveGroupState(e,t){let s=await this.openDB();return new Promise((r,i)=>{let a=s.transaction(ct,"readwrite");a.objectStore(ct).put(t,e),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async loadGroupState(e){let t=await this.openDB();return new Promise((s,r)=>{let o=t.transaction(ct,"readonly").objectStore(ct).get(e);o.onsuccess=()=>s(o.result||null),o.onerror=()=>r(o.error)})}async listGroupCids(){let e=await this.openDB();return new Promise((t,s)=>{let a=e.transaction(ct,"readonly").objectStore(ct).getAllKeys();a.onsuccess=()=>t(a.result||[]),a.onerror=()=>s(a.error)})}async deleteGroup(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(ct,"readwrite");i.objectStore(ct).delete(e),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async saveProviderState(e,t,s){let r=await this.openDB();return new Promise((i,a)=>{let o=r.transaction(B,"readwrite");o.objectStore(B).put(s,`provider:${e}:${t}`),o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async loadProviderState(e,t){let s=await this.openDB();return new Promise((r,i)=>{let c=s.transaction(B,"readonly").objectStore(B).get(`provider:${e}:${t}`);c.onsuccess=()=>r(c.result||null),c.onerror=()=>i(c.error)})}async saveSyncTimestamp(e,t){let s=await this.openDB();return new Promise((r,i)=>{let a=s.transaction(B,"readwrite");a.objectStore(B).put(t,`${Kt}${e}`),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async loadSyncTimestamp(e){let t=await this.openDB();return new Promise((s,r)=>{let o=t.transaction(B,"readonly").objectStore(B).get(`${Kt}${e}`);o.onsuccess=()=>s(o.result||null),o.onerror=()=>r(o.error)})}async loadAllSyncTimestamps(){let e=await this.openDB();return new Promise((t,s)=>{let i=e.transaction(B,"readonly").objectStore(B),a={},o=i.openCursor();o.onsuccess=()=>{let c=o.result;if(c){let l=c.key;if(l.startsWith(Kt)&&l!=="sync:removed_channels"){let p=l.slice(Kt.length);a[p]=c.value}c.continue()}else t(a)},o.onerror=()=>s(o.error)})}async loadScopeSyncCursor(e){let t=await this.openDB();return new Promise((s,r)=>{let a=t.transaction(B,"readonly").objectStore(B),o=a.get(`${Ys}${e}`);o.onsuccess=()=>{let c=Ci(o.result);if(c){s(c);return}let l=a.get(`${Kt}${e}`);l.onsuccess=()=>s(Ci(l.result)),l.onerror=()=>r(l.error)},o.onerror=()=>r(o.error)})}async saveScopeSyncCursor(e,t){let s=await this.openDB();return new Promise((r,i)=>{let a=s.transaction(B,"readwrite");a.objectStore(B).put(t,`${Ys}${e}`),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async loadAllScopeSyncCursors(){let e=await this.openDB();return new Promise((t,s)=>{let i=e.transaction(B,"readonly").objectStore(B),a={},o={},c=i.openCursor();c.onsuccess=()=>{let l=c.result;if(l){let p=l.key;if(p.startsWith(Ys)){let d=p.slice(Ys.length),u=Ci(l.value);u&&(o[d]=u)}else if(p.startsWith(Kt)&&p!=="sync:removed_channels"){let d=p.slice(Kt.length),u=Ci(l.value);u&&(a[d]=u)}l.continue()}else t({...a,...o})},c.onerror=()=>s(c.error)})}async saveAllScopeSyncCursors(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite"),a=i.objectStore(B);for(let[o,c]of Object.entries(e))a.put(c,`${Ys}${o}`);i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadChannelRepairState(e){let t=await this.openDB();return new Promise((s,r)=>{let o=t.transaction(B,"readonly").objectStore(B).get(`${xi}${e}`);o.onsuccess=()=>s(o.result||null),o.onerror=()=>r(o.error)})}async saveChannelRepairState(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite");i.objectStore(B).put(e,`${xi}${e.scope_cid}`),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async deleteChannelRepairState(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite");i.objectStore(B).delete(`${xi}${e}`),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async saveEncryptionSyncCheckpoint(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite"),a=i.objectStore(B);a.put(e.provider_bytes,`provider:${e.user_id}:${e.device_id}`);for(let[o,c]of Object.entries(e.scope_cursors||{}))a.put(c,`${Ys}${o}`);for(let[o,c]of Object.entries(e.pending_snapshots||{})){let l=`pending_e2ee_snapshots:${o}`;c.length===0?a.delete(l):a.put(c,l)}for(let o of e.repair_states||[])a.put(o,`${xi}${o.scope_cid}`);i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async tryAcquireRepairLock(e,t,s){let r=await this.openDB();return new Promise((i,a)=>{let o=r.transaction(B,"readwrite"),c=o.objectStore(B),l=`${Qh}${e}`,p=c.get(l),d=!1;p.onsuccess=()=>{let u=Date.now(),h=p.result;if(h?.owner_id&&h.expires_at&&h.expires_at>u&&h.owner_id!==t){d=!1;return}d=!0,c.put({scope_cid:e,owner_id:t,expires_at:u+s,updated_at:u},l)},p.onerror=()=>a(p.error),o.oncomplete=()=>i(d),o.onerror=()=>a(o.error)})}async releaseRepairLock(e,t){let s=await this.openDB();return new Promise((r,i)=>{let a=s.transaction(B,"readwrite"),o=a.objectStore(B),c=`${Qh}${e}`,l=o.get(c);l.onsuccess=()=>{let p=l.result;(!p||p.owner_id===t)&&o.delete(c)},l.onerror=()=>i(l.error),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async saveAllSyncTimestamps(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite"),a=i.objectStore(B);for(let[o,c]of Object.entries(e))a.put(c,`${Kt}${o}`);i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadRemovedSyncCursor(){let e=await this.openDB();return new Promise((t,s)=>{let a=e.transaction(B,"readonly").objectStore(B).get("sync:removed_channels");a.onsuccess=()=>{let o=a.result;if(!o){t(null);return}if(typeof o=="object"&&typeof o.removed_at=="string"&&typeof o.event_id=="string"){t(o);return}let c=Number(typeof o=="object"?o.removed_at:o);if(Number.isFinite(c)&&c>0){t({removed_at:new Date(c).toISOString(),event_id:typeof o=="object"&&typeof o.event_id=="string"?o.event_id:"00000000-0000-0000-0000-000000000000"});return}t(null)},a.onerror=()=>s(a.error)})}async saveRemovedSyncCursor(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite");i.objectStore(B).put(e,"sync:removed_channels"),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadPendingE2eeSnapshots(e){let t=await this.openDB();return new Promise((s,r)=>{let o=t.transaction(B,"readonly").objectStore(B).get(`pending_e2ee_snapshots:${e}`);o.onsuccess=()=>s(o.result||[]),o.onerror=()=>r(o.error)})}async savePendingE2eeSnapshots(e,t){let s=await this.openDB();return new Promise((r,i)=>{let a=s.transaction(B,"readwrite"),o=a.objectStore(B),c=`pending_e2ee_snapshots:${e}`;t.length===0?o.delete(c):o.put(t,c),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async loadPendingEvictions(){let e=await this.openDB();return new Promise((t,s)=>{let a=e.transaction(B,"readonly").objectStore(B).get("pending_evictions");a.onsuccess=()=>t(a.result||{}),a.onerror=()=>s(a.error)})}async savePendingEvictions(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite"),a=i.objectStore(B);Object.keys(e).length===0?a.delete("pending_evictions"):a.put(e,"pending_evictions"),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async saveArchiveUpload(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(Ct,"readwrite"),a=i.objectStore(Ct),o=e.upload?.archive_blob_id||"unknown";a.put(e,`${e.cid}:${e.epoch}:${o}`),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadPendingArchiveUploads(){let e=await this.openDB();return new Promise((t,s)=>{let a=e.transaction(Ct,"readonly").objectStore(Ct).getAll();a.onsuccess=()=>t(a.result||[]),a.onerror=()=>s(a.error)})}async deleteArchiveUpload(e,t,s){let r=await this.openDB();return new Promise((i,a)=>{let o=r.transaction(Ct,"readwrite"),c=o.objectStore(Ct);if(s)c.delete(`${e}:${t}:${s}`);else{let l=`${e}:${t}:`,p=c.openCursor();p.onsuccess=()=>{let d=p.result;d&&(String(d.key).startsWith(l)&&d.delete(),d.continue())}}o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async saveDeferredArchive(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(St,"readwrite");i.objectStore(St).put(e,`${e.cid}:${e.epoch}:${e.archive_blob_id}`),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadPendingDeferredArchives(){let e=await this.openDB();return new Promise((t,s)=>{let a=e.transaction(St,"readonly").objectStore(St).getAll();a.onsuccess=()=>t((a.result||[]).map(tw)),a.onerror=()=>s(a.error)})}async deleteDeferredArchive(e,t,s){let r=await this.openDB();return new Promise((i,a)=>{let o=r.transaction(St,"readwrite"),c=o.objectStore(St);if(s)c.delete(`${e}:${t}:${s}`);else{let l=`${e}:${t}:`,p=c.openCursor();p.onsuccess=()=>{let d=p.result;d&&(String(d.key).startsWith(l)&&d.delete(),d.continue())}}o.oncomplete=()=>i(),o.onerror=()=>a(o.error)})}async saveArchiveAck(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(Vt,"readwrite");i.objectStore(Vt).put(e,`${e.cid}:${e.epoch}:${e.scope}:${e.coverage_key}`),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadArchiveAck(e,t,s,r){let i=await this.openDB();return new Promise((a,o)=>{let l=i.transaction(Vt,"readonly").objectStore(Vt),p=l.get(`${e}:${t}:${s}:${r}`);p.onsuccess=()=>{if(p.result||s!=="account_owned"){a(p.result||null);return}let d=l.get(`${e}:${t}:${r}`);d.onsuccess=()=>{let u=d.result;a(u?{...u,scope:"account_owned",coverage_key:r,recovery_key_id:u.recovery_key_id||r}:null)},d.onerror=()=>o(d.error)},p.onerror=()=>o(p.error)})}async saveEpochArchiveCheckpoint(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite");i.objectStore(B).put(e,`${Ei}${e.scope_cid}:${e.epoch}`),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadEpochArchiveCheckpoint(e,t){let s=await this.openDB();return new Promise((r,i)=>{let o=s.transaction(B,"readonly").objectStore(B).get(`${Ei}${e}:${t}`);o.onsuccess=()=>r(o.result?Yh(o.result):null),o.onerror=()=>i(o.error)})}async loadEpochArchiveCheckpoints(){let e=await this.openDB();return new Promise((t,s)=>{let i=e.transaction(B,"readonly").objectStore(B),a=[],o=i.openCursor();o.onsuccess=()=>{let c=o.result;if(!c){t(a);return}String(c.key).startsWith(Ei)&&a.push(Yh(c.value)),c.continue()},o.onerror=()=>s(o.error)})}async deleteEpochArchiveCheckpoint(e,t){let s=await this.openDB();return new Promise((r,i)=>{let a=s.transaction(B,"readwrite");a.objectStore(B).delete(`${Ei}${e}:${t}`),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async saveArchiveStashKey(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(B,"readwrite");i.objectStore(B).put(e,Hh),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadArchiveStashKey(){let e=await this.openDB();return new Promise((t,s)=>{let a=e.transaction(B,"readonly").objectStore(B).get(Hh);a.onsuccess=()=>t(a.result||null),a.onerror=()=>s(a.error)})}async saveRecoveryPublicKey(e,t){let s=await this.openDB();return new Promise((r,i)=>{let a=s.transaction(B,"readwrite");a.objectStore(B).put(t,`recovery_public_key:${e}`),a.oncomplete=()=>r(),a.onerror=()=>i(a.error)})}async loadRecoveryPublicKey(e){let t=await this.openDB();return new Promise((s,r)=>{let o=t.transaction(B,"readonly").objectStore(B).get(`recovery_public_key:${e}`);o.onsuccess=()=>s(o.result||null),o.onerror=()=>r(o.error)})}async saveRestoreProgress(e){let t=await this.openDB();return new Promise((s,r)=>{let i=t.transaction(lt,"readwrite");i.objectStore(lt).put(e),i.oncomplete=()=>s(),i.onerror=()=>r(i.error)})}async loadRestoreProgress(e,t,s){let r=await this.openDB();return new Promise((i,a)=>{let l=r.transaction(lt,"readonly").objectStore(lt).get([t,s]);l.onsuccess=()=>{let p=l.result;i(p&&p.user_id===e?p:null)},l.onerror=()=>a(l.error)})}async loadIncompleteRestores(e,t){let s=["pending","running","partial","failed"];return(await Promise.all(s.map(i=>this._loadRestoreProgressByDeviceStatus(e,t,i)))).flat()}async loadRestoresWithPermanentGaps(e,t){return this._loadRestoreProgressByDeviceStatus(e,t,"done_with_gaps")}async deleteRestoreProgress(e,t,s){if(!await this.loadRestoreProgress(e,t,s))return;let i=await this.openDB();return new Promise((a,o)=>{let c=i.transaction(lt,"readwrite");c.objectStore(lt).delete([t,s]),c.oncomplete=()=>a(),c.onerror=()=>o(c.error)})}async _loadRestoreProgressByDeviceStatus(e,t,s){let r=await this.openDB();return new Promise((i,a)=>{let p=r.transaction(lt,"readonly").objectStore(lt).index("device_status").getAll(IDBKeyRange.only([t,s]));p.onsuccess=()=>{let d=(p.result||[]).filter(u=>u.user_id===e);i(d)},p.onerror=()=>a(p.error)})}};var sw="ermis_user_cache";var Xs="users",Xh=n=>n.replace(/[^a-zA-Z0-9._-]/g,"_")||"default",Jn=class{dbPromise=null;dbName;constructor(e,t){this.dbName=`${sw}_${Xh(e)}_${Xh(t)}`}openDB(){return typeof indexedDB>"u"?Promise.resolve(null):this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((e,t)=>{let s;try{s=indexedDB.open(this.dbName,1)}catch(r){this.dbPromise=null,t(r);return}s.onupgradeneeded=()=>{let r=s.result;r.objectStoreNames.contains(Xs)||r.createObjectStore(Xs,{keyPath:"id"}).createIndex("cached_at","cached_at",{unique:!1})},s.onsuccess=()=>e(s.result),s.onerror=()=>{this.dbPromise=null,t(s.error)}}),this.dbPromise)}async saveUsers(e){let t=e.filter(r=>r?.id);if(t.length===0)return;let s=await this.openDB();s&&await new Promise((r,i)=>{let a=s.transaction(Xs,"readwrite"),o=a.objectStore(Xs),c=Date.now();for(let l of t)o.put({...l,cached_at:c});a.oncomplete=()=>r(),a.onerror=()=>i(a.error),a.onabort=()=>i(a.error)})}async saveUser(e){await this.saveUsers([e])}async loadUsers(){let e=await this.openDB();return e?new Promise((t,s)=>{let r=e.transaction(Xs,"readonly"),i=r.objectStore(Xs).getAll();i.onsuccess=()=>{let a=(i.result||[]).map(o=>{let{cached_at:c,...l}=o;return l});t(a)},i.onerror=()=>s(i.error),r.onerror=()=>s(r.error)}):[]}};var Yn=class{loadTokenPromise;token;user;constructor(){this.loadTokenPromise=null}setTokenOrProvider=async(e,t)=>{this.user=t,typeof e=="string"&&(this.token=e),this.loadTokenPromise=Promise.resolve(this.token)};reset=()=>{this.token=void 0,this.user=void 0,this.loadTokenPromise=null};tokenReady=()=>this.loadTokenPromise;getToken=()=>this.token};function Si(n){return!n.status||n.status<200||300<=n.status}var Ai=We(Zh());var ys=class extends Error{code;response;status},dc=(l=>(l.CREATE_CALL="create-call",l.ACCEPT_CALL="accept-call",l.SIGNAL_CALL="signal-call",l.CONNECT_CALL="connect-call",l.HEALTH_CALL="health-call",l.END_CALL="end-call",l.REJECT_CALL="reject-call",l.MISS_CALL="miss-call",l.UPGRADE_CALL="upgrade-call",l))(dc||{}),uc=(i=>(i.PREPARING="preparing",i.RINGING="ringing",i.ENDED="ended",i.CONNECTED="connected",i.ERROR="error",i))(uc||{}),hc=(u=>(u[u.VIDEO_CONFIG=0]="VIDEO_CONFIG",u[u.AUDIO_CONFIG=1]="AUDIO_CONFIG",u[u.VIDEO_KEY=2]="VIDEO_KEY",u[u.VIDEO_DELTA=3]="VIDEO_DELTA",u[u.AUDIO=4]="AUDIO",u[u.ORIENTATION=5]="ORIENTATION",u[u.CONNECTED=6]="CONNECTED",u[u.TRANSCEIVER_STATE=7]="TRANSCEIVER_STATE",u[u.REQUEST_CONFIG=8]="REQUEST_CONFIG",u[u.REQUEST_KEY_FRAME=9]="REQUEST_KEY_FRAME",u[u.END_CALL=10]="END_CALL",u[u.HEALTH_CALL=11]="HEALTH_CALL",u))(hc||{});function nw(n){return typeof n=="string"||n instanceof String}var mc=class n{static _instance;activeChannels;axiosInstance;baseURL;userBaseURL;browser;cleaningIntervalRef;clientID;apiKey;projectId;listeners;logger;recoverStateOnReconnect;node;options;setUserPromise;state;tokenManager;user;userAgent;userID;wsBaseURL;wsConnection;wsPromise;consecutiveFailures;defaultWSTimeout;deviceId;latestKeyPackagesRemaining;encryptionManager;userCache;userCacheKey;userCacheSyncPromise=null;eventSource=null;constructor(e,t,s,r){this.apiKey=e,this.projectId=t,this.listeners={},this.state=new Hs;let i=r||{};this.browser=typeof i.browser<"u"?i.browser:typeof window<"u",this.node=!this.browser,this.options={withCredentials:!1,warmUp:!1,recoverStateOnReconnect:!0,...i},this.node&&!this.options.httpsAgent&&(this.options.httpsAgent=new ns.Agent({keepAlive:!0,keepAliveMsecs:3e3})),this.axiosInstance=zs.create(this.options),this.setBaseURL(s),this.wsConnection=null,this.wsPromise=null,this.setUserPromise=null,this.activeChannels={},this.tokenManager=new Yn,this.consecutiveFailures=0,this.defaultWSTimeout=15e3,this.axiosInstance.defaults.paramsSerializer=Pu,this.logger=ri(i.logger),$s(i.logger),this.recoverStateOnReconnect=this.options.recoverStateOnReconnect}static getInstance(e,t,s,r){return n._instance||(n._instance=new n(e,t,s,r)),n._instance}async refreshNewToken(e){return await this.post(this.userBaseURL+"/refresh_token",{refresh_token:e})}getAuthType(){return"jwt"}setBaseURL(e){this.baseURL=e,this.userBaseURL=this.options.userBaseURL||e+"/uss/v1",this.wsBaseURL=this.baseURL.replace("http","ws").replace(":3030",":8800")}async getExternalAuthToken(e,t){let s={apikey:this.apiKey,name:e.name};e.avatar&&(s.avatar=e.avatar);let r=this.userBaseURL+"/get_token/external_auth",i={"Content-Type":"application/json"};if(t){let a=typeof t=="string"&&t.startsWith("Bearer ")?t:`Bearer ${t}`;i.Authorization=a}try{return(await this.axiosInstance.get(r,{params:s,headers:i})).data}catch(a){let o="Failed to fetch external auth token";throw a.response&&a.response.data?o=a.response.data.message||JSON.stringify(a.response.data):a.message&&(o=a.message),new Error(o)}}connectUser=async(e,t,s)=>{if(this.logger("info","client:connectUser() - started",{tags:["connection","client"]}),!e.id)throw new Error('The "id" field on the user is missing');let r=e,i=t;if(s){let c=await this.getExternalAuthToken(e,t);i=c.token,r={...e,id:c.user_id}}if(this.userID===r.id&&this.setUserPromise)return this.logger("warn","Consecutive calls to connectUser is detected, ideally you should only call this function once in your app.",{tags:["connection","client"]}),this.setUserPromise;if(this.userID)throw new Error("Use client.disconnect() before trying to connect as a different user. connectUser was called twice.");if(this.node&&!this.options.allowServerSideConnect&&this.logger("warn",'Please do not use connectUser server side. connectUser impacts MAU and concurrent connection usage and thus your bill. If you have a valid use-case, add "allowServerSideConnect: true" to the client options to disable this warning.',{tags:["connection","client"]}),this.browser&&!this.deviceId)try{let c=new Ht("",this.logger);this.deviceId=await c.getDeviceId(),this.logger("info",`client:connectUser() - deviceId initialized: ${this.deviceId}`,{tags:["connection","client","e2ee"]})}catch(c){this.logger("warn","client:connectUser() - Failed to initialize deviceId from storage",{tags:["connection","client","e2ee"],err:c})}this.userID=r.id,await this._hydrateUserCacheFromStorage();let a=this._setToken(r,i);this._setUser(r),this._upsertUser({id:r.id,name:r?.name||r.id,avatar:r?.avatar||""},{updateReferences:!1});let o=this.openConnection();this.setUserPromise=Promise.all([a,o]).then(c=>c[1]);try{let c=await this.setUserPromise;return await this.connectToSSE(),this._scheduleUserCacheSync(),this.queryUser(r.id).then(l=>{let p={...this.user||r,...l};this.user=p,this._upsertUser(p,{updateReferences:!0}),this.dispatchEvent({type:"user.updated",me:this.user})}).catch(l=>{this.logger("error","client:connectUser() - failed to fetch full user profile",{err:l})}),c}catch(c){throw this.disconnectUser(),c}};setUser=this.connectUser;_setToken=(e,t)=>this.tokenManager.setTokenOrProvider(t,e);_setUser(e){this.user={...e},this.userID=e.id}_getUserCache(){if(!this.browser||!this.userID)return null;let e=`${this.projectId}:${this.userID}`;return(!this.userCache||this.userCacheKey!==e)&&(this.userCache=new Jn(this.projectId,this.userID),this.userCacheKey=e),this.userCache}_persistUsersToCache(e){let t=this._getUserCache(),s=e.filter(r=>r?.id);!t||s.length===0||t.saveUsers(s).catch(r=>{this.logger("warn","client:userCache - failed to persist users",{err:r})})}_shouldRefreshUserReferences(e,t){return e?e.name!==t.name||e.avatar!==t.avatar||e.about_me!==t.about_me||e.email!==t.email||e.phone!==t.phone:!0}_upsertUsers(e,t={}){let{persist:s=!0,updateReferences:r=!0}=t,i=e.filter(o=>o?.id);if(i.length===0)return;let a=r?i.filter(o=>this._shouldRefreshUserReferences(this.state.users[o.id],o)):[];this.state.updateUsers(i),s&&this._persistUsersToCache(i);for(let o of i)this.user?.id===o.id&&(this.user={...this.user,...o});for(let o of a){let c=this.state.users[o.id]||o;this._updateMemberWatcherReferences(c),this._updateUserMessageReferences(c)}a.length>0&&this.dispatchEvent({type:"users.updated",users:a})}_upsertUser(e,t={}){this._upsertUsers([e],t)}async _hydrateUserCacheFromStorage(){let e=this._getUserCache();if(e)try{let t=await e.loadUsers();this._upsertUsers(t,{persist:!1,updateReferences:!1})}catch(t){this.logger("warn","client:userCache - failed to hydrate users from IndexedDB",{err:t})}}_scheduleUserCacheSync(){!this.browser||this.userCacheSyncPromise||(this.userCacheSyncPromise=this.syncUserCache(1e4,1).catch(e=>{this.logger("warn","client:userCache - failed to sync users",{err:e})}).finally(()=>{this.userCacheSyncPromise=null}))}closeConnection=async e=>(this.cleaningIntervalRef!=null&&(clearInterval(this.cleaningIntervalRef),this.cleaningIntervalRef=void 0),await this.wsConnection?.disconnect(e),Promise.resolve());openConnection=async()=>{if(!this.userID)throw Error("User is not set on client, use client.connectUser instead");return this.wsConnection?.isConnecting&&this.wsPromise?(this.logger("info","client:openConnection() - connection already in progress",{tags:["connection","client"]}),this.wsPromise):this.wsConnection?.isHealthy?(this.logger("info","client:openConnection() - openConnection called twice, healthy connection already exists",{tags:["connection","client"]}),Promise.resolve()):(this.clientID=`${this.userID}--${Te()}`,this.wsPromise=this.connect(),this._startCleaning(),this.wsPromise)};_setupConnection=this.openConnection;disconnectUser=async e=>{this.logger("info","client:disconnect() - Disconnecting the client",{tags:["connection","client"]});let t=this.encryptionManager;t&&typeof t.destroy=="function"&&(t.destroy(),this.encryptionManager=void 0),this.deviceId=void 0,this.userCache=void 0,this.userCacheKey=void 0,this.userCacheSyncPromise=null,delete this.user,delete this.userID;let s=this.closeConnection(e);for(let r of Object.values(this.activeChannels))r._disconnect();return this.activeChannels={},this.state=new Hs,setTimeout(this.tokenManager.reset),s};disconnect=this.disconnectUser;on(e,t){let s=t?e:"all",r=t||e;return s in this.listeners||(this.listeners[s]=[]),this.logger("info",`Attaching listener for ${s} event`,{tags:["event","client"]}),this.listeners[s].push(r),{unsubscribe:()=>{this.logger("info",`Removing listener for ${s} event`,{tags:["event","client"]}),this.listeners[s]=this.listeners[s].filter(i=>i!==r)}}}off(e,t){let s=t?e:"all",r=t||e;s in this.listeners||(this.listeners[s]=[]),this.logger("info",`Removing listener for ${s} event`,{tags:["event","client"]}),this.listeners[s]=this.listeners[s].filter(i=>i!==r)}_logApiRequest(e,t,s,r){this.logger("info",`client: ${e} - Request - ${t}- ${JSON.stringify(s)} - ${JSON.stringify(r.params)}`,{tags:["api","api_request","client"],url:t,payload:s,config:r})}_logApiResponse(e,t,s){this.logger("info",`client:${e} - Response - url: ${t} > status ${s.status}`,{tags:["api","api_response","client"],url:t,response:s})}_logApiError(e,t,s,r){this.logger("error",`client:${e} - Error: ${JSON.stringify(s)} - url: ${t} - options: ${JSON.stringify(r)}`,{tags:["api","api_response","client"],url:t,error:s})}doAxiosRequest=async(e,t,s,r={})=>{await this.tokenManager.tokenReady();let i=this._enrichAxiosOptions(r);try{let a;switch(this._logApiRequest(e,t,s,i),e){case"get":a=await this.axiosInstance.get(t,i);break;case"delete":a=await this.axiosInstance.delete(t,i);break;case"post":a=await this.axiosInstance.post(t,s,i);break;case"postForm":a=await this.axiosInstance.postForm(t,s,i);break;case"put":a=await this.axiosInstance.put(t,s,i);break;case"patch":a=await this.axiosInstance.patch(t,s,i);break;case"options":a=await this.axiosInstance.options(t,i);break;default:throw new Error("Invalid request type")}return this._logApiResponse(e,t,a),this.consecutiveFailures=0,this.handleResponse(a)}catch(a){if(a.client_request_id=i.headers?.["x-client-request-id"],this._logApiError(e,t,a,r),this.consecutiveFailures+=1,a.response)return this.handleResponse(a.response);throw a}};get(e,t){return this.doAxiosRequest("get",e,null,{params:t})}put(e,t){return this.doAxiosRequest("put",e,t)}post(e,t,s){return this.doAxiosRequest("post",e,t,{params:s})}patch(e,t){return this.doAxiosRequest("patch",e,t)}delete(e,t){return this.doAxiosRequest("delete",e,null,{params:t})}sendFile(e,t,s,r,i){let a=Ru(t,s,r||"multipart/form-data");return i!=null&&a.append("user",JSON.stringify(i)),this.doAxiosRequest("postForm",e,a,{headers:a.getHeaders?a.getHeaders():{},config:{timeout:0,maxContentLength:1/0,maxBodyLength:1/0}})}async downloadMedia(e){let t=await fetch(e,{cache:"no-store"});if(!t.ok)throw new Error(`Failed to download media: ${t.statusText}`);return await t.blob()}errorFromResponse(e){let t;return t=new ys(`ErmisChat error HTTP code: ${e.status}`),e.data&&e.data.code&&(t=new Error(`ErmisChat error code ${e.data.code}: ${e.data.message}`),t.code=e.data.code),t.response=e,t.status=e.status,t}handleResponse(e){let t=e.data;if(Si(e))throw this.errorFromResponse(e);return t}dispatchEvent=e=>{if(e.received_at||(e.received_at=new Date),e.type==="channel.created"||e.type==="channel.topic.created")this._handleChannelCreatedEvent(e).then(()=>{this._afterDispatchEvent(e)});else{let t=this._handleClientEvent(e),s=e.cid,r=(s?this.activeChannels[s]:void 0)||(e.type==="protocol"&&s?.startsWith("mls:")?this.activeChannels[s.slice(4)]:void 0);if(r){let i=r._handleChannelEvent(e);if(i&&typeof i.then=="function"){i.then(()=>{this._callClientListeners(e),r&&r._callChannelListeners(e),t.forEach(a=>a())}).catch(a=>{this.logger("error","client:_handleChannelEvent() failed",{err:a,event:e}),this._callClientListeners(e),r&&r._callChannelListeners(e),t.forEach(o=>o())});return}}this._callClientListeners(e),r&&r._callChannelListeners(e),t.forEach(i=>i())}};_afterDispatchEvent(e){let t=this._handleClientEvent(e),s=e.cid,r=(s?this.activeChannels[s]:void 0)||(e.type==="protocol"&&s?.startsWith("mls:")?this.activeChannels[s.slice(4)]:void 0);if(r){let i=r._handleChannelEvent(e);if(i&&typeof i.then=="function"){i.then(()=>{this._callClientListeners(e),r&&r._callChannelListeners(e),t.forEach(a=>a())});return}}this._callClientListeners(e),r&&r._callChannelListeners(e),t.forEach(i=>i())}async _handleChannelCreatedEvent(e){let t=e.channel?.members||[];await xt(this,t);let s=Object.values(this.state.users),r=de(t,s),i=e.channel_type==="messaging"?hs(r,this.userID||""):e.channel?.name,a={...e.channel,members:r,name:i},o={channel:a,members:r,messages:[],pinned_messages:[]},c=this.channel(e.channel_type||"",e.channel_id||"");c.data=a,c._initializeState(o,"latest")}handleEvent=e=>{let t=e.data,s=Fu(JSON.parse(t));this.dispatchEvent(s)};_updateMemberWatcherReferences=e=>{Object.values(this.activeChannels).forEach(t=>{if(t?.state){let s=!1;if(t.state.members[e.id]&&(t.state.members={...t.state.members,[e.id]:{...t.state.members[e.id],user:e}},s=!0,t.data?.type==="messaging")){let r=Object.values(t.state.members);if(r.length===2){let i=r.find(a=>a.user?.id!==this.userID);i&&i.user?.id===e.id&&(t.data.name=e.name||e.id,t.data.image=e.avatar||"")}}t.state.watchers[e.id]&&(t.state.watchers={...t.state.watchers,[e.id]:e},s=!0),t.state.read[e.id]&&(t.state.read={...t.state.read,[e.id]:{...t.state.read[e.id],user:e}},s=!0),s&&(t._callChannelListeners({type:"channel.updated",channel:t.data,cid:t.cid}),t.state.members[e.id]&&t._callChannelListeners({type:"member.updated",member:t.state.members[e.id],cid:t.cid}),t._callChannelListeners({type:"user.updated",user:e,cid:t.cid}))}})};_updateUserReferences=this._updateMemberWatcherReferences;_updateUserMessageReferences=e=>{let t=this.state.userChannelReferences[e.id]||{};for(let s in t){let r=this.activeChannels[s];if(!r)continue;let i=r.state;i?.updateUserMessages(e),r._callChannelListeners({type:"channel.updated",channel:r.data,cid:r.cid});let a=i?.messages[i.messages.length-1];a&&r._callChannelListeners({type:"message.updated",message:a,cid:r.cid})}};_deleteUserMessageReference=(e,t=!1)=>{let s=this.state.userChannelReferences[e.id]||{};for(let r in s)this.activeChannels[r].state?.deleteUserMessages(e,t)};_handleClientEvent(e){let t=this,s=[];if(this.logger("info",`client:_handleClientEvent - Received event of type { ${e.type} }`,{tags:["event","client"],event:e}),e.type==="health.check"&&e.me){let r=e.me.key_packages_remaining;typeof r=="number"&&(this.latestKeyPackagesRemaining=r),this.encryptionManager?.initialized&&typeof r=="number"&&this.encryptionManager.ensureKeyPackages(r).catch(i=>{this.logger("warn","[Encryption] Failed to top up key packages",{err:i})})}if((e.type==="channel.deleted"||e.type==="notification.channel_deleted")&&e.cid){t.state.deleteAllChannelReference(e.cid),this.activeChannels[e.cid]?._disconnect(),s.push(()=>{e.cid&&delete this.activeChannels[e.cid]});for(let r of Object.values(this.activeChannels))r.type==="team"&&r.state.topics?.some(i=>i.cid===e.cid)&&(r.state.topics=r.state.topics.filter(i=>i.cid!==e.cid))}if(e.type==="notification.invite_rejected"&&e.member?.user_id===this.userID&&e.cid){if(e.mls_enabled&&this.encryptionManager?.initialized){let r=e.created_at||e.createdAt||e.message?.created_at||Date.now();if(this.encryptionManager.leaveGroup(e.cid,r),Array.isArray(e.topic_cids))for(let i of e.topic_cids)this.encryptionManager.ownsE2eeGroup(i)&&this.encryptionManager.leaveGroup(i,r)}t.state.deleteAllChannelReference(e.cid),this.activeChannels[e.cid]?._disconnect(),s.push(()=>{e.cid&&delete this.activeChannels[e.cid]})}return e.type,e.type==="member.added"&&e.member?.user_id===this.userID&&this.channel(e.channel_type||"",e.channel_id||"").watch().catch(i=>{this.logger("error","Failed to watch channel after member.added",{err:i,event:e})}),e.type==="message.new"&&e.channel_type==="topic"&&s.push(()=>{let r=e.parent_cid||e.channel?.parent_cid;if(r&&this.activeChannels[r]){let i=this.activeChannels[r];i.state.topics&&(i.state.topics.sort((a,o)=>{let c=a.state?.latestMessages?.[a.state.latestMessages.length-1]?.created_at,l=o.state?.latestMessages?.[o.state.latestMessages.length-1]?.created_at,p=c?new Date(c).getTime():0;return(l?new Date(l).getTime():0)-p}),i._callChannelListeners({...e,type:"channel.updated",channel:i.data}))}}),e.type==="channel.topic.updated"&&s.push(()=>{let r=e.parent_cid||e.channel?.parent_cid;if(r&&this.activeChannels[r]){let i=this.activeChannels[r];if(i.state?.topics&&e.channel){let a=i.state.topics.findIndex(o=>o.cid===e.cid||o.channel?.cid===e.cid);if(a!==-1){let o=i.state.topics[a];o.data?o.data={...o.data,...e.channel}:o.channel?o.channel={...o.channel,...e.channel}:Object.assign(o,e.channel)}i._callChannelListeners({...e,type:"channel.updated",channel:i.data})}}if(e.cid&&this.activeChannels[e.cid]){let i=this.activeChannels[e.cid];e.channel&&(i.data={...i.data,...e.channel},i._callChannelListeners({...e,type:"channel.updated",channel:i.data}))}}),(e.type==="channel.topic.closed"||e.type==="channel.topic.reopen")&&s.push(()=>{let r=e.type==="channel.topic.closed",i=e.parent_cid;if(i&&this.activeChannels[i]){let a=this.activeChannels[i];if(a.state?.topics){let o=a.state.topics.findIndex(c=>c.cid===e.cid||c.channel?.cid===e.cid);if(o!==-1){let c=a.state.topics[o];c.data?c.data.is_closed_topic=r:c.channel?c.channel.is_closed_topic=r:c.is_closed_topic=r}a._callChannelListeners({...e,type:"channel.updated",channel:a.data})}}if(e.cid&&this.activeChannels[e.cid]){let a=this.activeChannels[e.cid];a.data&&(a.data.is_closed_topic=r),a._callChannelListeners({...e,type:"channel.updated",channel:a.data})}}),e.type==="connection.recovered"&&s.push(()=>{Object.values(this.activeChannels).forEach(r=>{if(!r.state?.messages)return;r.state.messages.filter(a=>a.status==="failed_offline"&&a.user?.id===this.userID&&(!a.attachments||a.attachments.length===0)).forEach(a=>{a.id&&r.retryMessage(a.id).catch(o=>{this.logger("error",`Failed to auto-resend offline message ${a.id}`,{tags:["offline","retry"],err:o})})})})}),s}_callClientListeners=e=>{let t=this,s=[];t.listeners.all&&s.push(...t.listeners.all),t.listeners[e.type]&&s.push(...t.listeners[e.type]);for(let r of s)r(e)};recoverState=async()=>{this.logger("info","client:recoverState() - Start of recoverState",{tags:["connection"]}),this.encryptionManager?.initialized&&this.encryptionManager.markSyncStart();let e=Object.keys(this.activeChannels);if(e.length&&this.recoverStateOnReconnect){this.logger("info",`client:recoverState() - Start the querying of ${e.length} channels`,{tags:["connection","client"]});let{filter:t={type:["messaging","team","meeting"]},sort:s=[],options:r={message_limit:1}}=this.options.recoveryConfig||{};await this.queryChannels(t,s,r),this.logger("info","client:recoverState() - Querying channels finished",{tags:["connection","client"]}),this.dispatchEvent({type:"connection.recovered"})}else this.dispatchEvent({type:"connection.recovered"});if(this.encryptionManager?.initialized)try{await this.encryptionManager.sync()}catch(t){this.logger("error","[Encryption] Failed to sync on reconnect",{err:t})}this.wsPromise=Promise.resolve(),this.setUserPromise=Promise.resolve()};async connect(){if(!this.userID||!this.user)throw Error("Call connectUser before starting the connection");if(!this.wsBaseURL)throw Error("Websocket base url not set");if(!this.clientID)throw Error("clientID is not set");this.options.wsConnection&&this.node?(this.options.wsConnection.setClient(this),this.wsConnection=this.options.wsConnection):this.wsConnection=new Vn({client:this});try{return await this.wsConnection.connect(this.defaultWSTimeout)}catch(e){throw e}}async connectToSSE(e){if(this.eventSource){this.logger("info","client:connectToSSE() - SSE connection already established",{});return}let t=this._getToken();t?.startsWith("Bearer ")||(t=`Bearer ${t}`);let s={method:"GET",Authorization:t};this.eventSource=new Ai.EventSourcePolyfill(this.userBaseURL+"/sse/subscribe",{headers:s,heartbeatTimeout:6e4}),this.eventSource.onopen=()=>{this.logger("info","client:connectToSSE() - SSE connection established",{})},this.eventSource.onmessage=r=>{let i=JSON.parse(r.data);if(this.logger("info",`client:connectToSSE() - SSE message received event : ${JSON.stringify(i)}`,{event:r}),i.type==="AccountUserChainProjects"){let a={id:i.id,name:i.name,avatar:i.avatar,about_me:i.about_me,project_id:i.project_id};this.user?.id===a.id&&(this.user={...this.user,...a}),this._upsertUser(a),e&&e(i),this.dispatchEvent({type:"user.updated",user:a,me:this.user?.id===a.id?this.user:void 0})}},this.eventSource.onerror=r=>{this.logger("error",`client:connectToSSE() - SSE connection error : ${JSON.stringify(r.data)} `,{event:r}),r.status===401?(this.logger("error","client:connectToSSE() - Unauthorized (401). Aborting the connection.",{}),this.disconnectFromSSE()):(this.eventSource?.readyState===Ai.EventSourcePolyfill.CLOSED||this.eventSource?.readyState===Ai.EventSourcePolyfill.CONNECTING)&&(this.eventSource.close(),this.eventSource=null,setTimeout(()=>{this.logger("info","client:connectToSSE() - Reconnecting to SSE",{}),this.connectToSSE(e)},3e3))}}async disconnectFromSSE(){this.eventSource?(this.eventSource.close(),this.eventSource=null,this.logger("info","client:disconnectFromSSE() - SSE connection closed",{})):this.logger("info","client:disconnectFromSSE() - SSE connection already closed",{})}async queryUsers(e,t){await this.wsPromise;let s=this.userID,r=this.projectId,i=await this.get(this.userBaseURL+"/users",{project_id:r,page:t,page_size:e});return s&&this.userID===s&&this._upsertUsers(i.data),i}async syncUserCache(e=1e4,t=1){return await this.queryUsers(e,t)}async queryUser(e){let t=this.userID,s=this.projectId,r=await this.get(this.userBaseURL+"/users/"+e,{project_id:s});return t&&this.userID===t&&this._upsertUser(r),r}async getBatchUsers(e,t,s){let r=this.userID,i=this.projectId,a=await this.post(this.userBaseURL+"/users/batch?page=1&page_size=10000",{users:e,project_id:i},{page:t,page_size:s});return r&&this.userID===r&&this._upsertUsers(a.data),a.data||[]}async searchUsers(e,t,s){let r=this.projectId;return await this.post(this.userBaseURL+"/users/search",void 0,{page:e,page_size:t,name:s,project_id:r})}async queryContacts(){let e=this.projectId,s=(await this.post(this.baseURL+"/contacts/list",{project_id:e})).project_id_user_ids[e],r=[],i=[];return s.forEach(a=>{let o=a.other_id,c=this.state.users[o],l=c||{id:o};switch(a.relation_status){case"blocked":i.push(l);break;case"normal":r.push(l);break;default:}}),{contact_users:r,block_users:i}}_updateProjectID(e){this.projectId=e}async uploadAvatar(e){let t=new FormData;t.append("avatar",e);let s=await this.post(this.userBaseURL+"/users/upload",t,{headers:{"Content-Type":"multipart/form-data"}});if(this.user){this.user.avatar=s.avatar;let r={...this.user,avatar:s.avatar};this._upsertUser(r),this.dispatchEvent({type:"user.updated",me:this.user})}return s}async updateProfile(e){let t=await this.patch(this.userBaseURL+"/users/update",e);return this.user=t,this._upsertUser(t),this.user&&this.dispatchEvent({type:"user.updated",me:this.user}),t}async queryChannels(e,t=[],s={},r={}){await this.wsPromise;let i=this.projectId,a={filter_conditions:{...e,project_id:i},sort:t,...s},o=await this.post(this.baseURL+"/channels",a);o.channels.sort((u,h)=>{let m=ms(u.messages);if(u.channel.type==="team"&&Array.isArray(u.topics))for(let _ of u.topics)m=Math.max(m,ms(_.messages));let g=ms(h.messages);if(h.channel.type==="team"&&Array.isArray(h.topics))for(let _ of h.topics)g=Math.max(g,ms(_.messages));return g-m});let c=Array.from(new Set(o.channels.flatMap(u=>(u.channel.members||[]).map(h=>h.user.id))))||[];if(!e.parent_cid){let u=c.map(h=>({user:{id:h}}));await xt(this,u)}let l=Object.values(this.state.users);o.channels.forEach(u=>{u.channel.members=de(u.channel.members,l),u.messages=de(u.messages,l),u.read=de(u.read||[],l),u.channel.name=u.channel.type==="messaging"?hs(u.channel.members,this.userID||""):u.channel.name,u.channel.image=u.channel.type==="messaging"?Un(u.channel.members,this.userID||""):u.channel.image,u.channel.type==="team"&&Array.isArray(u.topics)&&u.topics.sort((h,m)=>{let g=ms(h.messages);return ms(m.messages)-g}),u.pinned_messages&&(u.pinned_messages=de(u.pinned_messages||[],l))}),this.encryptionManager?.storage&&await Promise.all(o.channels.map(async u=>{if(!(u.channel?.mls_enabled===!0)||!u.messages?.length)return;let m=this.channel(u.channel.type,u.channel.id);u.messages=await m._hydrateE2eeMessagesFromLocalCache(u.messages,u.channel),u.pinned_messages?.length&&(u.pinned_messages=await m._hydrateE2eeMessagesFromLocalCache(u.pinned_messages,u.channel))}));let{channels:p,userIds:d}=this.hydrateChannels(o.channels,r);return this.dispatchEvent({type:"channels.queried"}),p}hydrateChannels(e=[],t={}){let{skipInitialization:s,offlineMode:r=!1}=t,i=[],a=[];for(let o of e){let c=this.channel(o.channel.type,o.channel.id);c.data={...o.channel,is_pinned:o.is_pinned||!1},c.offlineMode=r,c.initialized=!r,s===void 0?c._initializeState(o,"latest",l=>{a.includes(l)||a.push(l)}):s.includes(o.channel.id)||(c.state.clearMessages(),c._initializeState(o,"latest",l=>{a.includes(l)||a.push(l)})),i.push(c)}return{channels:i,userIds:a}}async searchPublicChannel(e,t=0,s=25){let r=this.projectId;return await this.post(this.baseURL+"/channels/public/search",{project_id:r,search_term:e,limit:s,offset:t})}async pinChannel(e,t){return await this.post(this.baseURL+`/channels/${e}/${t}/pin`)}async unpinChannel(e,t){return await this.post(this.baseURL+`/channels/${e}/${t}/unpin`)}channel(e,t,s){if(!this.userID)throw Error("Call connectUser before creating a channel");if(~e.indexOf(":"))throw Error(`Invalid channel group ${e}, can't contain the : character`);let r,i=s||{};return typeof t=="string"?r=t:typeof t=="object"&&t!==null&&(i=t),this.getChannelById(e,r,i)}getChannelById=(e,t,s)=>{let r=`${e}:${t||""}`;if(r in this.activeChannels&&!this.activeChannels[r].disconnected){let a=this.activeChannels[r];return Object.keys(s).length>0&&(a.data=s,a._data=s),a}let i=new Ks(this,e,t,s);return this.activeChannels[i.cid]=i,i};getChannel=(e,t)=>{let s=Te(),r=`${this.projectId}:${s}`,i=`${e}:${r}`;if(i in this.activeChannels&&!this.activeChannels[i].disconnected){let o=this.activeChannels[i];return Object.keys(t).length>0&&(o.data=t,o._data=t),o}let a=new Ks(this,e,r,t);return this.activeChannels[a.cid]=a,a};async createQuickChannel(e){if(!this.userID)throw Error("Call connectUser before creating a channel");let t=new Date,s=new Intl.DateTimeFormat("en-US",{month:"short",day:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(t),r={name:e||`Quick Channel - ${s}`,members:[this.userID],public:!0},i=this.channel("meeting",r);return await i.create(),i}async joinQuickChannel(e){if(!this.userID)throw Error("Call connectUser before joining a channel");let t=this.channel("meeting",e);return await t.watch(),t.state.members&&t.state.members[this.userID]||(await t.acceptInvite("join"),await t.watch()),t}_normalizeExpiration(e){let t=null;if(typeof e=="number"){let s=new Date;s.setSeconds(s.getSeconds()+e),t=s.toISOString()}else nw(e)?t=e:e instanceof Date&&(t=e.toISOString());return t}getUserAgent(){return this.userAgent||`ermis-chat-sdk-javascript-client-${this.node?"node":"browser"}-2.0.1`}setUserAgent(e){this.userAgent=e}_enrichAxiosOptions(e={params:{},headers:{},config:{}}){let t=this._getToken();t?.startsWith("Bearer ")||(t=`Bearer ${t}`);let s=t?{Authorization:t}:void 0;e.headers?.["x-client-request-id"]||(e.headers={...e.headers,"x-client-request-id":Te()});let{params:r,headers:i,...a}=this.options.axiosRequestConfig||{};return{params:{...e.params,...r||{}},headers:{...s,"stream-auth-type":this.getAuthType(),"X-Stream-Client":this.getUserAgent(),...this.deviceId?{"X-Device-ID":this.deviceId}:{},...e.headers,...i||{},[di]:Vs},...e.config,...a||{}}}_getToken(){return this.tokenManager?this.tokenManager.getToken():null}_startCleaning(){let e=this;this.cleaningIntervalRef==null&&(this.cleaningIntervalRef=setInterval(()=>{for(let t of Object.values(e.activeChannels))t.clean()},500))}_buildWSPayload=e=>JSON.stringify({user_id:this.userID,user_details:this.user,client_request_id:e})};var rw={"channel.created":!0,"channel.deleted":!0,"channel.truncate":!0,"channel.truncate_for_me":!0,"channel.updated":!0,"channel.pinned":!0,"channel.unpinned":!0,"health.check":!0,"member.added":!0,"member.removed":!0,"member.updated":!0,"member.joined":!0,"member.promoted":!0,"member.demoted":!0,"member.banned":!0,"member.unbanned":!0,"member.blocked":!0,"member.unblocked":!0,"message.deleted":!0,"message.deleted_for_me":!0,"message.new":!0,"message.read":!0,"message.updated":!0,"message.pinned":!0,"message.unpinned":!0,"notification.channel_deleted":!0,"notification.invite_accepted":!0,"notification.invite_rejected":!0,"notification.invite_messaging_rejected":!0,"notification.invite_messaging_skipped":!0,"pollchoice.new":!0,"reaction.deleted":!0,"reaction.new":!0,"typing.start":!0,"typing.stop":!0,"user.watching.start":!0,"user.watching.stop":!0,"connection.changed":!0,"connection.recovered":!0,"capabilities.changed":!0,"channel.topic.disabled":!0,"channel.topic.enabled":!0,"channel.topic.created":!0,"channel.topic.closed":!0,"channel.topic.reopen":!0,"channel.topic.updated":!0,protocol:!0,"e2ee.initialized":!0,"e2ee.bootstrap_progress":!0,"e2ee.message_decrypted":!0,"e2ee.local_messages_loaded":!0,"e2ee.restore_progress":!0};var ki=class n{worker;nextId=0;pendingCalls=new Map;recvResolveQueue=[];recvDataQueue=[];recvErrorQueue=[];static cachedBlobUrl=null;static cachedWasmBytes=null;constructor(e){if(!n.cachedBlobUrl){let t=e.toString(),s=new XMLHttpRequest;if(s.open("GET",t,!1),s.send(),s.status===200){let r=new Blob([s.responseText],{type:"application/javascript"});n.cachedBlobUrl=URL.createObjectURL(r)}}n.cachedBlobUrl?this.worker=new Worker(n.cachedBlobUrl,{type:"module"}):this.worker=new Worker(e,{type:"module"}),this.worker.onmessage=t=>this.handleMessage(t.data),this.worker.onerror=t=>{b("error","WASM Worker error:",t.message),this.pendingCalls.forEach(({reject:s})=>s(new Error(`Worker error: ${t.message}`))),this.pendingCalls.clear()}}async init(e){if(!n.cachedWasmBytes){let s=new URL(e||"/ermis_call_node_wasm_bg.wasm",window.location.origin).href,r=await fetch(s);n.cachedWasmBytes=await r.arrayBuffer()}let t=n.cachedWasmBytes.slice(0);await this.call("init",{wasmBytes:t},[t])}async spawn(e){await this.call("spawn",{relayUrls:e})}async getLocalEndpointAddr(){return await this.call("getLocalEndpointAddr")}async connect(e){await this.call("connect",{address:e})}async acceptConnection(){await this.call("acceptConnection")}async sendFrame(e){await this.call("sendFrame",{data:e},[e.buffer])}async beginWithGop(e){await this.call("beginWithGop",{data:e},[e.buffer])}async sendAudioFrame(e){await this.call("sendAudioFrame",{data:e},[e.buffer])}async sendControlFrame(e){await this.call("sendControlFrame",{data:e})}async asyncRecv(){return this.recvDataQueue.length>0?this.recvDataQueue.shift():new Promise((e,t)=>{this.recvResolveQueue.push(e),this.recvErrorQueue.push(t)})}async startRecvLoop(){await this.call("startRecvLoop")}async stopRecvLoop(){await this.call("stopRecvLoop")}async closeEndpoint(){await this.call("closeEndpoint")}closeConnection(){let e=this.nextId++;this.worker.postMessage({id:e,type:"closeConnection"})}networkChange(){let e=this.nextId++;this.worker.postMessage({id:e,type:"networkChange"})}async getStats(){return await this.call("getStats")}async terminate(){try{await this.call("terminate")}catch{}this.worker.terminate(),this.recvResolveQueue=[],this.recvErrorQueue.forEach(e=>e(new Error("Worker terminated"))),this.recvErrorQueue=[],this.recvDataQueue=[]}handleMessage(e){if(e.type==="recv_data"){let r=e.data;if(this.recvResolveQueue.length>0){let i=this.recvResolveQueue.shift();this.recvErrorQueue.shift(),i(r)}else this.recvDataQueue.push(r);return}if(e.type==="recv_error"){let r=new Error(e.error);if(this.recvErrorQueue.length>0){let i=this.recvErrorQueue.shift();this.recvResolveQueue.shift(),i(r)}return}if(e.type==="sdk_log"){b(e.logLevel,...e.args);return}let{id:t}=e,s=this.pendingCalls.get(t);s&&(this.pendingCalls.delete(t),e.type==="error"?s.reject(new Error(e.error)):s.resolve(e.data))}call(e,t,s){let r=this.nextId++;return new Promise((i,a)=>{this.pendingCalls.set(r,{resolve:i,reject:a});let o={id:r,type:e,...t};s&&s.length>0?this.worker.postMessage(o,s):this.worker.postMessage(o)})}};var Pi=class{videoEncoder=null;audioEncoder=null;videoReader=null;audioReader=null;localStream=null;videoConfig=null;audioConfig=null;videoConfigSent=!1;audioConfigSent=!1;hasVideo=!1;hasAudio=!1;forceKeyFrame=!1;isSendingVideo=!1;isSendingAudio=!1;nodeCall;healthCallInterval=null;constructor(e){this.nodeCall=e}async connect(e){try{await this.nodeCall.connect(e),await this.sendConnected(),await this.sendConfigs(),this.startHealthCallInterval()}catch(t){b("error","Error starting MediaStreamSender:",t)}}async sendConfigs(){try{await this.sendTransceiverState(this.hasAudio,this.hasVideo),await this.sendAudioConfig(),this.localStream?.getVideoTracks()[0]&&await this.sendVideoConfig()}catch(e){b("error","Error sending configs:",e)}}stop=()=>{if(this.healthCallInterval&&(clearInterval(this.healthCallInterval),this.healthCallInterval=null),this.videoReader){try{this.videoReader.cancel("Stream stopped").catch(()=>{})}catch{}this.videoReader=null}if(this.videoEncoder){try{this.videoEncoder.state!=="closed"&&(this.videoEncoder.reset(),this.videoEncoder.close())}catch{}this.videoEncoder=null}if(this.audioEncoder){try{this.audioEncoder.state!=="closed"&&(this.audioEncoder.reset(),this.audioEncoder.close())}catch{}this.audioEncoder=null}if(this.audioReader){try{this.audioReader.cancel("Stream stopped").catch(()=>{})}catch{}this.audioReader=null}this.videoConfig=null,this.audioConfig=null,this.videoConfigSent=!1,this.audioConfigSent=!1,this.hasVideo=!1,this.hasAudio=!1,this.localStream&&(this.localStream.getTracks().forEach(e=>e.stop()),this.localStream=null)};initAudioEncoder=e=>{this.localStream=new MediaStream([e]),this.audioConfigSent=!1,this.hasAudio=!!e;let t=new AudioEncoder({output:(s,r)=>{if(r?.decoderConfig&&!this.audioConfigSent){let i;r.decoderConfig.description&&(i=Co(r.decoderConfig.description)),this.audioConfig={codec:r.decoderConfig.codec??"opus",sampleRate:r.decoderConfig.sampleRate??48e3,numberOfChannels:r.decoderConfig.numberOfChannels??1,...i&&{description:i}},this.sendAudioConfig()}if(s&&this.isReadyToSendData("audio")){if(this.isSendingAudio)return;this.isSendingAudio=!0;let i=new ArrayBuffer(s.byteLength);s.copyTo(i);let a=s.timestamp,o=qt(i,a,"audio",null);this.sendPacketOrQueue(o,"audio",null).finally(()=>{this.isSendingAudio=!1})}},error:s=>b("error","AudioEncoder error:",s)});t.configure({codec:"mp4a.40.2",sampleRate:48e3,numberOfChannels:1,bitrate:128e3}),this.audioEncoder=t,this.processAudioFrames(e)};initVideoEncoder(e){this.localStream&&this.localStream.addTrack(e),this.videoConfigSent=!1,this.hasVideo=!!e;let t=e.getSettings(),s=t.width||1280,r=t.height||720,i=new VideoEncoder({output:async(a,o)=>{if(o?.decoderConfig&&!this.videoConfigSent){let c;o.decoderConfig.description&&(c=Co(o.decoderConfig.description)),this.videoConfig={codec:o.decoderConfig.codec??"hev1.1.6.L93.B0",codedWidth:o.decoderConfig.codedWidth??s,codedHeight:o.decoderConfig.codedHeight??r,frameRate:30,orientation:0,...c&&{description:c}},await this.sendVideoConfig()}if(a&&this.isReadyToSendData("video")){if(this.isSendingVideo)return;this.isSendingVideo=!0;let c=new ArrayBuffer(a.byteLength);a.copyTo(c);let l=a.type==="key"?"video-key":"video-delta",p=a.timestamp,d=qt(c,p,l,null);this.sendPacketOrQueue(d,"video",l).finally(()=>{this.isSendingVideo=!1})}},error:a=>b("error","VideoEncoder error:",a)});i.configure({codec:"hev1.1.6.L93.B0",width:s,height:r,bitrate:5e5,framerate:30,latencyMode:"realtime",hardwareAcceleration:"prefer-hardware"}),this.videoEncoder=i,this.processVideoFrames(e)}initEncoders=e=>{let t=e.getVideoTracks()[0],s=e.getAudioTracks()[0];s&&this.initAudioEncoder(s),t&&this.initVideoEncoder(t)};sendTransceiverState=async(e,t)=>{let r=qt(null,null,"transciverState",{audio_enable:!!e,video_enable:!!t});await this.nodeCall.sendControlFrame(r)};async replaceVideoTrack(e){if(this.videoReader){try{await this.videoReader.cancel("Replacing track")}catch{}this.videoReader=null}e&&this.processVideoFrames(e)}async replaceAudioTrack(e){if(this.audioReader){try{await this.audioReader.cancel("Replacing audio track")}catch{}this.audioReader=null}e&&this.processAudioFrames(e)}requestKeyFrame=()=>{b("info","\u{1F4E5} KeyFrame requested"),this.forceKeyFrame=!0};processVideoFrames=async e=>{try{let t=new MediaStreamTrackProcessor({track:e});this.videoReader=t.readable.getReader();let s=0;for(;this.videoReader;){let{done:r,value:i}=await this.videoReader.read();if(r)break;if(!this.videoEncoder){i?.close();break}if(i){s+=1;let a=s%60===0||this.forceKeyFrame;this.forceKeyFrame&&(b("info","\u{1F4E4} Sending forced KeyFrame"),this.forceKeyFrame=!1);try{this.videoEncoder.encode(i,{keyFrame:a})}catch(o){b("error","Encode error:",o)}finally{i.close()}}}}catch(t){b("error",`Error processing video frames: ${t.message}`)}finally{if(this.videoReader)try{this.videoReader.releaseLock()}catch{}}};processAudioFrames=async e=>{let t=new MediaStreamTrackProcessor({track:e});this.audioReader=t.readable.getReader();try{for(;this.audioReader;){let{done:s,value:r}=await this.audioReader.read();if(s)break;if(!this.audioEncoder){r?.close();break}if(r)try{this.audioEncoder.encode(r)}catch(i){b("error","Audio Encoding error:",i)}finally{r.close()}}}catch(s){b("error",`Error processing audio frames: ${s.message}`)}finally{if(this.audioReader)try{this.audioReader.releaseLock()}catch{}}};isReadyToSendData=e=>{let t=!this.hasVideo||this.videoConfigSent,s=!this.hasAudio||this.audioConfigSent,r=t&&s;return e==="video"?r&&this.videoConfigSent:e==="audio"?r&&this.audioConfigSent:!1};sendVideoConfig=async()=>{if(this.videoConfig&&!this.videoConfigSent)try{let e=qt(null,null,"videoConfig",this.videoConfig);await this.nodeCall.sendControlFrame(e),this.videoConfigSent=!0}catch(e){b("error","Error sending video config:",e)}};sendAudioConfig=async()=>{if(this.audioConfig&&!this.audioConfigSent)try{let e=qt(null,null,"audioConfig",this.audioConfig);await this.nodeCall.sendControlFrame(e),this.audioConfigSent=!0}catch(e){b("error","Error sending audio config:",e)}};sendConnected=async()=>{let e=qt(null,null,"connected",null);await this.nodeCall.sendControlFrame(e)};startHealthCallInterval=()=>{this.healthCallInterval&&clearInterval(this.healthCallInterval),this.healthCallInterval=setInterval(()=>{this.sendHealthCall().catch(()=>{})},5e3)};sendHealthCall=async()=>{try{let e=qt(null,null,"healthCall",null);await this.nodeCall.sendControlFrame(e)}catch{}};sendPacketOrQueue=async(e,t,s)=>{this.isReadyToSendData(t)&&(t==="audio"?await this.nodeCall.sendAudioFrame(e):t==="video"&&(s==="video-key"?await this.nodeCall.beginWithGop(e):s==="video-delta"&&await this.nodeCall.sendFrame(e)))}};var Zs={VPS_NUT:32,SPS_NUT:33,PPS_NUT:34,PREFIX_SEI_NUT:39,SUFFIX_SEI_NUT:40,fromValue(n){return{32:"VPS_NUT",33:"SPS_NUT",34:"PPS_NUT",39:"PREFIX_SEI_NUT",40:"SUFFIX_SEI_NUT"}[n]||n}},Mi=class n{generalProfileSpace=0;generalTierFlag=!1;generalProfileIdc=0;generalProfileCompatibilityFlags=0;generalConstraintIndicatorFlags=0;generalLevelIdc=0;minSpatialSegmentationIdc=0;parallelismType=0;chromaFormatIdc=0;bitDepthLumaMinus8=0;bitDepthChromaMinus8=0;avgFrameRate=0;constantFrameRate=0;numTemporalLayers=0;temporalIdNested=!1;lengthSizeMinusOne=0;arrays=[];constructor(e){Object.assign(this,e)}static demux(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),s=new DataView(t.buffer,t.byteOffset,t.byteLength),r=0,i=0,a=W=>{let X=0;for(let M=0;M<W;M++){if(r>=t.length)throw new Error("End of buffer");let A=t[r]>>7-i&1;X=X<<1|A,i++,i===8&&(i=0,r++)}return X},o=()=>{if(i!==0)return a(8);if(r>=t.length)throw new Error("End of buffer");return t[r++]},c=()=>{if(i!==0)return a(16);let W=s.getUint16(r,!1);return r+=2,W},l=()=>{if(i!==0)return a(32);let W=s.getUint32(r,!1);return r+=4,W},p=()=>{let W=c(),X=l();return W*4294967296+X},d=W=>{if(i!==0){let M=new Uint8Array(W);for(let A=0;A<W;A++)M[A]=a(8);return M}if(r+W>t.length)throw new Error("End of buffer");let X=t.slice(r,r+W);return r+=W,X};if(o()!==1)throw new Error("Invalid configuration version");let h=a(2),m=a(1)===1,g=a(5),_=l(),v=p(),y=o();a(4);let x=a(12);a(6);let C=a(2);a(6);let S=a(2);a(5);let P=a(3);a(5);let E=a(3),k=c(),G=a(2),Q=a(3),ce=a(1)===1,q=a(2);if(q===2)throw new Error("length_size_minus_one must be 0, 1, or 3");let _e=o(),F=[];for(let W=0;W<_e;W++){let X=a(1)===1;a(1);let M=a(6),A=Zs.fromValue(M);M!==Zs.VPS_NUT&&M!==Zs.SPS_NUT&&M!==Zs.PPS_NUT&&M!==Zs.PREFIX_SEI_NUT&&Zs.SUFFIX_SEI_NUT;let z=c(),re=[];for(let ie=0;ie<z;ie++){let Re=c(),dt=d(Re);re.push(dt)}F.push({arrayCompleteness:X,nalUnitType:A,nalus:re})}return new n({generalProfileSpace:h,generalTierFlag:m,generalProfileIdc:g,generalProfileCompatibilityFlags:_,generalConstraintIndicatorFlags:v,generalLevelIdc:y,minSpatialSegmentationIdc:x,parallelismType:C,chromaFormatIdc:S,bitDepthLumaMinus8:P,bitDepthChromaMinus8:E,avgFrameRate:k,constantFrameRate:G,numTemporalLayers:Q,temporalIdNested:ce,lengthSizeMinusOne:q,arrays:F})}toCodecString(){let t={0:"",1:"A",2:"B",3:"C"}[this.generalProfileSpace];if(t===void 0)throw new Error("Unknown profile space");let s=`${t}${this.generalProfileIdc}`,r=this.generalProfileCompatibilityFlags.toString(16).padStart(8,"0").split("").reverse().join(""),i="";for(let d=0;d<r.length;d++){let u=r[d];(u!=="0"||d===0)&&(i+=u)}let o=`${this.generalTierFlag?"H":"L"}${this.generalLevelIdc}`,c="",l=this.generalConstraintIndicatorFlags,p=[Math.floor(l/1099511627776)&255,Math.floor(l/4294967296)&255,Math.floor(l/16777216)&255,Math.floor(l/65536)&255,Math.floor(l/256)&255,l&255];for(let d=2;d<6;d++)p[d]!==0&&(c+=`.${p[d].toString(16).padStart(2,"0")}`);return`hev1.${s}.${i}.${o}${c}`}};var iw=.5,fc=.05,Ii=class{videoDecoder=null;audioDecoder=null;videoWriter=null;audioContext=null;mediaDestination=null;scheduledAudioNodes=[];isWaitingForKeyFrame=!0;nextStartTime=0;lastVideoConfig=null;lastVideoConfigStr="";lastAudioConfigStr="";nodeCall;events;generatedStream=null;constructor(e,t={}){this.nodeCall=e,this.events=t}async acceptConnection(){try{await this.nodeCall.acceptConnection()}catch(e){b("error","\u274C Error starting MediaStreamReceiver:",e)}}getRemoteStream=()=>this.generatedStream;stop=()=>{this.resetDecoders()};initAudioContext=async()=>{if(!this.audioContext||this.audioContext.state==="closed"){let e=window.AudioContext||window.webkitAudioContext;this.audioContext=new e({sampleRate:48e3,latencyHint:"interactive"}),this.mediaDestination=this.audioContext.createMediaStreamDestination(),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.nextStartTime=this.audioContext.currentTime+fc}};initDecoders=e=>{if(this.audioDecoder&&this.audioDecoder.close(),this.initAudioContext(),this.mediaDestination){let t=this.mediaDestination.stream.getAudioTracks()[0];this.generatedStream=new MediaStream([t])}this.isWaitingForKeyFrame=!0,this.audioDecoder=new AudioDecoder({output:t=>this.playDecodedAudio(t),error:t=>b("error","AudioDecoder error:",t)}),e==="video"&&this.setupVideoDecoder(),this.receiveLoop()};setupVideoDecoder=()=>{if(!this.videoWriter)return;if(this.videoDecoder)try{this.videoDecoder.state!=="closed"&&this.videoDecoder.close()}catch{}let e=new VideoDecoder({output:async t=>{try{if(!this.videoWriter){t.close();return}if(this.videoWriter.desiredSize<=0){t.close();return}await this.videoWriter.write(t)}catch{t.close()}finally{t.close()}},error:t=>{b("error","\u274C VideoDecoder CRASHED:",t),this.isWaitingForKeyFrame=!0,this.videoWriter&&(b("info","\u267B\uFE0F Scheduled VideoDecoder respawn in 1000ms..."),setTimeout(()=>{if(this.videoWriter&&(this.setupVideoDecoder(),this.lastVideoConfig&&this.videoDecoder))try{this.videoDecoder.configure(this.lastVideoConfig)}catch{}},1e3))}});this.videoDecoder=e};playDecodedAudio=e=>{try{if(!this.audioContext||!this.mediaDestination){e.close();return}let{numberOfChannels:t,numberOfFrames:s,sampleRate:r}=e,i=s/r,a=this.audioContext.currentTime;this.nextStartTime<a?this.nextStartTime=a+fc:this.nextStartTime>a+iw&&(this.nextStartTime=a+fc,this.scheduledAudioNodes.forEach(l=>{try{l.stop()}catch{}}),this.scheduledAudioNodes=[]);let o=this.audioContext.createBuffer(t,s,r);for(let l=0;l<t;l++){let p=new Float32Array(s);e.copyTo(p,{planeIndex:l,format:"f32-planar"}),o.copyToChannel(p,l)}let c=this.audioContext.createBufferSource();if(c.buffer=o,c.connect(this.mediaDestination),this.scheduledAudioNodes.push(c),this.scheduledAudioNodes.length>100){let l=this.scheduledAudioNodes.shift();try{l?.stop(),l?.disconnect()}catch{}}c.onended=()=>{this.scheduledAudioNodes=this.scheduledAudioNodes.filter(l=>l!==c)},c.start(this.nextStartTime),this.nextStartTime+=i,e.close()}catch(t){b("error","Error in playDecodedAudio:",t),e?.close()}};newCodecFromDescription=(e,t)=>{if(!t.toLowerCase().includes("hvc")&&!t.toLowerCase().includes("hev"))return"";try{return Mi.demux(e).toCodecString()}catch{return""}};receiveLoop=async()=>{let e=new TextDecoder,t=Date.now();for(;;){Date.now()-t>16&&(await new Promise(s=>setTimeout(s,0)),t=Date.now());try{if(!this.nodeCall)break;let s=await this.nodeCall.asyncRecv(),r=new DataView(s.buffer,s.byteOffset,s.byteLength),i=r.getUint8(0),a=[0,1,6,7,5,8,9,10,11].includes(i)?1:9,o=new Uint8Array(s.buffer,s.byteOffset+a,s.byteLength-a);switch(i){case 0:{try{let l=e.decode(o);if(this.lastVideoConfigStr===l&&this.videoDecoder?.state==="configured")break;this.lastVideoConfigStr=l;let p=JSON.parse(l);if(b("info","videoConfig",p),!this.videoWriter){let m=new MediaStreamTrackGenerator({kind:"video"});this.videoWriter=m.writable.getWriter(),this.generatedStream&&this.generatedStream.addTrack(m)}this.videoDecoder||this.setupVideoDecoder(),this.isWaitingForKeyFrame=!0;let d;if(p.description)try{let m=atob(p.description),g=new Uint8Array(m.length);for(let _=0;_<m.length;_++)g[_]=m.charCodeAt(_);d=g.buffer}catch{}let u="";d&&(u=this.newCodecFromDescription(d,p.codec)||Tu(p.codec));let h={codec:u,frameRate:p.frameRate,codedWidth:p.codedWidth,codedHeight:p.codedHeight,...p.orientation&&{rotation:p.orientation},...d&&{description:d}};this.lastVideoConfig=h,this.videoDecoder&&this.videoDecoder.state!=="closed"&&((await VideoDecoder.isConfigSupported(h)).supported?(this.videoDecoder.configure(h),this.isWaitingForKeyFrame=!0):b("error","\u274C Browser does not support this video config:",h))}catch(l){b("error","\u274C Error processing VIDEO_CONFIG:",l)}break}case 1:{try{let l=e.decode(o);if(this.lastAudioConfigStr===l&&this.audioDecoder?.state==="configured")break;this.lastAudioConfigStr=l;let p=JSON.parse(l);b("info","audioConfig",p),this.audioDecoder?.state!=="closed"&&this.audioDecoder?.configure({codec:p.codec,sampleRate:p.sampleRate,numberOfChannels:p.numberOfChannels})}catch(l){b("error","\u274C Error processing AUDIO_CONFIG:",l)}break}case 2:case 3:{if(!this.videoDecoder||this.videoDecoder.state!=="configured")break;let l=i===2;if(this.isWaitingForKeyFrame){if(!l)break;this.isWaitingForKeyFrame=!1}if(!l&&this.videoDecoder.decodeQueueSize>5){this.isWaitingForKeyFrame=!0;break}let p=r.getBigUint64(1,!1),d=Number(p);try{this.videoDecoder.decode(new EncodedVideoChunk({type:l?"key":"delta",timestamp:d,data:o}))}catch(u){b("error","Video decode failed:",u),this.videoDecoder.state==="closed"&&(this.isWaitingForKeyFrame=!0)}break}case 4:{if(this.audioDecoder?.state==="configured"){let l=r.getBigUint64(1,!1),p=Number(l);this.audioDecoder.decode(new EncodedAudioChunk({type:"key",timestamp:p,data:o}))}break}case 6:this.events.onConnected&&this.events.onConnected();break;case 7:let c=JSON.parse(e.decode(o));this.events.onTransceiverState&&this.events.onTransceiverState(c);break;case 5:{let l=r.getInt32(1,!1);if(this.videoDecoder&&this.lastVideoConfig&&this.lastVideoConfig.rotation!==l){this.lastVideoConfig.rotation=l;try{this.videoDecoder.configure(this.lastVideoConfig),this.isWaitingForKeyFrame=!0,b("info","\u{1F504} Reconfigured rotation to",l,"- Waiting for next KeyFrame")}catch(p){b("error","Error reconfiguring VideoDecoder with new orientation:",p)}}break}case 8:b("info","\u{1F4E5} Received REQUEST_CONFIG"),this.events.onRequestConfig&&this.events.onRequestConfig();break;case 9:b("info","\u{1F4E5} Received REQUEST_KEY_FRAME"),this.events.onRequestKeyFrame&&this.events.onRequestKeyFrame();break;case 10:b("info","\u{1F4E5} Received END_CALL"),this.events.onEndCall&&this.events.onEndCall();break;case 11:break;default:break}}catch{await new Promise(r=>setTimeout(r,200))}}};resetDecoders=()=>{if(this.videoWriter){try{this.videoWriter.abort("Stream stopped").catch(()=>{}),this.videoWriter.releaseLock()}catch(e){b("warn","Error closing video writer:",e)}this.videoWriter=null}if(this.videoDecoder){try{this.videoDecoder.state!=="closed"&&(this.videoDecoder.reset(),this.videoDecoder.close())}catch{}this.videoDecoder=null}if(this.audioDecoder){try{this.audioDecoder.state!=="closed"&&(this.audioDecoder.reset(),this.audioDecoder.close())}catch{}this.audioDecoder=null}if(this.audioContext){try{this.audioContext.close()}catch(e){b("warn","Error closing audio context:",e)}this.audioContext=null}this.scheduledAudioNodes.forEach(e=>{try{e.stop()}catch{}}),this.scheduledAudioNodes=[],this.isWaitingForKeyFrame=!0,this.mediaDestination=null,this.nextStartTime=0,this.lastVideoConfig=null,this.generatedStream&&(this.generatedStream.getTracks().forEach(e=>e.stop()),this.generatedStream=null)}};var gc=class{wasmPath;workerPath;relayUrl="https://test-iroh.ermis.network.:8443";_client;sessionID;cid;callType;get userID(){return this._client?.userID}callStatus="";metadata;callNode=null;localStream=null;remoteStream=null;callerInfo;receiverInfo;onCallEvent;onLocalStream;onRemoteStream;onConnectionMessageChange;onCallStatus;onDataChannelMessage;onUpgradeCall;onScreenShareChange;onError;onDeviceChange;availableAudioDevices=[];availableVideoDevices=[];selectedAudioDeviceId;selectedVideoDeviceId;missCallTimeout=null;healthCallInterval=null;healthCallServerInterval=null;healthCallTimeout=null;healthCallWarningTimeout=null;signalHandler;connectionChangedHandler;messageUpdatedHandler;isOffline=!1;isDestroyed=!1;mediaSender=null;mediaReceiver=null;constructor(e,t,s,r,i){this._client=e,this.cid="",this.callType="",this.sessionID=t,this.metadata={},this.wasmPath=s,this.relayUrl=r,this.workerPath=i||"/wasm_worker.worker.mjs",this.listenSocketEvents(),this.setupDeviceChangeListener(),this.loadWasm()}async loadWasm(){try{this.callNode=new ki(new URL(this.workerPath,window.location.origin)),await this.callNode.init(this.wasmPath)}catch(e){throw b("error","Failed to load ErmisCall WASM Worker:",e),e}}async initialize(){try{this.callNode||await this.loadWasm();let e=this.callNode;return await e.spawn([this.relayUrl]),this.mediaSender=new Pi(e),this.mediaReceiver=new Ii(e,{onConnected:()=>{this.setCallStatus("connected"),this.connectCall(),this.missCallTimeout&&(clearTimeout(this.missCallTimeout),this.missCallTimeout=null),this.healthCallServerInterval&&clearInterval(this.healthCallServerInterval),this.healthCallServerInterval=setInterval(()=>{this.healthCall()},1e4);let t=this.mediaReceiver?.getRemoteStream();t&&this.onRemoteStream&&this.onRemoteStream(t)},onTransceiverState:t=>{typeof this.onDataChannelMessage=="function"&&this.onDataChannelMessage(t)},onRequestConfig:()=>{b("info","\u{1F4E4} Responding to REQUEST_CONFIG by sending configs"),this.mediaSender?.sendConfigs()},onRequestKeyFrame:()=>{b("info","\u{1F4E4} Responding to REQUEST_KEY_FRAME by forcing key frame"),this.mediaSender?.requestKeyFrame()},onEndCall:()=>{b("info","\u{1F4E5} Received END_CALL from remote peer"),this.destroy()}}),await e.startRecvLoop(),e}catch(e){throw b("error","Failed to initialize Ermis SDK:",e),e}}async getLocalEndpointAddr(){try{if(await this.initialize(),!this.callNode)return b("error","ErmisCall is not initialized."),null;let e=await this.callNode.getLocalEndpointAddr();return this.metadata&&(this.metadata.address=e),e}catch(e){return b("error","Failed to get address from ErmisCall:",e),null}}getClient(){return this._client}async _sendSignal(e){if(this.cid||e.cid)try{return await this.getClient().post(this.getClient().baseURL+"/signal",{...e,cid:this.cid||e.cid,is_video:this.callType==="video"||e.is_video,ios:!1,session_id:this.sessionID})}catch(s){let r=e.action;if(r==="health-call")return;if(typeof this.onError=="function")if(s.code==="ERR_NETWORK")r==="create-call"&&this.onError("call_network_error");else if(s.response.data.ermis_code===20)this.onError("call_recipient_busy");else{let i=s.response.data?.message?s.response.data?.message:"call_failed";this.onError(i)}}}async getAvailableDevices(){try{let e=await navigator.mediaDevices.enumerateDevices(),t=e.filter(r=>r.kind==="audioinput"),s=e.filter(r=>r.kind==="videoinput");return this.availableAudioDevices=t,this.availableVideoDevices=s,{audioDevices:t,videoDevices:s}}catch(e){return b("error","Error enumerating devices:",e),{audioDevices:[],videoDevices:[]}}}async getMediaConstraints(){let{audioDevices:e,videoDevices:t}=await this.getAvailableDevices();this.onDeviceChange&&this.onDeviceChange(e,t),!this.selectedAudioDeviceId&&e.length>0&&(this.selectedAudioDeviceId=e[0].deviceId),!this.selectedVideoDeviceId&&t.length>0&&(this.selectedVideoDeviceId=t[0].deviceId);let s={deviceId:this.selectedAudioDeviceId?{exact:this.selectedAudioDeviceId}:void 0,echoCancellation:!0,noiseSuppression:!0,sampleRate:48e3},r=this.callType==="video"?{deviceId:this.selectedVideoDeviceId?{exact:this.selectedVideoDeviceId}:void 0,width:640,height:360}:!1;return{audio:s,video:r}}async startLocalStream(){let e=await this.getMediaConstraints();try{let t=await navigator.mediaDevices.getUserMedia(e);return this.applyLocalStream(t)}catch(t){if(b("warn","Error getting user media:",t?.message),this.callType==="video"&&e.video)try{let s=await navigator.mediaDevices.getUserMedia({audio:e.audio,video:!1});return this.setConnectionMessage("Camera not available, using audio only"),this.applyLocalStream(s)}catch{}return typeof this.onError=="function"&&this.onError("call_no_devices"),null}}applyLocalStream(e){if(this.callStatus==="ended"){e.getTracks().forEach(t=>t.stop()),this.destroy();return}return this.onLocalStream&&this.onLocalStream(e),this.localStream=e,e}setConnectionMessage(e){typeof this.onConnectionMessageChange=="function"&&this.onConnectionMessageChange(e)}setCallStatus(e){this.callStatus=e,typeof this.onCallStatus=="function"&&this.onCallStatus(e)}setUserInfo(e,t){if(!e||!t)return;let s=e?this.getClient().activeChannels[e]:void 0,r=s?.state?.members||{},i=Object.keys(r),a=t||"",o=i.find(u=>u!==a)||"",c=s?.data?.members||[],l=u=>c.find(m=>m.user_id===u||m.user?.id===u)?.user,p=l(a)||r[a]?.user||this.getClient().state.users[a],d=l(o)||r[o]?.user||this.getClient().state.users[o];this.callerInfo={id:a,name:p?.name||a,avatar:p?.avatar||""},this.receiverInfo={id:o,name:d?.name||o,avatar:d?.avatar||""}}listenSocketEvents(){this.signalHandler=async e=>{let{action:t,user_id:s,session_id:r,cid:i,is_video:a,signal:o,metadata:c}=e;switch(t){case"create-call":if(s===this.userID&&r!==this.sessionID){this.isDestroyed=!0,this.destroy();return}if(this.isDestroyed=!1,this.callStatus="",this.callType=a?"video":"audio",this.setUserInfo(i,s),this.cid=i||"",this.metadata=c||{},typeof this.onCallEvent=="function"&&this.onCallEvent({type:s!==this.userID?"incoming":"outgoing",callType:a?"video":"audio",cid:i||"",callerInfo:this.callerInfo,receiverInfo:this.receiverInfo,metadata:this.metadata}),this.setCallStatus("ringing"),await this.startLocalStream(),this.callStatus==="ended")return;s!==this.userID&&await this.initialize(),s===this.userID&&(this.missCallTimeout&&clearTimeout(this.missCallTimeout),this.missCallTimeout=setTimeout(async()=>{await this.missCall()},6e4));break;case"accept-call":if(s===this.userID&&r!==this.sessionID){this.isDestroyed=!0,this.destroy();return}s!==this.userID&&!this.isDestroyed&&(this.mediaReceiver&&this.mediaSender&&(await this.mediaReceiver.acceptConnection(),await this.mediaSender.sendConnected()),this.localStream&&this.mediaSender&&this.mediaReceiver&&this.callType&&(this.mediaSender?.initEncoders(this.localStream),this.mediaReceiver?.initDecoders(this.callType)),this.mediaSender&&await this.mediaSender.sendConfigs());break;case"end-call":case"reject-call":case"miss-call":await this.destroy();break}},this.connectionChangedHandler=e=>{let t=e.online;this.isOffline=!t,t?(this.setConnectionMessage(null),this.callStatus==="connected"&&(this.healthCallServerInterval||(this.healthCallServerInterval=setInterval(()=>{this.healthCall()},1e4)))):(this.setConnectionMessage("Your network connection is unstable"),this.healthCallInterval&&(clearInterval(this.healthCallInterval),this.healthCallInterval=null),this.healthCallServerInterval&&(clearInterval(this.healthCallServerInterval),this.healthCallServerInterval=null))},this.messageUpdatedHandler=e=>{if(this.callStatus==="connected"&&e.cid===this.cid){let t=e.user?.id,s;t===this.callerInfo?.id?s=this.callerInfo:t===this.receiverInfo?.id&&(s=this.receiverInfo),s&&typeof this.onUpgradeCall=="function"&&this.onUpgradeCall(s)}},this._client.on("signal",this.signalHandler),this._client.on("connection.changed",this.connectionChangedHandler),this._client.on("message.updated",this.messageUpdatedHandler)}async cleanupCall(){if(this.mediaSender&&(this.mediaSender?.stop(),this.mediaSender=null),this.mediaReceiver&&(this.mediaReceiver.stop(),this.mediaReceiver=null),this.callNode){try{await Promise.race([this.callNode.terminate(),new Promise(e=>setTimeout(e,1e3))])}catch{}this.callNode=null}this.missCallTimeout&&(clearTimeout(this.missCallTimeout),this.missCallTimeout=null),this.healthCallInterval&&(clearInterval(this.healthCallInterval),this.healthCallInterval=null),this.healthCallServerInterval&&(clearInterval(this.healthCallServerInterval),this.healthCallServerInterval=null),this.healthCallTimeout&&(clearTimeout(this.healthCallTimeout),this.healthCallTimeout=null),this.healthCallWarningTimeout&&(clearTimeout(this.healthCallWarningTimeout),this.healthCallWarningTimeout=null),this.setConnectionMessage(null),this.cid="",this.callType="",this.metadata={},this.localStream&&(this.localStream.getTracks().forEach(e=>e.stop()),this.localStream=null),this.remoteStream&&(this.remoteStream.getTracks().forEach(e=>e.stop()),this.remoteStream=null),this.setCallStatus("ended")}async destroy(){await this.cleanupCall()}async getDevices(){return this.availableAudioDevices.length>0||this.availableVideoDevices.length>0?{audioDevices:this.availableAudioDevices,videoDevices:this.availableVideoDevices}:await this.getAvailableDevices()}getSelectedDevices(){let e=this.selectedAudioDeviceId?this.availableAudioDevices.find(s=>s.deviceId===this.selectedAudioDeviceId):void 0,t=this.selectedVideoDeviceId?this.availableVideoDevices.find(s=>s.deviceId===this.selectedVideoDeviceId):void 0;return{audioDevice:e,videoDevice:t}}getDefaultDevices(){return{audioDevice:this.availableAudioDevices[0],videoDevice:this.availableVideoDevices[0]}}prefillUserInfo(e){this.setUserInfo(e,this.userID)}async createCall(e,t){try{this.cid=t,this.callType=e,this.prefillUserInfo(t);let s=await this.getLocalEndpointAddr();await this._sendSignal({action:"create-call",cid:t,is_video:e==="video",metadata:{address:s}})}catch(s){throw b("error","Failed to create call:",s),s}}async acceptCall(){try{if(await this._sendSignal({action:"accept-call"}),this.mediaSender){let e=this.metadata?.address||"";await this.mediaSender.connect(e)}this.localStream&&this.mediaSender&&this.mediaReceiver&&(this.mediaSender?.initEncoders(this.localStream),this.mediaReceiver?.initDecoders(this.callType||"audio")),this.mediaSender&&await this.mediaSender.sendConfigs()}catch(e){throw b("error","Failed to accept call:",e),e}}async endCall(){await this._sendSignal({action:"end-call"}),this.destroy()}async rejectCall(){await this._sendSignal({action:"reject-call"}),this.destroy()}async missCall(){await this._sendSignal({action:"miss-call"}),this.destroy()}async connectCall(){return await this._sendSignal({action:"connect-call"})}async healthCall(){return await this._sendSignal({action:"health-call"})}async addVideoTrackToLocalStream(){let e=await this.getMediaConstraints(),t=await navigator.mediaDevices.getUserMedia(e),s=t.getVideoTracks()[0];this.localStream?(this.localStream.addTrack(s),this.onLocalStream&&this.onLocalStream(this.localStream)):(this.localStream=t,this.onLocalStream&&this.onLocalStream(this.localStream))}async upgradeCall(){try{if(this.callType="video",await this.addVideoTrackToLocalStream(),await this._sendSignal({action:"upgrade-call"}),this.localStream){this.mediaSender?.initVideoEncoder(this.localStream?.getVideoTracks()[0]);let e=!!this.localStream?.getAudioTracks().some(s=>s.enabled),t=!!this.localStream?.getVideoTracks().some(s=>s.enabled);await this.mediaSender?.sendTransceiverState(e,t)}}catch(e){throw b("error","Failed to upgrade call:",e),e}}async requestUpgradeCall(e){if(e&&(this.callType="video",await this.addVideoTrackToLocalStream(),this.localStream)){this.mediaSender?.initVideoEncoder(this.localStream?.getVideoTracks()[0]);let t=!!this.localStream?.getAudioTracks().some(r=>r.enabled),s=!!this.localStream?.getVideoTracks().some(r=>r.enabled);await this.mediaSender?.sendTransceiverState(t,s)}}async startScreenShare(){if(!navigator.mediaDevices.getDisplayMedia)throw new Error("Screen sharing is not supported in this browser.");let e=await navigator.mediaDevices.getDisplayMedia({video:!0}),t=e.getVideoTracks()[0];this.localStream?(this.localStream.getVideoTracks().forEach(s=>s.stop()),this.localStream.removeTrack(this.localStream.getVideoTracks()[0]),this.localStream.addTrack(t)):this.localStream=e,t.onended=()=>{this.stopScreenShare()},this.onLocalStream&&(this.onLocalStream(this.localStream),this.mediaSender?.replaceVideoTrack(this.localStream.getVideoTracks()[0])),typeof this.onScreenShareChange=="function"&&this.onScreenShareChange(!0)}async stopScreenShare(){let e=await this.getMediaConstraints();try{let t=await navigator.mediaDevices.getUserMedia({video:e.video,audio:!1}),s=t.getVideoTracks()[0];this.localStream?(this.localStream.getVideoTracks().forEach(r=>{r.stop(),this.localStream?.removeTrack(r)}),this.localStream.addTrack(s)):this.localStream=t,this.onLocalStream&&(this.onLocalStream(this.localStream),this.mediaSender?.replaceVideoTrack(this.localStream.getVideoTracks()[0])),typeof this.onScreenShareChange=="function"&&this.onScreenShareChange(!1)}catch(t){b("error","Error stopping screen share and reverting to camera:",t)}}async toggleMic(e){if(this.localStream){this.localStream.getAudioTracks().forEach(r=>{r.enabled=e});let t=e,s=this.localStream.getVideoTracks().some(r=>r.enabled);await this.mediaSender?.sendTransceiverState(t,s)}}async toggleCamera(e){if(this.localStream){this.localStream.getVideoTracks().forEach(r=>{r.enabled=e});let t=this.localStream.getAudioTracks().some(r=>r.enabled),s=e;await this.mediaSender?.sendTransceiverState(t,s)}}async switchAudioDevice(e){try{if(!this.availableAudioDevices.find(o=>o.deviceId===e))return b("error","Audio device not found:",e),this.onError&&this.onError("Selected microphone not found"),!1;if(this.selectedAudioDeviceId=e,!this.localStream)return!1;let s=await this.getMediaConstraints(),i=(await navigator.mediaDevices.getUserMedia({audio:s.audio,video:!1})).getAudioTracks()[0],a=this.localStream.getAudioTracks()[0];return this.mediaSender&&i&&await this.mediaSender.replaceAudioTrack(i),a&&(this.localStream.removeTrack(a),a.stop()),this.localStream.addTrack(i),this.onLocalStream&&this.onLocalStream(this.localStream),!0}catch(t){return b("error","Error switching audio device:",t),this.onError&&this.onError("Failed to switch microphone"),!1}}async switchVideoDevice(e){try{if(!this.availableVideoDevices.find(o=>o.deviceId===e))return b("error","Video device not found:",e),this.onError&&this.onError("Selected camera not found"),!1;if(this.selectedVideoDeviceId=e,!this.localStream)return!1;let s=await this.getMediaConstraints(),i=(await navigator.mediaDevices.getUserMedia({audio:!1,video:s.video})).getVideoTracks()[0],a=this.localStream.getVideoTracks()[0];return this.mediaSender&&i&&await this.mediaSender.replaceVideoTrack(i),a&&(this.localStream.removeTrack(a),a.stop()),this.localStream.addTrack(i),this.onLocalStream&&this.onLocalStream(this.localStream),!0}catch(t){return b("error","Error switching video device:",t),this.onError&&this.onError("Failed to switch camera"),!1}}setupDeviceChangeListener(){navigator.mediaDevices.addEventListener("devicechange",async()=>{let{audioDevices:e,videoDevices:t}=await this.getAvailableDevices();this.onDeviceChange&&this.onDeviceChange(e,t)})}};jt();var _c=class{apiKey;baseURL;options;axiosInstance;disconnected;browser;node;logger;consecutiveFailures;userAgent;lastIdentifier;lastMethod;address;constructor(e,t,s){let r=s||{};this.apiKey=e,this.logger=ri(r.logger),$s(r.logger),this.logger("info","auth:constructor - userBaseURL configured",{userBaseURL:s?.userBaseURL}),this.baseURL=s?.userBaseURL||t+"/uss/v1",this.browser=typeof r.browser<"u"?r.browser:typeof window<"u",this.node=!this.browser,this.options={withCredentials:!1,warmUp:!1,recoverStateOnReconnect:!0,...r},this.node&&!this.options.httpsAgent&&(this.options.httpsAgent=new ns.Agent({keepAlive:!0,keepAliveMsecs:3e3})),this.axiosInstance=zs.create(this.options),this.consecutiveFailures=0,this.disconnected=!1}_logApiRequest(e,t,s,r){this.logger("info",`client: ${e} - Request - ${t}- ${JSON.stringify(s)} - ${JSON.stringify(r.params)}`,{tags:["api","api_request","client"],url:t,payload:s,config:r})}_logApiResponse(e,t,s){this.logger("info",`client:${e} - Response - url: ${t} > status ${s.status}`,{tags:["api","api_response","client"],url:t,response:s})}_logApiError(e,t,s,r){this.logger("error",`client:${e} - Error: ${JSON.stringify(s)} - url: ${t} - options: ${JSON.stringify(r)}`,{tags:["api","api_response","client"],url:t,error:s})}doAxiosRequest=async(e,t,s,r={})=>{let i=this._enrichAxiosOptions(r);try{let a;switch(this._logApiRequest(e,t,s,i),e){case"get":a=await this.axiosInstance.get(t,i);break;case"delete":a=await this.axiosInstance.delete(t,i);break;case"post":a=await this.axiosInstance.post(t,s,i);break;case"postForm":a=await this.axiosInstance.postForm(t,s,i);break;case"put":a=await this.axiosInstance.put(t,s,i);break;case"patch":a=await this.axiosInstance.patch(t,s,i);break;case"options":a=await this.axiosInstance.options(t,i);break;default:throw new Error("Invalid request type")}return this._logApiResponse(e,t,a),this.consecutiveFailures=0,this.handleResponse(a)}catch(a){if(a.client_request_id=i.headers?.["x-client-request-id"],this._logApiError(e,t,a,r),this.consecutiveFailures+=1,a.response)return a.response.data.code===wt.TOKEN_EXPIRED?(this.consecutiveFailures>1&&await Ws(oi(this.consecutiveFailures)),await this.doAxiosRequest(e,t,s,i)):this.handleResponse(a.response);throw a}};get(e,t){return this.doAxiosRequest("get",e,null,{params:t})}put(e,t){return this.doAxiosRequest("put",e,t)}post(e,t,s){return this.doAxiosRequest("post",e,t,{params:s})}patch(e,t){return this.doAxiosRequest("patch",e,t)}delete(e,t){return this.doAxiosRequest("delete",e,null,{params:t})}errorFromResponse(e){let t;return t=new ys(`ErmisChat error HTTP code: ${e.status}`),e.data&&e.data.code&&(t=new Error(`ErmisChat error code ${e.data.code}: ${e.data.message}`),t.code=e.data.code),t.response=e,t.status=e.status,t}handleResponse(e){let t=e.data;if(Si(e))throw this.errorFromResponse(e);return t}getUserAgent(){return this.userAgent||`ermis-chat-sdk-javascript-client-${this.node?"node":"browser"}-2.0.1`}setUserAgent(e){this.userAgent=e}_enrichAxiosOptions(e={params:{},headers:{},config:{}}){let t=null;e.headers?.["x-client-request-id"]||(e.headers={...e.headers,"x-client-request-id":Te()});let{params:s,headers:r,...i}=this.options?.axiosRequestConfig||{};return{params:{...e.params,...s||{}},headers:{"X-Stream-Client":this.getUserAgent(),...e.headers,...r||{}},...t?{signal:t}:{},...e.config,...i||{}}}async sendOtpToPhone(e,t){this.lastIdentifier=e,this.lastMethod=t;let s={apikey:this.apiKey,identifier:e,language:"Vi",method:t,otp_type:"Login"};return this.post(this.baseURL+"/auth/get_otp_new",s)}async sendOtpToEmail(e){this.lastIdentifier=e,this.lastMethod="Email";let t={apikey:this.apiKey,identifier:e,language:"Vi",method:"Email",otp_type:"Login"};return this.post(this.baseURL+"/auth/get_otp_new",t)}async verifyOtp(e){let t={identifier:this.lastIdentifier,method:this.lastMethod,apikey:this.apiKey,otp:e};return this.post(this.baseURL+"/auth/otp_login",t)}async loginWithGoogle(e){let t={token:e,apikey:this.apiKey};return this.post(this.baseURL+"/auth/google_login",t)}async getWalletChallenge(e){this.address=e;let t=await this.post(this.baseURL+"/auth/get_challenge",{address:e,apikey:this.apiKey});return JSON.parse(t.challenge)}createNonce(e){let t="",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=s.length;for(let i=0;i<e;i++)t+=s.charAt(Math.floor(Math.random()*r));return t}async verifyWalletSignature(e){let t={address:this.address,signature:e,nonce:this.createNonce(20),apikey:this.apiKey};return this.post(this.baseURL+"/auth/verify_signature",t)}};function ue(n,e){return ui(Be(n,e))}function nt(n,e){return Be(n,e)}function aw(n){return{...n,commit:ue(n.commit,"commit"),group_info:ue(n.group_info,"group_info")}}function ow(n){return{...n,...n.commit?{commit:ue(n.commit,"commit")}:{},welcome:ue(n.welcome,"welcome"),ratchet_tree:ue(n.ratchet_tree,"ratchet_tree"),group_info:ue(n.group_info,"group_info")}}function cw(n){return{...n,group_info:ue(n.group_info,"group_info")}}function lw(n){return{...n,commit:ue(n.commit,"commit"),...n.group_info?{group_info:ue(n.group_info,"group_info")}:{}}}function pw(n){return{...n,commit:ue(n.commit,"commit"),group_info:ue(n.group_info,"group_info")}}function dw(n){return{...n,message:{...n.message,mls_ciphertext:ue(n.message.mls_ciphertext,"mls_ciphertext")}}}function uw(n){return{...n,message:{...n.message,mls_ciphertext:ue(n.message.mls_ciphertext,"mls_ciphertext")}}}function hw(n){return{...n,encrypted_archive:{ciphertext:ue(n.encrypted_archive.ciphertext,"encrypted_archive.ciphertext"),nonce:ue(n.encrypted_archive.nonce,"encrypted_archive.nonce"),aead_aad:ue(n.encrypted_archive.aead_aad,"encrypted_archive.aead_aad")},snapshot:{...n.snapshot,snapshot_bytes:ue(n.snapshot.snapshot_bytes,"snapshot.snapshot_bytes")},wraps:n.wraps.map(e=>({...e,hpke_kem_output:ue(e.hpke_kem_output,"wrap.hpke_kem_output"),hpke_ciphertext:ue(e.hpke_ciphertext,"wrap.hpke_ciphertext"),hpke_info:ue(e.hpke_info,"wrap.hpke_info")}))}}function mw(n){return{...n,topics:n.topics.map(e=>({...e,commit:ue(e.commit,"topic.commit"),welcome:ue(e.welcome,"topic.welcome"),ratchet_tree:ue(e.ratchet_tree,"topic.ratchet_tree"),group_info:ue(e.group_info,"topic.group_info")}))}}function fw(n){return{...n,topics:n.topics.map(e=>({...e,commit:ue(e.commit,"topic.commit"),...e.group_info?{group_info:ue(e.group_info,"topic.group_info")}:{}}))}}function nm(n){return{...n,key_package:nt(n.key_package,"key_package")}}function em(n){return{...n,members:n.members.map(e=>({...e,key_packages:e.key_packages.map(nm)}))}}function tm(n){return{...n,encrypted_archive_bytes:nt(n.encrypted_archive_bytes,"encrypted_archive_bytes"),aead_nonce:nt(n.aead_nonce,"aead_nonce"),aead_aad:nt(n.aead_aad,"aead_aad")}}function sm(n){return{...n,hpke_kem_output:nt(n.hpke_kem_output,"hpke_kem_output"),hpke_ciphertext:nt(n.hpke_ciphertext,"hpke_ciphertext"),hpke_info:nt(n.hpke_info,"hpke_info")}}function yc(n){return{...n,snapshot_bytes:nt(n.snapshot_bytes,"snapshot_bytes")}}var en=class{client;constructor(e){this.client=e}get baseURL(){return this.client.baseURL}get deviceHeaders(){let e=this.client.deviceId;return{[di]:Vs,...e?{"X-Device-ID":e}:{}}}async _post(e,t,s){return await this.client.doAxiosRequest("post",e,t,{headers:{...this.deviceHeaders,...s||{}}})}async _get(e,t){return await this.client.doAxiosRequest("get",e,null,{params:t||{},headers:this.deviceHeaders})}async _delete(e){return await this.client.doAxiosRequest("delete",e,null,{headers:this.deviceHeaders})}async uploadKeyPackages(e){return await this._post(this.baseURL+"/v1/e2ee/key_packages",{key_packages:e.key_packages.map(t=>ue(t,"key_package"))})}async getKeyPackageCount(){return await this._get(this.baseURL+"/v1/e2ee/key_packages/count")}async getKeyPackages(e){let t=await this._get(this.baseURL+`/v1/e2ee/key_packages/${e}`);return{...t,key_packages:t.key_packages.map(nm)}}async getKeyPackagesByCid(e,t,s){let r=await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/key_packages`,{target_user_ids:s});return em(r)}async getKeyPackagesByUserIds(e,t){let s=await this._post(this.baseURL+"/v1/e2ee/key_packages/batch",{user_ids:e,...t&&t>1?{count_per_device:t}:{}});return em(s)}async uploadRecoveryVault(e){return await this._post(this.baseURL+"/v1/e2ee/recovery/vault",{vault_bytes:ue(e.vault_bytes,"vault_bytes"),...e.expected_revision!==void 0?{expected_revision:e.expected_revision}:{}})}async getRecoveryVault(){let e=await this._get(this.baseURL+"/v1/e2ee/recovery/vault");return{...e,vault_bytes:nt(e.vault_bytes,"vault_bytes")}}async getRecoveryPublicKey(e){let t=await this._get(this.baseURL+`/v1/e2ee/recovery/public_key/${e}`);return{...t,public_key:nt(t.public_key,"public_key")}}async uploadEpochArchive(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/epoch_archives`,hw(s))}async querySponsoredArchiveRecipients(e,t,s){let r=await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/epoch_archives/recipients/query`,{epoch:s});return{...r,recipients:r.recipients.map(i=>({...i,public_key:nt(i.public_key,"recipient.public_key")}))}}async queryEpochArchives(e,t,s){let r=await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/epoch_archives/query`,s);return{...r,blobs:r.blobs?.map(tm),wraps:r.wraps?.map(sm),snapshots:r.snapshots?Object.fromEntries(Object.entries(r.snapshots).map(([i,a])=>[i,yc(a)])):void 0}}async listArchiveAvailability(e,t,s={}){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/epoch_archives/availability/query`,s)}async queryArchiveMaterial(e,t,s){let r=await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/epoch_archives/material/query`,s);return{...r,blobs:r.blobs?.map(tm),wraps:r.wraps?.map(sm),snapshots:r.snapshots?Object.fromEntries(Object.entries(r.snapshots).map(([i,a])=>[i,yc(a)])):void 0}}async getArchiveSnapshot(e,t,s){let r=await this._get(this.baseURL+`/v1/e2ee/channels/${e}/${t}/epoch_archives/snapshot/${s}`);return yc(r)}async queryArchiveCiphertexts(e,t,s){let r=await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/epoch_archives/ciphertexts/query`,s);return{...r,ciphertexts:r.ciphertexts.map(i=>({...i,mls_ciphertext:nt(i.mls_ciphertext,"mls_ciphertext")}))}}async enableE2ee(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/enable`,ow(s))}async keyRotation(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/key_rotation`,aw(s))}async sendMessage(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/message`,dw(s))}async initAttachment(e,t,s,r={}){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/attachments/init`,s,r.multipart?{"X-Ermis-E2EE-Attachment-Upload":"multipart-v1"}:void 0)}async queryE2eeAttachments(e,t,s={}){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/attachments/query`,s)}async completeAttachment(e,t,s,r){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/attachments/${s}/complete`,r)}async downloadAttachmentGrant(e,t,s,r){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/attachments/${s}/assets/${r}/download-grant`,{})}async deleteAttachment(e,t,s){return await this._delete(this.baseURL+`/v1/e2ee/channels/${e}/${t}/attachments/${s}`)}async updateMessage(e,t,s,r){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/${s}`,uw(r))}async syncChannel(e,t,s,r=100){let i=await this._get(this.baseURL+`/v1/e2ee/channels/${e}/${t}/sync`,{since:s,limit:r});return i.events=i.events.map(Ao),i}async syncAll(e,t=100,s){let r={cursors:e,limit:t};s!==void 0&&(r.removed_cursor=s);let i=await this._post(this.baseURL+"/v1/e2ee/sync",r);for(let a of Object.values(i)){let o=a;o&&"events"in o&&Array.isArray(o.events)&&(o.events=o.events.map(Ao))}return i}async scopeSync(e,t=100,s){let r={cursors:e,limit:t};s!==void 0&&(r.removed_cursor=s);let i=await this._post(this.baseURL+"/v1/e2ee/scope_sync",r);return Bu(i)}async uploadGroupInfo(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/group_info`,cw(s))}async getGroupInfo(e,t){let s=await this._get(this.baseURL+`/v1/e2ee/channels/${e}/${t}/group_info`);return{...s,group_info:nt(s.group_info,"group_info")}}async externalJoin(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/external_join`,lw(s))}async batchAddMembersToTopics(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/topics/batch_add_members`,mw(s))}async batchExternalJoinTopics(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/topics/batch_external_join`,fw(s))}async commitEviction(e,t,s){return await this._post(this.baseURL+`/v1/e2ee/channels/${e}/${t}/commit_eviction`,pw(s))}};var gw="BBY_E2EE_MESSAGE_AAD";var _w=new TextEncoder;function rm(n,e){if(!Number.isInteger(e)||e<0||e>65535)throw new Error(`u16 value out of range: ${e}`);n.push(e>>>8&255,e&255)}function Ti(n,e){let t=_w.encode(e);rm(n,t.length);for(let s of t)n.push(s)}function vc(n,e){if(e==null||e===""){n.push(0);return}n.push(1),Ti(n,e)}function tn(n){let e=n.replace(/-/g,"").toLowerCase();if(!/^[0-9a-f]{32}$/.test(e))throw new Error(`Invalid UUID: ${n}`);let t=new Uint8Array(16);for(let s=0;s<16;s+=1)t[s]=Number.parseInt(e.slice(s*2,s*2+2),16);return t}function im(n,e){let t=tn(n),s=tn(e);for(let r=0;r<16;r+=1)if(t[r]!==s[r])return t[r]-s[r];return 0}function Xn(n){if(!n||n.length===0)return[];let e=new Set;return n.map(s=>{let i=[...tn(s)].map(a=>a.toString(16).padStart(2,"0")).join("");if(e.has(i))throw new Error(`Duplicate E2EE attachment id: ${s}`);return e.add(i),s}).sort(im)}function Ui(n){let e=[];Ti(e,gw),e.push(1),Ti(e,n.cid),Ti(e,n.e2ee_group_id);for(let s of tn(n.message_id))e.push(s);vc(e,n.forward_cid),vc(e,n.forward_message_id),vc(e,n.forward_parent_cid);let t=Xn(n.e2ee_attachment_ids);rm(e,t.length);for(let s of t)for(let r of tn(s))e.push(r);return new Uint8Array(e)}function Di(n){return!!(n.e2ee_attachment_ids&&n.e2ee_attachment_ids.length>0||n.forward_cid||n.forward_message_id||n.forward_parent_cid)}function bc(n,e){if(!n||!e||n.length!==e.length)return!1;let t=0;for(let s=0;s<n.length;s+=1)t|=n[s]^e[s];return t===0}function yw(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Li(n,...e){if(!yw(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${n.length}`)}function wc(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function am(n,e){Li(n);let t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Fi=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),_t=(n,e)=>n<<32-e|n>>>e;var RP=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var vw=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function om(n){Li(n);let e="";for(let t=0;t<n.length;t++)e+=vw[n[t]];return e}function bw(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function xc(n){return typeof n=="string"&&(n=bw(n)),Li(n),n}var Oi=class{clone(){return this._cloneInto()}},AP={}.toString;function cm(n){let e=s=>n().update(xc(s)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function ww(n,e,t,s){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,s);let r=BigInt(32),i=BigInt(4294967295),a=Number(t>>r&i),o=Number(t&i),c=s?4:0,l=s?0:4;n.setUint32(e+c,a,s),n.setUint32(e+l,o,s)}var lm=(n,e,t)=>n&e^~n&t,pm=(n,e,t)=>n&e^n&t^e&t,Bi=class extends Oi{constructor(e,t,s,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Fi(this.buffer)}update(e){wc(this);let{view:t,buffer:s,blockLen:r}=this;e=xc(e);let i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let c=Fi(e);for(;r<=i-a;a+=r)this.process(c,a);continue}s.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){wc(this),am(e,this),this.finished=!0;let{buffer:t,view:s,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>r-a&&(this.process(s,0),a=0);for(let d=a;d<r;d++)t[d]=0;ww(s,r-8,BigInt(this.length*8),i),this.process(s,0);let o=Fi(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,p=this.get();if(l>p.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)o.setUint32(4*d,p[d],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:s,length:r,finished:i,destroyed:a,pos:o}=this;return e.length=r,e.pos=o,e.finished=i,e.destroyed=a,r%t&&e.buffer.set(s),e}};var xw=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Jt=new Uint32Array(64),Ec=class extends Bi{constructor(){super(64,32,8,!1),this.A=Qt[0]|0,this.B=Qt[1]|0,this.C=Qt[2]|0,this.D=Qt[3]|0,this.E=Qt[4]|0,this.F=Qt[5]|0,this.G=Qt[6]|0,this.H=Qt[7]|0}get(){let{A:e,B:t,C:s,D:r,E:i,F:a,G:o,H:c}=this;return[e,t,s,r,i,a,o,c]}set(e,t,s,r,i,a,o,c){this.A=e|0,this.B=t|0,this.C=s|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=c|0}process(e,t){for(let d=0;d<16;d++,t+=4)Jt[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let u=Jt[d-15],h=Jt[d-2],m=_t(u,7)^_t(u,18)^u>>>3,g=_t(h,17)^_t(h,19)^h>>>10;Jt[d]=g+Jt[d-7]+m+Jt[d-16]|0}let{A:s,B:r,C:i,D:a,E:o,F:c,G:l,H:p}=this;for(let d=0;d<64;d++){let u=_t(o,6)^_t(o,11)^_t(o,25),h=p+u+lm(o,c,l)+xw[d]+Jt[d]|0,g=(_t(s,2)^_t(s,13)^_t(s,22))+pm(s,r,i)|0;p=l,l=c,c=o,o=a+h|0,a=i,i=r,r=s,s=h+g|0}s=s+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,c=c+this.F|0,l=l+this.G|0,p=p+this.H|0,this.set(s,r,i,a,o,c,l,p)}roundClean(){Jt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var dm=cm(()=>new Ec);function Ew(n){return n instanceof Uint8Array?n:new Uint8Array(n)}var sn=class{hasher=dm.create();finished=!1;update(e){if(this.finished)throw new Error("SHA-256 digest already finalized");return this.hasher.update(Ew(e)),this}digest(){if(this.finished)throw new Error("SHA-256 digest already finalized");return this.finished=!0,this.hasher.digest()}hex(){return om(this.digest())}};function Cw(n){return new sn().update(n).hex()}function ji(){let n=globalThis.crypto;if(!n?.subtle||!n.getRandomValues)throw new Error("Web Crypto API is required for the default E2EE attachment provider. React Native must inject attachmentCryptoProvider.");return n}function Zn(n){let e=new Uint8Array(n.length);return e.set(n),e.buffer}async function um(n){return await ji().subtle.importKey("raw",Zn(n),{name:"AES-GCM"},!1,["encrypt","decrypt"])}var hm={randomBytes(n){let e=new Uint8Array(n);return ji().getRandomValues(e),e},generateAesGcmKey(){return this.randomBytes(32)},async aesGcmEncrypt(n,e,t){let s=await um(n);return new Uint8Array(await ji().subtle.encrypt({name:"AES-GCM",iv:Zn(e)},s,Zn(t)))},async aesGcmDecrypt(n,e,t){let s=await um(n);return new Uint8Array(await ji().subtle.decrypt({name:"AES-GCM",iv:Zn(e)},s,Zn(t)))},createSha256(){return new sn}},Rt=hm;var ir=256*1024,_m=480,ym=.72,tr=5e3,Cc=3,vm=4,bm=12e4;function Sw(n){let e=n.type.toLowerCase(),t=(n.name||"").toLowerCase();return e.includes("heic")||e.includes("heif")||t.endsWith(".heic")||t.endsWith(".heif")}function Rw(){return typeof document<"u"&&typeof URL<"u"&&typeof Blob<"u"}function wm(n,e){if(n<=0||e<=0)return{width:1,height:1};let t=Math.min(1,_m/Math.max(n,e));return{width:Math.max(1,Math.round(n*t)),height:Math.max(1,Math.round(e*t))}}function xm(n){return new Promise((e,t)=>{n.toBlob(s=>{s?e(s):t(new Error("E2EE attachment preview canvas produced no blob"))},"image/jpeg",ym)})}function Gi(n,e,t){return new Promise((s,r)=>{let i=setTimeout(()=>{c(),r(new Error(`E2EE attachment preview timed out waiting for ${e}`))},t),a=()=>{c(),s()},o=()=>{c(),r(new Error(`E2EE attachment preview failed on ${e}`))},c=()=>{clearTimeout(i),n.removeEventListener(e,a),n.removeEventListener("error",o)};n.addEventListener(e,a,{once:!0}),n.addEventListener("error",o,{once:!0})})}async function Aw(n){let e=URL.createObjectURL(n);try{let t=new Image;t.decoding="async",t.src=e,await Gi(t,"load",tr);let s=t.naturalWidth,r=t.naturalHeight,i=wm(s,r),a=document.createElement("canvas");a.width=i.width,a.height=i.height;let o=a.getContext("2d");if(!o)throw new Error("E2EE attachment preview canvas context unavailable");return o.drawImage(t,0,0,i.width,i.height),{blob:await xm(a),originalWidth:s,originalHeight:r,previewWidth:i.width,previewHeight:i.height}}finally{URL.revokeObjectURL(e)}}async function kw(n){let e=URL.createObjectURL(n),t=document.createElement("video");try{if(t.preload="metadata",t.muted=!0,t.playsInline=!0,t.src=e,await Gi(t,"loadedmetadata",tr),!t.videoWidth||!t.videoHeight)throw new Error("E2EE attachment video preview has no video track");let s=Number.isFinite(t.duration)&&t.duration>0?t.duration:0,r=Math.min(1,Math.max(0,s*.1));r>0?(t.currentTime=r,await Gi(t,"seeked",tr)):await Gi(t,"loadeddata",tr).catch(()=>{});let i=t.videoWidth,a=t.videoHeight,o=wm(i,a),c=document.createElement("canvas");c.width=o.width,c.height=o.height;let l=c.getContext("2d");if(!l)throw new Error("E2EE attachment preview canvas context unavailable");return l.drawImage(t,0,0,o.width,o.height),{blob:await xm(c),originalWidth:i,originalHeight:a,previewWidth:o.width,previewHeight:o.height,duration:s||void 0}}finally{t.removeAttribute("src"),t.load(),URL.revokeObjectURL(e)}}async function Ac(n){if(!Rw()||Sw(n))return;let e=n.type.toLowerCase();try{if(e.startsWith("image/"))return await Aw(n);if(e.startsWith("video/"))return await kw(n)}catch{return}}function sr(n,e,t){n[e]=t>>>24&255,n[e+1]=t>>>16&255,n[e+2]=t>>>8&255,n[e+3]=t&255}function mm(n,e){return(n[e]<<24|n[e+1]<<16|n[e+2]<<8|n[e+3])>>>0}function kc(n,e){if(n.length!==8)throw new Error("E2EE attachment nonce prefix must be 8 bytes");let t=new Uint8Array(12);return t.set(n,0),sr(t,8,e),t}function nr(n){let e=new Uint8Array(n.length);return e.set(n),e.buffer}function Pw(n,e){let t=new Uint8Array(e),s=0;for(let r of n)t.set(r,s),s+=r.length;return t}function Mw(n){return new Promise(e=>setTimeout(e,n))}function Sc(n){let e=new Error(n);return e.name="AbortError",e}var Ni=class extends Error{nonRetryable=!0;code;constructor(e,t){super(e),this.name="NonRetryableMultipartUploadError",this.code=t}};function Iw(n){return!!n?.nonRetryable}var qi=class extends Error{status;constructor(e){super(`E2EE attachment upload failed: HTTP ${e}`),this.name="PresignedObjectUploadHttpError",this.status=e}};function Tw(n){return n?.status}function ar(n){return n===void 0||!Number.isFinite(n)||n<=0?Cc:Math.min(vm,Math.max(1,Math.floor(n)))}function Uw(n){if(!n)return;let e=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/.exec(n);if(!e)return;let[,t,s,r,i,a,o]=e,c=Date.UTC(Number(t),Number(s)-1,Number(r),Number(i),Number(a),Number(o));return Number.isFinite(c)?c:void 0}function Em(n){try{let e=new URL(n),t=Uw(e.searchParams.get("X-Amz-Date")),s=Number(e.searchParams.get("X-Amz-Expires"));return t===void 0||!Number.isFinite(s)||s<=0?void 0:t+s*1e3}catch{return}}function fm(n,e=Date.now(),t=bm){let s=Em(n);return s!==void 0&&e+t>=s}function Dw(){let n=globalThis;if(n.__ERMIS_E2EE_ATTACHMENT_UPLOAD_DEBUG__===!0)return!0;try{return n.localStorage?.getItem("ermis_e2ee_attachment_upload_debug")==="1"}catch{return!1}}function er(n,e){if(Dw())try{console.debug("[Ermis E2EE attachment upload]",n,e)}catch{}}function gm(n){return new Ni(`E2EE attachment multipart part ${n} upload URL expired or is too close to expiry (multipart_upload_url_expired). Retry the attachment upload to obtain fresh presigned part URLs.`,"multipart_upload_url_expired")}function Lw(n){let e=new AbortController;if(!n)return e;let t=()=>e.abort();return n.aborted?t():n.addEventListener("abort",t,{once:!0}),e}function nn(n,e){if(e)throw e;if(n.aborted)throw Sc("E2EE attachment multipart upload aborted")}function zi(n,e=ir){if(!Number.isFinite(n)||n<0)throw new Error("Invalid E2EE attachment plaintext size");if(!Number.isFinite(e)||e<=0)throw new Error("Invalid E2EE attachment frame size");let t=Math.max(1,Math.ceil(n/e));return n+t*24}function rr(n){let e=globalThis.Buffer;if(e)return e.from(n).toString("base64");let t="",s=32768;for(let r=0;r<n.length;r+=s)t+=String.fromCharCode(...n.subarray(r,r+s));return btoa(t)}function Rc(n){let e=globalThis.Buffer;if(e)return new Uint8Array(e.from(n,"base64"));let t=atob(n),s=new Uint8Array(t.length);for(let r=0;r<t.length;r+=1)s[r]=t.charCodeAt(r);return s}function rn(n=Rt){if(typeof globalThis.crypto?.randomUUID=="function")return globalThis.crypto.randomUUID();let e=n.randomBytes(16);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}async function $i(n,e){let t=e.cryptoProvider||Rt,s=e.frameSize||ir,r=await t.generateAesGcmKey(),i=t.randomBytes(8),a=t.createSha256(),o=t.createSha256(),c=[],l=0,p=0;for(;l<n.size||n.size===0&&p===0;){let u=n.size===0?0:Math.min(l+s,n.size),h=new Uint8Array(await n.slice(l,u).arrayBuffer());o.update(h);let m=await t.aesGcmEncrypt(r,kc(i,p),h),g=new Uint8Array(8);if(sr(g,0,h.length),sr(g,4,m.length),a.update(g).update(m),c.push(nr(g),nr(m)),l=u,p+=1,e.onProgress?.({phase:"encrypting",loaded:Math.min(l,n.size),total:n.size,percentage:n.size===0?100:Math.round(Math.min(l,n.size)/n.size*100)}),n.size===0)break}let d=new Blob(c,{type:"application/octet-stream"});return{kind:e.kind,encryptedBlob:d,cipher_size:d.size,cipher_sha256:a.hex(),frame_size:s,content_key:rr(r),nonce_prefix:rr(i),plaintext_size:n.size,plaintext_sha256:o.hex(),display:e.display}}async function Ow(n,e,t,s,r,i){let a=Math.max(0,s.max_part_retries||0),o=Math.max(1,s.retry_max_elapsed_secs||900)*1e3,c=Date.now(),l=0;if(fm(n))throw gm(e);for(;;){nn(i||new AbortController().signal);let p=l+1,d=Date.now(),u=0;r?.({partNumber:e,loaded:0,total:t.length,attempt:p}),er("part_start",{part_number:e,size_bytes:t.length,attempt:p});try{let h=await Ic(n,new Blob([nr(t)],{type:"application/octet-stream"}),g=>{u=Math.max(u,g.loaded),r?.({partNumber:e,loaded:Math.min(u,t.length),total:t.length,attempt:p})},{readEtag:!0,signal:i});if(!h.etag)throw new Ni(`E2EE attachment multipart part ${e} upload did not expose ETag. Configure R2 CORS ExposeHeaders to include ETag before enabling multipart.`,"multipart_missing_etag");let m=Math.max(1,Date.now()-d);return er("part_complete",{part_number:e,size_bytes:t.length,attempt:p,duration_ms:m,mbps:Number((t.length*8/m/1e3).toFixed(2)),retry_count:l}),h.etag}catch(h){let m=Tw(h);if((m===401||m===403)&&fm(n,Date.now(),0)){let v=gm(e);throw er("part_failed",{part_number:e,attempt:p,status:m,retry_count:l,reason:v.code}),v}if(Iw(h)||i?.aborted)throw h;let g=Date.now()-c;if(l>=a||g>=o)throw er("part_failed",{part_number:e,attempt:p,status:m,retry_count:l,reason:h instanceof Error?h.message:"unknown"}),h;l+=1,er("part_retry",{part_number:e,next_attempt:l+1,status:m,retry_count:l});let _=Math.min(3e4,500*2**Math.min(l,6));await Mw(_+Math.floor(Math.random()*250))}}}async function Pc(n,e){let t=e.cryptoProvider||Rt,s=e.frameSize||ir,r=e.multipart,i=ar(e.uploadConcurrency),a=r.part_size;if(!Number.isFinite(a)||a<=0)throw new Error("Invalid E2EE attachment multipart part size");let o=zi(n.size,s),c=Math.max(1,Math.ceil(o/a));if(r.part_count!==c)throw new Error("E2EE attachment multipart part count mismatch");let l=new Map;for(let M of r.parts||[])l.set(M.part_number,M.put_url);let p=await t.generateAesGcmKey(),d=t.randomBytes(8),u=t.createSha256(),h=t.createSha256(),m=Lw(e.signal),g=[],_=new Map,v=new Map,y,x=0,C=0,S=1,P=[],E=0,k=()=>{let M=0;for(let z of v.values())M+=z;let A=Math.min(o,Math.max(C,x,x+M));C=A,e.onProgress?.({phase:"uploading",loaded:A,total:o,percentage:o===0?100:Math.round(A/o*100)})},G=async M=>{throw y=y||M,m.signal.aborted||m.abort(),await Promise.all([..._.values()]),y},Q=async()=>{if(_.size===0)return;let M=await Promise.race(_.values());M.ok||await G(M.error)},ce=async()=>{for(;_.size>=i;)await Q();nn(m.signal,y)},q=async(M,A,z)=>{await ce(),v.set(M,0);let re=(async()=>{try{let ie=await Ow(A,M,z,r,Re=>{v.set(M,Math.min(z.length,Re.loaded)),k()},m.signal);return g.push({part_number:M,etag:ie}),x+=z.length,v.delete(M),k(),{ok:!0}}catch(ie){return v.delete(M),m.signal.aborted||m.abort(),y=y||ie,k(),{ok:!1,error:ie}}finally{_.delete(M)}})();_.set(M,re)},_e=async M=>{if(E===0)return;nn(m.signal,y);let A=S,z=l.get(A);if(!z)throw new Error(`E2EE attachment multipart missing upload URL for part ${A}`);if(!M&&E!==a)throw new Error("E2EE attachment multipart attempted to flush a short non-final part");let re=Pw(P,E);S+=1,P=[],E=0,await q(A,z,re)},F=async M=>{let A=0;for(;A<M.length;){nn(m.signal,y);let z=a-E,re=Math.min(z,M.length-A);P.push(M.slice(A,A+re)),E+=re,A+=re,E===a&&await _e(!1)}},W=0,X=0;for(;W<n.size||n.size===0&&X===0;){nn(m.signal,y);let M=n.size===0?0:Math.min(W+s,n.size),A=new Uint8Array(await n.slice(W,M).arrayBuffer());h.update(A);let z=await t.aesGcmEncrypt(p,kc(d,X),A),re=new Uint8Array(8);if(sr(re,0,A.length),sr(re,4,z.length),u.update(re).update(z),await F(re),await F(z),W=M,X+=1,nn(m.signal,y),n.size===0)break}for(await _e(!0);_.size>0;)await Q();if(y&&await G(y),g.sort((M,A)=>M.part_number-A.part_number),g.length!==r.part_count)throw new Error("E2EE attachment multipart uploaded part count mismatch");return{encrypted:{kind:e.kind,cipher_size:o,cipher_sha256:u.hex(),frame_size:s,content_key:rr(p),nonce_prefix:rr(d),plaintext_size:n.size,plaintext_sha256:h.hex(),display:e.display},parts:g}}async function Cm(n,e,t=Rt,s){let r=t.createSha256(),i=0;for(;i<n.size;){let o=Math.min(i+ir,n.size);r.update(new Uint8Array(await n.slice(i,o).arrayBuffer())),i=o,s?.({phase:"verifying",loaded:i,total:n.size,percentage:n.size===0?100:Math.round(i/n.size*100)})}if(n.size===0&&s?.({phase:"verifying",loaded:0,total:0,percentage:100}),r.hex()!==e.toLowerCase())throw new Error("E2EE attachment ciphertext hash mismatch")}async function Mc(n,e,t=Rt,s){await Cm(n,e.cipher_sha256,t,s);let r=Rc(e.content_key),i=Rc(e.nonce_prefix),a=[],o=0,c=0,l=0,p=typeof e.plaintext_size=="number"&&Number.isFinite(e.plaintext_size)?e.plaintext_size:n.size;for(;o<n.size;){let d=new Uint8Array(await n.slice(o,o+8).arrayBuffer());if(d.length!==8)throw new Error("Invalid E2EE attachment frame header");let u=mm(d,0),h=mm(d,4);o+=8;let m=new Uint8Array(await n.slice(o,o+h).arrayBuffer());if(m.length!==h)throw new Error("Invalid E2EE attachment frame body");let g=await t.aesGcmDecrypt(r,kc(i,c),m);if(g.length!==u)throw new Error("Invalid E2EE attachment plaintext frame length");a.push(nr(g)),o+=h,l+=g.length,c+=1,s?.({phase:"decrypting",loaded:l,total:p,percentage:p===0?100:Math.round(l/p*100)})}return new Blob(a)}function or(n,e){return{asset_id:n,kind:e.kind,cipher_size:e.cipher_size,cipher_sha256:e.cipher_sha256,frame_size:e.frame_size,content_key:e.content_key,nonce_prefix:e.nonce_prefix,plaintext_size:e.plaintext_size,plaintext_sha256:e.plaintext_sha256,display:e.display}}function Wi(n){return{version:1,attachment_id:n.attachment_id,assets:n.assets}}async function Ic(n,e,t,s={}){if(typeof XMLHttpRequest<"u")return await new Promise((i,a)=>{let o=new XMLHttpRequest,c=()=>{o.abort(),a(Sc("E2EE attachment upload aborted"))};if(s.signal?.aborted){c();return}s.signal?.addEventListener("abort",c,{once:!0}),o.open("PUT",n),o.setRequestHeader("Content-Type","application/octet-stream"),o.upload.onprogress=({loaded:l,total:p})=>{p>0&&t?.({phase:"uploading",loaded:l,total:p,percentage:Math.round(l/p*100)})},o.onload=()=>{s.signal?.removeEventListener("abort",c),o.status<300?i({etag:s.readEtag&&o.getResponseHeader("ETag")||void 0}):a(new qi(o.status))},o.onerror=()=>{s.signal?.removeEventListener("abort",c),a(new Error("E2EE attachment upload network error"))},o.onabort=()=>{s.signal?.removeEventListener("abort",c),a(Sc("E2EE attachment upload aborted"))},o.send(e)});let r=await fetch(n,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:e,signal:s.signal});if(!r.ok)throw new qi(r.status);return{etag:s.readEtag&&r.headers.get("ETag")||void 0}}async function Vi(n,e,t,s){await Ic(n,e,t,{signal:s})}async function Tc(n,e){if(typeof XMLHttpRequest<"u")return await new Promise((o,c)=>{let l=new XMLHttpRequest;l.open("GET",n),l.responseType="blob",l.onprogress=({loaded:p,total:d,lengthComputable:u})=>{e?.({phase:"downloading",loaded:p,total:u&&d>0?d:0,percentage:u&&d>0?Math.round(p/d*100):void 0})},l.onload=()=>{if(l.status<300){let p=l.response instanceof Blob?l.response:new Blob([l.response]);e?.({phase:"downloading",loaded:p.size,total:p.size,percentage:100}),o(p)}else c(new Error(`E2EE attachment download failed: HTTP ${l.status}`))},l.onerror=()=>c(new Error("E2EE attachment download network error")),l.send()});let t=await fetch(n);if(!t.ok)throw new Error(`E2EE attachment download failed: HTTP ${t.status}`);let s=Number(t.headers.get("content-length")||0);if(!t.body||typeof t.body.getReader!="function"){let o=await t.blob();return e?.({phase:"downloading",loaded:o.size,total:o.size,percentage:100}),o}let r=t.body.getReader(),i=[],a=0;for(;;){let{done:o,value:c}=await r.read();if(o)break;c&&(i.push(nr(c)),a+=c.byteLength,e?.({phase:"downloading",loaded:a,total:s,percentage:s>0?Math.round(a/s*100):void 0}))}return new Blob(i,{type:"application/octet-stream"})}function cr(n,e=Rt){return e.createSha256().update(n).hex()}var Fw="/e2ee-media-stream-worker.js?v=20260702-3";var Bw="/__ermis/e2ee-media/",jw="/__ermis/e2ee-media-smoke";var Ki=null,Hi=new Map,an=new Map,Sm=!1;function Rm(){return typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`stream-${Date.now()}-${Math.random().toString(16).slice(2)}`}function Am(n){if(n!==void 0)return n;let e=globalThis.__ERMIS_E2EE_MEDIA_STREAMING_ENABLED__;if(e===!0||e==="1")return!0;try{return globalThis.localStorage?.getItem("ermis_e2ee_media_streaming")==="1"}catch{return!1}}function Gw(n){if(n!==void 0)return n;let e=globalThis.__ERMIS_E2EE_MEDIA_MSE_ENABLED__;if(e===!0||e==="1")return!0;try{return globalThis.localStorage?.getItem("ermis_e2ee_media_mse")==="1"}catch{return!1}}function Nw(){let n=globalThis.__ERMIS_E2EE_MEDIA_PLAYBACK_DEBUG__;if(n===!0||n==="1")return!0;try{return globalThis.localStorage?.getItem("ermis_e2ee_media_streaming_debug")==="1"||globalThis.localStorage?.getItem("ermis_e2ee_media_playback_debug")==="1"}catch{return!1}}function rt(n,e){Nw()&&(e===void 0?console.info(`[E2EE media streaming] fallback: ${n}`):console.info(`[E2EE media streaming] fallback: ${n}`,e))}function km(n={}){return Am(n.streamingEnabled)&&Gw(n.mseEnabled)}function qw(n){if(/iPad|iPhone|iPod/i.test(n))return!0;let e=typeof globalThis<"u"&&"ontouchend"in globalThis;return/Macintosh/i.test(n)&&e}function zw(n={}){if(!km(n))return!1;let e=n.userAgent||(typeof navigator<"u"?navigator.userAgent:"");if(qw(e))return!1;let t=n.mediaSource||globalThis.MediaSource;return!t||typeof t.isTypeSupported!="function"?!1:n.codecMimeType?t.isTypeSupported(n.codecMimeType):!0}function $w(n=3e3){return navigator.serviceWorker.controller?Promise.resolve(!0):new Promise(e=>{let t=i=>{clearTimeout(r),navigator.serviceWorker.removeEventListener("controllerchange",s),e(i)},s=()=>t(!!navigator.serviceWorker.controller),r=setTimeout(()=>t(!!navigator.serviceWorker.controller),n);navigator.serviceWorker.addEventListener("controllerchange",s)})}function on(n,e=5e3){let t=navigator.serviceWorker.controller;if(!t)return Promise.reject(new Error("E2EE media stream worker is not controlling this page yet"));let s=Rm();return new Promise((r,i)=>{let a=setTimeout(()=>{Hi.delete(s),i(new Error("E2EE media stream worker request timed out"))},e);Hi.set(s,{resolve:r,reject:i,timeout:a}),t.postMessage({...n,requestId:s})})}function Ww(){Sm||typeof navigator>"u"||!navigator.serviceWorker||(Sm=!0,navigator.serviceWorker.addEventListener("message",n=>{let e=n.data||{};if(!(!e||typeof e!="object")){if(e.type==="ERMIS_E2EE_MEDIA_STREAM_ACK"){let t=Hi.get(e.requestId);if(!t)return;Hi.delete(e.requestId),clearTimeout(t.timeout),e.ok===!1?t.reject(new Error(e.error||"E2EE media stream worker request failed")):t.resolve(e.payload);return}if(e.type==="ERMIS_E2EE_MEDIA_STREAM_RENEW_GRANT"){Vw(String(e.sessionId||""),String(e.requestId||""));return}e.type==="ERMIS_E2EE_MEDIA_STREAM_ERROR"&&rt("worker virtual URL failed",{url:e.url,range:e.range,error:e.error})}}))}async function Vw(n,e){let t=an.get(n),s=navigator.serviceWorker.controller;if(!(!t||!s))try{let r=await t.renewGrant();s.postMessage({type:"ERMIS_E2EE_MEDIA_STREAM_GRANT_RENEWED",requestId:e,sessionId:n,grantUrl:r.download_url,expiresAtMs:Date.now()+t.grantTtlMs})}catch(r){s.postMessage({type:"ERMIS_E2EE_MEDIA_STREAM_GRANT_FAILED",requestId:e,sessionId:n,error:r instanceof Error?r.message:String(r)})}}async function Kw(n={}){if(!Am(n.enabled))return rt("feature flag is disabled"),null;if(typeof window>"u"||typeof navigator>"u"||!("serviceWorker"in navigator))return rt("Service Worker is unavailable"),null;if(typeof ReadableStream>"u"||!globalThis.crypto?.subtle)return rt("ReadableStream or WebCrypto is unavailable"),null;Ww();let e=n.workerUrl||Fw,t=n.scope||"/",s=await navigator.serviceWorker.register(e,{scope:t});if(await navigator.serviceWorker.ready,!navigator.serviceWorker.controller&&!await $w())return rt("Service Worker is registered but not controlling this page yet"),null;await on({type:"ERMIS_E2EE_MEDIA_STREAM_PING"},3e3);let r=await fetch(`${jw}?t=${Date.now()}`,{cache:"no-store"});return r.status!==204?(rt("virtual smoke route was not intercepted",{status:r.status}),null):s}async function Pm(n={}){Ki||(Ki=Kw(n).catch(s=>(rt("worker registration failed",s instanceof Error?s.message:String(s)),null)));let t=!!(await Ki&&navigator.serviceWorker.controller);return t||(Ki=null),t}function Hw(n,e){return n.assets.find(t=>t.kind===e)||(e==="original"?n.assets[0]:void 0)}function Qw(n,e){let t=n?.display?.[e];return typeof t=="string"&&t?t:void 0}async function Jw(n,e=5e3){let t=new AbortController,s=setTimeout(()=>t.abort(),e);try{let r=await fetch(n,{headers:{Range:"bytes=0-0"},cache:"no-store",signal:t.signal});return{ok:r.status===206,status:r.status}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}finally{clearTimeout(s),t.abort()}}async function Uc(n){let e=n.kind||"original";if(e!=="original")return rt("only original assets are streamable",{kind:e}),null;let t=Hw(n.manifest,e);if(!t)return rt("manifest has no original asset"),null;let s=n.mimeType||Qw(t,"mime_type")||"application/octet-stream";if(!s.toLowerCase().startsWith("video/"))return rt("asset is not a video",{mimeType:s}),null;if(!await Pm(n))return null;let i=n.grantTtlMs||3e5,a=n.safetyMarginMs||3e4,o=await n.renewGrant();if(n.rangeSmoke!==!1){let p=await Jw(o.download_url,n.rangeSmokeTimeoutMs);if(!p.ok)return rt("R2 range smoke failed",p),null}let c=Rm();an.set(c,{renewGrant:n.renewGrant,grantTtlMs:i,safetyMarginMs:a});let l=typeof t.plaintext_size=="number"?t.plaintext_size:void 0;if(l===void 0||l<0)return an.delete(c),rt("manifest is missing plaintext_size"),null;try{await on({type:"ERMIS_E2EE_MEDIA_STREAM_CREATE_SESSION",session:{sessionId:c,grantUrl:o.download_url,expiresAtMs:Date.now()+i,safetyMarginMs:a,mimeType:s,plaintextSize:l,cipherSize:t.cipher_size,frameSize:t.frame_size||256*1024,contentKey:t.content_key,noncePrefix:t.nonce_prefix,assetId:t.asset_id,attachmentId:n.manifest.attachment_id}}),await on({type:"ERMIS_E2EE_MEDIA_STREAM_TEST_SESSION",sessionId:c},n.rangeSmokeTimeoutMs||5e3)}catch(p){an.delete(c),rt("worker session test failed",p instanceof Error?p.message:String(p));try{await on({type:"ERMIS_E2EE_MEDIA_STREAM_DISPOSE_SESSION",sessionId:c},2e3)}catch{}return null}return{sessionId:c,url:`${Bw}${encodeURIComponent(c)}`,dispose:async()=>{await Mm(c)}}}async function Mm(n){if(an.delete(n),!(typeof navigator>"u"||!navigator.serviceWorker?.controller))try{await on({type:"ERMIS_E2EE_MEDIA_STREAM_DISPOSE_SESSION",sessionId:n},2e3)}catch{}}async function Yw(){if(an.clear(),!(typeof navigator>"u"||!navigator.serviceWorker?.controller))try{await on({type:"ERMIS_E2EE_MEDIA_STREAM_DISPOSE_ALL"},2e3)}catch{}}function vs(n){return(n?.message||n?.response?.data?.message||String(n)).includes("epoch_stale")}function Im(n){let e=n?.response?.data||n?.data||n,t=typeof e?.reason=="string"?e.reason:"",s=typeof e?.message=="string"?e.message:typeof n?.message=="string"?n.message:"";return t==="e2ee_attachment_invalid"||s.includes("e2ee_attachment_invalid")}function Xw(n){return new Promise(e=>setTimeout(e,n))}function je(n){return String(n?.response?.data?.message||n?.message||n||"")}function Zw(n){let e=n?.response?.data?.ermis_code??n?.response?.data?.code??n?.ermis_code??n?.code,t=Number(e);return Number.isFinite(t)?t:void 0}function Tm(n){let e=Number(n?.response?.status??n?.status);return!Number.isFinite(e)||e<=0?!0:e===408||e===429||e>=500}function ex(n){let e=n?.response?.status||n?.status,t=je(n).toLowerCase();return e===404||t.includes("recovery vault not found")}function Um(n){return je(n).match(/target_user_id\s+(\S+)\s+is still an active channel member/)?.[1]}function Dm(n){let e=n.match(/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d+))?Z$/);return e?`${e[1]}.${(e[2]||"").padEnd(9,"0").slice(0,9)}Z`:n}function Yt(n,e){if(!n&&!e)return 0;if(!n)return-1;if(!e)return 1;let t=Dm(n),s=Dm(e);return t===s?0:t>s?1:-1}var At="00000000-0000-0000-0000-000000000000";function lr(n,e){if(!n&&!e)return 0;if(!n)return-1;if(!e)return 1;let t=Yt(n.created_at,e.created_at);return t!==0?t:n.event_id===e.event_id?0:n.event_id>e.event_id?1:-1}function tx(n,e){if(!e)return!0;let t=Yt(n.removed_at,e.removed_at);return t!==0?t>0:n.event_id>e.event_id}function sx(n){let e=new Error(`[Encryption] GroupInfo is stale for ${n}; retry after an existing member uploads fresh GroupInfo`);return e.code="stale_group_info",e}var Qi=100,nx=25,rx=100,Ji=3,pr=5,ix=6e4,Lm=6e4,ax=1e4,ox=2*6e4,Yi=3;function Ft(n,e){return`${n}:${e}`}function Bt(n){let e=n.indexOf(":");return e<0?null:{channelType:n.substring(0,e),channelId:n.substring(e+1)}}function cx(n){let e=[],t=[],s=null;for(let r of n){if(t.length===0){t=[r],s=r;continue}let i=r-(s??r);if(t.length>=nx||i>rx){e.push(t),t=[r],s=r;continue}t.push(r)}return t.length>0&&e.push(t),e}function lx(n){return Array.from(n).map(e=>e.toString(16).padStart(2,"0")).join("")}function px(n){return typeof n=="bigint"?n:BigInt(n)}function dx(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`archive-${Date.now()}-${Math.random().toString(36).slice(2)}`}var ee=null,Xi=class{initialized=!1;provider=null;identity=null;userId=null;deviceId=null;e2eeClient=null;client=null;storage;groups=new Map;_providerRestored=!1;_wasmPath="/openmls_wasm_bg.wasm";_injectedWasm=null;_syncing=!1;_syncPromise=null;_syncWorkPromise=null;_keyPackageUploadPromise=null;_syncGateResolve=null;_lastSyncStates=new Map;_scopeRepairLocks=new Map;_scopeRepairGateResolvers=new Map;_scopeRepairGatePromises=new Map;_scopeSyncRequestedAfterRepair=new Set;_repairLockOwnerId=`repair-${Date.now()}-${Math.random().toString(36).slice(2)}`;_channelReadyLocks=new Map;_channelReadyUntil=new Map;_channelReadyCacheMs=3e4;_recoveryPrivateKey=null;_recoveryPublicKey=null;_recoveryKeyId=null;_recoveryCiphersuite=null;_wrappedRecoveryKey=null;_recoveryVaultKnown=null;_recoveryVaultBytes=null;_recoveryVaultRevision=null;_recoveryPublicMetadataPromise=null;_recoveryRecheckDoneForUnlock=!1;_recoveryPostUnlockMaintenancePromise=null;_recoveryPostUnlockMaintenanceGeneration=0;_archiveStashKey=null;_archiveStashKeyPromise=null;_archiveCheckpointMaterializations=new Map;_sponsoredArchiveDisabled=!1;_expectedDecryptLogKeys=new Map;_waterfallSummaryLogKeys=new Map;_deferredEncryptionEventLogKeys=new Map;_attachmentCryptoProvider=Rt;_e2eeAttachmentMultipartEnabled=!1;_e2eeAttachmentMultipartUploadConcurrency=ar();_e2eeSendLockChains=new Map;_pendingE2eeSendJobs=new Set;_pendingE2eeSendAbortControllers=new Map;_canceledPendingE2eeSends=new Set;_restoreQueue=[];_restoreQueueRunning=!1;_restoreInflight=new Map;_bootstrapKnownChannelsPromise=null;_channelBootstrapSub=null;_e2eeBootstrapProgress={total:0,completed:0,failed_cids:[],status:"idle"};_pendingEvictions=new Map;_decryptedMsgIds=new Set;constructor(){this.storage=null}async initialize(e,t,s){this.initialized||(this.client=e,this.userId=t,s?.storage?this.storage=s.storage:this.storage=new Ht(t),s?.wasmPath&&(this._wasmPath=s.wasmPath),s?.wasmModule&&(this._injectedWasm=s.wasmModule),s?.enableSponsoredArchives===!1&&(this._sponsoredArchiveDisabled=!0),s?.attachmentCryptoProvider&&(this._attachmentCryptoProvider=s.attachmentCryptoProvider),this._e2eeAttachmentMultipartEnabled=s?.enableE2eeAttachmentMultipart===!0,this._e2eeAttachmentMultipartUploadConcurrency=ar(s?.e2eeAttachmentMultipartUploadConcurrency),this.client.deviceId?this.deviceId=this.client.deviceId:(this.deviceId=await this.storage.getDeviceId(),this.client.deviceId=this.deviceId),await this._initWasm(),await this._initIdentity(),this.e2eeClient=new en(e),await this._loadRecoveryPublicMetadata().catch(r=>{b("warn","[Encryption] Recovery public metadata unavailable during init:",r)}),await this._normalizeStaleRestoreProgress(),await this.ensureKeyPackagesFromCachedHealthOrServer(),await this._syncAndRestoreGroups(),await this._persistProvider(),this.client.encryptionManager=this,this._registerKnownChannelBootstrapListener(),this.initialized=!0,this._resumeEpochArchiveCheckpoints(),this.resumePendingE2eeSends(),this.client?.dispatchEvent?.({type:"e2ee.initialized",user_id:this.userId,device_id:this.deviceId}),b("info","[Encryption] Manager initialized",{userId:this.userId,deviceId:this.deviceId,groups:this.groups.size}))}async _initWasm(){if(ee){await this._restoreOrCreateProvider();return}if(this._injectedWasm)ee=this._injectedWasm;else throw new Error("[Encryption] wasmModule is required. Pass the loaded openmls WASM module via options.wasmModule in initialize().");await this._restoreOrCreateProvider()}async _restoreOrCreateProvider(){let e=await this.storage.loadProviderState(this.userId,this.deviceId);if(e)try{this.provider=ee.Provider.from_bytes(new Uint8Array(e)),this._providerRestored=!0,b("info","[Encryption] Provider restored from storage");return}catch(t){b("warn","[Encryption] Failed to restore Provider, creating new one:",t)}this.provider=new ee.Provider,b("info","[Encryption] New Provider created")}async _initIdentity(){let e=await this.storage.loadIdentity(this.userId,this.deviceId);if(e)this.identity=ee.Identity.from_bytes(this.provider,new Uint8Array(e)),b("info","[Encryption] Identity restored from storage");else{this.identity=new ee.Identity(this.provider,this.userId);let t=this.identity.to_bytes();await this.storage.saveIdentity(this.userId,this.deviceId,t),b("info","[Encryption] New identity created and saved")}}async _uploadKeyPackages(e){let t=Math.max(0,Math.min(Qi,Math.floor(e)));if(t!==0)return this._keyPackageUploadPromise?this._keyPackageUploadPromise:(this._keyPackageUploadPromise=(async()=>{try{let r=this.identity.key_packages(this.provider,t).map(i=>i.to_bytes());await this.e2eeClient.uploadKeyPackages({key_packages:r}),await this._persistProvider(),b("info",`[Encryption] Uploaded ${t} key packages`)}catch(s){b("warn","[Encryption] Failed to upload key packages:",s)}finally{this._keyPackageUploadPromise=null}})(),this._keyPackageUploadPromise)}async ensureKeyPackages(e){if(!Number.isFinite(e))return;let t=Math.max(0,Math.floor(e));if(t>=Qi)return;let s=Qi-t;b("info",`[Encryption] Key packages below target (${t}/${Qi}), topping up ${s}...`),await this._uploadKeyPackages(s)}async ensureKeyPackagesFromServer(){try{let e=await this.e2eeClient.getKeyPackageCount();await this.ensureKeyPackages(e.remaining)}catch(e){b("warn","[Encryption] Failed to check key package count:",e)}}async ensureKeyPackagesFromCachedHealthOrServer(){let e=this.client?.latestKeyPackagesRemaining;if(typeof e=="number"){await this.ensureKeyPackages(e);return}await this.ensureKeyPackagesFromServer()}async _persistProvider(){try{let e=this.provider.to_bytes();await this.storage.saveProviderState(this.userId,this.deviceId,e)}catch(e){b("warn","[Encryption] Failed to persist Provider:",e)}}async _saveEncryptionSyncCheckpoint(e={}){let t=this.provider.to_bytes();if(this.storage.saveEncryptionSyncCheckpoint){await this.storage.saveEncryptionSyncCheckpoint({user_id:this.userId,device_id:this.deviceId,provider_bytes:t,scope_cursors:e.scopeCursors,pending_snapshots:e.pendingSnapshots,repair_states:e.repairStates});return}if(await this.storage.saveProviderState(this.userId,this.deviceId,t),e.scopeCursors&&await this._saveAllScopeSyncCursors(e.scopeCursors),e.pendingSnapshots)for(let[s,r]of Object.entries(e.pendingSnapshots))await this._savePendingSnapshots(s,r);if(e.repairStates)for(let s of e.repairStates)await this._saveChannelRepairState(s)}async _fetchVault(){try{return await this.e2eeClient.getRecoveryVault()}catch(e){if(ex(e))return null;throw e}}async _loadRecoveryPublicMetadata(){if(this._recoveryVaultKnown===!1)return null;if(this._recoveryVaultKnown===!0&&this._recoveryVaultBytes&&this._recoveryPublicKey&&this._recoveryKeyId&&this._recoveryCiphersuite!==null&&this._recoveryVaultRevision!==null)return{vault_bytes:this._recoveryVaultBytes,revision:this._recoveryVaultRevision,recovery_key_id:this._recoveryKeyId,ciphersuite:this._recoveryCiphersuite,vault_format_version:1,kdf_metadata:{name:"PBKDF2-SHA256",iterations:6e5},updated_at:""};if(this._recoveryPublicMetadataPromise)return this._recoveryPublicMetadataPromise;let e=(async()=>{let t=await this._fetchVault();if(this._recoveryVaultKnown=t!==null,this._recoveryVaultBytes=t?t.vault_bytes:null,this._recoveryVaultRevision=t?t.revision:null,!t)return null;let s=ee.WrappedRecoveryKey.from_bytes(new Uint8Array(t.vault_bytes));return this._recoveryPublicKey=new Uint8Array(s.public_key),this._recoveryKeyId=s.key_id,this._recoveryCiphersuite=s.ciphersuite,this._wrappedRecoveryKey=s,await this.storage.saveRecoveryPublicKey(this.userId,this._recoveryPublicKey),await this._flushDeferredArchives(),t})();this._recoveryPublicMetadataPromise=e;try{return await e}finally{this._recoveryPublicMetadataPromise===e&&(this._recoveryPublicMetadataPromise=null)}}async getRecoveryStatus(){let e=await this._loadRecoveryPublicMetadata(),t=this.deviceId||await this.storage.getDeviceId(),s=(await this.storage.loadIncompleteRestores(this.userId,t)).map(o=>this._normalizeProgress(o)),r=(await this.storage.loadRestoresWithPermanentGaps(this.userId,t)).map(o=>this._normalizeProgress(o)),i=new Map;for(let o of s)this._isUserGatedRestoreProgress(o)&&i.set(o.cid,o);for(let o of r)i.set(o.cid,o);let a=new Set(s.filter(o=>this._isUserGatedRestoreProgress(o)).map(o=>o.cid));return{hasVault:e!==null,unlocked:this._recoveryPrivateKey!==null,hasIncompleteRestore:a.size>0,incompleteChannels:Array.from(a),channelsWithPermanentGaps:r.map(o=>o.cid),restoreProgressWithIssues:Array.from(i.values()),e2eeBootstrapRunning:this._e2eeBootstrapProgress.status==="running",e2eeBootstrapCompleted:this._e2eeBootstrapProgress.completed,e2eeBootstrapTotal:this._e2eeBootstrapProgress.total}}clearRecoveryUnlock(){this._recoveryPrivateKey=null,this._wrappedRecoveryKey=null,this._recoveryRecheckDoneForUnlock=!1,this._recoveryPostUnlockMaintenanceGeneration+=1}_scheduleRecoveryPostUnlockMaintenance(){if(this._recoveryPostUnlockMaintenancePromise)return;let e=this._recoveryPostUnlockMaintenanceGeneration,t=new Promise(s=>{setTimeout(()=>{if(this._recoveryPostUnlockMaintenanceGeneration!==e||!this._recoveryPrivateKey){s();return}(async()=>{try{await this._flushDeferredArchives()}catch(r){b("warn","[Encryption] Recovery post-unlock deferred archive flush failed:",r)}try{await this._resumeEpochArchiveCheckpoints()}catch(r){b("warn","[Encryption] Recovery post-unlock archive checkpoint resume failed:",r)}try{await this._recheckKnownRecoveryChannelsOnce()}catch(r){b("warn","[Encryption] Recovery post-unlock channel recheck failed:",r)}})().finally(s)},0)});this._recoveryPostUnlockMaintenancePromise=t,t.finally(()=>{this._recoveryPostUnlockMaintenancePromise===t&&(this._recoveryPostUnlockMaintenancePromise=null)})}async setupRecoveryPin(e){if(!/^\d{8,}$/.test(e))throw new Error("PIN must be at least 8 digits");let t=ee.generate_recovery_keypair(this.provider),s=ee.wrap_recovery_private_key(this.provider,e,t.private_key,t.public_key,t.key_id,t.ciphersuite,6e5),r=s.to_bytes(),i=await this.e2eeClient.uploadRecoveryVault({vault_bytes:r});if(i.status==="conflict")throw new Error("A recovery vault already exists. Reload it before setting a PIN.");this._recoveryVaultKnown=!0,this._recoveryVaultBytes=r,this._recoveryVaultRevision=i.revision,this._recoveryPublicMetadataPromise=null,this._recoveryPrivateKey=new Uint8Array(t.private_key),this._recoveryPublicKey=new Uint8Array(t.public_key),this._recoveryKeyId=t.key_id,this._recoveryCiphersuite=t.ciphersuite,this._wrappedRecoveryKey=s,await this.storage.saveRecoveryPublicKey(this.userId,this._recoveryPublicKey),this._scheduleRecoveryPostUnlockMaintenance()}async unlockRecoveryVault(e){let t=await this._loadRecoveryPublicMetadata();if(!t)throw new Error("Recovery vault not found.");let s=this._wrappedRecoveryKey||ee.WrappedRecoveryKey.from_bytes(new Uint8Array(t.vault_bytes)),r=ee.unwrap_recovery_private_key(this.provider,e,s);this._recoveryVaultKnown=!0,this._recoveryVaultBytes=t.vault_bytes,this._recoveryVaultRevision=t.revision,this._recoveryPrivateKey=new Uint8Array(r),this._recoveryPublicKey=new Uint8Array(s.public_key),this._recoveryKeyId=s.key_id,this._recoveryCiphersuite=s.ciphersuite,this._wrappedRecoveryKey=s,await this.storage.saveRecoveryPublicKey(this.userId,this._recoveryPublicKey),this._scheduleRecoveryPostUnlockMaintenance()}async changeRecoveryPin(e,t){if(!/^\d{8,}$/.test(t))throw new Error("PIN must be at least 8 digits");(!this._wrappedRecoveryKey||!this._recoveryPublicKey||!this._recoveryKeyId||!this._recoveryCiphersuite)&&await this.unlockRecoveryVault(e);let s=ee.unwrap_recovery_private_key(this.provider,e,this._wrappedRecoveryKey),r=ee.wrap_recovery_private_key(this.provider,t,s,this._recoveryPublicKey,this._recoveryKeyId,this._recoveryCiphersuite,6e5);if(this._recoveryVaultRevision===null)throw new Error("Recovery vault revision is unavailable. Reload the vault before changing the PIN.");let i=await this.e2eeClient.uploadRecoveryVault({vault_bytes:r.to_bytes(),expected_revision:this._recoveryVaultRevision});if(i.status==="conflict")throw new Error("Recovery PIN changed on another device. Reload the vault and try again.");this._recoveryVaultRevision=i.revision,this._wrappedRecoveryKey=r,this._recoveryPrivateKey=new Uint8Array(s),this._recoveryVaultBytes=r.to_bytes()}async changeUnlockedRecoveryPin(e){if(!/^\d{8,}$/.test(e))throw new Error("PIN must be at least 8 digits");if(!this._recoveryPrivateKey||!this._recoveryPublicKey||!this._recoveryKeyId||!this._recoveryCiphersuite)throw new Error("Recovery vault must be unlocked before changing the PIN.");let t=ee.wrap_recovery_private_key(this.provider,e,this._recoveryPrivateKey,this._recoveryPublicKey,this._recoveryKeyId,this._recoveryCiphersuite,6e5),s=t.to_bytes();if(this._recoveryVaultRevision===null)throw new Error("Recovery vault revision is unavailable. Reload the vault before changing the PIN.");let r=await this.e2eeClient.uploadRecoveryVault({vault_bytes:s,expected_revision:this._recoveryVaultRevision});if(r.status==="conflict")throw new Error("Recovery PIN changed on another device. Reload the vault and try again.");this._recoveryVaultRevision=r.revision,this._wrappedRecoveryKey=t,this._recoveryVaultBytes=s,this._recoveryVaultKnown=!0}hasRecoveryKey(){return!!this._recoveryPublicKey||!!this._wrappedRecoveryKey}isRecoveryVaultUnlocked(){return this._recoveryPrivateKey!==null}async archiveCurrentEpoch(e,t,s="primary",r){let i=Ft(e,t),a=this.groups.get(i);if(!a)return;let o=px(a.epoch()),c=Number(o),l=await this.storage.loadEpochArchiveCheckpoint(i,c);if(l){this._materializeEpochArchiveCheckpoint(l);return}let p=a.archive_epoch_v2(),d=lx(p.snapshot_hash),u=Date.now(),h={scope_cid:i,channel_type:e,channel_id:t,epoch:c,encrypted_archive_bytes:await this._encryptArchiveStashBytes(new Uint8Array(p.archive_bytes)),snapshot:{snapshot_bytes:new Uint8Array(p.snapshot_bytes),snapshot_hash:d},sponsor_role:s,primary_user_id:r||s==="primary"&&this.userId||void 0,materialization:{account_owned:"pending",group_sponsored:this._sponsoredArchiveDisabled?"unsupported":"pending"},captured_at:u,updated_at:u};await this.storage.saveEpochArchiveCheckpoint(h),this._materializeEpochArchiveCheckpoint(h)}async _materializeArchiveUpload(e,t,s,r){let i=await this._decryptArchiveStashBytes(e.encrypted_archive_bytes),a=BigInt(e.epoch),o=dx(),c=new ee.ArchiveBlobAad(e.scope_cid,a,t,o,e.snapshot.snapshot_hash),l=ee.encrypt_archive_blob(this.provider,i,c),p=s.map(d=>{let u=new ee.ArchiveKeyWrapInfo(e.scope_cid,a,t,o,e.snapshot.snapshot_hash,d.recovery_key_id),h=ee.wrap_archive_data_key(this.provider,new Uint8Array(l.adk),d.public_key,u);return{recipient_user_id:d.user_id,recipient_recovery_key_id:d.recovery_key_id,hpke_kem_output:h.kem_output,hpke_ciphertext:h.ciphertext,ciphersuite:h.ciphersuite,hpke_info:h.hpke_info}});return{epoch:e.epoch,archive_blob_id:o,idempotency_key:`${e.epoch}:${t}:${this.deviceId||"web"}:${o}`,scope:t,...r?{recipient_set_hash:r}:{},encrypted_archive:{ciphertext:l.ciphertext,nonce:l.nonce,aead_aad:l.aead_aad},snapshot:e.snapshot,wraps:p}}async _saveCheckpointMaterialization(e,t,s,r){let i={...e,materialization:{...e.materialization,[t]:s},last_error:r,updated_at:Date.now()};return await this.storage.saveEpochArchiveCheckpoint(i),Object.values(i.materialization).every(o=>o==="uploaded"||o==="terminal"||o==="unsupported")&&await this.storage.deleteEpochArchiveCheckpoint(i.scope_cid,i.epoch),i}_materializeEpochArchiveCheckpoint(e){let t=`${e.scope_cid}:${e.epoch}`,s=this._archiveCheckpointMaterializations.get(t);if(s)return s;let r=this._runEpochArchiveCheckpointMaterialization(e).finally(()=>{this._archiveCheckpointMaterializations.get(t)===r&&this._archiveCheckpointMaterializations.delete(t)});return this._archiveCheckpointMaterializations.set(t,r),r}async _runEpochArchiveCheckpointMaterialization(e){let t=e;try{if(t.materialization.account_owned==="pending"&&this._recoveryPublicKey&&this._recoveryKeyId&&!await this._hasArchiveAcknowledged(t.scope_cid,t.epoch,"account_owned",this._recoveryKeyId)&&!await this._hasPendingArchiveWork(t.scope_cid,t.epoch,"account_owned")){let s=await this._materializeArchiveUpload(t,"account_owned",[{user_id:this.userId,recovery_key_id:this._recoveryKeyId,public_key:this._recoveryPublicKey}]);await this._enqueueArchiveUpload({cid:t.scope_cid,channel_type:t.channel_type,channel_id:t.channel_id,epoch:t.epoch,scope:"account_owned",upload:s,retry_count:0,created_at:Date.now()})}}catch(s){t=await this._saveCheckpointMaterialization(t,"account_owned","pending",je(s))}if(t.materialization.group_sponsored==="pending"&&!this._sponsoredArchiveDisabled)try{if(t.sponsor_role==="backup"&&(await new Promise(r=>setTimeout(r,5e3)),!this._isDesignatedArchiveBackup(t.scope_cid,t.primary_user_id))){await this._saveCheckpointMaterialization(t,"group_sponsored","unsupported"),await this._drainArchiveUploadQueue();return}let s=await this.e2eeClient.querySponsoredArchiveRecipients(t.channel_type,t.channel_id,t.epoch);if(s.matching_candidate_exists)t=await this._saveCheckpointMaterialization(t,"group_sponsored","uploaded");else if(!s.recipient_set_hash||s.recipients.length===0||s.reason)t=await this._saveCheckpointMaterialization(t,"group_sponsored","terminal",s.reason);else if(!await this._hasArchiveAcknowledged(t.scope_cid,t.epoch,"group_sponsored",s.recipient_set_hash)&&!await this._hasPendingArchiveWork(t.scope_cid,t.epoch,"group_sponsored")){let r=await this._materializeArchiveUpload(t,"group_sponsored",s.recipients,s.recipient_set_hash);await this._enqueueArchiveUpload({cid:t.scope_cid,channel_type:t.channel_type,channel_id:t.channel_id,epoch:t.epoch,scope:"group_sponsored",upload:r,retry_count:0,created_at:Date.now()})}}catch(s){let r=Number(s?.response?.status??s?.status);r===404||r===405||je(s).includes("account_owned")||je(s).includes("unsupported scope")?(this._sponsoredArchiveDisabled=!0,t=await this._saveCheckpointMaterialization(t,"group_sponsored","unsupported")):t=await this._saveCheckpointMaterialization(t,"group_sponsored","pending",je(s))}await this._drainArchiveUploadQueue()}_isDesignatedArchiveBackup(e,t){let s=this.groups.get(e),r=this._getActiveChannel(e);if(!s||!r||!this.userId)return!1;let i=[];for(let o of Object.keys(r.state?.members||{}))try{for(let c of s.members_by_user_id(o)||[])i.push({userId:o,leafIndex:Number(c.index)})}catch{}i.sort((o,c)=>o.userId.localeCompare(c.userId)||o.leafIndex-c.leafIndex);let a=i.find(o=>o.userId!==t);return!!a&&a.userId===this.userId&&a.leafIndex===Number(s.own_leaf_index())}async _resumeEpochArchiveCheckpoints(){let e=await this.storage.loadEpochArchiveCheckpoints().catch(()=>[]);for(let t of e)this._materializeEpochArchiveCheckpoint(t)}async _hasArchiveAcknowledged(e,t,s="account_owned",r){let i=r||(s==="account_owned"?this._recoveryKeyId:null);return i?!!await this.storage.loadArchiveAck(e,t,s,i):!1}async _hasPendingArchiveWork(e,t,s){let[r,i]=await Promise.all([this.storage.loadPendingArchiveUploads(),this.storage.loadPendingDeferredArchives()]);return r.some(a=>a.cid===e&&a.epoch===t&&a.scope===s)||s==="account_owned"&&i.some(a=>a.cid===e&&a.epoch===t)}_getBrowserCrypto(){let e=globalThis.crypto;if(!e?.subtle||!e.getRandomValues)throw new Error("WebCrypto is required to protect deferred archive material.");return e}async _getArchiveStashKey(){if(this._archiveStashKey)return this._archiveStashKey;if(this._archiveStashKeyPromise)return this._archiveStashKeyPromise;this._archiveStashKeyPromise=(async()=>{let e=await this.storage.loadArchiveStashKey();if(e)return this._archiveStashKey=e,e;let t=await this._getBrowserCrypto().subtle.generateKey({name:"AES-GCM",length:256},!1,["encrypt","decrypt"]);return await this.storage.saveArchiveStashKey(t),this._archiveStashKey=t,t})();try{return await this._archiveStashKeyPromise}finally{this._archiveStashKeyPromise=null}}async _encryptArchiveStashBytes(e){let t=this._getBrowserCrypto(),s=await this._getArchiveStashKey(),r=new Uint8Array(12);t.getRandomValues(r);let i=new Uint8Array(e.length);i.set(e);let a=await t.subtle.encrypt({name:"AES-GCM",iv:r},s,i.buffer);return{ciphertext:new Uint8Array(a),nonce:r}}async _decryptArchiveStashBytes(e){let t=await this._getArchiveStashKey(),s=new Uint8Array(e.nonce),r=new Uint8Array(e.ciphertext),i=await this._getBrowserCrypto().subtle.decrypt({name:"AES-GCM",iv:s},t,r);return new Uint8Array(i)}_listKnownE2eeChannels(){let e=this.client?.activeChannels;if(!e)return[];let t=new Set,s=[];for(let[r,i]of Object.entries(e))!i?.id||!this._isE2eeChannelData(i.data||i)||t.has(r)||this._isInactiveInviteRole(this._membershipRoleForChannel(i))||this._resolveChannelE2eeGroupId(r,i)===r&&(t.add(r),s.push({cid:r,channelType:i.type,channelId:i.id}));return s}_isRecentMembership(e){let t=this._getMembershipCreatedAt(e);if(!t)return!1;let s=Date.parse(t);return Number.isFinite(s)&&Date.now()-s<ox}async _markKnownChannelPendingRecoveryUnlock(e){if(!this.userId||!this.deviceId||!this.storage||this._recoveryPrivateKey||!await this._loadRecoveryPublicMetadata().catch(()=>null))return;let s=this._getActiveChannel(e.cid);if(this._isRecentMembership(s))return;let r=await this.storage.loadRestoreProgress(this.userId,this.deviceId,e.cid),i=r?this._normalizeProgress(r):this._newRestoreProgressRecord(e.channelType,e.channelId);i.status==="done"||i.status==="done_with_gaps"||this._isUserGatedRestoreProgress(i)||await this._saveRestoreProgress({...i,requires_user_action:"unlock_recovery_vault"},"pending")}async _markKnownChannelsPendingRecoveryUnlock(e){if(!this._recoveryPrivateKey)for(let t of e)this.groups.has(t.cid)&&await this._markKnownChannelPendingRecoveryUnlock(t)}_emitBootstrapProgress(e){this._e2eeBootstrapProgress={...e,failed_cids:[...e.failed_cids]},this.client?.dispatchEvent?.({type:"e2ee.bootstrap_progress",...this._e2eeBootstrapProgress})}_registerKnownChannelBootstrapListener(){this._channelBootstrapSub||!this.client?.on||(this._channelBootstrapSub=this.client.on("channels.queried",()=>{this.bootstrapKnownE2eeChannels({source:"channels_queried"})}))}async bootstrapKnownE2eeChannels(e={}){if(!this.initialized)return{...this._e2eeBootstrapProgress,results:[]};if(this._bootstrapKnownChannelsPromise)return this._bootstrapKnownChannelsPromise;let t=(async()=>{let s=this._listKnownE2eeChannels(),r=s.filter(p=>!this.groups.has(p.cid));e.priorityActiveCid&&(r=[...r.filter(p=>p.cid===e.priorityActiveCid),...r.filter(p=>p.cid!==e.priorityActiveCid)]);let i=[],a=[];this._emitBootstrapProgress({total:r.length,completed:0,failed_cids:i,status:r.length>0?"running":"done"});let o=0;for(let p of r){this._emitBootstrapProgress({total:r.length,completed:o,running_cid:p.cid,failed_cids:i,status:"running"});try{let d=await this.ensureChannelReady(p.channelType,p.channelId,p.cid,{source:e.source||"startup"});a.push(d),d.status==="failed"||d.status==="stale_group_info"?i.push(p.cid):this.groups.has(p.cid)&&(this._recoveryPrivateKey?this.enqueueRestore(p.channelType,p.channelId,"background"):await this._markKnownChannelPendingRecoveryUnlock(p))}catch(d){i.push(p.cid),a.push({cid:p.cid,status:"failed",error:d instanceof Error?d.message:String(d)}),b("warn","[Encryption] Known E2EE channel bootstrap failed:",p.cid,d)}finally{o+=1,this._emitBootstrapProgress({total:r.length,completed:o,failed_cids:i,status:i.length>0&&o===r.length?"failed":"running"})}}let c=i.length>0?"failed":"done",l={total:r.length,completed:o,failed_cids:i,status:c};if(this._emitBootstrapProgress(l),this._recoveryPrivateKey)for(let p of s)this.groups.has(p.cid)&&this.enqueueRestore(p.channelType,p.channelId,"background");else await this._markKnownChannelsPendingRecoveryUnlock(s);return{...l,results:a}})().finally(()=>{this._bootstrapKnownChannelsPromise=null});return this._bootstrapKnownChannelsPromise=t,t}_listKnownE2eeTimelines(){let e=this.client?.activeChannels;if(!e)return[];let t=new Set,s=[];for(let[r,i]of Object.entries(e))!i?.id||!this._isE2eeChannelData(i.data||i)||t.has(r)||this._isInactiveInviteRole(this._membershipRoleForChannel(i))||(t.add(r),s.push({cid:r,channelType:i.type,channelId:i.id}));return s}async _recheckKnownRecoveryChannelsOnce(){if(!(!this._recoveryPrivateKey||this._recoveryRecheckDoneForUnlock)){this._recoveryRecheckDoneForUnlock=!0,await this.bootstrapKnownE2eeChannels({source:"recovery_unlock"}).catch(e=>{b("warn","[Encryption] Recovery unlock bootstrap did not fully complete; continuing archive recheck:",e)});for(let e of this._listKnownE2eeTimelines())try{await this.repairRecoveryChannel(e.channelType,e.channelId,{mode:"recheck_channel"})}catch(t){b("warn","[Encryption] Recovery unlock archive recheck failed:",e.cid,t)}}}async archiveCurrentEpochForCid(e,t="primary",s){let r=Bt(e);r&&await this.archiveCurrentEpoch(r.channelType,r.channelId,t,s)}async safeArchiveCurrentEpoch(e,t,s="primary",r){try{await this.archiveCurrentEpoch(e,t,s,r)}catch(i){b("warn","[Encryption] Archive current epoch failed; continuing encryption flow:",e,t,i)}}async safeArchiveCurrentEpochForCid(e,t="primary",s){let r=Bt(e);r&&await this.safeArchiveCurrentEpoch(r.channelType,r.channelId,t,s)}async _enqueueArchiveUpload(e){await this.storage.saveArchiveUpload(e)}async _flushDeferredArchives(){if(!this._recoveryPublicKey||!this._recoveryKeyId)return;let e=await this.storage.loadPendingDeferredArchives();for(let t of e)try{if(await this._hasArchiveAcknowledged(t.cid,t.epoch)){await this.storage.deleteDeferredArchive(t.cid,t.epoch,t.archive_blob_id);continue}if((await this.storage.loadPendingArchiveUploads()).some(a=>a.cid===t.cid&&a.epoch===t.epoch&&a.scope==="account_owned"&&a.upload?.archive_blob_id===t.archive_blob_id)){await this.storage.deleteDeferredArchive(t.cid,t.epoch,t.archive_blob_id);continue}let i=await this._decryptArchiveStashBytes(t.encrypted_adk);await this._enqueueArchiveUploadFromDeferred(t,i),await this.storage.deleteDeferredArchive(t.cid,t.epoch,t.archive_blob_id)}catch(s){await this.storage.saveDeferredArchive({...t,retry_count:t.retry_count+1,updated_at:Date.now()}),b("warn","[Encryption] Deferred archive flush failed; keeping for retry:",t.cid,t.epoch,s)}await this._drainArchiveUploadQueue()}async _enqueueArchiveUploadFromDeferred(e,t){if(!this._recoveryPublicKey||!this._recoveryKeyId)throw new Error("Recovery public key is not available.");let s=BigInt(e.epoch),r=new ee.ArchiveKeyWrapInfo(e.cid,s,e.scope,e.archive_blob_id,e.snapshot.snapshot_hash,this._recoveryKeyId),i=ee.wrap_archive_data_key(this.provider,t,this._recoveryPublicKey,r),a={epoch:e.epoch,archive_blob_id:e.archive_blob_id,idempotency_key:`${e.epoch}:account_owned:${this.deviceId||"web"}:${e.archive_blob_id}`,scope:e.scope,encrypted_archive:e.encrypted_archive,snapshot:e.snapshot,wraps:[{recipient_user_id:this.userId,recipient_recovery_key_id:this._recoveryKeyId,hpke_kem_output:i.kem_output,hpke_ciphertext:i.ciphertext,ciphersuite:i.ciphersuite,hpke_info:i.hpke_info}]};await this._enqueueArchiveUpload({cid:e.cid,channel_type:e.channel_type,channel_id:e.channel_id,epoch:e.epoch,scope:e.scope,upload:a,retry_count:e.retry_count,created_at:e.created_at})}async _markArchiveUploadAcknowledged(e,t,s){let r=t.scope==="group_sponsored"?t.recipient_set_hash:t.wraps?.[0]?.recipient_recovery_key_id;if(!r)return;let i=s==="duplicate_cap"?"duplicate_cap":s==="idempotent"?"idempotent":"uploaded";await this.storage.saveArchiveAck({cid:e.cid,epoch:e.epoch,scope:t.scope,coverage_key:r,...t.scope==="account_owned"?{recovery_key_id:r}:{recipient_set_hash:r},status:i,archive_blob_id:t.archive_blob_id,updated_at:Date.now()});let a=await this.storage.loadEpochArchiveCheckpoint(e.cid,e.epoch);a&&await this._saveCheckpointMaterialization(a,t.scope,"uploaded")}async _drainArchiveUploadQueue(){let e=await this.storage.loadPendingArchiveUploads();for(let t of e){let s=t.upload;try{let r=await this.e2eeClient.uploadEpochArchive(t.channel_type,t.channel_id,s);if(await this.storage.deleteArchiveUpload(t.cid,t.epoch,s.archive_blob_id),r.reason_code==="recipient_set_stale"&&s.scope==="group_sponsored"){let i=await this.storage.loadEpochArchiveCheckpoint(t.cid,t.epoch);if(i&&(i.sponsored_rewrap_count||0)<2){let a={...i,sponsored_rewrap_count:(i.sponsored_rewrap_count||0)+1,updated_at:Date.now()};await this.storage.saveEpochArchiveCheckpoint(a),await this._saveCheckpointMaterialization(a,"group_sponsored","pending",r.reason_code),this._materializeEpochArchiveCheckpoint(a)}else i&&await this._saveCheckpointMaterialization(i,"group_sponsored","terminal",r.reason_code);continue}await this._markArchiveUploadAcknowledged(t,s,r.reason_code),r.status!=="stored"&&b("info","[Encryption] Archive upload acknowledged without storing:",t.cid,t.epoch,r.reason_code)}catch(r){let i=Zw(r);if(!Tm(r)){await this.storage.deleteArchiveUpload(t.cid,t.epoch,s.archive_blob_id);let a=await this.storage.loadEpochArchiveCheckpoint(t.cid,t.epoch);if(a){let o=s.scope==="group_sponsored"&&(je(r).includes("account_owned")||je(r).includes("unsupported scope")||Number(r?.response?.status??r?.status)===404||Number(r?.response?.status??r?.status)===405);o&&(this._sponsoredArchiveDisabled=!0),await this._saveCheckpointMaterialization(a,s.scope,o?"unsupported":"terminal",je(r))}b("warn","[Encryption] Archive upload rejected; removing non-retryable work item:",{cid:t.cid,epoch:t.epoch,ermisCode:i,error:je(r)});continue}t.retry_count+=1,await this.storage.saveArchiveUpload(t),b("warn","[Encryption] Archive upload failed, queued for retry:",t.cid,t.epoch,r)}}}_newRestoreProgressRecord(e,t){let s=Date.now();return{device_id:this.deviceId,cid:Ft(e,t),user_id:this.userId,channel_type:e,channel_id:t,status:"pending",completed_epochs:[],permanent_gaps:[],transient_failures:[],repair_issues:[],last_checked_at:s,updated_at:s}}_normalizeProgress(e){let t=Array.from(new Set(e.completed_epochs||[])).sort((a,o)=>a-o),s=new Map;for(let a of e.permanent_gaps||[])s.set(a.epoch,a);let r=new Map;for(let a of e.transient_failures||[])s.has(a.epoch)||r.set(a.epoch,a);let i=new Map;for(let a of e.repair_issues||[]){let o=a.message_id.startsWith("legacy-epoch-")?a.message_version:this._messageVersionKey({id:a.message_id,created_at:a.created_at,updated_at:typeof a.encrypted_message?.updated_at=="string"?a.encrypted_message.updated_at:void 0}),c=i.get(o),l=c&&c.updated_at>a.updated_at?c:a;i.set(o,{...l,message_version:o})}if(e.repair_issues===void 0){for(let a of s.values()){let o=`legacy-epoch:${a.epoch}:${a.reason}`;i.set(o,{cid:e.cid,message_id:`legacy-epoch-${a.epoch}`,message_version:o,mls_epoch:a.epoch,reason:a.reason,status:a.reason==="expired_restore_window"?"terminal":"blocked",retry_count:a.reason==="decrypt_error"?Ji:0,max_retries:a.reason==="decrypt_error"?Ji:0,updated_at:a.updated_at})}for(let a of r.values()){let o=`legacy-epoch:${a.epoch}:${a.reason}`;i.set(o,{cid:e.cid,message_id:`legacy-epoch-${a.epoch}`,message_version:o,mls_epoch:a.epoch,reason:"legacy_epoch_failure",status:"retryable",retry_count:a.retry_count,max_retries:a.max_retries,updated_at:a.updated_at})}}return{...e,completed_epochs:t,permanent_gaps:Array.from(s.values()).sort((a,o)=>a.epoch-o.epoch),transient_failures:Array.from(r.values()).sort((a,o)=>a.epoch-o.epoch),repair_issues:Array.from(i.values()).sort((a,o)=>a.updated_at-o.updated_at)}}_isUserGatedRestoreProgress(e){let t=this._normalizeProgress(e);return t.requires_user_action==="unlock_recovery_vault"||(t.target_epochs?.length||0)>0||t.permanent_gaps.length>0||t.transient_failures.length>0}_repairIssuePolicy(e){return e==="expired_restore_window"?{status:"terminal",maxRetries:0}:e==="forward_secrecy_consumed"?{status:"blocked",maxRetries:0}:e==="network_error"||e==="server_error"?{status:"retryable",maxRetries:pr}:e==="decrypt_error"?{status:"retryable",maxRetries:Ji}:e==="legacy_epoch_failure"?{status:"retryable",maxRetries:pr}:{status:"blocked",maxRetries:0}}_upsertRepairIssueInProgress(e,t,s,r=!0){let i=String(t.id||t.message_id||"");if(!i)return e;let a={...t,id:i},o=this._messageVersionKey(a),c=(e.repair_issues||[]).find(m=>m.message_version===o),l=this._repairIssuePolicy(s),p=r?(c?.retry_count||0)+1:c?.retry_count||0,d=l.status==="retryable"&&p>=l.maxRetries&&l.maxRetries>0?"blocked":l.status,u=Date.now(),h={cid:String(t.cid||e.cid),message_id:i,message_version:o,mls_epoch:typeof t.mls_epoch=="number"?t.mls_epoch:c?.mls_epoch,encrypted_message:t.mls_ciphertext?{...t}:c?.encrypted_message,created_at:typeof t.created_at=="string"?t.created_at:c?.created_at,reason:s,status:d,retry_count:p,max_retries:l.maxRetries,last_attempt_at:u,updated_at:u};return this._normalizeProgress({...e,repair_issues:[...(e.repair_issues||[]).filter(m=>m.message_version!==o),h]})}_clearRepairIssueInProgress(e,t){let s=String(t.id||t.message_id||"");if(!s)return e;let r=this._messageVersionKey({...t,id:s});return this._normalizeProgress({...e,repair_issues:(e.repair_issues||[]).filter(i=>i.message_version!==r)})}_upsertLegacyEpochIssue(e,t,s){let r=`legacy-epoch:${t}:${s}`,i=this._repairIssuePolicy(s),a=(e.repair_issues||[]).find(c=>c.message_version===r),o=Date.now();return this._normalizeProgress({...e,repair_issues:[...(e.repair_issues||[]).filter(c=>c.message_version!==r),{cid:e.cid,message_id:`legacy-epoch-${t}`,message_version:r,mls_epoch:t,reason:s,status:i.status,retry_count:a?.retry_count||0,max_retries:i.maxRetries,last_attempt_at:o,updated_at:o}]})}_replaceTargetRepairIssueReason(e,t,s,r){let i=this._repairIssuePolicy(s),a=Date.now(),o=!1,c=(e.repair_issues||[]).map(l=>!(r&&r.size>0?r.has(l.message_id):l.mls_epoch===t&&!l.message_id.startsWith("legacy-epoch-"))||l.mls_epoch!==void 0&&l.mls_epoch!==t?l:(o=!0,{...l,reason:s,status:i.status,max_retries:i.maxRetries,last_attempt_at:a,updated_at:a}));return o?this._normalizeProgress({...e,repair_issues:c}):this._upsertLegacyEpochIssue(e,t,s)}async _recordRepairIssue(e,t,s,r=!0){if(!this.userId||!this.deviceId)return;let i=this._getActiveChannel(e),a=i?{channelType:i.type,channelId:i.id}:Bt(e);if(!a)return;let o=await this._loadOrCreateRestoreProgress(a.channelType,a.channelId);o=this._upsertRepairIssueInProgress(o,{...t,cid:e},s,r),await this._saveRestoreProgress(o,this._finalRestoreStatus(o))}async _clearRepairIssue(e,t){if(!this.userId||!this.deviceId)return;let s=this._getActiveChannel(e),r=s?{channelType:s.type,channelId:s.id}:Bt(e);if(!r)return;let i=await this._loadOrCreateRestoreProgress(r.channelType,r.channelId),a=i.repair_issues?.length||0;i=this._clearRepairIssueInProgress(i,t),(i.repair_issues?.length||0)!==a&&await this._saveRestoreProgress(i,this._finalRestoreStatus(i))}async _loadOrCreateRestoreProgress(e,t){let s=Ft(e,t),r=await this.storage.loadRestoreProgress(this.userId,this.deviceId,s);return this._normalizeProgress(r||this._newRestoreProgressRecord(e,t))}async _saveRestoreProgress(e,t){let s=this._normalizeProgress({...e,status:t||e.status,last_checked_at:Date.now(),updated_at:Date.now()});return await this.storage.saveRestoreProgress(s),this._emitRestoreProgress(s),s}_emitRestoreProgress(e){this.client?.dispatchEvent?.({type:"e2ee.restore_progress",cid:e.cid,restore_progress:e,status:e.status,completed_epochs:e.completed_epochs,permanent_gaps:e.permanent_gaps,transient_failures:e.transient_failures,repair_issues:e.repair_issues||[]})}_markEpochCompleted(e,t){let s=new Set(e.completed_epochs);return s.add(t),this._normalizeProgress({...e,completed_epochs:Array.from(s),permanent_gaps:e.permanent_gaps.filter(r=>r.epoch!==t),transient_failures:e.transient_failures.filter(r=>r.epoch!==t)})}_addPermanentGap(e,t,s){return this._normalizeProgress({...e,completed_epochs:e.completed_epochs.filter(r=>r!==t),permanent_gaps:[...e.permanent_gaps.filter(r=>r.epoch!==t),{epoch:t,reason:s,updated_at:Date.now()}],transient_failures:e.transient_failures.filter(r=>r.epoch!==t)})}_addTransientFailure(e,t,s){let r=e.transient_failures.find(o=>o.epoch===t),i=s==="decrypt_error"?Ji:pr,a=(r?.retry_count||0)+1;return a>=i&&s==="decrypt_error"?this._addPermanentGap(e,t,"decrypt_error"):this._normalizeProgress({...e,completed_epochs:e.completed_epochs.filter(o=>o!==t),transient_failures:[...e.transient_failures.filter(o=>o.epoch!==t),{epoch:t,reason:s,retry_count:a,max_retries:i,updated_at:Date.now()}]})}_finalRestoreStatus(e){let t=e.repair_issues||[];return t.some(r=>r.status==="retryable")||e.transient_failures.some(r=>r.retry_count<r.max_retries)?"failed":t.length>0||e.transient_failures.length>0||e.permanent_gaps.length>0?"done_with_gaps":"done"}_markManualRepairIssuesMissingArchives(e,t,s){if(!s?.manualRepair)return e;let r=new Set(t),i=s.targetEpochs?new Set(s.targetEpochs):null,a=new Set;for(let c of e.repair_issues||[])c.status==="terminal"||c.mls_epoch===void 0||s.messageIds&&!s.messageIds.has(c.message_id)||i&&!i.has(c.mls_epoch)||r.has(c.mls_epoch)||a.add(c.mls_epoch);let o=e;for(let c of a)o=this._addPermanentGap(o,c,"no_archive"),o=this._replaceTargetRepairIssueReason(o,c,"no_archive",s.messageIds);return o}async _normalizeStaleRestoreProgress(){if(!this.userId||!this.deviceId||!this.storage)return;let e=await this.storage.loadIncompleteRestores(this.userId,this.deviceId);await Promise.all(e.filter(t=>t.status==="running").map(t=>this._saveRestoreProgress(t,"partial")))}async getRestoreProgress(e,t){if(!this.userId||!this.deviceId)return null;let s=Ft(e,t),r=await this.storage.loadRestoreProgress(this.userId,this.deviceId,s);return r?this._normalizeProgress(r):null}_restoreRequestKey(e,t){return`${e}:${t?.fromEpoch??""}:${t?.toEpoch??""}`}_hasInflightRestoreForCid(e){let t=`${e}:`;for(let s of this._restoreInflight.keys())if(s.startsWith(t))return!0;return!1}async _shouldSkipRestoreEnqueue(e,t){if(t?.fromEpoch!==void 0||t?.toEpoch!==void 0)return!1;if(this._hasInflightRestoreForCid(e))return!0;if(!this.userId||!this.deviceId)return!1;try{let s=await this.storage.loadRestoreProgress(this.userId,this.deviceId,e);if(!s)return!1;let r=this._normalizeProgress(s).status;return r==="done"||r==="done_with_gaps"}catch(s){return b("warn","[Encryption] Restore progress check failed before enqueue:",e,s),!1}}async _enqueueRestoreIfNeeded(e){this._hasInflightRestoreForCid(e.cid)||await this._shouldSkipRestoreEnqueue(e.cid,e.options)||this._hasInflightRestoreForCid(e.cid)||(this._restoreQueue=this._restoreQueue.filter(t=>t.cid!==e.cid),e.priority==="active"?this._restoreQueue.unshift(e):this._restoreQueue.push(e),this._drainRestoreQueue())}enqueueRestore(e,t,s="background",r){let i=Ft(e,t);this._enqueueRestoreIfNeeded({cid:i,channelType:e,channelId:t,priority:s,options:r})}async _enqueueIncompleteRestores(){await this.bootstrapKnownE2eeChannels({source:"manual"});let e=await this.storage.loadIncompleteRestores(this.userId,this.deviceId),t=new Set;for(let s of e)s.status==="done"||s.status==="done_with_gaps"||this.groups.has(s.cid)&&(t.add(s.cid),await this._enqueueRestoreIfNeeded({cid:s.cid,channelType:s.channel_type,channelId:s.channel_id,priority:"background"}));for(let s of this._listKnownE2eeChannels())t.has(s.cid)||this.groups.has(s.cid)&&await this._enqueueRestoreIfNeeded({cid:s.cid,channelType:s.channelType,channelId:s.channelId,priority:"background"})}async _drainRestoreQueue(){if(!this._restoreQueueRunning){this._restoreQueueRunning=!0;try{for(;this._restoreQueue.length>0;){let e=this._restoreQueue.shift();try{await this.restoreHistoricalMessages(e.channelType,e.channelId,e.options)}catch(t){if(b("warn","[Encryption] Restore queue entry failed:",e.cid,t),!this._recoveryPrivateKey)break}}}finally{this._restoreQueueRunning=!1}}}async _withRecoveryNetworkRetry(e){let t;for(let s=0;s<pr;s+=1)try{return await e()}catch(r){if(t=r,!Tm(r)||s+1>=pr)break;await new Promise(i=>setTimeout(i,Math.min(250*2**s,4e3)))}throw t}async restoreHistoricalMessages(e,t,s){if(!this._recoveryPrivateKey)throw new Error("Recovery vault not unlocked.");let r=Ft(e,t),i=this._restoreRequestKey(r,s),a=this._restoreInflight.get(i);if(a)return a;let o=this._restoreHistoricalMessagesInternal(e,t,s);this._restoreInflight.set(i,o);try{return await o}finally{this._restoreInflight.get(i)===o&&this._restoreInflight.delete(i)}}async repairRecoveryChannel(e,t,s={}){if(!this._recoveryPrivateKey)throw new Error("Recovery vault not unlocked.");let r=s.mode||"failed_only",i=Ft(e,t),a=s.flushPending!==!1,o=a?this._dedupePendingSnapshots(await this.storage.loadPendingE2eeSnapshots(i)):[],c=a?await this._flushPendingE2eeSnapshots(i):{decrypted:[],pending:[]},l=new Map(o.map(y=>[y.message_id,y.version])),p=new Map;for(let y of c.decrypted){let x=l.get(y.id)||this._messageVersionKey({id:y.id,created_at:y.created_at,updated_at:y.updated_at});p.set(x,{messageId:y.id,messageVersion:x,createdAt:y.created_at})}let d=await this._loadOrCreateRestoreProgress(e,t),u=(d.repair_issues||[]).filter(y=>y.status!=="terminal"),h=Array.from(new Set(u.map(y=>y.mls_epoch).concat(o.map(y=>y.mls_epoch)).filter(y=>y!==void 0))),m=new Set(u.filter(y=>!y.message_id.startsWith("legacy-epoch-")).map(y=>y.message_id).concat(o.map(y=>y.message_id))),g=[];(r==="recheck_channel"||u.length>0||c.pending.length>0)&&(g=await this._restoreHistoricalMessagesInternal(e,t,{forceRecheck:!0,manualRepair:!0,timelineOnly:!0,targetEpochs:r==="failed_only"&&h.length>0?h:void 0,messageIds:r==="failed_only"&&m.size>0?m:void 0}));let _=0,v=new Set;for(let y of g){let x=y.messageId||`epoch:${y.epoch}:${y.reason||"gap"}`;if(v.add(x),!y.messageId||y.gap)continue;if(y.alreadyAvailable){_+=1;continue}let C=y.message||{},S=this._messageVersionKey({id:y.messageId,created_at:C.created_at||y.createdAt,updated_at:C.updated_at,mls_epoch:C.mls_epoch??y.epoch});p.set(S,{messageId:y.messageId,messageVersion:S,epoch:y.epoch,createdAt:y.createdAt})}for(let y of o)v.add(y.message_id);return d=await this._loadOrCreateRestoreProgress(e,t),{newlyRepaired:Array.from(p.values()),stillFailed:d.repair_issues||[],alreadyAvailable:_,checked:v.size}}async repairEncryptedChannel(e,t,s={}){let r=Ft(e,t),i=this._getActiveChannel(r),a=this._resolveChannelE2eeGroupId(r,i),o=s.mode||"replay";return this._withScopeRepairLock(a,async()=>o==="reset_local_state"?this._resetEncryptedChannelState(e,t,r,a):this._replayEncryptedChannelState(e,t,r,a))}async _repairMessagesAfterStateSync(e,t,s={}){return this._recoveryPrivateKey?{requiresPin:!1,messageRepair:await this.repairRecoveryChannel(e,t,{mode:"recheck_channel",flushPending:s.flushPending})}:{requiresPin:(await this.getRecoveryStatus().catch(()=>null))?.hasVault===!0}}_mergeRepairResults(e,t){if(!e)return t;if(!t)return e;let s=new Map;for(let r of[...e.newlyRepaired,...t.newlyRepaired])s.set(r.messageVersion,r);return{newlyRepaired:Array.from(s.values()),stillFailed:t.stillFailed,alreadyAvailable:Math.max(e.alreadyAvailable,t.alreadyAvailable),checked:Math.max(e.checked,t.checked)}}async _maxKnownRepairEpoch(e,t,s){let r=await this.getRestoreProgress(e,t).catch(()=>null),i=await this.storage.loadPendingE2eeSnapshots(s).catch(()=>[]),a=[...(r?.repair_issues||[]).map(o=>o.mls_epoch).filter(o=>o!==void 0),...i.map(o=>o.mls_epoch).filter(o=>o!==void 0)];return a.length>0?Math.max(...a):void 0}_isLocalEpochBehind(e,t){if(t===void 0)return!1;let s=this._localEpoch(e);return s!==void 0&&s>=0&&s<t}_encryptedRepairResultFromParts(e){let t=e.messageRepair?.newlyRepaired.length??0,s=e.messageRepair?.stillFailed.length??0;return{cid:e.cid,scopeCid:e.scopeCid,status:e.status,requiresPin:e.requiresPin??!1,resetAvailable:e.resetAvailable??!1,processedEvents:e.syncState?.processed_events??0,bufferedMessages:e.syncState?.buffered_messages??0,repairedMessages:t,stillFailed:s,messageRepair:e.messageRepair,syncState:e.syncState,repairState:e.repairState,error:e.error}}async _replayEncryptedChannelState(e,t,s,r){let i,a=!1,o;try{let P=await this._repairMessagesAfterStateSync(e,t,{flushPending:!1});i=P.messageRepair,a=P.requiresPin}catch(P){o=je(P)}let c=this._getActiveChannel(s),l=this._getActiveChannel(r)||c,p=await this._loadScopeSyncCursor(r),d=await this._loadChannelRepairState(r),u=await this._maxKnownRepairEpoch(e,t,s),h=!this._isLocalEpochBehind(r,u),m=d?.last_safe_cursor||(l?this._membershipBoundedEventCursor(l,h?p:null):h?p||this._nowEventCursor():this._nowEventCursor()),g=this._makeChannelRepairState(r,"replaying",{fail_count:d?.fail_count||0,last_safe_cursor:d?.last_safe_cursor,last_attempted_cursor:m,last_committed_cursor:p||void 0,max_observed_epoch:d?.max_observed_epoch});await this._saveChannelRepairState(g);let _;try{_=await this._syncChannelFromCursor(r,m,100)}catch(P){let E=(d?.fail_count||0)+1,k=this._makeChannelRepairState(r,E>=Yi?"reset_available":"replay_failed",{fail_count:E,last_safe_cursor:d?.last_safe_cursor||m,last_attempted_cursor:m,last_committed_cursor:p||void 0,max_observed_epoch:d?.max_observed_epoch,last_error:je(P)});return await this._saveChannelRepairState(k),this._encryptedRepairResultFromParts({cid:s,scopeCid:r,status:k.status,requiresPin:a,resetAvailable:k.status==="reset_available",repairState:k,messageRepair:i,error:k.last_error||o})}let v=_.processed_event_cursor||m,y=_.needs_retry?(d?.fail_count||0)+1:0,x=this._makeChannelRepairState(r,_.needs_retry?y>=Yi?"reset_available":"replay_failed":"healthy",{fail_count:y,last_safe_cursor:v,last_attempted_cursor:m,last_committed_cursor:await this._loadScopeSyncCursor(r)||v,max_observed_epoch:Math.max(d?.max_observed_epoch||0,_.max_observed_epoch||0)||void 0,last_error:_.error});if(await this._saveChannelRepairState(x),_.needs_retry){let P=a,E,k;try{let G=await this._repairMessagesAfterStateSync(e,t);P=G.requiresPin,E=this._mergeRepairResults(i,G.messageRepair)}catch(G){k=je(G),E=i}return this._encryptedRepairResultFromParts({cid:s,scopeCid:r,status:x.status,requiresPin:P,resetAvailable:x.status==="reset_available",syncState:_,repairState:x,messageRepair:E,error:x.last_error||k||o||_.error})}let{requiresPin:C,messageRepair:S}=await this._repairMessagesAfterStateSync(e,t);return this._encryptedRepairResultFromParts({cid:s,scopeCid:r,status:"healthy",requiresPin:C,resetAvailable:!1,syncState:_,repairState:x,messageRepair:this._mergeRepairResults(i,S),error:o})}async _resetEncryptedChannelState(e,t,s,r){let i=Bt(r)||{channelType:e,channelId:t},a=await this._loadChannelRepairState(r);if(a?.status!=="reset_available")throw new Error("Reset encrypted state is only available after protocol replay has failed.");let o=this.provider.to_bytes(),c=this.groups.get(r)||null,l=await this.storage.loadGroupState(r),p=await this.storage.loadPendingE2eeSnapshots(r),d=await this._loadScopeSyncCursor(r),u=this._makeChannelRepairState(r,"resetting",{fail_count:a?.fail_count||Yi,last_safe_cursor:a?.last_safe_cursor,last_attempted_cursor:d||void 0,last_committed_cursor:d||void 0,max_observed_epoch:a?.max_observed_epoch});await this._saveChannelRepairState(u);try{let h=this.groups.get(r);h&&typeof h.delete_state=="function"&&h.delete_state(this.provider),this.groups.delete(r),this._pendingEvictions.delete(r),this._channelReadyUntil.delete(r),await this.storage.deleteGroup(r),await this._savePendingSnapshots(r,[]),await this._persistPendingEvictions(),await this._saveEncryptionSyncCheckpoint({repairStates:[u]});let m=await this.joinExternal(i.channelType,i.channelId,r),g=await this.syncAfterExternalJoin(i.channelType,i.channelId,r);await this._drainArchiveUploadQueue();let _=this._makeChannelRepairState(r,"healthy",{fail_count:0,last_safe_cursor:g.sync_state?.processed_event_cursor||d||void 0,last_committed_cursor:await this._loadScopeSyncCursor(r)||d||void 0,max_observed_epoch:Math.max(a?.max_observed_epoch||0,m.epoch||0)||void 0});await this._saveChannelRepairState(_);let{requiresPin:v,messageRepair:y}=await this._repairMessagesAfterStateSync(e,t);return this._encryptedRepairResultFromParts({cid:s,scopeCid:r,status:"healthy",requiresPin:v,resetAvailable:!1,syncState:g.sync_state,repairState:_,messageRepair:y})}catch(h){this.provider=ee.Provider.from_bytes(new Uint8Array(o)),c?this.groups.set(r,c):this.groups.delete(r),l!=null?await this.storage.saveGroupState(r,l):await this.storage.deleteGroup(r),await this._savePendingSnapshots(r,p);let m=this._makeChannelRepairState(r,"reset_available",{fail_count:Math.max(a?.fail_count||0,Yi),last_safe_cursor:a?.last_safe_cursor,last_attempted_cursor:d||void 0,last_committed_cursor:d||void 0,max_observed_epoch:a?.max_observed_epoch,last_error:je(h)});return await this._saveEncryptionSyncCheckpoint({repairStates:[m]}),this._encryptedRepairResultFromParts({cid:s,scopeCid:r,status:"failed",resetAvailable:!0,repairState:m,error:m.last_error})}}async _restoreHistoricalMessagesInternal(e,t,s){if(!this._recoveryPrivateKey)throw new Error("Recovery vault not unlocked.");let r=Ft(e,t),i=this._getActiveChannel(r),a=this._resolveChannelE2eeGroupId(r,i),o=Bt(a)||{channelType:e,channelId:t},c=r!==a||s?.timelineOnly===!0,l=await this._loadOrCreateRestoreProgress(e,t),p=await this._withRecoveryNetworkRetry(()=>this.e2eeClient.queryEpochArchives(o.channelType,o.channelId,{list_epochs:!0})),d=s?.targetEpochs?new Set(s.targetEpochs):null,u=Array.from(new Set((p.epochs||[]).map(E=>E.epoch))).filter(E=>(!d||d.has(E))&&(s?.fromEpoch===void 0||E>=s.fromEpoch)&&(s?.toEpoch===void 0||E<=s.toEpoch)).sort((E,k)=>E-k),h=this._markManualRepairIssuesMissingArchives(l,u,s);h!==l&&(l=await this._saveRestoreProgress(h,this._finalRestoreStatus(h)));let m=new Set(l.completed_epochs),g=new Set(l.permanent_gaps.map(E=>E.epoch)),_=new Set([...l.transient_failures.filter(E=>E.retry_count<E.max_retries).map(E=>E.epoch),...(l.repair_issues||[]).filter(E=>E.status==="retryable"&&E.mls_epoch!==void 0).map(E=>E.mls_epoch)]),v=u.filter(E=>s?.forceRecheck||_.has(E)?!0:!(m.has(E)||g.has(E))).concat(Array.from(_).filter(E=>u.includes(E)&&(s?.manualRepair||!m.has(E)&&!g.has(E)))).filter((E,k,G)=>G.indexOf(E)===k).sort((E,k)=>E-k);if(v.length===0)return l=await this._saveRestoreProgress(l,this._finalRestoreStatus(l)),[];l=await this._saveRestoreProgress({...l,target_epochs:v},"running");let y=[],x=new Map,C=new Map,S=E=>{let k=C.get(E);return k||(k=this._collectActiveChannelEnvelopes(E),C.set(E,k)),k},P=new TextDecoder;for(let E of cx(v)){let k=Math.min(...E),G=Math.max(...E),Q,ce=[];try{Q=await this._withRecoveryNetworkRetry(()=>this.e2eeClient.queryEpochArchives(o.channelType,o.channelId,{epoch_from:k,epoch_to:G,include_snapshots:!0,include_wraps:!0}));let F;do{let W=await this._withRecoveryNetworkRetry(()=>this.e2eeClient.queryArchiveCiphertexts(o.channelType,o.channelId,{epoch_from:k,epoch_to:G,cursor:F,limit:500}));ce.push(...(c?W.ciphertexts.filter(X=>(X.cid||a)===r):W.ciphertexts).filter(X=>!s?.messageIds||s.messageIds.has(X.message_id))),F=W.has_more?W.next_cursor:void 0}while(F)}catch(F){let W=F?.response?.status>=500?"server_error":"network_error";for(let X of E)l=this._addTransientFailure(l,X,W),l=this._replaceTargetRepairIssueReason(l,X,W,s?.messageIds);throw await this._saveRestoreProgress(l,this._finalRestoreStatus(l)),F}let q=new Map;for(let F of ce)q.has(F.mls_epoch)||q.set(F.mls_epoch,[]),q.get(F.mls_epoch).push(F);let _e=new Map;for(let F of Q.wraps||[])_e.set(F.archive_blob_id,F);for(let F of E){let W=(Q.blobs||[]).filter(A=>A.epoch===F).sort((A,z)=>{let re=A.archive_scope==="group_sponsored"?0:1,ie=z.archive_scope==="group_sponsored"?0:1;return re!==ie?re-ie:A.created_at.localeCompare(z.created_at)});if(W.length===0){y.push({epoch:F,gap:!0,reason:"no_archive"}),l=this._addPermanentGap(l,F,"no_archive"),l=this._replaceTargetRepairIssueReason(l,F,"no_archive",s?.messageIds),l=await this._saveRestoreProgress(l,"running");continue}let X=W.map(A=>{let z=_e.get(A.archive_blob_id);return z?{blob:A,wrap:z,prepared:!1}:null}).filter(A=>A!==null),M=A=>{if(A.prepared)return!!A.archiveBytes&&!!A.snapshotBytes;A.prepared=!0;let z=Q.snapshots?.[A.blob.member_snapshot_hash];if(!z)return A.prepareError="missing_snapshot",!1;A.snapshotBytes=new Uint8Array(z.snapshot_bytes);try{let re=ee.unwrap_archive_data_key_from_parts(this.provider,this._recoveryPrivateKey,new Uint8Array(A.wrap.hpke_kem_output),new Uint8Array(A.wrap.hpke_ciphertext),new Uint8Array(A.wrap.hpke_info));return A.archiveBytes=ee.decrypt_archive_blob(this.provider,re,new Uint8Array(A.blob.encrypted_archive_bytes),new Uint8Array(A.blob.aead_nonce),new Uint8Array(A.blob.aead_aad)),!0}catch{return A.prepareError="no_matching_wrap",!1}};if(X.length===0){y.push({epoch:F,gap:!0,reason:"no_matching_wrap"}),l=this._addPermanentGap(l,F,"no_matching_wrap"),l=this._replaceTargetRepairIssueReason(l,F,"no_matching_wrap",s?.messageIds),l=await this._saveRestoreProgress(l,"running");continue}l=this._normalizeProgress({...l,repair_issues:(l.repair_issues||[]).filter(A=>A.mls_epoch!==F||!A.message_id.startsWith("legacy-epoch-"))});for(let A of q.get(F)||[]){let z=A.cid||r,re=S(z).get(A.message_id),ie=this._buildArchiveMessageEnvelope(z,A,re,{epoch:BigInt(F)}),Re=await this.storage.loadE2eeMessage(A.message_id);if(Re&&this._storedMessageCoversVersion(Re,ie)){l=this._clearRepairIssueInProgress(l,ie),y.push({epoch:F,messageId:A.message_id,source:"archive",createdAt:A.created_at,alreadyAvailable:!0});continue}let dt,Le;for(let Ae of X)if(M(Ae))try{Le=ee.decrypt_with_epoch_archive_v2(this.provider,Ae.archiveBytes,Ae.snapshotBytes,new Uint8Array(A.mls_ciphertext),!0,0),dt=Ae;break}catch{}if(Le&&dt){let Ae=P.decode(Le.content),it=JSON.parse(Ae),ge=it&&typeof it.text=="string"?it:{text:Ae},Ge=this._buildArchiveMessageEnvelope(z,A,re,Le),br={...this._storedFromPayload(z,ge,Ge,Re),isRestored:!0,restoredFrom:"epoch_archive",archiveBlobId:dt.blob.archive_blob_id,restoredAt:Date.now(),restoredEpoch:F};await this.storage.saveE2eeMessage(br),this._decryptedMsgIds.add(this._messageVersionKey(Ge)),l=this._clearRepairIssueInProgress(l,Ge);let wr=await this._buildFullMessageWithQuoted(br,Ge),xr=x.get(z)||[];xr.push(wr),x.set(z,xr),y.push({epoch:F,messageId:A.message_id,plaintext:ge,source:"archive",createdAt:A.created_at,message:wr,synced:!0});continue}let Oe=X.every(Ae=>Ae.prepareError==="missing_snapshot")?"missing_snapshot":X.every(Ae=>Ae.prepareError==="no_matching_wrap")?"no_matching_wrap":"decrypt_error";l=this._upsertRepairIssueInProgress(l,ie,Oe),y.push({epoch:F,messageId:A.message_id,gap:!0,reason:Oe})}l=this._markEpochCompleted(l,F),l=await this._saveRestoreProgress(l,"running")}}l=await this._saveRestoreProgress(l,this._finalRestoreStatus(l));for(let[E,k]of x){if(k.length===0)continue;this.client?.activeChannels?.[E]?.state?.addMessagesSorted(k,!1,!0,!0,"current"),this.client?.dispatchEvent({type:"e2ee.local_messages_loaded",cid:E,messages:k})}return y}_getEventCreatedAt(e){return e?.data?.created_at||e?.created_at||e?.data?.reaction?.created_at||e?.data?.message?.created_at}_toMillis(e){if(typeof e=="number")return e;let t=Number(e);if(!isNaN(t)&&t>1e12)return t;let s=new Date(e).getTime();return isNaN(s)?0:s}_nowCursor(){return new Date().toISOString()}_nowEventCursor(){return{created_at:this._nowCursor(),event_id:At}}_toCursorString(e){if(e instanceof Date)return e.toISOString();if(typeof e=="string"&&!Number.isFinite(Number(e)))return e;if(e==null)return this._nowCursor();let t=this._toMillis(e);return t?new Date(t).toISOString():this._nowCursor()}_initialSyncCursor(e){if(e==null)return this._nowCursor();let t=this._toMillis(e);return t?new Date(Math.max(0,t-1)).toISOString():this._nowCursor()}_getMembershipCreatedAt(e){if(!this.userId||!e)return;let t=e.state?.membership;if(t?.created_at)return t.created_at;let s=e.state?.members?.[this.userId];return s?.created_at?s.created_at:(Array.isArray(e.data?.members)?e.data.members:[]).find(a=>a?.user_id===this.userId||a?.user?.id===this.userId)?.created_at}_membershipBoundedCursor(e,t){let s=e?.data?.mls_enabled_at,r=this._getMembershipCreatedAt(e),i=[];return t&&i.push(this._toCursorString(t)),r&&i.push(this._initialSyncCursor(r)),s&&i.push(this._initialSyncCursor(s)),i.length===0?this._nowCursor():i.reduce((a,o)=>Yt(a,o)>=0?a:o)}_membershipBoundedEventCursor(e,t){let s=this._membershipBoundedCursor(e,t?.created_at);return t&&Yt(s,t.created_at)===0?t:{created_at:s,event_id:At}}_isE2eeChannelData(e){if(e?.mls_enabled===!0)return!0;let t=typeof e?.parent_cid=="string"?e.parent_cid:void 0;if(!t)return!1;let s=this._getActiveChannel(t);return s?.data?.mls_enabled===!0||s?.channel?.mls_enabled===!0}_resolveChannelE2eeGroupId(e,t){let s=t?.data||t?.channel||t||{};return typeof s.e2ee_group_id=="string"&&s.e2ee_group_id.length>0?s.e2ee_group_id:typeof s.mls_cid=="string"&&s.mls_cid.length>0?s.mls_cid:this._isE2eeChannelData(s)&&typeof s.parent_cid=="string"&&s.parent_cid.length>0&&s.gate!==!0?s.parent_cid:e}_resolveMessageE2eeGroupId(e,t){if(typeof e?.e2ee_group_id=="string"&&e.e2ee_group_id.length>0)return e.e2ee_group_id;if(typeof e?.mls_cid=="string"&&e.mls_cid.length>0)return e.mls_cid;let s=e?.cid||t,r=this._getActiveChannel(s),i=this._resolveChannelE2eeGroupId(s,r);return i!==s?i:t}_eventRouteCid(e,t){return e?.cid||e?.data?.cid||e?.data?.message?.cid||t}_eventCursorFromEnvelope(e,t){return{created_at:e?.created_at||this._getEventCreatedAt(e)||t||this._nowCursor(),event_id:e?.event_id||e?.data?.event_id||e?.data?.id||At}}_topicOwnsE2eeGroup(e){let t=this._getActiveChannel(e);return t?.data?.mls_enabled===!1||this._resolveChannelE2eeGroupId(e,t)!==e?!1:this.groups.has(e)}async _loadAllScopeSyncCursors(){if(this.storage.loadAllScopeSyncCursors)return this.storage.loadAllScopeSyncCursors();let e=await this.storage.loadAllSyncTimestamps(),t={};for(let[s,r]of Object.entries(e))t[s]={created_at:r,event_id:At};return t}async _saveAllScopeSyncCursors(e){if(this.storage.saveAllScopeSyncCursors){await this.storage.saveAllScopeSyncCursors(e);return}let t={};for(let[s,r]of Object.entries(e))t[s]=r.created_at;await this.storage.saveAllSyncTimestamps(t)}async _loadScopeSyncCursor(e){if(this.storage.loadScopeSyncCursor)return this.storage.loadScopeSyncCursor(e);let t=await this.storage.loadSyncTimestamp(e);return t?{created_at:t,event_id:At}:null}async _saveScopeSyncCursor(e,t){if(this.storage.saveScopeSyncCursor){await this.storage.saveScopeSyncCursor(e,t);return}await this.storage.saveSyncTimestamp(e,t.created_at)}async _loadChannelRepairState(e){return this.storage.loadChannelRepairState?this.storage.loadChannelRepairState(e):null}async _saveChannelRepairState(e){this.storage.saveChannelRepairState&&await this.storage.saveChannelRepairState(e)}async _deleteChannelRepairState(e){this.storage.deleteChannelRepairState&&await this.storage.deleteChannelRepairState(e)}_localEpoch(e){let t=this.groups.get(e);if(t)try{return Number(t.epoch())}catch{return}}_makeChannelRepairState(e,t,s={}){return{scope_cid:e,status:t,fail_count:0,local_epoch:this._localEpoch(e),updated_at:Date.now(),...s}}_startScopeRepairGate(e){if(this._scopeRepairGatePromises.has(e))return;let t=new Promise(s=>{this._scopeRepairGateResolvers.set(e,s)});this._scopeRepairGatePromises.set(e,t)}_finishScopeRepairGate(e){let t=this._scopeRepairGateResolvers.get(e);this._scopeRepairGateResolvers.delete(e),this._scopeRepairGatePromises.delete(e),t?.(),this._scopeSyncRequestedAfterRepair.delete(e)&&(async()=>{let s=await this._loadScopeSyncCursor(e)||this._nowEventCursor();await this._syncChannelFromCursor(e,s)})().catch(s=>{b("warn","[Encryption] Deferred scope sync after repair failed:",e,s)})}isScopeRepairing(e){return this._scopeRepairGatePromises.has(e)}requestScopeSyncAfterRepair(e){this._scopeSyncRequestedAfterRepair.add(e)}async waitForScopeRepair(e){let t=this._scopeRepairGatePromises.get(e);t&&await t}async _withScopeRepairLock(e,t){let s=this._scopeRepairLocks.get(e);if(s)return s;let r=(async()=>{let i=!1;if(this.storage.tryAcquireRepairLock&&(i=await this.storage.tryAcquireRepairLock(e,this._repairLockOwnerId,ix),!i))return{cid:e,scopeCid:e,status:"replay_failed",requiresPin:!1,resetAvailable:!1,processedEvents:0,bufferedMessages:0,repairedMessages:0,stillFailed:0,error:"Encrypted state repair is already running for this channel on another tab."};this._startScopeRepairGate(e);try{return await t()}finally{this._finishScopeRepairGate(e),i&&this.storage.releaseRepairLock&&await this.storage.releaseRepairLock(e,this._repairLockOwnerId).catch(a=>b("warn",a))}})();this._scopeRepairLocks.set(e,r);try{return await r}finally{this._scopeRepairLocks.get(e)===r&&this._scopeRepairLocks.delete(e)}}_startSyncGate(){this._syncing&&this._syncPromise||(this._syncing=!0,this._syncPromise=new Promise(e=>{this._syncGateResolve=e}))}_finishSyncGate(e){let t=this._syncGateResolve;this._syncGateResolve=null,this._syncing=!1,this._syncPromise=null,t?.()}_makeSyncState(e,t,s,r,i={}){let a=typeof s=="string"?{created_at:s,event_id:At}:s,o=typeof r=="string"?{created_at:r,event_id:At}:r;return{cid:e,status:t,started_cursor:a.created_at,processed_cursor:o.created_at,started_event_cursor:a,processed_event_cursor:o,has_more:!1,needs_retry:!1,processed_events:0,buffered_messages:0,...i}}_emitSyncState(e){this._lastSyncStates.set(e.cid,e),!e.needs_retry&&e.status!=="failed"&&e.status!=="stale_group_info"&&this._channelReadyUntil.set(e.cid,Date.now()+this._channelReadyCacheMs),this.client?.dispatchEvent?.({type:"e2ee.sync_state",cid:e.cid,sync_state:e})}getSyncState(e){return this._lastSyncStates.get(e)||null}async _isScopeReadyForOpen(e,t,s){if(!this.groups.has(e)||this.isScopeRepairing(e)||this._scopeRepairLocks.has(e)||this._scopeSyncRequestedAfterRepair.has(e))return!1;let r=this.getSyncState(e);if(!r||r.status!=="ready"||r.needs_retry||r.has_more)return!1;let i=t!==void 0?t:await this._loadScopeSyncCursor(e);if(!i)return!1;let a=s;if(a===void 0&&(a=this.client?.activeChannels?.[e]),a&&!this._isE2eeChannelData(a.data||a))return!1;let o=this._getMembershipCreatedAt(a);if(o){let p={created_at:this._initialSyncCursor(o),event_id:At};if(lr(i,p)<0)return!1}let c=r.processed_event_cursor||{created_at:r.processed_cursor,event_id:At};if(lr(i,c)<0)return!1;let l=await this._loadChannelRepairState(e);return!l||l.status==="healthy"}_getDurableSyncCursor({processedCursor:e,serverNextCursor:t,hasMore:s}){return!s&&t!==void 0&&Yt(t,e)>=0?t:e}_resolveProcessedEventCursor(e,t,s){let r=e.processedEventCursor??t,i=lr(r,s)<0;return{processedEventCursor:r,cursorLagged:i,durableCursor:i?r:s}}_pendingSnapshotVersion(e){let t=e.updated_at||e.created_at||"";return(e.id||"")+":"+t+":"+(e.mls_epoch??"")}_toPendingSnapshot(e,t,s,r,i){let a=s;return{cid:e,event_type:t,message_id:String(a.id||""),mls_epoch:typeof a.mls_epoch=="number"?a.mls_epoch:void 0,message:s,version:this._pendingSnapshotVersion(a),received_cursor:r,event_time:i}}_dedupePendingSnapshots(e){let t=new Map;for(let s of e)s.message_id&&t.set(s.version,s);return Array.from(t.values()).sort((s,r)=>Yt(s.received_cursor,r.received_cursor))}async _savePendingSnapshots(e,t){await this.storage.savePendingE2eeSnapshots(e,this._dedupePendingSnapshots(t))}_pendingSnapshotEventType(e){return e.updated_at&&e.updated_at!==e.created_at?"message_updated":"application"}_pendingSnapshotCursor(e){return e.updated_at||e.created_at||this._nowCursor()}async _rememberPendingE2eeSnapshot(e,t){if(!(typeof this.storage?.loadPendingE2eeSnapshots!="function"||typeof this.storage?.savePendingE2eeSnapshots!="function"))try{let s=await this.storage.loadPendingE2eeSnapshots(e),r=this._pendingSnapshotCursor(t);await this._savePendingSnapshots(e,[...s,this._toPendingSnapshot(e,this._pendingSnapshotEventType(t),t,r,r)])}catch(s){b("warn","[Encryption] Failed to persist pending E2EE snapshot:",e,s)}}_pendingRouteCidsForScope(e){let t=new Set([e]),s=(i,a)=>{i&&(i===e||this._resolveChannelE2eeGroupId(i,a)===e)&&t.add(i)},r=this.client?.activeChannels||{};for(let[i,a]of Object.entries(r)){s(i,a);let o=a?.state?.topics;if(Array.isArray(o))for(let c of o)s(c?.cid||c?.data?.cid||c?.channel?.cid,c)}return Array.from(t)}_publishDecryptedMessages(e){if(e.length===0)return;let t=new Map;for(let s of e){let r=t.get(s.cid)||[];r.push(s),t.set(s.cid,r)}for(let[s,r]of t){let i=this._getActiveChannel(s);if(i?.state?.messageSets){let a=Object.values(this.client?.state?.users||{}),o=r.map(l=>{let p=this.client?.state?.users?.[l.user_id];return{...l,content_type:"standard",user:Ue(l.user_id,p,l.user,Z(l.user_id,a),l.user_id===this.userId?this.client?.user:void 0),status:"received"}});typeof i.state.addMessagesSorted=="function"&&i.state.addMessagesSorted(o,!1,!0,!0,"latest");let c=new Map(r.map(l=>[l.id,l]));i.state.messageSets.forEach(l=>{for(let p=0;p<l.messages.length;p++){let d=l.messages[p],u=c.get(d.id);u&&(l.messages[p]={...d,content_type:"standard",text:u.text??"",attachments:u.attachments??d.attachments,sticker_url:u.sticker_url??d.sticker_url})}})}this.client?.dispatchEvent?.({type:"e2ee.post_join_sync",cid:s,messages:r.map(a=>({...a,content_type:"standard"}))})}}async _flushPendingSnapshotsForScope(e){if(typeof this.storage?.loadPendingE2eeSnapshots!="function"||typeof this.storage?.savePendingE2eeSnapshots!="function")return{decrypted:[],pending:[]};let t=this._pendingRouteCidsForScope(e),s=[];for(let u of t)s.push(...await this.storage.loadPendingE2eeSnapshots(u));let r=this._dedupePendingSnapshots(s);if(r.length===0)return{decrypted:[],pending:[]};let i=r.map(u=>({...u.message,cid:u.cid||u.message?.cid||e})),{decrypted:a,buffered:o}=await this.decryptApplicationMessages(e,i),c=new Set(o.map(u=>this._pendingSnapshotVersion(u))),l=r.filter(u=>c.has(u.version)),p=new Set([...t,...r.map(u=>u.cid||e),...l.map(u=>u.cid||e)]),d=new Map;for(let u of l){let h=u.cid||e,m=d.get(h)||[];m.push(u),d.set(h,m)}for(let u of p)await this._savePendingSnapshots(u,d.get(u)||[]);return this._publishDecryptedMessages(a),{decrypted:a,pending:l}}async _flushPendingE2eeSnapshots(e){let t=this._dedupePendingSnapshots(await this.storage.loadPendingE2eeSnapshots(e));if(t.length===0)return{decrypted:[],pending:[]};let{decrypted:s,buffered:r}=await this.decryptApplicationMessages(e,t.map(o=>o.message)),i=new Set(r.map(o=>this._pendingSnapshotVersion(o))),a=t.filter(o=>i.has(o.version));return await this._savePendingSnapshots(e,a),{decrypted:s,pending:a}}async sync(){return this._syncWorkPromise?this._syncWorkPromise:(this._startSyncGate(),this._syncWorkPromise=this._syncAndRestoreGroups().then(()=>{this._finishSyncGate()}).catch(e=>{throw this._finishSyncGate(e),e}).finally(()=>{this._syncWorkPromise=null}),this._syncWorkPromise)}isSyncing(){return this._syncing}waitForSync(){return this._syncPromise||Promise.resolve()}markSyncStart(){this._startSyncGate()}async _syncAndRestoreGroups(){try{let e=await this.storage.listGroupCids();if(e.length>0){b("info",`[Encryption] Restoring ${e.length} group(s) from Provider...`);for(let c of e)if(!this.groups.has(c))try{let l=ee.Group.load(this.provider,c);this.groups.set(c,l),b("info","[Encryption] Restored group:",c)}catch(l){b("warn","[Encryption] Failed to restore group:",c,l)}}try{let c=await this.storage.loadPendingEvictions();for(let[l,p]of Object.entries(c)){let d=this._pendingEvictions.get(l)??new Set;for(let u of p)d.add(u);this._pendingEvictions.set(l,d)}Object.keys(c).length>0&&b("info","[Encryption] Restored pending evictions from storage:",c)}catch(c){b("warn","[Encryption] Failed to load persisted evictions:",c)}let t=await this._loadAllScopeSyncCursors(),s=await this.storage.loadRemovedSyncCursor(),r=Array.from(this.groups.keys()),i={};for(let c of r){let l=this.client?.activeChannels?.[c];i[c]=this._membershipBoundedEventCursor(l,t[c])}Object.keys(i).length===0&&b("info","[Encryption] No existing channels to sync \u2014 will check for external join");let a=!0;for(;a;){a=!1;let c=await this.e2eeClient.scopeSync(i,100,s??null),l=c.removed_channels;if(l?.events?.length)for(let p of l.events)await this._processRemovedChannelTombstone(p);l?.next_cursor!==void 0&&tx(l.next_cursor,s)&&(s=l.next_cursor,await this.storage.saveRemovedSyncCursor(s)),l?.has_more&&(a=!0);for(let[p,d]of Object.entries(c.channels||{})){if(!d?.events||d.events.length===0){let S=await this._flushPendingSnapshotsForScope(p),P=i[p]??this._nowEventCursor();this._emitSyncState(this._makeSyncState(p,d.has_more?"syncing":"ready",P,P,{server_next_cursor:d.next_cursor?.created_at,server_next_event_cursor:d.next_cursor,has_more:d.has_more,needs_retry:d.has_more,processed_events:0,buffered_messages:S.pending.length})),d.has_more&&(a=!0);continue}let u=i[p]??this._nowEventCursor(),h=await this._processChannelEvents(p,d.events,u),m=this._eventCursorFromEnvelope(d.events[d.events.length-1],u.created_at),g=d.next_cursor??m,{processedEventCursor:_,cursorLagged:v,durableCursor:y}=this._resolveProcessedEventCursor(h,u,g),x=_.created_at,C=d.has_more||v;lr(y,u)>0&&(i[p]=y),this._emitSyncState(this._makeSyncState(p,v?"needs_retry":d.has_more?"syncing":"ready",u,_,{server_next_cursor:g.created_at,server_next_event_cursor:g,has_more:d.has_more,needs_retry:C,processed_events:h.processedEvents,buffered_messages:h.bufferedMessages,max_observed_epoch:h.maxObservedEpoch})),d.has_more&&!v&&(a=!0)}}await this._saveEncryptionSyncCheckpoint({scopeCursors:i}),b("info",`[Encryption] Sync complete. Groups: ${this.groups.size}`);let o=this.client?.activeChannels;if(o){let c=[];for(let[l,p]of Object.entries(o))this._isE2eeChannelData(p?.data||p)&&this._resolveChannelE2eeGroupId(l,p)===l&&!this.groups.has(l)&&c.push({cid:l,type:p.type,id:p.id});if(c.length>0){b("info",`[Encryption] Multi-device: ${c.length} E2EE channel(s) need external join`);for(let{cid:l,type:p,id:d}of c)try{let u=await this.syncNewChannel(p,d,l);b("info","[Encryption] Multi-device ensure completed:",l,u.status)}catch(u){b("warn","[Encryption] Multi-device external join failed:",l,u)}}}}catch(e){b("warn","[Encryption] Failed to sync and restore groups:",e)}}async _processRemovedChannelTombstone(e){let t=e.cid;if(!t)return;this.leaveGroup(t,e.removed_at),this._pendingEvictions.delete(t),await this._persistPendingEvictions(),await this._savePendingSnapshots(t,[]);let s=this.client?.activeChannels;s?.[t]&&delete s[t],b("info","[Encryption] Removed channel tombstone processed:",t,{removed_at:e.removed_at,removed_by:e.removed_by,removal_type:e.removal_type,self_remove:e.self_remove})}async _processChannelEvents(e,t,s=this._nowEventCursor()){let r=e,i=[],a=[],o=0,c=s,l,p=new Set(this._pendingRouteCidsForScope(r)),d=async()=>{let h=new Map;for(let m of a){let g=m.cid||r,_=h.get(g)||[];_.push(m),h.set(g,_)}for(let m of p)await this._savePendingSnapshots(m,h.get(m)||[])},u=async()=>{if(a.length===0)return;let h=a.splice(0,a.length).sort((y,x)=>Yt(y.received_cursor,x.received_cursor)),m=h.map(y=>({...y.message,cid:y.cid||y.message?.cid||r})),{decrypted:g,buffered:_}=await this.decryptApplicationMessages(r,m);i.push(...g);let v=new Set(_.map(y=>this._pendingSnapshotVersion(y)));a.push(...h.filter(y=>v.has(y.version))),await d()};for(let h of t)p.add(this._eventRouteCid(h,r));for(let h of p)a.push(...await this.storage.loadPendingE2eeSnapshots(h));a.splice(0,a.length,...this._dedupePendingSnapshots(a)),await u();for(let h of t){let m=this._getEventCreatedAt(h),g=this._eventCursorFromEnvelope(h,c.created_at),_=h.type,v=this._eventRouteCid(h,r),y=h?.cid||r,x=()=>{o+=1,c=g};switch(_){case"protocol":{let C=h.data||h.message||h,S=C.type||C.type_field;switch(typeof C.epoch=="number"&&(l=Math.max(l??C.epoch,C.epoch)),S){case"welcome":{if((C.target_user_ids||[]).includes(this.userId)&&!this.groups.has(y))try{await this.joinGroup(C.welcome,C.ratchet_tree,C.user?.id)}catch(E){if(this._isMissingKeyPackageError(E)){b("warn","[Encryption] Skipping stale welcome with no local KeyPackage:",y,E);break}throw E}break}case"commit":case"external_commit":{let P=C.device_id,E=C.user?.id;if(E===this.userId&&!!P&&P===this.deviceId){b("info",`[Encryption] Skipping own ${S} (already merged):`,y);break}if(!this.groups.has(y)){b("info",`[Encryption] Skipping ${S} before local group exists:`,y);break}let G=C.epoch??-1,Q=this.groups.get(y);if(Q&&G>=0){let q=Number(Q.epoch());if(q>=G){b("info",`[Encryption] processCommit: commit at epoch ${G} already applied (group at ${q}), skipping:`,y);break}}let ce=C.commit;await this.processCommit(y,ce,G,E,{flushPending:!1});break}}await u();break}case"application":{let C=h.data||h.message;if(C.content_type==="mls"){let P=this._resolveMessageE2eeGroupId(C,r),{decrypted:E,buffered:k}=await this.decryptApplicationMessages(v,[C],P);i.push(...E),k.length>0&&(a.push(...k.map(G=>this._toPendingSnapshot(v,"application",G,g.created_at,m))),await d())}else{await this.storage.saveE2eeMessage({id:C.id,cid:v,content_type:"standard",text:C.text||"",user_id:C.user?.id||"",user:C.user?{...C.user}:void 0,created_at:C.created_at||new Date().toISOString(),type:C.message_type||C.type||"system",parent_id:C.parent_id,quoted_message_id:C.quoted_message_id,mentioned_users:C.mentioned_users});let P=C.text||"";if((C.message_type==="system"||C.type==="system")&&(P.startsWith("12 ")||P.startsWith("11 ")||P.startsWith("21 "))){let E=P.split(" ")[1];if(E&&E!==this.userId){let k=this._resolveChannelE2eeGroupId(v,this._getActiveChannel(v)),G=this._getActiveChannel(v)||this._getActiveChannel(k);if(!G||!this.isDesignatedEvictor(G)){x();continue}let Q=this.groups.get(k);if(Q)try{let ce=Q.members_by_user_id(E);if(ce&&ce.length>0){let q=this._pendingEvictions.get(k)??new Set;q.add(E),this._pendingEvictions.set(k,q),b("info","[Encryption] Queued eviction (offline recovery) for",E,"in",k),this._persistPendingEvictions().catch(_e=>b("warn",_e))}}catch{}}}}break}case"invite_rejected":{let C=h.data||{},S=C.member?.user_id;if(!S)break;let P=this._resolveChannelE2eeGroupId(v,this._getActiveChannel(v)),E=this._getActiveChannel(v)||this._getActiveChannel(P);if(E?.state?.members&&delete E.state.members[S],S===this.userId){this.leaveGroup(P,m);for(let k of C.topic_cids??[])this._topicOwnsE2eeGroup(k)&&this.leaveGroup(k,m)}else if(C.mls_enabled){await this.queuePendingEviction(P,S);for(let k of C.topic_cids??[])this._topicOwnsE2eeGroup(k)&&await this.queuePendingEviction(k,S)}break}case"invite_accepted":case"invite_messaging_rejected":case"invite_messaging_skipped":break;case"member_removed":{let C=h.data||{},S=C.member?.user_id,P=C.user?.id;if(!S){x();continue}let E=this._resolveChannelE2eeGroupId(v,this._getActiveChannel(v)),k=this._getActiveChannel(v)||this._getActiveChannel(E);if(k?.state?.members&&delete k.state.members[S],S===this.userId){this.leaveGroup(E,m);for(let ce of C.topic_cids??[])this._topicOwnsE2eeGroup(ce)&&this.leaveGroup(ce,m);x();continue}if(!(C.self_remove===!0||C.self_remove===void 0&&!!P&&S===P)){x();continue}if(!k||!this.isDesignatedEvictor(k)){x();continue}let Q=this.groups.get(E);if(Q)try{let ce=Q.members_by_user_id(S);if(ce&&ce.length>0){let q=this._pendingEvictions.get(E)??new Set;q.add(S),this._pendingEvictions.set(E,q),await this._persistPendingEvictions(),b("info","[Encryption] Queued eviction from member_removed sync for",S,"in",E)}}catch{}break}case"reaction":{let C=h.data,S=C?.message_id;if(!S){x();continue}let P=this.client?.activeChannels?.[v];P?.state?.messageSets&&P.state.messageSets.forEach(E=>{for(let k=0;k<E.messages.length;k++)if(E.messages[k].id===S){E.messages[k]={...E.messages[k],latest_reactions:C.latest_reactions??E.messages[k].latest_reactions,reaction_counts:C.reaction_counts??E.messages[k].reaction_counts};break}});try{let E=await this.storage.loadE2eeMessage(S);E&&await this.storage.saveE2eeMessage({...E,latest_reactions:C.latest_reactions??E.latest_reactions,reaction_counts:C.reaction_counts??E.reaction_counts})}catch(E){b("warn","[Encryption] Failed to update reactions in storage:",S,E)}break}case"message_deleted":{let S=h.data?.message_id;if(!S){x();continue}let P=this.client?.activeChannels?.[v];P?.state&&(P.state.removeMessage({id:S}),P.state.removePinnedMessage({id:S}));try{await this.storage.deleteE2eeMessage(S)}catch(E){b("warn","[Encryption] Failed to delete message from storage during sync:",S,E)}this.client?.dispatchEvent?.({type:"message.deleted",message:{id:S},cid:v}),b("info","[Encryption] Sync: message deleted:",S);break}case"message_updated":{let C=h.data,S=C?.message;if(!S){x();continue}let P=S,E=!1;try{if(S.content_type==="mls"&&S.mls_ciphertext){let G={...S,updated_at:S.updated_at||C.created_at},Q=this._resolveMessageE2eeGroupId(G,r),{decrypted:ce,buffered:q}=await this.decryptApplicationMessages(v,[G],Q);q.length>0&&(E=!0,a.push(...q.map(_e=>this._toPendingSnapshot(v,"message_updated",_e,g.created_at,m))),await d()),ce[0]&&(P=await this._buildFullMessageWithQuoted(ce[0],S))}else{let G=await this.storage.loadE2eeMessage(S.id);G&&await this.storage.saveE2eeMessage({...G,text:S.text??G.text,updated_at:C.created_at})}}catch(G){b("warn","[Encryption] Failed to update message in storage during sync:",S.id,G)}if(E){b("info","[Encryption] Sync: buffered message update:",S.id),o+=1,c=g;continue}let k=this.client?.activeChannels?.[v];k?.state&&k.state.addMessageSorted(P,!1,!1),this.client?.dispatchEvent?.({type:"message.updated",message:P,cid:v}),b("info","[Encryption] Sync: message updated:",S.id);break}case"message_pin":{let C=h.data,S=C?.message;if(!S){x();continue}let P=this.client?.activeChannels?.[v];P?.state&&(C.action==="message.pinned"?P.state.addPinnedMessage(S):P.state.removePinnedMessage(S)),b("info","[Encryption] Sync: message",C.action,":",S.id);break}default:break}x()}return a.length>0&&(await u(),a.length===0&&t.length>0&&(c=this._eventCursorFromEnvelope(t[t.length-1],c.created_at))),this._publishDecryptedMessages(i),b("info","[Encryption] Processed",t.length,"events for:",e),{processedEventCursor:c,processedEvents:o,bufferedMessages:a.length,decrypted:i,maxObservedEpoch:l}}async _syncChannelFromCursor(e,t,s=100){let r=t,i=this._makeSyncState(e,"ready",t,t);for(;;){let a=r,c=(await this.e2eeClient.scopeSync({[e]:a},s)).channels?.[e];if(!c?.events||c.events.length===0){let v=await this._flushPendingSnapshotsForScope(e);return i=this._makeSyncState(e,c?.has_more?"needs_retry":"ready",a,a,{server_next_cursor:c?.next_cursor?.created_at,server_next_event_cursor:c?.next_cursor,has_more:!!c?.has_more,needs_retry:!!c?.has_more,buffered_messages:v.pending.length}),this._emitSyncState(i),i}let l=await this._processChannelEvents(e,c.events,a),p=this._eventCursorFromEnvelope(c.events[c.events.length-1],a.created_at),d=c.next_cursor??p,{processedEventCursor:u,cursorLagged:h,durableCursor:m}=this._resolveProcessedEventCursor(l,a,d),g=u.created_at,_=h;if(i=this._makeSyncState(e,_?"needs_retry":c.has_more?"syncing":"ready",a,u,{server_next_cursor:d.created_at,server_next_event_cursor:d,has_more:!!c.has_more,needs_retry:!!c.has_more||_,processed_events:l.processedEvents,buffered_messages:l.bufferedMessages,max_observed_epoch:l.maxObservedEpoch}),this._emitSyncState(i),lr(m,a)>0&&(r=m,await this._saveEncryptionSyncCheckpoint({scopeCursors:{[e]:m}})),_||!c.has_more)return i}this._pendingEvictions.size>0&&await this._persistPendingEvictions()}async syncNewChannel(e,t,s){if(this.groups.has(s))return{cid:s,status:"ready",epoch:this.getEpoch(s),sync_state:this.getSyncState(s)||void 0};let r=this.client?.activeChannels?.[s],i=await this._loadScopeSyncCursor(s),a=this._membershipBoundedEventCursor(r,i),o=await this._syncChannelFromCursor(s,a,100);if(!this.groups.has(s)){b("info","[Encryption] No welcome found for:",s,"\u2192 attempting external join");try{let c=await this.joinExternal(e,t,s),l=await this.syncAfterExternalJoin(e,t,s);return b("info","[Encryption] External join fallback succeeded:",s),{cid:s,status:l.status==="needs_retry"?"needs_retry":"joined_external",epoch:c.epoch,sync_state:l.sync_state}}catch(c){if(b("warn","[Encryption] External join fallback failed:",s,c),c?.code==="stale_group_info"){let l=this._makeSyncState(s,"stale_group_info",a.created_at,o.processed_cursor,{needs_retry:!0,error:c.message});return this._emitSyncState(l),{cid:s,status:"stale_group_info",sync_state:l,error:c.message}}return{cid:s,status:"failed",sync_state:o,error:c.message}}}return{cid:s,status:o.needs_retry?"needs_retry":"joined_welcome",epoch:this.getEpoch(s),sync_state:o}}async syncAfterExternalJoin(e,t,s){if(!this.groups.has(s))return b("warn","[Encryption] syncAfterExternalJoin: no group for",s,"\u2014 skipping"),{cid:s,status:"skipped",error:"no local encryption group"};let r=this.client?.activeChannels?.[s],i=await this._loadScopeSyncCursor(s),a=this._membershipBoundedEventCursor(r,i),o=await this._syncChannelFromCursor(s,a,100);return this.client?.dispatchEvent?.({type:"e2ee.post_join_sync",cid:s}),b("info","[Encryption] syncAfterExternalJoin complete for:",s),{cid:s,status:o.needs_retry?"needs_retry":"ready",epoch:this.getEpoch(s),sync_state:o}}async ensureChannelReady(e,t,s,r={}){let i=r.source;if(!this.initialized)return{cid:s,status:"failed",error:"[Encryption] Not initialized"};if(i==="open"&&await this._isScopeReadyForOpen(s))return await this._flushPendingSnapshotsForScope(s),{cid:s,status:"ready",epoch:this.getEpoch(s),sync_state:this.getSyncState(s)||void 0};let a=this._channelReadyLocks.get(s);if(a)return a;let o=(async()=>{let c=this.client?.activeChannels?.[s];if(c&&!this._isE2eeChannelData(c.data||c))return{cid:s,status:"skipped",error:"channel is not E2EE enabled"};let l=this._resolveChannelE2eeGroupId(s,c);if(l!==s){let v=Bt(l);if(!v)return{cid:s,status:"failed",error:`invalid e2ee_group_id: ${l}`};let y=await this.ensureChannelReady(v.channelType,v.channelId,l,{source:r.source||"inherited_topic"});return{cid:s,status:y.status,epoch:this.getEpoch(l),sync_state:y.sync_state,error:y.error}}if(!this.groups.has(s)){let v=await this.syncNewChannel(e,t,s);return v.sync_state&&!v.sync_state.needs_retry&&v.status!=="failed"&&v.status!=="stale_group_info"&&this.client?.dispatchEvent?.({type:"e2ee.channel_ready",cid:s,sync_state:v.sync_state}),v}let p=await this._loadScopeSyncCursor(s),d=this._getMembershipCreatedAt(c),u=d?this._initialSyncCursor(d):void 0,h=p?.created_at;if(i==="invite_accepted"&&u&&(!h||Yt(u,h)>0)){await this._deleteLocalGroupState(s);let v=await this.syncNewChannel(e,t,s);return v.sync_state&&!v.sync_state.needs_retry&&v.status!=="failed"&&v.status!=="stale_group_info"&&this.client?.dispatchEvent?.({type:"e2ee.channel_ready",cid:s,sync_state:v.sync_state}),v}if(i==="open"&&await this._isScopeReadyForOpen(s,p,c))return await this._flushPendingSnapshotsForScope(s),{cid:s,status:"ready",epoch:this.getEpoch(s),sync_state:this.getSyncState(s)||void 0};let m=this._membershipBoundedEventCursor(c,p),g=await this._syncChannelFromCursor(s,m,100),_={cid:s,status:g.needs_retry?"needs_retry":"ready",epoch:this.getEpoch(s),sync_state:g};return g.needs_retry||this.client?.dispatchEvent?.({type:"e2ee.channel_ready",cid:s,sync_state:g}),_})().finally(()=>{this._channelReadyLocks.delete(s)});return this._channelReadyLocks.set(s,o),o}getGroup(e){return this.groups.get(e)||null}ownsE2eeGroup(e){return this._resolveChannelE2eeGroupId(e,this._getActiveChannel(e))===e&&this.groups.has(e)}getEpoch(e){let t=this.groups.get(e);return t?Number(t.epoch()):-1}createGroup(e){let t=ee.Group.create_with_cid(this.provider,this.identity,e);return this.groups.set(e,t),this._saveGroup(e),b("info","[Encryption] Group created:",e),t}async joinGroup(e,t,s){let r=t?ee.RatchetTree.from_bytes(new Uint8Array(t)):null,i=ee.Group.join_with_welcome(this.provider,new Uint8Array(e),r),a=i.cid();return this.groups.has(a)?(b("info","[Encryption] Already have group, skipping join:",a),i.free(),this.groups.get(a)):(this.groups.set(a,i),await this._saveGroup(a),await this._persistProvider(),await this.safeArchiveCurrentEpochForCid(a,"backup",s),b("info","[Encryption] Joined group via Welcome:",a),i)}_isMissingKeyPackageError(e){let t=String(e?.message||e||"").toLowerCase();return t.includes("no matching key package")||t.includes("key package was found")}async _saveGroup(e){try{await this.storage.saveGroupState(e,!0)}catch(t){b("warn","[Encryption] Failed to save group CID:",e,t)}}async enableE2ee(e,t,s,r,i="member_assisted"){let a=this.createGroup(s),{members:o}=await this.e2eeClient.getKeyPackagesByCid(e,t),c=[];for(let h of o)for(let m of h.key_packages){let g=ee.KeyPackage.from_bytes(new Uint8Array(m.key_package));c.push(g)}let l=a.add_members(this.provider,this.identity,c),p=a.export_ratchet_tree(),d=l.group_info;if(!d||d.length===0)throw a.clear_pending_commit(this.provider),await this._persistProvider(),new Error("[Encryption] enableE2ee: commitBundle.group_info is empty \u2014 cannot proceed");let u;try{u=await this.e2eeClient.enableE2ee(e,t,{welcome:l.welcome,ratchet_tree:p.to_bytes(),epoch:Number(a.epoch()),group_info:d,e2ee_recovery_policy:i})}catch(h){throw b("error","[Encryption] enableE2ee failed, clearing pending commit:",h),a.clear_pending_commit(this.provider),await this._persistProvider(),h}return a.merge_pending_commit(this.provider),await this._persistProvider(),await this.safeArchiveCurrentEpoch(e,t),b("info","[Encryption] E2EE enabled for channel:",s,"epoch:",Number(a.epoch())),u}async createE2eeChannel(e,t,s,r){if(e==="messaging"){let _=this.client?.projectId;if(!_)throw new Error("[Encryption] createE2eeChannel: client.projectId is required for messaging E2EE");t=ee.hash_channel_id(_,r),s=`messaging:${t}`,b("info","[Encryption] createE2eeChannel: computed messaging channelId:",t)}if(!t||!s)throw new Error("[Encryption] createE2eeChannel: channelId and cid are required for non-messaging channels");let i=this.createGroup(s),a=Array.from(new Set(r)).filter(_=>_!==this.userId),{members:o}=await this.e2eeClient.getKeyPackagesByUserIds(r),c=new Set(o.filter(_=>_.key_packages?.length>0).map(_=>_.user_id)),l=a.filter(_=>!c.has(_));if(l.length>0)throw this.groups.delete(s),await this.storage.deleteGroup?.(s),await this._persistProvider(),new Error(`[Encryption] Cannot create E2EE channel. The following members have no uploaded KeyPackages: ${l.join(", ")}. Ask them to sign in once with E2EE enabled, then try again.`);let p=[];for(let _ of o)for(let v of _.key_packages){let y=ee.KeyPackage.from_bytes(new Uint8Array(v.key_package));p.push(y)}p.length===0&&a.length===0&&b("info","[Encryption] createE2eeChannel: no other member KPs found, creating solo group for:",s);let d=p.length>0?i.add_members(this.provider,this.identity,p):i.commit_pending_proposals(this.provider,this.identity),u=i.export_ratchet_tree(),h=d.group_info;if(!h||h.length===0)throw i.clear_pending_commit(this.provider),await this._persistProvider(),new Error("[Encryption] createE2eeChannel: commitBundle.group_info is empty \u2014 cannot proceed");let m=Number(i.epoch());i.merge_pending_commit(this.provider),await this._persistProvider(),b("info","[Encryption] createE2eeChannel: bundle ready for cid:",s,"epoch:",Number(i.epoch()));let g={welcome:p.length>0?d.welcome:new Uint8Array(0),ratchet_tree:u.to_bytes(),group_info:h,epoch:m,cid:s};return e==="messaging"&&(g.channel_id=t),g}_requireCompositeCommitMethods(e){let t=["commit_member_add_with_removals","commit_self_update_with_removals","commit_member_removals"];for(let s of t)if(typeof e?.[s]!="function")throw new Error(`[Encryption] OpenMLS WASM is outdated: missing ${s}()`)}async _collectPendingGhosts(e,t=[]){let s=this.groups.get(e);if(!s)return[];let r=this._pendingEvictions.get(e),i=new Set([...r??[],...t]),a=[];for(let o of i)if(o){if(this.userId&&o===this.userId){r?.has(o)&&(r.delete(o),await this._removePendingEviction(e,o));continue}try{let c=s.members_by_user_id(o);c&&c.length>0?a.push(o):r?.has(o)&&(r.delete(o),await this._removePendingEviction(e,o))}catch{}}return r&&r.size===0&&this._pendingEvictions.delete(e),Array.from(new Set(a))}async _cleanupEvictedGhosts(e,t){if(t.length===0)return;let s=this._pendingEvictions.get(e);if(s){for(let r of t)s.delete(r),await this._removePendingEviction(e,r);s.size===0&&this._pendingEvictions.delete(e),await this._persistPendingEvictions(),b("info","[Encryption] Cleaned up evicted ghosts:",t,"from",e)}}_isActiveChannelMember(e,t){let s=this._getActiveChannel(e);if(!s)return!1;let r=s.data,i=s.state;return(Array.isArray(r?.members)?r.members:[]).some(o=>o?.user_id===t)?!0:!!i?.members?.[t]}async _dropActivePendingEvictions(e,t){let s=[],r=this._pendingEvictions.get(e);for(let i of new Set(t))this._isActiveChannelMember(e,i)&&(r?.has(i)&&(r.delete(i),await this._removePendingEviction(e,i)),s.push(i));return r&&r.size===0&&this._pendingEvictions.delete(e),s.length>0&&(await this._persistPendingEvictions(),b("info","[Encryption] Dropped pending ghosts that are active again:",s,"from",e)),s}async addMembers(e,t,s,r,i=!1){let a=this.groups.get(s);if(!a)throw new Error(`[Encryption] No group for cid: ${s}`);let{members:o}=await this.e2eeClient.getKeyPackagesByUserIds(r),c=[];for(let g of o)for(let _ of g.key_packages){let v=ee.KeyPackage.from_bytes(new Uint8Array(_.key_package));c.push({userId:g.user_id,kp:v})}if(c.length===0)throw new Error("[Encryption] No key packages available for any target user");let l=[];for(let{userId:g}of c)try{let _=a.members_by_user_id(g);_&&_.length>0&&l.push(g)}catch{}this._requireCompositeCommitMethods(a);let p=await this._collectPendingGhosts(s,l),d=c.map(({kp:g})=>g),u=a.commit_member_add_with_removals(this.provider,this.identity,p,d),h=a.export_ratchet_tree(),m=u.group_info;if(!m||m.length===0)throw a.clear_pending_commit(this.provider),await this._persistProvider(),new Error("[Encryption] addMembers: commitBundle.group_info is empty \u2014 cannot proceed");try{let g=this.client?.activeChannels?.[s];if(!g)throw new Error(`[Encryption] No active channel found for cid: ${s}`);await g.addMembersE2ee(r,{commit:u.commit,welcome:u.welcome,ratchet_tree:h.to_bytes(),epoch:Number(a.epoch()),group_info:m})}catch(g){if(vs(g)&&!i)return b("warn","[Encryption] addMembers: epoch_stale, clearing + syncing + retrying"),a.clear_pending_commit(this.provider),await this._persistProvider(),await this.sync(),this.addMembers(e,t,s,r,!0);throw b("error","[Encryption] addMembers failed, clearing pending commit:",g),a.clear_pending_commit(this.provider),await this._persistProvider(),g}return a.merge_pending_commit(this.provider),await this._persistProvider(),await this.safeArchiveCurrentEpoch(e,t),await this._cleanupEvictedGhosts(s,p),b("info","[Encryption] Added",r.length,"users to:",s,"epoch:",Number(a.epoch())),{epoch:Number(a.epoch())}}async _drainPendingEvictions(){if(this._pendingEvictions.size===0)return;let e=new Map(this._pendingEvictions);for(let[t,s]of e){let r=t.indexOf(":"),i=t.substring(0,r),a=t.substring(r+1),o=this.groups.get(t),c=this._getActiveChannel(t);if(!c)continue;if(!this.isDesignatedEvictor(c)){b("info","[Encryption] _drainPendingEvictions: keep queued for",t,"\u2014 this client is not designated evictor");continue}if(!o)continue;let l=await this._collectPendingGhosts(t,Array.from(s));if(l.length!==0)try{this._requireCompositeCommitMethods(o);let p=o.commit_member_removals(this.provider,this.identity,l),d=p.group_info;if(!d||d.length===0)throw o.clear_pending_commit(this.provider),await this._persistProvider(),new Error("[Encryption] _drainPendingEvictions: commitBundle.group_info is empty");await this.e2eeClient.commitEviction(i,a,{target_user_ids:l,commit:p.commit,epoch:Number(o.epoch()),group_info:d}),o.merge_pending_commit(this.provider),await this._persistProvider(),await this._cleanupEvictedGhosts(t,l)}catch(p){o.clear_pending_commit(this.provider),await this._persistProvider();let d=Um(p);if(d){await this.sync(),await this._dropActivePendingEvictions(t,[d]),b("warn","[Encryption] _drainPendingEvictions: target active again, dropped from retry list:",t,d);continue}vs(p)&&(await this.sync(),await this._dropActivePendingEvictions(t,l)),b("warn","[Encryption] _drainPendingEvictions: composite commit failed, queue kept for retry:",t,p)}}}async _persistPendingEvictions(){let e={};for(let[t,s]of this._pendingEvictions)e[t]=Array.from(s);await this.storage.savePendingEvictions(e)}async _removePendingEviction(e,t){let s=await this.storage.loadPendingEvictions(),r=new Set(s[e]??[]);r.delete(t),r.size===0?delete s[e]:s[e]=Array.from(r),await this.storage.savePendingEvictions(s)}async _deleteLocalGroupState(e){let t=this.groups.get(e);if(t){try{typeof t.delete_state=="function"&&t.delete_state(this.provider)}catch(s){b("warn","[Encryption] _deleteLocalGroupState: failed to delete OpenMLS group state for",e,s)}this.groups.delete(e),b("info","[Encryption] _deleteLocalGroupState: deleted local group state for",e)}this._channelReadyUntil.delete(e),await this.storage.deleteGroup?.(e),await this._savePendingSnapshots(e,[]),await this._persistProvider()}leaveGroup(e,t){let s=this._toCursorString(t),r=this.groups.get(e);if(r){try{typeof r.delete_state=="function"&&r.delete_state(this.provider)}catch(i){b("warn","[Encryption] leaveGroup: failed to delete OpenMLS group state for",e,i)}this.groups.delete(e),b("info","[Encryption] leaveGroup: deleted local group state for",e)}this._persistProvider().catch(i=>b("warn",i)),this.storage.deleteGroup?.(e).catch?.(i=>b("warn",i)),this._saveScopeSyncCursor(e,{created_at:s,event_id:At}).catch(i=>b("warn",i)),this._savePendingSnapshots(e,[]).catch(i=>b("warn",i))}async cleanupOrphanedGroups(e){let t=new Set(e),s=[];for(let[r]of this.groups)t.has(r)||s.push(r);for(let r of s)this.groups.delete(r),await this.storage.deleteGroup?.(r),b("info","[Encryption] cleanupOrphanedGroups: removed orphaned group",r);s.length>0&&await this._persistProvider()}_getActiveChannel(e){let t=this.client?.activeChannels||{};if(t[e])return t[e];for(let s of Object.values(t)){let r=s?.state?.topics?.find(i=>i?.cid===e);if(r)return r}}_membershipRoleForChannel(e){if(!this.userId||!e)return;let t=e.state?.members?.[this.userId];if(t?.channel_role)return t.channel_role;let s=e.state?.membership;return s?.channel_role?s.channel_role:(Array.isArray(e.data?.members)?e.data.members:[]).find(a=>a?.user_id===this.userId||a?.user?.id===this.userId)?.channel_role}_isInactiveInviteRole(e){return e==="pending"||e==="rejected"||e==="skipped"}isChannelEncryptionSyncBlocked(e){return this._isInactiveInviteRole(this._membershipRoleForChannel(this._getActiveChannel(e)))}_isEncryptionProcessingBlockedForRoute(e,t){if(t&&t!==e){let s=this._getActiveChannel(e);if(this._resolveChannelE2eeGroupId(e,s)===t)return this.isChannelEncryptionSyncBlocked(t)}return this.isChannelEncryptionSyncBlocked(e)||!!t&&t!==e&&this.isChannelEncryptionSyncBlocked(t)}_shouldLogThrottled(e,t,s){let r=Date.now(),i=e.get(t)||0;if(r-i<s)return!1;if(e.set(t,r),e.size>2e3)for(let[a,o]of e)r-o>s&&e.delete(a);return!0}_logDeferredEncryptionEventOnce(e,t,s,r){let i=`${e}:${t}:${s}:${r||""}`;this._shouldLogThrottled(this._deferredEncryptionEventLogKeys,i,Lm)&&b("info","[Encryption] Deferred encryption event until channel state is ready:",{reason:e,cid:t,groupCid:s,messageId:r})}_safeGroupEpoch(e){try{let t=Number(e?.epoch?.());return Number.isFinite(t)?t:void 0}catch{return}}_isRecoveryVaultLockedOrUnknown(){return!this._recoveryPrivateKey&&this._recoveryVaultKnown!==!1}_isExpectedRecoverableDecryptFailure(e,t,s){let r=this._safeGroupEpoch(e),i=typeof t.mls_epoch=="number"?t.mls_epoch:void 0,a=r!==void 0&&i!==void 0&&i<=r,o=s.includes("Generation is too old")||s.includes("AEAD decryption")||s.includes("epoch differs from the group");return this._isRecoveryVaultLockedOrUnknown()&&(a||o)||a}_logExpectedDecryptFailureOnce(e,t,s,r){let i=`${e}:${this._messageVersionKey(t)}:${r}`;this._shouldLogThrottled(this._expectedDecryptLogKeys,i,Lm)&&b("info","[Encryption] Message is waiting for encrypted history recovery:",{cid:e,msgId:t.id,groupEpoch:s,msgEpoch:t.mls_epoch,vaultLocked:this._isRecoveryVaultLockedOrUnknown(),error:r})}async queuePendingEviction(e,t){if(!t||this.userId&&t===this.userId)return!1;let s=this._getActiveChannel(e);if(!s||!this.isDesignatedEvictor(s))return!1;let r=this.groups.get(e);if(!r)return!1;try{let a=r.members_by_user_id(t);if(!a||a.length===0)return!1}catch{return!1}let i=this._pendingEvictions.get(e)??new Set;return i.add(t),this._pendingEvictions.set(e,i),await this._persistPendingEvictions(),b("info","[Encryption] Queued pending eviction for",t,"in",e),!0}isDesignatedEvictor(e){if(!this.userId)return!1;let t=e.data,s=e.state,r=t?.created_by?.id||t?.channel?.created_by?.id;if(r&&r===this.userId)return!0;let i=new Set(Object.keys(s?.watchers||{}));if(i.add(this.userId),r&&i.has(r))return!1;let a=s?.members?Object.values(s.members):[],c=(Array.isArray(t?.members)&&t.members.length>0?t.members:a).filter(l=>(l.channel_role||"")==="moder").map(l=>l.user_id).filter(l=>!!(l&&i.has(l))).sort();return c.length>0&&c[0]===this.userId}async evictMember(e,t,s,r,i=!1,a=!1){if(!this.provider||!this.identity||!this.client||!this.storage||!this.e2eeClient)throw new Error("[Encryption] Not initialized");if(!i&&this.userId&&r===this.userId)throw new Error("[Encryption] evictMember cannot remove the current user; use channel.leaveChannelE2ee() for self-leave");let o=this.groups.get(s);if(!o){b("warn","[Encryption] evictMember: no local group for",s,"\u2014 skipping");return}b("info","[Encryption] Evicting member:",r,"from:",s,"(selfLeft:",i,")");let c=!0;try{let u=o.members_by_user_id(r);c=!!(u&&u.length>0)}catch{}let l=await this._collectPendingGhosts(s,[r]);if(!c&&!i)throw new Error(`[Encryption] evictMember: target ${r} has no encryption leaf in ${s}`);if(l.length===0){if(i){await this._removePendingEviction(s,r);return}throw new Error(`[Encryption] evictMember: no encryption leaves to remove for ${r} in ${s}`)}l.length>1&&b("info","[Encryption] evictMember: bundling",l.length-1,"ghosts with target eviction");let p;try{this._requireCompositeCommitMethods(o),p=o.commit_member_removals(this.provider,this.identity,l)}catch(u){throw b("error","[Encryption] evictMember: WASM commit_member_removals failed:",u),u}let d=p.group_info;if(!d||d.length===0)throw b("error","[Encryption] evictMember: commitBundle has no group_info"),o.clear_pending_commit(this.provider),await this._persistProvider(),new Error("[Encryption] evictMember: commitBundle.group_info is empty \u2014 cannot proceed");try{if(i){if(!this.e2eeClient)throw new Error("[Encryption] e2eeClient not initialized");await this.e2eeClient.commitEviction(e,t,{target_user_ids:l,commit:p.commit,epoch:Number(o.epoch()),group_info:d})}else{let u=this.client?.activeChannels?.[s];if(!u)throw new Error(`[Encryption] No active channel found for cid: ${s}`);await u.removeMembersE2ee([r],{commit:p.commit,epoch:Number(o.epoch()),group_info:d})}}catch(u){let h=Um(u);if(i&&h){b("warn","[Encryption] evictMember: target active again, dropping pending eviction:",h),o.clear_pending_commit(this.provider),await this._persistProvider(),await this.sync(),await this._dropActivePendingEvictions(s,[h]);return}if(vs(u)&&!a){b("warn","[Encryption] evictMember: epoch_stale \u2014 syncing before retry/drop",r),o.clear_pending_commit(this.provider),await this._persistProvider(),await this.sync(),i&&await this._dropActivePendingEvictions(s,l);return}throw o.clear_pending_commit(this.provider),await this._persistProvider(),u}o.merge_pending_commit(this.provider),await this._persistProvider(),await this.safeArchiveCurrentEpoch(e,t),await this._cleanupEvictedGhosts(s,l),b("info","[Encryption] Evicted",r,"from:",s,"epoch:",Number(o.epoch()))}async joinExternal(e,t,s){if(!this.initialized)throw new Error("[Encryption] Not initialized");for(let r=0;r<2;r++){let i=await this.e2eeClient.getGroupInfo(e,t);if(i.is_stale)throw sx(s);let a=ee.Group.join_external(this.provider,this.identity,new Uint8Array(i.group_info),null),o=a.group;if(!o)throw new Error("[Encryption] External join failed: no group returned");try{await this.e2eeClient.externalJoin(e,t,{commit:a.commit,epoch:Number(o.epoch())})}catch(c){if(b("error","[Encryption] External join failed, clearing pending commit:",c),o.clear_pending_commit(this.provider),await this._persistProvider(),vs(c)&&r===0)continue;throw c}return o.merge_pending_commit(this.provider),this.groups.set(s,o),await this._saveGroup(s),await this._persistProvider(),await this._uploadGroupInfo(e,t,o),await this.safeArchiveCurrentEpoch(e,t),b("info","[Encryption] External join completed for:",s,"epoch:",Number(o.epoch())),{epoch:Number(o.epoch()),status:"joined_external"}}throw new Error("[Encryption] External join failed after retry")}async keyRotation(e,t=!1){if(!this.initialized)throw new Error("[Encryption] Not initialized");let s=this.groups.get(e);if(!s)throw new Error(`[Encryption] No group for cid: ${e}`);let r=e.indexOf(":");if(r<0)throw new Error(`[Encryption] Invalid cid format: ${e}`);let i=e.substring(0,r),a=e.substring(r+1);this._requireCompositeCommitMethods(s);let o=await this._collectPendingGhosts(e),c=s.commit_self_update_with_removals(this.provider,this.identity,o),l=c.group_info;if(!l||l.length===0)throw s.clear_pending_commit(this.provider),await this._persistProvider(),new Error("[Encryption] keyRotation: bundle.group_info is empty \u2014 cannot proceed");let p=l;try{await this.e2eeClient.keyRotation(i,a,{commit:c.commit,epoch:Number(s.epoch()),group_info:p})}catch(d){if(vs(d)&&!t)return b("warn","[Encryption] keyRotation: epoch_stale, clearing + syncing + retrying"),s.clear_pending_commit(this.provider),await this._persistProvider(),await this.sync(),this.keyRotation(e,!0);throw b("error","[Encryption] keyRotation failed, clearing pending commit:",d),s.clear_pending_commit(this.provider),await this._persistProvider(),d}return s.merge_pending_commit(this.provider),await this._cleanupEvictedGhosts(e,o),await this._saveGroup(e),await this._persistProvider(),await this.safeArchiveCurrentEpoch(i,a),b("info","[Encryption] Key rotation completed for:",e,"epoch:",Number(s.epoch())),{epoch:Number(s.epoch())}}async _uploadGroupInfo(e,t,s){try{let r=s.export_group_info(this.provider,this.identity,!0);if(b("info","[Encryption] Exported group_info for:",e,t,"epoch:",Number(s.epoch())),!e||!t){b("warn","[Encryption] Invalid CID format for GroupInfo upload:",e,t);return}await this.e2eeClient.uploadGroupInfo(e,t,{group_info:r,epoch:Number(s.epoch())}),b("info","[Encryption] GroupInfo uploaded for:",e,t,"epoch:",Number(s.epoch()))}catch(r){b("error","[Encryption] Failed to upload GroupInfo for:",e,t,r)}}encryptMessage(e,t,s){let r=this.groups.get(e);if(!r)throw new Error(`[Encryption] No group for cid: ${e}`);let i=new TextEncoder,a=JSON.stringify(t),o=i.encode(a),c=s?r.create_message_with_aad(this.provider,this.identity,o,s):r.create_message(this.provider,this.identity,o);try{r.save_state(this.provider)}catch(l){b("warn","[Encryption] Failed to save group state after encrypt:",l)}return c}decryptMessage(e,t,s){let r=this.groups.get(e);if(!r)throw new Error(`[Encryption] No group for cid: ${e}`);let i=r.process_message(this.provider,new Uint8Array(t)),a=i.aad?new Uint8Array(i.aad):void 0;if(s&&!bc(a,s))throw new Error("[Encryption] MLS AAD mismatch");try{r.save_state(this.provider)}catch(p){b("warn","[Encryption] Failed to save group state after decrypt:",p)}let o=new TextDecoder,c=i.content?o.decode(i.content):"",l;try{let p=JSON.parse(c);p&&typeof p=="object"&&typeof p.text=="string"?l=p:l={text:c}}catch{l={text:c}}return b("info","[Encryption] Decrypted message:",l.text),{payload:l,messageType:i.message_type,senderIndex:i.sender_index,epoch:Number(i.epoch),aad:a}}async processCommit(e,t,s,r,i={}){if(this.isChannelEncryptionSyncBlocked(e))return this._logDeferredEncryptionEventOnce("pending_invite_commit",e,e),null;let a=this.groups.get(e);if(!a)return b("warn","[Encryption] processCommit: no group for",e),null;if(s!==void 0&&s>=0){let c=Number(a.epoch());if(b("info","[Encryption] processCommit: group epoch:",c,"event epoch:",s),c>=s)return b("info",`[Encryption] processCommit: commit at epoch ${s} already applied (group at ${c}), skipping:`,e),null}let o=this.provider.to_bytes();try{let c=a.process_message(this.provider,new Uint8Array(t));b("info","[Encryption] Commit processed for:",e,"epoch:",Number(a.epoch())),await this._persistProvider(),await this.safeArchiveCurrentEpochForCid(e,"backup",r);let l=this._pendingEvictions.get(e);if(l&&l.size>0){let p=!1;for(let d of[...l])try{let u=a.members_by_user_id(d);(!u||u.length===0)&&(l.delete(d),p=!0)}catch{}p&&(l.size===0&&this._pendingEvictions.delete(e),this._persistPendingEvictions().catch(d=>b("warn",d)))}return i.flushPending!==!1&&await this._flushPendingSnapshotsForScope(e),c}catch(c){let l=c.message||"";if(l.includes("epoch differs"))return b("warn","[Encryption] processCommit: commit already applied (epoch mismatch), skipping:",e),null;if(l.includes("missing a proposal")){b("warn","[Encryption] processCommit: missing proposal \u2014 repair reset required for",e),this.provider=ee.Provider.from_bytes(new Uint8Array(o));let p=new Error(`[Encryption] Missing proposal while processing commit for ${e}`);throw p.code="missing_proposal",p}throw b("warn","[Encryption] processCommit failed, rolling back Provider snapshot:",l),this.provider=ee.Provider.from_bytes(new Uint8Array(o)),c}}_decryptPromises=new Map;_messageVersionKey(e){let t=e.updated_at||e.created_at||"",s=t?new Date(t).getTime():Number.NaN,r=Number.isFinite(s)?new Date(s).toISOString():t;return`${e.id}:${r}`}_storedMessageCoversVersion(e,t){let s=t.updated_at;if(!s)return!0;let r=e.updated_at||e.created_at;return new Date(r).getTime()>=new Date(s).getTime()}_messageTypeForPayload(e,t){return e.sticker_url?"sticker":typeof t=="string"&&t?t:"regular"}_dateishToIso(e){if(e instanceof Date)return e.toISOString();if(typeof e=="string"&&e)return e;if(typeof e=="number"&&Number.isFinite(e))return new Date(e).toISOString()}_collectActiveChannelEnvelopes(e){let t=this.client?.activeChannels?.[e],s=t?.state?.messageSets||[],r=t?.state?.pinnedMessages||[],i=[...s.flatMap(o=>o.messages||[]),...r],a=new Map;for(let o of i)o?.id&&a.set(o.id,o);return a}_buildArchiveMessageEnvelope(e,t,s,r){let i=s?.user?.id||s?.user_id||t.user?.id||t.user_id||r.own_message&&this.userId||void 0,a=Ue(i,s?.user,t.user,i?this.client?.state?.users?.[i]:void 0,i===this.userId?this.client?.user:void 0)||(i?{id:i}:void 0),o=this._dateishToIso(s?.created_at)||this._dateishToIso(t.created_at)||new Date().toISOString(),c=this._dateishToIso(s?.updated_at)||this._dateishToIso(t.updated_at);return{...s||{},...t,id:t.message_id,cid:e,user:a,user_id:i,created_at:o,updated_at:c,mls_epoch:t.mls_epoch,mls_ciphertext:new Uint8Array(t.mls_ciphertext),archive_epoch:r.epoch!==void 0?Number(r.epoch):t.mls_epoch,archive_generation:r.generation,archive_own_message:r.own_message,archive_sender_index:r.sender_index}}_storedFromPayload(e,t,s,r){let i=s.user?.id||r?.user_id||"",a=i?this.client?.state?.users?.[i]:void 0,o=Ue(i,a,s.user,r?.user,i===this.userId?this.client?.user:void 0);return{id:s.id,cid:e,content_type:"standard",text:t.text,attachments:t.attachments||r?.attachments,sticker_url:t.sticker_url||r?.sticker_url,poll_type:t.poll_type||r?.poll_type,poll_choice_counts:t.poll_choice_counts||r?.poll_choice_counts,latest_poll_choices:t.latest_poll_choices||r?.latest_poll_choices,old_texts:t.old_texts||r?.old_texts,is_edited:!!(t.old_texts?.length||r?.old_texts?.length),user_id:i,user:o,created_at:r?.created_at||s.created_at||new Date().toISOString(),updated_at:s.updated_at||s.created_at||r?.updated_at,type:this._messageTypeForPayload(t,r?.type||s.type),parent_id:s.parent_id||r?.parent_id,quoted_message_id:s.quoted_message_id||r?.quoted_message_id,forward_cid:s.forward_cid||r?.forward_cid,forward_message_id:s.forward_message_id||r?.forward_message_id,forward_parent_cid:s.forward_parent_cid||r?.forward_parent_cid,e2ee_attachment_ids:s.e2ee_attachment_ids||r?.e2ee_attachment_ids,mentioned_users:s.mentioned_users||r?.mentioned_users,mentioned_all:s.mentioned_all!==void 0?s.mentioned_all:r?.mentioned_all}}_normalizeQuotedMessagePreview(e){if(!e||typeof e!="object")return;let t=e;if(!t.id)return;let s=t.user_id||t.user?.id,r=typeof s=="string"&&s?this.client?.state?.users?.[s]:void 0;return{...t,content_type:t.content_type||"standard",type:t.type||"regular",user_id:s||t.user_id,user:Ue(s,r,t.user)||(s?{id:s}:void 0),attachments:t.attachments||[]}}_isRenderableQuotedMessage(e){return e?!!(typeof e.text=="string"&&e.text.trim()||Array.isArray(e.attachments)&&e.attachments.length>0||typeof e.sticker_url=="string"&&e.sticker_url||e.type==="sticker"):!1}_findQuotedMessageInActiveChannels(e){let t=Object.values(this.client?.activeChannels||{});for(let s of t){let r=s?.state,i=Array.isArray(r?.messageSets)?r.messageSets:[];for(let l of i){let d=(Array.isArray(l?.messages)?l.messages:[]).find(h=>h?.id===e),u=this._normalizeQuotedMessagePreview(d);if(u)return u}let o=(Array.isArray(r?.pinnedMessages)?r.pinnedMessages:[]).find(l=>l?.id===e),c=this._normalizeQuotedMessagePreview(o);if(c)return c}}async _resolveQuotedMessagePreview(e,t){let s=this._normalizeQuotedMessagePreview(t);if(this._isRenderableQuotedMessage(s)||typeof e!="string"||!e)return s;let r=this._findQuotedMessageInActiveChannels(e);if(this._isRenderableQuotedMessage(r))return r;try{let i=await this.storage.loadE2eeMessage(e),a=this._normalizeQuotedMessagePreview(i);return this._isRenderableQuotedMessage(a)?a:s}catch(i){return b("warn","[Encryption] Failed to hydrate quoted message preview:",{quotedMessageId:e,err:i}),s}}_expectedAadForMessage(e,t,s){let r=Array.isArray(s.e2ee_attachment_ids)?s.e2ee_attachment_ids:void 0,i={cid:e,e2ee_group_id:t,message_id:s.id,forward_cid:typeof s.forward_cid=="string"?s.forward_cid:void 0,forward_message_id:typeof s.forward_message_id=="string"?s.forward_message_id:void 0,forward_parent_cid:typeof s.forward_parent_cid=="string"?s.forward_parent_cid:void 0,e2ee_attachment_ids:r};return Di(i)?Ui(i):void 0}_manifestAttachmentIds(e){if(!Array.isArray(e.attachments))return[];let t=[];for(let s of e.attachments)s&&typeof s=="object"&&s.version===1&&typeof s.attachment_id=="string"&&t.push(s.attachment_id);return t}_validateEnvelopeAttachmentIds(e,t){let s=Array.isArray(e.e2ee_attachment_ids)?e.e2ee_attachment_ids:[],r=this._manifestAttachmentIds(t),i=Xn(s),a=Xn(r);if(i.length!==a.length)throw new Error("[Encryption] E2EE attachment manifest/envelope id mismatch");for(let o=0;o<i.length;o+=1)if(i[o]!==a[o])throw new Error("[Encryption] E2EE attachment manifest/envelope id mismatch")}async processE2eeMessage(e,t){let s=this._messageVersionKey(t);if(this._decryptPromises.has(s))return b("info","[Encryption] processE2eeMessage: deduplicating concurrent request via EncryptionPlaintextCache:",s),this._decryptPromises.get(s);let r=this._processE2eeMessageInternal(e,t);this._decryptPromises.set(s,r);try{return await r}finally{this._decryptPromises.delete(s)}}async _processE2eeMessageInternal(e,t){let s=t.mls_ciphertext;if(!s)return null;let r=this._messageVersionKey(t),i=typeof t.cid=="string"&&t.cid||e,a=this._resolveMessageE2eeGroupId(t,e);if(this._isEncryptionProcessingBlockedForRoute(i,a))return await this._rememberPendingE2eeSnapshot(i,t),this._logDeferredEncryptionEventOnce("pending_invite_message",i,a,t.id),null;if(this.isScopeRepairing(a)){b("info","[Encryption] processE2eeMessage: repair in progress, waiting for scope:",a,t.id);try{await this.waitForScopeRepair(a)}catch{}let l=await this.storage.loadE2eeMessage(t.id);if(l&&this._storedMessageCoversVersion(l,t))return this._decryptedMsgIds.add(r),await this._clearRepairIssue(i,t),await this._buildFullMessageWithQuoted(l,t)}if(this._syncing){b("info","[Encryption] processE2eeMessage: sync in progress, waiting for completion:",t.id);try{await this.waitForSync()}catch{}if(this._decryptedMsgIds.has(r)){b("info","[Encryption] processE2eeMessage: decrypted by sync (post-wait), returning cached:",r);let p=await this.storage.loadE2eeMessage(t.id);return p&&this._storedMessageCoversVersion(p,t)?(await this._clearRepairIssue(i,t),await this._buildFullMessageWithQuoted(p,t)):null}let l=await this.storage.loadE2eeMessage(t.id);if(l&&this._storedMessageCoversVersion(l,t))return this._decryptedMsgIds.add(r),await this._clearRepairIssue(i,t),await this._buildFullMessageWithQuoted(l,t)}if(this._decryptedMsgIds.has(r)){b("info","[Encryption] processE2eeMessage: already decrypted (in-memory), skipping:",r);let l=await this.storage.loadE2eeMessage(t.id);return l&&this._storedMessageCoversVersion(l,t)?(await this._clearRepairIssue(i,t),await this._buildFullMessageWithQuoted(l,t)):null}let o=await this.storage.loadE2eeMessage(t.id);if(o&&this._storedMessageCoversVersion(o,t))return b("info","[Encryption] processE2eeMessage: already decrypted (IndexedDB), skipping:",r),this._decryptedMsgIds.add(r),await this._clearRepairIssue(i,t),await this._buildFullMessageWithQuoted(o,t);let c=this.groups.get(a);if(!c)return await this._rememberPendingE2eeSnapshot(i,t),this._logDeferredEncryptionEventOnce("missing_local_group",i,a,t.id),await this._recordRepairIssue(i,t,"missing_local_snapshot",!1),null;b("info","[Encryption] processE2eeMessage:",{msgId:t.id,cid:i,groupCid:a,groupEpoch:Number(c.epoch()),msgEpoch:t.mls_epoch,senderId:t.user?.id});try{let l=s instanceof Uint8Array?s:new Uint8Array(s),p=this._expectedAadForMessage(i,a,t),{payload:d,messageType:u}=this.decryptMessage(a,l,p);if(this._validateEnvelopeAttachmentIds(t,d),this._decryptedMsgIds.add(r),u===0){let h=await this.storage.loadE2eeMessage(t.id),m=this._storedFromPayload(i,d,t,h);return await this.storage.saveE2eeMessage(m),await this._clearRepairIssue(i,t),await this._persistProvider(),await this._buildFullMessageWithQuoted(m,t)}}catch(l){let p=l.message||"";if(this._isForwardSecrecyConsumedError(p))return b("warn","[Encryption] Forward secrecy: message already consumed, cannot re-decrypt:",t.id,{groupEpoch:this._safeGroupEpoch(c),msgEpoch:t.mls_epoch}),await this._recordRepairIssue(i,t,"forward_secrecy_consumed",!1),null;let d=this._safeGroupEpoch(c);this._isExpectedRecoverableDecryptFailure(c,t,p)?(await this._rememberPendingE2eeSnapshot(i,t),this._logExpectedDecryptFailureOnce(i,t,d,p),await this._recordRepairIssue(i,t,"decrypt_error",!1)):(await this._rememberPendingE2eeSnapshot(i,t),b("error","[Encryption] Failed to decrypt message:",i,{msgId:t.id,groupEpoch:d,msgEpoch:t.mls_epoch,error:p}),await this._recordRepairIssue(i,t,"decrypt_error"))}return null}_isForwardSecrecyConsumedError(e){return e.includes("forward secrecy")||e.includes("SecretReuseError")||e.includes("requested secret was deleted")}_buildFullMessage(e,t){let s=e.user_id||e.user?.id||t.user?.id||t.user_id||"",r=s?this.client?.state?.users?.[s]:void 0,i=Ue(s,r,e.user,t.user,s===this.userId?this.client?.user:void 0);return{id:e.id,cid:e.cid,user_id:s,user:i,type:e.type||t.type||"regular",created_at:e.created_at,content_type:"standard",text:e.text,attachments:e.attachments||[],sticker_url:e.sticker_url,poll_type:e.poll_type,poll_choice_counts:e.poll_choice_counts,latest_poll_choices:e.latest_poll_choices,old_texts:e.old_texts,is_edited:e.is_edited,e2ee_status:e.e2ee_status||null,parent_id:e.parent_id||t.parent_id,quoted_message_id:e.quoted_message_id||t.quoted_message_id,quoted_message:e.quoted_message||t.quoted_message,forward_cid:t.forward_cid,forward_message_id:t.forward_message_id,forward_parent_cid:t.forward_parent_cid,e2ee_attachment_ids:t.e2ee_attachment_ids||e.e2ee_attachment_ids,mentioned_users:e.mentioned_users||t.mentioned_users,mentioned_all:e.mentioned_all||t.mentioned_all,latest_reactions:t.latest_reactions||[],reaction_counts:t.reaction_counts,pinned_by:t.pinned_by,pinned_at:t.pinned_at,updated_at:e.updated_at||t.updated_at}}async _buildFullMessageWithQuoted(e,t){let s=this._buildFullMessage(e,t),r=await this._resolveQuotedMessagePreview(s.quoted_message_id,s.quoted_message);return r&&(s.quoted_message=r),s}async uploadE2eeAttachments(e,t,s,r={}){if(!this.e2eeClient)throw new Error("[Encryption] E2EE client is not initialized");let i=this.e2eeClient;if(s.length===0)return{attachments:[],e2ee_attachment_ids:[]};if(s.length>10)throw new Error("[Encryption] E2EE messages support at most 10 attachments");let a=[],o=[],c=this._e2eeAttachmentMultipartEnabled;for(let l=0;l<s.length;l+=1){let p=s[l],d=q=>r.onProgress?.({fileIndex:l,...q});r.onProgress?.({fileIndex:l,phase:"generating_preview",loaded:0,total:p.size,percentage:0});let u=await Ac(p),h=u?.blob,m=r.displayOverrides?.get(l)||{};d({phase:"generating_preview",loaded:p.size,total:p.size,percentage:100});let g={name:p.name,mime_type:p.type,size:p.size,width:u?.originalWidth,height:u?.originalHeight,duration:u?.duration,...m},_=zi(p.size),v;if(h)try{v=await $i(h,{kind:"preview",cryptoProvider:this._attachmentCryptoProvider,display:{name:p.name?`${p.name}.preview.jpg`:void 0,mime_type:"image/jpeg",size:h.size,preview_of:"original",width:u?.previewWidth,height:u?.previewHeight},onProgress:d})}catch{v=void 0}let y=async q=>{if((q.upload_mode||"single_put")==="multipart"){if(!q.multipart)throw new Error("[Encryption] E2EE attachment multipart init did not include multipart data");let W=await Pc(p,{kind:"original",cryptoProvider:this._attachmentCryptoProvider,display:g,multipart:q.multipart,uploadConcurrency:this._e2eeAttachmentMultipartUploadConcurrency,onProgress:d,signal:r.signal});return{manifestAsset:or(q.asset_id,W.encrypted),completeAsset:{asset_id:q.asset_id,multipart:{parts:W.parts}}}}if(!q.put_url)throw new Error("[Encryption] E2EE attachment init did not return original PUT URL");let F=await $i(p,{kind:"original",cryptoProvider:this._attachmentCryptoProvider,display:g,onProgress:d});return await Vi(q.put_url,F.encryptedBlob,d,r.signal),{manifestAsset:or(q.asset_id,F)}},x=async(q,_e)=>{for(let F=0;F<2;F+=1)try{await i.completeAttachment(e,t,q,_e);return}catch(W){if(Im(W)||F===1)throw W;await Xw(500)}},C=async()=>{let q=await i.initAttachment(e,t,{idempotency_key:rn(this._attachmentCryptoProvider),assets:[{kind:"original",cipher_size_estimate:_}]},{multipart:c}),_e=q.assets.find(X=>X.kind==="original");if(!_e)throw new Error("[Encryption] E2EE attachment init did not return original asset");let F=await y(_e);d({phase:"completing",loaded:F.manifestAsset.cipher_size,total:F.manifestAsset.cipher_size,percentage:100});let W={completion_lease_id:rn(this._attachmentCryptoProvider),...F.completeAsset?{assets:[F.completeAsset]}:{}};return await x(q.attachment_id,W),Wi({attachment_id:q.attachment_id,assets:[F.manifestAsset]})};if(!v){let q=await C();a.push(q),o.push(q.attachment_id);continue}let S=await i.initAttachment(e,t,{idempotency_key:rn(this._attachmentCryptoProvider),assets:[{kind:"original",cipher_size_estimate:_},{kind:"preview",cipher_size_estimate:v.cipher_size}]},{multipart:c}),P=S.assets.find(q=>q.kind==="original"),E=S.assets.find(q=>q.kind==="preview");if(!P)throw new Error("[Encryption] E2EE attachment init did not return original asset");if(!E)throw new Error("[Encryption] E2EE attachment init did not return preview asset");if(!E.put_url)throw new Error("[Encryption] E2EE attachment init did not return preview PUT URL");let k=await y(P);try{await Vi(E.put_url,v.encryptedBlob,d,r.signal)}catch{i.deleteAttachment(e,t,S.attachment_id).catch(()=>{});let q=await C();a.push(q),o.push(q.attachment_id);continue}let G=k.manifestAsset.cipher_size+v.cipher_size;d({phase:"completing",loaded:G,total:G,percentage:100});let Q={completion_lease_id:rn(this._attachmentCryptoProvider),...k.completeAsset?{assets:[k.completeAsset]}:{}};await x(S.attachment_id,Q);let ce=Wi({attachment_id:S.attachment_id,assets:[k.manifestAsset,or(E.asset_id,v)]});a.push(ce),o.push(S.attachment_id)}return{attachments:a,e2ee_attachment_ids:o}}async createE2eeAttachmentStreamUrl(e,t,s,r="original",i={}){if(!this.e2eeClient)throw new Error("[Encryption] E2EE client is not initialized");return await Uc({...i,channelType:e,channelId:t,manifest:s,kind:r,renewGrant:async()=>{let a=s.assets.find(o=>o.kind===r)||(r==="original"?s.assets[0]:void 0);if(!a)throw new Error("[Encryption] E2EE attachment manifest has no streamable asset");return await this.e2eeClient.downloadAttachmentGrant(e,t,s.attachment_id,a.asset_id)}})}async downloadE2eeAttachmentAsset(e,t,s,r="original",i={}){if(!this.e2eeClient)throw new Error("[Encryption] E2EE client is not initialized");let a=s.assets.find(l=>l.kind===r)||(r==="original"?s.assets[0]:void 0);if(!a)throw new Error("[Encryption] E2EE attachment manifest has no assets");i.onProgress?.({phase:"granting",loaded:0,total:1,percentage:0});let o=await this.e2eeClient.downloadAttachmentGrant(e,t,s.attachment_id,a.asset_id);i.onProgress?.({phase:"granting",loaded:1,total:1,percentage:100});let c=await Tc(o.download_url,i.onProgress);return await Mc(c,a,this._attachmentCryptoProvider,i.onProgress)}async queryE2eeAttachmentMessages(e,t,s={}){if(!this.e2eeClient)throw new Error("[Encryption] E2EE client is not initialized");let r=await this.e2eeClient.queryE2eeAttachments(e,t,s),i=r.attachments.map(c=>c.message_id),a=this.storage.loadE2eeMessages?await this.storage.loadE2eeMessages(i):new Map;if(!this.storage.loadE2eeMessages)for(let c of i){let l=await this.storage.loadE2eeMessage(c);l&&a.set(c,l)}return{attachments:r.attachments.map(c=>this._mapE2eeAttachmentProjectionToDisplayItem(c,a.get(c.message_id))),next_cursor:r.next_cursor,has_more:r.has_more}}_mapE2eeAttachmentProjectionToDisplayItem(e,t){let r=(Array.isArray(t?.attachments)?t?.attachments:[]).find(_=>!!(_&&typeof _=="object"&&_.version===1&&_.attachment_id===e.attachment_id&&Array.isArray(_.assets))),i=e.assets.find(_=>_.kind==="original")||e.assets[0];if(!r)return{id:e.attachment_id,attachment_type:"file",user_id:e.created_by_user_id,cid:e.cid,url:"",thumb_url:"",file_name:"Encrypted attachment",content_type:"application/octet-stream",content_length:i?.cipher_size||0,content_disposition:"attachment",message_id:e.message_id,created_at:e.created_at,updated_at:e.updated_at,e2ee_manifest_missing:!0};let a=r.assets.find(_=>_.kind==="original")||r.assets[0],o=a?.display||{},c=o.name,l=o.mime_type,p=o.size,d=o.attachment_type,u=typeof c=="string"&&c.trim()?c:"Encrypted attachment",h=typeof l=="string"&&l.trim()?l:"application/octet-stream",m=typeof p=="number"&&Number.isFinite(p)?p:a?.plaintext_size||i?.cipher_size||a?.cipher_size||0,g=d==="voiceRecording"?"voiceRecording":h.startsWith("image/")?"image":h.startsWith("video/")?"video":"file";return{id:e.attachment_id,attachment_type:g,user_id:e.created_by_user_id,cid:e.cid,url:"",thumb_url:"",file_name:u,content_type:h,content_length:m,content_disposition:"attachment",message_id:e.message_id,created_at:e.created_at,updated_at:e.updated_at,e2ee_manifest:r}}async _withE2eeSendLock(e,t){let s=this._e2eeSendLockChains.get(e)||Promise.resolve(),r,i=new Promise(o=>{r=o}),a=s.catch(()=>{}).then(()=>i);this._e2eeSendLockChains.set(e,a),await s.catch(()=>{});try{return await t()}finally{r(),this._e2eeSendLockChains.get(e)===a&&this._e2eeSendLockChains.delete(e)}}_displayOverridesArrayToMap(e){if(!e?.length)return;let t=new Map;return e.forEach((s,r)=>{s&&t.set(r,s)}),t}async enqueueE2eeAttachmentMessage(e){if(!e.files.length)throw new Error("[Encryption] enqueueE2eeAttachmentMessage requires at least one file");let t=this._resolveChannelE2eeGroupId(e.cid,this._getActiveChannel(e.cid)),s=e.displayOverrides?e.files.map((a,o)=>e.displayOverrides?.get(o)):void 0,r=Date.now(),i={message_id:e.messageId,cid:e.cid,e2ee_group_id:t,channel_type:e.channelType,channel_id:e.channelId,text:e.text,files:e.files,display_overrides:s,local_attachments:e.localAttachments,aad_metadata:e.options,retry_count:0,status:"uploading",created_at:r,updated_at:r};return await this.storage.savePendingE2eeSend(i),this._processQueuedE2eeAttachmentMessage(i,e),i}async cancelPendingE2eeSend(e){this._canceledPendingE2eeSends.add(e),this._pendingE2eeSendAbortControllers.get(e)?.abort();let t=await this.storage.loadPendingE2eeSend(e).catch(()=>null);t&&(await this.storage.savePendingE2eeSend({...t,status:"canceled",updated_at:Date.now()}),await this.storage.deletePendingE2eeSend(e))}async resumePendingE2eeSends(){if(!this.storage?.listPendingE2eeSends)return;let e=[];try{e=await this.storage.listPendingE2eeSends(["generating_preview","uploading","uploaded","encrypting","sending","failed_retryable"])}catch(t){b("warn","[Encryption] Failed to list pending E2EE sends for resume",t);return}e.filter(t=>(t.files?.length&&t.channel_type&&t.channel_id||t.mls_ciphertext)&&t.text!==void 0).forEach(t=>{this._processQueuedE2eeAttachmentMessage(t)})}async _sendPersistedPendingE2eeRecord(e){if(!e.channel_type||!e.channel_id||!e.mls_ciphertext||e.mls_epoch===void 0)throw new Error("Pending E2EE send is missing persisted send material");let t={...e.send_envelope||{},...e.e2ee_attachment_ids?.length?{e2ee_attachment_ids:e.e2ee_attachment_ids}:{},...e.forward_cid?{forward_cid:e.forward_cid}:{},...e.forward_message_id?{forward_message_id:e.forward_message_id}:{},...e.forward_parent_cid?{forward_parent_cid:e.forward_parent_cid}:{}};return await this.e2eeClient.sendMessage(e.channel_type,e.channel_id,{message:{id:e.message_id,mls_ciphertext:e.mls_ciphertext,mls_epoch:e.mls_epoch,e2ee_group_id:e.e2ee_group_id,...t}})}async _processQueuedE2eeAttachmentMessage(e,t){if(this._pendingE2eeSendJobs.has(e.message_id))return;this._pendingE2eeSendJobs.add(e.message_id);let s=e,r=0,i=0,a=typeof s.local_progress=="number"?s.local_progress:-1,o=typeof AbortController<"u"?new AbortController:void 0;o&&this._pendingE2eeSendAbortControllers.set(e.message_id,o);let c=()=>this._canceledPendingE2eeSends.has(e.message_id),l=()=>{if(c()||o?.signal.aborted){let d=new Error("Pending E2EE send canceled");throw d.name="AbortError",d}},p=async d=>{c()||(s={...s,...d,updated_at:Date.now()},await this.storage.savePendingE2eeSend(s))};try{l();let d=s.files||t?.files,u=s.channel_type||t?.channelType,h=s.channel_id||t?.channelId;if(s.status==="sending"&&s.mls_ciphertext){let v=await this._withE2eeSendLock(s.e2ee_group_id,()=>this._sendPersistedPendingE2eeRecord(s));await this.storage.deletePendingE2eeSend(s.message_id),t?.onSuccess?.(v);return}if(!d?.length||!u||!h){await p({status:"failed_terminal",last_error:"Missing durable files or channel routing for pending E2EE send"});return}let m=await this.uploadE2eeAttachments(u,h,d,{displayOverrides:t?.displayOverrides||this._displayOverridesArrayToMap(s.display_overrides),signal:o?.signal,onProgress:v=>{if(c())return;let y=v.phase==="generating_preview"?"generating_preview":v.phase==="encrypting"?"encrypting":"uploading",x=Math.max(0,Math.min(100,Math.round(v.percentage))),C=Date.now(),S=C-i>=250||x!==a||x===100;(C-r>=500||x!==a||x===100)&&(r=C,a=x,p({status:y,local_progress:x})),S&&(i=C,t?.onProgress?.({...v,percentage:x}))}});l(),await p({status:"uploaded",manifest:m.attachments,e2ee_attachment_ids:m.e2ee_attachment_ids,local_progress:100});let g={...s.aad_metadata||{},...t?.options||{},attachments:m.attachments,e2ee_attachment_ids:m.e2ee_attachment_ids};t?.onProgress?.({fileIndex:Math.max(0,d.length-1),phase:"sending",loaded:1,total:1,percentage:100}),await p({status:"sending"}),l();let _=await this.sendMessage(u,h,s.cid,s.text||"",s.message_id,g);await this.storage.deletePendingE2eeSend(s.message_id),t?.onSuccess?.(_)}catch(d){if(c()||o?.signal.aborted){await this.storage.deletePendingE2eeSend(s.message_id).catch(()=>{});return}let u=Im(d);await p({status:u?"failed_terminal":"failed_retryable",retry_count:(s.retry_count||0)+1,last_error:je(d)}),t?.onError?.(d)}finally{this._pendingE2eeSendJobs.delete(e.message_id),this._pendingE2eeSendAbortControllers.delete(e.message_id),this._canceledPendingE2eeSends.delete(e.message_id)}}async sendMessage(e,t,s,r,i,a={}){let o=this._resolveChannelE2eeGroupId(s,this._getActiveChannel(s));return await this._withE2eeSendLock(o,()=>this._sendMessageUnlocked(e,t,s,r,i,a,o))}async _sendMessageUnlocked(e,t,s,r,i,a,o){let c={text:r};a.attachments&&a.attachments.length>0&&(c.attachments=a.attachments),a.sticker_url&&(c.sticker_url=a.sticker_url),a.poll_type&&(c.poll_type=a.poll_type),a.poll_choice_counts&&(c.poll_choice_counts=a.poll_choice_counts);let{attachments:l,sticker_url:p,poll_type:d,poll_choice_counts:u,...h}=a;if(!this.getGroup(o)){let G=Bt(o),Q=G?await this.ensureChannelReady(G.channelType,G.channelId,o,{source:"send"}):await this.ensureChannelReady(e,t,o,{source:"send"});if(!this.getGroup(o))throw new Error(`[Encryption] No group for cid: ${o}; ensureChannelReady status=${Q.status}`)}let m=this._manifestAttachmentIds(c),g=a.e2ee_attachment_ids||m;g.length>0&&this._validateEnvelopeAttachmentIds({e2ee_attachment_ids:g},c);let _={cid:s,e2ee_group_id:o,message_id:i,forward_cid:a.forward_cid,forward_message_id:a.forward_message_id,forward_parent_cid:a.forward_parent_cid,e2ee_attachment_ids:g},v=Di(_)?Ui(_):void 0,y=this.encryptMessage(o,c,v),x=this.getGroup(o),C,S=Date.now(),P={message_id:i,cid:s,e2ee_group_id:o,channel_type:e,channel_id:t,text:r,mls_ciphertext:y,mls_ciphertext_sha256:cr(y,this._attachmentCryptoProvider),mls_epoch:Number(x.epoch()),e2ee_attachment_ids:g,aad_metadata:v?_:void 0,send_envelope:h,forward_cid:a.forward_cid,forward_message_id:a.forward_message_id,forward_parent_cid:a.forward_parent_cid,manifest:c.attachments,retry_count:0,status:"sending",created_at:S,updated_at:S};await this._persistProvider(),await this.storage.savePendingE2eeSend(P);try{C=await this.e2eeClient.sendMessage(e,t,{message:{id:i,mls_ciphertext:y,mls_epoch:Number(x.epoch()),e2ee_group_id:o,...g.length>0?{e2ee_attachment_ids:g}:{},...h}})}catch(G){if(vs(G)){b("warn","[Encryption] sendMessage: epoch_stale \u2014 syncing group and retrying..."),await this.sync(),y=this.encryptMessage(o,c,v),x=this.getGroup(o),await this._persistProvider(),await this.storage.savePendingE2eeSend({...P,mls_ciphertext:y,mls_ciphertext_sha256:cr(y,this._attachmentCryptoProvider),mls_epoch:Number(x.epoch()),retry_count:P.retry_count+1,updated_at:Date.now()});try{C=await this.e2eeClient.sendMessage(e,t,{message:{id:i,mls_ciphertext:y,mls_epoch:Number(x.epoch()),e2ee_group_id:o,...g.length>0?{e2ee_attachment_ids:g}:{},...h}})}catch(Q){throw await this.storage.savePendingE2eeSend({...P,mls_ciphertext:y,mls_ciphertext_sha256:cr(y,this._attachmentCryptoProvider),mls_epoch:Number(x.epoch()),retry_count:P.retry_count+1,status:"failed_retryable",last_error:je(Q),updated_at:Date.now()}),Q}}else throw await this.storage.savePendingE2eeSend({...P,status:"failed_retryable",last_error:je(G),updated_at:Date.now()}),G}await this.storage.savePendingE2eeSend({...P,status:"sent",updated_at:Date.now()});let E=new Date().toISOString(),k={id:i,cid:s,content_type:"standard",text:r,attachments:c.attachments,sticker_url:c.sticker_url,poll_type:c.poll_type,poll_choice_counts:c.poll_choice_counts,user_id:this.userId,user:Ue(this.userId||void 0,this.client?.user,this.userId?this.client?.state?.users?.[this.userId]:void 0),created_at:E,type:this._messageTypeForPayload(c),parent_id:a.parent_id,quoted_message_id:a.quoted_message_id,mentioned_users:a.mentioned_users,mentioned_all:a.mentioned_all,forward_cid:a.forward_cid,forward_message_id:a.forward_message_id,forward_parent_cid:a.forward_parent_cid,e2ee_attachment_ids:g};return await this.storage.saveE2eeMessage(k),await this._persistProvider(),{...C,message:await this._buildFullMessageWithQuoted(k,{forward_cid:a.forward_cid,forward_message_id:a.forward_message_id,forward_parent_cid:a.forward_parent_cid,e2ee_attachment_ids:g})}}async updateMessage(e,t,s,r,i,a={}){b("info","[Encryption] updateMessage: encrypting edit",{cid:s,message_id:r});let o=await this.storage.loadE2eeMessage(r),c=o?[...o.old_texts||[],{text:o.text,created_at:o.updated_at||o.created_at||new Date().toISOString()}]:[],l={text:i};c.length>0&&(l.old_texts=c),a.attachments&&a.attachments.length>0&&(l.attachments=a.attachments),a.sticker_url&&(l.sticker_url=a.sticker_url),a.poll_type&&(l.poll_type=a.poll_type),a.poll_choice_counts&&(l.poll_choice_counts=a.poll_choice_counts);let{attachments:p,sticker_url:d,poll_type:u,poll_choice_counts:h,...m}=a,g=this._resolveChannelE2eeGroupId(s,this._getActiveChannel(s));if(!this.getGroup(g)){let x=Bt(g),C=x?await this.ensureChannelReady(x.channelType,x.channelId,g,{source:"edit"}):await this.ensureChannelReady(e,t,g,{source:"edit"});if(!this.getGroup(g))throw new Error(`[Encryption] No group for cid: ${g}; ensureChannelReady status=${C.status}`)}let _=this.encryptMessage(g,l),v=this.getGroup(g),y;try{y=await this.e2eeClient.updateMessage(e,t,r,{message:{mls_ciphertext:_,mls_epoch:Number(v.epoch()),e2ee_group_id:g,...m}}),b("info","[Encryption] updateMessage: sent",{cid:s,message_id:r})}catch(x){if(vs(x))b("warn","[Encryption] updateMessage: epoch_stale \u2014 syncing group and retrying..."),await this.sync(),_=this.encryptMessage(g,l),v=this.getGroup(g),y=await this.e2eeClient.updateMessage(e,t,r,{message:{mls_ciphertext:_,mls_epoch:Number(v.epoch()),e2ee_group_id:g,...m}});else throw x}try{let x=o||await this.storage.loadE2eeMessage(r);x?await this.storage.saveE2eeMessage({...x,content_type:"standard",text:i,is_edited:!0,updated_at:new Date().toISOString(),old_texts:c,attachments:l.attachments||x.attachments,sticker_url:l.sticker_url||x.sticker_url,poll_type:l.poll_type||x.poll_type,poll_choice_counts:l.poll_choice_counts||x.poll_choice_counts,type:this._messageTypeForPayload(l,x.type),mentioned_users:a.mentioned_users||x.mentioned_users,mentioned_all:a.mentioned_all!==void 0?a.mentioned_all:x.mentioned_all}):await this.storage.saveE2eeMessage({id:r,cid:s,content_type:"standard",text:i,attachments:l.attachments,sticker_url:l.sticker_url,poll_type:l.poll_type,poll_choice_counts:l.poll_choice_counts,user_id:this.userId,user:Ue(this.userId||void 0,this.client?.user,this.userId?this.client?.state?.users?.[this.userId]:void 0),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),type:this._messageTypeForPayload(l),mentioned_users:a.mentioned_users,mentioned_all:a.mentioned_all,is_edited:!0,old_texts:[]})}catch(x){b("warn","[Encryption] updateMessage: failed to update local cache:",r,x)}return await this._persistProvider(),y}async decryptApplicationMessages(e,t,s){let r=[],i=[],a=0,o=0,c=0,l=0,p=[...t].sort((h,m)=>new Date(h.created_at).getTime()-new Date(m.created_at).getTime());for(let h of p){if(!h.mls_ciphertext)continue;let m=typeof h.cid=="string"&&h.cid||e,g=this._resolveMessageE2eeGroupId(h,s||e);if(this._isEncryptionProcessingBlockedForRoute(m,g)){i.push(h),this._logDeferredEncryptionEventOnce("pending_invite_waterfall",m,g,h.id);continue}let _=this.groups.get(g);if(!_){i.push(h),c+=1,this._logDeferredEncryptionEventOnce("missing_local_group_waterfall",m,g,h.id),await this._recordRepairIssue(m,h,"missing_local_snapshot",!1);continue}let v=await this.storage.loadE2eeMessage(h.id);if(v&&this._storedMessageCoversVersion(v,h)){r.push(v),await this._clearRepairIssue(m,h);continue}try{let{payload:y,messageType:x}=this.decryptMessage(g,h.mls_ciphertext);if(this._decryptedMsgIds.add(this._messageVersionKey(h)),x===0){let C=await this.storage.loadE2eeMessage(h.id),S=this._storedFromPayload(m,y,h,C);await this.storage.saveE2eeMessage(S),await this._clearRepairIssue(m,h),r.push(S)}}catch(y){let x=y.message||"";if(this._isForwardSecrecyConsumedError(x)){this._decryptedMsgIds.add(this._messageVersionKey(h)),await this._recordRepairIssue(m,h,"forward_secrecy_consumed",!1),l+=1,this._logExpectedDecryptFailureOnce(m,h,this._safeGroupEpoch(_),x);continue}i.push(h),this._isExpectedRecoverableDecryptFailure(_,h,x)?(a+=1,await this._recordRepairIssue(m,h,"decrypt_error",!1),this._logExpectedDecryptFailureOnce(m,h,this._safeGroupEpoch(_),x)):(o+=1,await this._recordRepairIssue(m,h,"decrypt_error"))}}r.length>0&&await this._persistProvider();let d=s||e,u=[e,d,r.length,i.length,a,o,c,l].join(":");if((r.length>0||i.length>0)&&this._shouldLogThrottled(this._waterfallSummaryLogKeys,u,ax)){let h={cid:e,group:d,decrypted:r.length,buffered:i.length,pendingRecovery:a,missingLocalGroup:c,consumed:l,decryptFailures:o};o>0?b("warn","[Encryption] Waterfall decrypt completed with unexpected failures:",h):b("info","[Encryption] Waterfall decrypt summary:",h)}return{decrypted:r,buffered:i}}destroy(){let e=Array.from(this.groups.values());for(let t=0;t<e.length;t++)try{e[t].free()}catch{}if(this.groups.clear(),this.identity)try{this.identity.free()}catch{}if(this.provider)try{this.provider.free()}catch{}this.initialized=!1,this.provider=null,this.identity=null,this.userId=null,this.deviceId=null,this.e2eeClient=null,this.client=null,this._recoveryPrivateKey=null,this._recoveryPublicKey=null,this._recoveryKeyId=null,this._recoveryCiphersuite=null,this._wrappedRecoveryKey=null,this._recoveryVaultKnown=null,this._recoveryVaultBytes=null,this._recoveryVaultRevision=null,this._recoveryPublicMetadataPromise=null,this._archiveStashKey=null,this._archiveStashKeyPromise=null,this._recoveryPostUnlockMaintenancePromise=null,this._recoveryPostUnlockMaintenanceGeneration+=1,this._expectedDecryptLogKeys.clear(),this._waterfallSummaryLogKeys.clear(),this._deferredEncryptionEventLogKeys.clear(),this._restoreQueue=[],this._restoreQueueRunning=!1,this._restoreInflight.clear(),this._bootstrapKnownChannelsPromise=null,this._channelBootstrapSub?.unsubscribe?.(),this._channelBootstrapSub=null,this._e2eeBootstrapProgress={total:0,completed:0,failed_cids:[],status:"idle"},this._decryptedMsgIds.clear(),this._pendingEvictions.clear(),this._syncing=!1,this._syncPromise=null,this._syncWorkPromise=null,this._syncGateResolve=null,this._lastSyncStates.clear(),this._channelReadyLocks.clear(),this._channelReadyUntil.clear(),this._providerRestored=!1,this.storage=null,b("info","[Encryption] Manager destroyed")}async createE2eeTopic(e,t){if(!this.initialized)throw new Error("[Encryption] Not initialized");let s=this.createGroup(e),{members:r}=await this.e2eeClient.getKeyPackagesByUserIds(t),i=[];for(let p of r)for(let d of p.key_packages){let u=ee.KeyPackage.from_bytes(new Uint8Array(d.key_package));i.push(u)}let a=i.length>0?s.add_members(this.provider,this.identity,i):s.commit_pending_proposals(this.provider,this.identity),o=s.export_ratchet_tree(),c=a.group_info;if(!c||c.length===0)throw s.clear_pending_commit(this.provider),await this._persistProvider(),new Error("[Encryption] createE2eeTopic: commitBundle.group_info is empty \u2014 cannot proceed");let l=Number(s.epoch());return s.merge_pending_commit(this.provider),await this._persistProvider(),b("info","[Encryption] createE2eeTopic: bundle ready for:",e,"epoch:",Number(s.epoch())),{commit:a.commit,welcome:i.length>0?a.welcome:new Uint8Array(0),ratchet_tree:o.to_bytes(),group_info:c,epoch:l}}async batchAddMembersToTopics(e,t,s,r){if(!this.initialized)throw new Error("[Encryption] Not initialized");let i=s.filter(h=>this._topicOwnsE2eeGroup(h));if(i.length===0)return{results:[]};let a=i.length,{members:o}=await this.e2eeClient.getKeyPackagesByUserIds(r,a),c=new Map;for(let h of o)for(let m of h.key_packages){let g=`${h.user_id}:${m.device_id}`;c.has(g)||c.set(g,[]);let _=ee.KeyPackage.from_bytes(new Uint8Array(m.key_package));c.get(g).push(_)}let l=[],p=[],d=new Map;for(let h=0;h<i.length;h++){let m=i[h],g=this.groups.get(m);if(!g){b("warn","[Encryption] batchAddMembersToTopics: no group for",m,"\u2014 skipping");continue}let _=[];for(let[,v]of c)h<v.length&&_.push(v[h]);if(_.length===0){b("warn","[Encryption] batchAddMembersToTopics: no KPs available for topic",m);continue}try{this._requireCompositeCommitMethods(g);let v=await this._collectPendingGhosts(m,r),y=g.commit_member_add_with_removals(this.provider,this.identity,v,_),x=g.export_ratchet_tree(),C=y.group_info;if(!C||C.length===0){g.clear_pending_commit(this.provider),b("error","[Encryption] batchAddMembersToTopics: empty group_info for",m);continue}l.push({topic_cid:m,commit:y.commit,welcome:y.welcome,ratchet_tree:x.to_bytes(),group_info:C,epoch:Number(g.epoch())}),p.push(m),d.set(m,v)}catch(v){b("error","[Encryption] batchAddMembersToTopics: WASM error for",m,v)}}if(l.length===0)return{results:[]};let u;try{u=await this.e2eeClient.batchAddMembersToTopics(e,t,{target_user_ids:r,topics:l})}catch(h){for(let m of p){let g=this.groups.get(m);g&&g.clear_pending_commit(this.provider)}throw await this._persistProvider(),h}for(let h of u.results){let m=this.groups.get(h.topic_cid);m&&(h.success?(m.merge_pending_commit(this.provider),await this._cleanupEvictedGhosts(h.topic_cid,d.get(h.topic_cid)??[]),b("info","[Encryption] batchAddMembers: merged",h.topic_cid,"epoch:",h.epoch)):(m.clear_pending_commit(this.provider),b("warn","[Encryption] batchAddMembers: failed",h.topic_cid,h.error)))}await this._persistProvider();for(let h of u.results)h.success&&await this.safeArchiveCurrentEpochForCid(h.topic_cid);return u}async batchExternalJoinTopics(e,t,s){if(!this.initialized)throw new Error("[Encryption] Not initialized");let r=s.filter(c=>this._resolveChannelE2eeGroupId(c,this._getActiveChannel(c))===c);if(r.length===0)return{results:[]};let i=[],a=new Map;for(let c of r)try{let l=c.indexOf(":"),p=c.substring(l+1),{group_info:d}=await this.e2eeClient.getGroupInfo("topic",p),u=ee.Group.join_external(this.provider,this.identity,new Uint8Array(d),null),h=u.group;if(!h){b("error","[Encryption] batchExternalJoin: no group for",c);continue}a.set(c,h),i.push({topic_cid:c,commit:u.commit,epoch:Number(h.epoch())})}catch(l){b("error","[Encryption] batchExternalJoin: error for",c,l)}if(i.length===0)return{results:[]};let o;try{o=await this.e2eeClient.batchExternalJoinTopics(e,t,{topics:i})}catch(c){for(let[,l]of a)try{l.clear_pending_commit(this.provider)}catch{}throw await this._persistProvider(),c}for(let c of o.results){let l=a.get(c.topic_cid);if(l)if(c.success){l.merge_pending_commit(this.provider),this.groups.set(c.topic_cid,l),await this._saveGroup(c.topic_cid);let p=c.topic_cid.indexOf(":"),d=c.topic_cid.substring(p+1);await this._uploadGroupInfo("topic",d,l),await this._saveScopeSyncCursor(c.topic_cid,this._nowEventCursor()),b("info","[Encryption] batchExternalJoin: joined",c.topic_cid,"epoch:",c.epoch)}else{try{l.clear_pending_commit(this.provider)}catch{}b("warn","[Encryption] batchExternalJoin: failed",c.topic_cid,c.error)}}await this._persistProvider();for(let c of o.results)c.success&&await this.safeArchiveCurrentEpochForCid(c.topic_cid);return o}};var cf=new Map;async function Ox(n="/openmls_wasm_bg.wasm"){let e=n,t=cf.get(e);return t||(t=(async()=>{let s=await Promise.resolve().then(()=>(of(),af));return await s.default(n),s.init(),s})(),cf.set(e,t)),t}function Bc(n,e){return(n[e]<<24|n[e+1]<<16|n[e+2]<<8|n[e+3])>>>0}function Fx(n,e){let t=Bc(n,e),s=Bc(n,e+4),r=t*2**32+s;return Number.isSafeInteger(r)?r:void 0}function Bx(n,e,t){let s="";for(let r=0;r<t;r+=1)s+=String.fromCharCode(n[e+r]);return s}function jx(n){let e=[],t=0;for(;t+8<=n.length;){let s=Bc(n,t),r=Bx(n,t+4,4),i=8,a=s;if(s===1){if(t+16>n.length)break;let o=Fx(n,t+8);if(o===void 0)break;a=o,i=16}else s===0&&(a=n.length-t);if(a<i||t+a>n.length)break;e.push({type:r,start:t,headerSize:i,end:t+a}),t+=a}return e}function Gx(n,e){return n.slice(e.start+e.headerSize,e.end)}function vr(n,e){let t=new TextEncoder().encode(e);e:for(let s=0;s<=n.length-t.length;s+=1){for(let r=0;r<t.length;r+=1)if(n[s+r]!==t[r])continue e;return!0}return!1}function Nx(n,e){let t=n?.toLowerCase()||"",s=e?.toLowerCase()||"";if(t==="video/quicktime"||s.endsWith(".mov"))return"mov_unsupported";if(t&&t!=="video/mp4"&&t!=="video/x-m4v"&&t!=="video/m4v")return"container_unsupported"}function qx(n){if(vr(n,"hvc1")||vr(n,"hev1"))return{reason:"hevc_unsupported"};let e=vr(n,"avc1")?"avc1.42E01E":vr(n,"avc3")?"avc3.42E01E":void 0;if(!e)return{reason:"video_codec_unsupported"};let t=[e];return vr(n,"mp4a")&&t.push("mp4a.40.2"),{codecMimeType:`video/mp4; codecs="${t.join(", ")}"`}}function zx(n){let e=jx(n.bytes),t=e.find(l=>l.type==="ftyp"),s=e.find(l=>l.type==="moov"),r=e.find(l=>l.type==="moof"),i=e.find(l=>l.type==="mdat"),a={hasFtyp:!!t,hasMoov:!!s,hasMoof:!!r,hasMdat:!!i},o=Nx(n.mimeType,n.fileName);if(o)return{ok:!1,reason:o,...a};if(!t)return{ok:!1,reason:"ftyp_missing",...a};if(!s)return{ok:!1,reason:"moov_missing_in_probe",...a};if(!r)return{ok:!1,reason:"moof_missing",...a};if(!i)return{ok:!1,reason:"mdat_missing",...a};let c=qx(Gx(n.bytes,s));return c.codecMimeType?{ok:!0,codecMimeType:c.codecMimeType,...a}:{ok:!1,reason:c.reason||"codec_unsupported",...a}}var $x=8,Wx=2,Vx=2,Kx=16777216,Hx=134217728,Qx=268435456;function Es(n,e){if(!Number.isInteger(n)||n<0)throw new Error(`${e} must be a non-negative integer`);return n}function Cs(n,e){if(!Number.isInteger(n)||n<=0)throw new Error(`${e} must be a positive integer`);return n}function Jx(n){let e=Es(n.currentFrame,"currentFrame"),t=Es(n.lastFrame,"lastFrame");if(e>t)throw new Error("currentFrame must be <= lastFrame");let s=Cs(n.prefetchFrames||8,"prefetchFrames"),r=Cs(n.prefetchThresholdFrames||2,"prefetchThresholdFrames"),i=Cs(n.sequentialPrefetchHits||2,"sequentialPrefetchHits"),a=n.sequentialHits===void 0?0:Es(n.sequentialHits,"sequentialHits"),o=n.prefetchedUntilFrame===void 0?-1:Es(n.prefetchedUntilFrame,"prefetchedUntilFrame"),c=n.rangeFrameSpan===void 0?t-e+1:Cs(n.rangeFrameSpan,"rangeFrameSpan"),l=!!n.noRange||c>r||a>=i,p=l&&e>o;return{firstFrame:e,lastFrame:p?Math.min(t,e+s-1):e,prefetch:l}}function Yx(n){let e=Es(n.frameIndex,"frameIndex"),t=Cs(n.frameSize,"frameSize"),s=Es(n.plaintextSize,"plaintextSize"),r=e*t;return Math.max(0,Math.min(t,s-r))}function Xx(n){let e=Es(n.plaintextSize,"plaintextSize"),t=Cs(n.baseSessionCacheLimit||16777216,"baseSessionCacheLimit"),s=Cs(n.fullReplayCacheLimit||134217728,"fullReplayCacheLimit");return e>0&&e<=s?Math.max(t,e):t}function jc(n,e){return e[n]??n}function lf(n,e,t){if(!n||typeof n!="string")return n??"";let s=n.trim();if(!s)return"";let r=s.split(" "),i=r[0],a=r[1]??"",o=a?jc(a,e):t?.userFallback??"User";switch(i){case"1":{let c=r.slice(2).join(" "),l=t?.["1"]??t?.changeName;return l?l.replace("{{user}}",o).replace("{{channel}}",c):`${o} changed the channel name to ${c}.`}case"2":{let c=t?.["2"]??t?.changeAvatar;return c?c.replace("{{user}}",o):`${o} changed the channel avatar.`}case"3":{let c=t?.["3"]??t?.changeDescription;return c?c.replace("{{user}}",o):`${o} changed the channel description.`}case"4":{let c=t?.["4"]??t?.removed;return c?c.replace("{{user}}",o):`${o} was removed from the channel.`}case"5":{let c=t?.["5"]??t?.banned;return c?c.replace("{{user}}",o):`${o} was banned.`}case"6":{let c=t?.["6"]??t?.unbanned;return c?c.replace("{{user}}",o):`${o} was unbanned.`}case"7":{let c=t?.["7"]??t?.promoted;return c?c.replace("{{user}}",o):`${o} was promoted to moderator.`}case"8":{let c=t?.["8"]??t?.demoted;return c?c.replace("{{user}}",o):`${o} was demoted from moderator.`}case"9":{let c=t?.["9"]??t?.permissionsUpdated;return c?c.replace("{{user}}",o):`${o}'s permissions were updated.`}case"10":{let c=t?.["10"]??t?.joined;return c?c.replace("{{user}}",o):`${o} joined the channel.`}case"11":{let c=t?.["11"]??t?.declined;return c?c.replace("{{user}}",o):`${o} declined the channel invitation.`}case"12":{let c=t?.["12"]??t?.left;return c?c.replace("{{user}}",o):`${o} left the channel.`}case"13":{let c=t?.["13"]??t?.clearedHistory;return c?c.replace("{{user}}",o):`${o} cleared the chat history.`}case"14":{let l=(r[2]??"")==="true"?"public":"private",p=t?.[l]??l,d=t?.["14"]??t?.changeType;return d?d.replace("{{user}}",o).replace("{{type}}",p):`${o} changed the channel to ${p}.`}case"15":{let c=r[2]??"0";if(c==="0"){let h=t?.["15_off"]??t?.cooldownOff;return h?h.replace("{{user}}",o):`${o} disabled cooldown.`}let l=`${c}ms`,p=t?.durationUnitMin??"minute",d=t?.durationUnitSec??"seconds";c==="10000"?l=`10 ${d}`:c==="30000"?l=`30 ${d}`:c==="60000"?l=`1 ${p}`:c==="300000"?l=`5 ${p}`:c==="900000"?l=`15 ${p}`:c==="3600000"&&(l=`60 ${p}`);let u=t?.["15_on"]??t?.cooldownOn;return u?u.replace("{{user}}",o).replace("{{duration}}",l):`${o} enabled cooldown for ${l}.`}case"16":{let c=t?.["16"]??t?.bannedWordsUpdated;return c?c.replace("{{user}}",o):`${o} updated the banned words.`}case"17":{let c=t?.["17"]??t?.added;return c?c.replace("{{user}}",o):`${o} was added to the channel.`}case"18":{let c=r[1]??"",l=r[2]??"",p=c?jc(c,e):t?.userFallback??"User",d=l?jc(l,e):t?.userFallback??"User",u=t?.adminFallback??"Admin",h=t?.["18"]??t?.adminTransfer;return h?h.replace("{{user}}",p).replace("{{targetUser}}",d).replace("{{admin}}",u):`${u} ${p} left and assigned ${d} as the new admin.`}case"19":{let c=t?.["19"]??t?.pinned;return c?c.replace("{{user}}",o):`${o} pinned a message.`}case"20":{let c=t?.["20"]??t?.unpinned;return c?c.replace("{{user}}",o):`${o} unpinned a message.`}default:return s}}var pt={AUDIO:"audio",VIDEO:"video"};function Zx(n,e){if(!n)return"";let t=parseInt(n,10);if(isNaN(t)||t<=0)return"";let s=Math.floor(t/1e3),r=Math.floor(s/60),i=s%60,a=e?.durationUnitMin??"min",o=e?.durationUnitSec??"sec";return`${r} ${a}, ${i} ${o}`}function pf(n,e,t){if(!n||typeof n!="string")return null;let s=n.trim();if(!s)return null;let r=s.split(" "),i=parseInt(r[0],10),a=r[1]??"",o=e===a,c="",l="",p="",d="";(i===3||i===6)&&(c=r[2]??"",l=r[3]==="0"?"":r[3]??"");let u;switch(i){case 1:u=o?t?.calling??"Calling...":t?.incomingAudioCall??"Incoming audio call...",p=pt.AUDIO,d="#54D62C";break;case 2:u=o?t?.outgoingAudioCall??"Outgoing audio call":t?.missedAudioCall??"You missed audio call",p=pt.AUDIO,d="#FF4842";break;case 3:l?(u=o?t?.outgoingAudioCall??"Outgoing audio call":t?.incomingAudioCall??"Incoming audio call",d="#54D62C"):(c===e?u=t?.cancelAudioCall??"You cancel audio call":u=t?.missedAudioCall??"You missed audio call",d="#FF4842"),p=pt.AUDIO;break;case 4:u=o?t?.calling??"Calling...":t?.incomingVideoCall??"Incoming video call...",p=pt.VIDEO,d="#54D62C";break;case 5:u=o?t?.outgoingVideoCall??"Outgoing video call":t?.missedVideoCall??"You missed video call",p=pt.VIDEO,d="#FF4842";break;case 6:l?(u=o?t?.outgoingVideoCall??"Outgoing video call":t?.incomingVideoCall??"Incoming video call",d="#54D62C"):(c===e?u=t?.cancelVideoCall??"You cancel video call":u=t?.missedVideoCall??"You missed video call",d="#FF4842"),p=pt.VIDEO;break;case 7:u=o?t?.rejectedAudioCallRecipient??"Recipient rejected audio call":t?.rejectedAudioCallYou??"You rejected audio call",p=pt.AUDIO,d="#FF4842";break;case 8:u=o?t?.rejectedVideoCallRecipient??"Recipient rejected video call":t?.rejectedVideoCallYou??"You rejected video call",p=pt.VIDEO,d="#FF4842";break;case 9:u=o?t?.busyRecipient??"Recipient was busy":t?.missedAudioCall??"You missed audio call",p=pt.AUDIO,d="#FF4842";break;case 10:u=o?t?.busyRecipient??"Recipient was busy":t?.missedVideoCall??"You missed video call",p=pt.VIDEO,d="#FF4842";break;default:u=s,p="",d=""}return{text:u,duration:Zx(l,t),callType:p,color:d}}return un(eE);})();
21
22
  /*! Bundled license information:
22
23
 
23
24
  mime-db/index.js:
@@ -42,5 +43,8 @@ event-source-polyfill/src/eventsource.js:
42
43
  * Available under MIT License (MIT)
43
44
  * https://github.com/Yaffle/EventSource/
44
45
  *)
46
+
47
+ @noble/hashes/esm/utils.js:
48
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
45
49
  */
46
50
  //# sourceMappingURL=index.browser.full-bundle.min.js.map