@chillicream/nitro-embedded
Version:
Nitro GraphQL IDE
1 lines • 23.7 kB
JavaScript
(self.webpackChunknitro=self.webpackChunknitro||[]).push([[936],{64293:e=>{function t(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}e.exports=t,t.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},t.prototype.reset=function(){this.attempts=0},t.prototype.setMin=function(e){this.ms=e},t.prototype.setMax=function(e){this.max=e},t.prototype.setJitter=function(e){this.jitter=e}},75438:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,a){if("function"!==typeof r)throw new TypeError("The listener must be a function");var s=new o(r,i||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},s.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},s.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},s.prototype.emit=function(e,t,r,o,i,a){var s=n?n+e:e;if(!this._events[s])return!1;var c,p,u=this._events[s],l=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),l){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,i),!0;case 6:return u.fn.call(u.context,t,r,o,i,a),!0}for(p=1,c=new Array(l-1);p<l;p++)c[p-1]=arguments[p];u.fn.apply(u.context,c)}else{var f,d=u.length;for(p=0;p<d;p++)switch(u[p].once&&this.removeListener(e,u[p].fn,void 0,!0),l){case 1:u[p].fn.call(u[p].context);break;case 2:u[p].fn.call(u[p].context,t);break;case 3:u[p].fn.call(u[p].context,t,r);break;case 4:u[p].fn.call(u[p].context,t,r,o);break;default:if(!c)for(f=1,c=new Array(l-1);f<l;f++)c[f-1]=arguments[f];u[p].fn.apply(u[p].context,c)}}return!0},s.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return a(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||o&&!s.once||r&&s.context!==r||a(this,i);else{for(var c=0,p=[],u=s.length;c<u;c++)(s[c].fn!==t||o&&!s[c].once||r&&s[c].context!==r)&&p.push(s[c]);p.length?this._events[i]=1===p.length?p[0]:p:a(this,i)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s},62967:(e,t,n)=>{"use strict";n.d(t,{Qb:()=>r.Qb,qx:()=>r.qx,r5:()=>r.r5});n(49996);var r=n(24815);n(49358),n(94806)},28232:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});class r{constructor(e){var t=this;this._start=0,this._pos=0,this.getStartOfToken=()=>this._start,this.getCurrentPosition=()=>this._pos,this.eol=()=>this._sourceText.length===this._pos,this.sol=()=>0===this._pos,this.peek=()=>this._sourceText.charAt(this._pos)||null,this.next=()=>{const e=this._sourceText.charAt(this._pos);return this._pos++,e},this.eat=e=>{if(this._testNextCharacter(e))return this._start=this._pos,this._pos++,this._sourceText.charAt(this._pos-1)},this.eatWhile=e=>{let t=this._testNextCharacter(e),n=!1;for(t&&(n=t,this._start=this._pos);t;)this._pos++,t=this._testNextCharacter(e),n=!0;return n},this.eatSpace=()=>this.eatWhile(/[\s\u00a0]/),this.skipToEnd=()=>{this._pos=this._sourceText.length},this.skipTo=e=>{this._pos=e},this.match=function(e){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=null,o=null;if("string"===typeof e){o=new RegExp(e,arguments.length>2&&void 0!==arguments[2]&&arguments[2]?"i":"g").test(t._sourceText.slice(t._pos,t._pos+e.length)),r=e}else e instanceof RegExp&&(o=t._sourceText.slice(t._pos).match(e),r=null===o||void 0===o?void 0:o[0]);return!(null==o||!("string"===typeof e||o instanceof Array&&t._sourceText.startsWith(o[0],t._pos)))&&(n&&(t._start=t._pos,r&&r.length&&(t._pos+=r.length)),o)},this.backUp=e=>{this._pos-=e},this.column=()=>this._pos,this.indentation=()=>{const e=this._sourceText.match(/\s*/);let t=0;if(e&&0!==e.length){const n=e[0];let r=0;for(;n.length>r;)9===n.charCodeAt(r)?t+=2:t++,r++}return t},this.current=()=>this._sourceText.slice(this._start,this._pos),this._sourceText=e}_testNextCharacter(e){const t=this._sourceText.charAt(this._pos);let n=!1;return n="string"===typeof e?t===e:e instanceof RegExp?e.test(t):e(t),n}}},59968:(e,t,n)=>{"use strict";n.d(t,{Rq:()=>a,pi:()=>i,vM:()=>s});var r=n(27212),o=n(466);const i=e=>" "===e||"\t"===e||","===e||"\n"===e||"\r"===e||"\ufeff"===e||"\xa0"===e,a={Name:/^[_A-Za-z][_0-9A-Za-z]*/,Punctuation:/^(?:!|\$|\(|\)|\.\.\.|:|=|&|@|\[|]|\{|\||\})/,Number:/^-?(?:0|(?:[1-9][0-9]*))(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?/,String:/^(?:"""(?:\\"""|[^"]|"[^"]|""[^"])*(?:""")?|"(?:[^"\\]|\\(?:"|\/|\\|b|f|n|r|t|u[0-9a-fA-F]{4}))*"?)/,Comment:/^#.*/},s={Document:[(0,r.p_)("Definition")],Definition(e){switch(e.value){case"{":return"ShortQuery";case"query":return"Query";case"mutation":return"Mutation";case"subscription":return"Subscription";case"fragment":return o.b.FRAGMENT_DEFINITION;case"schema":return"SchemaDef";case"scalar":return"ScalarDef";case"type":return"ObjectTypeDef";case"interface":return"InterfaceDef";case"union":return"UnionDef";case"enum":return"EnumDef";case"input":return"InputDef";case"extend":return"ExtendDef";case"directive":return"DirectiveDef"}},ShortQuery:["SelectionSet"],Query:[p("query"),(0,r.m7)(u("def")),(0,r.m7)("VariableDefinitions"),(0,r.p_)("Directive"),"SelectionSet"],Mutation:[p("mutation"),(0,r.m7)(u("def")),(0,r.m7)("VariableDefinitions"),(0,r.p_)("Directive"),"SelectionSet"],Subscription:[p("subscription"),(0,r.m7)(u("def")),(0,r.m7)("VariableDefinitions"),(0,r.p_)("Directive"),"SelectionSet"],VariableDefinitions:[(0,r.p)("("),(0,r.p_)("VariableDefinition"),(0,r.p)(")")],VariableDefinition:["Variable",(0,r.p)(":"),"Type",(0,r.m7)("DefaultValue")],Variable:[(0,r.p)("$","variable"),u("variable")],DefaultValue:[(0,r.p)("="),"Value"],SelectionSet:[(0,r.p)("{"),(0,r.p_)("Selection"),(0,r.p)("}")],Selection:(e,t)=>"..."===e.value?t.match(/[\s\u00a0,]*(on\b|@|{)/,!1)?"InlineFragment":"FragmentSpread":t.match(/[\s\u00a0,]*:/,!1)?"AliasedField":"Field",AliasedField:[u("property"),(0,r.p)(":"),u("qualifier"),(0,r.m7)("Arguments"),(0,r.p_)("Directive"),(0,r.m7)("SelectionSet")],Field:[u("property"),(0,r.m7)("Arguments"),(0,r.p_)("Directive"),(0,r.m7)("SelectionSet")],Arguments:[(0,r.p)("("),(0,r.p_)("Argument"),(0,r.p)(")")],Argument:[u("attribute"),(0,r.p)(":"),"Value"],FragmentSpread:[(0,r.p)("..."),u("def"),(0,r.p_)("Directive")],InlineFragment:[(0,r.p)("..."),(0,r.m7)("TypeCondition"),(0,r.p_)("Directive"),"SelectionSet"],FragmentDefinition:[p("fragment"),(0,r.m7)((0,r.FC)(u("def"),[p("on")])),"TypeCondition",(0,r.p_)("Directive"),"SelectionSet"],TypeCondition:[p("on"),"NamedType"],Value(e){switch(e.kind){case"Number":return"NumberValue";case"String":return"StringValue";case"Punctuation":switch(e.value){case"[":return"ListValue";case"{":return"ObjectValue";case"$":return"Variable";case"&":return"NamedType"}return null;case"Name":switch(e.value){case"true":case"false":return"BooleanValue"}return"null"===e.value?"NullValue":"EnumValue"}},NumberValue:[(0,r.t)("Number","number")],StringValue:[{style:"string",match:e=>"String"===e.kind,update(e,t){t.value.startsWith('"""')&&(e.inBlockstring=!t.value.slice(3).endsWith('"""'))}}],BooleanValue:[(0,r.t)("Name","builtin")],NullValue:[(0,r.t)("Name","keyword")],EnumValue:[u("string-2")],ListValue:[(0,r.p)("["),(0,r.p_)("Value"),(0,r.p)("]")],ObjectValue:[(0,r.p)("{"),(0,r.p_)("ObjectField"),(0,r.p)("}")],ObjectField:[u("attribute"),(0,r.p)(":"),"Value"],Type:e=>"["===e.value?"ListType":"NonNullType",ListType:[(0,r.p)("["),"Type",(0,r.p)("]"),(0,r.m7)((0,r.p)("!"))],NonNullType:["NamedType",(0,r.m7)((0,r.p)("!"))],NamedType:[(c="atom",{style:c,match:e=>"Name"===e.kind,update(e,t){var n;(null===(n=e.prevState)||void 0===n?void 0:n.prevState)&&(e.name=t.value,e.prevState.prevState.type=t.value)}})],Directive:[(0,r.p)("@","meta"),u("meta"),(0,r.m7)("Arguments")],DirectiveDef:[p("directive"),(0,r.p)("@","meta"),u("meta"),(0,r.m7)("ArgumentsDef"),p("on"),(0,r.p_)("DirectiveLocation",(0,r.p)("|"))],InterfaceDef:[p("interface"),u("atom"),(0,r.m7)("Implements"),(0,r.p_)("Directive"),(0,r.p)("{"),(0,r.p_)("FieldDef"),(0,r.p)("}")],Implements:[p("implements"),(0,r.p_)("NamedType",(0,r.p)("&"))],DirectiveLocation:[u("string-2")],SchemaDef:[p("schema"),(0,r.p_)("Directive"),(0,r.p)("{"),(0,r.p_)("OperationTypeDef"),(0,r.p)("}")],OperationTypeDef:[u("keyword"),(0,r.p)(":"),u("atom")],ScalarDef:[p("scalar"),u("atom"),(0,r.p_)("Directive")],ObjectTypeDef:[p("type"),u("atom"),(0,r.m7)("Implements"),(0,r.p_)("Directive"),(0,r.p)("{"),(0,r.p_)("FieldDef"),(0,r.p)("}")],FieldDef:[u("property"),(0,r.m7)("ArgumentsDef"),(0,r.p)(":"),"Type",(0,r.p_)("Directive")],ArgumentsDef:[(0,r.p)("("),(0,r.p_)("InputValueDef"),(0,r.p)(")")],InputValueDef:[u("attribute"),(0,r.p)(":"),"Type",(0,r.m7)("DefaultValue"),(0,r.p_)("Directive")],UnionDef:[p("union"),u("atom"),(0,r.p_)("Directive"),(0,r.p)("="),(0,r.p_)("UnionMember",(0,r.p)("|"))],UnionMember:["NamedType"],EnumDef:[p("enum"),u("atom"),(0,r.p_)("Directive"),(0,r.p)("{"),(0,r.p_)("EnumValueDef"),(0,r.p)("}")],EnumValueDef:[u("string-2"),(0,r.p_)("Directive")],InputDef:[p("input"),u("atom"),(0,r.p_)("Directive"),(0,r.p)("{"),(0,r.p_)("InputValueDef"),(0,r.p)("}")],ExtendDef:[p("extend"),"ExtensionDefinition"],ExtensionDefinition(e){switch(e.value){case"schema":return o.b.SCHEMA_EXTENSION;case"scalar":return o.b.SCALAR_TYPE_EXTENSION;case"type":return o.b.OBJECT_TYPE_EXTENSION;case"interface":return o.b.INTERFACE_TYPE_EXTENSION;case"union":return o.b.UNION_TYPE_EXTENSION;case"enum":return o.b.ENUM_TYPE_EXTENSION;case"input":return o.b.INPUT_OBJECT_TYPE_EXTENSION}},[o.b.SCHEMA_EXTENSION]:["SchemaDef"],[o.b.SCALAR_TYPE_EXTENSION]:["ScalarDef"],[o.b.OBJECT_TYPE_EXTENSION]:["ObjectTypeDef"],[o.b.INTERFACE_TYPE_EXTENSION]:["InterfaceDef"],[o.b.UNION_TYPE_EXTENSION]:["UnionDef"],[o.b.ENUM_TYPE_EXTENSION]:["EnumDef"],[o.b.INPUT_OBJECT_TYPE_EXTENSION]:["InputDef"]};var c;function p(e){return{style:"keyword",match:t=>"Name"===t.kind&&t.value===e}}function u(e){return{style:e,match:e=>"Name"===e.kind,update(e,t){e.name=t.value}}}},24815:(e,t,n)=>{"use strict";n.d(t,{Qb:()=>r.A,qx:()=>i.q,r5:()=>o.A});var r=n(28232),o=(n(59968),n(83759)),i=(n(80587),n(44323),n(5798))},58819:(e,t)=>{"use strict";t.nI=t.OL=void 0;t.OL=1e3;t.nI=3e4},69278:(e,t)=>{"use strict";var n=function(){function e(){throw new Error("Static Class")}return e.GQL_CONNECTION_INIT="connection_init",e.GQL_CONNECTION_ACK="connection_ack",e.GQL_CONNECTION_ERROR="connection_error",e.GQL_CONNECTION_KEEP_ALIVE="ka",e.GQL_CONNECTION_TERMINATE="connection_terminate",e.GQL_START="start",e.GQL_DATA="data",e.GQL_ERROR="error",e.GQL_COMPLETE="complete",e.GQL_STOP="stop",e.SUBSCRIPTION_START="subscription_start",e.SUBSCRIPTION_DATA="subscription_data",e.SUBSCRIPTION_SUCCESS="subscription_success",e.SUBSCRIPTION_FAIL="subscription_fail",e.SUBSCRIPTION_END="subscription_end",e.INIT="init",e.INIT_SUCCESS="init_success",e.INIT_FAIL="init_fail",e.KEEP_ALIVE="keepalive",e}();t.A=n},30325:(e,t)=>{"use strict";t.BS=void 0;t.BS="graphql-ws"},32691:(e,t)=>{"use strict";t.A=function(e){return null!==e&&"object"===typeof e}},87357:(e,t)=>{"use strict";t.A=function(e){return"string"===typeof e}},65292:(e,t,n)=>{"use strict";n.d(t,{A:()=>r}),e=n.hmd(e);const r=function(e){var t,n=e.Symbol;return"function"===typeof n?n.observable?t=n.observable:(t=n("observable"),n.observable=t):t="@@observable",t}("undefined"!==typeof self?self:"undefined"!==typeof window?window:"undefined"!==typeof n.g?n.g:e)},34145:(e,t,n)=>{"use strict";function r(e){return null===e?"null":Array.isArray(e)?"array":typeof e}function o(e){return"object"===r(e)}function i(e,t){return e.length<124?e:t}n.d(t,{UU:()=>d});const a="graphql-transport-ws";var s,c;function p(e){if(!o(e))throw new Error("Message is expected to be an object, but got ".concat(r(e)));if(!e.type)throw new Error("Message is missing the 'type' property");if("string"!==typeof e.type)throw new Error("Message is expects the 'type' property to be a string, but got ".concat(r(e.type)));switch(e.type){case c.ConnectionInit:case c.ConnectionAck:case c.Ping:case c.Pong:if(null!=e.payload&&!o(e.payload))throw new Error('"'.concat(e.type,"\" message expects the 'payload' property to be an object or nullish or missing, but got \"").concat(e.payload,'"'));break;case c.Subscribe:if("string"!==typeof e.id)throw new Error('"'.concat(e.type,"\" message expects the 'id' property to be a string, but got ").concat(r(e.id)));if(!e.id)throw new Error('"'.concat(e.type,"\" message requires a non-empty 'id' property"));if(!o(e.payload))throw new Error('"'.concat(e.type,"\" message expects the 'payload' property to be an object, but got ").concat(r(e.payload)));if("string"!==typeof e.payload.query)throw new Error('"'.concat(e.type,"\" message payload expects the 'query' property to be a string, but got ").concat(r(e.payload.query)));if(null!=e.payload.variables&&!o(e.payload.variables))throw new Error('"'.concat(e.type,"\" message payload expects the 'variables' property to be a an object or nullish or missing, but got ").concat(r(e.payload.variables)));if(null!=e.payload.operationName&&"string"!==r(e.payload.operationName))throw new Error('"'.concat(e.type,"\" message payload expects the 'operationName' property to be a string or nullish or missing, but got ").concat(r(e.payload.operationName)));if(null!=e.payload.extensions&&!o(e.payload.extensions))throw new Error('"'.concat(e.type,"\" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ").concat(r(e.payload.extensions)));break;case c.Next:if("string"!==typeof e.id)throw new Error('"'.concat(e.type,"\" message expects the 'id' property to be a string, but got ").concat(r(e.id)));if(!e.id)throw new Error('"'.concat(e.type,"\" message requires a non-empty 'id' property"));if(!o(e.payload))throw new Error('"'.concat(e.type,"\" message expects the 'payload' property to be an object, but got ").concat(r(e.payload)));break;case c.Error:if("string"!==typeof e.id)throw new Error('"'.concat(e.type,"\" message expects the 'id' property to be a string, but got ").concat(r(e.id)));if(!e.id)throw new Error('"'.concat(e.type,"\" message requires a non-empty 'id' property"));if(t=e.payload,!(Array.isArray(t)&&t.length>0&&t.every((e=>"message"in e))))throw new Error('"'.concat(e.type,"\" message expects the 'payload' property to be an array of GraphQL errors, but got ").concat(JSON.stringify(e.payload)));break;case c.Complete:if("string"!==typeof e.id)throw new Error('"'.concat(e.type,"\" message expects the 'id' property to be a string, but got ").concat(r(e.id)));if(!e.id)throw new Error('"'.concat(e.type,"\" message requires a non-empty 'id' property"));break;default:throw new Error("Invalid message 'type' property \"".concat(e.type,'"'))}var t;return e}function u(e,t){return p(e),JSON.stringify(e,t)}!function(e){e[e.InternalServerError=4500]="InternalServerError",e[e.InternalClientError=4005]="InternalClientError",e[e.BadRequest=4400]="BadRequest",e[e.BadResponse=4004]="BadResponse",e[e.Unauthorized=4401]="Unauthorized",e[e.Forbidden=4403]="Forbidden",e[e.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",e[e.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",e[e.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",e[e.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",e[e.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"}(s||(s={})),function(e){e.ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete"}(c||(c={}));var l=function(e){return this instanceof l?(this.v=e,this):new l(e)},f=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},a("next"),a("throw"),a("return"),r[Symbol.asyncIterator]=function(){return this},r;function a(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||s(e,t)}))})}function s(e,t){try{(n=o[e](t)).value instanceof l?Promise.resolve(n.value.v).then(c,p):u(i[0][2],n)}catch(r){u(i[0][3],r)}var n}function c(e){s("next",e)}function p(e){s("throw",e)}function u(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}};function d(e){const{url:t,connectionParams:n,lazy:r=!0,onNonLazyError:o=console.error,lazyCloseTimeout:d=0,keepAlive:m=0,disablePong:v,connectionAckWaitTimeout:b=0,retryAttempts:_=5,retryWait:g=async function(e){let t=1e3;for(let n=0;n<e;n++)t*=2;await new Promise((e=>setTimeout(e,t+Math.floor(2700*Math.random()+300))))},shouldRetry:E=y,isFatalConnectionProblem:w,on:S,webSocketImpl:T,generateID:N=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},jsonMessageReplacer:x,jsonMessageReviver:I}=e;let C;if(T){if(!("function"===typeof(D=T)&&"constructor"in D&&"CLOSED"in D&&"CLOSING"in D&&"CONNECTING"in D&&"OPEN"in D))throw new Error("Invalid WebSocket implementation provided");C=T}else"undefined"!==typeof WebSocket?C=WebSocket:"undefined"!==typeof global?C=global.WebSocket||global.MozWebSocket:"undefined"!==typeof window&&(C=window.WebSocket||window.MozWebSocket);var D;if(!C)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const A=C,O=(()=>{const e=(()=>{const e={};return{on:(t,n)=>(e[t]=n,()=>{delete e[t]}),emit(t){var n;"id"in t&&(null===(n=e[t.id])||void 0===n||n.call(e,t))}}})(),t={connecting:(null===S||void 0===S?void 0:S.connecting)?[S.connecting]:[],opened:(null===S||void 0===S?void 0:S.opened)?[S.opened]:[],connected:(null===S||void 0===S?void 0:S.connected)?[S.connected]:[],ping:(null===S||void 0===S?void 0:S.ping)?[S.ping]:[],pong:(null===S||void 0===S?void 0:S.pong)?[S.pong]:[],message:(null===S||void 0===S?void 0:S.message)?[e.emit,S.message]:[e.emit],closed:(null===S||void 0===S?void 0:S.closed)?[S.closed]:[],error:(null===S||void 0===S?void 0:S.error)?[S.error]:[]};return{onMessage:e.on,on(e,n){const r=t[e];return r.push(n),()=>{r.splice(r.indexOf(n),1)}},emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];for(const i of[...t[e]])i(...r)}}})();function k(e){const t=[O.on("error",(n=>{t.forEach((e=>e())),e(n)})),O.on("closed",(n=>{t.forEach((e=>e())),e(n)}))]}let P,V,L=0,R=!1,M=0,j=!1;async function F(){clearTimeout(V);const[e,r]=await(null!==P&&void 0!==P?P:P=new Promise(((e,r)=>(async()=>{if(R){if(await g(M),!L)return P=void 0,r({code:1e3,reason:"All Subscriptions Gone"});M++}O.emit("connecting",R);const o=new A("function"===typeof t?await t():t,a);let l,f;function d(){isFinite(m)&&m>0&&(clearTimeout(f),f=setTimeout((()=>{o.readyState===A.OPEN&&(o.send(u({type:c.Ping})),O.emit("ping",!1,void 0))}),m))}k((e=>{P=void 0,clearTimeout(l),clearTimeout(f),r(e),e instanceof h&&(o.close(4499,"Terminated"),o.onerror=null,o.onclose=null)})),o.onerror=e=>O.emit("error",e),o.onclose=e=>O.emit("closed",e),o.onopen=async()=>{try{O.emit("opened",o);const e="function"===typeof n?await n():n;if(o.readyState!==A.OPEN)return;o.send(u(e?{type:c.ConnectionInit,payload:e}:{type:c.ConnectionInit},x)),isFinite(b)&&b>0&&(l=setTimeout((()=>{o.close(s.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")}),b)),d()}catch(e){O.emit("error",e),o.close(s.InternalClientError,i(e instanceof Error?e.message:new Error(e).message,"Internal client error"))}};let y=!1;o.onmessage=t=>{let{data:n}=t;try{const t=function(e,t){return p("string"===typeof e?JSON.parse(e,t):e)}(n,I);if(O.emit("message",t),"ping"===t.type||"pong"===t.type)return O.emit(t.type,!0,t.payload),void("pong"===t.type?d():v||(o.send(u(t.payload?{type:c.Pong,payload:t.payload}:{type:c.Pong})),O.emit("pong",!1,t.payload)));if(y)return;if(t.type!==c.ConnectionAck)throw new Error("First message cannot be of type ".concat(t.type));clearTimeout(l),y=!0,O.emit("connected",o,t.payload,R),R=!1,M=0,e([o,new Promise(((e,t)=>k(t)))])}catch(r){o.onmessage=null,O.emit("error",r),o.close(s.BadResponse,i(r instanceof Error?r.message:new Error(r).message,"Bad response"))}}})())));e.readyState===A.CLOSING&&await r;let o=()=>{};const l=new Promise((e=>o=e));return[e,o,Promise.race([l.then((()=>{if(!L){const t=()=>e.close(1e3,"Normal Closure");isFinite(d)&&d>0?V=setTimeout((()=>{e.readyState===A.OPEN&&t()}),d):t()}})),r])]}function U(e){if(y(e)&&(t=e.code,![1e3,1001,1006,1005,1012,1013,1014].includes(t)&&t>=1e3&&t<=1999||[s.InternalServerError,s.InternalClientError,s.BadRequest,s.BadResponse,s.Unauthorized,s.SubprotocolNotAcceptable,s.SubscriberAlreadyExists,s.TooManyInitialisationRequests].includes(e.code)))throw e;var t;if(j)return!1;if(y(e)&&1e3===e.code)return L>0;if(!_||M>=_)throw e;if(!E(e))throw e;if(null===w||void 0===w?void 0:w(e))throw e;return R=!0}function q(e,t){const n=N(e);let r=!1,o=!1,i=()=>{L--,r=!0};return(async()=>{for(L++;;)try{const[a,s,p]=await F();if(r)return s();const l=O.onMessage(n,(e=>{switch(e.type){case c.Next:return void t.next(e.payload);case c.Error:return o=!0,r=!0,t.error(e.payload),void i();case c.Complete:return r=!0,void i()}}));return a.send(u({id:n,type:c.Subscribe,payload:e},x)),i=()=>{r||a.readyState!==A.OPEN||a.send(u({id:n,type:c.Complete},x)),L--,r=!0,s()},void await p.finally(l)}catch(a){if(!U(a))return}})().then((()=>{o||t.complete()})).catch((e=>{t.error(e)})),()=>{r||i()}}return r||(async()=>{for(L++;;)try{const[,,e]=await F();await e}catch(e){try{if(!U(e))return}catch(e){return null===o||void 0===o?void 0:o(e)}}})(),{on:O.on,subscribe:q,iterate(e){const t=[],n={done:!1,error:null,resolve:()=>{}},r=q(e,{next(e){t.push(e),n.resolve()},error(e){n.done=!0,n.error=e,n.resolve()},complete(){n.done=!0,n.resolve()}}),o=function(){return f(this,arguments,(function*(){for(;;){for(t.length||(yield l(new Promise((e=>n.resolve=e))));t.length;)yield yield l(t.shift());if(n.error)throw n.error;if(n.done)return yield l(void 0)}}))}();return o.throw=async e=>(n.done||(n.done=!0,n.error=e,n.resolve()),{done:!0,value:void 0}),o.return=async()=>(r(),{done:!0,value:void 0}),o},async dispose(){if(j=!0,P){const[e]=await P;e.close(1e3,"Normal Closure")}},terminate(){P&&O.emit("closed",new h)}}}class h extends Error{constructor(){super(...arguments),this.name="TerminatedCloseEvent",this.message="4499: Terminated",this.code=4499,this.reason="Terminated",this.wasClean=!1}}function y(e){return o(e)&&"code"in e&&"reason"in e}}}]);