UNPKG

@miragejs/graphql

Version:

A library for handling GraphQL requests with Mirage JS

49 lines (43 loc) 346 kB
(function(ut,le){typeof exports=="object"&&typeof module<"u"?le(exports):typeof define=="function"&&define.amd?define(["exports"],le):(ut=typeof globalThis<"u"?globalThis:ut||self,le(ut.MirageGraphQL={}))})(this,function(ut){"use strict";function le(e,t){if(!!!e)throw new Error(t)}function br(e){return typeof(e==null?void 0:e.then)=="function"}function Er(e){return typeof e=="object"&&e!==null}function Qn(e,t){if(!!!e)throw new Error(t??"Unexpected invariant triggered.")}const yd=/\r\n|[\n\r]/g;function Ta(e,t){let n=0,r=1;for(const i of e.body.matchAll(yd)){if(typeof i.index=="number"||Qn(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function gd(e){return lu(e.source,Ta(e.source,e.start))}function lu(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,s=e.locationOffset.line-1,a=t.line+s,o=t.line===1?n:0,c=t.column+o,h=`${e.name}:${a}:${c} `,v=r.split(/\r\n|[\n\r]/g),p=v[i];if(p.length>120){const b=Math.floor(c/80),w=c%80,$=[];for(let H=0;H<p.length;H+=80)$.push(p.slice(H,H+80));return h+fu([[`${a} |`,$[0]],...$.slice(1,b+1).map(H=>["|",H]),["|","^".padStart(w)],["|",$[b+1]]])}return h+fu([[`${a-1} |`,v[i-1]],[`${a} |`,p],["|","^".padStart(c)],[`${a+1} |`,v[i+1]]])}function fu(e){const t=e.filter(([r,i])=>i!==void 0),n=Math.max(...t.map(([r])=>r.length));return t.map(([r,i])=>r.padStart(n)+(i?" "+i:"")).join(` `)}function md(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 P extends Error{constructor(t,...n){var r,i,s;const{nodes:a,source:o,positions:c,path:h,originalError:v,extensions:p}=md(n);super(t),this.name="GraphQLError",this.path=h??void 0,this.originalError=v??void 0,this.nodes=du(Array.isArray(a)?a:a?[a]:void 0);const b=du((r=this.nodes)===null||r===void 0?void 0:r.map($=>$.loc).filter($=>$!=null));this.source=o??(b==null||(i=b[0])===null||i===void 0?void 0:i.source),this.positions=c??(b==null?void 0:b.map($=>$.start)),this.locations=c&&o?c.map($=>Ta(o,$)):b==null?void 0:b.map($=>Ta($.source,$.start));const w=Er(v==null?void 0:v.extensions)?v==null?void 0:v.extensions:void 0;this.extensions=(s=p??w)!==null&&s!==void 0?s: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}}),v!=null&&v.stack?Object.defineProperty(this,"stack",{value:v.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,P):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+=` `+gd(n.loc));else if(this.source&&this.locations)for(const n of this.locations)t+=` `+lu(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 du(e){return e===void 0||e.length===0?void 0:e}function Qt(e,t,n){return new P(`Syntax Error: ${n}`,{source:e,positions:[t]})}class vd{constructor(t,n,r){this.start=t.start,this.end=n.end,this.startToken=t,this.endToken=n,this.source=r}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class hu{constructor(t,n,r,i,s,a){this.kind=t,this.start=n,this.end=r,this.line=i,this.column=s,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 pu={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"]},_d=new Set(Object.keys(pu));function ba(e){const t=e==null?void 0:e.kind;return typeof t=="string"&&_d.has(t)}var Xt;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"})(Xt||(Xt={}));var ne;(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"})(ne||(ne={}));var N;(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"})(N||(N={}));function Ea(e){return e===9||e===32}function Gi(e){return e>=48&&e<=57}function yu(e){return e>=97&&e<=122||e>=65&&e<=90}function Ia(e){return yu(e)||e===95}function gu(e){return yu(e)||Gi(e)||e===95}function Td(e){var t;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let a=0;a<e.length;++a){var s;const o=e[a],c=bd(o);c!==o.length&&(r=(s=r)!==null&&s!==void 0?s:a,i=a,a!==0&&c<n&&(n=c))}return e.map((a,o)=>o===0?a:a.slice(n)).slice((t=r)!==null&&t!==void 0?t:0,i+1)}function bd(e){let t=0;for(;t<e.length&&Ea(e.charCodeAt(t));)++t;return t}function Ed(e,t){const n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=r.length===1,s=r.length>1&&r.slice(1).every(w=>w.length===0||Ea(w.charCodeAt(0))),a=n.endsWith('\\"""'),o=e.endsWith('"')&&!a,c=e.endsWith("\\"),h=o||c,v=!(t!=null&&t.minimize)&&(!i||e.length>70||h||s||a);let p="";const b=i&&Ea(e.charCodeAt(0));return(v&&!b||s)&&(p+=` `),p+=n,(v||h)&&(p+=` `),'"""'+p+'"""'}var L;(function(e){e.SOF="<SOF>",e.EOF="<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"})(L||(L={}));class Id{constructor(t){const n=new hu(L.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!==L.EOF)do if(t.next)t=t.next;else{const n=Ad(this,t.end);t.next=n,n.prev=t,t=n}while(t.kind===L.COMMENT);return t}}function Nd(e){return e===L.BANG||e===L.DOLLAR||e===L.AMP||e===L.PAREN_L||e===L.PAREN_R||e===L.SPREAD||e===L.COLON||e===L.EQUALS||e===L.AT||e===L.BRACKET_L||e===L.BRACKET_R||e===L.BRACE_L||e===L.PIPE||e===L.BRACE_R}function Ri(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function ps(e,t){return mu(e.charCodeAt(t))&&vu(e.charCodeAt(t+1))}function mu(e){return e>=55296&&e<=56319}function vu(e){return e>=56320&&e<=57343}function hi(e,t){const n=e.source.body.codePointAt(t);if(n===void 0)return L.EOF;if(n>=32&&n<=126){const r=String.fromCodePoint(n);return r==='"'?`'"'`:`"${r}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function Et(e,t,n,r,i){const s=e.line,a=1+n-e.lineStart;return new hu(t,n,r,s,a,i)}function Ad(e,t){const n=e.source.body,r=n.length;let i=t;for(;i<r;){const s=n.charCodeAt(i);switch(s){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++e.line,e.lineStart=i;continue;case 13:n.charCodeAt(i+1)===10?i+=2:++i,++e.line,e.lineStart=i;continue;case 35:return Sd(e,i);case 33:return Et(e,L.BANG,i,i+1);case 36:return Et(e,L.DOLLAR,i,i+1);case 38:return Et(e,L.AMP,i,i+1);case 40:return Et(e,L.PAREN_L,i,i+1);case 41:return Et(e,L.PAREN_R,i,i+1);case 46:if(n.charCodeAt(i+1)===46&&n.charCodeAt(i+2)===46)return Et(e,L.SPREAD,i,i+3);break;case 58:return Et(e,L.COLON,i,i+1);case 61:return Et(e,L.EQUALS,i,i+1);case 64:return Et(e,L.AT,i,i+1);case 91:return Et(e,L.BRACKET_L,i,i+1);case 93:return Et(e,L.BRACKET_R,i,i+1);case 123:return Et(e,L.BRACE_L,i,i+1);case 124:return Et(e,L.PIPE,i,i+1);case 125:return Et(e,L.BRACE_R,i,i+1);case 34:return n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34?Cd(e,i):wd(e,i)}if(Gi(s)||s===45)return Od(e,i,s);if(Ia(s))return Dd(e,i);throw Qt(e.source,i,s===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:Ri(s)||ps(n,i)?`Unexpected character: ${hi(e,i)}.`:`Invalid character: ${hi(e,i)}.`)}return Et(e,L.EOF,r,r)}function Sd(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){const s=n.charCodeAt(i);if(s===10||s===13)break;if(Ri(s))++i;else if(ps(n,i))i+=2;else break}return Et(e,L.COMMENT,t,i,n.slice(t+1,i))}function Od(e,t,n){const r=e.source.body;let i=t,s=n,a=!1;if(s===45&&(s=r.charCodeAt(++i)),s===48){if(s=r.charCodeAt(++i),Gi(s))throw Qt(e.source,i,`Invalid number, unexpected digit after 0: ${hi(e,i)}.`)}else i=Na(e,i,s),s=r.charCodeAt(i);if(s===46&&(a=!0,s=r.charCodeAt(++i),i=Na(e,i,s),s=r.charCodeAt(i)),(s===69||s===101)&&(a=!0,s=r.charCodeAt(++i),(s===43||s===45)&&(s=r.charCodeAt(++i)),i=Na(e,i,s),s=r.charCodeAt(i)),s===46||Ia(s))throw Qt(e.source,i,`Invalid number, expected digit but got: ${hi(e,i)}.`);return Et(e,a?L.FLOAT:L.INT,t,i,r.slice(t,i))}function Na(e,t,n){if(!Gi(n))throw Qt(e.source,t,`Invalid number, expected digit but got: ${hi(e,t)}.`);const r=e.source.body;let i=t+1;for(;Gi(r.charCodeAt(i));)++i;return i}function wd(e,t){const n=e.source.body,r=n.length;let i=t+1,s=i,a="";for(;i<r;){const o=n.charCodeAt(i);if(o===34)return a+=n.slice(s,i),Et(e,L.STRING,t,i+1,a);if(o===92){a+=n.slice(s,i);const c=n.charCodeAt(i+1)===117?n.charCodeAt(i+2)===123?Rd(e,i):Fd(e,i):$d(e,i);a+=c.value,i+=c.size,s=i;continue}if(o===10||o===13)break;if(Ri(o))++i;else if(ps(n,i))i+=2;else throw Qt(e.source,i,`Invalid character within String: ${hi(e,i)}.`)}throw Qt(e.source,i,"Unterminated string.")}function Rd(e,t){const n=e.source.body;let r=0,i=3;for(;i<12;){const s=n.charCodeAt(t+i++);if(s===125){if(i<5||!Ri(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|Vi(s),r<0)break}throw Qt(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function Fd(e,t){const n=e.source.body,r=_u(n,t+2);if(Ri(r))return{value:String.fromCodePoint(r),size:6};if(mu(r)&&n.charCodeAt(t+6)===92&&n.charCodeAt(t+7)===117){const i=_u(n,t+8);if(vu(i))return{value:String.fromCodePoint(r,i),size:12}}throw Qt(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function _u(e,t){return Vi(e.charCodeAt(t))<<12|Vi(e.charCodeAt(t+1))<<8|Vi(e.charCodeAt(t+2))<<4|Vi(e.charCodeAt(t+3))}function Vi(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function $d(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 Qt(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function Cd(e,t){const n=e.source.body,r=n.length;let i=e.lineStart,s=t+3,a=s,o="";const c=[];for(;s<r;){const h=n.charCodeAt(s);if(h===34&&n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34){o+=n.slice(a,s),c.push(o);const v=Et(e,L.BLOCK_STRING,t,s+3,Td(c).join(` `));return e.line+=c.length-1,e.lineStart=i,v}if(h===92&&n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34&&n.charCodeAt(s+3)===34){o+=n.slice(a,s),a=s+1,s+=4;continue}if(h===10||h===13){o+=n.slice(a,s),c.push(o),h===13&&n.charCodeAt(s+1)===10?s+=2:++s,o="",a=s,i=s;continue}if(Ri(h))++s;else if(ps(n,s))s+=2;else throw Qt(e.source,s,`Invalid character within String: ${hi(e,s)}.`)}throw Qt(e.source,s,"Unterminated string.")}function Dd(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){const s=n.charCodeAt(i);if(gu(s))++i;else break}return Et(e,L.NAME,t,i,n.slice(t,i))}const xd=10,Tu=2;function z(e){return ys(e,[])}function ys(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return Pd(e,t);default:return String(e)}}function Pd(e,t){if(e===null)return"null";if(t.includes(e))return"[Circular]";const n=[...t,e];if(Md(e)){const r=e.toJSON();if(r!==e)return typeof r=="string"?r:ys(r,n)}else if(Array.isArray(e))return jd(e,n);return Ld(e,n)}function Md(e){return typeof e.toJSON=="function"}function Ld(e,t){const n=Object.entries(e);return n.length===0?"{}":t.length>Tu?"["+kd(e)+"]":"{ "+n.map(([i,s])=>i+": "+ys(s,t)).join(", ")+" }"}function jd(e,t){if(e.length===0)return"[]";if(t.length>Tu)return"[Array]";const n=Math.min(xd,e.length),r=e.length-n,i=[];for(let s=0;s<n;++s)i.push(ys(e[s],t));return r===1?i.push("... 1 more item"):r>1&&i.push(`... ${r} more items`),"["+i.join(", ")+"]"}function kd(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 Ir=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 r;const i=n.prototype[Symbol.toStringTag],s=Symbol.toStringTag in t?t[Symbol.toStringTag]:(r=t.constructor)===null||r===void 0?void 0:r.name;if(i===s){const a=z(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 bu{constructor(t,n="GraphQL request",r={line:1,column:1}){typeof t=="string"||le(!1,`Body must be a string. Received: ${z(t)}.`),this.body=t,this.name=n,this.locationOffset=r,this.locationOffset.line>0||le(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||le(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function Ud(e){return Ir(e,bu)}function Eu(e,t){return new Bd(e,t).parseDocument()}class Bd{constructor(t,n={}){const r=Ud(t)?t:new bu(t);this._lexer=new Id(r),this._options=n,this._tokenCounter=0}parseName(){const t=this.expectToken(L.NAME);return this.node(t,{kind:N.NAME,value:t.value})}parseDocument(){return this.node(this._lexer.token,{kind:N.DOCUMENT,definitions:this.many(L.SOF,this.parseDefinition,L.EOF)})}parseDefinition(){if(this.peek(L.BRACE_L))return this.parseOperationDefinition();const t=this.peekDescription(),n=t?this._lexer.lookahead():this._lexer.token;if(n.kind===L.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 Qt(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(L.BRACE_L))return this.node(t,{kind:N.OPERATION_DEFINITION,operation:Xt.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const n=this.parseOperationType();let r;return this.peek(L.NAME)&&(r=this.parseName()),this.node(t,{kind:N.OPERATION_DEFINITION,operation:n,name:r,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const t=this.expectToken(L.NAME);switch(t.value){case"query":return Xt.QUERY;case"mutation":return Xt.MUTATION;case"subscription":return Xt.SUBSCRIPTION}throw this.unexpected(t)}parseVariableDefinitions(){return this.optionalMany(L.PAREN_L,this.parseVariableDefinition,L.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:N.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(L.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(L.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const t=this._lexer.token;return this.expectToken(L.DOLLAR),this.node(t,{kind:N.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:N.SELECTION_SET,selections:this.many(L.BRACE_L,this.parseSelection,L.BRACE_R)})}parseSelection(){return this.peek(L.SPREAD)?this.parseFragment():this.parseField()}parseField(){const t=this._lexer.token,n=this.parseName();let r,i;return this.expectOptionalToken(L.COLON)?(r=n,i=this.parseName()):i=n,this.node(t,{kind:N.FIELD,alias:r,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(L.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(t){const n=t?this.parseConstArgument:this.parseArgument;return this.optionalMany(L.PAREN_L,n,L.PAREN_R)}parseArgument(t=!1){const n=this._lexer.token,r=this.parseName();return this.expectToken(L.COLON),this.node(n,{kind:N.ARGUMENT,name:r,value:this.parseValueLiteral(t)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const t=this._lexer.token;this.expectToken(L.SPREAD);const n=this.expectOptionalKeyword("on");return!n&&this.peek(L.NAME)?this.node(t,{kind:N.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(t,{kind:N.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:N.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:N.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 L.BRACKET_L:return this.parseList(t);case L.BRACE_L:return this.parseObject(t);case L.INT:return this.advanceLexer(),this.node(n,{kind:N.INT,value:n.value});case L.FLOAT:return this.advanceLexer(),this.node(n,{kind:N.FLOAT,value:n.value});case L.STRING:case L.BLOCK_STRING:return this.parseStringLiteral();case L.NAME:switch(this.advanceLexer(),n.value){case"true":return this.node(n,{kind:N.BOOLEAN,value:!0});case"false":return this.node(n,{kind:N.BOOLEAN,value:!1});case"null":return this.node(n,{kind:N.NULL});default:return this.node(n,{kind:N.ENUM,value:n.value})}case L.DOLLAR:if(t)if(this.expectToken(L.DOLLAR),this._lexer.token.kind===L.NAME){const r=this._lexer.token.value;throw Qt(this._lexer.source,n.start,`Unexpected variable "$${r}" 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:N.STRING,value:t.value,block:t.kind===L.BLOCK_STRING})}parseList(t){const n=()=>this.parseValueLiteral(t);return this.node(this._lexer.token,{kind:N.LIST,values:this.any(L.BRACKET_L,n,L.BRACKET_R)})}parseObject(t){const n=()=>this.parseObjectField(t);return this.node(this._lexer.token,{kind:N.OBJECT,fields:this.any(L.BRACE_L,n,L.BRACE_R)})}parseObjectField(t){const n=this._lexer.token,r=this.parseName();return this.expectToken(L.COLON),this.node(n,{kind:N.OBJECT_FIELD,name:r,value:this.parseValueLiteral(t)})}parseDirectives(t){const n=[];for(;this.peek(L.AT);)n.push(this.parseDirective(t));return n}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(t){const n=this._lexer.token;return this.expectToken(L.AT),this.node(n,{kind:N.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(t)})}parseTypeReference(){const t=this._lexer.token;let n;if(this.expectOptionalToken(L.BRACKET_L)){const r=this.parseTypeReference();this.expectToken(L.BRACKET_R),n=this.node(t,{kind:N.LIST_TYPE,type:r})}else n=this.parseNamedType();return this.expectOptionalToken(L.BANG)?this.node(t,{kind:N.NON_NULL_TYPE,type:n}):n}parseNamedType(){return this.node(this._lexer.token,{kind:N.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(L.STRING)||this.peek(L.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");const r=this.parseConstDirectives(),i=this.many(L.BRACE_L,this.parseOperationTypeDefinition,L.BRACE_R);return this.node(t,{kind:N.SCHEMA_DEFINITION,description:n,directives:r,operationTypes:i})}parseOperationTypeDefinition(){const t=this._lexer.token,n=this.parseOperationType();this.expectToken(L.COLON);const r=this.parseNamedType();return this.node(t,{kind:N.OPERATION_TYPE_DEFINITION,operation:n,type:r})}parseScalarTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");const r=this.parseName(),i=this.parseConstDirectives();return this.node(t,{kind:N.SCALAR_TYPE_DEFINITION,description:n,name:r,directives:i})}parseObjectTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");const r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:N.OBJECT_TYPE_DEFINITION,description:n,name:r,interfaces:i,directives:s,fields:a})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(L.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(L.BRACE_L,this.parseFieldDefinition,L.BRACE_R)}parseFieldDefinition(){const t=this._lexer.token,n=this.parseDescription(),r=this.parseName(),i=this.parseArgumentDefs();this.expectToken(L.COLON);const s=this.parseTypeReference(),a=this.parseConstDirectives();return this.node(t,{kind:N.FIELD_DEFINITION,description:n,name:r,arguments:i,type:s,directives:a})}parseArgumentDefs(){return this.optionalMany(L.PAREN_L,this.parseInputValueDef,L.PAREN_R)}parseInputValueDef(){const t=this._lexer.token,n=this.parseDescription(),r=this.parseName();this.expectToken(L.COLON);const i=this.parseTypeReference();let s;this.expectOptionalToken(L.EQUALS)&&(s=this.parseConstValueLiteral());const a=this.parseConstDirectives();return this.node(t,{kind:N.INPUT_VALUE_DEFINITION,description:n,name:r,type:i,defaultValue:s,directives:a})}parseInterfaceTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");const r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(t,{kind:N.INTERFACE_TYPE_DEFINITION,description:n,name:r,interfaces:i,directives:s,fields:a})}parseUnionTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseUnionMemberTypes();return this.node(t,{kind:N.UNION_TYPE_DEFINITION,description:n,name:r,directives:i,types:s})}parseUnionMemberTypes(){return this.expectOptionalToken(L.EQUALS)?this.delimitedMany(L.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseEnumValuesDefinition();return this.node(t,{kind:N.ENUM_TYPE_DEFINITION,description:n,name:r,directives:i,values:s})}parseEnumValuesDefinition(){return this.optionalMany(L.BRACE_L,this.parseEnumValueDefinition,L.BRACE_R)}parseEnumValueDefinition(){const t=this._lexer.token,n=this.parseDescription(),r=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(t,{kind:N.ENUM_VALUE_DEFINITION,description:n,name:r,directives:i})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw Qt(this._lexer.source,this._lexer.token.start,`${gs(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 r=this.parseName(),i=this.parseConstDirectives(),s=this.parseInputFieldsDefinition();return this.node(t,{kind:N.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:r,directives:i,fields:s})}parseInputFieldsDefinition(){return this.optionalMany(L.BRACE_L,this.parseInputValueDef,L.BRACE_R)}parseTypeSystemExtension(){const t=this._lexer.lookahead();if(t.kind===L.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(),r=this.optionalMany(L.BRACE_L,this.parseOperationTypeDefinition,L.BRACE_R);if(n.length===0&&r.length===0)throw this.unexpected();return this.node(t,{kind:N.SCHEMA_EXTENSION,directives:n,operationTypes:r})}parseScalarTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();if(r.length===0)throw this.unexpected();return this.node(t,{kind:N.SCALAR_TYPE_EXTENSION,name:n,directives:r})}parseObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&s.length===0)throw this.unexpected();return this.node(t,{kind:N.OBJECT_TYPE_EXTENSION,name:n,interfaces:r,directives:i,fields:s})}parseInterfaceTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&s.length===0)throw this.unexpected();return this.node(t,{kind:N.INTERFACE_TYPE_EXTENSION,name:n,interfaces:r,directives:i,fields:s})}parseUnionTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:N.UNION_TYPE_EXTENSION,name:n,directives:r,types:i})}parseEnumTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:N.ENUM_TYPE_EXTENSION,name:n,directives:r,values:i})}parseInputObjectTypeExtension(){const t=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(t,{kind:N.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:r,fields:i})}parseDirectiveDefinition(){const t=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(L.AT);const r=this.parseName(),i=this.parseArgumentDefs(),s=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const a=this.parseDirectiveLocations();return this.node(t,{kind:N.DIRECTIVE_DEFINITION,description:n,name:r,arguments:i,repeatable:s,locations:a})}parseDirectiveLocations(){return this.delimitedMany(L.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const t=this._lexer.token,n=this.parseName();if(Object.prototype.hasOwnProperty.call(ne,n.value))return n;throw this.unexpected(t)}node(t,n){return this._options.noLocation!==!0&&(n.loc=new vd(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 Qt(this._lexer.source,n.start,`Expected ${Iu(t)}, found ${gs(n)}.`)}expectOptionalToken(t){return this._lexer.token.kind===t?(this.advanceLexer(),!0):!1}expectKeyword(t){const n=this._lexer.token;if(n.kind===L.NAME&&n.value===t)this.advanceLexer();else throw Qt(this._lexer.source,n.start,`Expected "${t}", found ${gs(n)}.`)}expectOptionalKeyword(t){const n=this._lexer.token;return n.kind===L.NAME&&n.value===t?(this.advanceLexer(),!0):!1}unexpected(t){const n=t??this._lexer.token;return Qt(this._lexer.source,n.start,`Unexpected ${gs(n)}.`)}any(t,n,r){this.expectToken(t);const i=[];for(;!this.expectOptionalToken(r);)i.push(n.call(this));return i}optionalMany(t,n,r){if(this.expectOptionalToken(t)){const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(r));return i}return[]}many(t,n,r){this.expectToken(t);const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(r));return i}delimitedMany(t,n){this.expectOptionalToken(t);const r=[];do r.push(n.call(this));while(this.expectOptionalToken(t));return r}advanceLexer(){const{maxTokens:t}=this._options,n=this._lexer.advance();if(t!==void 0&&n.kind!==L.EOF&&(++this._tokenCounter,this._tokenCounter>t))throw Qt(this._lexer.source,n.start,`Document contains more that ${t} tokens. Parsing aborted.`)}}function gs(e){const t=e.value;return Iu(e.kind)+(t!=null?` "${t}"`:"")}function Iu(e){return Nd(e)?`"${e}"`:e}const Gd=5;function Qr(e,t){const[n,r]=t?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const s=r.map(c=>`"${c}"`);switch(s.length){case 0:return"";case 1:return i+s[0]+"?";case 2:return i+s[0]+" or "+s[1]+"?"}const a=s.slice(0,Gd),o=a.pop();return i+a.join(", ")+", or "+o+"?"}function Nu(e){return e}function pi(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function Aa(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Xr(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function Sa(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(ms(i)&&ms(s)){let a=0;do++n,a=a*10+i-Oa,i=e.charCodeAt(n);while(ms(i)&&a>0);let o=0;do++r,o=o*10+s-Oa,s=t.charCodeAt(r);while(ms(s)&&o>0);if(a<o)return-1;if(a>o)return 1}else{if(i<s)return-1;if(i>s)return 1;++n,++r}}return e.length-t.length}const Oa=48,Vd=57;function ms(e){return!isNaN(e)&&Oa<=e&&e<=Vd}function ni(e,t){const n=Object.create(null),r=new zd(e),i=Math.floor(e.length*.4)+1;for(const s of t){const a=r.measure(s,i);a!==void 0&&(n[s]=a)}return Object.keys(n).sort((s,a)=>{const o=n[s]-n[a];return o!==0?o:Sa(s,a)})}class zd{constructor(t){this._input=t,this._inputLowerCase=t.toLowerCase(),this._inputArray=Au(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 r=t.toLowerCase();if(this._inputLowerCase===r)return 1;let i=Au(r),s=this._inputArray;if(i.length<s.length){const v=i;i=s,s=v}const a=i.length,o=s.length;if(a-o>n)return;const c=this._rows;for(let v=0;v<=o;v++)c[0][v]=v;for(let v=1;v<=a;v++){const p=c[(v-1)%3],b=c[v%3];let w=b[0]=v;for(let $=1;$<=o;$++){const H=i[v-1]===s[$-1]?0:1;let G=Math.min(p[$]+1,b[$-1]+1,p[$-1]+H);if(v>1&&$>1&&i[v-1]===s[$-2]&&i[v-2]===s[$-1]){const ce=c[(v-2)%3][$-2];G=Math.min(G,ce+1)}G<w&&(w=G),b[$]=G}if(w>n)return}const h=c[a%3][o];return h<=n?h:void 0}}function Au(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function fr(e){if(e==null)return Object.create(null);if(Object.getPrototypeOf(e)===null)return e;const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]=r;return t}function Hd(e){return`"${e.replace(qd,Kd)}"`}const qd=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Kd(e){return Yd[e.charCodeAt(0)]}const Yd=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"],zi=Object.freeze({});function vs(e,t,n=pu){const r=new Map;for(const ce of Object.values(N))r.set(ce,_s(t,ce));let i,s=Array.isArray(e),a=[e],o=-1,c=[],h=e,v,p;const b=[],w=[];do{o++;const ce=o===a.length,re=ce&&c.length!==0;if(ce){if(v=w.length===0?void 0:b[b.length-1],h=p,p=w.pop(),re)if(s){h=h.slice();let Te=0;for(const[Fe,Be]of c){const Xe=Fe-Te;Be===null?(h.splice(Xe,1),Te++):h[Xe]=Be}}else{h=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));for(const[Te,Fe]of c)h[Te]=Fe}o=i.index,a=i.keys,c=i.edits,s=i.inArray,i=i.prev}else if(p){if(v=s?o:a[o],h=p[v],h==null)continue;b.push(v)}let me;if(!Array.isArray(h)){var $,H;ba(h)||le(!1,`Invalid AST Node: ${z(h)}.`);const Te=ce?($=r.get(h.kind))===null||$===void 0?void 0:$.leave:(H=r.get(h.kind))===null||H===void 0?void 0:H.enter;if(me=Te==null?void 0:Te.call(t,h,v,p,b,w),me===zi)break;if(me===!1){if(!ce){b.pop();continue}}else if(me!==void 0&&(c.push([v,me]),!ce))if(ba(me))h=me;else{b.pop();continue}}if(me===void 0&&re&&c.push([v,h]),ce)b.pop();else{var G;i={inArray:s,index:o,keys:a,edits:c,prev:i},s=Array.isArray(h),a=s?h:(G=n[h.kind])!==null&&G!==void 0?G:[],o=-1,c=[],p&&w.push(p),p=h}}while(i!==void 0);return c.length!==0?c[c.length-1][1]:e}function Su(e){const t=new Array(e.length).fill(null),n=Object.create(null);for(const r of Object.values(N)){let i=!1;const s=new Array(e.length).fill(void 0),a=new Array(e.length).fill(void 0);for(let c=0;c<e.length;++c){const{enter:h,leave:v}=_s(e[c],r);i||(i=h!=null||v!=null),s[c]=h,a[c]=v}if(!i)continue;const o={enter(...c){const h=c[0];for(let p=0;p<e.length;p++)if(t[p]===null){var v;const b=(v=s[p])===null||v===void 0?void 0:v.apply(e[p],c);if(b===!1)t[p]=h;else if(b===zi)t[p]=zi;else if(b!==void 0)return b}},leave(...c){const h=c[0];for(let p=0;p<e.length;p++)if(t[p]===null){var v;const b=(v=a[p])===null||v===void 0?void 0:v.apply(e[p],c);if(b===zi)t[p]=zi;else if(b!==void 0&&b!==!1)return b}else t[p]===h&&(t[p]=null)}};n[r]=o}return n}function _s(e,t){const n=e[t];return typeof n=="object"?n:typeof n=="function"?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function jt(e){return vs(e,Qd)}const Jd=80,Qd={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>W(e.definitions,` `)},OperationDefinition:{leave(e){const t=ve("(",W(e.variableDefinitions,", "),")"),n=W([e.operation,W([e.name,t]),W(e.directives," ")]," ");return(n==="query"?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+ve(" = ",n)+ve(" ",W(r," "))},SelectionSet:{leave:({selections:e})=>Nr(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=ve("",e,": ")+t;let a=s+ve("(",W(n,", "),")");return a.length>Jd&&(a=s+ve(`( `,Ts(W(n,` `)),` )`)),W([a,W(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+ve(" ",W(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>W(["...",ve("on ",e),W(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${ve("(",W(n,", "),")")} on ${t} ${ve("",W(r," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?Ed(e):Hd(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+W(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+W(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+ve("(",W(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>ve("",e,` `)+W(["schema",W(t," "),Nr(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>ve("",e,` `)+W(["scalar",t,W(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ve("",e,` `)+W(["type",t,ve("implements ",W(n," & ")),W(r," "),Nr(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>ve("",e,` `)+t+(Ou(n)?ve(`( `,Ts(W(n,` `)),` )`):ve("(",W(n,", "),")"))+": "+r+ve(" ",W(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>ve("",e,` `)+W([t+": "+n,ve("= ",r),W(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ve("",e,` `)+W(["interface",t,ve("implements ",W(n," & ")),W(r," "),Nr(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>ve("",e,` `)+W(["union",t,W(n," "),ve("= ",W(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>ve("",e,` `)+W(["enum",t,W(n," "),Nr(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>ve("",e,` `)+W([t,W(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>ve("",e,` `)+W(["input",t,W(n," "),Nr(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>ve("",e,` `)+"directive @"+t+(Ou(n)?ve(`( `,Ts(W(n,` `)),` )`):ve("(",W(n,", "),")"))+(r?" repeatable":"")+" on "+W(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>W(["extend schema",W(e," "),Nr(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>W(["extend scalar",e,W(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>W(["extend type",e,ve("implements ",W(t," & ")),W(n," "),Nr(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>W(["extend interface",e,ve("implements ",W(t," & ")),W(n," "),Nr(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>W(["extend union",e,W(t," "),ve("= ",W(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>W(["extend enum",e,W(t," "),Nr(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>W(["extend input",e,W(t," "),Nr(n)]," ")}};function W(e,t=""){var n;return(n=e==null?void 0:e.filter(r=>r).join(t))!==null&&n!==void 0?n:""}function Nr(e){return ve(`{ `,Ts(W(e,` `)),` }`)}function ve(e,t,n=""){return t!=null&&t!==""?e+t+n:""}function Ts(e){return ve(" ",e.replace(/\n/g,` `))}function Ou(e){var t;return(t=e==null?void 0:e.some(n=>n.includes(` `)))!==null&&t!==void 0?t:!1}function wa(e,t){switch(e.kind){case N.NULL:return null;case N.INT:return parseInt(e.value,10);case N.FLOAT:return parseFloat(e.value);case N.STRING:case N.ENUM:case N.BOOLEAN:return e.value;case N.LIST:return e.values.map(n=>wa(n,t));case N.OBJECT:return Aa(e.fields,n=>n.name.value,n=>wa(n.value,t));case N.VARIABLE:return t==null?void 0:t[e.name.value]}}function Ar(e){if(e!=null||le(!1,"Must provide name."),typeof e=="string"||le(!1,"Expected name to be a string."),e.length===0)throw new P("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!gu(e.charCodeAt(t)))throw new P(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!Ia(e.charCodeAt(0)))throw new P(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function Xd(e){if(e==="true"||e==="false"||e==="null")throw new P(`Enum values cannot be named: ${e}`);return Ar(e)}function Ra(e){return ri(e)||xe(e)||Ye(e)||Pn(e)||Xn(e)||kt(e)||Ut(e)||be(e)}function ri(e){return Ir(e,oi)}function xe(e){return Ir(e,Wr)}function Ye(e){return Ir(e,$a)}function Pn(e){return Ir(e,Ca)}function Xn(e){return Ir(e,Ki)}function kt(e){return Ir(e,Da)}function Ut(e){return Ir(e,Vn)}function be(e){return Ir(e,ge)}function Sr(e){return ri(e)||Xn(e)||kt(e)||Fa(e)&&Sr(e.ofType)}function Hi(e){return ri(e)||xe(e)||Ye(e)||Pn(e)||Xn(e)||Fa(e)&&Hi(e.ofType)}function ii(e){return ri(e)||Xn(e)}function si(e){return xe(e)||Ye(e)||Pn(e)}function ai(e){return Ye(e)||Pn(e)}class Vn{constructor(t){Ra(t)||le(!1,`Expected ${z(t)} to be a GraphQL type.`),this.ofType=t}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class ge{constructor(t){Wd(t)||le(!1,`Expected ${z(t)} to be a GraphQL nullable type.`),this.ofType=t}get[Symbol.toStringTag](){return"GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}}function Fa(e){return Ut(e)||be(e)}function Wd(e){return Ra(e)&&!be(e)}function wu(e){if(e)return be(e)?e.ofType:e}function Zd(e){return ri(e)||xe(e)||Ye(e)||Pn(e)||Xn(e)||kt(e)}function Or(e){if(e){let t=e;for(;Fa(t);)t=t.ofType;return t}}function Ru(e){return typeof e=="function"?e():e}function Fu(e){return typeof e=="function"?e():e}class oi{constructor(t){var n,r,i,s;const a=(n=t.parseValue)!==null&&n!==void 0?n:Nu;this.name=Ar(t.name),this.description=t.description,this.specifiedByURL=t.specifiedByURL,this.serialize=(r=t.serialize)!==null&&r!==void 0?r:Nu,this.parseValue=a,this.parseLiteral=(i=t.parseLiteral)!==null&&i!==void 0?i:(o,c)=>a(wa(o,c)),this.extensions=fr(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(s=t.extensionASTNodes)!==null&&s!==void 0?s:[],t.specifiedByURL==null||typeof t.specifiedByURL=="string"||le(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${z(t.specifiedByURL)}.`),t.serialize==null||typeof t.serialize=="function"||le(!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"||le(!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 Wr{constructor(t){var n;this.name=Ar(t.name),this.description=t.description,this.isTypeOf=t.isTypeOf,this.extensions=fr(t.extensions),this.astNode=t.astNode,this.extensionASTNodes=(n=t.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=()=>Cu(t),this._interfaces=()=>$u(t),t.isTypeOf==null||typeof t.isTypeOf=="function"||le(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${z(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:xu(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function $u(e){var t;const n=Ru((t=e.interfaces)!==null&&t!==void 0?t:[]);return Array.isArray(n)||le(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function Cu(e){const t=Fu(e.fields);return Fi(t)||le(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Xr(t,(n,r)=>{var i;Fi(n)||le(!1,`${e.name}.${r} field config must be an object.`),n.resolve==null||typeof n.resolve=="function"||le(!1,`${e.name}.${r} field resolver must be a function if provided, but got: ${z(n.resolve)}.`);const s=(i=n.args)!==null&&i!==void 0?i:{};return Fi(s)||le(!1,`${e.name}.${r} args must be an object with argument names as keys.`),{name:Ar(r),description:n.description,type:n.type,args:Du(s),resolve:n.resolve,subscribe:n.subscribe,deprecationReason:n.deprecationReason,extensions:fr(n.extensions),astNode:n.astNode}})}function Du(e){return Object.entries(e).map(([t,n])=>({name:Ar(t),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:fr(n.extensions),astNode:n.astNode}))}function Fi(e){return Er(e)&&!Array.isArray(e)}function xu(e){return Xr(e,t=>({description:t.description,type:t.type,args:Pu(t.args),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:t.extensions,astNode:t.astNode}))}function Pu(e){return Aa(e,t=>t.name,t=>({description:t.description,type:t.type,defaultValue:t.defaultValue,deprecatio