@medplum/fhir-router 2.0.17 → 2.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@medplum/core"),require("dataloader"),require("rfc6902")):"function"==typeof define&&define.amd?define(["exports","@medplum/core","dataloader","rfc6902"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.fhirRouter={}),e.medplum.core,e.dataloader,e.rfc6902)}(this,(function(e,t,n,r){"use strict";class i{constructor(e,t,n){this.router=e,this.repo=t,this.bundle=n,this.ids={}}async processBatch(){const e=this.bundle.type;if(!e)throw new t.OperationOutcomeError(t.badRequest("Missing bundle type"));if("batch"!==e&&"transaction"!==e)throw new t.OperationOutcomeError(t.badRequest("Unrecognized bundle type"));const n=this.bundle.entry;if(!n)throw new t.OperationOutcomeError(t.badRequest("Missing bundle entry"));const r=[];for(const e of n){const n=this.rewriteIdsInObject(e);e?.resource?.id&&(n.resource.id=this.rewriteIdsInString(e.resource.id,!0));try{r.push(await this.processBatchEntry(n))}catch(e){r.push(s(t.normalizeOperationOutcome(e)))}}return{resourceType:"Bundle",type:e+"-response",entry:r}}async processBatchEntry(e){this.validateEntry(e);const n=e.request;if(e.resource?.resourceType&&n.ifNoneExist){const r=`https://example.com/${e.resource.resourceType}`,i=new URL("?"+n.ifNoneExist,r),o=await this.repo.search(t.parseSearchUrl(i)),a=o?.entry;if(a.length>1)return s(t.badRequest("Multiple matches"));if(1===a.length){const n=a[0].resource;return e.fullUrl&&this.addReplacementId(e.fullUrl,n),s(t.allOk,n)}}let r=e.resource;"PATCH"===n.method&&(r=this.parsePatchBody(e));const i=new URL(n.url,"https://example.com/"),o=await this.router.handleRequest({method:n.method,pathname:i.pathname,params:Object.create(null),query:Object.fromEntries(i.searchParams),body:r},this.repo);return e.fullUrl&&2===o.length&&this.addReplacementId(e.fullUrl,o[1]),s(o[0],o[1])}validateEntry(e){if(!e.request)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request"));if(!e.request.method)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request.method"));if(!e.request.url)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request.url"))}parsePatchBody(e){const n=e.resource;if(!n)throw new t.OperationOutcomeError(t.badRequest("Missing entry.resource"));if("Binary"!==n.resourceType)throw new t.OperationOutcomeError(t.badRequest("Patch resource must be a Binary"));if(!n.data)throw new t.OperationOutcomeError(t.badRequest("Missing entry.resource.data"));return JSON.parse(Buffer.from(n.data,"base64").toString("utf8"))}addReplacementId(e,t){e?.startsWith("urn:uuid:")&&(this.ids[e]=t)}rewriteIds(e){return Array.isArray(e)?this.rewriteIdsInArray(e):"string"==typeof e?this.rewriteIdsInString(e):"object"==typeof e?this.rewriteIdsInObject(e):e}rewriteIdsInArray(e){return e.map((e=>this.rewriteIds(e)))}rewriteIdsInObject(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,this.rewriteIds(t)])))}rewriteIdsInString(e,n=!1){const r=e.match(/urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);if(r){const i=r[0],s=this.ids[i];if(s){let r=t.getReferenceString(s);return n&&(r=t.resolveId({reference:r})),r?e.replaceAll(i,r):e}}return e}}function s(e,n){return{response:{outcome:e,status:t.getStatus(e).toString(),location:t.isOk(e)&&n?.id?t.getReferenceString(n):void 0},resource:n}}function o(e,t){if(!Boolean(e))throw new Error(t)}function a(e){return"function"==typeof(null==e?void 0:e.then)}function c(e){return"object"==typeof e&&null!==e}function u(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}const l=/\r\n|[\n\r]/g;function p(e,t){let n=0,r=1;for(const i of e.body.matchAll(l)){if("number"==typeof i.index||u(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function d(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,s=e.locationOffset.line-1,o=t.line+s,a=1===t.line?n:0,c=t.column+a,u=`${e.name}:${o}:${c}\n`,l=r.split(/\r\n|[\n\r]/g),p=l[i];if(p.length>120){const e=Math.floor(c/80),t=c%80,n=[];for(let e=0;e<p.length;e+=80)n.push(p.slice(e,e+80));return u+f([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return u+f([[o-1+" |",l[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,l[i+1]]])}function f(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>e.padStart(n)+(t?" "+t:""))).join("\n")}class h extends Error{constructor(e,...t){var n,r,i;const{nodes:s,source:o,positions:a,path:u,originalError:l,extensions:d}=function(e){const t=e[0];return null==t||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}(t);super(e),this.name="GraphQLError",this.path=null!=u?u:void 0,this.originalError=null!=l?l:void 0,this.nodes=m(Array.isArray(s)?s:s?[s]:void 0);const f=m(null===(n=this.nodes)||void 0===n?void 0:n.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=o?o:null==f||null===(r=f[0])||void 0===r?void 0:r.source,this.positions=null!=a?a:null==f?void 0:f.map((e=>e.start)),this.locations=a&&o?a.map((e=>p(o,e))):null==f?void 0:f.map((e=>p(e.source,e.start)));const y=c(null==l?void 0:l.extensions)?null==l?void 0:l.extensions:void 0;this.extensions=null!==(i=null!=d?d:y)&&void 0!==i?i: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}}),null!=l&&l.stack?Object.defineProperty(this,"stack",{value:l.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,h):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(e+="\n\n"+d((t=n.loc).source,p(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+d(this.source,t);var t;return e}toJSON(){const e={message:this.message};return null!=this.locations&&(e.locations=this.locations),null!=this.path&&(e.path=this.path),null!=this.extensions&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function m(e){return void 0===e||0===e.length?void 0:e}function y(e,t,n){return new h(`Syntax Error: ${n}`,{source:e,positions:[t]})}class v{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class T{constructor(e,t,n,r,i,s){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=s,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 E={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"]},g=new Set(Object.keys(E));function N(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&g.has(t)}var I,b,O,_;function S(e){return 9===e||32===e}function w(e){return e>=48&&e<=57}function A(e){return e>=97&&e<=122||e>=65&&e<=90}function D(e){return A(e)||95===e}function x(e){return A(e)||w(e)||95===e}function R(e){var t;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let t=0;t<e.length;++t){var s;const o=e[t],a=k(o);a!==o.length&&(r=null!==(s=r)&&void 0!==s?s:t,i=t,0!==t&&a<n&&(n=a))}return e.map(((e,t)=>0===t?e:e.slice(n))).slice(null!==(t=r)&&void 0!==t?t:0,i+1)}function k(e){let t=0;for(;t<e.length&&S(e.charCodeAt(t));)++t;return t}!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(I||(I={})),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"}(b||(b={})),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"}(O||(O={})),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"}(_||(_={}));class F{constructor(e){const t=new T(_.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){this.lastToken=this.token;return this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==_.EOF)do{if(e.next)e=e.next;else{const t=M(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===_.COMMENT);return e}}function L(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function $(e,t){return C(e.charCodeAt(t))&&V(e.charCodeAt(t+1))}function C(e){return e>=55296&&e<=56319}function V(e){return e>=56320&&e<=57343}function U(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return _.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function j(e,t,n,r,i){const s=e.line,o=1+n-e.lineStart;return new T(t,n,r,s,o,i)}function M(e,t){const n=e.source.body,r=n.length;let i=t;for(;i<r;){const t=n.charCodeAt(i);switch(t){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++e.line,e.lineStart=i;continue;case 13:10===n.charCodeAt(i+1)?i+=2:++i,++e.line,e.lineStart=i;continue;case 35:return P(e,i);case 33:return j(e,_.BANG,i,i+1);case 36:return j(e,_.DOLLAR,i,i+1);case 38:return j(e,_.AMP,i,i+1);case 40:return j(e,_.PAREN_L,i,i+1);case 41:return j(e,_.PAREN_R,i,i+1);case 46:if(46===n.charCodeAt(i+1)&&46===n.charCodeAt(i+2))return j(e,_.SPREAD,i,i+3);break;case 58:return j(e,_.COLON,i,i+1);case 61:return j(e,_.EQUALS,i,i+1);case 64:return j(e,_.AT,i,i+1);case 91:return j(e,_.BRACKET_L,i,i+1);case 93:return j(e,_.BRACKET_R,i,i+1);case 123:return j(e,_.BRACE_L,i,i+1);case 124:return j(e,_.PIPE,i,i+1);case 125:return j(e,_.BRACE_R,i,i+1);case 34:return 34===n.charCodeAt(i+1)&&34===n.charCodeAt(i+2)?X(e,i):q(e,i)}if(w(t)||45===t)return B(e,i,t);if(D(t))return H(e,i);throw y(e.source,i,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":L(t)||$(n,i)?`Unexpected character: ${U(e,i)}.`:`Invalid character: ${U(e,i)}.`)}return j(e,_.EOF,r,r)}function P(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){const e=n.charCodeAt(i);if(10===e||13===e)break;if(L(e))++i;else{if(!$(n,i))break;i+=2}}return j(e,_.COMMENT,t,i,n.slice(t+1,i))}function B(e,t,n){const r=e.source.body;let i=t,s=n,o=!1;if(45===s&&(s=r.charCodeAt(++i)),48===s){if(s=r.charCodeAt(++i),w(s))throw y(e.source,i,`Invalid number, unexpected digit after 0: ${U(e,i)}.`)}else i=G(e,i,s),s=r.charCodeAt(i);if(46===s&&(o=!0,s=r.charCodeAt(++i),i=G(e,i,s),s=r.charCodeAt(i)),69!==s&&101!==s||(o=!0,s=r.charCodeAt(++i),43!==s&&45!==s||(s=r.charCodeAt(++i)),i=G(e,i,s),s=r.charCodeAt(i)),46===s||D(s))throw y(e.source,i,`Invalid number, expected digit but got: ${U(e,i)}.`);return j(e,o?_.FLOAT:_.INT,t,i,r.slice(t,i))}function G(e,t,n){if(!w(n))throw y(e.source,t,`Invalid number, expected digit but got: ${U(e,t)}.`);const r=e.source.body;let i=t+1;for(;w(r.charCodeAt(i));)++i;return i}function q(e,t){const n=e.source.body,r=n.length;let i=t+1,s=i,o="";for(;i<r;){const r=n.charCodeAt(i);if(34===r)return o+=n.slice(s,i),j(e,_.STRING,t,i+1,o);if(92!==r){if(10===r||13===r)break;if(L(r))++i;else{if(!$(n,i))throw y(e.source,i,`Invalid character within String: ${U(e,i)}.`);i+=2}}else{o+=n.slice(s,i);const t=117===n.charCodeAt(i+1)?123===n.charCodeAt(i+2)?J(e,i):Y(e,i):z(e,i);o+=t.value,i+=t.size,s=i}}throw y(e.source,i,"Unterminated string.")}function J(e,t){const n=e.source.body;let r=0,i=3;for(;i<12;){const e=n.charCodeAt(t+i++);if(125===e){if(i<5||!L(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|K(e),r<0)break}throw y(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function Y(e,t){const n=e.source.body,r=Q(n,t+2);if(L(r))return{value:String.fromCodePoint(r),size:6};if(C(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=Q(n,t+8);if(V(e))return{value:String.fromCodePoint(r,e),size:12}}throw y(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function Q(e,t){return K(e.charCodeAt(t))<<12|K(e.charCodeAt(t+1))<<8|K(e.charCodeAt(t+2))<<4|K(e.charCodeAt(t+3))}function K(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function z(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:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw y(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function X(e,t){const n=e.source.body,r=n.length;let i=e.lineStart,s=t+3,o=s,a="";const c=[];for(;s<r;){const r=n.charCodeAt(s);if(34===r&&34===n.charCodeAt(s+1)&&34===n.charCodeAt(s+2)){a+=n.slice(o,s),c.push(a);const r=j(e,_.BLOCK_STRING,t,s+3,R(c).join("\n"));return e.line+=c.length-1,e.lineStart=i,r}if(92!==r||34!==n.charCodeAt(s+1)||34!==n.charCodeAt(s+2)||34!==n.charCodeAt(s+3))if(10!==r&&13!==r)if(L(r))++s;else{if(!$(n,s))throw y(e.source,s,`Invalid character within String: ${U(e,s)}.`);s+=2}else a+=n.slice(o,s),c.push(a),13===r&&10===n.charCodeAt(s+1)?s+=2:++s,a="",o=s,i=s;else a+=n.slice(o,s),o=s+1,s+=4}throw y(e.source,s,"Unterminated string.")}function H(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){if(!x(n.charCodeAt(i)))break;++i}return j(e,_.NAME,t,i,n.slice(t,i))}const W=10,Z=2;function ee(e){return te(e,[])}function te(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const n=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:te(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>Z)return"[Array]";const n=Math.min(W,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(te(e[r],t));1===r?i.push("... 1 more item"):r>1&&i.push(`... ${r} more items`);return"["+i.join(", ")+"]"}(e,n);return function(e,t){const n=Object.entries(e);if(0===n.length)return"{}";if(t.length>Z)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const r=n.map((([e,n])=>e+": "+te(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const ne="production"===process.env.NODE_ENV?function(e,t){return e instanceof t}:function(e,t){if(e instanceof t)return!0;if("object"==typeof e&&null!==e){var n;const r=t.prototype[Symbol.toStringTag];if(r===(Symbol.toStringTag in e?e[Symbol.toStringTag]:null===(n=e.constructor)||void 0===n?void 0:n.name)){const t=ee(e);throw new Error(`Cannot use ${r} "${t}" from another module or realm.\n\nEnsure that there is only one instance of "graphql" in the node_modules\ndirectory. If different versions of "graphql" are the dependencies of other\nrelied on modules, use "resolutions" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate "graphql" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`)}}return!1};class re{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||o(!1,`Body must be a string. Received: ${ee(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||o(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||o(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}class ie{constructor(e,t={}){const n=function(e){return ne(e,re)}(e)?e:new re(e);this._lexer=new F(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(_.NAME);return this.node(e,{kind:O.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:O.DOCUMENT,definitions:this.many(_.SOF,this.parseDefinition,_.EOF)})}parseDefinition(){if(this.peek(_.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===_.NAME){switch(t.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(e)throw y(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(t.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(_.BRACE_L))return this.node(e,{kind:O.OPERATION_DEFINITION,operation:I.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(_.NAME)&&(n=this.parseName()),this.node(e,{kind:O.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(_.NAME);switch(e.value){case"query":return I.QUERY;case"mutation":return I.MUTATION;case"subscription":return I.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(_.PAREN_L,this.parseVariableDefinition,_.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:O.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(_.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(_.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(_.DOLLAR),this.node(e,{kind:O.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:O.SELECTION_SET,selections:this.many(_.BRACE_L,this.parseSelection,_.BRACE_R)})}parseSelection(){return this.peek(_.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(_.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:O.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(_.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(_.PAREN_L,t,_.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(_.COLON),this.node(t,{kind:O.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(_.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(_.NAME)?this.node(e,{kind:O.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:O.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),!0===this._options.allowLegacyFragmentVariables?this.node(e,{kind:O.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(e,{kind:O.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case _.BRACKET_L:return this.parseList(e);case _.BRACE_L:return this.parseObject(e);case _.INT:return this.advanceLexer(),this.node(t,{kind:O.INT,value:t.value});case _.FLOAT:return this.advanceLexer(),this.node(t,{kind:O.FLOAT,value:t.value});case _.STRING:case _.BLOCK_STRING:return this.parseStringLiteral();case _.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:O.BOOLEAN,value:!0});case"false":return this.node(t,{kind:O.BOOLEAN,value:!1});case"null":return this.node(t,{kind:O.NULL});default:return this.node(t,{kind:O.ENUM,value:t.value})}case _.DOLLAR:if(e){if(this.expectToken(_.DOLLAR),this._lexer.token.kind===_.NAME){const e=this._lexer.token.value;throw y(this._lexer.source,t.start,`Unexpected variable "$${e}" in constant value.`)}throw this.unexpected(t)}return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:O.STRING,value:e.value,block:e.kind===_.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:O.LIST,values:this.any(_.BRACKET_L,(()=>this.parseValueLiteral(e)),_.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:O.OBJECT,fields:this.any(_.BRACE_L,(()=>this.parseObjectField(e)),_.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(_.COLON),this.node(t,{kind:O.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(_.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(_.AT),this.node(t,{kind:O.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(_.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(_.BRACKET_R),t=this.node(e,{kind:O.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(_.BANG)?this.node(e,{kind:O.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:O.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(_.STRING)||this.peek(_.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.many(_.BRACE_L,this.parseOperationTypeDefinition,_.BRACE_R);return this.node(e,{kind:O.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(_.COLON);const n=this.parseNamedType();return this.node(e,{kind:O.OPERATION_TYPE_DEFINITION,operation:t,type:n})}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();return this.node(e,{kind:O.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r})}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:O.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(_.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(_.BRACE_L,this.parseFieldDefinition,_.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(_.COLON);const i=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:O.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:s})}parseArgumentDefs(){return this.optionalMany(_.PAREN_L,this.parseInputValueDef,_.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(_.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(_.EQUALS)&&(i=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:O.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:s})}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:O.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(e,{kind:O.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(_.EQUALS)?this.delimitedMany(_.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(e,{kind:O.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(_.BRACE_L,this.parseEnumValueDefinition,_.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:O.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r})}parseEnumValueName(){if("true"===this._lexer.token.value||"false"===this._lexer.token.value||"null"===this._lexer.token.value)throw y(this._lexer.source,this._lexer.token.start,`${se(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(e,{kind:O.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(_.BRACE_L,this.parseInputValueDef,_.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===_.NAME)switch(e.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(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const t=this.parseConstDirectives(),n=this.optionalMany(_.BRACE_L,this.parseOperationTypeDefinition,_.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:O.SCHEMA_EXTENSION,directives:t,operationTypes:n})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseConstDirectives();if(0===n.length)throw this.unexpected();return this.node(e,{kind:O.SCALAR_TYPE_EXTENSION,name:t,directives:n})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:O.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:O.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:O.UNION_TYPE_EXTENSION,name:t,directives:n,types:r})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:O.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:O.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(_.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:O.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:s})}parseDirectiveLocations(){return this.delimitedMany(_.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(b,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new v(e,this._lexer.lastToken,this._lexer.source)),t}peek(e){return this._lexer.token.kind===e}expectToken(e){const t=this._lexer.token;if(t.kind===e)return this.advanceLexer(),t;throw y(this._lexer.source,t.start,`Expected ${oe(e)}, found ${se(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==_.NAME||t.value!==e)throw y(this._lexer.source,t.start,`Expected "${e}", found ${se(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===_.NAME&&t.value===e&&(this.advanceLexer(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return y(this._lexer.source,t.start,`Unexpected ${se(t)}.`)}any(e,t,n){this.expectToken(e);const r=[];for(;!this.expectOptionalToken(n);)r.push(t.call(this));return r}optionalMany(e,t,n){if(this.expectOptionalToken(e)){const e=[];do{e.push(t.call(this))}while(!this.expectOptionalToken(n));return e}return[]}many(e,t,n){this.expectToken(e);const r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}delimitedMany(e,t){this.expectOptionalToken(e);const n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n}advanceLexer(){const{maxTokens:e}=this._options,t=this._lexer.advance();if(void 0!==e&&t.kind!==_.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw y(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function se(e){const t=e.value;return oe(e.kind)+(null!=t?` "${t}"`:"")}function oe(e){return function(e){return 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)?`"${e}"`:e}const ae=5;function ce(e,t){const[n,r]=t?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const s=r.map((e=>`"${e}"`));switch(s.length){case 0:return"";case 1:return i+s[0]+"?";case 2:return i+s[0]+" or "+s[1]+"?"}const o=s.slice(0,ae),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function ue(e){return e}function le(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function pe(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function de(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function fe(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(ye(i)&&ye(s)){let o=0;do{++n,o=10*o+i-he,i=e.charCodeAt(n)}while(ye(i)&&o>0);let a=0;do{++r,a=10*a+s-he,s=t.charCodeAt(r)}while(ye(s)&&a>0);if(o<a)return-1;if(o>a)return 1}else{if(i<s)return-1;if(i>s)return 1;++n,++r}}return e.length-t.length}const he=48,me=57;function ye(e){return!isNaN(e)&&he<=e&&e<=me}function ve(e,t){const n=Object.create(null),r=new Te(e),i=Math.floor(.4*e.length)+1;for(const e of t){const t=r.measure(e,i);void 0!==t&&(n[e]=t)}return Object.keys(n).sort(((e,t)=>{const r=n[e]-n[t];return 0!==r?r:fe(e,t)}))}class Te{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=Ee(this._inputLowerCase),this._rows=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)]}measure(e,t){if(this._input===e)return 0;const n=e.toLowerCase();if(this._inputLowerCase===n)return 1;let r=Ee(n),i=this._inputArray;if(r.length<i.length){const e=r;r=i,i=e}const s=r.length,o=i.length;if(s-o>t)return;const a=this._rows;for(let e=0;e<=o;e++)a[0][e]=e;for(let e=1;e<=s;e++){const n=a[(e-1)%3],s=a[e%3];let c=s[0]=e;for(let t=1;t<=o;t++){const o=r[e-1]===i[t-1]?0:1;let u=Math.min(n[t]+1,s[t-1]+1,n[t-1]+o);if(e>1&&t>1&&r[e-1]===i[t-2]&&r[e-2]===i[t-1]){const n=a[(e-2)%3][t-2];u=Math.min(u,n+1)}u<c&&(c=u),s[t]=u}if(c>t)return}const c=a[s%3][o];return c<=t?c:void 0}}function Ee(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function ge(e){if(null==e)return Object.create(null);if(null===Object.getPrototypeOf(e))return e;const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]=r;return t}const Ne=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Ie(e){return be[e.charCodeAt(0)]}const be=["\\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"],Oe=Object.freeze({});function _e(e,t,n=E){const r=new Map;for(const e of Object.values(O))r.set(e,Se(t,e));let i,s,a,c=Array.isArray(e),u=[e],l=-1,p=[],d=e;const f=[],h=[];do{l++;const e=l===u.length,T=e&&0!==p.length;if(e){if(s=0===h.length?void 0:f[f.length-1],d=a,a=h.pop(),T)if(c){d=d.slice();let e=0;for(const[t,n]of p){const r=t-e;null===n?(d.splice(r,1),e++):d[r]=n}}else{d=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));for(const[e,t]of p)d[e]=t}l=i.index,u=i.keys,p=i.edits,c=i.inArray,i=i.prev}else if(a){if(s=c?l:u[l],d=a[s],null==d)continue;f.push(s)}let E;if(!Array.isArray(d)){var m,y;N(d)||o(!1,`Invalid AST Node: ${ee(d)}.`);const n=e?null===(m=r.get(d.kind))||void 0===m?void 0:m.leave:null===(y=r.get(d.kind))||void 0===y?void 0:y.enter;if(E=null==n?void 0:n.call(t,d,s,a,f,h),E===Oe)break;if(!1===E){if(!e){f.pop();continue}}else if(void 0!==E&&(p.push([s,E]),!e)){if(!N(E)){f.pop();continue}d=E}}var v;if(void 0===E&&T&&p.push([s,d]),e)f.pop();else i={inArray:c,index:l,keys:u,edits:p,prev:i},c=Array.isArray(d),u=c?d:null!==(v=n[d.kind])&&void 0!==v?v:[],l=-1,p=[],a&&h.push(a),a=d}while(void 0!==i);return 0!==p.length?p[p.length-1][1]:e}function Se(e,t){const n=e[t];return"object"==typeof n?n:"function"==typeof n?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function we(e){return _e(e,Ae)}const Ae={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>De(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=Re("(",De(e.variableDefinitions,", "),")"),n=De([e.operation,De([e.name,t]),De(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+Re(" = ",n)+Re(" ",De(r," "))},SelectionSet:{leave:({selections:e})=>xe(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=Re("",e,": ")+t;let o=s+Re("(",De(n,", "),")");return o.length>80&&(o=s+Re("(\n",ke(De(n,"\n")),"\n)")),De([o,De(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+Re(" ",De(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>De(["...",Re("on ",e),De(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${Re("(",De(n,", "),")")} on ${t} ${Re("",De(r," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e,t){const n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=1===r.length,s=r.length>1&&r.slice(1).every((e=>0===e.length||S(e.charCodeAt(0)))),o=n.endsWith('\\"""'),a=e.endsWith('"')&&!o,c=e.endsWith("\\"),u=a||c,l=!(null!=t&&t.minimize)&&(!i||e.length>70||u||s||o);let p="";const d=i&&S(e.charCodeAt(0));return(l&&!d||s)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(Ne,Ie)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+De(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+De(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+Re("(",De(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>Re("",e,"\n")+De(["schema",De(t," "),xe(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>Re("",e,"\n")+De(["scalar",t,De(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>Re("",e,"\n")+De(["type",t,Re("implements ",De(n," & ")),De(r," "),xe(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>Re("",e,"\n")+t+(Fe(n)?Re("(\n",ke(De(n,"\n")),"\n)"):Re("(",De(n,", "),")"))+": "+r+Re(" ",De(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>Re("",e,"\n")+De([t+": "+n,Re("= ",r),De(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>Re("",e,"\n")+De(["interface",t,Re("implements ",De(n," & ")),De(r," "),xe(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>Re("",e,"\n")+De(["union",t,De(n," "),Re("= ",De(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>Re("",e,"\n")+De(["enum",t,De(n," "),xe(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>Re("",e,"\n")+De([t,De(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>Re("",e,"\n")+De(["input",t,De(n," "),xe(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>Re("",e,"\n")+"directive @"+t+(Fe(n)?Re("(\n",ke(De(n,"\n")),"\n)"):Re("(",De(n,", "),")"))+(r?" repeatable":"")+" on "+De(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>De(["extend schema",De(e," "),xe(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>De(["extend scalar",e,De(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>De(["extend type",e,Re("implements ",De(t," & ")),De(n," "),xe(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>De(["extend interface",e,Re("implements ",De(t," & ")),De(n," "),xe(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>De(["extend union",e,De(t," "),Re("= ",De(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>De(["extend enum",e,De(t," "),xe(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>De(["extend input",e,De(t," "),xe(n)]," ")}};function De(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function xe(e){return Re("{\n",ke(De(e,"\n")),"\n}")}function Re(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function ke(e){return Re(" ",e.replace(/\n/g,"\n "))}function Fe(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function Le(e,t){switch(e.kind){case O.NULL:return null;case O.INT:return parseInt(e.value,10);case O.FLOAT:return parseFloat(e.value);case O.STRING:case O.ENUM:case O.BOOLEAN:return e.value;case O.LIST:return e.values.map((e=>Le(e,t)));case O.OBJECT:return pe(e.fields,(e=>e.name.value),(e=>Le(e.value,t)));case O.VARIABLE:return null==t?void 0:t[e.name.value]}}function $e(e){if(null!=e||o(!1,"Must provide name."),"string"==typeof e||o(!1,"Expected name to be a string."),0===e.length)throw new h("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!x(e.charCodeAt(t)))throw new h(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!D(e.charCodeAt(0)))throw new h(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function Ce(e){if("true"===e||"false"===e||"null"===e)throw new h(`Enum values cannot be named: ${e}`);return $e(e)}function Ve(e){return Ue(e)||je(e)||Me(e)||Pe(e)||Be(e)||Ge(e)||qe(e)||Je(e)}function Ue(e){return ne(e,st)}function je(e){return ne(e,ot)}function Me(e){return ne(e,ht)}function Pe(e){return ne(e,mt)}function Be(e){return ne(e,vt)}function Ge(e){return ne(e,Et)}function qe(e){return ne(e,He)}function Je(e){return ne(e,We)}function Ye(e){return Ue(e)||Be(e)||Ge(e)||Ze(e)&&Ye(e.ofType)}function Qe(e){return Ue(e)||je(e)||Me(e)||Pe(e)||Be(e)||Ze(e)&&Qe(e.ofType)}function Ke(e){return Ue(e)||Be(e)}function ze(e){return je(e)||Me(e)||Pe(e)}function Xe(e){return Me(e)||Pe(e)}class He{constructor(e){Ve(e)||o(!1,`Expected ${ee(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class We{constructor(e){var t;Ve(t=e)&&!Je(t)||o(!1,`Expected ${ee(e)} to be a GraphQL nullable type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}}function Ze(e){return qe(e)||Je(e)}function et(e){if(e)return Je(e)?e.ofType:e}function tt(e){return Ue(e)||je(e)||Me(e)||Pe(e)||Be(e)||Ge(e)}function nt(e){if(e){let t=e;for(;Ze(t);)t=t.ofType;return t}}function rt(e){return"function"==typeof e?e():e}function it(e){return"function"==typeof e?e():e}class st{constructor(e){var t,n,r,i;const s=null!==(t=e.parseValue)&&void 0!==t?t:ue;this.name=$e(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=null!==(n=e.serialize)&&void 0!==n?n:ue,this.parseValue=s,this.parseLiteral=null!==(r=e.parseLiteral)&&void 0!==r?r:(e,t)=>s(Le(e,t)),this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(i=e.extensionASTNodes)&&void 0!==i?i:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||o(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${ee(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||o(!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.`),e.parseLiteral&&("function"==typeof e.parseValue&&"function"==typeof e.parseLiteral||o(!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 ot{constructor(e){var t;this.name=$e(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=()=>ct(e),this._interfaces=()=>at(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||o(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${ee(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:pt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function at(e){var t;const n=rt(null!==(t=e.interfaces)&&void 0!==t?t:[]);return Array.isArray(n)||o(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function ct(e){const t=it(e.fields);return lt(t)||o(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),de(t,((t,n)=>{var r;lt(t)||o(!1,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||o(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${ee(t.resolve)}.`);const i=null!==(r=t.args)&&void 0!==r?r:{};return lt(i)||o(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:$e(n),description:t.description,type:t.type,args:ut(i),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:ge(t.extensions),astNode:t.astNode}}))}function ut(e){return Object.entries(e).map((([e,t])=>({name:$e(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:ge(t.extensions),astNode:t.astNode})))}function lt(e){return c(e)&&!Array.isArray(e)}function pt(e){return de(e,(e=>({description:e.description,type:e.type,args:dt(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function dt(e){return pe(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function ft(e){return Je(e.type)&&void 0===e.defaultValue}class ht{constructor(e){var t;this.name=$e(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=ct.bind(void 0,e),this._interfaces=at.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||o(!1,`${this.name} must provide "resolveType" as a function, but got: ${ee(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:pt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class mt{constructor(e){var t;this.name=$e(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._types=yt.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||o(!1,`${this.name} must provide "resolveType" as a function, but got: ${ee(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}getTypes(){return"function"==typeof this._types&&(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 yt(e){const t=rt(e.types);return Array.isArray(t)||o(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class vt{constructor(e){var t,n,r;this.name=$e(e.name),this.description=e.description,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._values=(n=this.name,lt(r=e.values)||o(!1,`${n} values must be an object with value names as keys.`),Object.entries(r).map((([e,t])=>(lt(t)||o(!1,`${n}.${e} must refer to an object with a "value" key representing an internal value but got: ${ee(t)}.`),{name:Ce(e),description:t.description,value:void 0!==t.value?t.value:e,deprecationReason:t.deprecationReason,extensions:ge(t.extensions),astNode:t.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=le(this._values,(e=>e.name))}get[Symbol.toStringTag](){return"GraphQLEnumType"}getValues(){return this._values}getValue(e){return this._nameLookup[e]}serialize(e){const t=this._valueLookup.get(e);if(void 0===t)throw new h(`Enum "${this.name}" cannot represent value: ${ee(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=ee(e);throw new h(`Enum "${this.name}" cannot represent non-string value: ${t}.`+Tt(this,t))}const t=this.getValue(e);if(null==t)throw new h(`Value "${e}" does not exist in "${this.name}" enum.`+Tt(this,e));return t.value}parseLiteral(e,t){if(e.kind!==O.ENUM){const t=we(e);throw new h(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+Tt(this,t),{nodes:e})}const n=this.getValue(e.value);if(null==n){const t=we(e);throw new h(`Value "${t}" does not exist in "${this.name}" enum.`+Tt(this,t),{nodes:e})}return n.value}toConfig(){const e=pe(this.getValues(),(e=>e.name),(e=>({description:e.description,value:e.value,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Tt(e,t){return ce("the enum value",ve(t,e.getValues().map((e=>e.name))))}class Et{constructor(e){var t;this.name=$e(e.name),this.description=e.description,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=gt.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=de(this.getFields(),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function gt(e){const t=it(e.fields);return lt(t)||o(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),de(t,((t,n)=>(!("resolve"in t)||o(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:$e(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:ge(t.extensions),astNode:t.astNode})))}function Nt(e){return Je(e.type)&&void 0===e.defaultValue}function It(e,t){return e===t||(Je(e)&&Je(t)||!(!qe(e)||!qe(t)))&&It(e.ofType,t.ofType)}function bt(e,t,n){return t===n||(Je(n)?!!Je(t)&&bt(e,t.ofType,n.ofType):Je(t)?bt(e,t.ofType,n):qe(n)?!!qe(t)&&bt(e,t.ofType,n.ofType):!qe(t)&&(Xe(n)&&(Me(t)||je(t))&&e.isSubType(n,t)))}function Ot(e,t,n){return t===n||(Xe(t)?Xe(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Xe(n)&&e.isSubType(n,t))}const _t=2147483647,St=-2147483648,wt=new st({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=Ft(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isInteger(n))throw new h(`Int cannot represent non-integer value: ${ee(t)}`);if(n>_t||n<St)throw new h("Int cannot represent non 32-bit signed integer value: "+ee(t));return n},parseValue(e){if("number"!=typeof e||!Number.isInteger(e))throw new h(`Int cannot represent non-integer value: ${ee(e)}`);if(e>_t||e<St)throw new h(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==O.INT)throw new h(`Int cannot represent non-integer value: ${we(e)}`,{nodes:e});const t=parseInt(e.value,10);if(t>_t||t<St)throw new h(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),At=new st({name:"Float",description:"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",serialize(e){const t=Ft(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isFinite(n))throw new h(`Float cannot represent non numeric value: ${ee(t)}`);return n},parseValue(e){if("number"!=typeof e||!Number.isFinite(e))throw new h(`Float cannot represent non numeric value: ${ee(e)}`);return e},parseLiteral(e){if(e.kind!==O.FLOAT&&e.kind!==O.INT)throw new h(`Float cannot represent non numeric value: ${we(e)}`,e);return parseFloat(e.value)}}),Dt=new st({name:"String",description:"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",serialize(e){const t=Ft(e);if("string"==typeof t)return t;if("boolean"==typeof t)return t?"true":"false";if("number"==typeof t&&Number.isFinite(t))return t.toString();throw new h(`String cannot represent value: ${ee(e)}`)},parseValue(e){if("string"!=typeof e)throw new h(`String cannot represent a non string value: ${ee(e)}`);return e},parseLiteral(e){if(e.kind!==O.STRING)throw new h(`String cannot represent a non string value: ${we(e)}`,{nodes:e});return e.value}}),xt=new st({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){const t=Ft(e);if("boolean"==typeof t)return t;if(Number.isFinite(t))return 0!==t;throw new h(`Boolean cannot represent a non boolean value: ${ee(t)}`)},parseValue(e){if("boolean"!=typeof e)throw new h(`Boolean cannot represent a non boolean value: ${ee(e)}`);return e},parseLiteral(e){if(e.kind!==O.BOOLEAN)throw new h(`Boolean cannot represent a non boolean value: ${we(e)}`,{nodes:e});return e.value}}),Rt=new st({name:"ID",description:'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',serialize(e){const t=Ft(e);if("string"==typeof t)return t;if(Number.isInteger(t))return String(t);throw new h(`ID cannot represent value: ${ee(e)}`)},parseValue(e){if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e.toString();throw new h(`ID cannot represent value: ${ee(e)}`)},parseLiteral(e){if(e.kind!==O.STRING&&e.kind!==O.INT)throw new h("ID cannot represent a non-string and non-integer value: "+we(e),{nodes:e});return e.value}}),kt=Object.freeze([Dt,wt,At,xt,Rt]);function Ft(e){if(c(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!c(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function Lt(e){return ne(e,$t)}class $t{constructor(e){var t,n;this.name=$e(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(t=e.isRepeatable)&&void 0!==t&&t,this.extensions=ge(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||o(!1,`@${e.name} locations must be an Array.`);const r=null!==(n=e.args)&&void 0!==n?n:{};c(r)&&!Array.isArray(r)||o(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=ut(r)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:dt(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const Ct=new $t({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[b.FIELD,b.FRAGMENT_SPREAD,b.INLINE_FRAGMENT],args:{if:{type:new We(xt),description:"Included when true."}}}),Vt=new $t({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[b.FIELD,b.FRAGMENT_SPREAD,b.INLINE_FRAGMENT],args:{if:{type:new We(xt),description:"Skipped when true."}}}),Ut=new $t({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[b.FIELD_DEFINITION,b.ARGUMENT_DEFINITION,b.INPUT_FIELD_DEFINITION,b.ENUM_VALUE],args:{reason:{type:Dt,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",defaultValue:"No longer supported"}}}),jt=new $t({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[b.SCALAR],args:{url:{type:new We(Dt),description:"The URL that specifies the behavior of this scalar."}}}),Mt=Object.freeze([Ct,Vt,Ut,jt]);function Pt(e){return"object"==typeof e&&"function"==typeof(null==e?void 0:e[Symbol.iterator])}function Bt(e,t){if(Je(t)){const n=Bt(e,t.ofType);return(null==n?void 0:n.kind)===O.NULL?null:n}if(null===e)return{kind:O.NULL};if(void 0===e)return null;if(qe(t)){const n=t.ofType;if(Pt(e)){const t=[];for(const r of e){const e=Bt(r,n);null!=e&&t.push(e)}return{kind:O.LIST,values:t}}return Bt(e,n)}if(Ge(t)){if(!c(e))return null;const n=[];for(const r of Object.values(t.getFields())){const t=Bt(e[r.name],r.type);t&&n.push({kind:O.OBJECT_FIELD,name:{kind:O.NAME,value:r.name},value:t})}return{kind:O.OBJECT,fields:n}}if(Ke(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:O.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return Gt.test(e)?{kind:O.INT,value:e}:{kind:O.FLOAT,value:e}}if("string"==typeof n)return Be(t)?{kind:O.ENUM,value:n}:t===Rt&&Gt.test(n)?{kind:O.INT,value:n}:{kind:O.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${ee(n)}.`)}u(!1,"Unexpected input type: "+ee(t))}const Gt=/^-?(?:0|[1-9][0-9]*)$/,qt=new ot({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:()=>({description:{type:Dt,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new We(new He(new We(Qt))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new We(Qt),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:Qt,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:Qt,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new We(new He(new We(Jt))),resolve:e=>e.getDirectives()}})}),Jt=new ot({name:"__Directive",description:"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn 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 We(Dt),resolve:e=>e.name},description:{type:Dt,resolve:e=>e.description},isRepeatable:{type:new We(xt),resolve:e=>e.isRepeatable},locations:{type:new We(new He(new We(Yt))),resolve:e=>e.locations},args:{type:new We(new He(new We(zt))),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),Yt=new vt({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:b.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:b.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:b.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:b.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:b.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:b.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:b.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:b.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:b.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:b.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:b.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:b.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:b.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:b.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:b.UNION,description:"Location adjacent to a union definition."},ENUM:{value:b.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:b.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:b.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:b.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),Qt=new ot({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 We(Wt),resolve:e=>Ue(e)?Ht.SCALAR:je(e)?Ht.OBJECT:Me(e)?Ht.INTERFACE:Pe(e)?Ht.UNION:Be(e)?Ht.ENUM:Ge(e)?Ht.INPUT_OBJECT:qe(e)?Ht.LIST:Je(e)?Ht.NON_NULL:void u(!1,`Unexpected type: "${ee(e)}".`)},name:{type:Dt,resolve:e=>"name"in e?e.name:void 0},description:{type:Dt,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:Dt,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new He(new We(Kt)),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(je(e)||Me(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new He(new We(Qt)),resolve(e){if(je(e)||Me(e))return e.getInterfaces()}},possibleTypes:{type:new He(new We(Qt)),resolve(e,t,n,{schema:r}){if(Xe(e))return r.getPossibleTypes(e)}},enumValues:{type:new He(new We(Xt)),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Be(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new He(new We(zt)),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Ge(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:Qt,resolve:e=>"ofType"in e?e.ofType:void 0}})}),Kt=new ot({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 We(Dt),resolve:e=>e.name},description:{type:Dt,resolve:e=>e.description},args:{type:new We(new He(new We(zt))),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new We(Qt),resolve:e=>e.type},isDeprecated:{type:new We(xt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Dt,resolve:e=>e.deprecationReason}})}),zt=new ot({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 We(Dt),resolve:e=>e.name},description:{type:Dt,resolve:e=>e.description},type:{type:new We(Qt),resolve:e=>e.type},defaultValue:{type:Dt,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=Bt(n,t);return r?we(r):null}},isDeprecated:{type:new We(xt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Dt,resolve:e=>e.deprecationReason}})}),Xt=new ot({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 We(Dt),resolve:e=>e.name},description:{type:Dt,resolve:e=>e.description},isDeprecated:{type:new We(xt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Dt,resolve:e=>e.deprecationReason}})});var Ht;!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"}(Ht||(Ht={}));const Wt=new vt({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:Ht.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:Ht.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:Ht.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:Ht.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:Ht.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:Ht.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:Ht.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:Ht.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),Zt={name:"__schema",type:new We(qt),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},en={name:"__type",type:Qt,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new We(Dt),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},tn={name:"__typename",type:new We(Dt),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},nn=Object.freeze([qt,Jt,Yt,Qt,Kt,zt,Xt,Wt]);function rn(e){return nn.some((({name:t})=>e.name===t))}function sn(e){if(!function(e){return ne(e,on)}(e))throw new Error(`Expected ${ee(e)} to be a GraphQL schema.`);return e}class on{constructor(e){var t,n;this.__validationErrors=!0===e.assumeValid?[]:void 0,c(e)||o(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||o(!1,`"types" must be Array if provided but got: ${ee(e.types)}.`),!e.directives||Array.isArray(e.directives)||o(!1,`"directives" must be Array if provided but got: ${ee(e.directives)}.`),this.description=e.description,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=null!==(n=e.directives)&&void 0!==n?n:Mt;const r=new Set(e.types);if(null!=e.types)for(const t of e.types)r.delete(t),an(t,r);null!=this._queryType&&an(this._queryType,r),null!=this._mutationType&&an(this._mutationType,r),null!=this._subscriptionType&&an(this._subscriptionType,r);for(const e of this._directives)if(Lt(e))for(const t of e.args)an(t.type,r);an(qt,r),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const e of r){if(null==e)continue;const t=e.name;if(t||o(!1,"One of the provided types for building the Schema is missing a name."),void 0!==this._typeMap[t])throw new Error(`Schema must contain uniquely named types but contains multiple types named "${t}".`);if(this._typeMap[t]=e,Me(e)){for(const t of e.getInterfaces())if(Me(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(je(e))for(const t of e.getInterfaces())if(Me(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case I.QUERY:return this.getQueryType();case I.MUTATION:return this.getMutationType();case I.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return Pe(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){const t=this._implementationsMap[e.name];return null!=t?t:{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(void 0===n){if(n=Object.create(null),Pe(e))for(const t of e.getTypes())n[t.name]=!0;else{const t=this.getImplementations(e);for(const e of t.objects)n[e.name]=!0;for(const e of t.interfaces)n[e.name]=!0}this._subTypeMap[e.name]=n}return void 0!==n[t.name]}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find((t=>t.name===e))}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:void 0!==this.__validationErrors}}}function an(e,t){const n=nt(e);if(!t.has(n))if(t.add(n),Pe(n))for(const e of n.getTypes())an(e,t);else if(je(n)||Me(n)){for(const e of n.getInterfaces())an(e,t);for(const e of Object.values(n.getFields())){an(e.type,t);for(const n of e.args)an(n.type,t)}}else if(Ge(n))for(const e of Object.values(n.getFields()))an(e.type,t);return t}function cn(e){if(sn(e),e.__validationErrors)return e.__validationErrors;const t=new ln(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!je(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${ee(n)}.`,null!==(r=pn(t,I.QUERY))&&void 0!==r?r:n.astNode)}}else e.reportError("Query root type must be provided.",t.astNode);const i=t.getMutationType();var s;i&&!je(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${ee(i)}.`,null!==(s=pn(t,I.MUTATION))&&void 0!==s?s:i.astNode);const o=t.getSubscriptionType();var a;o&&!je(o)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${ee(o)}.`,null!==(a=pn(t,I.SUBSCRIPTION))&&void 0!==a?a:o.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(Lt(n)){dn(e,n);for(const r of n.args){var t;if(dn(e,r),Ye(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${ee(r.type)}.`,r.astNode),ft(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[In(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${ee(n)}.`,null==n?void 0:n.astNode)}(t),function(e){const t=function(e){const t=Object.create(null),n=[],r=Object.create(null);return i;function i(s){if(t[s.name])return;t[s.name]=!0,r[s.name]=n.length;const o=Object.values(s.getFields());for(const t of o)if(Je(t.type)&&Ge(t.type.ofType)){const s=t.type.ofType,o=r[s.name];if(n.push(t),void 0===o)i(s);else{const t=n.slice(o),r=t.map((e=>e.name)).join(".");e.reportError(`Cannot reference Input Object "${s.name}" within itself through a series of non-null fields: "${r}".`,t.map((e=>e.astNode)))}n.pop()}r[s.name]=void 0}}(e),n=e.schema.getTypeMap();for(const r of Object.values(n))tt(r)?(rn(r)||dn(e,r),je(r)||Me(r)?(fn(e,r),hn(e,r)):Pe(r)?vn(e,r):Be(r)?Tn(e,r):Ge(r)&&(En(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${ee(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}function un(e){const t=cn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}class ln{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new h(e,{nodes:n}))}getErrors(){return this._errors}}function pn(e,t){var n;return null===(n=[e.astNode,...e.extensionASTNodes].flatMap((e=>{var t;return null!==(t=null==e?void 0:e.operationTypes)&&void 0!==t?t:[]})).find((e=>e.operation===t)))||void 0===n?void 0:n.type}function dn(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function fn(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const o of n){var r;if(dn(e,o),!Qe(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Output Type but got: ${ee(o.type)}.`,null===(r=o.astNode)||void 0===r?void 0:r.type);for(const n of o.args){const r=n.name;var i,s;if(dn(e,n),!Ye(n.type))e.reportError(`The type of ${t.name}.${o.name}(${r}:) must be Input Type but got: ${ee(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(ft(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${o.name}(${r}:) cannot be deprecated.`,[In(n.astNode),null===(s=n.astNode)||void 0===s?void 0:s.type])}}}function hn(e,t){const n=Object.create(null);for(const r of t.getInterfaces())Me(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,gn(t,r)):(n[r.name]=!0,yn(e,t,r),mn(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,gn(t,r)):e.reportError(`Type ${ee(t)} must only implement Interface types, it cannot implement ${ee(r)}.`,gn(t,r))}function mn(e,t,n){const r=t.getFields();for(const c of Object.values(n.getFields())){const u=c.name,l=r[u];if(l){var i,s;if(!bt(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${ee(c.type)} but ${t.name}.${u} is type ${ee(l.type)}.`,[null===(i=c.astNode)||void 0===i?void 0:i.type,null===(s=l.astNode)||void 0===s?void 0:s.type]);for(const r of c.args){const i=r.name,s=l.args.find((e=>e.name===i));var o,a;if(s){if(!It(r.type,s.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${ee(r.type)} but ${t.name}.${u}(${i}:) is type ${ee(s.type)}.`,[null===(o=r.astNode)||void 0===o?void 0:o.type,null===(a=s.astNode)||void 0===a?void 0:a.type])}else e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expected but ${t.name}.${u} does not provide it.`,[r.astNode,l.astNode])}for(const r of l.args){const i=r.name;!c.args.find((e=>e.name===i))&&ft(r)&&e.reportError(`Object field ${t.name}.${u} includes required argument ${i} that is missing from the Interface field ${n.name}.${u}.`,[r.astNode,c.astNode])}}else e.reportError(`Interface field ${n.name}.${u} expected but ${t.name} does not provide it.`,[c.astNode,t.astNode,...t.extensionASTNodes])}}function yn(e,t,n){const r=t.getInterfaces();for(const i of n.getInterfaces())r.includes(i)||e.reportError(i===t?`Type ${t.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${t.name} must implement ${i.name} because it is implemented by ${n.name}.`,[...gn(n,i),...gn(t,n)])}function vn(e,t){const n=t.getTypes();0===n.length&&e.reportError(`Union type ${t.name} must define one or more member types.`,[t.astNode,...t.extensionASTNodes]);const r=Object.create(null);for(const i of n)r[i.name]?e.reportError(`Union type ${t.name} can only include type ${i.name} once.`,Nn(t,i.name)):(r[i.name]=!0,je(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${ee(i)}.`,Nn(t,String(i))))}function Tn(e,t){const n=t.getValues();0===n.length&&e.reportError(`Enum type ${t.name} must define one or more values.`,[t.astNode,...t.extensionASTNodes]);for(const t of n)dn(e,t)}function En(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const s of n){var r,i;if(dn(e,s),!Ye(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Input Type but got: ${ee(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);if(Nt(s)&&null!=s.deprecationReason)e.reportError(`Required input field ${t.name}.${s.name} cannot be deprecated.`,[In(s.astNode),null===(i=s.astNode)||void 0===i?void 0:i.type])}}function gn(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.interfaces)&&void 0!==t?t:[]})).filter((e=>e.name.value===t.name))}function Nn(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.types)&&void 0!==t?t:[]})).filter((e=>e.name.value===t))}function In(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===Ut.name))}function bn(e,t){switch(t.kind){case O.LIST_TYPE:{const n=bn(e,t.type);return n&&new He(n)}case O.NON_NULL_TYPE:{const n=bn(e,t.type);return n&&new We(n)}case O.NAMED_TYPE:return e.getType(t.name.value)}}class On{constructor(e,t,n){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=null!=n?n:_n,t&&(Ye(t)&&this._inputTypeStack.push(t),ze(t)&&this._parentTypeStack.push(t),Qe(t)&&this._typeStack.push(t))}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(e){const t=this._schema;switch(e.kind){case O.SELECTION_SET:{const e=nt(this.getType());this._parentTypeStack.push(ze(e)?e:void 0);break}case O.FIELD:{const n=this.getParentType();let r,i;n&&(r=this._getFieldDef(t,n,e),r&&(i=r.type)),this._fieldDefStack.push(r),this._typeStack.push(Qe(i)?i:void 0);break}case O.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case O.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(je(n)?n:void 0);break}case O.INLINE_FRAGMENT:case O.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?bn(t,n):nt(this.getType());this._typeStack.push(Qe(r)?r:void 0);break}case O.VARIABLE_DEFINITION:{const n=bn(t,e.type);this._inputTypeStack.push(Ye(n)?n:void 0);break}case O.ARGUMENT:{var n;let t,r;const i=null!==(n=this.getDirective())&&void 0!==n?n:this.getFieldDef();i&&(t=i.args.find((t=>t.name===e.name.value)),t&&(r=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(Ye(r)?r:void 0);break}case O.LIST:{const e=et(this.getInputType()),t=qe(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(Ye(t)?t:void 0);break}case O.OBJECT_FIELD:{const t=nt(this.getInputType());let n,r;Ge(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(Ye(n)?n:void 0);break}case O.ENUM:{const t=nt(this.getInputType());let n;Be(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case O.SELECTION_SET:this._parentTypeStack.pop();break;case O.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case O.DIRECTIVE:this._directive=null;break;case O.OPERATION_DEFINITION:case O.INLINE_FRAGMENT:case O.FRAGMENT_DEFINITION:this._typeStack.pop();break;case O.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case O.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case O.LIST:case O.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case O.ENUM:this._enumValue=null}}}function _n(e,t,n){const r=n.name.value;return r===Zt.name&&e.getQueryType()===t?Zt:r===en.name&&e.getQueryType()===t?en:r===tn.name&&ze(t)?tn:je(t)||Me(t)?t.getFields()[r]:void 0}function Sn(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=Se(t,r.kind).enter;if(i){const s=i.apply(t,n);return void 0!==s&&(e.leave(r),N(s)&&e.enter(s)),s}},leave(...n){const r=n[0],i=Se(t,r.kind).leave;let s;return i&&(s=i.apply(t,n)),e.leave(r),s}}}function wn(e){return e.kind===O.OPERATION_DEFINITION||e.kind===O.FRAGMENT_DEFINITION}function An(e){return e.kind===O.SCALAR_TYPE_DEFINITION||e.kind===O.OBJECT_TYPE_DEFINITION||e.kind===O.INTERFACE_TYPE_DEFINITION||e.kind===O.UNION_TYPE_DEFINITION||e.kind===O.ENUM_TYPE_DEFINITION||e.kind===O.INPUT_OBJECT_TYPE_DEFINITION}function Dn(e){return e.kind===O.SCALAR_TYPE_EXTENSION||e.kind===O.OBJECT_TYPE_EXTENSION||e.kind===O.INTERFACE_TYPE_EXTENSION||e.kind===O.UNION_TYPE_EXTENSION||e.kind===O.ENUM_TYPE_EXTENSION||e.kind===O.INPUT_OBJECT_TYPE_EXTENSION}function xn(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Mt;for(const e of r)t[e.name]=e.args.map((e=>e.name));const i=e.getDocument().definitions;for(const e of i)if(e.kind===O.DIRECTIVE_DEFINITION){var s;const n=null!==(s=e.arguments)&&void 0!==s?s:[];t[e.name.value]=n.map((e=>e.name.value))}return{Directive(n){const r=n.name.value,i=t[r];if(n.arguments&&i)for(const t of n.arguments){const n=t.name.value;if(!i.includes(n)){const s=ve(n,i);e.reportError(new h(`Unknown argument "${n}" on directive "@${r}".`+ce(s),{nodes:t}))}}return!1}}}const Rn=[...kt,...nn].map((e=>e.name));function kn(e){switch(e.kind){case O.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:kn(e.value)}))).sort(((e,t)=>fe(e.name.value,t.name.value))))};case O.LIST:return{...e,values:e.values.map(kn)};case O.INT:case O.FLOAT:case O.STRING:case O.BOOLEAN:case O.NULL:case O.ENUM:case O.VARIABLE:return e}var t}function Fn(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+Fn(t))).join(" and "):e}function Ln(e,t,n,r,i,s,o){const a=e.getFragment(o);if(!a)return;const[c,u]=Pn(e,n,a);if(s!==c){Cn(e,t,n,r,i,s,c);for(const a of u)r.has(a,o,i)||(r.add(a,o,i),Ln(e,t,n,r,i,s,a))}}function $n(e,t,n,r,i,s,o){if(s===o)return;if(r.has(s,o,i))return;r.add(s,o,i);const a=e.getFragment(s),c=e.getFragment(o);if(!a||!c)return;const[u,l]=Pn(e,n,a),[p,d]=Pn(e,n,c);Cn(e,t,n,r,i,u,p);for(const o of d)$n(e,t,n,r,i,s,o);for(const s of l)$n(e,t,n,r,i,s,o)}function Cn(e,t,n,r,i,s,o){for(const[a,c]of Object.entries(s)){const s=o[a];if(s)for(const o of c)for(const c of s){const s=Vn(e,n,r,i,a,o,c);s&&t.push(s)}}}function Vn(e,t,n,r,i,s,o){const[a,c,u]=s,[l,p,d]=o,f=r||a!==l&&je(a)&&je(l);if(!f){const e=c.name.value,t=p.name.value;if(e!==t)return[[i,`"${e}" and "${t}" are different fields`],[c],[p]];if(Un(c)!==Un(p))return[[i,"they have differing arguments"],[c],[p]]}const h=null==u?void 0:u.type,m=null==d?void 0:d.type;if(h&&m&&jn(h,m))return[[i,`they return conflicting types "${ee(h)}" and "${ee(m)}"`],[c],[p]];const y=c.selectionSet,v=p.selectionSet;if(y&&v){const r=function(e,t,n,r,i,s,o,a){const c=[],[u,l]=Mn(e,t,i,s),[p,d]=Mn(e,t,o,a);Cn(e,c,t,n,r,u,p);for(const i of d)Ln(e,c,t,n,r,u,i);for(const i of l)Ln(e,c,t,n,r,p,i);for(const i of l)for(const s of d)$n(e,c,t,n,r,i,s);return c}(e,t,n,f,nt(h),y,nt(m),v);return function(e,t,n,r){if(e.length>0)return[[t,e.map((([e])=>e))],[n,...e.map((([,e])=>e)).flat()],[r,...e.map((([,,e])=>e)).flat()]]}(r,i,c,p)}}function Un(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return we(kn({kind:O.OBJECT,fields:n.map((e=>({kind:O.OBJECT_FIELD,name:e.name,value:e.value})))}))}function jn(e,t){return qe(e)?!qe(t)||jn(e.ofType,t.ofType):!!qe(t)||(Je(e)?!Je(t)||jn(e.ofType,t.ofType):!!Je(t)||!(!Ke(e)&&!Ke(t))&&e!==t)}function Mn(e,t,n,r){const i=t.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);Bn(e,n,r,s,o);const a=[s,Object.keys(o)];return t.set(r,a),a}function Pn(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=bn(e.getSchema(),n.typeCondition);return Mn(e,t,i,n.selectionSet)}function Bn(e,t,n,r,i){for(const s of n.selections)switch(s.kind){case O.FIELD:{const e=s.name.value;let n;(je(t)||Me(t))&&(n=t.getFields()[e]);const i=s.alias?s.alias.value:e;r[i]||(r[i]=[]),r[i].push([t,s,n]);break}case O.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case O.INLINE_FRAGMENT:{const n=s.typeCondition,o=n?bn(e.getSchema(),n):t;Bn(e,o,s.selectionSet,r,i);break}}}class Gn{constructor(){this._data=new Map}has(e,t,n){var r;const[i,s]=e<t?[e,t]:[t,e],o=null===(r=this._data.get(i))||void 0===r?void 0:r.get(s);return void 0!==o&&(!!n||n===o)}add(e,t,n){const[r,i]=e<t?[e,t]:[t,e],s=this._data.get(r);void 0===s?this._data.set(r,new Map([[i,n]])):s.set(i,n)}}function qn(e){var t;const n=Object.create(null),r=e.getSchema(),i=null!==(t=null==r?void 0:r.getDirectives())&&void 0!==t?t:Mt;for(const e of i)n[e.name]=le(e.args.filter(ft),(e=>e.name));const s=e.getDocument().definitions;for(const e of s)if(e.kind===O.DIRECTIVE_DEFINITION){var o;const t=null!==(o=e.arguments)&&void 0!==o?o:[];n[e.name.value]=le(t.filter(Jn),(e=>e.name.value))}return{Directive:{leave(t){const r=t.name.value,i=n[r];if(i){var s;const n=null!==(s=t.arguments)&&void 0!==s?s:[],o=new Set(n.map((e=>e.name.value)));for(const[n,s]of Object.entries(i))if(!o.has(n)){const i=Ve(s.type)?ee(s.type):we(s.type);e.reportError(new h(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}}}function Jn(e){return e.type.kind===O.NON_NULL_TYPE&&null==e.defaultValue}function Yn(e){return e.map((e=>"number"==typeof e?"["+e.toString()+"]":"."+e)).join("")}function Qn(e,t,n){return{prev:e,key:t,typename:n}}function Kn(e){const t=[];let n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function zn(e,t,n=Xn){return Hn(e,t,n,void 0)}function Xn(e,t,n){let r="Invalid value "+ee(t);throw e.length>0&&(r+=` at "value${Yn(e)}"`),n.message=r+": "+n.message,n}function Hn(e,t,n,r){if(Je(t))return null!=e?Hn(e,t.ofType,n,r):void n(Kn(r),e,new h(`Expected non-nullable type "${ee(t)}" not to be null.`));if(null==e)return null;if(qe(t)){const i=t.ofType;return Pt(e)?Array.from(e,((e,t)=>{const s=Qn(r,t,void 0);return Hn(e,i,n,s)})):[Hn(e,i,n,r)]}if(Ge(t)){if(!c(e))return void n(Kn(r),e,new h(`Expected type "${t.name}" to be an object.`));const i={},s=t.getFields();for(const o of Object.values(s)){const s=e[o.name];if(void 0!==s)i[o.name]=Hn(s,o.type,n,Qn(r,o.name,t.name));else if(void 0!==o.defaultValue)i[o.name]=o.defaultValue;else if(Je(o.type)){const t=ee(o.type);n(Kn(r),e,new h(`Field "${o.name}" of required type "${t}" was not provided.`))}}for(const i of Object.keys(e))if(!s[i]){const s=ve(i,Object.keys(t.getFields()));n(Kn(r),e,new h(`Field "${i}" is not defined by type "${t.name}".`+ce(s)))}return i}if(Ke(t)){let i;try{i=t.parseValue(e)}catch(i){return void n(Kn(r),e,i instanceof h?i:new h(`Expected type "${t.name}". `+i.message,{originalError:i}))}return void 0===i&&n(Kn(r),e,new h(`Expected type "${t.name}".`)),i}u(!1,"Unexpected input type: "+ee(t))}function Wn(e,t,n){if(e){if(e.kind===O.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&Je(t))return;return i}if(Je(t)){if(e.kind===O.NULL)return;return Wn(e,t.ofType,n)}if(e.kind===O.NULL)return null;if(qe(t)){const r=t.ofType;if(e.kind===O.LIST){const t=[];for(const i of e.values)if(Zn(i,n)){if(Je(r))return;t.push(null)}else{const e=Wn(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=Wn(e,r,n);if(void 0===i)return;return[i]}if(Ge(t)){if(e.kind!==O.OBJECT)return;const r=Object.create(null),i=le(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||Zn(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(Je(e.type))return;continue}const s=Wn(t.value,e.type,n);if(void 0===s)return;r[e.name]=s}return r}if(Ke(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}u(!1,"Unexpected input type: "+ee(t))}}function Zn(e,t){return e.kind===O.VARIABLE&&(null==t||void 0===t[e.name.value])}function er(e,t,n,r){const i=[],s=null==r?void 0:r.maxErrors;try{const r=function(e,t,n,r){const i={};for(const s of t){const t=s.variable.name.value,o=bn(e,s.type);if(!Ye(o)){const e=we(s.type);r(new h(`Variable "$${t}" expected value of type "${e}" which cannot be used as an input type.`,{nodes:s.type}));continue}if(!rr(n,t)){if(s.defaultValue)i[t]=Wn(s.defaultValue,o);else if(Je(o)){const e=ee(o);r(new h(`Variable "$${t}" of required type "${e}" was not provided.`,{nodes:s}))}continue}const a=n[t];if(null===a&&Je(o)){const e=ee(o);r(new h(`Variable "$${t}" of non-null type "${e}" must not be null.`,{nodes:s}))}else i[t]=zn(a,o,((e,n,i)=>{let o=`Variable "$${t}" got invalid value `+ee(n);e.length>0&&(o+=` at "${t}${Yn(e)}"`),r(new h(o+"; "+i.message,{nodes:s,originalError:i.originalError}))}))}return i}(e,t,n,(e=>{if(null!=s&&i.length>=s)throw new h("Too many errors processing variables, error limit reached. Execution aborted.");i.push(e)}));if(0===i.length)return{coerced:r}}catch(e){i.push(e)}return{errors:i}}function tr(e,t,n){var r;const i={},s=le(null!==(r=t.arguments)&&void 0!==r?r:[],(e=>e.name.value));for(const r of e.args){const e=r.name,o=r.type,a=s[e];if(!a){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(Je(o))throw new h(`Argument "${e}" of required type "${ee(o)}" was not provided.`,{nodes:t});continue}const c=a.value;let u=c.kind===O.NULL;if(c.kind===O.VARIABLE){const t=c.name.value;if(null==n||!rr(n,t)){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(Je(o))throw new h(`Argument "${e}" of required type "${ee(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}u=null==n[t]}if(u&&Je(o))throw new h(`Argument "${e}" of non-null type "${ee(o)}" must not be null.`,{nodes:c});const l=Wn(c,o,n);if(void 0===l)throw new h(`Argument "${e}" has invalid value ${we(c)}.`,{nodes:c});i[e]=l}return i}function nr(e,t,n){var r;const i=null===(r=t.directives)||void 0===r?void 0:r.find((t=>t.name.value===e.name));if(i)return tr(e,i,n)}function rr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ir(e,t,n,r,i){const s=new Map;return sr(e,t,n,r,i,s,new Set),s}function sr(e,t,n,r,i,s,o){for(const c of i.selections)switch(c.kind){case O.FIELD:{if(!or(n,c))continue;const e=(a=c).alias?a.alias.value:a.name.value,t=s.get(e);void 0!==t?t.push(c):s.set(e,[c]);break}case O.INLINE_FRAGMENT:if(!or(n,c)||!ar(e,c,r))continue;sr(e,t,n,r,c.selectionSet,s,o);break;case O.FRAGMENT_SPREAD:{const i=c.name.value;if(o.has(i)||!or(n,c))continue;o.add(i);const a=t[i];if(!a||!ar(e,a,r))continue;sr(e,t,n,r,a.selectionSet,s,o);break}}var a}function or(e,t){const n=nr(Vt,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=nr(Ct,t,e);return!1!==(null==r?void 0:r.if)}function ar(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=bn(e,r);return i===n||!!Xe(i)&&e.isSubType(i,n)}function cr(e,t){const n=new Map;for(const r of e){const e=t(r),i=n.get(e);void 0===i?n.set(e,[r]):i.push(r)}return n}function ur(e,t){const n=e.getInputType();if(!n)return;const r=nt(n);if(Ke(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=ee(n);e.reportError(new h(`Expected value of type "${r}", found ${we(t)}.`,{nodes:t}))}}catch(r){const i=ee(n);r instanceof h?e.reportError(r):e.reportError(new h(`Expected value of type "${i}", found ${we(t)}; `+r.message,{nodes:t,originalError:r}))}else{const r=ee(n);e.reportError(new h(`Expected value of type "${r}", found ${we(t)}.`,{nodes:t}))}}function lr(e,t,n,r,i){if(Je(r)&&!Je(t)){if(!(null!=n&&n.kind!==O.NULL)&&!(void 0!==i))return!1;return bt(e,t,r.ofType)}return bt(e,t,r)}const pr=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!wn(n)){const t=n.kind===O.SCHEMA_DEFINITION||n.kind===O.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new h(`The ${t} definition is not executable.`,{nodes:n}))}return!1}}},function(e){const t=Object.create(null);return{OperationDefinition(n){const r=n.name;return r&&(t[r.value]?e.reportError(new h(`There can be only one operation named "${r.value}".`,{nodes:[t[r.value],r]})):t[r.value]=r),!1},FragmentDefinition:()=>!1}},function(e){let t=0;return{Document(e){t=e.definitions.filter((e=>e.kind===O.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new h("This anonymous operation must be the only defined operation.",{nodes:n}))}}},function(e){return{OperationDefinition(t){if("subscription"===t.operation){const n=e.getSchema(),r=n.getSubscriptionType();if(r){const i=t.name?t.name.value:null,s=Object.create(null),o=e.getDocument(),a=Object.create(null);for(const e of o.definitions)e.kind===O.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=ir(n,a,s,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new h(null!=i?`Subscription "${i}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",{nodes:t}))}for(const t of c.values()){t[0].name.value.startsWith("__")&&e.reportError(new h(null!=i?`Subscription "${i}" must not select an introspection top level field.`:"Anonymous Subscription must not select an introspection top level field.",{nodes:t}))}}}}}},function(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(const t of e.getDocument().definitions)An(t)&&(r[t.name.value]=!0);const i=[...Object.keys(n),...Object.keys(r)];return{NamedType(t,s,o,a,c){const u=t.name.value;if(!n[u]&&!r[u]){var l;const n=null!==(l=c[2])&&void 0!==l?l:o,r=null!=n&&("kind"in(p=n)&&(function(e){return e.kind===O.SCHEMA_DEFINITION||An(e)||e.kind===O.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===O.SCHEMA_EXTENSION||Dn(e)}(p)));if(r&&Rn.includes(u))return;const s=ve(u,r?Rn.concat(i):i);e.reportError(new h(`Unknown type "${u}".`+ce(s),{nodes:t}))}var p}}},function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=bn(e.getSchema(),n);if(t&&!ze(t)){const t=we(n);e.reportError(new h(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){const n=bn(e.getSchema(),t.typeCondition);if(n&&!ze(n)){const n=we(t.typeCondition);e.reportError(new h(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}},function(e){return{VariableDefinition(t){const n=bn(e.getSchema(),t.type);if(void 0!==n&&!Ye(n)){const n=t.variable.name.value,r=we(t.type);e.reportError(new h(`Variable "$${n}" cannot be non-input type "${r}".`,{nodes:t.type}))}}}},function(e){return{Field(t){const n=e.getType(),r=t.selectionSet;if(n)if(Ke(nt(n))){if(r){const i=t.name.value,s=ee(n);e.reportError(new h(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(!r){const r=t.name.value,i=ee(n);e.reportError(new h(`Field "${r}" of type "${i}" must have a selection of subfields. Did you mean "${r} { ... }"?`,{nodes:t}))}}}},function(e){return{Field(t){const n=e.getParentType();if(n){if(!e.getFieldDef()){const r=e.getSchema(),i=t.name.value;let s=ce("to use an inline fragment on",function(e,t,n){if(!Xe(t))return[];const r=new Set,i=Object.create(null);for(const o of e.getPossibleTypes(t))if(o.getFields()[n]){r.add(o),i[o.name]=1;for(const e of o.getInterfaces()){var s;e.getFields()[n]&&(r.add(e),i[e.name]=(null!==(s=i[e.name])&&void 0!==s?s:0)+1)}}return[...r].sort(((t,n)=>{const r=i[n.name]-i[t.name];return 0!==r?r:Me(t)&&e.isSubType(t,n)?-1:Me(n)&&e.isSubType(n,t)?1:fe(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===s&&(s=ce(function(e,t){if(je(e)||Me(e)){return ve(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new h(`Cannot query field "${i}" on type "${n.name}".`+s,{nodes:t}))}}}}},function(e){const t=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){const r=n.name.value;return t[r]?e.reportError(new h(`There can be only one fragment named "${r}".`,{nodes:[t[r],n.name]})):t[r]=n.name,!1}}},function(e){return{FragmentSpread(t){const n=t.name.value;e.getFragment(n)||e.reportError(new h(`Unknown fragment "${n}".`,{nodes:t.name}))}}},function(e){const t=[],n=[];return{OperationDefinition:e=>(t.push(e),!1),FragmentDefinition:e=>(n.push(e),!1),Document:{leave(){const r=Object.create(null);for(const n of t)for(const t of e.getRecursivelyReferencedFragments(n))r[t.name.value]=!0;for(const t of n){const n=t.name.value;!0!==r[n]&&e.reportError(new h(`Fragment "${n}" is never used.`,{nodes:t}))}}}}},function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(ze(n)&&ze(r)&&!Ot(e.getSchema(),n,r)){const i=ee(r),s=ee(n);e.reportError(new h(`Fragment cannot be spread here as objects of type "${i}" can never be of type "${s}".`,{nodes:t}))}},FragmentSpread(t){const n=t.name.value,r=function(e,t){const n=e.getFragment(t);if(n){const t=bn(e.getSchema(),n.typeCondition);if(ze(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!Ot(e.getSchema(),r,i)){const s=ee(i),o=ee(r);e.reportError(new h(`Fragment "${n}" cannot be spread here as objects of type "${s}" can never be of type "${o}".`,{nodes:t}))}}}},function(e){const t=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition:e=>(i(e),!1)};function i(s){if(t[s.name.value])return;const o=s.name.value;t[o]=!0;const a=e.getFragmentSpreads(s.selectionSet);if(0!==a.length){r[o]=n.length;for(const t of a){const s=t.name.value,o=r[s];if(n.push(t),void 0===o){const t=e.getFragment(s);t&&i(t)}else{const t=n.slice(o),r=t.slice(0,-1).map((e=>'"'+e.name.value+'"')).join(", ");e.reportError(new h(`Cannot spread fragment "${s}" within itself`+(""!==r?` via ${r}.`:"."),{nodes:t}))}n.pop()}r[o]=void 0}}},function(e){return{OperationDefinition(t){var n;const r=cr(null!==(n=t.variableDefinitions)&&void 0!==n?n:[],(e=>e.variable.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new h(`There can be only one variable named "$${t}".`,{nodes:n.map((e=>e.variable.name))}))}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:i}of r){const r=i.name.value;!0!==t[r]&&e.reportError(new h(n.name?`Variable "$${r}" is not defined by operation "${n.name.value}".`:`Variable "$${r}" is not defined.`,{nodes:[i,n]}))}}},VariableDefinition(e){t[e.variable.name.value]=!0}}},function(e){let t=[];return{OperationDefinition:{enter(){t=[]},leave(n){const r=Object.create(null),i=e.getRecursiveVariableUsages(n);for(const{node:e}of i)r[e.name.value]=!0;for(const i of t){const t=i.variable.name.value;!0!==r[t]&&e.reportError(new h(n.name?`Variable "$${t}" is never used in operation "${n.name.value}".`:`Variable "$${t}" is never used.`,{nodes:i}))}}},VariableDefinition(e){t.push(e)}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Mt;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===O.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map((e=>e.value)));return{Directive(n,r,i,s,o){const a=n.name.value,c=t[a];if(!c)return void e.reportError(new h(`Unknown directive "@${a}".`,{nodes:n}));const l=function(e){const t=e[e.length-1];switch("kind"in t||u(!1),t.kind){case O.OPERATION_DEFINITION:return function(e){switch(e){case I.QUERY:return b.QUERY;case I.MUTATION:return b.MUTATION;case I.SUBSCRIPTION:return b.SUBSCRIPTION}}(t.operation);case O.FIELD:return b.FIELD;case O.FRAGMENT_SPREAD:return b.FRAGMENT_SPREAD;case O.INLINE_FRAGMENT:return b.INLINE_FRAGMENT;case O.FRAGMENT_DEFINITION:return b.FRAGMENT_DEFINITION;case O.VARIABLE_DEFINITION:return b.VARIABLE_DEFINITION;case O.SCHEMA_DEFINITION:case O.SCHEMA_EXTENSION:return b.SCHEMA;case O.SCALAR_TYPE_DEFINITION:case O.SCALAR_TYPE_EXTENSION:return b.SCALAR;case O.OBJECT_TYPE_DEFINITION:case O.OBJECT_TYPE_EXTENSION:return b.OBJECT;case O.FIELD_DEFINITION:return b.FIELD_DEFINITION;case O.INTERFACE_TYPE_DEFINITION:case O.INTERFACE_TYPE_EXTENSION:return b.INTERFACE;case O.UNION_TYPE_DEFINITION:case O.UNION_TYPE_EXTENSION:return b.UNION;case O.ENUM_TYPE_DEFINITION:case O.ENUM_TYPE_EXTENSION:return b.ENUM;case O.ENUM_VALUE_DEFINITION:return b.ENUM_VALUE;case O.INPUT_OBJECT_TYPE_DEFINITION:case O.INPUT_OBJECT_TYPE_EXTENSION:return b.INPUT_OBJECT;case O.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||u(!1),t.kind===O.INPUT_OBJECT_TYPE_DEFINITION?b.INPUT_FIELD_DEFINITION:b.ARGUMENT_DEFINITION}default:u(!1,"Unexpected kind: "+ee(t.kind))}}(o);l&&!c.includes(l)&&e.reportError(new h(`Directive "@${a}" may not be used on ${l}.`,{nodes:n}))}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Mt;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===O.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);const s=Object.create(null),o=Object.create(null);return{enter(n){if(!("directives"in n)||!n.directives)return;let r;if(n.kind===O.SCHEMA_DEFINITION||n.kind===O.SCHEMA_EXTENSION)r=s;else if(An(n)||Dn(n)){const e=n.name.value;r=o[e],void 0===r&&(o[e]=r=Object.create(null))}else r=Object.create(null);for(const i of n.directives){const n=i.name.value;t[n]&&(r[n]?e.reportError(new h(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}},function(e){return{...xn(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,s=ve(n,r.args.map((e=>e.name)));e.reportError(new h(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+ce(s),{nodes:t}))}}}},function(e){return{Field:t,Directive:t};function t(t){var n;const r=cr(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new h(`There can be only one argument named "${t}".`,{nodes:n.map((e=>e.name))}))}},function(e){return{ListValue(t){if(!qe(et(e.getParentInputType())))return ur(e,t),!1},ObjectValue(t){const n=nt(e.getInputType());if(!Ge(n))return ur(e,t),!1;const r=le(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&Nt(i)){const r=ee(i.type);e.reportError(new h(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,{nodes:t}))}}},ObjectField(t){const n=nt(e.getParentInputType());if(!e.getInputType()&&Ge(n)){const r=ve(t.name.value,Object.keys(n.getFields()));e.reportError(new h(`Field "${t.name.value}" is not defined by type "${n.name}".`+ce(r),{nodes:t}))}},NullValue(t){const n=e.getInputType();Je(n)&&e.reportError(new h(`Expected value of type "${ee(n)}", found ${we(t)}.`,{nodes:t}))},EnumValue:t=>ur(e,t),IntValue:t=>ur(e,t),FloatValue:t=>ur(e,t),StringValue:t=>ur(e,t),BooleanValue:t=>ur(e,t)}},function(e){return{...qn(e),Field:{leave(t){var n;const r=e.getFieldDef();if(!r)return!1;const i=new Set(null===(n=t.arguments)||void 0===n?void 0:n.map((e=>e.name.value)));for(const n of r.args)if(!i.has(n.name)&&ft(n)){const i=ee(n.type);e.reportError(new h(`Field "${r.name}" argument "${n.name}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:n,type:i,defaultValue:s}of r){const r=n.name.value,o=t[r];if(o&&i){const t=e.getSchema(),a=bn(t,o.type);if(a&&!lr(t,a,o.defaultValue,i,s)){const t=ee(a),s=ee(i);e.reportError(new h(`Variable "$${r}" of type "${t}" used in position expecting type "${s}".`,{nodes:[o,n]}))}}}}},VariableDefinition(e){t[e.variable.name.value]=e}}},function(e){const t=new Gn,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const s=[],[o,a]=Mn(e,t,r,i);if(function(e,t,n,r,i){for(const[s,o]of Object.entries(i))if(o.length>1)for(let i=0;i<o.length;i++)for(let a=i+1;a<o.length;a++){const c=Vn(e,n,r,!1,s,o[i],o[a]);c&&t.push(c)}}(e,s,t,n,o),0!==a.length)for(let r=0;r<a.length;r++){Ln(e,s,t,n,!1,o,a[r]);for(let i=r+1;i<a.length;i++)$n(e,s,t,n,!1,a[r],a[i])}return s}(e,n,t,e.getParentType(),r);for(const[[t,n],r,s]of i){const i=Fn(n);e.reportError(new h(`Fields "${t}" conflict because ${i}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:r.concat(s)}))}}}},function(e){const t=[];let n=Object.create(null);return{ObjectValue:{enter(){t.push(n),n=Object.create(null)},leave(){const e=t.pop();e||u(!1),n=e}},ObjectField(t){const r=t.name.value;n[r]?e.reportError(new h(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}]);class dr{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}get[Symbol.toStringTag](){return"ASTValidationContext"}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t;if(this._fragments)t=this._fragments;else{t=Object.create(null);for(const e of this.getDocument().definitions)e.kind===O.FRAGMENT_DEFINITION&&(t[e.name.value]=e);this._fragments=t}return t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];const n=[e];let r;for(;r=n.pop();)for(const e of r.selections)e.kind===O.FRAGMENT_SPREAD?t.push(e):e.selectionSet&&n.push(e.selectionSet);this._fragmentSpreads.set(e,t)}return t}getRecursivelyReferencedFragments(e){let t=this._recursivelyReferencedFragments.get(e);if(!t){t=[];const n=Object.create(null),r=[e.selectionSet];let i;for(;i=r.pop();)for(const e of this.getFragmentSpreads(i)){const i=e.name.value;if(!0!==n[i]){n[i]=!0;const e=this.getFragment(i);e&&(t.push(e),r.push(e.selectionSet))}}this._recursivelyReferencedFragments.set(e,t)}return t}}class fr extends dr{constructor(e,t,n,r){super(t,r),this._schema=e,this._typeInfo=n,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}get[Symbol.toStringTag](){return"ValidationContext"}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){const n=[],r=new On(this._schema);_e(e,Sn(r,{VariableDefinition:()=>!1,Variable(e){n.push({node:e,type:r.getInputType(),defaultValue:r.getDefaultValue()})}})),t=n,this._variableUsages.set(e,t)}return t}getRecursiveVariableUsages(e){let t=this._recursiveVariableUsages.get(e);if(!t){t=this.getVariableUsages(e);for(const n of this.getRecursivelyReferencedFragments(e))t=t.concat(this.getVariableUsages(n));this._recursiveVariableUsages.set(e,t)}return t}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}}function hr(e,t,n=pr,r,i=new On(e)){var s;const a=null!==(s=null==r?void 0:r.maxErrors)&&void 0!==s?s:100;t||o(!1,"Must provide document."),un(e);const c=Object.freeze({}),u=[],l=new fr(e,t,i,(e=>{if(u.length>=a)throw u.push(new h("Too many validation errors, error limit reached. Validation aborted.")),c;u.push(e)})),p=function(e){const t=new Array(e.length).fill(null),n=Object.create(null);for(const r of Object.values(O)){let i=!1;const s=new Array(e.length).fill(void 0),o=new Array(e.length).fill(void 0);for(let t=0;t<e.length;++t){const{enter:n,leave:a}=Se(e[t],r);i||(i=null!=n||null!=a),s[t]=n,o[t]=a}if(!i)continue;const a={enter(...n){const r=n[0];for(let o=0;o<e.length;o++)if(null===t[o]){var i;const a=null===(i=s[o])||void 0===i?void 0:i.apply(e[o],n);if(!1===a)t[o]=r;else if(a===Oe)t[o]=Oe;else if(void 0!==a)return a}},leave(...n){const r=n[0];for(let s=0;s<e.length;s++)if(null===t[s]){var i;const r=null===(i=o[s])||void 0===i?void 0:i.apply(e[s],n);if(r===Oe)t[s]=Oe;else if(void 0!==r&&!1!==r)return r}else t[s]===r&&(t[s]=null)}};n[r]=a}return n}(n.map((e=>e(l))));try{_e(t,Sn(i,p))}catch(e){if(e!==c)throw e}return u}class mr extends Error{constructor(e){super("Unexpected error value: "+ee(e)),this.name="NonErrorThrown",this.thrownValue=e}}function yr(e,t,n){var r;const i=(s=e)instanceof Error?s:new mr(s);var s,o;return o=i,Array.isArray(o.path)?i:new h(i.message,{nodes:null!==(r=i.nodes)&&void 0!==r?r:t,source:i.source,positions:i.positions,path:n,originalError:i})}const vr=function(e){let t;return function(n,r,i){void 0===t&&(t=new WeakMap);let s=t.get(n);void 0===s&&(s=new WeakMap,t.set(n,s));let o=s.get(r);void 0===o&&(o=new WeakMap,s.set(r,o));let a=o.get(i);return void 0===a&&(a=e(n,r,i),o.set(i,a)),a}}(((e,t,n)=>function(e,t,n,r,i){const s=new Map,o=new Set;for(const a of i)a.selectionSet&&sr(e,t,n,r,a.selectionSet,s,o);return s}(e.schema,e.fragments,e.variableValues,t,n)));function Tr(e){arguments.length<2||o(!1,"graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.");const{schema:t,document:n,variableValues:r,rootValue:i}=e;!function(e,t,n){t||o(!1,"Must provide document."),un(e),null==n||c(n)||o(!1,"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.")}(t,n,r);const s=function(e){var t,n;const{schema:r,document:i,rootValue:s,contextValue:o,variableValues:a,operationName:c,fieldResolver:u,typeResolver:l,subscribeFieldResolver:p}=e;let d;const f=Object.create(null);for(const e of i.definitions)switch(e.kind){case O.OPERATION_DEFINITION:if(null==c){if(void 0!==d)return[new h("Must provide operation name if query contains multiple operations.")];d=e}else(null===(t=e.name)||void 0===t?void 0:t.value)===c&&(d=e);break;case O.FRAGMENT_DEFINITION:f[e.name.value]=e}if(!d)return null!=c?[new h(`Unknown operation named "${c}".`)]:[new h("Must provide an operation.")];const m=null!==(n=d.variableDefinitions)&&void 0!==n?n:[],y=er(r,m,null!=a?a:{},{maxErrors:50});if(y.errors)return y.errors;return{schema:r,fragments:f,rootValue:s,contextValue:o,operation:d,variableValues:y.coerced,fieldResolver:null!=u?u:Ar,typeResolver:null!=l?l:wr,subscribeFieldResolver:null!=p?p:Ar,errors:[]}}(e);if(!("schema"in s))return{errors:s};try{const{operation:e}=s,t=function(e,t,n){const r=e.schema.getRootType(t.operation);if(null==r)throw new h(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});const i=ir(e.schema,e.fragments,e.variableValues,r,t.selectionSet),s=void 0;switch(t.operation){case I.QUERY:return gr(e,r,n,s,i);case I.MUTATION:return function(e,t,n,r,i){return function(e,t,n){let r=n;for(const n of e)r=a(r)?r.then((e=>t(e,n))):t(r,n);return r}(i.entries(),((i,[s,o])=>{const c=Qn(r,s,t.name),u=Nr(e,t,n,o,c);return void 0===u?i:a(u)?u.then((e=>(i[s]=e,i))):(i[s]=u,i)}),Object.create(null))}(e,r,n,s,i);case I.SUBSCRIPTION:return gr(e,r,n,s,i)}}(s,e,i);return a(t)?t.then((e=>Er(e,s.errors)),(e=>(s.errors.push(e),Er(null,s.errors)))):Er(t,s.errors)}catch(e){return s.errors.push(e),Er(null,s.errors)}}function Er(e,t){return 0===t.length?{data:e}:{errors:t,data:e}}function gr(e,t,n,r,i){const s=Object.create(null);let o=!1;for(const[c,u]of i.entries()){const i=Nr(e,t,n,u,Qn(r,c,t.name));void 0!==i&&(s[c]=i,a(i)&&(o=!0))}return o?(c=s,Promise.all(Object.values(c)).then((e=>{const t=Object.create(null);for(const[n,r]of Object.keys(c).entries())t[r]=e[n];return t}))):s;var c}function Nr(e,t,n,r,i){var s;const o=function(e,t,n){const r=n.name.value;if(r===Zt.name&&e.getQueryType()===t)return Zt;if(r===en.name&&e.getQueryType()===t)return en;if(r===tn.name)return tn;return t.getFields()[r]}(e.schema,t,r[0]);if(!o)return;const c=o.type,u=null!==(s=o.resolve)&&void 0!==s?s:e.fieldResolver,l=function(e,t,n,r,i){return{fieldName:t.name,fieldNodes:n,returnType:t.type,parentType:r,path:i,schema:e.schema,fragments:e.fragments,rootValue:e.rootValue,operation:e.operation,variableValues:e.variableValues}}(e,o,r,t,i);try{const t=tr(o,r[0],e.variableValues),s=u(n,t,e.contextValue,l);let p;return p=a(s)?s.then((t=>br(e,c,r,l,i,t))):br(e,c,r,l,i,s),a(p)?p.then(void 0,(t=>Ir(yr(t,r,Kn(i)),c,e))):p}catch(t){return Ir(yr(t,r,Kn(i)),c,e)}}function Ir(e,t,n){if(Je(t))throw e;return n.errors.push(e),null}function br(e,t,n,r,i,s){if(s instanceof Error)throw s;if(Je(t)){const o=br(e,t.ofType,n,r,i,s);if(null===o)throw new Error(`Cannot return null for non-nullable field ${r.parentType.name}.${r.fieldName}.`);return o}return null==s?null:qe(t)?function(e,t,n,r,i,s){if(!Pt(s))throw new h(`Expected Iterable, but did not find one for field "${r.parentType.name}.${r.fieldName}".`);const o=t.ofType;let c=!1;const u=Array.from(s,((t,s)=>{const u=Qn(i,s,void 0);try{let i;return i=a(t)?t.then((t=>br(e,o,n,r,u,t))):br(e,o,n,r,u,t),a(i)?(c=!0,i.then(void 0,(t=>Ir(yr(t,n,Kn(u)),o,e)))):i}catch(t){return Ir(yr(t,n,Kn(u)),o,e)}}));return c?Promise.all(u):u}(e,t,n,r,i,s):Ke(t)?function(e,t){const n=e.serialize(t);if(null==n)throw new Error(`Expected \`${ee(e)}.serialize(${ee(t)})\` to return non-nullable value, returned: ${ee(n)}`);return n}(t,s):Xe(t)?function(e,t,n,r,i,s){var o;const c=null!==(o=t.resolveType)&&void 0!==o?o:e.typeResolver,u=e.contextValue,l=c(s,u,r,t);if(a(l))return l.then((o=>_r(e,Or(o,e,t,n,r,s),n,r,i,s)));return _r(e,Or(l,e,t,n,r,s),n,r,i,s)}(e,t,n,r,i,s):je(t)?_r(e,t,n,r,i,s):void u(!1,"Cannot complete value of unexpected output type: "+ee(t))}function Or(e,t,n,r,i,s){if(null==e)throw new h(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}". Either the "${n.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,r);if(je(e))throw new h("Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.");if("string"!=typeof e)throw new h(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${ee(s)}, received "${ee(e)}".`);const o=t.schema.getType(e);if(null==o)throw new h(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!je(o))throw new h(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw new h(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function _r(e,t,n,r,i,s){const o=vr(e,t,n);if(t.isTypeOf){const c=t.isTypeOf(s,e.contextValue,r);if(a(c))return c.then((r=>{if(!r)throw Sr(t,s,n);return gr(e,t,s,i,o)}));if(!c)throw Sr(t,s,n)}return gr(e,t,s,i,o)}function Sr(e,t,n){return new h(`Expected value of type "${e.name}" but got: ${ee(t)}.`,{nodes:n})}const wr=function(e,t,n,r){if(c(e)&&"string"==typeof e.__typename)return e.__typename;const i=n.schema.getPossibleTypes(r),s=[];for(let r=0;r<i.length;r++){const o=i[r];if(o.isTypeOf){const i=o.isTypeOf(e,t,n);if(a(i))s[r]=i;else if(i)return o.name}}return s.length?Promise.all(s).then((e=>{for(let t=0;t<e.length;t++)if(e[t])return i[t].name})):void 0},Ar=function(e,t,n,r){if(c(e)||"function"==typeof e){const i=e[r.fieldName];return"function"==typeof i?e[r.fieldName](t,n,r):i}};const Dr={base64Binary:Dt,boolean:xt,canonical:Dt,code:Dt,date:Dt,dateTime:Dt,decimal:At,id:Rt,instant:Dt,integer:At,markdown:Dt,number:At,positiveInt:At,string:Dt,time:Dt,unsignedInt:At,uri:Dt,url:Dt,xhtml:Dt,"http://hl7.org/fhirpath/System.Boolean":xt,"http://hl7.org/fhirpath/System.Date":Dt,"http://hl7.org/fhirpath/System.DateTime":Dt,"http://hl7.org/fhirpath/System.Decimal":At,"http://hl7.org/fhirpath/System.Integer":At,"http://hl7.org/fhirpath/System.String":Dt,"http://hl7.org/fhirpath/System.Time":Dt},xr=new t.LRUCache;let Rr;async function kr(e,r){const{query:i,operationName:s,variables:o}=e.body;if(!i)return[t.badRequest("Must provide query.")];let a;try{a=new ie(i,c).parseDocument()}catch(e){return[t.badRequest("GraphQL syntax error.")]}var c;const u=function(){Rr||(Rr=function(){for(const e of t.getResourceTypes())Dr[e]=Lr(e);const e={};for(const n of t.getResourceTypes()){const t=Fr(n);e[n]={type:t,args:{id:{type:new We(Rt),description:n+" ID"}},resolve:Mr},e[n+"List"]={type:new He(t),args:Vr(n),resolve:jr}}return new on({query:new ot({name:"QueryType",fields:e})})}());return Rr}(),l=hr(u,a,[...pr,Yr]);if(l.length>0)return[(p=l,{resourceType:"OperationOutcome",issue:p.map((e=>({severity:"error",code:"invalid",details:{text:e.message}})))})];var p;const d=function(e){return e.includes("query IntrospectionQuery")||e.includes("__schema")||e.includes("__type")}(i);if(d)return[t.forbidden];const f=new n((e=>r.readReferences(e)));let h=d&&xr.get(i);return h||(h=await Tr({schema:u,document:a,contextValue:{repo:r,dataLoader:f},operationName:s,variableValues:o})),[t.allOk,h]}function Fr(e){let t=Dr[e];return t||(t=Lr(e),Dr[e]=t),t}function Lr(e){if("ResourceList"===e)return new mt({name:"ResourceList",types:()=>t.getResourceTypes().map(Fr).filter((e=>!!e)),resolveType:Br});const n=t.getResourceTypeSchema(e);return new ot({name:e,description:n.description,fields:()=>function(e){const n={};return function(e,n){const r=t.getResourceTypeSchema(e),i=r.properties;t.isResourceTypeSchema(r)&&(n.resourceType={type:new We(Dt),description:"Resource Type"});"Reference"===e&&(n.resource={description:"Reference",type:Fr("ResourceList"),resolve:Pr});for(const r of Object.keys(i)){const i=t.getElementDefinition(e,r);for(const e of i.type)$r(n,r,i,e)}}(e,n),function(e,n){for(const r of t.getResourceTypes()){const i=Fr(r),s=t.getSearchParameters(r),o={};let a=0;if(s)for(const[t,n]of Object.entries(s))n.target&&n.target.includes(e)&&(o[qr(t)]={value:t},a++);if(a>0){const t=new vt({name:e+"_"+r+"_reference",values:o}),s=Vr(r);s._reference={type:new We(t),description:`Specify which property to use for reverse lookup for ${r}`},n[r+"List"]={type:new He(i),args:s,resolve:jr}}}}(e,n),n}(e)})}function $r(e,n,r,i){let s=i.code;"Element"!==s&&"BackboneElement"!==s||(s=t.buildTypeName(r.path?.split(".")));const o={description:r.short,type:Ur(r,s),resolve:Gr};"*"===r.max&&(o.args=function(e){const n={_count:{type:wt,description:"Specify how many elements to return from a repeating list."},_offset:{type:wt,description:"Specify the offset to start at for a repeating element."}};if(!t.isLowerCase(e.charAt(0))){n.fhirpath={type:Dt,description:"A FHIRPath statement selecting which of the subnodes is to be included"};const r=t.globalSchema.types[e];if(r.properties)for(const i of Object.keys(r.properties)){const r=t.getElementDefinition(e,i);for(const e of r.type)Cr(n,i,r,e)}}return n}(s));e[n.replace("[x]",t.capitalize(i.code))]=o}function Cr(e,n,r,i){const s=i.code,o=n.replace("[x]",t.capitalize(s));switch(s){case"canonical":case"code":case"id":case"oid":case"string":case"uri":case"url":case"uuid":case"http://hl7.org/fhirpath/System.String":e[o]={type:Dt,description:r.short}}}function Vr(e){const n={_count:{type:wt,description:"Specify how many elements to return from a repeating list."},_offset:{type:wt,description:"Specify the offset to start at for a repeating element."},_sort:{type:Dt,description:"Specify the sort order by comma-separated list of sort rules in priority order."},_id:{type:Dt,description:"Select resources based on the logical id of the resource."},_lastUpdated:{type:Dt,description:"Select resources based on the last time they were changed."}},r=t.getSearchParameters(e);if(r)for(const[e,t]of Object.entries(r))n[qr(e)]={type:Dt,description:t.description};return n}function Ur(e,t){const n=Fr(t);return"*"===e.max?new He(n):n}async function jr(e,n,r,i){const s=i.fieldName,o=function(e,n,r){let i;if(n){const e=r._reference;delete r._reference,i={code:e,operator:t.Operator.EQUALS,value:t.getReferenceString(n)}}r=Object.fromEntries(Object.entries(r).map((([e,t])=>[Jr(e),t])));const s=t.parseSearchRequest(e,r);if(i){const e=s.filters||[];s.filters=[i,...e]}return s}(s.substring(0,s.length-4),e,n),a=await r.repo.search(o);return a.entry?.map((e=>e.resource))}async function Mr(e,n,r,i){try{return await r.dataLoader.load({reference:`${i.fieldName}/${n.id}`})}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e),e)}}async function Pr(e,n,r){try{return await r.dataLoader.load(e)}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e),e)}}function Br(e){const t=e?.resourceType;if(t)return Fr(t).name}async function Gr(e,n,r,i){const s=e?.[i.fieldName];if(!n||!s)return s;const{_offset:o,_count:a,fhirpath:c,...u}=n;let l=s;for(const[e,t]of Object.entries(u))l=l.filter((n=>n[e]===t));return c&&(l=l.filter((e=>t.toJsBoolean(t.evalFhirPathTyped(c,[t.toTypedValue(e)]))))),o&&(l=l.slice(o)),a&&(l=l.slice(0,a)),l}function qr(e){return e.replaceAll("-","_")}function Jr(e){return e.startsWith("_")?e:e.replaceAll("_","-")}const Yr=e=>({Field(t,n,r,i){const s=function(e){return e.filter((e=>"selections"===e)).length}(i);if(s>12){const n=t.name.value;e.reportError(new h(`Field "${n}" exceeds max depth (depth=${s}, max=12)`,{nodes:t}))}}});class Qr{constructor(){this.routes=[]}add(e,t,n){const r=t.split("/").filter((e=>!!e)).map((e=>e.startsWith(":")?{value:e.substring(1),param:!0}:{value:e}));this.routes.push({method:e,path:r,handler:n})}find(e,t){const n=t.split("/").filter((e=>!!e));let r,i=-1;for(const t of this.routes){const s=Kr(t,e,n);s>i&&(r=t,i=s)}if(r)return{handler:r.handler,params:zr(r,n)}}}function Kr(e,t,n){if(t!==e.method||n.length!==e.path.length)return-1;let r=0;for(let t=0;t<n.length;t++)if(!e.path[t].param){if(n[t]!==e.path[t].value)return-1;r++}return r}function zr(e,t){const n=Object.create(null);for(let r=0;r<t.length;r++)e.path[r].param&&(n[e.path[r].value]=t[r]);return n}async function Xr(e,n,r){const s=e.body;if("Bundle"!==s.resourceType)return[t.badRequest("Not a bundle")];const o=await async function(e,t,n){return new i(e,t,n).processBatch()}(r,n,s);return[t.allOk,o]}async function Hr(e,n){const{resourceType:r}=e.params,i=e.query,s=await n.search(t.parseSearchRequest(r,i));return[t.allOk,s]}async function Wr(e,n){const{resourceType:r}=e.params,i=e.body,s=await n.search(t.parseSearchRequest(r,i));return[t.allOk,s]}async function Zr(e,n){const{resourceType:r}=e.params,i=e.body;if(i.resourceType!==r)return[t.badRequest("Incorrect resource type")];const s=await n.createResource(i);return[t.created,s]}async function ei(e,n){const{resourceType:r,id:i}=e.params,s=await n.readResource(r,i);return[t.allOk,s]}async function ti(e,n){const{resourceType:r,id:i}=e.params,s=await n.readHistory(r,i);return[t.allOk,s]}async function ni(e,n){const{resourceType:r,id:i,vid:s}=e.params,o=await n.readVersion(r,i,s);return[t.allOk,o]}async function ri(e,n){const{resourceType:r,id:i}=e.params,s=e.body;if(s.resourceType!==r)return[t.badRequest("Incorrect resource type")];if(s.id!==i)return[t.badRequest("Incorrect ID")];const o=await n.updateResource(s);return[t.allOk,o]}async function ii(e,n){const{resourceType:r,id:i}=e.params;return await n.deleteResource(r,i),[t.allOk]}async function si(e,n){const{resourceType:r,id:i}=e.params,s=e.body,o=await n.patchResource(r,i,s);return[t.allOk,o]}class oi{async searchOne(e){const t=await this.search({...e,count:1});return t.entry?.[0]?.resource}async searchResources(e){const t=await this.search(e);return t.entry?.map((e=>e.resource))||[]}}const ai=(e,n,r)=>{const i=t.globalSchema.types[e.resourceType]?.searchParams?.[r.code],s=i?.expression;if(!s)return 0;const o=JSON.stringify(t.evalFhirPath(s,e)),a=JSON.stringify(t.evalFhirPath(s,n));return o.localeCompare(a)*(r.descending?-1:1)},ci=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));e.BaseRepository=oi,e.FhirRouter=class{constructor(){this.router=new Qr,this.router.add("POST","",Xr),this.router.add("GET",":resourceType",Hr),this.router.add("POST",":resourceType/_search",Wr),this.router.add("POST",":resourceType",Zr),this.router.add("GET",":resourceType/:id",ei),this.router.add("GET",":resourceType/:id/_history",ti),this.router.add("GET",":resourceType/:id/_history/:vid",ni),this.router.add("PUT",":resourceType/:id",ri),this.router.add("DELETE",":resourceType/:id",ii),this.router.add("PATCH",":resourceType/:id",si),this.router.add("POST","$graphql",kr)}async handleRequest(e,n){const r=this.router.find(e.method,e.pathname);if(!r)return[t.notFound];const{handler:i,params:s}=r;return e.params=s,i(e,n,this)}},e.MemoryRepository=class extends oi{constructor(){super(),this.resources=new Map,this.history=new Map}async createResource(e){const n=t.deepClone(e);n.id||(n.id=ci()),n.meta||(n.meta={}),n.meta?.versionId||(n.meta.versionId=ci()),n.meta?.lastUpdated||(n.meta.lastUpdated=(new Date).toISOString());const{resourceType:r,id:i}=n;let s=this.resources.get(r);s||(s=new Map,this.resources.set(r,s)),s.set(i,n);let o=this.history.get(r);o||(o=new Map,this.history.set(r,o));let a=o.get(i);return a||(a=[],o.set(i,a)),a.push(n),t.deepClone(n)}updateResource(e){const n=t.deepClone(e);return n.meta&&(n.meta.versionId&&delete n.meta.versionId,n.meta.lastUpdated&&delete n.meta.lastUpdated),this.createResource(n)}async patchResource(e,n,i){const s=await this.readResource(e,n);try{const e=r.applyPatch(s,i).filter(Boolean);if(e.length>0)throw new t.OperationOutcomeError(t.badRequest(e.map((e=>e.message)).join("\n")))}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e))}return this.updateResource(s)}async readResource(e,n){const r=this.resources.get(e)?.get(n);if(!r)throw new t.OperationOutcomeError(t.notFound);return t.deepClone(r)}async readReference(e){const n=e.reference?.split("/");if(!n||2!==n.length)throw new t.OperationOutcomeError(t.badRequest("Invalid reference"));return this.readResource(n[0],n[1])}async readReferences(e){return Promise.all(e.map((e=>this.readReference(e))))}async readHistory(e,n){return await this.readResource(e,n),{resourceType:"Bundle",type:"history",entry:(this.history.get(e)?.get(n)||[]).reverse().map((e=>({resource:t.deepClone(e)})))}}async readVersion(e,n,r){await this.readResource(e,n);const i=this.history.get(e)?.get(n)?.find((e=>e.meta?.versionId===r));if(!i)throw new t.OperationOutcomeError(t.notFound);return t.deepClone(i)}async search(e){const{resourceType:n}=e,r=this.resources.get(n)||new Map,i=[];for(const n of r.values())t.matchesSearchRequest(n,e)&&i.push(n);let s=i.map((e=>({resource:t.deepClone(e)})));if(e.sortRules)for(const t of e.sortRules)s=s.sort(((e,n)=>ai(e.resource,n.resource,t)));return void 0!==e.offset&&(s=s.slice(e.offset)),void 0!==e.count&&(s=s.slice(0,e.count)),{resourceType:"Bundle",type:"searchset",entry:s,total:i.length}}async deleteResource(e,n){if(!this.resources.get(e)?.get(n))throw new t.OperationOutcomeError(t.notFound);this.resources.get(e)?.delete(n)}},e.Router=Qr}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@medplum/core"),require("dataloader"),require("rfc6902")):"function"==typeof define&&define.amd?define(["exports","@medplum/core","dataloader","rfc6902"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).medplum=e.medplum||{},e.medplum.fhirRouter={}),e.medplum.core,e.dataloader,e.rfc6902)}(this,(function(e,t,n,r){"use strict";class i{constructor(e,t,n){this.router=e,this.repo=t,this.bundle=n,this.ids={}}async processBatch(){const e=this.bundle.type;if(!e)throw new t.OperationOutcomeError(t.badRequest("Missing bundle type"));if("batch"!==e&&"transaction"!==e)throw new t.OperationOutcomeError(t.badRequest("Unrecognized bundle type"));const n=this.bundle.entry;if(!n)throw new t.OperationOutcomeError(t.badRequest("Missing bundle entry"));const r=[];for(const e of n){const n=this.rewriteIdsInObject(e);e?.resource?.id&&(n.resource.id=this.rewriteIdsInString(e.resource.id,!0));try{r.push(await this.processBatchEntry(n))}catch(e){r.push(s(t.normalizeOperationOutcome(e)))}}return{resourceType:"Bundle",type:e+"-response",entry:r}}async processBatchEntry(e){this.validateEntry(e);const n=e.request;if(e.resource?.resourceType&&n.ifNoneExist){const r=`https://example.com/${e.resource.resourceType}`,i=new URL("?"+n.ifNoneExist,r),o=await this.repo.search(t.parseSearchUrl(i)),a=o?.entry;if(a.length>1)return s(t.badRequest("Multiple matches"));if(1===a.length){const n=a[0].resource;return e.fullUrl&&this.addReplacementId(e.fullUrl,n),s(t.allOk,n)}}let r=e.resource;"PATCH"===n.method&&(r=this.parsePatchBody(e));const i=new URL(n.url,"https://example.com/"),o=await this.router.handleRequest({method:n.method,pathname:i.pathname,params:Object.create(null),query:Object.fromEntries(i.searchParams),body:r},this.repo);return e.fullUrl&&2===o.length&&this.addReplacementId(e.fullUrl,o[1]),s(o[0],o[1])}validateEntry(e){if(!e.request)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request"));if(!e.request.method)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request.method"));if(!e.request.url)throw new t.OperationOutcomeError(t.badRequest("Missing entry.request.url"))}parsePatchBody(e){const n=e.resource;if(!n)throw new t.OperationOutcomeError(t.badRequest("Missing entry.resource"));if("Binary"!==n.resourceType)throw new t.OperationOutcomeError(t.badRequest("Patch resource must be a Binary"));if(!n.data)throw new t.OperationOutcomeError(t.badRequest("Missing entry.resource.data"));return JSON.parse(Buffer.from(n.data,"base64").toString("utf8"))}addReplacementId(e,t){e?.startsWith("urn:uuid:")&&(this.ids[e]=t)}rewriteIds(e){return Array.isArray(e)?this.rewriteIdsInArray(e):"string"==typeof e?this.rewriteIdsInString(e):"object"==typeof e?this.rewriteIdsInObject(e):e}rewriteIdsInArray(e){return e.map((e=>this.rewriteIds(e)))}rewriteIdsInObject(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,this.rewriteIds(t)])))}rewriteIdsInString(e,n=!1){const r=e.match(/urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);if(r){const i=r[0],s=this.ids[i];if(s){let r=t.getReferenceString(s);return n&&(r=t.resolveId({reference:r})),r?e.replaceAll(i,r):e}}return e}}function s(e,n){return{response:{outcome:e,status:t.getStatus(e).toString(),location:t.isOk(e)&&n?.id?t.getReferenceString(n):void 0},resource:n}}function o(e,t){if(!Boolean(e))throw new Error(t)}function a(e){return"function"==typeof(null==e?void 0:e.then)}function c(e){return"object"==typeof e&&null!==e}function u(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}const l=/\r\n|[\n\r]/g;function p(e,t){let n=0,r=1;for(const i of e.body.matchAll(l)){if("number"==typeof i.index||u(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function d(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,i=t.line-1,s=e.locationOffset.line-1,o=t.line+s,a=1===t.line?n:0,c=t.column+a,u=`${e.name}:${o}:${c}\n`,l=r.split(/\r\n|[\n\r]/g),p=l[i];if(p.length>120){const e=Math.floor(c/80),t=c%80,n=[];for(let e=0;e<p.length;e+=80)n.push(p.slice(e,e+80));return u+f([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return u+f([[o-1+" |",l[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,l[i+1]]])}function f(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>e.padStart(n)+(t?" "+t:""))).join("\n")}class h extends Error{constructor(e,...t){var n,r,i;const{nodes:s,source:o,positions:a,path:u,originalError:l,extensions:d}=function(e){const t=e[0];return null==t||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}(t);super(e),this.name="GraphQLError",this.path=null!=u?u:void 0,this.originalError=null!=l?l:void 0,this.nodes=m(Array.isArray(s)?s:s?[s]:void 0);const f=m(null===(n=this.nodes)||void 0===n?void 0:n.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=o?o:null==f||null===(r=f[0])||void 0===r?void 0:r.source,this.positions=null!=a?a:null==f?void 0:f.map((e=>e.start)),this.locations=a&&o?a.map((e=>p(o,e))):null==f?void 0:f.map((e=>p(e.source,e.start)));const y=c(null==l?void 0:l.extensions)?null==l?void 0:l.extensions:void 0;this.extensions=null!==(i=null!=d?d:y)&&void 0!==i?i: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}}),null!=l&&l.stack?Object.defineProperty(this,"stack",{value:l.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,h):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(e+="\n\n"+d((t=n.loc).source,p(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+d(this.source,t);var t;return e}toJSON(){const e={message:this.message};return null!=this.locations&&(e.locations=this.locations),null!=this.path&&(e.path=this.path),null!=this.extensions&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function m(e){return void 0===e||0===e.length?void 0:e}function y(e,t,n){return new h(`Syntax Error: ${n}`,{source:e,positions:[t]})}class v{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class T{constructor(e,t,n,r,i,s){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=s,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 E={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"]},g=new Set(Object.keys(E));function N(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&g.has(t)}var I,b,O,_;function S(e){return 9===e||32===e}function w(e){return e>=48&&e<=57}function A(e){return e>=97&&e<=122||e>=65&&e<=90}function D(e){return A(e)||95===e}function x(e){return A(e)||w(e)||95===e}function R(e){var t;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let t=0;t<e.length;++t){var s;const o=e[t],a=k(o);a!==o.length&&(r=null!==(s=r)&&void 0!==s?s:t,i=t,0!==t&&a<n&&(n=a))}return e.map(((e,t)=>0===t?e:e.slice(n))).slice(null!==(t=r)&&void 0!==t?t:0,i+1)}function k(e){let t=0;for(;t<e.length&&S(e.charCodeAt(t));)++t;return t}!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(I||(I={})),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"}(b||(b={})),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"}(O||(O={})),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"}(_||(_={}));class F{constructor(e){const t=new T(_.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){this.lastToken=this.token;return this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==_.EOF)do{if(e.next)e=e.next;else{const t=M(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===_.COMMENT);return e}}function L(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function $(e,t){return C(e.charCodeAt(t))&&V(e.charCodeAt(t+1))}function C(e){return e>=55296&&e<=56319}function V(e){return e>=56320&&e<=57343}function U(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return _.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function j(e,t,n,r,i){const s=e.line,o=1+n-e.lineStart;return new T(t,n,r,s,o,i)}function M(e,t){const n=e.source.body,r=n.length;let i=t;for(;i<r;){const t=n.charCodeAt(i);switch(t){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++e.line,e.lineStart=i;continue;case 13:10===n.charCodeAt(i+1)?i+=2:++i,++e.line,e.lineStart=i;continue;case 35:return P(e,i);case 33:return j(e,_.BANG,i,i+1);case 36:return j(e,_.DOLLAR,i,i+1);case 38:return j(e,_.AMP,i,i+1);case 40:return j(e,_.PAREN_L,i,i+1);case 41:return j(e,_.PAREN_R,i,i+1);case 46:if(46===n.charCodeAt(i+1)&&46===n.charCodeAt(i+2))return j(e,_.SPREAD,i,i+3);break;case 58:return j(e,_.COLON,i,i+1);case 61:return j(e,_.EQUALS,i,i+1);case 64:return j(e,_.AT,i,i+1);case 91:return j(e,_.BRACKET_L,i,i+1);case 93:return j(e,_.BRACKET_R,i,i+1);case 123:return j(e,_.BRACE_L,i,i+1);case 124:return j(e,_.PIPE,i,i+1);case 125:return j(e,_.BRACE_R,i,i+1);case 34:return 34===n.charCodeAt(i+1)&&34===n.charCodeAt(i+2)?X(e,i):q(e,i)}if(w(t)||45===t)return B(e,i,t);if(D(t))return H(e,i);throw y(e.source,i,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":L(t)||$(n,i)?`Unexpected character: ${U(e,i)}.`:`Invalid character: ${U(e,i)}.`)}return j(e,_.EOF,r,r)}function P(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){const e=n.charCodeAt(i);if(10===e||13===e)break;if(L(e))++i;else{if(!$(n,i))break;i+=2}}return j(e,_.COMMENT,t,i,n.slice(t+1,i))}function B(e,t,n){const r=e.source.body;let i=t,s=n,o=!1;if(45===s&&(s=r.charCodeAt(++i)),48===s){if(s=r.charCodeAt(++i),w(s))throw y(e.source,i,`Invalid number, unexpected digit after 0: ${U(e,i)}.`)}else i=G(e,i,s),s=r.charCodeAt(i);if(46===s&&(o=!0,s=r.charCodeAt(++i),i=G(e,i,s),s=r.charCodeAt(i)),69!==s&&101!==s||(o=!0,s=r.charCodeAt(++i),43!==s&&45!==s||(s=r.charCodeAt(++i)),i=G(e,i,s),s=r.charCodeAt(i)),46===s||D(s))throw y(e.source,i,`Invalid number, expected digit but got: ${U(e,i)}.`);return j(e,o?_.FLOAT:_.INT,t,i,r.slice(t,i))}function G(e,t,n){if(!w(n))throw y(e.source,t,`Invalid number, expected digit but got: ${U(e,t)}.`);const r=e.source.body;let i=t+1;for(;w(r.charCodeAt(i));)++i;return i}function q(e,t){const n=e.source.body,r=n.length;let i=t+1,s=i,o="";for(;i<r;){const r=n.charCodeAt(i);if(34===r)return o+=n.slice(s,i),j(e,_.STRING,t,i+1,o);if(92!==r){if(10===r||13===r)break;if(L(r))++i;else{if(!$(n,i))throw y(e.source,i,`Invalid character within String: ${U(e,i)}.`);i+=2}}else{o+=n.slice(s,i);const t=117===n.charCodeAt(i+1)?123===n.charCodeAt(i+2)?J(e,i):Y(e,i):z(e,i);o+=t.value,i+=t.size,s=i}}throw y(e.source,i,"Unterminated string.")}function J(e,t){const n=e.source.body;let r=0,i=3;for(;i<12;){const e=n.charCodeAt(t+i++);if(125===e){if(i<5||!L(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|K(e),r<0)break}throw y(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function Y(e,t){const n=e.source.body,r=Q(n,t+2);if(L(r))return{value:String.fromCodePoint(r),size:6};if(C(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=Q(n,t+8);if(V(e))return{value:String.fromCodePoint(r,e),size:12}}throw y(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function Q(e,t){return K(e.charCodeAt(t))<<12|K(e.charCodeAt(t+1))<<8|K(e.charCodeAt(t+2))<<4|K(e.charCodeAt(t+3))}function K(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function z(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:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw y(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function X(e,t){const n=e.source.body,r=n.length;let i=e.lineStart,s=t+3,o=s,a="";const c=[];for(;s<r;){const r=n.charCodeAt(s);if(34===r&&34===n.charCodeAt(s+1)&&34===n.charCodeAt(s+2)){a+=n.slice(o,s),c.push(a);const r=j(e,_.BLOCK_STRING,t,s+3,R(c).join("\n"));return e.line+=c.length-1,e.lineStart=i,r}if(92!==r||34!==n.charCodeAt(s+1)||34!==n.charCodeAt(s+2)||34!==n.charCodeAt(s+3))if(10!==r&&13!==r)if(L(r))++s;else{if(!$(n,s))throw y(e.source,s,`Invalid character within String: ${U(e,s)}.`);s+=2}else a+=n.slice(o,s),c.push(a),13===r&&10===n.charCodeAt(s+1)?s+=2:++s,a="",o=s,i=s;else a+=n.slice(o,s),o=s+1,s+=4}throw y(e.source,s,"Unterminated string.")}function H(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){if(!x(n.charCodeAt(i)))break;++i}return j(e,_.NAME,t,i,n.slice(t,i))}const W=10,Z=2;function ee(e){return te(e,[])}function te(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const n=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:te(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>Z)return"[Array]";const n=Math.min(W,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(te(e[r],t));1===r?i.push("... 1 more item"):r>1&&i.push(`... ${r} more items`);return"["+i.join(", ")+"]"}(e,n);return function(e,t){const n=Object.entries(e);if(0===n.length)return"{}";if(t.length>Z)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const r=n.map((([e,n])=>e+": "+te(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const ne="production"===process.env.NODE_ENV?function(e,t){return e instanceof t}:function(e,t){if(e instanceof t)return!0;if("object"==typeof e&&null!==e){var n;const r=t.prototype[Symbol.toStringTag];if(r===(Symbol.toStringTag in e?e[Symbol.toStringTag]:null===(n=e.constructor)||void 0===n?void 0:n.name)){const t=ee(e);throw new Error(`Cannot use ${r} "${t}" from another module or realm.\n\nEnsure that there is only one instance of "graphql" in the node_modules\ndirectory. If different versions of "graphql" are the dependencies of other\nrelied on modules, use "resolutions" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate "graphql" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.`)}}return!1};class re{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||o(!1,`Body must be a string. Received: ${ee(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||o(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||o(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}class ie{constructor(e,t={}){const n=function(e){return ne(e,re)}(e)?e:new re(e);this._lexer=new F(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(_.NAME);return this.node(e,{kind:O.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:O.DOCUMENT,definitions:this.many(_.SOF,this.parseDefinition,_.EOF)})}parseDefinition(){if(this.peek(_.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===_.NAME){switch(t.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(e)throw y(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(t.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(_.BRACE_L))return this.node(e,{kind:O.OPERATION_DEFINITION,operation:I.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(_.NAME)&&(n=this.parseName()),this.node(e,{kind:O.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(_.NAME);switch(e.value){case"query":return I.QUERY;case"mutation":return I.MUTATION;case"subscription":return I.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(_.PAREN_L,this.parseVariableDefinition,_.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:O.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(_.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(_.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(_.DOLLAR),this.node(e,{kind:O.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:O.SELECTION_SET,selections:this.many(_.BRACE_L,this.parseSelection,_.BRACE_R)})}parseSelection(){return this.peek(_.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(_.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:O.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(_.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(_.PAREN_L,t,_.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(_.COLON),this.node(t,{kind:O.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(_.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(_.NAME)?this.node(e,{kind:O.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:O.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),!0===this._options.allowLegacyFragmentVariables?this.node(e,{kind:O.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(e,{kind:O.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case _.BRACKET_L:return this.parseList(e);case _.BRACE_L:return this.parseObject(e);case _.INT:return this.advanceLexer(),this.node(t,{kind:O.INT,value:t.value});case _.FLOAT:return this.advanceLexer(),this.node(t,{kind:O.FLOAT,value:t.value});case _.STRING:case _.BLOCK_STRING:return this.parseStringLiteral();case _.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:O.BOOLEAN,value:!0});case"false":return this.node(t,{kind:O.BOOLEAN,value:!1});case"null":return this.node(t,{kind:O.NULL});default:return this.node(t,{kind:O.ENUM,value:t.value})}case _.DOLLAR:if(e){if(this.expectToken(_.DOLLAR),this._lexer.token.kind===_.NAME){const e=this._lexer.token.value;throw y(this._lexer.source,t.start,`Unexpected variable "$${e}" in constant value.`)}throw this.unexpected(t)}return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:O.STRING,value:e.value,block:e.kind===_.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:O.LIST,values:this.any(_.BRACKET_L,(()=>this.parseValueLiteral(e)),_.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:O.OBJECT,fields:this.any(_.BRACE_L,(()=>this.parseObjectField(e)),_.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(_.COLON),this.node(t,{kind:O.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(_.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(_.AT),this.node(t,{kind:O.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(_.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(_.BRACKET_R),t=this.node(e,{kind:O.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(_.BANG)?this.node(e,{kind:O.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:O.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(_.STRING)||this.peek(_.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.many(_.BRACE_L,this.parseOperationTypeDefinition,_.BRACE_R);return this.node(e,{kind:O.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(_.COLON);const n=this.parseNamedType();return this.node(e,{kind:O.OPERATION_TYPE_DEFINITION,operation:t,type:n})}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();return this.node(e,{kind:O.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r})}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:O.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(_.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(_.BRACE_L,this.parseFieldDefinition,_.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(_.COLON);const i=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:O.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:s})}parseArgumentDefs(){return this.optionalMany(_.PAREN_L,this.parseInputValueDef,_.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(_.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(_.EQUALS)&&(i=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:O.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:s})}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:O.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(e,{kind:O.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(_.EQUALS)?this.delimitedMany(_.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(e,{kind:O.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(_.BRACE_L,this.parseEnumValueDefinition,_.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:O.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r})}parseEnumValueName(){if("true"===this._lexer.token.value||"false"===this._lexer.token.value||"null"===this._lexer.token.value)throw y(this._lexer.source,this._lexer.token.start,`${se(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(e,{kind:O.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(_.BRACE_L,this.parseInputValueDef,_.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===_.NAME)switch(e.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(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const t=this.parseConstDirectives(),n=this.optionalMany(_.BRACE_L,this.parseOperationTypeDefinition,_.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:O.SCHEMA_EXTENSION,directives:t,operationTypes:n})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseConstDirectives();if(0===n.length)throw this.unexpected();return this.node(e,{kind:O.SCALAR_TYPE_EXTENSION,name:t,directives:n})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:O.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(0===n.length&&0===r.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:O.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseUnionMemberTypes();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:O.UNION_TYPE_EXTENSION,name:t,directives:n,types:r})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:O.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();if(0===n.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:O.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(_.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:O.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:s})}parseDirectiveLocations(){return this.delimitedMany(_.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(b,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new v(e,this._lexer.lastToken,this._lexer.source)),t}peek(e){return this._lexer.token.kind===e}expectToken(e){const t=this._lexer.token;if(t.kind===e)return this.advanceLexer(),t;throw y(this._lexer.source,t.start,`Expected ${oe(e)}, found ${se(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==_.NAME||t.value!==e)throw y(this._lexer.source,t.start,`Expected "${e}", found ${se(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===_.NAME&&t.value===e&&(this.advanceLexer(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return y(this._lexer.source,t.start,`Unexpected ${se(t)}.`)}any(e,t,n){this.expectToken(e);const r=[];for(;!this.expectOptionalToken(n);)r.push(t.call(this));return r}optionalMany(e,t,n){if(this.expectOptionalToken(e)){const e=[];do{e.push(t.call(this))}while(!this.expectOptionalToken(n));return e}return[]}many(e,t,n){this.expectToken(e);const r=[];do{r.push(t.call(this))}while(!this.expectOptionalToken(n));return r}delimitedMany(e,t){this.expectOptionalToken(e);const n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n}advanceLexer(){const{maxTokens:e}=this._options,t=this._lexer.advance();if(void 0!==e&&t.kind!==_.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw y(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function se(e){const t=e.value;return oe(e.kind)+(null!=t?` "${t}"`:"")}function oe(e){return function(e){return 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)?`"${e}"`:e}const ae=5;function ce(e,t){const[n,r]=t?[e,t]:[void 0,e];let i=" Did you mean ";n&&(i+=n+" ");const s=r.map((e=>`"${e}"`));switch(s.length){case 0:return"";case 1:return i+s[0]+"?";case 2:return i+s[0]+" or "+s[1]+"?"}const o=s.slice(0,ae),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function ue(e){return e}function le(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function pe(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function de(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function fe(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),s=t.charCodeAt(r);if(ye(i)&&ye(s)){let o=0;do{++n,o=10*o+i-he,i=e.charCodeAt(n)}while(ye(i)&&o>0);let a=0;do{++r,a=10*a+s-he,s=t.charCodeAt(r)}while(ye(s)&&a>0);if(o<a)return-1;if(o>a)return 1}else{if(i<s)return-1;if(i>s)return 1;++n,++r}}return e.length-t.length}const he=48,me=57;function ye(e){return!isNaN(e)&&he<=e&&e<=me}function ve(e,t){const n=Object.create(null),r=new Te(e),i=Math.floor(.4*e.length)+1;for(const e of t){const t=r.measure(e,i);void 0!==t&&(n[e]=t)}return Object.keys(n).sort(((e,t)=>{const r=n[e]-n[t];return 0!==r?r:fe(e,t)}))}class Te{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=Ee(this._inputLowerCase),this._rows=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)]}measure(e,t){if(this._input===e)return 0;const n=e.toLowerCase();if(this._inputLowerCase===n)return 1;let r=Ee(n),i=this._inputArray;if(r.length<i.length){const e=r;r=i,i=e}const s=r.length,o=i.length;if(s-o>t)return;const a=this._rows;for(let e=0;e<=o;e++)a[0][e]=e;for(let e=1;e<=s;e++){const n=a[(e-1)%3],s=a[e%3];let c=s[0]=e;for(let t=1;t<=o;t++){const o=r[e-1]===i[t-1]?0:1;let u=Math.min(n[t]+1,s[t-1]+1,n[t-1]+o);if(e>1&&t>1&&r[e-1]===i[t-2]&&r[e-2]===i[t-1]){const n=a[(e-2)%3][t-2];u=Math.min(u,n+1)}u<c&&(c=u),s[t]=u}if(c>t)return}const c=a[s%3][o];return c<=t?c:void 0}}function Ee(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function ge(e){if(null==e)return Object.create(null);if(null===Object.getPrototypeOf(e))return e;const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]=r;return t}const Ne=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Ie(e){return be[e.charCodeAt(0)]}const be=["\\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"],Oe=Object.freeze({});function _e(e,t,n=E){const r=new Map;for(const e of Object.values(O))r.set(e,Se(t,e));let i,s,a,c=Array.isArray(e),u=[e],l=-1,p=[],d=e;const f=[],h=[];do{l++;const e=l===u.length,T=e&&0!==p.length;if(e){if(s=0===h.length?void 0:f[f.length-1],d=a,a=h.pop(),T)if(c){d=d.slice();let e=0;for(const[t,n]of p){const r=t-e;null===n?(d.splice(r,1),e++):d[r]=n}}else{d=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));for(const[e,t]of p)d[e]=t}l=i.index,u=i.keys,p=i.edits,c=i.inArray,i=i.prev}else if(a){if(s=c?l:u[l],d=a[s],null==d)continue;f.push(s)}let E;if(!Array.isArray(d)){var m,y;N(d)||o(!1,`Invalid AST Node: ${ee(d)}.`);const n=e?null===(m=r.get(d.kind))||void 0===m?void 0:m.leave:null===(y=r.get(d.kind))||void 0===y?void 0:y.enter;if(E=null==n?void 0:n.call(t,d,s,a,f,h),E===Oe)break;if(!1===E){if(!e){f.pop();continue}}else if(void 0!==E&&(p.push([s,E]),!e)){if(!N(E)){f.pop();continue}d=E}}var v;if(void 0===E&&T&&p.push([s,d]),e)f.pop();else i={inArray:c,index:l,keys:u,edits:p,prev:i},c=Array.isArray(d),u=c?d:null!==(v=n[d.kind])&&void 0!==v?v:[],l=-1,p=[],a&&h.push(a),a=d}while(void 0!==i);return 0!==p.length?p[p.length-1][1]:e}function Se(e,t){const n=e[t];return"object"==typeof n?n:"function"==typeof n?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function we(e){return _e(e,Ae)}const Ae={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>De(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=Re("(",De(e.variableDefinitions,", "),")"),n=De([e.operation,De([e.name,t]),De(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+Re(" = ",n)+Re(" ",De(r," "))},SelectionSet:{leave:({selections:e})=>xe(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=Re("",e,": ")+t;let o=s+Re("(",De(n,", "),")");return o.length>80&&(o=s+Re("(\n",ke(De(n,"\n")),"\n)")),De([o,De(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+Re(" ",De(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>De(["...",Re("on ",e),De(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${Re("(",De(n,", "),")")} on ${t} ${Re("",De(r," ")," ")}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?function(e,t){const n=e.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=1===r.length,s=r.length>1&&r.slice(1).every((e=>0===e.length||S(e.charCodeAt(0)))),o=n.endsWith('\\"""'),a=e.endsWith('"')&&!o,c=e.endsWith("\\"),u=a||c,l=!(null!=t&&t.minimize)&&(!i||e.length>70||u||s||o);let p="";const d=i&&S(e.charCodeAt(0));return(l&&!d||s)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(Ne,Ie)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+De(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+De(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+Re("(",De(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>Re("",e,"\n")+De(["schema",De(t," "),xe(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>Re("",e,"\n")+De(["scalar",t,De(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>Re("",e,"\n")+De(["type",t,Re("implements ",De(n," & ")),De(r," "),xe(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>Re("",e,"\n")+t+(Fe(n)?Re("(\n",ke(De(n,"\n")),"\n)"):Re("(",De(n,", "),")"))+": "+r+Re(" ",De(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>Re("",e,"\n")+De([t+": "+n,Re("= ",r),De(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>Re("",e,"\n")+De(["interface",t,Re("implements ",De(n," & ")),De(r," "),xe(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>Re("",e,"\n")+De(["union",t,De(n," "),Re("= ",De(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>Re("",e,"\n")+De(["enum",t,De(n," "),xe(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>Re("",e,"\n")+De([t,De(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>Re("",e,"\n")+De(["input",t,De(n," "),xe(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>Re("",e,"\n")+"directive @"+t+(Fe(n)?Re("(\n",ke(De(n,"\n")),"\n)"):Re("(",De(n,", "),")"))+(r?" repeatable":"")+" on "+De(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>De(["extend schema",De(e," "),xe(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>De(["extend scalar",e,De(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>De(["extend type",e,Re("implements ",De(t," & ")),De(n," "),xe(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>De(["extend interface",e,Re("implements ",De(t," & ")),De(n," "),xe(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>De(["extend union",e,De(t," "),Re("= ",De(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>De(["extend enum",e,De(t," "),xe(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>De(["extend input",e,De(t," "),xe(n)]," ")}};function De(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function xe(e){return Re("{\n",ke(De(e,"\n")),"\n}")}function Re(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function ke(e){return Re(" ",e.replace(/\n/g,"\n "))}function Fe(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function Le(e,t){switch(e.kind){case O.NULL:return null;case O.INT:return parseInt(e.value,10);case O.FLOAT:return parseFloat(e.value);case O.STRING:case O.ENUM:case O.BOOLEAN:return e.value;case O.LIST:return e.values.map((e=>Le(e,t)));case O.OBJECT:return pe(e.fields,(e=>e.name.value),(e=>Le(e.value,t)));case O.VARIABLE:return null==t?void 0:t[e.name.value]}}function $e(e){if(null!=e||o(!1,"Must provide name."),"string"==typeof e||o(!1,"Expected name to be a string."),0===e.length)throw new h("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!x(e.charCodeAt(t)))throw new h(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!D(e.charCodeAt(0)))throw new h(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function Ce(e){if("true"===e||"false"===e||"null"===e)throw new h(`Enum values cannot be named: ${e}`);return $e(e)}function Ve(e){return Ue(e)||je(e)||Me(e)||Pe(e)||Be(e)||Ge(e)||qe(e)||Je(e)}function Ue(e){return ne(e,st)}function je(e){return ne(e,ot)}function Me(e){return ne(e,ht)}function Pe(e){return ne(e,mt)}function Be(e){return ne(e,vt)}function Ge(e){return ne(e,Et)}function qe(e){return ne(e,He)}function Je(e){return ne(e,We)}function Ye(e){return Ue(e)||Be(e)||Ge(e)||Ze(e)&&Ye(e.ofType)}function Qe(e){return Ue(e)||je(e)||Me(e)||Pe(e)||Be(e)||Ze(e)&&Qe(e.ofType)}function Ke(e){return Ue(e)||Be(e)}function ze(e){return je(e)||Me(e)||Pe(e)}function Xe(e){return Me(e)||Pe(e)}class He{constructor(e){Ve(e)||o(!1,`Expected ${ee(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class We{constructor(e){var t;Ve(t=e)&&!Je(t)||o(!1,`Expected ${ee(e)} to be a GraphQL nullable type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}}function Ze(e){return qe(e)||Je(e)}function et(e){if(e)return Je(e)?e.ofType:e}function tt(e){return Ue(e)||je(e)||Me(e)||Pe(e)||Be(e)||Ge(e)}function nt(e){if(e){let t=e;for(;Ze(t);)t=t.ofType;return t}}function rt(e){return"function"==typeof e?e():e}function it(e){return"function"==typeof e?e():e}class st{constructor(e){var t,n,r,i;const s=null!==(t=e.parseValue)&&void 0!==t?t:ue;this.name=$e(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=null!==(n=e.serialize)&&void 0!==n?n:ue,this.parseValue=s,this.parseLiteral=null!==(r=e.parseLiteral)&&void 0!==r?r:(e,t)=>s(Le(e,t)),this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(i=e.extensionASTNodes)&&void 0!==i?i:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||o(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${ee(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||o(!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.`),e.parseLiteral&&("function"==typeof e.parseValue&&"function"==typeof e.parseLiteral||o(!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 ot{constructor(e){var t;this.name=$e(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=()=>ct(e),this._interfaces=()=>at(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||o(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${ee(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:pt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function at(e){var t;const n=rt(null!==(t=e.interfaces)&&void 0!==t?t:[]);return Array.isArray(n)||o(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function ct(e){const t=it(e.fields);return lt(t)||o(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),de(t,((t,n)=>{var r;lt(t)||o(!1,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||o(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${ee(t.resolve)}.`);const i=null!==(r=t.args)&&void 0!==r?r:{};return lt(i)||o(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:$e(n),description:t.description,type:t.type,args:ut(i),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:ge(t.extensions),astNode:t.astNode}}))}function ut(e){return Object.entries(e).map((([e,t])=>({name:$e(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:ge(t.extensions),astNode:t.astNode})))}function lt(e){return c(e)&&!Array.isArray(e)}function pt(e){return de(e,(e=>({description:e.description,type:e.type,args:dt(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function dt(e){return pe(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function ft(e){return Je(e.type)&&void 0===e.defaultValue}class ht{constructor(e){var t;this.name=$e(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=ct.bind(void 0,e),this._interfaces=at.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||o(!1,`${this.name} must provide "resolveType" as a function, but got: ${ee(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}getInterfaces(){return"function"==typeof this._interfaces&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:pt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class mt{constructor(e){var t;this.name=$e(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._types=yt.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||o(!1,`${this.name} must provide "resolveType" as a function, but got: ${ee(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}getTypes(){return"function"==typeof this._types&&(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 yt(e){const t=rt(e.types);return Array.isArray(t)||o(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class vt{constructor(e){var t,n,r;this.name=$e(e.name),this.description=e.description,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._values=(n=this.name,lt(r=e.values)||o(!1,`${n} values must be an object with value names as keys.`),Object.entries(r).map((([e,t])=>(lt(t)||o(!1,`${n}.${e} must refer to an object with a "value" key representing an internal value but got: ${ee(t)}.`),{name:Ce(e),description:t.description,value:void 0!==t.value?t.value:e,deprecationReason:t.deprecationReason,extensions:ge(t.extensions),astNode:t.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=le(this._values,(e=>e.name))}get[Symbol.toStringTag](){return"GraphQLEnumType"}getValues(){return this._values}getValue(e){return this._nameLookup[e]}serialize(e){const t=this._valueLookup.get(e);if(void 0===t)throw new h(`Enum "${this.name}" cannot represent value: ${ee(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=ee(e);throw new h(`Enum "${this.name}" cannot represent non-string value: ${t}.`+Tt(this,t))}const t=this.getValue(e);if(null==t)throw new h(`Value "${e}" does not exist in "${this.name}" enum.`+Tt(this,e));return t.value}parseLiteral(e,t){if(e.kind!==O.ENUM){const t=we(e);throw new h(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+Tt(this,t),{nodes:e})}const n=this.getValue(e.value);if(null==n){const t=we(e);throw new h(`Value "${t}" does not exist in "${this.name}" enum.`+Tt(this,t),{nodes:e})}return n.value}toConfig(){const e=pe(this.getValues(),(e=>e.name),(e=>({description:e.description,value:e.value,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Tt(e,t){return ce("the enum value",ve(t,e.getValues().map((e=>e.name))))}class Et{constructor(e){var t;this.name=$e(e.name),this.description=e.description,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=gt.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=de(this.getFields(),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function gt(e){const t=it(e.fields);return lt(t)||o(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),de(t,((t,n)=>(!("resolve"in t)||o(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:$e(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:ge(t.extensions),astNode:t.astNode})))}function Nt(e){return Je(e.type)&&void 0===e.defaultValue}function It(e,t){return e===t||(Je(e)&&Je(t)||!(!qe(e)||!qe(t)))&&It(e.ofType,t.ofType)}function bt(e,t,n){return t===n||(Je(n)?!!Je(t)&&bt(e,t.ofType,n.ofType):Je(t)?bt(e,t.ofType,n):qe(n)?!!qe(t)&&bt(e,t.ofType,n.ofType):!qe(t)&&(Xe(n)&&(Me(t)||je(t))&&e.isSubType(n,t)))}function Ot(e,t,n){return t===n||(Xe(t)?Xe(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Xe(n)&&e.isSubType(n,t))}const _t=2147483647,St=-2147483648,wt=new st({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=Ft(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isInteger(n))throw new h(`Int cannot represent non-integer value: ${ee(t)}`);if(n>_t||n<St)throw new h("Int cannot represent non 32-bit signed integer value: "+ee(t));return n},parseValue(e){if("number"!=typeof e||!Number.isInteger(e))throw new h(`Int cannot represent non-integer value: ${ee(e)}`);if(e>_t||e<St)throw new h(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==O.INT)throw new h(`Int cannot represent non-integer value: ${we(e)}`,{nodes:e});const t=parseInt(e.value,10);if(t>_t||t<St)throw new h(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),At=new st({name:"Float",description:"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",serialize(e){const t=Ft(e);if("boolean"==typeof t)return t?1:0;let n=t;if("string"==typeof t&&""!==t&&(n=Number(t)),"number"!=typeof n||!Number.isFinite(n))throw new h(`Float cannot represent non numeric value: ${ee(t)}`);return n},parseValue(e){if("number"!=typeof e||!Number.isFinite(e))throw new h(`Float cannot represent non numeric value: ${ee(e)}`);return e},parseLiteral(e){if(e.kind!==O.FLOAT&&e.kind!==O.INT)throw new h(`Float cannot represent non numeric value: ${we(e)}`,e);return parseFloat(e.value)}}),Dt=new st({name:"String",description:"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",serialize(e){const t=Ft(e);if("string"==typeof t)return t;if("boolean"==typeof t)return t?"true":"false";if("number"==typeof t&&Number.isFinite(t))return t.toString();throw new h(`String cannot represent value: ${ee(e)}`)},parseValue(e){if("string"!=typeof e)throw new h(`String cannot represent a non string value: ${ee(e)}`);return e},parseLiteral(e){if(e.kind!==O.STRING)throw new h(`String cannot represent a non string value: ${we(e)}`,{nodes:e});return e.value}}),xt=new st({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){const t=Ft(e);if("boolean"==typeof t)return t;if(Number.isFinite(t))return 0!==t;throw new h(`Boolean cannot represent a non boolean value: ${ee(t)}`)},parseValue(e){if("boolean"!=typeof e)throw new h(`Boolean cannot represent a non boolean value: ${ee(e)}`);return e},parseLiteral(e){if(e.kind!==O.BOOLEAN)throw new h(`Boolean cannot represent a non boolean value: ${we(e)}`,{nodes:e});return e.value}}),Rt=new st({name:"ID",description:'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',serialize(e){const t=Ft(e);if("string"==typeof t)return t;if(Number.isInteger(t))return String(t);throw new h(`ID cannot represent value: ${ee(e)}`)},parseValue(e){if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e.toString();throw new h(`ID cannot represent value: ${ee(e)}`)},parseLiteral(e){if(e.kind!==O.STRING&&e.kind!==O.INT)throw new h("ID cannot represent a non-string and non-integer value: "+we(e),{nodes:e});return e.value}}),kt=Object.freeze([Dt,wt,At,xt,Rt]);function Ft(e){if(c(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!c(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function Lt(e){return ne(e,$t)}class $t{constructor(e){var t,n;this.name=$e(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(t=e.isRepeatable)&&void 0!==t&&t,this.extensions=ge(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||o(!1,`@${e.name} locations must be an Array.`);const r=null!==(n=e.args)&&void 0!==n?n:{};c(r)&&!Array.isArray(r)||o(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=ut(r)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:dt(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const Ct=new $t({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[b.FIELD,b.FRAGMENT_SPREAD,b.INLINE_FRAGMENT],args:{if:{type:new We(xt),description:"Included when true."}}}),Vt=new $t({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[b.FIELD,b.FRAGMENT_SPREAD,b.INLINE_FRAGMENT],args:{if:{type:new We(xt),description:"Skipped when true."}}}),Ut=new $t({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[b.FIELD_DEFINITION,b.ARGUMENT_DEFINITION,b.INPUT_FIELD_DEFINITION,b.ENUM_VALUE],args:{reason:{type:Dt,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",defaultValue:"No longer supported"}}}),jt=new $t({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[b.SCALAR],args:{url:{type:new We(Dt),description:"The URL that specifies the behavior of this scalar."}}}),Mt=Object.freeze([Ct,Vt,Ut,jt]);function Pt(e){return"object"==typeof e&&"function"==typeof(null==e?void 0:e[Symbol.iterator])}function Bt(e,t){if(Je(t)){const n=Bt(e,t.ofType);return(null==n?void 0:n.kind)===O.NULL?null:n}if(null===e)return{kind:O.NULL};if(void 0===e)return null;if(qe(t)){const n=t.ofType;if(Pt(e)){const t=[];for(const r of e){const e=Bt(r,n);null!=e&&t.push(e)}return{kind:O.LIST,values:t}}return Bt(e,n)}if(Ge(t)){if(!c(e))return null;const n=[];for(const r of Object.values(t.getFields())){const t=Bt(e[r.name],r.type);t&&n.push({kind:O.OBJECT_FIELD,name:{kind:O.NAME,value:r.name},value:t})}return{kind:O.OBJECT,fields:n}}if(Ke(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:O.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return Gt.test(e)?{kind:O.INT,value:e}:{kind:O.FLOAT,value:e}}if("string"==typeof n)return Be(t)?{kind:O.ENUM,value:n}:t===Rt&&Gt.test(n)?{kind:O.INT,value:n}:{kind:O.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${ee(n)}.`)}u(!1,"Unexpected input type: "+ee(t))}const Gt=/^-?(?:0|[1-9][0-9]*)$/,qt=new ot({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:()=>({description:{type:Dt,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new We(new He(new We(Qt))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new We(Qt),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:Qt,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:Qt,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new We(new He(new We(Jt))),resolve:e=>e.getDirectives()}})}),Jt=new ot({name:"__Directive",description:"A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn 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 We(Dt),resolve:e=>e.name},description:{type:Dt,resolve:e=>e.description},isRepeatable:{type:new We(xt),resolve:e=>e.isRepeatable},locations:{type:new We(new He(new We(Yt))),resolve:e=>e.locations},args:{type:new We(new He(new We(zt))),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),Yt=new vt({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:b.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:b.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:b.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:b.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:b.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:b.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:b.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:b.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:b.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:b.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:b.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:b.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:b.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:b.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:b.UNION,description:"Location adjacent to a union definition."},ENUM:{value:b.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:b.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:b.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:b.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),Qt=new ot({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 We(Wt),resolve:e=>Ue(e)?Ht.SCALAR:je(e)?Ht.OBJECT:Me(e)?Ht.INTERFACE:Pe(e)?Ht.UNION:Be(e)?Ht.ENUM:Ge(e)?Ht.INPUT_OBJECT:qe(e)?Ht.LIST:Je(e)?Ht.NON_NULL:void u(!1,`Unexpected type: "${ee(e)}".`)},name:{type:Dt,resolve:e=>"name"in e?e.name:void 0},description:{type:Dt,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:Dt,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new He(new We(Kt)),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(je(e)||Me(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new He(new We(Qt)),resolve(e){if(je(e)||Me(e))return e.getInterfaces()}},possibleTypes:{type:new He(new We(Qt)),resolve(e,t,n,{schema:r}){if(Xe(e))return r.getPossibleTypes(e)}},enumValues:{type:new He(new We(Xt)),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Be(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new He(new We(zt)),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Ge(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:Qt,resolve:e=>"ofType"in e?e.ofType:void 0}})}),Kt=new ot({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 We(Dt),resolve:e=>e.name},description:{type:Dt,resolve:e=>e.description},args:{type:new We(new He(new We(zt))),args:{includeDeprecated:{type:xt,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new We(Qt),resolve:e=>e.type},isDeprecated:{type:new We(xt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Dt,resolve:e=>e.deprecationReason}})}),zt=new ot({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 We(Dt),resolve:e=>e.name},description:{type:Dt,resolve:e=>e.description},type:{type:new We(Qt),resolve:e=>e.type},defaultValue:{type:Dt,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=Bt(n,t);return r?we(r):null}},isDeprecated:{type:new We(xt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Dt,resolve:e=>e.deprecationReason}})}),Xt=new ot({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 We(Dt),resolve:e=>e.name},description:{type:Dt,resolve:e=>e.description},isDeprecated:{type:new We(xt),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:Dt,resolve:e=>e.deprecationReason}})});var Ht;!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"}(Ht||(Ht={}));const Wt=new vt({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:Ht.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:Ht.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:Ht.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:Ht.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:Ht.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:Ht.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:Ht.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:Ht.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),Zt={name:"__schema",type:new We(qt),description:"Access the current type schema of this server.",args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},en={name:"__type",type:Qt,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new We(Dt),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},tn={name:"__typename",type:new We(Dt),description:"The name of the current Object type at runtime.",args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},nn=Object.freeze([qt,Jt,Yt,Qt,Kt,zt,Xt,Wt]);function rn(e){return nn.some((({name:t})=>e.name===t))}function sn(e){if(!function(e){return ne(e,on)}(e))throw new Error(`Expected ${ee(e)} to be a GraphQL schema.`);return e}class on{constructor(e){var t,n;this.__validationErrors=!0===e.assumeValid?[]:void 0,c(e)||o(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||o(!1,`"types" must be Array if provided but got: ${ee(e.types)}.`),!e.directives||Array.isArray(e.directives)||o(!1,`"directives" must be Array if provided but got: ${ee(e.directives)}.`),this.description=e.description,this.extensions=ge(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=null!==(n=e.directives)&&void 0!==n?n:Mt;const r=new Set(e.types);if(null!=e.types)for(const t of e.types)r.delete(t),an(t,r);null!=this._queryType&&an(this._queryType,r),null!=this._mutationType&&an(this._mutationType,r),null!=this._subscriptionType&&an(this._subscriptionType,r);for(const e of this._directives)if(Lt(e))for(const t of e.args)an(t.type,r);an(qt,r),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const e of r){if(null==e)continue;const t=e.name;if(t||o(!1,"One of the provided types for building the Schema is missing a name."),void 0!==this._typeMap[t])throw new Error(`Schema must contain uniquely named types but contains multiple types named "${t}".`);if(this._typeMap[t]=e,Me(e)){for(const t of e.getInterfaces())if(Me(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(je(e))for(const t of e.getInterfaces())if(Me(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case I.QUERY:return this.getQueryType();case I.MUTATION:return this.getMutationType();case I.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return Pe(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){const t=this._implementationsMap[e.name];return null!=t?t:{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(void 0===n){if(n=Object.create(null),Pe(e))for(const t of e.getTypes())n[t.name]=!0;else{const t=this.getImplementations(e);for(const e of t.objects)n[e.name]=!0;for(const e of t.interfaces)n[e.name]=!0}this._subTypeMap[e.name]=n}return void 0!==n[t.name]}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find((t=>t.name===e))}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:void 0!==this.__validationErrors}}}function an(e,t){const n=nt(e);if(!t.has(n))if(t.add(n),Pe(n))for(const e of n.getTypes())an(e,t);else if(je(n)||Me(n)){for(const e of n.getInterfaces())an(e,t);for(const e of Object.values(n.getFields())){an(e.type,t);for(const n of e.args)an(n.type,t)}}else if(Ge(n))for(const e of Object.values(n.getFields()))an(e.type,t);return t}function cn(e){if(sn(e),e.__validationErrors)return e.__validationErrors;const t=new ln(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!je(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${ee(n)}.`,null!==(r=pn(t,I.QUERY))&&void 0!==r?r:n.astNode)}}else e.reportError("Query root type must be provided.",t.astNode);const i=t.getMutationType();var s;i&&!je(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${ee(i)}.`,null!==(s=pn(t,I.MUTATION))&&void 0!==s?s:i.astNode);const o=t.getSubscriptionType();var a;o&&!je(o)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${ee(o)}.`,null!==(a=pn(t,I.SUBSCRIPTION))&&void 0!==a?a:o.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(Lt(n)){dn(e,n);for(const r of n.args){var t;if(dn(e,r),Ye(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${ee(r.type)}.`,r.astNode),ft(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[In(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${ee(n)}.`,null==n?void 0:n.astNode)}(t),function(e){const t=function(e){const t=Object.create(null),n=[],r=Object.create(null);return i;function i(s){if(t[s.name])return;t[s.name]=!0,r[s.name]=n.length;const o=Object.values(s.getFields());for(const t of o)if(Je(t.type)&&Ge(t.type.ofType)){const s=t.type.ofType,o=r[s.name];if(n.push(t),void 0===o)i(s);else{const t=n.slice(o),r=t.map((e=>e.name)).join(".");e.reportError(`Cannot reference Input Object "${s.name}" within itself through a series of non-null fields: "${r}".`,t.map((e=>e.astNode)))}n.pop()}r[s.name]=void 0}}(e),n=e.schema.getTypeMap();for(const r of Object.values(n))tt(r)?(rn(r)||dn(e,r),je(r)||Me(r)?(fn(e,r),hn(e,r)):Pe(r)?vn(e,r):Be(r)?Tn(e,r):Ge(r)&&(En(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${ee(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}function un(e){const t=cn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}class ln{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new h(e,{nodes:n}))}getErrors(){return this._errors}}function pn(e,t){var n;return null===(n=[e.astNode,...e.extensionASTNodes].flatMap((e=>{var t;return null!==(t=null==e?void 0:e.operationTypes)&&void 0!==t?t:[]})).find((e=>e.operation===t)))||void 0===n?void 0:n.type}function dn(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function fn(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const o of n){var r;if(dn(e,o),!Qe(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Output Type but got: ${ee(o.type)}.`,null===(r=o.astNode)||void 0===r?void 0:r.type);for(const n of o.args){const r=n.name;var i,s;if(dn(e,n),!Ye(n.type))e.reportError(`The type of ${t.name}.${o.name}(${r}:) must be Input Type but got: ${ee(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(ft(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${o.name}(${r}:) cannot be deprecated.`,[In(n.astNode),null===(s=n.astNode)||void 0===s?void 0:s.type])}}}function hn(e,t){const n=Object.create(null);for(const r of t.getInterfaces())Me(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,gn(t,r)):(n[r.name]=!0,yn(e,t,r),mn(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,gn(t,r)):e.reportError(`Type ${ee(t)} must only implement Interface types, it cannot implement ${ee(r)}.`,gn(t,r))}function mn(e,t,n){const r=t.getFields();for(const c of Object.values(n.getFields())){const u=c.name,l=r[u];if(l){var i,s;if(!bt(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${ee(c.type)} but ${t.name}.${u} is type ${ee(l.type)}.`,[null===(i=c.astNode)||void 0===i?void 0:i.type,null===(s=l.astNode)||void 0===s?void 0:s.type]);for(const r of c.args){const i=r.name,s=l.args.find((e=>e.name===i));var o,a;if(s){if(!It(r.type,s.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${ee(r.type)} but ${t.name}.${u}(${i}:) is type ${ee(s.type)}.`,[null===(o=r.astNode)||void 0===o?void 0:o.type,null===(a=s.astNode)||void 0===a?void 0:a.type])}else e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expected but ${t.name}.${u} does not provide it.`,[r.astNode,l.astNode])}for(const r of l.args){const i=r.name;!c.args.find((e=>e.name===i))&&ft(r)&&e.reportError(`Object field ${t.name}.${u} includes required argument ${i} that is missing from the Interface field ${n.name}.${u}.`,[r.astNode,c.astNode])}}else e.reportError(`Interface field ${n.name}.${u} expected but ${t.name} does not provide it.`,[c.astNode,t.astNode,...t.extensionASTNodes])}}function yn(e,t,n){const r=t.getInterfaces();for(const i of n.getInterfaces())r.includes(i)||e.reportError(i===t?`Type ${t.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${t.name} must implement ${i.name} because it is implemented by ${n.name}.`,[...gn(n,i),...gn(t,n)])}function vn(e,t){const n=t.getTypes();0===n.length&&e.reportError(`Union type ${t.name} must define one or more member types.`,[t.astNode,...t.extensionASTNodes]);const r=Object.create(null);for(const i of n)r[i.name]?e.reportError(`Union type ${t.name} can only include type ${i.name} once.`,Nn(t,i.name)):(r[i.name]=!0,je(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${ee(i)}.`,Nn(t,String(i))))}function Tn(e,t){const n=t.getValues();0===n.length&&e.reportError(`Enum type ${t.name} must define one or more values.`,[t.astNode,...t.extensionASTNodes]);for(const t of n)dn(e,t)}function En(e,t){const n=Object.values(t.getFields());0===n.length&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(const s of n){var r,i;if(dn(e,s),!Ye(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Input Type but got: ${ee(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);if(Nt(s)&&null!=s.deprecationReason)e.reportError(`Required input field ${t.name}.${s.name} cannot be deprecated.`,[In(s.astNode),null===(i=s.astNode)||void 0===i?void 0:i.type])}}function gn(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.interfaces)&&void 0!==t?t:[]})).filter((e=>e.name.value===t.name))}function Nn(e,t){const{astNode:n,extensionASTNodes:r}=e;return(null!=n?[n,...r]:r).flatMap((e=>{var t;return null!==(t=e.types)&&void 0!==t?t:[]})).filter((e=>e.name.value===t))}function In(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===Ut.name))}function bn(e,t){switch(t.kind){case O.LIST_TYPE:{const n=bn(e,t.type);return n&&new He(n)}case O.NON_NULL_TYPE:{const n=bn(e,t.type);return n&&new We(n)}case O.NAMED_TYPE:return e.getType(t.name.value)}}class On{constructor(e,t,n){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=null!=n?n:_n,t&&(Ye(t)&&this._inputTypeStack.push(t),ze(t)&&this._parentTypeStack.push(t),Qe(t)&&this._typeStack.push(t))}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(e){const t=this._schema;switch(e.kind){case O.SELECTION_SET:{const e=nt(this.getType());this._parentTypeStack.push(ze(e)?e:void 0);break}case O.FIELD:{const n=this.getParentType();let r,i;n&&(r=this._getFieldDef(t,n,e),r&&(i=r.type)),this._fieldDefStack.push(r),this._typeStack.push(Qe(i)?i:void 0);break}case O.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case O.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(je(n)?n:void 0);break}case O.INLINE_FRAGMENT:case O.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?bn(t,n):nt(this.getType());this._typeStack.push(Qe(r)?r:void 0);break}case O.VARIABLE_DEFINITION:{const n=bn(t,e.type);this._inputTypeStack.push(Ye(n)?n:void 0);break}case O.ARGUMENT:{var n;let t,r;const i=null!==(n=this.getDirective())&&void 0!==n?n:this.getFieldDef();i&&(t=i.args.find((t=>t.name===e.name.value)),t&&(r=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(Ye(r)?r:void 0);break}case O.LIST:{const e=et(this.getInputType()),t=qe(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(Ye(t)?t:void 0);break}case O.OBJECT_FIELD:{const t=nt(this.getInputType());let n,r;Ge(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(Ye(n)?n:void 0);break}case O.ENUM:{const t=nt(this.getInputType());let n;Be(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case O.SELECTION_SET:this._parentTypeStack.pop();break;case O.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case O.DIRECTIVE:this._directive=null;break;case O.OPERATION_DEFINITION:case O.INLINE_FRAGMENT:case O.FRAGMENT_DEFINITION:this._typeStack.pop();break;case O.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case O.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case O.LIST:case O.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case O.ENUM:this._enumValue=null}}}function _n(e,t,n){const r=n.name.value;return r===Zt.name&&e.getQueryType()===t?Zt:r===en.name&&e.getQueryType()===t?en:r===tn.name&&ze(t)?tn:je(t)||Me(t)?t.getFields()[r]:void 0}function Sn(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=Se(t,r.kind).enter;if(i){const s=i.apply(t,n);return void 0!==s&&(e.leave(r),N(s)&&e.enter(s)),s}},leave(...n){const r=n[0],i=Se(t,r.kind).leave;let s;return i&&(s=i.apply(t,n)),e.leave(r),s}}}function wn(e){return e.kind===O.OPERATION_DEFINITION||e.kind===O.FRAGMENT_DEFINITION}function An(e){return e.kind===O.SCALAR_TYPE_DEFINITION||e.kind===O.OBJECT_TYPE_DEFINITION||e.kind===O.INTERFACE_TYPE_DEFINITION||e.kind===O.UNION_TYPE_DEFINITION||e.kind===O.ENUM_TYPE_DEFINITION||e.kind===O.INPUT_OBJECT_TYPE_DEFINITION}function Dn(e){return e.kind===O.SCALAR_TYPE_EXTENSION||e.kind===O.OBJECT_TYPE_EXTENSION||e.kind===O.INTERFACE_TYPE_EXTENSION||e.kind===O.UNION_TYPE_EXTENSION||e.kind===O.ENUM_TYPE_EXTENSION||e.kind===O.INPUT_OBJECT_TYPE_EXTENSION}function xn(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Mt;for(const e of r)t[e.name]=e.args.map((e=>e.name));const i=e.getDocument().definitions;for(const e of i)if(e.kind===O.DIRECTIVE_DEFINITION){var s;const n=null!==(s=e.arguments)&&void 0!==s?s:[];t[e.name.value]=n.map((e=>e.name.value))}return{Directive(n){const r=n.name.value,i=t[r];if(n.arguments&&i)for(const t of n.arguments){const n=t.name.value;if(!i.includes(n)){const s=ve(n,i);e.reportError(new h(`Unknown argument "${n}" on directive "@${r}".`+ce(s),{nodes:t}))}}return!1}}}const Rn=[...kt,...nn].map((e=>e.name));function kn(e){switch(e.kind){case O.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:kn(e.value)}))).sort(((e,t)=>fe(e.name.value,t.name.value))))};case O.LIST:return{...e,values:e.values.map(kn)};case O.INT:case O.FLOAT:case O.STRING:case O.BOOLEAN:case O.NULL:case O.ENUM:case O.VARIABLE:return e}var t}function Fn(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+Fn(t))).join(" and "):e}function Ln(e,t,n,r,i,s,o){const a=e.getFragment(o);if(!a)return;const[c,u]=Pn(e,n,a);if(s!==c){Cn(e,t,n,r,i,s,c);for(const a of u)r.has(a,o,i)||(r.add(a,o,i),Ln(e,t,n,r,i,s,a))}}function $n(e,t,n,r,i,s,o){if(s===o)return;if(r.has(s,o,i))return;r.add(s,o,i);const a=e.getFragment(s),c=e.getFragment(o);if(!a||!c)return;const[u,l]=Pn(e,n,a),[p,d]=Pn(e,n,c);Cn(e,t,n,r,i,u,p);for(const o of d)$n(e,t,n,r,i,s,o);for(const s of l)$n(e,t,n,r,i,s,o)}function Cn(e,t,n,r,i,s,o){for(const[a,c]of Object.entries(s)){const s=o[a];if(s)for(const o of c)for(const c of s){const s=Vn(e,n,r,i,a,o,c);s&&t.push(s)}}}function Vn(e,t,n,r,i,s,o){const[a,c,u]=s,[l,p,d]=o,f=r||a!==l&&je(a)&&je(l);if(!f){const e=c.name.value,t=p.name.value;if(e!==t)return[[i,`"${e}" and "${t}" are different fields`],[c],[p]];if(Un(c)!==Un(p))return[[i,"they have differing arguments"],[c],[p]]}const h=null==u?void 0:u.type,m=null==d?void 0:d.type;if(h&&m&&jn(h,m))return[[i,`they return conflicting types "${ee(h)}" and "${ee(m)}"`],[c],[p]];const y=c.selectionSet,v=p.selectionSet;if(y&&v){const r=function(e,t,n,r,i,s,o,a){const c=[],[u,l]=Mn(e,t,i,s),[p,d]=Mn(e,t,o,a);Cn(e,c,t,n,r,u,p);for(const i of d)Ln(e,c,t,n,r,u,i);for(const i of l)Ln(e,c,t,n,r,p,i);for(const i of l)for(const s of d)$n(e,c,t,n,r,i,s);return c}(e,t,n,f,nt(h),y,nt(m),v);return function(e,t,n,r){if(e.length>0)return[[t,e.map((([e])=>e))],[n,...e.map((([,e])=>e)).flat()],[r,...e.map((([,,e])=>e)).flat()]]}(r,i,c,p)}}function Un(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return we(kn({kind:O.OBJECT,fields:n.map((e=>({kind:O.OBJECT_FIELD,name:e.name,value:e.value})))}))}function jn(e,t){return qe(e)?!qe(t)||jn(e.ofType,t.ofType):!!qe(t)||(Je(e)?!Je(t)||jn(e.ofType,t.ofType):!!Je(t)||!(!Ke(e)&&!Ke(t))&&e!==t)}function Mn(e,t,n,r){const i=t.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);Bn(e,n,r,s,o);const a=[s,Object.keys(o)];return t.set(r,a),a}function Pn(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=bn(e.getSchema(),n.typeCondition);return Mn(e,t,i,n.selectionSet)}function Bn(e,t,n,r,i){for(const s of n.selections)switch(s.kind){case O.FIELD:{const e=s.name.value;let n;(je(t)||Me(t))&&(n=t.getFields()[e]);const i=s.alias?s.alias.value:e;r[i]||(r[i]=[]),r[i].push([t,s,n]);break}case O.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case O.INLINE_FRAGMENT:{const n=s.typeCondition,o=n?bn(e.getSchema(),n):t;Bn(e,o,s.selectionSet,r,i);break}}}class Gn{constructor(){this._data=new Map}has(e,t,n){var r;const[i,s]=e<t?[e,t]:[t,e],o=null===(r=this._data.get(i))||void 0===r?void 0:r.get(s);return void 0!==o&&(!!n||n===o)}add(e,t,n){const[r,i]=e<t?[e,t]:[t,e],s=this._data.get(r);void 0===s?this._data.set(r,new Map([[i,n]])):s.set(i,n)}}function qn(e){var t;const n=Object.create(null),r=e.getSchema(),i=null!==(t=null==r?void 0:r.getDirectives())&&void 0!==t?t:Mt;for(const e of i)n[e.name]=le(e.args.filter(ft),(e=>e.name));const s=e.getDocument().definitions;for(const e of s)if(e.kind===O.DIRECTIVE_DEFINITION){var o;const t=null!==(o=e.arguments)&&void 0!==o?o:[];n[e.name.value]=le(t.filter(Jn),(e=>e.name.value))}return{Directive:{leave(t){const r=t.name.value,i=n[r];if(i){var s;const n=null!==(s=t.arguments)&&void 0!==s?s:[],o=new Set(n.map((e=>e.name.value)));for(const[n,s]of Object.entries(i))if(!o.has(n)){const i=Ve(s.type)?ee(s.type):we(s.type);e.reportError(new h(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}}}function Jn(e){return e.type.kind===O.NON_NULL_TYPE&&null==e.defaultValue}function Yn(e){return e.map((e=>"number"==typeof e?"["+e.toString()+"]":"."+e)).join("")}function Qn(e,t,n){return{prev:e,key:t,typename:n}}function Kn(e){const t=[];let n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function zn(e,t,n=Xn){return Hn(e,t,n,void 0)}function Xn(e,t,n){let r="Invalid value "+ee(t);throw e.length>0&&(r+=` at "value${Yn(e)}"`),n.message=r+": "+n.message,n}function Hn(e,t,n,r){if(Je(t))return null!=e?Hn(e,t.ofType,n,r):void n(Kn(r),e,new h(`Expected non-nullable type "${ee(t)}" not to be null.`));if(null==e)return null;if(qe(t)){const i=t.ofType;return Pt(e)?Array.from(e,((e,t)=>{const s=Qn(r,t,void 0);return Hn(e,i,n,s)})):[Hn(e,i,n,r)]}if(Ge(t)){if(!c(e))return void n(Kn(r),e,new h(`Expected type "${t.name}" to be an object.`));const i={},s=t.getFields();for(const o of Object.values(s)){const s=e[o.name];if(void 0!==s)i[o.name]=Hn(s,o.type,n,Qn(r,o.name,t.name));else if(void 0!==o.defaultValue)i[o.name]=o.defaultValue;else if(Je(o.type)){const t=ee(o.type);n(Kn(r),e,new h(`Field "${o.name}" of required type "${t}" was not provided.`))}}for(const i of Object.keys(e))if(!s[i]){const s=ve(i,Object.keys(t.getFields()));n(Kn(r),e,new h(`Field "${i}" is not defined by type "${t.name}".`+ce(s)))}return i}if(Ke(t)){let i;try{i=t.parseValue(e)}catch(i){return void n(Kn(r),e,i instanceof h?i:new h(`Expected type "${t.name}". `+i.message,{originalError:i}))}return void 0===i&&n(Kn(r),e,new h(`Expected type "${t.name}".`)),i}u(!1,"Unexpected input type: "+ee(t))}function Wn(e,t,n){if(e){if(e.kind===O.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&Je(t))return;return i}if(Je(t)){if(e.kind===O.NULL)return;return Wn(e,t.ofType,n)}if(e.kind===O.NULL)return null;if(qe(t)){const r=t.ofType;if(e.kind===O.LIST){const t=[];for(const i of e.values)if(Zn(i,n)){if(Je(r))return;t.push(null)}else{const e=Wn(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=Wn(e,r,n);if(void 0===i)return;return[i]}if(Ge(t)){if(e.kind!==O.OBJECT)return;const r=Object.create(null),i=le(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||Zn(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(Je(e.type))return;continue}const s=Wn(t.value,e.type,n);if(void 0===s)return;r[e.name]=s}return r}if(Ke(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}u(!1,"Unexpected input type: "+ee(t))}}function Zn(e,t){return e.kind===O.VARIABLE&&(null==t||void 0===t[e.name.value])}function er(e,t,n,r){const i=[],s=null==r?void 0:r.maxErrors;try{const r=function(e,t,n,r){const i={};for(const s of t){const t=s.variable.name.value,o=bn(e,s.type);if(!Ye(o)){const e=we(s.type);r(new h(`Variable "$${t}" expected value of type "${e}" which cannot be used as an input type.`,{nodes:s.type}));continue}if(!rr(n,t)){if(s.defaultValue)i[t]=Wn(s.defaultValue,o);else if(Je(o)){const e=ee(o);r(new h(`Variable "$${t}" of required type "${e}" was not provided.`,{nodes:s}))}continue}const a=n[t];if(null===a&&Je(o)){const e=ee(o);r(new h(`Variable "$${t}" of non-null type "${e}" must not be null.`,{nodes:s}))}else i[t]=zn(a,o,((e,n,i)=>{let o=`Variable "$${t}" got invalid value `+ee(n);e.length>0&&(o+=` at "${t}${Yn(e)}"`),r(new h(o+"; "+i.message,{nodes:s,originalError:i.originalError}))}))}return i}(e,t,n,(e=>{if(null!=s&&i.length>=s)throw new h("Too many errors processing variables, error limit reached. Execution aborted.");i.push(e)}));if(0===i.length)return{coerced:r}}catch(e){i.push(e)}return{errors:i}}function tr(e,t,n){var r;const i={},s=le(null!==(r=t.arguments)&&void 0!==r?r:[],(e=>e.name.value));for(const r of e.args){const e=r.name,o=r.type,a=s[e];if(!a){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(Je(o))throw new h(`Argument "${e}" of required type "${ee(o)}" was not provided.`,{nodes:t});continue}const c=a.value;let u=c.kind===O.NULL;if(c.kind===O.VARIABLE){const t=c.name.value;if(null==n||!rr(n,t)){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(Je(o))throw new h(`Argument "${e}" of required type "${ee(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}u=null==n[t]}if(u&&Je(o))throw new h(`Argument "${e}" of non-null type "${ee(o)}" must not be null.`,{nodes:c});const l=Wn(c,o,n);if(void 0===l)throw new h(`Argument "${e}" has invalid value ${we(c)}.`,{nodes:c});i[e]=l}return i}function nr(e,t,n){var r;const i=null===(r=t.directives)||void 0===r?void 0:r.find((t=>t.name.value===e.name));if(i)return tr(e,i,n)}function rr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ir(e,t,n,r,i){const s=new Map;return sr(e,t,n,r,i,s,new Set),s}function sr(e,t,n,r,i,s,o){for(const c of i.selections)switch(c.kind){case O.FIELD:{if(!or(n,c))continue;const e=(a=c).alias?a.alias.value:a.name.value,t=s.get(e);void 0!==t?t.push(c):s.set(e,[c]);break}case O.INLINE_FRAGMENT:if(!or(n,c)||!ar(e,c,r))continue;sr(e,t,n,r,c.selectionSet,s,o);break;case O.FRAGMENT_SPREAD:{const i=c.name.value;if(o.has(i)||!or(n,c))continue;o.add(i);const a=t[i];if(!a||!ar(e,a,r))continue;sr(e,t,n,r,a.selectionSet,s,o);break}}var a}function or(e,t){const n=nr(Vt,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=nr(Ct,t,e);return!1!==(null==r?void 0:r.if)}function ar(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=bn(e,r);return i===n||!!Xe(i)&&e.isSubType(i,n)}function cr(e,t){const n=new Map;for(const r of e){const e=t(r),i=n.get(e);void 0===i?n.set(e,[r]):i.push(r)}return n}function ur(e,t){const n=e.getInputType();if(!n)return;const r=nt(n);if(Ke(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=ee(n);e.reportError(new h(`Expected value of type "${r}", found ${we(t)}.`,{nodes:t}))}}catch(r){const i=ee(n);r instanceof h?e.reportError(r):e.reportError(new h(`Expected value of type "${i}", found ${we(t)}; `+r.message,{nodes:t,originalError:r}))}else{const r=ee(n);e.reportError(new h(`Expected value of type "${r}", found ${we(t)}.`,{nodes:t}))}}function lr(e,t,n,r,i){if(Je(r)&&!Je(t)){if(!(null!=n&&n.kind!==O.NULL)&&!(void 0!==i))return!1;return bt(e,t,r.ofType)}return bt(e,t,r)}const pr=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!wn(n)){const t=n.kind===O.SCHEMA_DEFINITION||n.kind===O.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new h(`The ${t} definition is not executable.`,{nodes:n}))}return!1}}},function(e){const t=Object.create(null);return{OperationDefinition(n){const r=n.name;return r&&(t[r.value]?e.reportError(new h(`There can be only one operation named "${r.value}".`,{nodes:[t[r.value],r]})):t[r.value]=r),!1},FragmentDefinition:()=>!1}},function(e){let t=0;return{Document(e){t=e.definitions.filter((e=>e.kind===O.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new h("This anonymous operation must be the only defined operation.",{nodes:n}))}}},function(e){return{OperationDefinition(t){if("subscription"===t.operation){const n=e.getSchema(),r=n.getSubscriptionType();if(r){const i=t.name?t.name.value:null,s=Object.create(null),o=e.getDocument(),a=Object.create(null);for(const e of o.definitions)e.kind===O.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=ir(n,a,s,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new h(null!=i?`Subscription "${i}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",{nodes:t}))}for(const t of c.values()){t[0].name.value.startsWith("__")&&e.reportError(new h(null!=i?`Subscription "${i}" must not select an introspection top level field.`:"Anonymous Subscription must not select an introspection top level field.",{nodes:t}))}}}}}},function(e){const t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(const t of e.getDocument().definitions)An(t)&&(r[t.name.value]=!0);const i=[...Object.keys(n),...Object.keys(r)];return{NamedType(t,s,o,a,c){const u=t.name.value;if(!n[u]&&!r[u]){var l;const n=null!==(l=c[2])&&void 0!==l?l:o,r=null!=n&&("kind"in(p=n)&&(function(e){return e.kind===O.SCHEMA_DEFINITION||An(e)||e.kind===O.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===O.SCHEMA_EXTENSION||Dn(e)}(p)));if(r&&Rn.includes(u))return;const s=ve(u,r?Rn.concat(i):i);e.reportError(new h(`Unknown type "${u}".`+ce(s),{nodes:t}))}var p}}},function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=bn(e.getSchema(),n);if(t&&!ze(t)){const t=we(n);e.reportError(new h(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){const n=bn(e.getSchema(),t.typeCondition);if(n&&!ze(n)){const n=we(t.typeCondition);e.reportError(new h(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}},function(e){return{VariableDefinition(t){const n=bn(e.getSchema(),t.type);if(void 0!==n&&!Ye(n)){const n=t.variable.name.value,r=we(t.type);e.reportError(new h(`Variable "$${n}" cannot be non-input type "${r}".`,{nodes:t.type}))}}}},function(e){return{Field(t){const n=e.getType(),r=t.selectionSet;if(n)if(Ke(nt(n))){if(r){const i=t.name.value,s=ee(n);e.reportError(new h(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(!r){const r=t.name.value,i=ee(n);e.reportError(new h(`Field "${r}" of type "${i}" must have a selection of subfields. Did you mean "${r} { ... }"?`,{nodes:t}))}}}},function(e){return{Field(t){const n=e.getParentType();if(n){if(!e.getFieldDef()){const r=e.getSchema(),i=t.name.value;let s=ce("to use an inline fragment on",function(e,t,n){if(!Xe(t))return[];const r=new Set,i=Object.create(null);for(const o of e.getPossibleTypes(t))if(o.getFields()[n]){r.add(o),i[o.name]=1;for(const e of o.getInterfaces()){var s;e.getFields()[n]&&(r.add(e),i[e.name]=(null!==(s=i[e.name])&&void 0!==s?s:0)+1)}}return[...r].sort(((t,n)=>{const r=i[n.name]-i[t.name];return 0!==r?r:Me(t)&&e.isSubType(t,n)?-1:Me(n)&&e.isSubType(n,t)?1:fe(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===s&&(s=ce(function(e,t){if(je(e)||Me(e)){return ve(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new h(`Cannot query field "${i}" on type "${n.name}".`+s,{nodes:t}))}}}}},function(e){const t=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){const r=n.name.value;return t[r]?e.reportError(new h(`There can be only one fragment named "${r}".`,{nodes:[t[r],n.name]})):t[r]=n.name,!1}}},function(e){return{FragmentSpread(t){const n=t.name.value;e.getFragment(n)||e.reportError(new h(`Unknown fragment "${n}".`,{nodes:t.name}))}}},function(e){const t=[],n=[];return{OperationDefinition:e=>(t.push(e),!1),FragmentDefinition:e=>(n.push(e),!1),Document:{leave(){const r=Object.create(null);for(const n of t)for(const t of e.getRecursivelyReferencedFragments(n))r[t.name.value]=!0;for(const t of n){const n=t.name.value;!0!==r[n]&&e.reportError(new h(`Fragment "${n}" is never used.`,{nodes:t}))}}}}},function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(ze(n)&&ze(r)&&!Ot(e.getSchema(),n,r)){const i=ee(r),s=ee(n);e.reportError(new h(`Fragment cannot be spread here as objects of type "${i}" can never be of type "${s}".`,{nodes:t}))}},FragmentSpread(t){const n=t.name.value,r=function(e,t){const n=e.getFragment(t);if(n){const t=bn(e.getSchema(),n.typeCondition);if(ze(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!Ot(e.getSchema(),r,i)){const s=ee(i),o=ee(r);e.reportError(new h(`Fragment "${n}" cannot be spread here as objects of type "${s}" can never be of type "${o}".`,{nodes:t}))}}}},function(e){const t=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition:e=>(i(e),!1)};function i(s){if(t[s.name.value])return;const o=s.name.value;t[o]=!0;const a=e.getFragmentSpreads(s.selectionSet);if(0!==a.length){r[o]=n.length;for(const t of a){const s=t.name.value,o=r[s];if(n.push(t),void 0===o){const t=e.getFragment(s);t&&i(t)}else{const t=n.slice(o),r=t.slice(0,-1).map((e=>'"'+e.name.value+'"')).join(", ");e.reportError(new h(`Cannot spread fragment "${s}" within itself`+(""!==r?` via ${r}.`:"."),{nodes:t}))}n.pop()}r[o]=void 0}}},function(e){return{OperationDefinition(t){var n;const r=cr(null!==(n=t.variableDefinitions)&&void 0!==n?n:[],(e=>e.variable.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new h(`There can be only one variable named "$${t}".`,{nodes:n.map((e=>e.variable.name))}))}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:i}of r){const r=i.name.value;!0!==t[r]&&e.reportError(new h(n.name?`Variable "$${r}" is not defined by operation "${n.name.value}".`:`Variable "$${r}" is not defined.`,{nodes:[i,n]}))}}},VariableDefinition(e){t[e.variable.name.value]=!0}}},function(e){let t=[];return{OperationDefinition:{enter(){t=[]},leave(n){const r=Object.create(null),i=e.getRecursiveVariableUsages(n);for(const{node:e}of i)r[e.name.value]=!0;for(const i of t){const t=i.variable.name.value;!0!==r[t]&&e.reportError(new h(n.name?`Variable "$${t}" is never used in operation "${n.name.value}".`:`Variable "$${t}" is never used.`,{nodes:i}))}}},VariableDefinition(e){t.push(e)}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Mt;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===O.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map((e=>e.value)));return{Directive(n,r,i,s,o){const a=n.name.value,c=t[a];if(!c)return void e.reportError(new h(`Unknown directive "@${a}".`,{nodes:n}));const l=function(e){const t=e[e.length-1];switch("kind"in t||u(!1),t.kind){case O.OPERATION_DEFINITION:return function(e){switch(e){case I.QUERY:return b.QUERY;case I.MUTATION:return b.MUTATION;case I.SUBSCRIPTION:return b.SUBSCRIPTION}}(t.operation);case O.FIELD:return b.FIELD;case O.FRAGMENT_SPREAD:return b.FRAGMENT_SPREAD;case O.INLINE_FRAGMENT:return b.INLINE_FRAGMENT;case O.FRAGMENT_DEFINITION:return b.FRAGMENT_DEFINITION;case O.VARIABLE_DEFINITION:return b.VARIABLE_DEFINITION;case O.SCHEMA_DEFINITION:case O.SCHEMA_EXTENSION:return b.SCHEMA;case O.SCALAR_TYPE_DEFINITION:case O.SCALAR_TYPE_EXTENSION:return b.SCALAR;case O.OBJECT_TYPE_DEFINITION:case O.OBJECT_TYPE_EXTENSION:return b.OBJECT;case O.FIELD_DEFINITION:return b.FIELD_DEFINITION;case O.INTERFACE_TYPE_DEFINITION:case O.INTERFACE_TYPE_EXTENSION:return b.INTERFACE;case O.UNION_TYPE_DEFINITION:case O.UNION_TYPE_EXTENSION:return b.UNION;case O.ENUM_TYPE_DEFINITION:case O.ENUM_TYPE_EXTENSION:return b.ENUM;case O.ENUM_VALUE_DEFINITION:return b.ENUM_VALUE;case O.INPUT_OBJECT_TYPE_DEFINITION:case O.INPUT_OBJECT_TYPE_EXTENSION:return b.INPUT_OBJECT;case O.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||u(!1),t.kind===O.INPUT_OBJECT_TYPE_DEFINITION?b.INPUT_FIELD_DEFINITION:b.ARGUMENT_DEFINITION}default:u(!1,"Unexpected kind: "+ee(t.kind))}}(o);l&&!c.includes(l)&&e.reportError(new h(`Directive "@${a}" may not be used on ${l}.`,{nodes:n}))}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():Mt;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===O.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);const s=Object.create(null),o=Object.create(null);return{enter(n){if(!("directives"in n)||!n.directives)return;let r;if(n.kind===O.SCHEMA_DEFINITION||n.kind===O.SCHEMA_EXTENSION)r=s;else if(An(n)||Dn(n)){const e=n.name.value;r=o[e],void 0===r&&(o[e]=r=Object.create(null))}else r=Object.create(null);for(const i of n.directives){const n=i.name.value;t[n]&&(r[n]?e.reportError(new h(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}},function(e){return{...xn(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,s=ve(n,r.args.map((e=>e.name)));e.reportError(new h(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+ce(s),{nodes:t}))}}}},function(e){return{Field:t,Directive:t};function t(t){var n;const r=cr(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new h(`There can be only one argument named "${t}".`,{nodes:n.map((e=>e.name))}))}},function(e){return{ListValue(t){if(!qe(et(e.getParentInputType())))return ur(e,t),!1},ObjectValue(t){const n=nt(e.getInputType());if(!Ge(n))return ur(e,t),!1;const r=le(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&Nt(i)){const r=ee(i.type);e.reportError(new h(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,{nodes:t}))}}},ObjectField(t){const n=nt(e.getParentInputType());if(!e.getInputType()&&Ge(n)){const r=ve(t.name.value,Object.keys(n.getFields()));e.reportError(new h(`Field "${t.name.value}" is not defined by type "${n.name}".`+ce(r),{nodes:t}))}},NullValue(t){const n=e.getInputType();Je(n)&&e.reportError(new h(`Expected value of type "${ee(n)}", found ${we(t)}.`,{nodes:t}))},EnumValue:t=>ur(e,t),IntValue:t=>ur(e,t),FloatValue:t=>ur(e,t),StringValue:t=>ur(e,t),BooleanValue:t=>ur(e,t)}},function(e){return{...qn(e),Field:{leave(t){var n;const r=e.getFieldDef();if(!r)return!1;const i=new Set(null===(n=t.arguments)||void 0===n?void 0:n.map((e=>e.name.value)));for(const n of r.args)if(!i.has(n.name)&&ft(n)){const i=ee(n.type);e.reportError(new h(`Field "${r.name}" argument "${n.name}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}},function(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){const r=e.getRecursiveVariableUsages(n);for(const{node:n,type:i,defaultValue:s}of r){const r=n.name.value,o=t[r];if(o&&i){const t=e.getSchema(),a=bn(t,o.type);if(a&&!lr(t,a,o.defaultValue,i,s)){const t=ee(a),s=ee(i);e.reportError(new h(`Variable "$${r}" of type "${t}" used in position expecting type "${s}".`,{nodes:[o,n]}))}}}}},VariableDefinition(e){t[e.variable.name.value]=e}}},function(e){const t=new Gn,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const s=[],[o,a]=Mn(e,t,r,i);if(function(e,t,n,r,i){for(const[s,o]of Object.entries(i))if(o.length>1)for(let i=0;i<o.length;i++)for(let a=i+1;a<o.length;a++){const c=Vn(e,n,r,!1,s,o[i],o[a]);c&&t.push(c)}}(e,s,t,n,o),0!==a.length)for(let r=0;r<a.length;r++){Ln(e,s,t,n,!1,o,a[r]);for(let i=r+1;i<a.length;i++)$n(e,s,t,n,!1,a[r],a[i])}return s}(e,n,t,e.getParentType(),r);for(const[[t,n],r,s]of i){const i=Fn(n);e.reportError(new h(`Fields "${t}" conflict because ${i}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:r.concat(s)}))}}}},function(e){const t=[];let n=Object.create(null);return{ObjectValue:{enter(){t.push(n),n=Object.create(null)},leave(){const e=t.pop();e||u(!1),n=e}},ObjectField(t){const r=t.name.value;n[r]?e.reportError(new h(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}]);class dr{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}get[Symbol.toStringTag](){return"ASTValidationContext"}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t;if(this._fragments)t=this._fragments;else{t=Object.create(null);for(const e of this.getDocument().definitions)e.kind===O.FRAGMENT_DEFINITION&&(t[e.name.value]=e);this._fragments=t}return t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];const n=[e];let r;for(;r=n.pop();)for(const e of r.selections)e.kind===O.FRAGMENT_SPREAD?t.push(e):e.selectionSet&&n.push(e.selectionSet);this._fragmentSpreads.set(e,t)}return t}getRecursivelyReferencedFragments(e){let t=this._recursivelyReferencedFragments.get(e);if(!t){t=[];const n=Object.create(null),r=[e.selectionSet];let i;for(;i=r.pop();)for(const e of this.getFragmentSpreads(i)){const i=e.name.value;if(!0!==n[i]){n[i]=!0;const e=this.getFragment(i);e&&(t.push(e),r.push(e.selectionSet))}}this._recursivelyReferencedFragments.set(e,t)}return t}}class fr extends dr{constructor(e,t,n,r){super(t,r),this._schema=e,this._typeInfo=n,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}get[Symbol.toStringTag](){return"ValidationContext"}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){const n=[],r=new On(this._schema);_e(e,Sn(r,{VariableDefinition:()=>!1,Variable(e){n.push({node:e,type:r.getInputType(),defaultValue:r.getDefaultValue()})}})),t=n,this._variableUsages.set(e,t)}return t}getRecursiveVariableUsages(e){let t=this._recursiveVariableUsages.get(e);if(!t){t=this.getVariableUsages(e);for(const n of this.getRecursivelyReferencedFragments(e))t=t.concat(this.getVariableUsages(n));this._recursiveVariableUsages.set(e,t)}return t}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}}function hr(e,t,n=pr,r,i=new On(e)){var s;const a=null!==(s=null==r?void 0:r.maxErrors)&&void 0!==s?s:100;t||o(!1,"Must provide document."),un(e);const c=Object.freeze({}),u=[],l=new fr(e,t,i,(e=>{if(u.length>=a)throw u.push(new h("Too many validation errors, error limit reached. Validation aborted.")),c;u.push(e)})),p=function(e){const t=new Array(e.length).fill(null),n=Object.create(null);for(const r of Object.values(O)){let i=!1;const s=new Array(e.length).fill(void 0),o=new Array(e.length).fill(void 0);for(let t=0;t<e.length;++t){const{enter:n,leave:a}=Se(e[t],r);i||(i=null!=n||null!=a),s[t]=n,o[t]=a}if(!i)continue;const a={enter(...n){const r=n[0];for(let o=0;o<e.length;o++)if(null===t[o]){var i;const a=null===(i=s[o])||void 0===i?void 0:i.apply(e[o],n);if(!1===a)t[o]=r;else if(a===Oe)t[o]=Oe;else if(void 0!==a)return a}},leave(...n){const r=n[0];for(let s=0;s<e.length;s++)if(null===t[s]){var i;const r=null===(i=o[s])||void 0===i?void 0:i.apply(e[s],n);if(r===Oe)t[s]=Oe;else if(void 0!==r&&!1!==r)return r}else t[s]===r&&(t[s]=null)}};n[r]=a}return n}(n.map((e=>e(l))));try{_e(t,Sn(i,p))}catch(e){if(e!==c)throw e}return u}class mr extends Error{constructor(e){super("Unexpected error value: "+ee(e)),this.name="NonErrorThrown",this.thrownValue=e}}function yr(e,t,n){var r;const i=(s=e)instanceof Error?s:new mr(s);var s,o;return o=i,Array.isArray(o.path)?i:new h(i.message,{nodes:null!==(r=i.nodes)&&void 0!==r?r:t,source:i.source,positions:i.positions,path:n,originalError:i})}const vr=function(e){let t;return function(n,r,i){void 0===t&&(t=new WeakMap);let s=t.get(n);void 0===s&&(s=new WeakMap,t.set(n,s));let o=s.get(r);void 0===o&&(o=new WeakMap,s.set(r,o));let a=o.get(i);return void 0===a&&(a=e(n,r,i),o.set(i,a)),a}}(((e,t,n)=>function(e,t,n,r,i){const s=new Map,o=new Set;for(const a of i)a.selectionSet&&sr(e,t,n,r,a.selectionSet,s,o);return s}(e.schema,e.fragments,e.variableValues,t,n)));function Tr(e){arguments.length<2||o(!1,"graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.");const{schema:t,document:n,variableValues:r,rootValue:i}=e;!function(e,t,n){t||o(!1,"Must provide document."),un(e),null==n||c(n)||o(!1,"Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.")}(t,n,r);const s=function(e){var t,n;const{schema:r,document:i,rootValue:s,contextValue:o,variableValues:a,operationName:c,fieldResolver:u,typeResolver:l,subscribeFieldResolver:p}=e;let d;const f=Object.create(null);for(const e of i.definitions)switch(e.kind){case O.OPERATION_DEFINITION:if(null==c){if(void 0!==d)return[new h("Must provide operation name if query contains multiple operations.")];d=e}else(null===(t=e.name)||void 0===t?void 0:t.value)===c&&(d=e);break;case O.FRAGMENT_DEFINITION:f[e.name.value]=e}if(!d)return null!=c?[new h(`Unknown operation named "${c}".`)]:[new h("Must provide an operation.")];const m=null!==(n=d.variableDefinitions)&&void 0!==n?n:[],y=er(r,m,null!=a?a:{},{maxErrors:50});if(y.errors)return y.errors;return{schema:r,fragments:f,rootValue:s,contextValue:o,operation:d,variableValues:y.coerced,fieldResolver:null!=u?u:Ar,typeResolver:null!=l?l:wr,subscribeFieldResolver:null!=p?p:Ar,errors:[]}}(e);if(!("schema"in s))return{errors:s};try{const{operation:e}=s,t=function(e,t,n){const r=e.schema.getRootType(t.operation);if(null==r)throw new h(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});const i=ir(e.schema,e.fragments,e.variableValues,r,t.selectionSet),s=void 0;switch(t.operation){case I.QUERY:return gr(e,r,n,s,i);case I.MUTATION:return function(e,t,n,r,i){return function(e,t,n){let r=n;for(const n of e)r=a(r)?r.then((e=>t(e,n))):t(r,n);return r}(i.entries(),((i,[s,o])=>{const c=Qn(r,s,t.name),u=Nr(e,t,n,o,c);return void 0===u?i:a(u)?u.then((e=>(i[s]=e,i))):(i[s]=u,i)}),Object.create(null))}(e,r,n,s,i);case I.SUBSCRIPTION:return gr(e,r,n,s,i)}}(s,e,i);return a(t)?t.then((e=>Er(e,s.errors)),(e=>(s.errors.push(e),Er(null,s.errors)))):Er(t,s.errors)}catch(e){return s.errors.push(e),Er(null,s.errors)}}function Er(e,t){return 0===t.length?{data:e}:{errors:t,data:e}}function gr(e,t,n,r,i){const s=Object.create(null);let o=!1;for(const[c,u]of i.entries()){const i=Nr(e,t,n,u,Qn(r,c,t.name));void 0!==i&&(s[c]=i,a(i)&&(o=!0))}return o?(c=s,Promise.all(Object.values(c)).then((e=>{const t=Object.create(null);for(const[n,r]of Object.keys(c).entries())t[r]=e[n];return t}))):s;var c}function Nr(e,t,n,r,i){var s;const o=function(e,t,n){const r=n.name.value;if(r===Zt.name&&e.getQueryType()===t)return Zt;if(r===en.name&&e.getQueryType()===t)return en;if(r===tn.name)return tn;return t.getFields()[r]}(e.schema,t,r[0]);if(!o)return;const c=o.type,u=null!==(s=o.resolve)&&void 0!==s?s:e.fieldResolver,l=function(e,t,n,r,i){return{fieldName:t.name,fieldNodes:n,returnType:t.type,parentType:r,path:i,schema:e.schema,fragments:e.fragments,rootValue:e.rootValue,operation:e.operation,variableValues:e.variableValues}}(e,o,r,t,i);try{const t=tr(o,r[0],e.variableValues),s=u(n,t,e.contextValue,l);let p;return p=a(s)?s.then((t=>br(e,c,r,l,i,t))):br(e,c,r,l,i,s),a(p)?p.then(void 0,(t=>Ir(yr(t,r,Kn(i)),c,e))):p}catch(t){return Ir(yr(t,r,Kn(i)),c,e)}}function Ir(e,t,n){if(Je(t))throw e;return n.errors.push(e),null}function br(e,t,n,r,i,s){if(s instanceof Error)throw s;if(Je(t)){const o=br(e,t.ofType,n,r,i,s);if(null===o)throw new Error(`Cannot return null for non-nullable field ${r.parentType.name}.${r.fieldName}.`);return o}return null==s?null:qe(t)?function(e,t,n,r,i,s){if(!Pt(s))throw new h(`Expected Iterable, but did not find one for field "${r.parentType.name}.${r.fieldName}".`);const o=t.ofType;let c=!1;const u=Array.from(s,((t,s)=>{const u=Qn(i,s,void 0);try{let i;return i=a(t)?t.then((t=>br(e,o,n,r,u,t))):br(e,o,n,r,u,t),a(i)?(c=!0,i.then(void 0,(t=>Ir(yr(t,n,Kn(u)),o,e)))):i}catch(t){return Ir(yr(t,n,Kn(u)),o,e)}}));return c?Promise.all(u):u}(e,t,n,r,i,s):Ke(t)?function(e,t){const n=e.serialize(t);if(null==n)throw new Error(`Expected \`${ee(e)}.serialize(${ee(t)})\` to return non-nullable value, returned: ${ee(n)}`);return n}(t,s):Xe(t)?function(e,t,n,r,i,s){var o;const c=null!==(o=t.resolveType)&&void 0!==o?o:e.typeResolver,u=e.contextValue,l=c(s,u,r,t);if(a(l))return l.then((o=>_r(e,Or(o,e,t,n,r,s),n,r,i,s)));return _r(e,Or(l,e,t,n,r,s),n,r,i,s)}(e,t,n,r,i,s):je(t)?_r(e,t,n,r,i,s):void u(!1,"Cannot complete value of unexpected output type: "+ee(t))}function Or(e,t,n,r,i,s){if(null==e)throw new h(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}". Either the "${n.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,r);if(je(e))throw new h("Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.");if("string"!=typeof e)throw new h(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${ee(s)}, received "${ee(e)}".`);const o=t.schema.getType(e);if(null==o)throw new h(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!je(o))throw new h(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw new h(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function _r(e,t,n,r,i,s){const o=vr(e,t,n);if(t.isTypeOf){const c=t.isTypeOf(s,e.contextValue,r);if(a(c))return c.then((r=>{if(!r)throw Sr(t,s,n);return gr(e,t,s,i,o)}));if(!c)throw Sr(t,s,n)}return gr(e,t,s,i,o)}function Sr(e,t,n){return new h(`Expected value of type "${e.name}" but got: ${ee(t)}.`,{nodes:n})}const wr=function(e,t,n,r){if(c(e)&&"string"==typeof e.__typename)return e.__typename;const i=n.schema.getPossibleTypes(r),s=[];for(let r=0;r<i.length;r++){const o=i[r];if(o.isTypeOf){const i=o.isTypeOf(e,t,n);if(a(i))s[r]=i;else if(i)return o.name}}return s.length?Promise.all(s).then((e=>{for(let t=0;t<e.length;t++)if(e[t])return i[t].name})):void 0},Ar=function(e,t,n,r){if(c(e)||"function"==typeof e){const i=e[r.fieldName];return"function"==typeof i?e[r.fieldName](t,n,r):i}};const Dr={base64Binary:Dt,boolean:xt,canonical:Dt,code:Dt,date:Dt,dateTime:Dt,decimal:At,id:Rt,instant:Dt,integer:At,markdown:Dt,number:At,positiveInt:At,string:Dt,time:Dt,unsignedInt:At,uri:Dt,url:Dt,xhtml:Dt,"http://hl7.org/fhirpath/System.Boolean":xt,"http://hl7.org/fhirpath/System.Date":Dt,"http://hl7.org/fhirpath/System.DateTime":Dt,"http://hl7.org/fhirpath/System.Decimal":At,"http://hl7.org/fhirpath/System.Integer":At,"http://hl7.org/fhirpath/System.String":Dt,"http://hl7.org/fhirpath/System.Time":Dt},xr=new t.LRUCache;let Rr;async function kr(e,r){const{query:i,operationName:s,variables:o}=e.body;if(!i)return[t.badRequest("Must provide query.")];let a;try{a=new ie(i,c).parseDocument()}catch(e){return[t.badRequest("GraphQL syntax error.")]}var c;const u=function(){Rr||(Rr=function(){for(const e of t.getResourceTypes())Dr[e]=Lr(e);const e={};for(const n of t.getResourceTypes()){const t=Fr(n);e[n]={type:t,args:{id:{type:new We(Rt),description:n+" ID"}},resolve:Br},e[n+"List"]={type:new He(t),args:Vr(n),resolve:Mr},e[n+"Connection"]={type:jr(n,t),args:Vr(n),resolve:Pr}}return new on({query:new ot({name:"QueryType",fields:e})})}());return Rr}(),l=hr(u,a,[...pr,Kr]);if(l.length>0)return[(p=l,{resourceType:"OperationOutcome",issue:p.map((e=>({severity:"error",code:"invalid",details:{text:e.message}})))})];var p;const d=function(e){return e.includes("query IntrospectionQuery")||e.includes("__schema")||e.includes("__type")}(i);if(d)return[t.forbidden];const f=new n((e=>r.readReferences(e)));let h=d&&xr.get(i);return h||(h=await Tr({schema:u,document:a,contextValue:{repo:r,dataLoader:f},operationName:s,variableValues:o})),[t.allOk,h]}function Fr(e){let t=Dr[e];return t||(t=Lr(e),Dr[e]=t),t}function Lr(e){if("ResourceList"===e)return new mt({name:"ResourceList",types:()=>t.getResourceTypes().map(Fr).filter((e=>!!e)),resolveType:qr});const n=t.getResourceTypeSchema(e);return new ot({name:e,description:n.description,fields:()=>function(e){const n={};return function(e,n){const r=t.getResourceTypeSchema(e),i=r.properties;t.isResourceTypeSchema(r)&&(n.resourceType={type:new We(Dt),description:"Resource Type"});"Reference"===e&&(n.resource={description:"Reference",type:Fr("ResourceList"),resolve:Gr});for(const r of Object.keys(i)){const i=t.getElementDefinition(e,r);for(const e of i.type)$r(n,r,i,e)}}(e,n),function(e,n){for(const r of t.getResourceTypes()){const i=Fr(r),s=t.getSearchParameters(r),o={};let a=0;if(s)for(const[t,n]of Object.entries(s))n.target&&n.target.includes(e)&&(o[Qr(t)]={value:t},a++);if(a>0){const t=new vt({name:e+"_"+r+"_reference",values:o}),s=Vr(r);s._reference={type:new We(t),description:`Specify which property to use for reverse lookup for ${r}`},n[r+"List"]={type:new He(i),args:s,resolve:Mr}}}}(e,n),n}(e)})}function $r(e,n,r,i){let s=i.code;"Element"!==s&&"BackboneElement"!==s||(s=t.buildTypeName(r.path?.split(".")));const o={description:r.short,type:Ur(r,s),resolve:Jr};"*"===r.max&&(o.args=function(e){const n={_count:{type:wt,description:"Specify how many elements to return from a repeating list."},_offset:{type:wt,description:"Specify the offset to start at for a repeating element."}};if(!t.isLowerCase(e.charAt(0))){n.fhirpath={type:Dt,description:"A FHIRPath statement selecting which of the subnodes is to be included"};const r=t.globalSchema.types[e];if(r.properties)for(const i of Object.keys(r.properties)){const r=t.getElementDefinition(e,i);for(const e of r.type)Cr(n,i,r,e)}}return n}(s));e[n.replace("[x]",t.capitalize(i.code))]=o}function Cr(e,n,r,i){const s=i.code,o=n.replace("[x]",t.capitalize(s));switch(s){case"canonical":case"code":case"id":case"oid":case"string":case"uri":case"url":case"uuid":case"http://hl7.org/fhirpath/System.String":e[o]={type:Dt,description:r.short}}}function Vr(e){const n={_count:{type:wt,description:"Specify how many elements to return from a repeating list."},_offset:{type:wt,description:"Specify the offset to start at for a repeating element."},_sort:{type:Dt,description:"Specify the sort order by comma-separated list of sort rules in priority order."},_id:{type:Dt,description:"Select resources based on the logical id of the resource."},_lastUpdated:{type:Dt,description:"Select resources based on the last time they were changed."}},r=t.getSearchParameters(e);if(r)for(const[e,t]of Object.entries(r))n[Qr(e)]={type:Dt,description:t.description};return n}function Ur(e,t){const n=Fr(t);return"*"===e.max?new He(n):n}function jr(e,t){return new ot({name:e+"Connection",fields:{count:{type:wt},offset:{type:wt},pageSize:{type:wt},first:{type:Dt},previous:{type:Dt},next:{type:Dt},last:{type:Dt},edges:{type:new He(new ot({name:e+"ConnectionEdge",fields:{mode:{type:Dt},score:{type:At},resource:{type:t}}}))}}})}async function Mr(e,t,n,r){const i=r.fieldName,s=Yr(i.substring(0,i.length-4),e,t),o=await n.repo.search(s);return o.entry?.map((e=>e.resource))}async function Pr(e,n,r,i){const s=i.fieldName,o=Yr(s.substring(0,s.length-10),e,n);(function(e,t){return e.fieldNodes.some((e=>e.selectionSet?.selections.some((e=>"Field"===e.kind&&e.name.value===t))))})(i,"count")&&(o.total="accurate");const a=await r.repo.search(o);return{count:a.total,offset:o.offset||0,pageSize:o.count||t.DEFAULT_SEARCH_COUNT,edges:a.entry?.map((e=>({mode:e.search?.mode,score:e.search?.score,resource:e.resource})))}}async function Br(e,n,r,i){try{return await r.dataLoader.load({reference:`${i.fieldName}/${n.id}`})}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e),e)}}async function Gr(e,n,r){try{return await r.dataLoader.load(e)}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e),e)}}function qr(e){const t=e?.resourceType;if(t)return Fr(t).name}async function Jr(e,n,r,i){const s=e?.[i.fieldName];if(!n||!s)return s;const{_offset:o,_count:a,fhirpath:c,...u}=n;let l=s;for(const[e,t]of Object.entries(u))l=l.filter((n=>n[e]===t));return c&&(l=l.filter((e=>t.toJsBoolean(t.evalFhirPathTyped(c,[t.toTypedValue(e)]))))),o&&(l=l.slice(o)),a&&(l=l.slice(0,a)),l}function Yr(e,n,r){let i;if(n){const e=r._reference;delete r._reference,i={code:e,operator:t.Operator.EQUALS,value:t.getReferenceString(n)}}r=Object.fromEntries(Object.entries(r).map((([e,t])=>{return[(n=e,n.startsWith("_")?n:n.replaceAll("_","-")),t];var n})));const s=t.parseSearchRequest(e,r);if(i){const e=s.filters||[];s.filters=[i,...e]}return s}function Qr(e){return e.replaceAll("-","_")}const Kr=e=>({Field(t,n,r,i){const s=function(e){return e.filter((e=>"selections"===e)).length}(i);if(s>12){const n=t.name.value;e.reportError(new h(`Field "${n}" exceeds max depth (depth=${s}, max=12)`,{nodes:t}))}}});class zr{constructor(){this.routes=[]}add(e,t,n){const r=t.split("/").filter((e=>!!e)).map((e=>e.startsWith(":")?{value:e.substring(1),param:!0}:{value:e}));this.routes.push({method:e,path:r,handler:n})}find(e,t){const n=t.split("/").filter((e=>!!e));let r,i=-1;for(const t of this.routes){const s=Xr(t,e,n);s>i&&(r=t,i=s)}if(r)return{handler:r.handler,params:Hr(r,n)}}}function Xr(e,t,n){if(t!==e.method||n.length!==e.path.length)return-1;let r=0;for(let t=0;t<n.length;t++)if(!e.path[t].param){if(n[t]!==e.path[t].value)return-1;r++}return r}function Hr(e,t){const n=Object.create(null);for(let r=0;r<t.length;r++)e.path[r].param&&(n[e.path[r].value]=t[r]);return n}async function Wr(e,n,r){const s=e.body;if("Bundle"!==s.resourceType)return[t.badRequest("Not a bundle")];const o=await async function(e,t,n){return new i(e,t,n).processBatch()}(r,n,s);return[t.allOk,o]}async function Zr(e,n){const{resourceType:r}=e.params,i=e.query,s=await n.search(t.parseSearchRequest(r,i));return[t.allOk,s]}async function ei(e,n){const{resourceType:r}=e.params,i=e.body,s=await n.search(t.parseSearchRequest(r,i));return[t.allOk,s]}async function ti(e,n){const{resourceType:r}=e.params,i=e.body;if(i.resourceType!==r)return[t.badRequest("Incorrect resource type")];const s=await n.createResource(i);return[t.created,s]}async function ni(e,n){const{resourceType:r,id:i}=e.params,s=await n.readResource(r,i);return[t.allOk,s]}async function ri(e,n){const{resourceType:r,id:i}=e.params,s=await n.readHistory(r,i);return[t.allOk,s]}async function ii(e,n){const{resourceType:r,id:i,vid:s}=e.params,o=await n.readVersion(r,i,s);return[t.allOk,o]}async function si(e,n){const{resourceType:r,id:i}=e.params,s=e.body;if(s.resourceType!==r)return[t.badRequest("Incorrect resource type")];if(s.id!==i)return[t.badRequest("Incorrect ID")];const o=await n.updateResource(s);return[t.allOk,o]}async function oi(e,n){const{resourceType:r,id:i}=e.params;return await n.deleteResource(r,i),[t.allOk]}async function ai(e,n){const{resourceType:r,id:i}=e.params,s=e.body,o=await n.patchResource(r,i,s);return[t.allOk,o]}class ci{async searchOne(e){const t=await this.search({...e,count:1});return t.entry?.[0]?.resource}async searchResources(e){const t=await this.search(e);return t.entry?.map((e=>e.resource))||[]}}const ui=(e,n,r)=>{const i=t.globalSchema.types[e.resourceType]?.searchParams?.[r.code],s=i?.expression;if(!s)return 0;const o=JSON.stringify(t.evalFhirPath(s,e)),a=JSON.stringify(t.evalFhirPath(s,n));return o.localeCompare(a)*(r.descending?-1:1)},li=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));e.BaseRepository=ci,e.FhirRouter=class{constructor(){this.router=new zr,this.router.add("POST","",Wr),this.router.add("GET",":resourceType",Zr),this.router.add("POST",":resourceType/_search",ei),this.router.add("POST",":resourceType",ti),this.router.add("GET",":resourceType/:id",ni),this.router.add("GET",":resourceType/:id/_history",ri),this.router.add("GET",":resourceType/:id/_history/:vid",ii),this.router.add("PUT",":resourceType/:id",si),this.router.add("DELETE",":resourceType/:id",oi),this.router.add("PATCH",":resourceType/:id",ai),this.router.add("POST","$graphql",kr)}async handleRequest(e,n){const r=this.router.find(e.method,e.pathname);if(!r)return[t.notFound];const{handler:i,params:s}=r;return e.params=s,i(e,n,this)}},e.MemoryRepository=class extends ci{constructor(){super(),this.resources=new Map,this.history=new Map}async createResource(e){const n=t.deepClone(e);n.id||(n.id=li()),n.meta||(n.meta={}),n.meta?.versionId||(n.meta.versionId=li()),n.meta?.lastUpdated||(n.meta.lastUpdated=(new Date).toISOString());const{resourceType:r,id:i}=n;let s=this.resources.get(r);s||(s=new Map,this.resources.set(r,s)),s.set(i,n);let o=this.history.get(r);o||(o=new Map,this.history.set(r,o));let a=o.get(i);return a||(a=[],o.set(i,a)),a.push(n),t.deepClone(n)}updateResource(e){const n=t.deepClone(e);return n.meta&&(n.meta.versionId&&delete n.meta.versionId,n.meta.lastUpdated&&delete n.meta.lastUpdated),this.createResource(n)}async patchResource(e,n,i){const s=await this.readResource(e,n);try{const e=r.applyPatch(s,i).filter(Boolean);if(e.length>0)throw new t.OperationOutcomeError(t.badRequest(e.map((e=>e.message)).join("\n")))}catch(e){throw new t.OperationOutcomeError(t.normalizeOperationOutcome(e))}return this.updateResource(s)}async readResource(e,n){const r=this.resources.get(e)?.get(n);if(!r)throw new t.OperationOutcomeError(t.notFound);return t.deepClone(r)}async readReference(e){const n=e.reference?.split("/");if(!n||2!==n.length)throw new t.OperationOutcomeError(t.badRequest("Invalid reference"));return this.readResource(n[0],n[1])}async readReferences(e){return Promise.all(e.map((e=>this.readReference(e))))}async readHistory(e,n){return await this.readResource(e,n),{resourceType:"Bundle",type:"history",entry:(this.history.get(e)?.get(n)||[]).reverse().map((e=>({resource:t.deepClone(e)})))}}async readVersion(e,n,r){await this.readResource(e,n);const i=this.history.get(e)?.get(n)?.find((e=>e.meta?.versionId===r));if(!i)throw new t.OperationOutcomeError(t.notFound);return t.deepClone(i)}async search(e){const{resourceType:n}=e,r=this.resources.get(n)||new Map,i=[];for(const n of r.values())t.matchesSearchRequest(n,e)&&i.push(n);let s=i.map((e=>({resource:t.deepClone(e)})));if(e.sortRules)for(const t of e.sortRules)s=s.sort(((e,n)=>ui(e.resource,n.resource,t)));return void 0!==e.offset&&(s=s.slice(e.offset)),void 0!==e.count&&(s=s.slice(0,e.count)),{resourceType:"Bundle",type:"searchset",entry:s,total:i.length}}async deleteResource(e,n){if(!this.resources.get(e)?.get(n))throw new t.OperationOutcomeError(t.notFound);this.resources.get(e)?.delete(n)}},e.Router=zr}));
2
2
  //# sourceMappingURL=index.min.cjs.map