(function(I,C){typeof exports=="object"&&typeof module<"u"?module.exports=C():typeof define=="function"&&define.amd?define(C):(I=typeof globalThis<"u"?globalThis:I||self,I["urql-scalars-exchange"]=C())})(this,function(){"use strict";function I(e,t){if(!!!e)throw new Error(t)}function C(e){return typeof e=="object"&&e!==null}function Ne(e,t){if(!!!e)throw new Error(t??"Unexpected invariant triggered.")}const Ct=/\r\n|[\n\r]/g;function ke(e,t){let n=0,s=1;for(const i of e.body.matchAll(Ct)){if(typeof i.index=="number"||Ne(!1),i.index>=t)break;n=i.index+i[0].length,s+=1}return{line:s,column:t+1-n}}function Ut(e){return Je(e.source,ke(e.source,e.start))}function Je(e,t){const n=e.locationOffset.column-1,s="".padStart(n)+e.body,i=t.line-1,r=e.locationOffset.line-1,a=t.line+r,l=t.line===1?n:0,p=t.column+l,f=`${e.name}:${a}:${p} `,h=s.split(/\r\n|[\n\r]/g),g=h[i];if(g.length>120){const T=Math.floor(p/80),b=p%80,y=[];for(let x=0;x["|",x]),["|","^".padStart(b)],["|",y[T+1]]])}return f+Ye([[`${a-1} |`,h[i-1]],[`${a} |`,g],["|","^".padStart(p)],[`${a+1} |`,h[i+1]]])}function Ye(e){const t=e.filter(([s,i])=>i!==void 0),n=Math.max(...t.map(([s])=>s.length));return t.map(([s,i])=>s.padStart(n)+(i?" "+i:"")).join(` `)}function Mt(e){const t=e[0];return t==null||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}class A extends Error{constructor(t,...n){var s,i,r;const{nodes:a,source:l,positions:p,path:f,originalError:h,extensions:g}=Mt(n);super(t),this.name="GraphQLError",this.path=f??void 0,this.originalError=h??void 0,this.nodes=qe(Array.isArray(a)?a:a?[a]:void 0);const T=qe((s=this.nodes)===null||s===void 0?void 0:s.map(y=>y.loc).filter(y=>y!=null));this.source=l??(T==null||(i=T[0])===null||i===void 0?void 0:i.source),this.positions=p??(T==null?void 0:T.map(y=>y.start)),this.locations=p&&l?p.map(y=>ke(l,y)):T==null?void 0:T.map(y=>ke(y.source,y.start));const b=C(h==null?void 0:h.extensions)?h==null?void 0:h.extensions:void 0;this.extensions=(r=g??b)!==null&&r!==void 0?r:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),h!=null&&h.stack?Object.defineProperty(this,"stack",{value:h.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,A):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let t=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(t+=` `+Ut(n.loc));else if(this.source&&this.locations)for(const n of this.locations)t+=` `+Je(this.source,n);return t}toJSON(){const t={message:this.message};return this.locations!=null&&(t.locations=this.locations),this.path!=null&&(t.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(t.extensions=this.extensions),t}}function qe(e){return e===void 0||e.length===0?void 0:e}function k(e,t,n){return new A(`Syntax Error: ${n}`,{source:e,positions:[t]})}class Vt{constructor(t,n,s){this.start=t.start,this.end=n.end,this.startToken=t,this.endToken=n,this.source=s}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class ze{constructor(t,n,s,i,r,a){this.kind=t,this.start=n,this.end=s,this.line=i,this.column=r,this.value=a,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const Xe={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},jt=new Set(Object.keys(Xe));function ve(e){const t=e==null?void 0:e.kind;return typeof t=="string"&&jt.has(t)}var H;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"})(H||(H={}));var _;(function(e){e.QUERY="QUERY",e.MUTATION="MUTATION",e.SUBSCRIPTION="SUBSCRIPTION",e.FIELD="FIELD",e.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",e.FRAGMENT_SPREAD="FRAGMENT_SPREAD",e.INLINE_FRAGMENT="INLINE_FRAGMENT",e.VARIABLE_DEFINITION="VARIABLE_DEFINITION",e.SCHEMA="SCHEMA",e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.FIELD_DEFINITION="FIELD_DEFINITION",e.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.ENUM_VALUE="ENUM_VALUE",e.INPUT_OBJECT="INPUT_OBJECT",e.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"})(_||(_={}));var c;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(c||(c={}));function Re(e){return e===9||e===32}function de(e){return e>=48&&e<=57}function He(e){return e>=97&&e<=122||e>=65&&e<=90}function Fe(e){return He(e)||e===95}function Ze(e){return He(e)||de(e)||e===95}function Bt(e){var t;let n=Number.MAX_SAFE_INTEGER,s=null,i=-1;for(let a=0;al===0?a:a.slice(n)).slice((t=s)!==null&&t!==void 0?t:0,i+1)}function $t(e){let t=0;for(;t1&&s.slice(1).every(b=>b.length===0||Re(b.charCodeAt(0))),a=n.endsWith('\\"""'),l=e.endsWith('"')&&!a,p=e.endsWith("\\"),f=l||p,h=!(t!=null&&t.minimize)&&(!i||e.length>70||f||r||a);let g="";const T=i&&Re(e.charCodeAt(0));return(h&&!T||r)&&(g+=` `),g+=n,(h||f)&&(g+=` `),'"""'+g+'"""'}var o;(function(e){e.SOF="",e.EOF="",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"})(o||(o={}));class Gt{constructor(t){const n=new ze(o.SOF,0,0,0,0);this.source=t,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let t=this.token;if(t.kind!==o.EOF)do if(t.next)t=t.next;else{const n=Jt(this,t.end);t.next=n,n.prev=t,t=n}while(t.kind===o.COMMENT);return t}}function Qt(e){return e===o.BANG||e===o.DOLLAR||e===o.AMP||e===o.PAREN_L||e===o.PAREN_R||e===o.SPREAD||e===o.COLON||e===o.EQUALS||e===o.AT||e===o.BRACKET_L||e===o.BRACKET_R||e===o.BRACE_L||e===o.PIPE||e===o.BRACE_R}function ce(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function Ie(e,t){return We(e.charCodeAt(t))&&Ke(e.charCodeAt(t+1))}function We(e){return e>=55296&&e<=56319}function Ke(e){return e>=56320&&e<=57343}function ie(e,t){const n=e.source.body.codePointAt(t);if(n===void 0)return o.EOF;if(n>=32&&n<=126){const s=String.fromCodePoint(n);return s==='"'?`'"'`:`"${s}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function D(e,t,n,s,i){const r=e.line,a=1+n-e.lineStart;return new ze(t,n,s,r,a,i)}function Jt(e,t){const n=e.source.body,s=n.length;let i=t;for(;i=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function Zt(e,t){const n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:` `,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw k(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function Wt(e,t){const n=e.source.body,s=n.length;let i=e.lineStart,r=t+3,a=r,l="";const p=[];for(;rtt?"["+an(e)+"]":"{ "+n.map(([i,r])=>i+": "+_e(r,t)).join(", ")+" }"}function rn(e,t){if(e.length===0)return"[]";if(t.length>tt)return"[Array]";const n=Math.min(en,e.length),s=e.length-n,i=[];for(let r=0;r1&&i.push(`... ${s} more items`),"["+i.join(", ")+"]"}function an(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(t==="Object"&&typeof e.constructor=="function"){const n=e.constructor.name;if(typeof n=="string"&&n!=="")return n}return t}const q=globalThis.process&&globalThis.process.env.NODE_ENV==="production"?function(t,n){return t instanceof n}:function(t,n){if(t instanceof n)return!0;if(typeof t=="object"&&t!==null){var s;const i=n.prototype[Symbol.toStringTag],r=Symbol.toStringTag in t?t[Symbol.toStringTag]:(s=t.constructor)===null||s===void 0?void 0:s.name;if(i===r){const a=m(t);throw new Error(`Cannot use ${i} "${a}" from another module or realm. Ensure that there is only one instance of "graphql" in the node_modules directory. If different versions of "graphql" are the dependencies of other relied on modules, use "resolutions" to ensure only one version is installed. https://yarnpkg.com/en/docs/selective-version-resolutions Duplicate "graphql" modules cannot be used at the same time since different versions may have different capabilities and behavior. The data from one version used in the function from another could produce confusing and spurious results.`)}}return!1};class nt{constructor(t,n="GraphQL request",s={line:1,column:1}){typeof t=="string"||I(!1,`Body must be a string. Received: ${m(t)}.`),this.body=t,this.name=n,this.locationOffset=s,this.locationOffset.line>0||I(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||I(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function on(e){return q(e,nt)}function cn(e,t){const n=new un(e,t);n.expectToken(o.SOF);const s=n.parseValueLiteral(!1);return n.expectToken(o.EOF),s}class un{constructor(t,n={}){const s=on(t)?t:new nt(t);this._lexer=new Gt(s),this._options=n,this._tokenCounter=0}parseName(){const t=this.expectToken(o.NAME);return this.node(t,{kind:c.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:c.DOCUMENT,definitions:this.many(o.SOF,this.parseDefinition,o.EOF)})}parseDefinition(){if(this.peek(o.BRACE_L))return this.parseOperationDefinition();const t=this.peekDescription(),n=t?this._lexer.lookahead():this._lexer.token;if(n.kind===o.NAME){switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(t)throw k(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(n.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(n)}parseOperationDefinition(){const t=this._lexer.token;if(this.peek(o.BRACE_L))return this.node(t,{kind:c.OPERATION_DEFINITION,operation:H.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const n=this.parseOperationType();let s;return this.peek(o.NAME)&&(s=this.parseName()),this.node(t,{kind:c.OPERATION_DEFINITION,operation:n,name:s,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const t=this.expectToken(o.NAME);switch(t.value){case"query":return H.QUERY;case"mutation":return H.MUTATION;case"subscription":return H.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(o.PAREN_L,this.parseVariableDefinition,o.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:c.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(o.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(o.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const t=this._lexer.token;return this.expectToken(o.DOLLAR),this.node(t,{kind:c.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:c.SELECTION_SET,selections:this.many(o.BRACE_L,this.parseSelection,o.BRACE_R)})}parseSelection(){return this.peek(o.SPREAD)?this.parseFragment():this.parseField()}parseField(){const t=this._lexer.token,n=this.parseName();let s,i;return this.expectOptionalToken(o.COLON)?(s=n,i=this.parseName()):i=n,this.node(t,{kind:c.FIELD,alias:s,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(o.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){const n=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(o.PAREN_L,n,o.PAREN_R)}parseArgument(t=!1){const n=this._lexer.token,s=this.parseName();return this.expectToken(o.COLON),this.node(n,{kind:c.ARGUMENT,name:s,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const t=this._lexer.token;this.expectToken(o.SPREAD);const n=this.expectOptionalKeyword("on");return!n&&this.peek(o.NAME)?this.node(t,{kind:c.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(t,{kind:c.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const t=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(t,{kind:c.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(t,{kind:c.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(t){const n=this._lexer.token;switch(n.kind){case o.BRACKET_L:return this.parseList(t);case o.BRACE_L:return this.parseObject(t);case o.INT:return this.advanceLexer(),this.node(n,{kind:c.INT,value:n.value});case o.FLOAT:return this.advanceLexer(),this.node(n,{kind:c.FLOAT,value:n.value});case o.STRING:case o.BLOCK_STRING:return this.parseStringLiteral();case o.NAME:switch(this.advanceLexer(),n.value){case"true":return this.node(n,{kind:c.BOOLEAN,value:!0});case"false":return this.node(n,{kind:c.BOOLEAN,value:!1});case"null":return this.node(n,{kind:c.NULL});default:return this.node(n,{kind:c.ENUM,value:n.value})}case o.DOLLAR:if(t)if(this.expectToken(o.DOLLAR),this._lexer.token.kind===o.NAME){const s=this._lexer.token.value;throw k(this._lexer.source,n.start,`Unexpected variable "$${s}" in constant value.`)}else throw this.unexpected(n);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const t=this._lexer.token;return this.advanceLexer(),this.node(t,{kind:c.STRING,value:t.value,block:t.kind===o.BLOCK_STRING})}parseList(t){const n=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:c.LIST,values:this.any(o.BRACKET_L,n,o.BRACKET_R)})}parseObject(t){const n=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:c.OBJECT,fields:this.any(o.BRACE_L,n,o.BRACE_R)})}parseObjectField(t){const n=this._lexer.token,s=this.parseName();return this.expectToken(o.COLON),this.node(n,{kind:c.OBJECT_FIELD,name:s,value:this.parseValueLiteral(t)})}parseDirectives(t){const n=[];for(;this.peek(o.AT);)n.push(this.parseDirective(t));return n}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){const n=this._lexer.token;return this.expectToken(o.AT),this.node(n,{kind:c.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){const t=this._lexer.token;let n;if(this.expectOptionalToken(o.BRACKET_L)){const s=this.parseTypeReference();this.expectToken(o.BRACKET_R),n=this.node(t,{kind:c.LIST_TYPE,type:s})}else n=this.parseNamedType();return this.expectOptionalToken(o.BANG)?this.node(t,{kind:c.NON_NULL_TYPE,type:n}):n}parseNamedType(){return this.node(this._lexer.token,{kind:c.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(o.STRING)||this.peek(o.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");const s=this.parseConstDirectives(),i=this.many(o.BRACE_L,this.parseOperationTypeDefinition,o.BRACE_R);return this.node(t,{kind:c.SCHEMA_DEFINITION,description:n,directives:s,operationTypes:i})}parseOperationTypeDefinition(){const t=this._lexer.token,n=this.parseOperationType();this.expectToken(o.COLON);const s=this.parseNamedType();return this.node(t,{kind:c.OPERATION_TYPE_DEFINITION,operation:n,type:s})}parseScalarTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");const s=this.parseName(),i=this.parseConstDirectives();return this.node(t,{kind:c.SCALAR_TYPE_DEFINITION,description:n,name:s,directives:i})}parseObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");const s=this.parseName(),i=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:c.OBJECT_TYPE_DEFINITION,description:n,name:s,interfaces:i,directives:r,fields:a})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(o.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(o.BRACE_L,this.parseFieldDefinition,o.BRACE_R)}parseFieldDefinition(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseName(),i=this.parseArgumentDefs();this.expectToken(o.COLON);const r=this.parseTypeReference(),a=this.parseConstDirectives();return this.node(t,{kind:c.FIELD_DEFINITION,description:n,name:s,arguments:i,type:r,directives:a})}parseArgumentDefs(){return this.optionalMany(o.PAREN_L,this.parseInputValueDef,o.PAREN_R)}parseInputValueDef(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseName();this.expectToken(o.COLON);const i=this.parseTypeReference();let r;this.expectOptionalToken(o.EQUALS)&&(r=this.parseConstValueLiteral());const a=this.parseConstDirectives();return this.node(t,{kind:c.INPUT_VALUE_DEFINITION,description:n,name:s,type:i,defaultValue:r,directives:a})}parseInterfaceTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");const s=this.parseName(),i=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:c.INTERFACE_TYPE_DEFINITION,description:n,name:s,interfaces:i,directives:r,fields:a})}parseUnionTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");const s=this.parseName(),i=this.parseConstDirectives(),r=this.parseUnionMemberTypes();return this.node(t,{kind:c.UNION_TYPE_DEFINITION,description:n,name:s,directives:i,types:r})}parseUnionMemberTypes(){return this.expectOptionalToken(o.EQUALS)?this.delimitedMany(o.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");const s=this.parseName(),i=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();return this.node(t,{kind:c.ENUM_TYPE_DEFINITION,description:n,name:s,directives:i,values:r})}parseEnumValuesDefinition(){return this.optionalMany(o.BRACE_L,this.parseEnumValueDefinition,o.BRACE_R)}parseEnumValueDefinition(){const t=this._lexer.token,n=this.parseDescription(),s=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(t,{kind:c.ENUM_VALUE_DEFINITION,description:n,name:s,directives:i})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw k(this._lexer.source,this._lexer.token.start,`${ge(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");const s=this.parseName(),i=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();return this.node(t,{kind:c.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:s,directives:i,fields:r})}parseInputFieldsDefinition(){return this.optionalMany(o.BRACE_L,this.parseInputValueDef,o.BRACE_R)}parseTypeSystemExtension(){const t=this._lexer.lookahead();if(t.kind===o.NAME)switch(t.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(t)}parseSchemaExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const n=this.parseConstDirectives(),s=this.optionalMany(o.BRACE_L,this.parseOperationTypeDefinition,o.BRACE_R);if(n.length===0&&s.length===0)throw this.unexpected();return this.node(t,{kind:c.SCHEMA_EXTENSION,directives:n,operationTypes:s})}parseScalarTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const n=this.parseName(),s=this.parseConstDirectives();if(s.length===0)throw this.unexpected();return this.node(t,{kind:c.SCALAR_TYPE_EXTENSION,name:n,directives:s})}parseObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const n=this.parseName(),s=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),r=this.parseFieldsDefinition();if(s.length===0&&i.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:c.OBJECT_TYPE_EXTENSION,name:n,interfaces:s,directives:i,fields:r})}parseInterfaceTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const n=this.parseName(),s=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),r=this.parseFieldsDefinition();if(s.length===0&&i.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:c.INTERFACE_TYPE_EXTENSION,name:n,interfaces:s,directives:i,fields:r})}parseUnionTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const n=this.parseName(),s=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(s.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:c.UNION_TYPE_EXTENSION,name:n,directives:s,types:i})}parseEnumTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const n=this.parseName(),s=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(s.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:c.ENUM_TYPE_EXTENSION,name:n,directives:s,values:i})}parseInputObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const n=this.parseName(),s=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(s.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:c.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:s,fields:i})}parseDirectiveDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(o.AT);const s=this.parseName(),i=this.parseArgumentDefs(),r=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const a=this.parseDirectiveLocations();return this.node(t,{kind:c.DIRECTIVE_DEFINITION,description:n,name:s,arguments:i,repeatable:r,locations:a})}parseDirectiveLocations(){return this.delimitedMany(o.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const t=this._lexer.token,n=this.parseName();if(Object.prototype.hasOwnProperty.call(_,n.value))return n;throw this.unexpected(t)}node(t,n){return this._options.noLocation!==!0&&(n.loc=new Vt(t,this._lexer.lastToken,this._lexer.source)),n}peek(t){return this._lexer.token.kind===t}expectToken(t){const n=this._lexer.token;if(n.kind===t)return this.advanceLexer(),n;throw k(this._lexer.source,n.start,`Expected ${it(t)}, found ${ge(n)}.`)}expectOptionalToken(t){return this._lexer.token.kind===t?(this.advanceLexer(),!0):!1}expectKeyword(t){const n=this._lexer.token;if(n.kind===o.NAME&&n.value===t)this.advanceLexer();else throw k(this._lexer.source,n.start,`Expected "${t}", found ${ge(n)}.`)}expectOptionalKeyword(t){const n=this._lexer.token;return n.kind===o.NAME&&n.value===t?(this.advanceLexer(),!0):!1}unexpected(t){const n=t??this._lexer.token;return k(this._lexer.source,n.start,`Unexpected ${ge(n)}.`)}any(t,n,s){this.expectToken(t);const i=[];for(;!this.expectOptionalToken(s);)i.push(n.call(this));return i}optionalMany(t,n,s){if(this.expectOptionalToken(t)){const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(s));return i}return[]}many(t,n,s){this.expectToken(t);const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(s));return i}delimitedMany(t,n){this.expectOptionalToken(t);const s=[];do s.push(n.call(this));while(this.expectOptionalToken(t));return s}advanceLexer(){const{maxTokens:t}=this._options,n=this._lexer.advance();if(t!==void 0&&n.kind!==o.EOF&&(++this._tokenCounter,this._tokenCounter>t))throw k(this._lexer.source,n.start,`Document contains more that ${t} tokens. Parsing aborted.`)}}function ge(e){const t=e.value;return it(e.kind)+(t!=null?` "${t}"`:"")}function it(e){return Qt(e)?`"${e}"`:e}const ln=5;function pn(e,t){const[n,s]=t?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const r=s.map(p=>`"${p}"`);switch(r.length){case 0:return"";case 1:return i+r[0]+"?";case 2:return i+r[0]+" or "+r[1]+"?"}const a=r.slice(0,ln),l=a.pop();return i+a.join(", ")+", or "+l+"?"}function st(e){return e}function rt(e,t){const n=Object.create(null);for(const s of e)n[t(s)]=s;return n}function se(e,t,n){const s=Object.create(null);for(const i of e)s[t(i)]=n(i);return s}function Ae(e,t){const n=Object.create(null);for(const s of Object.keys(e))n[s]=t(e[s],s);return n}function dn(e,t){let n=0,s=0;for(;n0);let l=0;do++s,l=l*10+r-Ue,r=t.charCodeAt(s);while(Se(r)&&l>0);if(al)return 1}else{if(ir)return 1;++n,++s}}return e.length-t.length}const Ue=48,hn=57;function Se(e){return!isNaN(e)&&Ue<=e&&e<=hn}function fn(e,t){const n=Object.create(null),s=new mn(e),i=Math.floor(e.length*.4)+1;for(const r of t){const a=s.measure(r,i);a!==void 0&&(n[r]=a)}return Object.keys(n).sort((r,a)=>{const l=n[r]-n[a];return l!==0?l:dn(r,a)})}class mn{constructor(t){this._input=t,this._inputLowerCase=t.toLowerCase(),this._inputArray=at(this._inputLowerCase),this._rows=[new Array(t.length+1).fill(0),new Array(t.length+1).fill(0),new Array(t.length+1).fill(0)]}measure(t,n){if(this._input===t)return 0;const s=t.toLowerCase();if(this._inputLowerCase===s)return 1;let i=at(s),r=this._inputArray;if(i.lengthn)return;const p=this._rows;for(let h=0;h<=l;h++)p[0][h]=h;for(let h=1;h<=a;h++){const g=p[(h-1)%3],T=p[h%3];let b=T[0]=h;for(let y=1;y<=l;y++){const x=i[h-1]===r[y-1]?0:1;let L=Math.min(g[y]+1,T[y-1]+1,g[y-1]+x);if(h>1&&y>1&&i[h-1]===r[y-2]&&i[h-2]===r[y-1]){const w=p[(h-2)%3][y-2];L=Math.min(L,w+1)}Ln)return}const f=p[a%3][l];return f<=n?f:void 0}}function at(e){const t=e.length,n=new Array(t);for(let s=0;se.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>d(e.definitions,` `)},OperationDefinition:{leave(e){const t=N("(",d(e.variableDefinitions,", "),")"),n=d([e.operation,d([e.name,t]),d(e.directives," ")]," ");return(n==="query"?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:s})=>e+": "+t+N(" = ",n)+N(" ",d(s," "))},SelectionSet:{leave:({selections:e})=>$(e)},Field:{leave({alias:e,name:t,arguments:n,directives:s,selectionSet:i}){const r=N("",e,": ")+t;let a=r+N("(",d(n,", "),")");return a.length>In&&(a=r+N(`( `,be(d(n,` `)),` )`)),d([a,d(s," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+N(" ",d(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>d(["...",N("on ",e),d(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:s,selectionSet:i})=>`fragment ${e}${N("(",d(n,", "),")")} on ${t} ${N("",d(s," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?Pt(e):Tn(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+d(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+d(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+N("(",d(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>N("",e,` `)+d(["schema",d(t," "),$(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>N("",e,` `)+d(["scalar",t,d(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:s,fields:i})=>N("",e,` `)+d(["type",t,N("implements ",d(n," & ")),d(s," "),$(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:s,directives:i})=>N("",e,` `)+t+(ct(n)?N(`( `,be(d(n,` `)),` )`):N("(",d(n,", "),")"))+": "+s+N(" ",d(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:s,directives:i})=>N("",e,` `)+d([t+": "+n,N("= ",s),d(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:s,fields:i})=>N("",e,` `)+d(["interface",t,N("implements ",d(n," & ")),d(s," "),$(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:s})=>N("",e,` `)+d(["union",t,d(n," "),N("= ",d(s," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:s})=>N("",e,` `)+d(["enum",t,d(n," "),$(s)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>N("",e,` `)+d([t,d(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:s})=>N("",e,` `)+d(["input",t,d(n," "),$(s)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:s,locations:i})=>N("",e,` `)+"directive @"+t+(ct(n)?N(`( `,be(d(n,` `)),` )`):N("(",d(n,", "),")"))+(s?" repeatable":"")+" on "+d(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>d(["extend schema",d(e," "),$(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>d(["extend scalar",e,d(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:s})=>d(["extend type",e,N("implements ",d(t," & ")),d(n," "),$(s)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:s})=>d(["extend interface",e,N("implements ",d(t," & ")),d(n," "),$(s)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>d(["extend union",e,d(t," "),N("= ",d(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>d(["extend enum",e,d(t," "),$(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>d(["extend input",e,d(t," "),$(n)]," ")}};function d(e,t=""){var n;return(n=e==null?void 0:e.filter(s=>s).join(t))!==null&&n!==void 0?n:""}function $(e){return N(`{ `,be(d(e,` `)),` }`)}function N(e,t,n=""){return t!=null&&t!==""?e+t+n:""}function be(e){return N(" ",e.replace(/\n/g,` `))}function ct(e){var t;return(t=e==null?void 0:e.some(n=>n.includes(` `)))!==null&&t!==void 0?t:!1}function Ve(e,t){switch(e.kind){case c.NULL:return null;case c.INT:return parseInt(e.value,10);case c.FLOAT:return parseFloat(e.value);case c.STRING:case c.ENUM:case c.BOOLEAN:return e.value;case c.LIST:return e.values.map(n=>Ve(n,t));case c.OBJECT:return se(e.fields,n=>n.name.value,n=>Ve(n.value,t));case c.VARIABLE:return t==null?void 0:t[e.name.value]}}function P(e){if(e!=null||I(!1,"Must provide name."),typeof e=="string"||I(!1,"Expected name to be a string."),e.length===0)throw new A("Expected name to be a non-empty string.");for(let t=1;ta(Ve(l,p)),this.extensions=j(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(r=t.extensionASTNodes)!==null&&r!==void 0?r:[],t.specifiedByURL==null||typeof t.specifiedByURL=="string"||I(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${m(t.specifiedByURL)}.`),t.serialize==null||typeof t.serialize=="function"||I(!1,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),t.parseLiteral&&(typeof t.parseValue=="function"&&typeof t.parseLiteral=="function"||I(!1,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}get[Symbol.toStringTag](){return"GraphQLScalarType"}toConfig(){return{name:this.name,description:this.description,specifiedByURL:this.specifiedByURL,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class ne{constructor(t){var n;this.name=P(t.name),this.description=t.description,this.isTypeOf=t.isTypeOf,this.extensions=j(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=()=>mt(t),this._interfaces=()=>ft(t),t.isTypeOf==null||typeof t.isTypeOf=="function"||I(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${m(t.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:yt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function ft(e){var t;const n=dt((t=e.interfaces)!==null&&t!==void 0?t:[]);return Array.isArray(n)||I(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function mt(e){const t=ht(e.fields);return le(t)||I(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Ae(t,(n,s)=>{var i;le(n)||I(!1,`${e.name}.${s} field config must be an object.`),n.resolve==null||typeof n.resolve=="function"||I(!1,`${e.name}.${s} field resolver must be a function if provided, but got: ${m(n.resolve)}.`);const r=(i=n.args)!==null&&i!==void 0?i:{};return le(r)||I(!1,`${e.name}.${s} args must be an object with argument names as keys.`),{name:P(s),description:n.description,type:n.type,args:Tt(r),resolve:n.resolve,subscribe:n.subscribe,deprecationReason:n.deprecationReason,extensions:j(n.extensions),astNode:n.astNode}})}function Tt(e){return Object.entries(e).map(([t,n])=>({name:P(t),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:j(n.extensions),astNode:n.astNode}))}function le(e){return C(e)&&!Array.isArray(e)}function yt(e){return Ae(e,t=>({description:t.description,type:t.type,args:Et(t.args),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:t.extensions,astNode:t.astNode}))}function Et(e){return se(e,t=>t.name,t=>({description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:t.extensions,astNode:t.astNode}))}class Nt{constructor(t){var n;this.name=P(t.name),this.description=t.description,this.resolveType=t.resolveType,this.extensions=j(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=mt.bind(void 0,t),this._interfaces=ft.bind(void 0,t),t.resolveType==null||typeof t.resolveType=="function"||I(!1,`${this.name} must provide "resolveType" as a function, but got: ${m(t.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:yt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class vt{constructor(t){var n;this.name=P(t.name),this.description=t.description,this.resolveType=t.resolveType,this.extensions=j(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._types=Ln.bind(void 0,t),t.resolveType==null||typeof t.resolveType=="function"||I(!1,`${this.name} must provide "resolveType" as a function, but got: ${m(t.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}getTypes(){return typeof this._types=="function"&&(this._types=this._types()),this._types}toConfig(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Ln(e){const t=dt(e.types);return Array.isArray(t)||I(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class Oe{constructor(t){var n;this.name=P(t.name),this.description=t.description,this.extensions=j(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._values=Dn(this.name,t.values),this._valueLookup=new Map(this._values.map(s=>[s.value,s])),this._nameLookup=rt(this._values,s=>s.name)}get[Symbol.toStringTag](){return"GraphQLEnumType"}getValues(){return this._values}getValue(t){return this._nameLookup[t]}serialize(t){const n=this._valueLookup.get(t);if(n===void 0)throw new A(`Enum "${this.name}" cannot represent value: ${m(t)}`);return n.name}parseValue(t){if(typeof t!="string"){const s=m(t);throw new A(`Enum "${this.name}" cannot represent non-string value: ${s}.`+xe(this,s))}const n=this.getValue(t);if(n==null)throw new A(`Value "${t}" does not exist in "${this.name}" enum.`+xe(this,t));return n.value}parseLiteral(t,n){if(t.kind!==c.ENUM){const i=W(t);throw new A(`Enum "${this.name}" cannot represent non-enum value: ${i}.`+xe(this,i),{nodes:t})}const s=this.getValue(t.value);if(s==null){const i=W(t);throw new A(`Value "${i}" does not exist in "${this.name}" enum.`+xe(this,i),{nodes:t})}return s.value}toConfig(){const t=se(this.getValues(),n=>n.name,n=>({description:n.description,value:n.value,deprecationReason:n.deprecationReason,extensions:n.extensions,astNode:n.astNode}));return{name:this.name,description:this.description,values:t,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function xe(e,t){const n=e.getValues().map(i=>i.name),s=fn(t,n);return pn("the enum value",s)}function Dn(e,t){return le(t)||I(!1,`${e} values must be an object with value names as keys.`),Object.entries(t).map(([n,s])=>(le(s)||I(!1,`${e}.${n} must refer to an object with a "value" key representing an internal value but got: ${m(s)}.`),{name:gn(n),description:s.description,value:s.value!==void 0?s.value:n,deprecationReason:s.deprecationReason,extensions:j(s.extensions),astNode:s.astNode}))}class It{constructor(t){var n;this.name=P(t.name),this.description=t.description,this.extensions=j(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=wn.bind(void 0,t)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}toConfig(){const t=Ae(this.getFields(),n=>({description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:n.extensions,astNode:n.astNode}));return{name:this.name,description:this.description,fields:t,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function wn(e){const t=ht(e.fields);return le(t)||I(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Ae(t,(n,s)=>(!("resolve"in n)||I(!1,`${e.name}.${s} field has a resolve property, but Input Types cannot define resolvers.`),{name:P(s),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:j(n.extensions),astNode:n.astNode}))}const $e=2147483647,Pe=-2147483648,kn=new oe({name:"Int",description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize(e){const t=Te(e);if(typeof t=="boolean")return t?1:0;let n=t;if(typeof t=="string"&&t!==""&&(n=Number(t)),typeof n!="number"||!Number.isInteger(n))throw new A(`Int cannot represent non-integer value: ${m(t)}`);if(n>$e||n$e||e$e||t({description:{type:O,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new v(new M(new v(J))),resolve(e){return Object.values(e.getTypeMap())}},queryType:{description:"The type that query operations will be rooted at.",type:new v(J),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:J,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:J,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new v(new M(new v(At))),resolve:e=>e.getDirectives()}})}),At=new ne({name:"__Directive",description:`A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document. In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.`,fields:()=>({name:{type:new v(O),resolve:e=>e.name},description:{type:O,resolve:e=>e.description},isRepeatable:{type:new v(B),resolve:e=>e.isRepeatable},locations:{type:new v(new M(new v(St))),resolve:e=>e.locations},args:{type:new v(new M(new v(Le))),args:{includeDeprecated:{type:B,defaultValue:!1}},resolve(e,{includeDeprecated:t}){return t?e.args:e.args.filter(n=>n.deprecationReason==null)}}})}),St=new Oe({name:"__DirectiveLocation",description:"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",values:{QUERY:{value:_.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:_.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:_.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:_.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:_.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:_.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:_.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:_.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:_.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:_.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:_.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:_.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:_.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:_.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:_.UNION,description:"Location adjacent to a union definition."},ENUM:{value:_.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:_.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:_.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:_.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),J=new ne({name:"__Type",description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:()=>({kind:{type:new v(xt),resolve(e){if(ue(e))return S.SCALAR;if(G(e))return S.OBJECT;if(U(e))return S.INTERFACE;if(K(e))return S.UNION;if(ee(e))return S.ENUM;if(te(e))return S.INPUT_OBJECT;if(re(e))return S.LIST;if(Q(e))return S.NON_NULL;Ne(!1,`Unexpected type: "${m(e)}".`)}},name:{type:O,resolve:e=>"name"in e?e.name:void 0},description:{type:O,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:O,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new M(new v(bt)),args:{includeDeprecated:{type:B,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(G(e)||U(e)){const n=Object.values(e.getFields());return t?n:n.filter(s=>s.deprecationReason==null)}}},interfaces:{type:new M(new v(J)),resolve(e){if(G(e)||U(e))return e.getInterfaces()}},possibleTypes:{type:new M(new v(J)),resolve(e,t,n,{schema:s}){if(bn(e))return s.getPossibleTypes(e)}},enumValues:{type:new M(new v(Ot)),args:{includeDeprecated:{type:B,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(ee(e)){const n=e.getValues();return t?n:n.filter(s=>s.deprecationReason==null)}}},inputFields:{type:new M(new v(Le)),args:{includeDeprecated:{type:B,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(te(e)){const n=Object.values(e.getFields());return t?n:n.filter(s=>s.deprecationReason==null)}}},ofType:{type:J,resolve:e=>"ofType"in e?e.ofType:void 0}})}),bt=new ne({name:"__Field",description:"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",fields:()=>({name:{type:new v(O),resolve:e=>e.name},description:{type:O,resolve:e=>e.description},args:{type:new v(new M(new v(Le))),args:{includeDeprecated:{type:B,defaultValue:!1}},resolve(e,{includeDeprecated:t}){return t?e.args:e.args.filter(n=>n.deprecationReason==null)}},type:{type:new v(J),resolve:e=>e.type},isDeprecated:{type:new v(B),resolve:e=>e.deprecationReason!=null},deprecationReason:{type:O,resolve:e=>e.deprecationReason}})}),Le=new ne({name:"__InputValue",description:"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",fields:()=>({name:{type:new v(O),resolve:e=>e.name},description:{type:O,resolve:e=>e.description},type:{type:new v(J),resolve:e=>e.type},defaultValue:{type:O,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,s=ye(n,t);return s?W(s):null}},isDeprecated:{type:new v(B),resolve:e=>e.deprecationReason!=null},deprecationReason:{type:O,resolve:e=>e.deprecationReason}})}),Ot=new ne({name:"__EnumValue",description:"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",fields:()=>({name:{type:new v(O),resolve:e=>e.name},description:{type:O,resolve:e=>e.description},isDeprecated:{type:new v(B),resolve:e=>e.deprecationReason!=null},deprecationReason:{type:O,resolve:e=>e.deprecationReason}})});var S;(function(e){e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.INPUT_OBJECT="INPUT_OBJECT",e.LIST="LIST",e.NON_NULL="NON_NULL"})(S||(S={}));const xt=new Oe({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:S.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:S.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:S.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:S.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:S.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:S.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:S.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:S.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),Lt={name:"__schema",type:new v(Ge),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:s})=>s,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Dt={name:"__type",type:J,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new v(O),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(e,{name:t},n,{schema:s})=>s.getType(t),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},wt={name:"__typename",type:new v(O),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:s})=>s.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Gn=Object.freeze([Ge,At,St,J,bt,Le,Ot,xt]);class Qn{constructor(t){var n,s;this.__validationErrors=t.assumeValid===!0?[]:void 0,C(t)||I(!1,"Must provide configuration object."),!t.types||Array.isArray(t.types)||I(!1,`"types" must be Array if provided but got: ${m(t.types)}.`),!t.directives||Array.isArray(t.directives)||I(!1,`"directives" must be Array if provided but got: ${m(t.directives)}.`),this.description=t.description,this.extensions=j(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._queryType=t.query,this._mutationType=t.mutation,this._subscriptionType=t.subscription,this._directives=(s=t.directives)!==null&&s!==void 0?s:$n;const i=new Set(t.types);if(t.types!=null)for(const r of t.types)i.delete(r),Y(r,i);this._queryType!=null&&Y(this._queryType,i),this._mutationType!=null&&Y(this._mutationType,i),this._subscriptionType!=null&&Y(this._subscriptionType,i);for(const r of this._directives)if(Cn(r))for(const a of r.args)Y(a.type,i);Y(Ge,i),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const r of i){if(r==null)continue;const a=r.name;if(a||I(!1,"One of the provided types for building the Schema is missing a name."),this._typeMap[a]!==void 0)throw new Error(`Schema must contain uniquely named types but contains multiple types named "${a}".`);if(this._typeMap[a]=r,U(r)){for(const l of r.getInterfaces())if(U(l)){let p=this._implementationsMap[l.name];p===void 0&&(p=this._implementationsMap[l.name]={objects:[],interfaces:[]}),p.interfaces.push(r)}}else if(G(r)){for(const l of r.getInterfaces())if(U(l)){let p=this._implementationsMap[l.name];p===void 0&&(p=this._implementationsMap[l.name]={objects:[],interfaces:[]}),p.objects.push(r)}}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(t){switch(t){case H.QUERY:return this.getQueryType();case H.MUTATION:return this.getMutationType();case H.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(t){return this.getTypeMap()[t]}getPossibleTypes(t){return K(t)?t.getTypes():this.getImplementations(t).objects}getImplementations(t){const n=this._implementationsMap[t.name];return n??{objects:[],interfaces:[]}}isSubType(t,n){let s=this._subTypeMap[t.name];if(s===void 0){if(s=Object.create(null),K(t))for(const i of t.getTypes())s[i.name]=!0;else{const i=this.getImplementations(t);for(const r of i.objects)s[r.name]=!0;for(const r of i.interfaces)s[r.name]=!0}this._subTypeMap[t.name]=s}return s[n.name]!==void 0}getDirectives(){return this._directives}getDirective(t){return this.getDirectives().find(n=>n.name===t)}toConfig(){return{description:this.description,query:this.getQueryType(),mutation:this.getMutationType(),subscription:this.getSubscriptionType(),types:Object.values(this.getTypeMap()),directives:this.getDirectives(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,assumeValid:this.__validationErrors!==void 0}}}function Y(e,t){const n=me(e);if(!t.has(n)){if(t.add(n),K(n))for(const s of n.getTypes())Y(s,t);else if(G(n)||U(n)){for(const s of n.getInterfaces())Y(s,t);for(const s of Object.values(n.getFields())){Y(s.type,t);for(const i of s.args)Y(i.type,t)}}else if(te(n))for(const s of Object.values(n.getFields()))Y(s.type,t)}return t}function De(e,t){switch(t.kind){case c.LIST_TYPE:{const n=De(e,t.type);return n&&new M(n)}case c.NON_NULL_TYPE:{const n=De(e,t.type);return n&&new v(n)}case c.NAMED_TYPE:return e.getType(t.name.value)}}class Jn{constructor(t,n,s){this._schema=t,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=s??Yn,n&&(ae(n)&&this._inputTypeStack.push(n),je(n)&&this._parentTypeStack.push(n),fe(n)&&this._typeStack.push(n))}get[Symbol.toStringTag](){return"TypeInfo"}getType(){if(this._typeStack.length>0)return this._typeStack[this._typeStack.length-1]}getParentType(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]}getInputType(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]}getParentInputType(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]}getFieldDef(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]}getDefaultValue(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]}getDirective(){return this._directive}getArgument(){return this._argument}getEnumValue(){return this._enumValue}enter(t){const n=this._schema;switch(t.kind){case c.SELECTION_SET:{const i=me(this.getType());this._parentTypeStack.push(je(i)?i:void 0);break}case c.FIELD:{const i=this.getParentType();let r,a;i&&(r=this._getFieldDef(n,i,t),r&&(a=r.type)),this._fieldDefStack.push(r),this._typeStack.push(fe(a)?a:void 0);break}case c.DIRECTIVE:this._directive=n.getDirective(t.name.value);break;case c.OPERATION_DEFINITION:{const i=n.getRootType(t.operation);this._typeStack.push(G(i)?i:void 0);break}case c.INLINE_FRAGMENT:case c.FRAGMENT_DEFINITION:{const i=t.typeCondition,r=i?De(n,i):me(this.getType());this._typeStack.push(fe(r)?r:void 0);break}case c.VARIABLE_DEFINITION:{const i=De(n,t.type);this._inputTypeStack.push(ae(i)?i:void 0);break}case c.ARGUMENT:{var s;let i,r;const a=(s=this.getDirective())!==null&&s!==void 0?s:this.getFieldDef();a&&(i=a.args.find(l=>l.name===t.name.value),i&&(r=i.type)),this._argument=i,this._defaultValueStack.push(i?i.defaultValue:void 0),this._inputTypeStack.push(ae(r)?r:void 0);break}case c.LIST:{const i=xn(this.getInputType()),r=re(i)?i.ofType:i;this._defaultValueStack.push(void 0),this._inputTypeStack.push(ae(r)?r:void 0);break}case c.OBJECT_FIELD:{const i=me(this.getInputType());let r,a;te(i)&&(a=i.getFields()[t.name.value],a&&(r=a.type)),this._defaultValueStack.push(a?a.defaultValue:void 0),this._inputTypeStack.push(ae(r)?r:void 0);break}case c.ENUM:{const i=me(this.getInputType());let r;ee(i)&&(r=i.getValue(t.value)),this._enumValue=r;break}}}leave(t){switch(t.kind){case c.SELECTION_SET:this._parentTypeStack.pop();break;case c.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case c.DIRECTIVE:this._directive=null;break;case c.OPERATION_DEFINITION:case c.INLINE_FRAGMENT:case c.FRAGMENT_DEFINITION:this._typeStack.pop();break;case c.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case c.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case c.LIST:case c.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case c.ENUM:this._enumValue=null;break}}}function Yn(e,t,n){const s=n.name.value;if(s===Lt.name&&e.getQueryType()===t)return Lt;if(s===Dt.name&&e.getQueryType()===t)return Dt;if(s===wt.name&&je(t))return wt;if(G(t)||U(t))return t.getFields()[s]}function qn(e,t){return{enter(...n){const s=n[0];e.enter(s);const i=Me(t,s.kind).enter;if(i){const r=i.apply(t,n);return r!==void 0&&(e.leave(s),ve(r)&&e.enter(r)),r}},leave(...n){const s=n[0],i=Me(t,s.kind).leave;let r;return i&&(r=i.apply(t,n)),e.leave(s),r}}}function Ee(e,t,n){if(e){if(e.kind===c.VARIABLE){const s=e.name.value;if(n==null||n[s]===void 0)return;const i=n[s];return i===null&&Q(t)?void 0:i}if(Q(t))return e.kind===c.NULL?void 0:Ee(e,t.ofType,n);if(e.kind===c.NULL)return null;if(re(t)){const s=t.ofType;if(e.kind===c.LIST){const r=[];for(const a of e.values)if(kt(a,n)){if(Q(s))return;r.push(null)}else{const l=Ee(a,s,n);if(l===void 0)return;r.push(l)}return r}const i=Ee(e,s,n);return i===void 0?void 0:[i]}if(te(t)){if(e.kind!==c.OBJECT)return;const s=Object.create(null),i=rt(e.fields,r=>r.name.value);for(const r of Object.values(t.getFields())){const a=i[r.name];if(!a||kt(a.value,n)){if(r.defaultValue!==void 0)s[r.name]=r.defaultValue;else if(Q(r.type))return;continue}const l=Ee(a.value,r.type,n);if(l===void 0)return;s[r.name]=l}return s}if(lt(t)){let s;try{s=t.parseLiteral(e,n)}catch{return}return s===void 0?void 0:s}Ne(!1,"Unexpected input type: "+m(t))}}function kt(e,t){return e.kind===c.VARIABLE&&(t==null||t[e.name.value]===void 0)}function zn(e,t){C(e)&&C(e.__schema)||I(!1,`Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${m(e)}.`);const n=e.__schema,s=se(n.types,u=>u.name,u=>T(u));for(const u of[...Fn,...Gn])s[u.name]&&(s[u.name]=u);const i=n.queryType?h(n.queryType):null,r=n.mutationType?h(n.mutationType):null,a=n.subscriptionType?h(n.subscriptionType):null,l=n.directives?n.directives.map(ti):[];return new Qn({description:n.description,query:i,mutation:r,subscription:a,types:Object.values(s),directives:l,assumeValid:t==null?void 0:t.assumeValid});function p(u){if(u.kind===S.LIST){const E=u.ofType;if(!E)throw new Error("Decorated type deeper than introspection query.");return new M(p(E))}if(u.kind===S.NON_NULL){const E=u.ofType;if(!E)throw new Error("Decorated type deeper than introspection query.");const X=p(E);return new v(On(X))}return f(u)}function f(u){const E=u.name;if(!E)throw new Error(`Unknown type reference: ${m(u)}.`);const X=s[E];if(!X)throw new Error(`Invalid or incomplete schema, unknown type: ${E}. Ensure that a full introspection query is used in order to build a client schema.`);return X}function h(u){return An(f(u))}function g(u){return Sn(f(u))}function T(u){if(u!=null&&u.name!=null&&u.kind!=null)switch(u.kind){case S.SCALAR:return b(u);case S.OBJECT:return x(u);case S.INTERFACE:return L(u);case S.UNION:return w(u);case S.ENUM:return F(u);case S.INPUT_OBJECT:return R(u)}const E=m(u);throw new Error(`Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${E}.`)}function b(u){return new oe({name:u.name,description:u.description,specifiedByURL:u.specifiedByURL})}function y(u){if(u.interfaces===null&&u.kind===S.INTERFACE)return[];if(!u.interfaces){const E=m(u);throw new Error(`Introspection result missing interfaces: ${E}.`)}return u.interfaces.map(g)}function x(u){return new ne({name:u.name,description:u.description,interfaces:()=>y(u),fields:()=>V(u)})}function L(u){return new Nt({name:u.name,description:u.description,interfaces:()=>y(u),fields:()=>V(u)})}function w(u){if(!u.possibleTypes){const E=m(u);throw new Error(`Introspection result missing possibleTypes: ${E}.`)}return new vt({name:u.name,description:u.description,types:()=>u.possibleTypes.map(h)})}function F(u){if(!u.enumValues){const E=m(u);throw new Error(`Introspection result missing enumValues: ${E}.`)}return new Oe({name:u.name,description:u.description,values:se(u.enumValues,E=>E.name,E=>({description:E.description,deprecationReason:E.deprecationReason}))})}function R(u){if(!u.inputFields){const E=m(u);throw new Error(`Introspection result missing inputFields: ${E}.`)}return new It({name:u.name,description:u.description,fields:()=>Z(u.inputFields)})}function V(u){if(!u.fields)throw new Error(`Introspection result missing fields: ${m(u)}.`);return se(u.fields,E=>E.name,z)}function z(u){const E=p(u.type);if(!fe(E)){const X=m(E);throw new Error(`Introspection must provide output type for fields, but received: ${X}.`)}if(!u.args){const X=m(u);throw new Error(`Introspection result missing field args: ${X}.`)}return{description:u.description,deprecationReason:u.deprecationReason,type:E,args:Z(u.args)}}function Z(u){return se(u,E=>E.name,we)}function we(u){const E=p(u.type);if(!ae(E)){const ni=m(E);throw new Error(`Introspection must provide input type for arguments, but received: ${ni}.`)}const X=u.defaultValue!=null?Ee(cn(u.defaultValue),E):void 0;return{description:u.description,type:E,defaultValue:X,deprecationReason:u.deprecationReason}}function ti(u){if(!u.args){const E=m(u);throw new Error(`Introspection result missing directive args: ${E}.`)}if(!u.locations){const E=m(u);throw new Error(`Introspection result missing directive locations: ${E}.`)}return new pe({name:u.name,description:u.description,isRepeatable:u.isRepeatable,locations:u.locations.slice(),args:Z(u.args)})}}function Xn(e){return{tag:1,0:e}}function Hn(e){return t=>n=>t(s=>{s===0||s.tag===0?n(s):n(Xn(e(s[0])))})}var Zn=(...e)=>{for(var t=e[0],n=1,s=e.length;n{s=s[i],ve(s)&&n(s)})}function Rt(e,t){const n=[];let s;return Wn(e,t,i=>{i.kind===c.FIELD?i.alias?n.push(i.alias.value):n.push(i.name.value):i.kind===c.FRAGMENT_DEFINITION&&(s=i.name.value)}),[n,s]}function Qe(e,t,n){if(e==null)return e;if(Array.isArray(e))return e.map(a=>Qe(a,t,n));const s={...e};let i=s;for(let a=0;aQe(f,p,n)),s}else{if(i[l]===null)return s;i[l]={...i[l]}}i=i[l]}const r=t[t.length-1];return Array.isArray(i[r])?i[r]=i[r].map(n):i[r]!=null&&(i[r]=n(i[r])),s}function Ft(e){if(re(e)||Q(e))return Ft(e.ofType);if(ue(e))return e}function Kn(e){return Ft(e)}function ei({schema:e,scalars:t}){const n=zn(e),s=new Jn(n),i=r=>{const a=[],l={},p=qn(s,{Field(T,b,y,x,L){const w=s.getType();if(w==null)return;const F=Kn(w);if(F==null)return;const{name:R}=F;if(t[R]==null)return;const[V,z]=Rt(x,L),Z={kind:"scalar",name:R,path:V};z==null?a.push(Z):(l[z]=l[z]??[],l[z].push(Z))},FragmentSpread(T,b,y,x,L){const[w,F]=Rt(x,L),R={kind:"fragment",fragmentName:T.name.value,path:w};F==null?a.push(R):(l[F]=l[F]??[],l[F].push(R))}});ot(r,p);const f={},h=(T,b=[])=>{var x;if(f[T])return f[T];if(b.includes(T))return[];const y=[];return(x=l[T])==null||x.forEach(L=>{if(L.kind==="scalar")y.push(L);else if(L.kind==="fragment"){const w=h(L.fragmentName,[...b,T]).map(F=>({...F,path:[...L.path,...F.path]}));y.push(...w)}}),f[T]=y,y},g=[];return a.forEach(T=>{if(T.kind==="scalar")g.push(T);else if(T.kind==="fragment"){const b=h(T.fragmentName).map(y=>({...y,path:[...T.path,...y.path]}));g.push(...b)}}),g};return({forward:r})=>a=>{const l=r(a);return Zn(l,Hn(p=>{if(p.data==null)return p;const f=i(p.operation.query);return f.length===0||f.forEach(({name:h,path:g})=>{p.data=Qe(p.data,g,t[h])}),p}))}}return ei});