@medplum/fhir-router 2.0.19 → 2.0.21

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
- import{OperationOutcomeError as e,badRequest as t,normalizeOperationOutcome as n,parseSearchUrl as r,getReferenceString as i,resolveId as s,getStatus as o,isOk as a,allOk as c,LRUCache as u,forbidden as l,getResourceTypes as p,getResourceTypeSchema as d,isResourceTypeSchema as f,getElementDefinition as h,buildTypeName as m,capitalize as y,isLowerCase as v,globalSchema as T,getSearchParameters as E,DEFAULT_SEARCH_COUNT as g,toJsBoolean as N,evalFhirPathTyped as I,toTypedValue as b,Operator as _,parseSearchRequest as O,notFound as S,created as w,deepClone as A,matchesSearchRequest as D,evalFhirPath as x}from"@medplum/core";import k from"dataloader";import{applyPatch as R}from"rfc6902";class F{constructor(e,t,n){this.router=e,this.repo=t,this.bundle=n,this.ids={}}async processBatch(){const r=this.bundle.type;if(!r)throw new e(t("Missing bundle type"));if("batch"!==r&&"transaction"!==r)throw new e(t("Unrecognized bundle type"));const i=this.bundle.entry;if(!i)throw new e(t("Missing bundle entry"));const s=[];for(const e of i){const t=this.rewriteIdsInObject(e);e?.resource?.id&&(t.resource.id=this.rewriteIdsInString(e.resource.id,!0));try{s.push(await this.processBatchEntry(t))}catch(e){s.push(L(n(e)))}}return{resourceType:"Bundle",type:r+"-response",entry:s}}async processBatchEntry(e){this.validateEntry(e);const n=e.request;if(e.resource?.resourceType&&n.ifNoneExist){const i=`https://example.com/${e.resource.resourceType}`,s=new URL("?"+n.ifNoneExist,i),o=await this.repo.search(r(s)),a=o?.entry;if(a.length>1)return L(t("Multiple matches"));if(1===a.length){const t=a[0].resource;return e.fullUrl&&this.addReplacementId(e.fullUrl,t),L(c,t)}}let i=e.resource;"PATCH"===n.method&&(i=this.parsePatchBody(e));const s=new URL(n.url,"https://example.com/"),o=await this.router.handleRequest({method:n.method,pathname:s.pathname,params:Object.create(null),query:Object.fromEntries(s.searchParams),body:i},this.repo);return e.fullUrl&&2===o.length&&this.addReplacementId(e.fullUrl,o[1]),L(o[0],o[1])}validateEntry(n){if(!n.request)throw new e(t("Missing entry.request"));if(!n.request.method)throw new e(t("Missing entry.request.method"));if(!n.request.url)throw new e(t("Missing entry.request.url"))}parsePatchBody(n){const r=n.resource;if(!r)throw new e(t("Missing entry.resource"));if("Binary"!==r.resourceType)throw new e(t("Patch resource must be a Binary"));if(!r.data)throw new e(t("Missing entry.resource.data"));return JSON.parse(Buffer.from(r.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,t=!1){const n=e.match(/urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);if(n){const r=n[0],o=this.ids[r];if(o){let n=i(o);return t&&(n=s({reference:n})),n?e.replaceAll(r,n):e}}return e}}function L(e,t){return{response:{outcome:e,status:o(e).toString(),location:a(e)&&t?.id?i(t):void 0},resource:t}}function $(e,t){if(!Boolean(e))throw new Error(t)}function C(e){return"function"==typeof(null==e?void 0:e.then)}function V(e){return"object"==typeof e&&null!==e}function U(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}const j=/\r\n|[\n\r]/g;function M(e,t){let n=0,r=1;for(const i of e.body.matchAll(j)){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 P(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+B([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return u+B([[o-1+" |",l[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,l[i+1]]])}function B(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 G extends Error{constructor(e,...t){var n,r,i;const{nodes:s,source:o,positions:a,path:c,originalError:u,extensions:l}=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!=c?c:void 0,this.originalError=null!=u?u:void 0,this.nodes=J(Array.isArray(s)?s:s?[s]:void 0);const p=J(null===(n=this.nodes)||void 0===n?void 0:n.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=o?o:null==p||null===(r=p[0])||void 0===r?void 0:r.source,this.positions=null!=a?a:null==p?void 0:p.map((e=>e.start)),this.locations=a&&o?a.map((e=>M(o,e))):null==p?void 0:p.map((e=>M(e.source,e.start)));const d=V(null==u?void 0:u.extensions)?null==u?void 0:u.extensions:void 0;this.extensions=null!==(i=null!=l?l:d)&&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!=u&&u.stack?Object.defineProperty(this,"stack",{value:u.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,G):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"+P((t=n.loc).source,M(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+P(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 J(e){return void 0===e||0===e.length?void 0:e}function Y(e,t,n){return new G(`Syntax Error: ${n}`,{source:e,positions:[t]})}class Q{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 q{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 K={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"]},z=new Set(Object.keys(K));function X(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&z.has(t)}var H,W,Z,ee;function te(e){return 9===e||32===e}function ne(e){return e>=48&&e<=57}function re(e){return e>=97&&e<=122||e>=65&&e<=90}function ie(e){return re(e)||95===e}function se(e){return re(e)||ne(e)||95===e}function oe(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=ae(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 ae(e){let t=0;for(;t<e.length&&te(e.charCodeAt(t));)++t;return t}!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(H||(H={})),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"}(W||(W={})),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"}(Z||(Z={})),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"}(ee||(ee={}));class ce{constructor(e){const t=new q(ee.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!==ee.EOF)do{if(e.next)e=e.next;else{const t=me(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===ee.COMMENT);return e}}function ue(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function le(e,t){return pe(e.charCodeAt(t))&&de(e.charCodeAt(t+1))}function pe(e){return e>=55296&&e<=56319}function de(e){return e>=56320&&e<=57343}function fe(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return ee.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function he(e,t,n,r,i){const s=e.line,o=1+n-e.lineStart;return new q(t,n,r,s,o,i)}function me(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 ye(e,i);case 33:return he(e,ee.BANG,i,i+1);case 36:return he(e,ee.DOLLAR,i,i+1);case 38:return he(e,ee.AMP,i,i+1);case 40:return he(e,ee.PAREN_L,i,i+1);case 41:return he(e,ee.PAREN_R,i,i+1);case 46:if(46===n.charCodeAt(i+1)&&46===n.charCodeAt(i+2))return he(e,ee.SPREAD,i,i+3);break;case 58:return he(e,ee.COLON,i,i+1);case 61:return he(e,ee.EQUALS,i,i+1);case 64:return he(e,ee.AT,i,i+1);case 91:return he(e,ee.BRACKET_L,i,i+1);case 93:return he(e,ee.BRACKET_R,i,i+1);case 123:return he(e,ee.BRACE_L,i,i+1);case 124:return he(e,ee.PIPE,i,i+1);case 125:return he(e,ee.BRACE_R,i,i+1);case 34:return 34===n.charCodeAt(i+1)&&34===n.charCodeAt(i+2)?Oe(e,i):Ee(e,i)}if(ne(t)||45===t)return ve(e,i,t);if(ie(t))return Se(e,i);throw Y(e.source,i,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":ue(t)||le(n,i)?`Unexpected character: ${fe(e,i)}.`:`Invalid character: ${fe(e,i)}.`)}return he(e,ee.EOF,r,r)}function ye(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(ue(e))++i;else{if(!le(n,i))break;i+=2}}return he(e,ee.COMMENT,t,i,n.slice(t+1,i))}function ve(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),ne(s))throw Y(e.source,i,`Invalid number, unexpected digit after 0: ${fe(e,i)}.`)}else i=Te(e,i,s),s=r.charCodeAt(i);if(46===s&&(o=!0,s=r.charCodeAt(++i),i=Te(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=Te(e,i,s),s=r.charCodeAt(i)),46===s||ie(s))throw Y(e.source,i,`Invalid number, expected digit but got: ${fe(e,i)}.`);return he(e,o?ee.FLOAT:ee.INT,t,i,r.slice(t,i))}function Te(e,t,n){if(!ne(n))throw Y(e.source,t,`Invalid number, expected digit but got: ${fe(e,t)}.`);const r=e.source.body;let i=t+1;for(;ne(r.charCodeAt(i));)++i;return i}function Ee(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),he(e,ee.STRING,t,i+1,o);if(92!==r){if(10===r||13===r)break;if(ue(r))++i;else{if(!le(n,i))throw Y(e.source,i,`Invalid character within String: ${fe(e,i)}.`);i+=2}}else{o+=n.slice(s,i);const t=117===n.charCodeAt(i+1)?123===n.charCodeAt(i+2)?ge(e,i):Ne(e,i):_e(e,i);o+=t.value,i+=t.size,s=i}}throw Y(e.source,i,"Unterminated string.")}function ge(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||!ue(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|be(e),r<0)break}throw Y(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function Ne(e,t){const n=e.source.body,r=Ie(n,t+2);if(ue(r))return{value:String.fromCodePoint(r),size:6};if(pe(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=Ie(n,t+8);if(de(e))return{value:String.fromCodePoint(r,e),size:12}}throw Y(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function Ie(e,t){return be(e.charCodeAt(t))<<12|be(e.charCodeAt(t+1))<<8|be(e.charCodeAt(t+2))<<4|be(e.charCodeAt(t+3))}function be(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function _e(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 Oe(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=he(e,ee.BLOCK_STRING,t,s+3,oe(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(ue(r))++s;else{if(!le(n,s))throw Y(e.source,s,`Invalid character within String: ${fe(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 Se(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){if(!se(n.charCodeAt(i)))break;++i}return he(e,ee.NAME,t,i,n.slice(t,i))}const we=10,Ae=2;function De(e){return xe(e,[])}function xe(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:xe(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>Ae)return"[Array]";const n=Math.min(we,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(xe(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>Ae)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+": "+xe(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const ke="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=De(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||$(!1,`Body must be a string. Received: ${De(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||$(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||$(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}class Fe{constructor(e,t={}){const n=function(e){return ke(e,Re)}(e)?e:new Re(e);this._lexer=new ce(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(ee.NAME);return this.node(e,{kind:Z.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:Z.DOCUMENT,definitions:this.many(ee.SOF,this.parseDefinition,ee.EOF)})}parseDefinition(){if(this.peek(ee.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===ee.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(ee.BRACE_L))return this.node(e,{kind:Z.OPERATION_DEFINITION,operation:H.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(ee.NAME)&&(n=this.parseName()),this.node(e,{kind:Z.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(ee.NAME);switch(e.value){case"query":return H.QUERY;case"mutation":return H.MUTATION;case"subscription":return H.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(ee.PAREN_L,this.parseVariableDefinition,ee.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:Z.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(ee.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(ee.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(ee.DOLLAR),this.node(e,{kind:Z.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:Z.SELECTION_SET,selections:this.many(ee.BRACE_L,this.parseSelection,ee.BRACE_R)})}parseSelection(){return this.peek(ee.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(ee.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:Z.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(ee.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(ee.PAREN_L,t,ee.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(ee.COLON),this.node(t,{kind:Z.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(ee.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(ee.NAME)?this.node(e,{kind:Z.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:Z.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:Z.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:Z.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 ee.BRACKET_L:return this.parseList(e);case ee.BRACE_L:return this.parseObject(e);case ee.INT:return this.advanceLexer(),this.node(t,{kind:Z.INT,value:t.value});case ee.FLOAT:return this.advanceLexer(),this.node(t,{kind:Z.FLOAT,value:t.value});case ee.STRING:case ee.BLOCK_STRING:return this.parseStringLiteral();case ee.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:Z.BOOLEAN,value:!0});case"false":return this.node(t,{kind:Z.BOOLEAN,value:!1});case"null":return this.node(t,{kind:Z.NULL});default:return this.node(t,{kind:Z.ENUM,value:t.value})}case ee.DOLLAR:if(e){if(this.expectToken(ee.DOLLAR),this._lexer.token.kind===ee.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:Z.STRING,value:e.value,block:e.kind===ee.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:Z.LIST,values:this.any(ee.BRACKET_L,(()=>this.parseValueLiteral(e)),ee.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:Z.OBJECT,fields:this.any(ee.BRACE_L,(()=>this.parseObjectField(e)),ee.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(ee.COLON),this.node(t,{kind:Z.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(ee.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(ee.AT),this.node(t,{kind:Z.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(ee.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(ee.BRACKET_R),t=this.node(e,{kind:Z.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(ee.BANG)?this.node(e,{kind:Z.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:Z.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(ee.STRING)||this.peek(ee.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(ee.BRACE_L,this.parseOperationTypeDefinition,ee.BRACE_R);return this.node(e,{kind:Z.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(ee.COLON);const n=this.parseNamedType();return this.node(e,{kind:Z.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:Z.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:Z.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(ee.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(ee.BRACE_L,this.parseFieldDefinition,ee.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(ee.COLON);const i=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:Z.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:s})}parseArgumentDefs(){return this.optionalMany(ee.PAREN_L,this.parseInputValueDef,ee.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(ee.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(ee.EQUALS)&&(i=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:Z.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:Z.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:Z.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(ee.EQUALS)?this.delimitedMany(ee.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:Z.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(ee.BRACE_L,this.parseEnumValueDefinition,ee.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:Z.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,`${Le(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:Z.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(ee.BRACE_L,this.parseInputValueDef,ee.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===ee.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(ee.BRACE_L,this.parseOperationTypeDefinition,ee.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:Z.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:Z.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:Z.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:Z.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:Z.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:Z.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:Z.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(ee.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:Z.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:s})}parseDirectiveLocations(){return this.delimitedMany(ee.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(W,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new Q(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 ${$e(e)}, found ${Le(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==ee.NAME||t.value!==e)throw Y(this._lexer.source,t.start,`Expected "${e}", found ${Le(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===ee.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 ${Le(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!==ee.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw Y(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function Le(e){const t=e.value;return $e(e.kind)+(null!=t?` "${t}"`:"")}function $e(e){return function(e){return e===ee.BANG||e===ee.DOLLAR||e===ee.AMP||e===ee.PAREN_L||e===ee.PAREN_R||e===ee.SPREAD||e===ee.COLON||e===ee.EQUALS||e===ee.AT||e===ee.BRACKET_L||e===ee.BRACKET_R||e===ee.BRACE_L||e===ee.PIPE||e===ee.BRACE_R}(e)?`"${e}"`:e}const Ce=5;function Ve(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,Ce),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function Ue(e){return e}function je(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function Me(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Pe(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function Be(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-Ge,i=e.charCodeAt(n)}while(Ye(i)&&o>0);let a=0;do{++r,a=10*a+s-Ge,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 Ge=48,Je=57;function Ye(e){return!isNaN(e)&&Ge<=e&&e<=Je}function Qe(e,t){const n=Object.create(null),r=new qe(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:Be(e,t)}))}class qe{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=Ke(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=Ke(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 Ke(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function ze(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 Xe=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function He(e){return We[e.charCodeAt(0)]}const We=["\\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"],Ze=Object.freeze({});function et(e,t,n=K){const r=new Map;for(const e of Object.values(Z))r.set(e,tt(t,e));let i,s,o,a=Array.isArray(e),c=[e],u=-1,l=[],p=e;const d=[],f=[];do{u++;const e=u===c.length,v=e&&0!==l.length;if(e){if(s=0===f.length?void 0:d[d.length-1],p=o,o=f.pop(),v)if(a){p=p.slice();let e=0;for(const[t,n]of l){const r=t-e;null===n?(p.splice(r,1),e++):p[r]=n}}else{p=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));for(const[e,t]of l)p[e]=t}u=i.index,c=i.keys,l=i.edits,a=i.inArray,i=i.prev}else if(o){if(s=a?u:c[u],p=o[s],null==p)continue;d.push(s)}let T;if(!Array.isArray(p)){var h,m;X(p)||$(!1,`Invalid AST Node: ${De(p)}.`);const n=e?null===(h=r.get(p.kind))||void 0===h?void 0:h.leave:null===(m=r.get(p.kind))||void 0===m?void 0:m.enter;if(T=null==n?void 0:n.call(t,p,s,o,d,f),T===Ze)break;if(!1===T){if(!e){d.pop();continue}}else if(void 0!==T&&(l.push([s,T]),!e)){if(!X(T)){d.pop();continue}p=T}}var y;if(void 0===T&&v&&l.push([s,p]),e)d.pop();else i={inArray:a,index:u,keys:c,edits:l,prev:i},a=Array.isArray(p),c=a?p:null!==(y=n[p.kind])&&void 0!==y?y:[],u=-1,l=[],o&&f.push(o),o=p}while(void 0!==i);return 0!==l.length?l[l.length-1][1]:e}function tt(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 nt(e){return et(e,rt)}const rt={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>it(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=ot("(",it(e.variableDefinitions,", "),")"),n=it([e.operation,it([e.name,t]),it(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+ot(" = ",n)+ot(" ",it(r," "))},SelectionSet:{leave:({selections:e})=>st(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=ot("",e,": ")+t;let o=s+ot("(",it(n,", "),")");return o.length>80&&(o=s+ot("(\n",at(it(n,"\n")),"\n)")),it([o,it(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+ot(" ",it(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>it(["...",ot("on ",e),it(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${ot("(",it(n,", "),")")} on ${t} ${ot("",it(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||te(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&&te(e.charCodeAt(0));return(l&&!d||s)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(Xe,He)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+it(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+it(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+ot("(",it(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>ot("",e,"\n")+it(["schema",it(t," "),st(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>ot("",e,"\n")+it(["scalar",t,it(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ot("",e,"\n")+it(["type",t,ot("implements ",it(n," & ")),it(r," "),st(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>ot("",e,"\n")+t+(ct(n)?ot("(\n",at(it(n,"\n")),"\n)"):ot("(",it(n,", "),")"))+": "+r+ot(" ",it(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>ot("",e,"\n")+it([t+": "+n,ot("= ",r),it(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ot("",e,"\n")+it(["interface",t,ot("implements ",it(n," & ")),it(r," "),st(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>ot("",e,"\n")+it(["union",t,it(n," "),ot("= ",it(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>ot("",e,"\n")+it(["enum",t,it(n," "),st(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>ot("",e,"\n")+it([t,it(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>ot("",e,"\n")+it(["input",t,it(n," "),st(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>ot("",e,"\n")+"directive @"+t+(ct(n)?ot("(\n",at(it(n,"\n")),"\n)"):ot("(",it(n,", "),")"))+(r?" repeatable":"")+" on "+it(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>it(["extend schema",it(e," "),st(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>it(["extend scalar",e,it(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>it(["extend type",e,ot("implements ",it(t," & ")),it(n," "),st(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>it(["extend interface",e,ot("implements ",it(t," & ")),it(n," "),st(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>it(["extend union",e,it(t," "),ot("= ",it(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>it(["extend enum",e,it(t," "),st(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>it(["extend input",e,it(t," "),st(n)]," ")}};function it(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function st(e){return ot("{\n",at(it(e,"\n")),"\n}")}function ot(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function at(e){return ot(" ",e.replace(/\n/g,"\n "))}function ct(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function ut(e,t){switch(e.kind){case Z.NULL:return null;case Z.INT:return parseInt(e.value,10);case Z.FLOAT:return parseFloat(e.value);case Z.STRING:case Z.ENUM:case Z.BOOLEAN:return e.value;case Z.LIST:return e.values.map((e=>ut(e,t)));case Z.OBJECT:return Me(e.fields,(e=>e.name.value),(e=>ut(e.value,t)));case Z.VARIABLE:return null==t?void 0:t[e.name.value]}}function lt(e){if(null!=e||$(!1,"Must provide name."),"string"==typeof e||$(!1,"Expected name to be a string."),0===e.length)throw new G("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!se(e.charCodeAt(t)))throw new G(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!ie(e.charCodeAt(0)))throw new G(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function pt(e){if("true"===e||"false"===e||"null"===e)throw new G(`Enum values cannot be named: ${e}`);return lt(e)}function dt(e){return ft(e)||ht(e)||mt(e)||yt(e)||vt(e)||Tt(e)||Et(e)||gt(e)}function ft(e){return ke(e,Lt)}function ht(e){return ke(e,$t)}function mt(e){return ke(e,Gt)}function yt(e){return ke(e,Jt)}function vt(e){return ke(e,Qt)}function Tt(e){return ke(e,Kt)}function Et(e){return ke(e,St)}function gt(e){return ke(e,wt)}function Nt(e){return ft(e)||vt(e)||Tt(e)||At(e)&&Nt(e.ofType)}function It(e){return ft(e)||ht(e)||mt(e)||yt(e)||vt(e)||At(e)&&It(e.ofType)}function bt(e){return ft(e)||vt(e)}function _t(e){return ht(e)||mt(e)||yt(e)}function Ot(e){return mt(e)||yt(e)}class St{constructor(e){dt(e)||$(!1,`Expected ${De(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class wt{constructor(e){var t;dt(t=e)&&!gt(t)||$(!1,`Expected ${De(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 At(e){return Et(e)||gt(e)}function Dt(e){if(e)return gt(e)?e.ofType:e}function xt(e){return ft(e)||ht(e)||mt(e)||yt(e)||vt(e)||Tt(e)}function kt(e){if(e){let t=e;for(;At(t);)t=t.ofType;return t}}function Rt(e){return"function"==typeof e?e():e}function Ft(e){return"function"==typeof e?e():e}class Lt{constructor(e){var t,n,r,i;const s=null!==(t=e.parseValue)&&void 0!==t?t:Ue;this.name=lt(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(ut(e,t)),this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(i=e.extensionASTNodes)&&void 0!==i?i:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||$(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${De(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||$(!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||$(!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 $t{constructor(e){var t;this.name=lt(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=()=>Vt(e),this._interfaces=()=>Ct(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||$(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${De(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:Mt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Ct(e){var t;const n=Rt(null!==(t=e.interfaces)&&void 0!==t?t:[]);return Array.isArray(n)||$(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function Vt(e){const t=Ft(e.fields);return jt(t)||$(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Pe(t,((t,n)=>{var r;jt(t)||$(!1,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||$(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${De(t.resolve)}.`);const i=null!==(r=t.args)&&void 0!==r?r:{};return jt(i)||$(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:lt(n),description:t.description,type:t.type,args:Ut(i),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:ze(t.extensions),astNode:t.astNode}}))}function Ut(e){return Object.entries(e).map((([e,t])=>({name:lt(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:ze(t.extensions),astNode:t.astNode})))}function jt(e){return V(e)&&!Array.isArray(e)}function Mt(e){return Pe(e,(e=>({description:e.description,type:e.type,args:Pt(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Pt(e){return Me(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Bt(e){return gt(e.type)&&void 0===e.defaultValue}class Gt{constructor(e){var t;this.name=lt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Vt.bind(void 0,e),this._interfaces=Ct.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||$(!1,`${this.name} must provide "resolveType" as a function, but got: ${De(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:Mt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class Jt{constructor(e){var t;this.name=lt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ze(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||$(!1,`${this.name} must provide "resolveType" as a function, but got: ${De(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)||$(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class Qt{constructor(e){var t,n,r;this.name=lt(e.name),this.description=e.description,this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._values=(n=this.name,jt(r=e.values)||$(!1,`${n} values must be an object with value names as keys.`),Object.entries(r).map((([e,t])=>(jt(t)||$(!1,`${n}.${e} must refer to an object with a "value" key representing an internal value but got: ${De(t)}.`),{name:pt(e),description:t.description,value:void 0!==t.value?t.value:e,deprecationReason:t.deprecationReason,extensions:ze(t.extensions),astNode:t.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=je(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 G(`Enum "${this.name}" cannot represent value: ${De(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=De(e);throw new G(`Enum "${this.name}" cannot represent non-string value: ${t}.`+qt(this,t))}const t=this.getValue(e);if(null==t)throw new G(`Value "${e}" does not exist in "${this.name}" enum.`+qt(this,e));return t.value}parseLiteral(e,t){if(e.kind!==Z.ENUM){const t=nt(e);throw new G(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+qt(this,t),{nodes:e})}const n=this.getValue(e.value);if(null==n){const t=nt(e);throw new G(`Value "${t}" does not exist in "${this.name}" enum.`+qt(this,t),{nodes:e})}return n.value}toConfig(){const e=Me(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 qt(e,t){return Ve("the enum value",Qe(t,e.getValues().map((e=>e.name))))}class Kt{constructor(e){var t;this.name=lt(e.name),this.description=e.description,this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=zt.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=Pe(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 zt(e){const t=Ft(e.fields);return jt(t)||$(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Pe(t,((t,n)=>(!("resolve"in t)||$(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:lt(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:ze(t.extensions),astNode:t.astNode})))}function Xt(e){return gt(e.type)&&void 0===e.defaultValue}function Ht(e,t){return e===t||(gt(e)&&gt(t)||!(!Et(e)||!Et(t)))&&Ht(e.ofType,t.ofType)}function Wt(e,t,n){return t===n||(gt(n)?!!gt(t)&&Wt(e,t.ofType,n.ofType):gt(t)?Wt(e,t.ofType,n):Et(n)?!!Et(t)&&Wt(e,t.ofType,n.ofType):!Et(t)&&(Ot(n)&&(mt(t)||ht(t))&&e.isSubType(n,t)))}function Zt(e,t,n){return t===n||(Ot(t)?Ot(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Ot(n)&&e.isSubType(n,t))}const en=2147483647,tn=-2147483648,nn=new Lt({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=un(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 G(`Int cannot represent non-integer value: ${De(t)}`);if(n>en||n<tn)throw new G("Int cannot represent non 32-bit signed integer value: "+De(t));return n},parseValue(e){if("number"!=typeof e||!Number.isInteger(e))throw new G(`Int cannot represent non-integer value: ${De(e)}`);if(e>en||e<tn)throw new G(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==Z.INT)throw new G(`Int cannot represent non-integer value: ${nt(e)}`,{nodes:e});const t=parseInt(e.value,10);if(t>en||t<tn)throw new G(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),rn=new Lt({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=un(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 G(`Float cannot represent non numeric value: ${De(t)}`);return n},parseValue(e){if("number"!=typeof e||!Number.isFinite(e))throw new G(`Float cannot represent non numeric value: ${De(e)}`);return e},parseLiteral(e){if(e.kind!==Z.FLOAT&&e.kind!==Z.INT)throw new G(`Float cannot represent non numeric value: ${nt(e)}`,e);return parseFloat(e.value)}}),sn=new Lt({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=un(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 G(`String cannot represent value: ${De(e)}`)},parseValue(e){if("string"!=typeof e)throw new G(`String cannot represent a non string value: ${De(e)}`);return e},parseLiteral(e){if(e.kind!==Z.STRING)throw new G(`String cannot represent a non string value: ${nt(e)}`,{nodes:e});return e.value}}),on=new Lt({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){const t=un(e);if("boolean"==typeof t)return t;if(Number.isFinite(t))return 0!==t;throw new G(`Boolean cannot represent a non boolean value: ${De(t)}`)},parseValue(e){if("boolean"!=typeof e)throw new G(`Boolean cannot represent a non boolean value: ${De(e)}`);return e},parseLiteral(e){if(e.kind!==Z.BOOLEAN)throw new G(`Boolean cannot represent a non boolean value: ${nt(e)}`,{nodes:e});return e.value}}),an=new Lt({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=un(e);if("string"==typeof t)return t;if(Number.isInteger(t))return String(t);throw new G(`ID cannot represent value: ${De(e)}`)},parseValue(e){if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e.toString();throw new G(`ID cannot represent value: ${De(e)}`)},parseLiteral(e){if(e.kind!==Z.STRING&&e.kind!==Z.INT)throw new G("ID cannot represent a non-string and non-integer value: "+nt(e),{nodes:e});return e.value}}),cn=Object.freeze([sn,nn,rn,on,an]);function un(e){if(V(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!V(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function ln(e){return ke(e,pn)}class pn{constructor(e){var t,n;this.name=lt(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(t=e.isRepeatable)&&void 0!==t&&t,this.extensions=ze(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||$(!1,`@${e.name} locations must be an Array.`);const r=null!==(n=e.args)&&void 0!==n?n:{};V(r)&&!Array.isArray(r)||$(!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:Pt(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const dn=new pn({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[W.FIELD,W.FRAGMENT_SPREAD,W.INLINE_FRAGMENT],args:{if:{type:new wt(on),description:"Included when true."}}}),fn=new pn({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[W.FIELD,W.FRAGMENT_SPREAD,W.INLINE_FRAGMENT],args:{if:{type:new wt(on),description:"Skipped when true."}}}),hn=new pn({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[W.FIELD_DEFINITION,W.ARGUMENT_DEFINITION,W.INPUT_FIELD_DEFINITION,W.ENUM_VALUE],args:{reason:{type:sn,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"}}}),mn=new pn({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[W.SCALAR],args:{url:{type:new wt(sn),description:"The URL that specifies the behavior of this scalar."}}}),yn=Object.freeze([dn,fn,hn,mn]);function vn(e){return"object"==typeof e&&"function"==typeof(null==e?void 0:e[Symbol.iterator])}function Tn(e,t){if(gt(t)){const n=Tn(e,t.ofType);return(null==n?void 0:n.kind)===Z.NULL?null:n}if(null===e)return{kind:Z.NULL};if(void 0===e)return null;if(Et(t)){const n=t.ofType;if(vn(e)){const t=[];for(const r of e){const e=Tn(r,n);null!=e&&t.push(e)}return{kind:Z.LIST,values:t}}return Tn(e,n)}if(Tt(t)){if(!V(e))return null;const n=[];for(const r of Object.values(t.getFields())){const t=Tn(e[r.name],r.type);t&&n.push({kind:Z.OBJECT_FIELD,name:{kind:Z.NAME,value:r.name},value:t})}return{kind:Z.OBJECT,fields:n}}if(bt(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:Z.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return En.test(e)?{kind:Z.INT,value:e}:{kind:Z.FLOAT,value:e}}if("string"==typeof n)return vt(t)?{kind:Z.ENUM,value:n}:t===an&&En.test(n)?{kind:Z.INT,value:n}:{kind:Z.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${De(n)}.`)}U(!1,"Unexpected input type: "+De(t))}const En=/^-?(?:0|[1-9][0-9]*)$/,gn=new $t({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:sn,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new wt(new St(new wt(bn))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new wt(bn),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:bn,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:bn,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new wt(new St(new wt(Nn))),resolve:e=>e.getDirectives()}})}),Nn=new $t({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 wt(sn),resolve:e=>e.name},description:{type:sn,resolve:e=>e.description},isRepeatable:{type:new wt(on),resolve:e=>e.isRepeatable},locations:{type:new wt(new St(new wt(In))),resolve:e=>e.locations},args:{type:new wt(new St(new wt(On))),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),In=new Qt({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:W.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:W.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:W.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:W.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:W.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:W.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:W.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:W.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:W.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:W.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:W.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:W.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:W.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:W.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:W.UNION,description:"Location adjacent to a union definition."},ENUM:{value:W.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:W.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:W.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:W.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),bn=new $t({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 wt(An),resolve:e=>ft(e)?wn.SCALAR:ht(e)?wn.OBJECT:mt(e)?wn.INTERFACE:yt(e)?wn.UNION:vt(e)?wn.ENUM:Tt(e)?wn.INPUT_OBJECT:Et(e)?wn.LIST:gt(e)?wn.NON_NULL:void U(!1,`Unexpected type: "${De(e)}".`)},name:{type:sn,resolve:e=>"name"in e?e.name:void 0},description:{type:sn,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:sn,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new St(new wt(_n)),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(ht(e)||mt(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new St(new wt(bn)),resolve(e){if(ht(e)||mt(e))return e.getInterfaces()}},possibleTypes:{type:new St(new wt(bn)),resolve(e,t,n,{schema:r}){if(Ot(e))return r.getPossibleTypes(e)}},enumValues:{type:new St(new wt(Sn)),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(vt(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new St(new wt(On)),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Tt(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:bn,resolve:e=>"ofType"in e?e.ofType:void 0}})}),_n=new $t({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 wt(sn),resolve:e=>e.name},description:{type:sn,resolve:e=>e.description},args:{type:new wt(new St(new wt(On))),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new wt(bn),resolve:e=>e.type},isDeprecated:{type:new wt(on),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:sn,resolve:e=>e.deprecationReason}})}),On=new $t({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 wt(sn),resolve:e=>e.name},description:{type:sn,resolve:e=>e.description},type:{type:new wt(bn),resolve:e=>e.type},defaultValue:{type:sn,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=Tn(n,t);return r?nt(r):null}},isDeprecated:{type:new wt(on),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:sn,resolve:e=>e.deprecationReason}})}),Sn=new $t({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 wt(sn),resolve:e=>e.name},description:{type:sn,resolve:e=>e.description},isDeprecated:{type:new wt(on),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:sn,resolve:e=>e.deprecationReason}})});var wn;!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"}(wn||(wn={}));const An=new Qt({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:wn.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:wn.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:wn.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:wn.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:wn.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:wn.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:wn.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:wn.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),Dn={name:"__schema",type:new wt(gn),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},xn={name:"__type",type:bn,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new wt(sn),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},kn={name:"__typename",type:new wt(sn),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},Rn=Object.freeze([gn,Nn,In,bn,_n,On,Sn,An]);function Fn(e){return Rn.some((({name:t})=>e.name===t))}function Ln(e){if(!function(e){return ke(e,$n)}(e))throw new Error(`Expected ${De(e)} to be a GraphQL schema.`);return e}class $n{constructor(e){var t,n;this.__validationErrors=!0===e.assumeValid?[]:void 0,V(e)||$(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||$(!1,`"types" must be Array if provided but got: ${De(e.types)}.`),!e.directives||Array.isArray(e.directives)||$(!1,`"directives" must be Array if provided but got: ${De(e.directives)}.`),this.description=e.description,this.extensions=ze(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:yn;const r=new Set(e.types);if(null!=e.types)for(const t of e.types)r.delete(t),Cn(t,r);null!=this._queryType&&Cn(this._queryType,r),null!=this._mutationType&&Cn(this._mutationType,r),null!=this._subscriptionType&&Cn(this._subscriptionType,r);for(const e of this._directives)if(ln(e))for(const t of e.args)Cn(t.type,r);Cn(gn,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||$(!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,mt(e)){for(const t of e.getInterfaces())if(mt(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(ht(e))for(const t of e.getInterfaces())if(mt(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 H.QUERY:return this.getQueryType();case H.MUTATION:return this.getMutationType();case H.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return yt(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),yt(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 Cn(e,t){const n=kt(e);if(!t.has(n))if(t.add(n),yt(n))for(const e of n.getTypes())Cn(e,t);else if(ht(n)||mt(n)){for(const e of n.getInterfaces())Cn(e,t);for(const e of Object.values(n.getFields())){Cn(e.type,t);for(const n of e.args)Cn(n.type,t)}}else if(Tt(n))for(const e of Object.values(n.getFields()))Cn(e.type,t);return t}function Vn(e){if(Ln(e),e.__validationErrors)return e.__validationErrors;const t=new jn(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!ht(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${De(n)}.`,null!==(r=Mn(t,H.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&&!ht(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${De(i)}.`,null!==(s=Mn(t,H.MUTATION))&&void 0!==s?s:i.astNode);const o=t.getSubscriptionType();var a;o&&!ht(o)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${De(o)}.`,null!==(a=Mn(t,H.SUBSCRIPTION))&&void 0!==a?a:o.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(ln(n)){Pn(e,n);for(const r of n.args){var t;if(Pn(e,r),Nt(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${De(r.type)}.`,r.astNode),Bt(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[Hn(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${De(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(gt(t.type)&&Tt(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))xt(r)?(Fn(r)||Pn(e,r),ht(r)||mt(r)?(Bn(e,r),Gn(e,r)):yt(r)?Qn(e,r):vt(r)?qn(e,r):Tt(r)&&(Kn(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${De(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}function Un(e){const t=Vn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}class jn{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new G(e,{nodes:n}))}getErrors(){return this._errors}}function Mn(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 Pn(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function Bn(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(Pn(e,o),!It(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Output Type but got: ${De(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(Pn(e,n),!Nt(n.type))e.reportError(`The type of ${t.name}.${o.name}(${r}:) must be Input Type but got: ${De(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(Bt(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${o.name}(${r}:) cannot be deprecated.`,[Hn(n.astNode),null===(s=n.astNode)||void 0===s?void 0:s.type])}}}function Gn(e,t){const n=Object.create(null);for(const r of t.getInterfaces())mt(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,zn(t,r)):(n[r.name]=!0,Yn(e,t,r),Jn(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,zn(t,r)):e.reportError(`Type ${De(t)} must only implement Interface types, it cannot implement ${De(r)}.`,zn(t,r))}function Jn(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(!Wt(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${De(c.type)} but ${t.name}.${u} is type ${De(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(!Ht(r.type,s.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${De(r.type)} but ${t.name}.${u}(${i}:) is type ${De(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))&&Bt(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}.`,[...zn(n,i),...zn(t,n)])}function Qn(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.`,Xn(t,i.name)):(r[i.name]=!0,ht(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${De(i)}.`,Xn(t,String(i))))}function qn(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)Pn(e,t)}function Kn(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(Pn(e,s),!Nt(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Input Type but got: ${De(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);if(Xt(s)&&null!=s.deprecationReason)e.reportError(`Required input field ${t.name}.${s.name} cannot be deprecated.`,[Hn(s.astNode),null===(i=s.astNode)||void 0===i?void 0:i.type])}}function zn(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 Xn(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 Hn(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===hn.name))}function Wn(e,t){switch(t.kind){case Z.LIST_TYPE:{const n=Wn(e,t.type);return n&&new St(n)}case Z.NON_NULL_TYPE:{const n=Wn(e,t.type);return n&&new wt(n)}case Z.NAMED_TYPE:return e.getType(t.name.value)}}class Zn{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:er,t&&(Nt(t)&&this._inputTypeStack.push(t),_t(t)&&this._parentTypeStack.push(t),It(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 Z.SELECTION_SET:{const e=kt(this.getType());this._parentTypeStack.push(_t(e)?e:void 0);break}case Z.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(It(i)?i:void 0);break}case Z.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case Z.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(ht(n)?n:void 0);break}case Z.INLINE_FRAGMENT:case Z.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?Wn(t,n):kt(this.getType());this._typeStack.push(It(r)?r:void 0);break}case Z.VARIABLE_DEFINITION:{const n=Wn(t,e.type);this._inputTypeStack.push(Nt(n)?n:void 0);break}case Z.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(Nt(r)?r:void 0);break}case Z.LIST:{const e=Dt(this.getInputType()),t=Et(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(Nt(t)?t:void 0);break}case Z.OBJECT_FIELD:{const t=kt(this.getInputType());let n,r;Tt(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(Nt(n)?n:void 0);break}case Z.ENUM:{const t=kt(this.getInputType());let n;vt(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case Z.SELECTION_SET:this._parentTypeStack.pop();break;case Z.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case Z.DIRECTIVE:this._directive=null;break;case Z.OPERATION_DEFINITION:case Z.INLINE_FRAGMENT:case Z.FRAGMENT_DEFINITION:this._typeStack.pop();break;case Z.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case Z.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case Z.LIST:case Z.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case Z.ENUM:this._enumValue=null}}}function er(e,t,n){const r=n.name.value;return r===Dn.name&&e.getQueryType()===t?Dn:r===xn.name&&e.getQueryType()===t?xn:r===kn.name&&_t(t)?kn:ht(t)||mt(t)?t.getFields()[r]:void 0}function tr(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=tt(t,r.kind).enter;if(i){const s=i.apply(t,n);return void 0!==s&&(e.leave(r),X(s)&&e.enter(s)),s}},leave(...n){const r=n[0],i=tt(t,r.kind).leave;let s;return i&&(s=i.apply(t,n)),e.leave(r),s}}}function nr(e){return e.kind===Z.OPERATION_DEFINITION||e.kind===Z.FRAGMENT_DEFINITION}function rr(e){return e.kind===Z.SCALAR_TYPE_DEFINITION||e.kind===Z.OBJECT_TYPE_DEFINITION||e.kind===Z.INTERFACE_TYPE_DEFINITION||e.kind===Z.UNION_TYPE_DEFINITION||e.kind===Z.ENUM_TYPE_DEFINITION||e.kind===Z.INPUT_OBJECT_TYPE_DEFINITION}function ir(e){return e.kind===Z.SCALAR_TYPE_EXTENSION||e.kind===Z.OBJECT_TYPE_EXTENSION||e.kind===Z.INTERFACE_TYPE_EXTENSION||e.kind===Z.UNION_TYPE_EXTENSION||e.kind===Z.ENUM_TYPE_EXTENSION||e.kind===Z.INPUT_OBJECT_TYPE_EXTENSION}function sr(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():yn;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===Z.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=Qe(n,i);e.reportError(new G(`Unknown argument "${n}" on directive "@${r}".`+Ve(s),{nodes:t}))}}return!1}}}const or=[...cn,...Rn].map((e=>e.name));function ar(e){switch(e.kind){case Z.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:ar(e.value)}))).sort(((e,t)=>Be(e.name.value,t.name.value))))};case Z.LIST:return{...e,values:e.values.map(ar)};case Z.INT:case Z.FLOAT:case Z.STRING:case Z.BOOLEAN:case Z.NULL:case Z.ENUM:case Z.VARIABLE:return e}var t}function cr(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+cr(t))).join(" and "):e}function ur(e,t,n,r,i,s,o){const a=e.getFragment(o);if(!a)return;const[c,u]=yr(e,n,a);if(s!==c){pr(e,t,n,r,i,s,c);for(const a of u)r.has(a,o,i)||(r.add(a,o,i),ur(e,t,n,r,i,s,a))}}function lr(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]=yr(e,n,a),[p,d]=yr(e,n,c);pr(e,t,n,r,i,u,p);for(const o of d)lr(e,t,n,r,i,s,o);for(const s of l)lr(e,t,n,r,i,s,o)}function pr(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=dr(e,n,r,i,a,o,c);s&&t.push(s)}}}function dr(e,t,n,r,i,s,o){const[a,c,u]=s,[l,p,d]=o,f=r||a!==l&&ht(a)&&ht(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(fr(c)!==fr(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&&hr(h,m))return[[i,`they return conflicting types "${De(h)}" and "${De(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]=mr(e,t,i,s),[p,d]=mr(e,t,o,a);pr(e,c,t,n,r,u,p);for(const i of d)ur(e,c,t,n,r,u,i);for(const i of l)ur(e,c,t,n,r,p,i);for(const i of l)for(const s of d)lr(e,c,t,n,r,i,s);return c}(e,t,n,f,kt(h),y,kt(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 fr(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return nt(ar({kind:Z.OBJECT,fields:n.map((e=>({kind:Z.OBJECT_FIELD,name:e.name,value:e.value})))}))}function hr(e,t){return Et(e)?!Et(t)||hr(e.ofType,t.ofType):!!Et(t)||(gt(e)?!gt(t)||hr(e.ofType,t.ofType):!!gt(t)||!(!bt(e)&&!bt(t))&&e!==t)}function mr(e,t,n,r){const i=t.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);vr(e,n,r,s,o);const a=[s,Object.keys(o)];return t.set(r,a),a}function yr(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=Wn(e.getSchema(),n.typeCondition);return mr(e,t,i,n.selectionSet)}function vr(e,t,n,r,i){for(const s of n.selections)switch(s.kind){case Z.FIELD:{const e=s.name.value;let n;(ht(t)||mt(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 Z.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case Z.INLINE_FRAGMENT:{const n=s.typeCondition,o=n?Wn(e.getSchema(),n):t;vr(e,o,s.selectionSet,r,i);break}}}class Tr{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 Er(e){var t;const n=Object.create(null),r=e.getSchema(),i=null!==(t=null==r?void 0:r.getDirectives())&&void 0!==t?t:yn;for(const e of i)n[e.name]=je(e.args.filter(Bt),(e=>e.name));const s=e.getDocument().definitions;for(const e of s)if(e.kind===Z.DIRECTIVE_DEFINITION){var o;const t=null!==(o=e.arguments)&&void 0!==o?o:[];n[e.name.value]=je(t.filter(gr),(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=dt(s.type)?De(s.type):nt(s.type);e.reportError(new G(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}}}function gr(e){return e.type.kind===Z.NON_NULL_TYPE&&null==e.defaultValue}function Nr(e){return e.map((e=>"number"==typeof e?"["+e.toString()+"]":"."+e)).join("")}function Ir(e,t,n){return{prev:e,key:t,typename:n}}function br(e){const t=[];let n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function _r(e,t,n=Or){return Sr(e,t,n,void 0)}function Or(e,t,n){let r="Invalid value "+De(t);throw e.length>0&&(r+=` at "value${Nr(e)}"`),n.message=r+": "+n.message,n}function Sr(e,t,n,r){if(gt(t))return null!=e?Sr(e,t.ofType,n,r):void n(br(r),e,new G(`Expected non-nullable type "${De(t)}" not to be null.`));if(null==e)return null;if(Et(t)){const i=t.ofType;return vn(e)?Array.from(e,((e,t)=>{const s=Ir(r,t,void 0);return Sr(e,i,n,s)})):[Sr(e,i,n,r)]}if(Tt(t)){if(!V(e))return void n(br(r),e,new G(`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]=Sr(s,o.type,n,Ir(r,o.name,t.name));else if(void 0!==o.defaultValue)i[o.name]=o.defaultValue;else if(gt(o.type)){const t=De(o.type);n(br(r),e,new G(`Field "${o.name}" of required type "${t}" was not provided.`))}}for(const i of Object.keys(e))if(!s[i]){const s=Qe(i,Object.keys(t.getFields()));n(br(r),e,new G(`Field "${i}" is not defined by type "${t.name}".`+Ve(s)))}return i}if(bt(t)){let i;try{i=t.parseValue(e)}catch(i){return void n(br(r),e,i instanceof G?i:new G(`Expected type "${t.name}". `+i.message,{originalError:i}))}return void 0===i&&n(br(r),e,new G(`Expected type "${t.name}".`)),i}U(!1,"Unexpected input type: "+De(t))}function wr(e,t,n){if(e){if(e.kind===Z.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&gt(t))return;return i}if(gt(t)){if(e.kind===Z.NULL)return;return wr(e,t.ofType,n)}if(e.kind===Z.NULL)return null;if(Et(t)){const r=t.ofType;if(e.kind===Z.LIST){const t=[];for(const i of e.values)if(Ar(i,n)){if(gt(r))return;t.push(null)}else{const e=wr(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=wr(e,r,n);if(void 0===i)return;return[i]}if(Tt(t)){if(e.kind!==Z.OBJECT)return;const r=Object.create(null),i=je(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||Ar(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(gt(e.type))return;continue}const s=wr(t.value,e.type,n);if(void 0===s)return;r[e.name]=s}return r}if(bt(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}U(!1,"Unexpected input type: "+De(t))}}function Ar(e,t){return e.kind===Z.VARIABLE&&(null==t||void 0===t[e.name.value])}function Dr(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=Wn(e,s.type);if(!Nt(o)){const e=nt(s.type);r(new G(`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]=wr(s.defaultValue,o);else if(gt(o)){const e=De(o);r(new G(`Variable "$${t}" of required type "${e}" was not provided.`,{nodes:s}))}continue}const a=n[t];if(null===a&&gt(o)){const e=De(o);r(new G(`Variable "$${t}" of non-null type "${e}" must not be null.`,{nodes:s}))}else i[t]=_r(a,o,((e,n,i)=>{let o=`Variable "$${t}" got invalid value `+De(n);e.length>0&&(o+=` at "${t}${Nr(e)}"`),r(new G(o+"; "+i.message,{nodes:s,originalError:i.originalError}))}))}return i}(e,t,n,(e=>{if(null!=s&&i.length>=s)throw new G("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 xr(e,t,n){var r;const i={},s=je(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(gt(o))throw new G(`Argument "${e}" of required type "${De(o)}" was not provided.`,{nodes:t});continue}const c=a.value;let u=c.kind===Z.NULL;if(c.kind===Z.VARIABLE){const t=c.name.value;if(null==n||!Rr(n,t)){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(gt(o))throw new G(`Argument "${e}" of required type "${De(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}u=null==n[t]}if(u&&gt(o))throw new G(`Argument "${e}" of non-null type "${De(o)}" must not be null.`,{nodes:c});const l=wr(c,o,n);if(void 0===l)throw new G(`Argument "${e}" has invalid value ${nt(c)}.`,{nodes:c});i[e]=l}return i}function kr(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 xr(e,i,n)}function Rr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Fr(e,t,n,r,i){const s=new Map;return Lr(e,t,n,r,i,s,new Set),s}function Lr(e,t,n,r,i,s,o){for(const c of i.selections)switch(c.kind){case Z.FIELD:{if(!$r(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 Z.INLINE_FRAGMENT:if(!$r(n,c)||!Cr(e,c,r))continue;Lr(e,t,n,r,c.selectionSet,s,o);break;case Z.FRAGMENT_SPREAD:{const i=c.name.value;if(o.has(i)||!$r(n,c))continue;o.add(i);const a=t[i];if(!a||!Cr(e,a,r))continue;Lr(e,t,n,r,a.selectionSet,s,o);break}}var a}function $r(e,t){const n=kr(fn,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=kr(dn,t,e);return!1!==(null==r?void 0:r.if)}function Cr(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=Wn(e,r);return i===n||!!Ot(i)&&e.isSubType(i,n)}function Vr(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=kt(n);if(bt(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=De(n);e.reportError(new G(`Expected value of type "${r}", found ${nt(t)}.`,{nodes:t}))}}catch(r){const i=De(n);r instanceof G?e.reportError(r):e.reportError(new G(`Expected value of type "${i}", found ${nt(t)}; `+r.message,{nodes:t,originalError:r}))}else{const r=De(n);e.reportError(new G(`Expected value of type "${r}", found ${nt(t)}.`,{nodes:t}))}}function jr(e,t,n,r,i){if(gt(r)&&!gt(t)){if(!(null!=n&&n.kind!==Z.NULL)&&!(void 0!==i))return!1;return Wt(e,t,r.ofType)}return Wt(e,t,r)}const Mr=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!nr(n)){const t=n.kind===Z.SCHEMA_DEFINITION||n.kind===Z.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new G(`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 G(`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===Z.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new G("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===Z.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=Fr(n,a,s,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new G(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 G(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)rr(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===Z.SCHEMA_DEFINITION||rr(e)||e.kind===Z.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===Z.SCHEMA_EXTENSION||ir(e)}(p)));if(r&&or.includes(u))return;const s=Qe(u,r?or.concat(i):i);e.reportError(new G(`Unknown type "${u}".`+Ve(s),{nodes:t}))}var p}}},function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=Wn(e.getSchema(),n);if(t&&!_t(t)){const t=nt(n);e.reportError(new G(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){const n=Wn(e.getSchema(),t.typeCondition);if(n&&!_t(n)){const n=nt(t.typeCondition);e.reportError(new G(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}},function(e){return{VariableDefinition(t){const n=Wn(e.getSchema(),t.type);if(void 0!==n&&!Nt(n)){const n=t.variable.name.value,r=nt(t.type);e.reportError(new G(`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(bt(kt(n))){if(r){const i=t.name.value,s=De(n);e.reportError(new G(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(!r){const r=t.name.value,i=De(n);e.reportError(new G(`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=Ve("to use an inline fragment on",function(e,t,n){if(!Ot(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:mt(t)&&e.isSubType(t,n)?-1:mt(n)&&e.isSubType(n,t)?1:Be(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===s&&(s=Ve(function(e,t){if(ht(e)||mt(e)){return Qe(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new G(`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 G(`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 G(`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 G(`Fragment "${n}" is never used.`,{nodes:t}))}}}}},function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(_t(n)&&_t(r)&&!Zt(e.getSchema(),n,r)){const i=De(r),s=De(n);e.reportError(new G(`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=Wn(e.getSchema(),n.typeCondition);if(_t(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!Zt(e.getSchema(),r,i)){const s=De(i),o=De(r);e.reportError(new G(`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 G(`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=Vr(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 G(`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 G(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 G(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():yn;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===Z.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 G(`Unknown directive "@${a}".`,{nodes:n}));const u=function(e){const t=e[e.length-1];switch("kind"in t||U(!1),t.kind){case Z.OPERATION_DEFINITION:return function(e){switch(e){case H.QUERY:return W.QUERY;case H.MUTATION:return W.MUTATION;case H.SUBSCRIPTION:return W.SUBSCRIPTION}}(t.operation);case Z.FIELD:return W.FIELD;case Z.FRAGMENT_SPREAD:return W.FRAGMENT_SPREAD;case Z.INLINE_FRAGMENT:return W.INLINE_FRAGMENT;case Z.FRAGMENT_DEFINITION:return W.FRAGMENT_DEFINITION;case Z.VARIABLE_DEFINITION:return W.VARIABLE_DEFINITION;case Z.SCHEMA_DEFINITION:case Z.SCHEMA_EXTENSION:return W.SCHEMA;case Z.SCALAR_TYPE_DEFINITION:case Z.SCALAR_TYPE_EXTENSION:return W.SCALAR;case Z.OBJECT_TYPE_DEFINITION:case Z.OBJECT_TYPE_EXTENSION:return W.OBJECT;case Z.FIELD_DEFINITION:return W.FIELD_DEFINITION;case Z.INTERFACE_TYPE_DEFINITION:case Z.INTERFACE_TYPE_EXTENSION:return W.INTERFACE;case Z.UNION_TYPE_DEFINITION:case Z.UNION_TYPE_EXTENSION:return W.UNION;case Z.ENUM_TYPE_DEFINITION:case Z.ENUM_TYPE_EXTENSION:return W.ENUM;case Z.ENUM_VALUE_DEFINITION:return W.ENUM_VALUE;case Z.INPUT_OBJECT_TYPE_DEFINITION:case Z.INPUT_OBJECT_TYPE_EXTENSION:return W.INPUT_OBJECT;case Z.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||U(!1),t.kind===Z.INPUT_OBJECT_TYPE_DEFINITION?W.INPUT_FIELD_DEFINITION:W.ARGUMENT_DEFINITION}default:U(!1,"Unexpected kind: "+De(t.kind))}}(o);u&&!c.includes(u)&&e.reportError(new G(`Directive "@${a}" may not be used on ${u}.`,{nodes:n}))}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():yn;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===Z.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===Z.SCHEMA_DEFINITION||n.kind===Z.SCHEMA_EXTENSION)r=s;else if(rr(n)||ir(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 G(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}},function(e){return{...sr(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,s=Qe(n,r.args.map((e=>e.name)));e.reportError(new G(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+Ve(s),{nodes:t}))}}}},function(e){return{Field:t,Directive:t};function t(t){var n;const r=Vr(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new G(`There can be only one argument named "${t}".`,{nodes:n.map((e=>e.name))}))}},function(e){return{ListValue(t){if(!Et(Dt(e.getParentInputType())))return Ur(e,t),!1},ObjectValue(t){const n=kt(e.getInputType());if(!Tt(n))return Ur(e,t),!1;const r=je(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&Xt(i)){const r=De(i.type);e.reportError(new G(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,{nodes:t}))}}},ObjectField(t){const n=kt(e.getParentInputType());if(!e.getInputType()&&Tt(n)){const r=Qe(t.name.value,Object.keys(n.getFields()));e.reportError(new G(`Field "${t.name.value}" is not defined by type "${n.name}".`+Ve(r),{nodes:t}))}},NullValue(t){const n=e.getInputType();gt(n)&&e.reportError(new G(`Expected value of type "${De(n)}", found ${nt(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{...Er(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)&&Bt(n)){const i=De(n.type);e.reportError(new G(`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=Wn(t,o.type);if(a&&!jr(t,a,o.defaultValue,i,s)){const t=De(a),s=De(i);e.reportError(new G(`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 Tr,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const s=[],[o,a]=mr(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=dr(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++){ur(e,s,t,n,!1,o,a[r]);for(let i=r+1;i<a.length;i++)lr(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=cr(n);e.reportError(new G(`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 G(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}]);class Pr{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===Z.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===Z.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 Br extends Pr{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 Zn(this._schema);et(e,tr(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 Gr(e,t,n=Mr,r,i=new Zn(e)){var s;const o=null!==(s=null==r?void 0:r.maxErrors)&&void 0!==s?s:100;t||$(!1,"Must provide document."),Un(e);const a=Object.freeze({}),c=[],u=new Br(e,t,i,(e=>{if(c.length>=o)throw c.push(new G("Too many validation errors, error limit reached. Validation aborted.")),a;c.push(e)})),l=function(e){const t=new Array(e.length).fill(null),n=Object.create(null);for(const r of Object.values(Z)){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}=tt(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===Ze)t[o]=Ze;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===Ze)t[s]=Ze;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(u))));try{et(t,tr(i,l))}catch(e){if(e!==a)throw e}return c}class Jr extends Error{constructor(e){super("Unexpected error value: "+De(e)),this.name="NonErrorThrown",this.thrownValue=e}}function Yr(e,t,n){var r;const i=(s=e)instanceof Error?s:new Jr(s);var s,o;return o=i,Array.isArray(o.path)?i:new G(i.message,{nodes:null!==(r=i.nodes)&&void 0!==r?r:t,source:i.source,positions:i.positions,path:n,originalError:i})}const Qr=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&&Lr(e,t,n,r,a.selectionSet,s,o);return s}(e.schema,e.fragments,e.variableValues,t,n)));function qr(e){arguments.length<2||$(!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||$(!1,"Must provide document."),Un(e),null==n||V(n)||$(!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 Z.OPERATION_DEFINITION:if(null==c){if(void 0!==d)return[new G("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 Z.FRAGMENT_DEFINITION:f[e.name.value]=e}if(!d)return null!=c?[new G(`Unknown operation named "${c}".`)]:[new G("Must provide an operation.")];const h=null!==(n=d.variableDefinitions)&&void 0!==n?n:[],m=Dr(r,h,null!=a?a:{},{maxErrors:50});if(m.errors)return m.errors;return{schema:r,fragments:f,rootValue:s,contextValue:o,operation:d,variableValues:m.coerced,fieldResolver:null!=u?u:ri,typeResolver:null!=l?l:ni,subscribeFieldResolver:null!=p?p:ri,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 G(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});const i=Fr(e.schema,e.fragments,e.variableValues,r,t.selectionSet),s=void 0;switch(t.operation){case H.QUERY:return zr(e,r,n,s,i);case H.MUTATION:return function(e,t,n,r,i){return function(e,t,n){let r=n;for(const n of e)r=C(r)?r.then((e=>t(e,n))):t(r,n);return r}(i.entries(),((i,[s,o])=>{const a=Ir(r,s,t.name),c=Xr(e,t,n,o,a);return void 0===c?i:C(c)?c.then((e=>(i[s]=e,i))):(i[s]=c,i)}),Object.create(null))}(e,r,n,s,i);case H.SUBSCRIPTION:return zr(e,r,n,s,i)}}(s,e,i);return C(t)?t.then((e=>Kr(e,s.errors)),(e=>(s.errors.push(e),Kr(null,s.errors)))):Kr(t,s.errors)}catch(e){return s.errors.push(e),Kr(null,s.errors)}}function Kr(e,t){return 0===t.length?{data:e}:{errors:t,data:e}}function zr(e,t,n,r,i){const s=Object.create(null);let o=!1;for(const[a,c]of i.entries()){const i=Xr(e,t,n,c,Ir(r,a,t.name));void 0!==i&&(s[a]=i,C(i)&&(o=!0))}return o?(a=s,Promise.all(Object.values(a)).then((e=>{const t=Object.create(null);for(const[n,r]of Object.keys(a).entries())t[r]=e[n];return t}))):s;var a}function Xr(e,t,n,r,i){var s;const o=function(e,t,n){const r=n.name.value;if(r===Dn.name&&e.getQueryType()===t)return Dn;if(r===xn.name&&e.getQueryType()===t)return xn;if(r===kn.name)return kn;return t.getFields()[r]}(e.schema,t,r[0]);if(!o)return;const a=o.type,c=null!==(s=o.resolve)&&void 0!==s?s:e.fieldResolver,u=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=xr(o,r[0],e.variableValues),s=c(n,t,e.contextValue,u);let l;return l=C(s)?s.then((t=>Wr(e,a,r,u,i,t))):Wr(e,a,r,u,i,s),C(l)?l.then(void 0,(t=>Hr(Yr(t,r,br(i)),a,e))):l}catch(t){return Hr(Yr(t,r,br(i)),a,e)}}function Hr(e,t,n){if(gt(t))throw e;return n.errors.push(e),null}function Wr(e,t,n,r,i,s){if(s instanceof Error)throw s;if(gt(t)){const o=Wr(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:Et(t)?function(e,t,n,r,i,s){if(!vn(s))throw new G(`Expected Iterable, but did not find one for field "${r.parentType.name}.${r.fieldName}".`);const o=t.ofType;let a=!1;const c=Array.from(s,((t,s)=>{const c=Ir(i,s,void 0);try{let i;return i=C(t)?t.then((t=>Wr(e,o,n,r,c,t))):Wr(e,o,n,r,c,t),C(i)?(a=!0,i.then(void 0,(t=>Hr(Yr(t,n,br(c)),o,e)))):i}catch(t){return Hr(Yr(t,n,br(c)),o,e)}}));return a?Promise.all(c):c}(e,t,n,r,i,s):bt(t)?function(e,t){const n=e.serialize(t);if(null==n)throw new Error(`Expected \`${De(e)}.serialize(${De(t)})\` to return non-nullable value, returned: ${De(n)}`);return n}(t,s):Ot(t)?function(e,t,n,r,i,s){var o;const a=null!==(o=t.resolveType)&&void 0!==o?o:e.typeResolver,c=e.contextValue,u=a(s,c,r,t);if(C(u))return u.then((o=>ei(e,Zr(o,e,t,n,r,s),n,r,i,s)));return ei(e,Zr(u,e,t,n,r,s),n,r,i,s)}(e,t,n,r,i,s):ht(t)?ei(e,t,n,r,i,s):void U(!1,"Cannot complete value of unexpected output type: "+De(t))}function Zr(e,t,n,r,i,s){if(null==e)throw new G(`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(ht(e))throw new G("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 G(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${De(s)}, received "${De(e)}".`);const o=t.schema.getType(e);if(null==o)throw new G(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!ht(o))throw new G(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw new G(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function ei(e,t,n,r,i,s){const o=Qr(e,t,n);if(t.isTypeOf){const a=t.isTypeOf(s,e.contextValue,r);if(C(a))return a.then((r=>{if(!r)throw ti(t,s,n);return zr(e,t,s,i,o)}));if(!a)throw ti(t,s,n)}return zr(e,t,s,i,o)}function ti(e,t,n){return new G(`Expected value of type "${e.name}" but got: ${De(t)}.`,{nodes:n})}const ni=function(e,t,n,r){if(V(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(C(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},ri=function(e,t,n,r){if(V(e)||"function"==typeof e){const i=e[r.fieldName];return"function"==typeof i?e[r.fieldName](t,n,r):i}};const ii={base64Binary:sn,boolean:on,canonical:sn,code:sn,date:sn,dateTime:sn,decimal:rn,id:an,instant:sn,integer:rn,markdown:sn,number:rn,positiveInt:rn,string:sn,time:sn,unsignedInt:rn,uri:sn,url:sn,xhtml:sn,"http://hl7.org/fhirpath/System.Boolean":on,"http://hl7.org/fhirpath/System.Date":sn,"http://hl7.org/fhirpath/System.DateTime":sn,"http://hl7.org/fhirpath/System.Decimal":rn,"http://hl7.org/fhirpath/System.Integer":rn,"http://hl7.org/fhirpath/System.String":sn,"http://hl7.org/fhirpath/System.Time":sn},si=new u;let oi;async function ai(e,n){const{query:r,operationName:i,variables:s}=e.body;if(!r)return[t("Must provide query.")];let o;try{o=new Fe(r,a).parseDocument()}catch(e){return[t("GraphQL syntax error.")]}var a;const u=function(){oi||(oi=function(){for(const e of p())ii[e]=ui(e);const e={};for(const t of p()){const n=ci(t);e[t]={type:n,args:{id:{type:new wt(an),description:t+" ID"}},resolve:vi},e[t+"List"]={type:new St(n),args:di(t),resolve:mi},e[t+"Connection"]={type:hi(t,n),args:di(t),resolve:yi}}return new $n({query:new $t({name:"QueryType",fields:e})})}());return oi}(),d=Gr(u,o,[...Mr,bi]);if(d.length>0)return[(f=d,{resourceType:"OperationOutcome",issue:f.map((e=>({severity:"error",code:"invalid",details:{text:e.message}})))})];var f;const h=function(e){return e.includes("query IntrospectionQuery")||e.includes("__schema")||e.includes("__type")}(r);if(h)return[l];const m=new k((e=>n.readReferences(e)));let y=h&&si.get(r);return y||(y=await qr({schema:u,document:o,contextValue:{repo:n,dataLoader:m},operationName:i,variableValues:s})),[c,y]}function ci(e){let t=ii[e];return t||(t=ui(e),ii[e]=t),t}function ui(e){if("ResourceList"===e)return new Jt({name:"ResourceList",types:()=>p().map(ci).filter((e=>!!e)),resolveType:Ei});const t=d(e);return new $t({name:e,description:t.description,fields:()=>function(e){const t={};return function(e,t){const n=d(e),r=n.properties;f(n)&&(t.resourceType={type:new wt(sn),description:"Resource Type"});"Reference"===e&&(t.resource={description:"Reference",type:ci("ResourceList"),resolve:Ti});for(const n of Object.keys(r)){const r=h(e,n);for(const e of r.type)li(t,n,r,e)}}(e,t),function(e,t){for(const n of p()){const r=ci(n),i=E(n),s={};let o=0;if(i)for(const[t,n]of Object.entries(i))n.target&&n.target.includes(e)&&(s[Ii(t)]={value:t},o++);if(o>0){const i=new Qt({name:e+"_"+n+"_reference",values:s}),o=di(n);o._reference={type:new wt(i),description:`Specify which property to use for reverse lookup for ${n}`},t[n+"List"]={type:new St(r),args:o,resolve:mi}}}}(e,t),t}(e)})}function li(e,t,n,r){let i=r.code;"Element"!==i&&"BackboneElement"!==i||(i=m(n.path?.split(".")));const s={description:n.short,type:fi(n,i),resolve:gi};"*"===n.max&&(s.args=function(e){const t={_count:{type:nn,description:"Specify how many elements to return from a repeating list."},_offset:{type:nn,description:"Specify the offset to start at for a repeating element."}};if(!v(e.charAt(0))){t.fhirpath={type:sn,description:"A FHIRPath statement selecting which of the subnodes is to be included"};const n=T.types[e];if(n.properties)for(const r of Object.keys(n.properties)){const n=h(e,r);for(const e of n.type)pi(t,r,n,e)}}return t}(i));e[t.replace("[x]",y(r.code))]=s}function pi(e,t,n,r){const i=r.code,s=t.replace("[x]",y(i));switch(i){case"canonical":case"code":case"id":case"oid":case"string":case"uri":case"url":case"uuid":case"http://hl7.org/fhirpath/System.String":e[s]={type:sn,description:n.short}}}function di(e){const t={_count:{type:nn,description:"Specify how many elements to return from a repeating list."},_offset:{type:nn,description:"Specify the offset to start at for a repeating element."},_sort:{type:sn,description:"Specify the sort order by comma-separated list of sort rules in priority order."},_id:{type:sn,description:"Select resources based on the logical id of the resource."},_lastUpdated:{type:sn,description:"Select resources based on the last time they were changed."}},n=E(e);if(n)for(const[e,r]of Object.entries(n))t[Ii(e)]={type:sn,description:r.description};return t}function fi(e,t){const n=ci(t);return"*"===e.max?new St(n):n}function hi(e,t){return new $t({name:e+"Connection",fields:{count:{type:nn},offset:{type:nn},pageSize:{type:nn},first:{type:sn},previous:{type:sn},next:{type:sn},last:{type:sn},edges:{type:new St(new $t({name:e+"ConnectionEdge",fields:{mode:{type:sn},score:{type:rn},resource:{type:t}}}))}}})}async function mi(e,t,n,r){const i=r.fieldName,s=Ni(i.substring(0,i.length-4),e,t),o=await n.repo.search(s);return o.entry?.map((e=>e.resource))}async function yi(e,t,n,r){const i=r.fieldName,s=Ni(i.substring(0,i.length-10),e,t);(function(e,t){return e.fieldNodes.some((e=>e.selectionSet?.selections.some((e=>"Field"===e.kind&&e.name.value===t))))})(r,"count")&&(s.total="accurate");const o=await n.repo.search(s);return{count:o.total,offset:s.offset||0,pageSize:s.count||g,edges:o.entry?.map((e=>({mode:e.search?.mode,score:e.search?.score,resource:e.resource})))}}async function vi(t,r,i,s){try{return await i.dataLoader.load({reference:`${s.fieldName}/${r.id}`})}catch(t){throw new e(n(t),t)}}async function Ti(t,r,i){try{return await i.dataLoader.load(t)}catch(t){throw new e(n(t),t)}}function Ei(e){const t=e?.resourceType;if(t)return ci(t).name}async function gi(e,t,n,r){const i=e?.[r.fieldName];if(!t||!i)return i;const{_offset:s,_count:o,fhirpath:a,...c}=t;let u=i;for(const[e,t]of Object.entries(c))u=u.filter((n=>n[e]===t));return a&&(u=u.filter((e=>N(I(a,[b(e)]))))),s&&(u=u.slice(s)),o&&(u=u.slice(0,o)),u}function Ni(e,t,n){let r;if(t){const e=n._reference;delete n._reference,r={code:e,operator:_.EQUALS,value:i(t)}}n=Object.fromEntries(Object.entries(n).map((([e,t])=>{return[(n=e,n.startsWith("_")?n:n.replaceAll("_","-")),t];var n})));const s=O(e,n);if(r){const e=s.filters||[];s.filters=[r,...e]}return s}function Ii(e){return e.replaceAll("-","_")}const bi=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 G(`Field "${n}" exceeds max depth (depth=${s}, max=12)`,{nodes:t}))}}});class _i{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=Oi(t,e,n);s>i&&(r=t,i=s)}if(r)return{handler:r.handler,params:Si(r,n)}}}function Oi(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 Si(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 wi(e,n,r){const i=e.body;if("Bundle"!==i.resourceType)return[t("Not a bundle")];const s=await async function(e,t,n){return new F(e,t,n).processBatch()}(r,n,i);return[c,s]}async function Ai(e,t){const{resourceType:n}=e.params,r=e.query,i=await t.search(O(n,r));return[c,i]}async function Di(e,t){const{resourceType:n}=e.params,r=e.body,i=await t.search(O(n,r));return[c,i]}async function xi(e,n){const{resourceType:r}=e.params,i=e.body;if(i.resourceType!==r)return[t("Incorrect resource type")];const s=await n.createResource(i);return[w,s]}async function ki(e,t){const{resourceType:n,id:r}=e.params,i=await t.readResource(n,r);return[c,i]}async function Ri(e,t){const{resourceType:n,id:r}=e.params,i=await t.readHistory(n,r);return[c,i]}async function Fi(e,t){const{resourceType:n,id:r,vid:i}=e.params,s=await t.readVersion(n,r,i);return[c,s]}async function Li(e,n){const{resourceType:r,id:i}=e.params,s=e.body;if(s.resourceType!==r)return[t("Incorrect resource type")];if(s.id!==i)return[t("Incorrect ID")];const o=await n.updateResource(s);return[c,o]}async function $i(e,t){const{resourceType:n,id:r}=e.params;return await t.deleteResource(n,r),[c]}async function Ci(e,t){const{resourceType:n,id:r}=e.params,i=e.body,s=await t.patchResource(n,r,i);return[c,s]}class Vi{constructor(){this.router=new _i,this.router.add("POST","",wi),this.router.add("GET",":resourceType",Ai),this.router.add("POST",":resourceType/_search",Di),this.router.add("POST",":resourceType",xi),this.router.add("GET",":resourceType/:id",ki),this.router.add("GET",":resourceType/:id/_history",Ri),this.router.add("GET",":resourceType/:id/_history/:vid",Fi),this.router.add("PUT",":resourceType/:id",Li),this.router.add("DELETE",":resourceType/:id",$i),this.router.add("PATCH",":resourceType/:id",Ci),this.router.add("POST","$graphql",ai)}async handleRequest(e,t){const n=this.router.find(e.method,e.pathname);if(!n)return[S];const{handler:r,params:i}=n;return e.params=i,r(e,t,this)}}class Ui{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))||[]}}class ji extends Ui{constructor(){super(),this.resources=new Map,this.history=new Map}async createResource(e){const t=A(e);t.id||(t.id=Pi()),t.meta||(t.meta={}),t.meta?.versionId||(t.meta.versionId=Pi()),t.meta?.lastUpdated||(t.meta.lastUpdated=(new Date).toISOString());const{resourceType:n,id:r}=t;let i=this.resources.get(n);i||(i=new Map,this.resources.set(n,i)),i.set(r,t);let s=this.history.get(n);s||(s=new Map,this.history.set(n,s));let o=s.get(r);return o||(o=[],s.set(r,o)),o.push(t),A(t)}updateResource(e){const t=A(e);return t.meta&&(t.meta.versionId&&delete t.meta.versionId,t.meta.lastUpdated&&delete t.meta.lastUpdated),this.createResource(t)}async patchResource(r,i,s){const o=await this.readResource(r,i);try{const n=R(o,s).filter(Boolean);if(n.length>0)throw new e(t(n.map((e=>e.message)).join("\n")))}catch(t){throw new e(n(t))}return this.updateResource(o)}async readResource(t,n){const r=this.resources.get(t)?.get(n);if(!r)throw new e(S);return A(r)}async readReference(n){const r=n.reference?.split("/");if(!r||2!==r.length)throw new e(t("Invalid reference"));return this.readResource(r[0],r[1])}async readReferences(e){return Promise.all(e.map((e=>this.readReference(e))))}async readHistory(e,t){return await this.readResource(e,t),{resourceType:"Bundle",type:"history",entry:(this.history.get(e)?.get(t)||[]).reverse().map((e=>({resource:A(e)})))}}async readVersion(t,n,r){await this.readResource(t,n);const i=this.history.get(t)?.get(n)?.find((e=>e.meta?.versionId===r));if(!i)throw new e(S);return A(i)}async search(e){const{resourceType:t}=e,n=this.resources.get(t)||new Map,r=[];for(const t of n.values())D(t,e)&&r.push(t);let i=r.map((e=>({resource:A(e)})));if(e.sortRules)for(const t of e.sortRules)i=i.sort(((e,n)=>Mi(e.resource,n.resource,t)));return void 0!==e.offset&&(i=i.slice(e.offset)),void 0!==e.count&&(i=i.slice(0,e.count)),{resourceType:"Bundle",type:"searchset",entry:i,total:r.length}}async deleteResource(t,n){if(!this.resources.get(t)?.get(n))throw new e(S);this.resources.get(t)?.delete(n)}}const Mi=(e,t,n)=>{const r=T.types[e.resourceType]?.searchParams?.[n.code],i=r?.expression;if(!i)return 0;const s=JSON.stringify(x(i,e)),o=JSON.stringify(x(i,t));return s.localeCompare(o)*(n.descending?-1:1)},Pi=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));export{Ui as BaseRepository,Vi as FhirRouter,ji as MemoryRepository,_i as Router};
1
+ import{OperationOutcomeError as e,badRequest as t,normalizeOperationOutcome as n,parseSearchUrl as r,getReferenceString as i,resolveId as s,getStatus as o,isOk as a,allOk as c,LRUCache as u,forbidden as l,getResourceTypes as p,getResourceTypeSchema as d,isResourceTypeSchema as f,getElementDefinition as h,buildTypeName as m,capitalize as y,isLowerCase as v,globalSchema as T,getSearchParameters as E,DEFAULT_SEARCH_COUNT as g,toJsBoolean as N,evalFhirPathTyped as I,toTypedValue as b,Operator as _,parseSearchRequest as O,notFound as S,created as w,deepClone as A,matchesSearchRequest as D,evalFhirPath as x}from"@medplum/core";import k from"dataloader";import{applyPatch as R}from"rfc6902";class F{constructor(e,t,n){this.router=e,this.repo=t,this.bundle=n,this.ids={}}async processBatch(){const r=this.bundle.type;if(!r)throw new e(t("Missing bundle type"));if("batch"!==r&&"transaction"!==r)throw new e(t("Unrecognized bundle type"));const i=this.bundle.entry;if(!i)throw new e(t("Missing bundle entry"));const s=[];for(const e of i){const t=this.rewriteIdsInObject(e);e?.resource?.id&&(t.resource.id=this.rewriteIdsInString(e.resource.id,!0));try{s.push(await this.processBatchEntry(t))}catch(e){s.push(L(n(e)))}}return{resourceType:"Bundle",type:r+"-response",entry:s}}async processBatchEntry(e){this.validateEntry(e);const n=e.request;if(e.resource?.resourceType&&n.ifNoneExist){const i=`https://example.com/${e.resource.resourceType}`,s=new URL("?"+n.ifNoneExist,i),o=await this.repo.search(r(s)),a=o?.entry;if(a.length>1)return L(t("Multiple matches"));if(1===a.length){const t=a[0].resource;return e.fullUrl&&this.addReplacementId(e.fullUrl,t),L(c,t)}}let i=e.resource;"PATCH"===n.method&&(i=this.parsePatchBody(e));const s=new URL(n.url,"https://example.com/"),o=await this.router.handleRequest({method:n.method,pathname:s.pathname,params:Object.create(null),query:Object.fromEntries(s.searchParams),body:i},this.repo);return e.fullUrl&&2===o.length&&this.addReplacementId(e.fullUrl,o[1]),L(o[0],o[1])}validateEntry(n){if(!n.request)throw new e(t("Missing entry.request"));if(!n.request.method)throw new e(t("Missing entry.request.method"));if(!n.request.url)throw new e(t("Missing entry.request.url"))}parsePatchBody(n){const r=n.resource;if(!r)throw new e(t("Missing entry.resource"));if("Binary"!==r.resourceType)throw new e(t("Patch resource must be a Binary"));if(!r.data)throw new e(t("Missing entry.resource.data"));return JSON.parse(Buffer.from(r.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,t=!1){const n=e.match(/urn:uuid:\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/);if(n){const r=n[0],o=this.ids[r];if(o){let n=i(o);return t&&(n=s({reference:n})),n?e.replaceAll(r,n):e}}return e}}function L(e,t){return{response:{outcome:e,status:o(e).toString(),location:a(e)&&t?.id?i(t):void 0},resource:t}}function $(e,t){if(!Boolean(e))throw new Error(t)}function C(e){return"function"==typeof(null==e?void 0:e.then)}function V(e){return"object"==typeof e&&null!==e}function U(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}const j=/\r\n|[\n\r]/g;function M(e,t){let n=0,r=1;for(const i of e.body.matchAll(j)){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 P(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+B([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return u+B([[o-1+" |",l[i-1]],[`${o} |`,p],["|","^".padStart(c)],[`${o+1} |`,l[i+1]]])}function B(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 G extends Error{constructor(e,...t){var n,r,i;const{nodes:s,source:o,positions:a,path:c,originalError:u,extensions:l}=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!=c?c:void 0,this.originalError=null!=u?u:void 0,this.nodes=J(Array.isArray(s)?s:s?[s]:void 0);const p=J(null===(n=this.nodes)||void 0===n?void 0:n.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=o?o:null==p||null===(r=p[0])||void 0===r?void 0:r.source,this.positions=null!=a?a:null==p?void 0:p.map((e=>e.start)),this.locations=a&&o?a.map((e=>M(o,e))):null==p?void 0:p.map((e=>M(e.source,e.start)));const d=V(null==u?void 0:u.extensions)?null==u?void 0:u.extensions:void 0;this.extensions=null!==(i=null!=l?l:d)&&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!=u&&u.stack?Object.defineProperty(this,"stack",{value:u.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,G):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"+P((t=n.loc).source,M(t.source,t.start)));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+P(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 J(e){return void 0===e||0===e.length?void 0:e}function Y(e,t,n){return new G(`Syntax Error: ${n}`,{source:e,positions:[t]})}class Q{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 q{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 K={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"]},z=new Set(Object.keys(K));function X(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&z.has(t)}var H,W,Z,ee;function te(e){return 9===e||32===e}function ne(e){return e>=48&&e<=57}function re(e){return e>=97&&e<=122||e>=65&&e<=90}function ie(e){return re(e)||95===e}function se(e){return re(e)||ne(e)||95===e}function oe(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=ae(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 ae(e){let t=0;for(;t<e.length&&te(e.charCodeAt(t));)++t;return t}!function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(H||(H={})),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"}(W||(W={})),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"}(Z||(Z={})),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"}(ee||(ee={}));class ce{constructor(e){const t=new q(ee.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!==ee.EOF)do{if(e.next)e=e.next;else{const t=me(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===ee.COMMENT);return e}}function ue(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function le(e,t){return pe(e.charCodeAt(t))&&de(e.charCodeAt(t+1))}function pe(e){return e>=55296&&e<=56319}function de(e){return e>=56320&&e<=57343}function fe(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return ee.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function he(e,t,n,r,i){const s=e.line,o=1+n-e.lineStart;return new q(t,n,r,s,o,i)}function me(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 ye(e,i);case 33:return he(e,ee.BANG,i,i+1);case 36:return he(e,ee.DOLLAR,i,i+1);case 38:return he(e,ee.AMP,i,i+1);case 40:return he(e,ee.PAREN_L,i,i+1);case 41:return he(e,ee.PAREN_R,i,i+1);case 46:if(46===n.charCodeAt(i+1)&&46===n.charCodeAt(i+2))return he(e,ee.SPREAD,i,i+3);break;case 58:return he(e,ee.COLON,i,i+1);case 61:return he(e,ee.EQUALS,i,i+1);case 64:return he(e,ee.AT,i,i+1);case 91:return he(e,ee.BRACKET_L,i,i+1);case 93:return he(e,ee.BRACKET_R,i,i+1);case 123:return he(e,ee.BRACE_L,i,i+1);case 124:return he(e,ee.PIPE,i,i+1);case 125:return he(e,ee.BRACE_R,i,i+1);case 34:return 34===n.charCodeAt(i+1)&&34===n.charCodeAt(i+2)?Oe(e,i):Ee(e,i)}if(ne(t)||45===t)return ve(e,i,t);if(ie(t))return Se(e,i);throw Y(e.source,i,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":ue(t)||le(n,i)?`Unexpected character: ${fe(e,i)}.`:`Invalid character: ${fe(e,i)}.`)}return he(e,ee.EOF,r,r)}function ye(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(ue(e))++i;else{if(!le(n,i))break;i+=2}}return he(e,ee.COMMENT,t,i,n.slice(t+1,i))}function ve(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),ne(s))throw Y(e.source,i,`Invalid number, unexpected digit after 0: ${fe(e,i)}.`)}else i=Te(e,i,s),s=r.charCodeAt(i);if(46===s&&(o=!0,s=r.charCodeAt(++i),i=Te(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=Te(e,i,s),s=r.charCodeAt(i)),46===s||ie(s))throw Y(e.source,i,`Invalid number, expected digit but got: ${fe(e,i)}.`);return he(e,o?ee.FLOAT:ee.INT,t,i,r.slice(t,i))}function Te(e,t,n){if(!ne(n))throw Y(e.source,t,`Invalid number, expected digit but got: ${fe(e,t)}.`);const r=e.source.body;let i=t+1;for(;ne(r.charCodeAt(i));)++i;return i}function Ee(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),he(e,ee.STRING,t,i+1,o);if(92!==r){if(10===r||13===r)break;if(ue(r))++i;else{if(!le(n,i))throw Y(e.source,i,`Invalid character within String: ${fe(e,i)}.`);i+=2}}else{o+=n.slice(s,i);const t=117===n.charCodeAt(i+1)?123===n.charCodeAt(i+2)?ge(e,i):Ne(e,i):_e(e,i);o+=t.value,i+=t.size,s=i}}throw Y(e.source,i,"Unterminated string.")}function ge(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||!ue(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|be(e),r<0)break}throw Y(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function Ne(e,t){const n=e.source.body,r=Ie(n,t+2);if(ue(r))return{value:String.fromCodePoint(r),size:6};if(pe(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=Ie(n,t+8);if(de(e))return{value:String.fromCodePoint(r,e),size:12}}throw Y(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function Ie(e,t){return be(e.charCodeAt(t))<<12|be(e.charCodeAt(t+1))<<8|be(e.charCodeAt(t+2))<<4|be(e.charCodeAt(t+3))}function be(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function _e(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 Oe(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=he(e,ee.BLOCK_STRING,t,s+3,oe(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(ue(r))++s;else{if(!le(n,s))throw Y(e.source,s,`Invalid character within String: ${fe(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 Se(e,t){const n=e.source.body,r=n.length;let i=t+1;for(;i<r;){if(!se(n.charCodeAt(i)))break;++i}return he(e,ee.NAME,t,i,n.slice(t,i))}const we=10,Ae=2;function De(e){return xe(e,[])}function xe(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:xe(t,n)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>Ae)return"[Array]";const n=Math.min(we,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(xe(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>Ae)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+": "+xe(n,t)));return"{ "+r.join(", ")+" }"}(e,n)}(e,t);default:return String(e)}}const ke="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=De(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||$(!1,`Body must be a string. Received: ${De(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||$(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||$(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}class Fe{constructor(e,t={}){const n=function(e){return ke(e,Re)}(e)?e:new Re(e);this._lexer=new ce(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(ee.NAME);return this.node(e,{kind:Z.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:Z.DOCUMENT,definitions:this.many(ee.SOF,this.parseDefinition,ee.EOF)})}parseDefinition(){if(this.peek(ee.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===ee.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(ee.BRACE_L))return this.node(e,{kind:Z.OPERATION_DEFINITION,operation:H.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(ee.NAME)&&(n=this.parseName()),this.node(e,{kind:Z.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(ee.NAME);switch(e.value){case"query":return H.QUERY;case"mutation":return H.MUTATION;case"subscription":return H.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(ee.PAREN_L,this.parseVariableDefinition,ee.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:Z.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(ee.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(ee.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(ee.DOLLAR),this.node(e,{kind:Z.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:Z.SELECTION_SET,selections:this.many(ee.BRACE_L,this.parseSelection,ee.BRACE_R)})}parseSelection(){return this.peek(ee.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,r;return this.expectOptionalToken(ee.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:Z.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(ee.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(ee.PAREN_L,t,ee.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(ee.COLON),this.node(t,{kind:Z.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(ee.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(ee.NAME)?this.node(e,{kind:Z.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:Z.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:Z.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:Z.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 ee.BRACKET_L:return this.parseList(e);case ee.BRACE_L:return this.parseObject(e);case ee.INT:return this.advanceLexer(),this.node(t,{kind:Z.INT,value:t.value});case ee.FLOAT:return this.advanceLexer(),this.node(t,{kind:Z.FLOAT,value:t.value});case ee.STRING:case ee.BLOCK_STRING:return this.parseStringLiteral();case ee.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:Z.BOOLEAN,value:!0});case"false":return this.node(t,{kind:Z.BOOLEAN,value:!1});case"null":return this.node(t,{kind:Z.NULL});default:return this.node(t,{kind:Z.ENUM,value:t.value})}case ee.DOLLAR:if(e){if(this.expectToken(ee.DOLLAR),this._lexer.token.kind===ee.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:Z.STRING,value:e.value,block:e.kind===ee.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:Z.LIST,values:this.any(ee.BRACKET_L,(()=>this.parseValueLiteral(e)),ee.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:Z.OBJECT,fields:this.any(ee.BRACE_L,(()=>this.parseObjectField(e)),ee.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(ee.COLON),this.node(t,{kind:Z.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(ee.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(ee.AT),this.node(t,{kind:Z.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(ee.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(ee.BRACKET_R),t=this.node(e,{kind:Z.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(ee.BANG)?this.node(e,{kind:Z.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:Z.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(ee.STRING)||this.peek(ee.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(ee.BRACE_L,this.parseOperationTypeDefinition,ee.BRACE_R);return this.node(e,{kind:Z.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(ee.COLON);const n=this.parseNamedType();return this.node(e,{kind:Z.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:Z.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:Z.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(ee.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(ee.BRACE_L,this.parseFieldDefinition,ee.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(ee.COLON);const i=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:Z.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:s})}parseArgumentDefs(){return this.optionalMany(ee.PAREN_L,this.parseInputValueDef,ee.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(ee.COLON);const r=this.parseTypeReference();let i;this.expectOptionalToken(ee.EQUALS)&&(i=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:Z.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:Z.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:Z.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(ee.EQUALS)?this.delimitedMany(ee.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:Z.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(ee.BRACE_L,this.parseEnumValueDefinition,ee.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:Z.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,`${Le(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:Z.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(ee.BRACE_L,this.parseInputValueDef,ee.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===ee.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(ee.BRACE_L,this.parseOperationTypeDefinition,ee.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:Z.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:Z.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:Z.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:Z.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:Z.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:Z.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:Z.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(ee.AT);const n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:Z.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:s})}parseDirectiveLocations(){return this.delimitedMany(ee.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(W,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new Q(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 ${$e(e)}, found ${Le(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==ee.NAME||t.value!==e)throw Y(this._lexer.source,t.start,`Expected "${e}", found ${Le(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===ee.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 ${Le(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!==ee.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw Y(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function Le(e){const t=e.value;return $e(e.kind)+(null!=t?` "${t}"`:"")}function $e(e){return function(e){return e===ee.BANG||e===ee.DOLLAR||e===ee.AMP||e===ee.PAREN_L||e===ee.PAREN_R||e===ee.SPREAD||e===ee.COLON||e===ee.EQUALS||e===ee.AT||e===ee.BRACKET_L||e===ee.BRACKET_R||e===ee.BRACE_L||e===ee.PIPE||e===ee.BRACE_R}(e)?`"${e}"`:e}const Ce=5;function Ve(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,Ce),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function Ue(e){return e}function je(e,t){const n=Object.create(null);for(const r of e)n[t(r)]=r;return n}function Me(e,t,n){const r=Object.create(null);for(const i of e)r[t(i)]=n(i);return r}function Pe(e,t){const n=Object.create(null);for(const r of Object.keys(e))n[r]=t(e[r],r);return n}function Be(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-Ge,i=e.charCodeAt(n)}while(Ye(i)&&o>0);let a=0;do{++r,a=10*a+s-Ge,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 Ge=48,Je=57;function Ye(e){return!isNaN(e)&&Ge<=e&&e<=Je}function Qe(e,t){const n=Object.create(null),r=new qe(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:Be(e,t)}))}class qe{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=Ke(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=Ke(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 Ke(e){const t=e.length,n=new Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function ze(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 Xe=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function He(e){return We[e.charCodeAt(0)]}const We=["\\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"],Ze=Object.freeze({});function et(e,t,n=K){const r=new Map;for(const e of Object.values(Z))r.set(e,tt(t,e));let i,s,o,a=Array.isArray(e),c=[e],u=-1,l=[],p=e;const d=[],f=[];do{u++;const e=u===c.length,v=e&&0!==l.length;if(e){if(s=0===f.length?void 0:d[d.length-1],p=o,o=f.pop(),v)if(a){p=p.slice();let e=0;for(const[t,n]of l){const r=t-e;null===n?(p.splice(r,1),e++):p[r]=n}}else{p=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));for(const[e,t]of l)p[e]=t}u=i.index,c=i.keys,l=i.edits,a=i.inArray,i=i.prev}else if(o){if(s=a?u:c[u],p=o[s],null==p)continue;d.push(s)}let T;if(!Array.isArray(p)){var h,m;X(p)||$(!1,`Invalid AST Node: ${De(p)}.`);const n=e?null===(h=r.get(p.kind))||void 0===h?void 0:h.leave:null===(m=r.get(p.kind))||void 0===m?void 0:m.enter;if(T=null==n?void 0:n.call(t,p,s,o,d,f),T===Ze)break;if(!1===T){if(!e){d.pop();continue}}else if(void 0!==T&&(l.push([s,T]),!e)){if(!X(T)){d.pop();continue}p=T}}var y;if(void 0===T&&v&&l.push([s,p]),e)d.pop();else i={inArray:a,index:u,keys:c,edits:l,prev:i},a=Array.isArray(p),c=a?p:null!==(y=n[p.kind])&&void 0!==y?y:[],u=-1,l=[],o&&f.push(o),o=p}while(void 0!==i);return 0!==l.length?l[l.length-1][1]:e}function tt(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 nt(e){return et(e,rt)}const rt={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>it(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=ot("(",it(e.variableDefinitions,", "),")"),n=it([e.operation,it([e.name,t]),it(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+ot(" = ",n)+ot(" ",it(r," "))},SelectionSet:{leave:({selections:e})=>st(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){const s=ot("",e,": ")+t;let o=s+ot("(",it(n,", "),")");return o.length>80&&(o=s+ot("(\n",at(it(n,"\n")),"\n)")),it([o,it(r," "),i]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+ot(" ",it(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>it(["...",ot("on ",e),it(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${ot("(",it(n,", "),")")} on ${t} ${ot("",it(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||te(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&&te(e.charCodeAt(0));return(l&&!d||s)&&(p+="\n"),p+=n,(l||u)&&(p+="\n"),'"""'+p+'"""'}(e):`"${e.replace(Xe,He)}"`},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+it(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+it(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+ot("(",it(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>ot("",e,"\n")+it(["schema",it(t," "),st(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>ot("",e,"\n")+it(["scalar",t,it(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ot("",e,"\n")+it(["type",t,ot("implements ",it(n," & ")),it(r," "),st(i)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>ot("",e,"\n")+t+(ct(n)?ot("(\n",at(it(n,"\n")),"\n)"):ot("(",it(n,", "),")"))+": "+r+ot(" ",it(i," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>ot("",e,"\n")+it([t+": "+n,ot("= ",r),it(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ot("",e,"\n")+it(["interface",t,ot("implements ",it(n," & ")),it(r," "),st(i)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>ot("",e,"\n")+it(["union",t,it(n," "),ot("= ",it(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>ot("",e,"\n")+it(["enum",t,it(n," "),st(r)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>ot("",e,"\n")+it([t,it(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>ot("",e,"\n")+it(["input",t,it(n," "),st(r)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>ot("",e,"\n")+"directive @"+t+(ct(n)?ot("(\n",at(it(n,"\n")),"\n)"):ot("(",it(n,", "),")"))+(r?" repeatable":"")+" on "+it(i," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>it(["extend schema",it(e," "),st(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>it(["extend scalar",e,it(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>it(["extend type",e,ot("implements ",it(t," & ")),it(n," "),st(r)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>it(["extend interface",e,ot("implements ",it(t," & ")),it(n," "),st(r)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>it(["extend union",e,it(t," "),ot("= ",it(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>it(["extend enum",e,it(t," "),st(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>it(["extend input",e,it(t," "),st(n)]," ")}};function it(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function st(e){return ot("{\n",at(it(e,"\n")),"\n}")}function ot(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function at(e){return ot(" ",e.replace(/\n/g,"\n "))}function ct(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}function ut(e,t){switch(e.kind){case Z.NULL:return null;case Z.INT:return parseInt(e.value,10);case Z.FLOAT:return parseFloat(e.value);case Z.STRING:case Z.ENUM:case Z.BOOLEAN:return e.value;case Z.LIST:return e.values.map((e=>ut(e,t)));case Z.OBJECT:return Me(e.fields,(e=>e.name.value),(e=>ut(e.value,t)));case Z.VARIABLE:return null==t?void 0:t[e.name.value]}}function lt(e){if(null!=e||$(!1,"Must provide name."),"string"==typeof e||$(!1,"Expected name to be a string."),0===e.length)throw new G("Expected name to be a non-empty string.");for(let t=1;t<e.length;++t)if(!se(e.charCodeAt(t)))throw new G(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!ie(e.charCodeAt(0)))throw new G(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function pt(e){if("true"===e||"false"===e||"null"===e)throw new G(`Enum values cannot be named: ${e}`);return lt(e)}function dt(e){return ft(e)||ht(e)||mt(e)||yt(e)||vt(e)||Tt(e)||Et(e)||gt(e)}function ft(e){return ke(e,Lt)}function ht(e){return ke(e,$t)}function mt(e){return ke(e,Gt)}function yt(e){return ke(e,Jt)}function vt(e){return ke(e,Qt)}function Tt(e){return ke(e,Kt)}function Et(e){return ke(e,St)}function gt(e){return ke(e,wt)}function Nt(e){return ft(e)||vt(e)||Tt(e)||At(e)&&Nt(e.ofType)}function It(e){return ft(e)||ht(e)||mt(e)||yt(e)||vt(e)||At(e)&&It(e.ofType)}function bt(e){return ft(e)||vt(e)}function _t(e){return ht(e)||mt(e)||yt(e)}function Ot(e){return mt(e)||yt(e)}class St{constructor(e){dt(e)||$(!1,`Expected ${De(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class wt{constructor(e){var t;dt(t=e)&&!gt(t)||$(!1,`Expected ${De(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 At(e){return Et(e)||gt(e)}function Dt(e){if(e)return gt(e)?e.ofType:e}function xt(e){return ft(e)||ht(e)||mt(e)||yt(e)||vt(e)||Tt(e)}function kt(e){if(e){let t=e;for(;At(t);)t=t.ofType;return t}}function Rt(e){return"function"==typeof e?e():e}function Ft(e){return"function"==typeof e?e():e}class Lt{constructor(e){var t,n,r,i;const s=null!==(t=e.parseValue)&&void 0!==t?t:Ue;this.name=lt(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(ut(e,t)),this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(i=e.extensionASTNodes)&&void 0!==i?i:[],null==e.specifiedByURL||"string"==typeof e.specifiedByURL||$(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${De(e.specifiedByURL)}.`),null==e.serialize||"function"==typeof e.serialize||$(!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||$(!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 $t{constructor(e){var t;this.name=lt(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=()=>Vt(e),this._interfaces=()=>Ct(e),null==e.isTypeOf||"function"==typeof e.isTypeOf||$(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${De(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:Mt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Ct(e){var t;const n=Rt(null!==(t=e.interfaces)&&void 0!==t?t:[]);return Array.isArray(n)||$(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),n}function Vt(e){const t=Ft(e.fields);return jt(t)||$(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Pe(t,((t,n)=>{var r;jt(t)||$(!1,`${e.name}.${n} field config must be an object.`),null==t.resolve||"function"==typeof t.resolve||$(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${De(t.resolve)}.`);const i=null!==(r=t.args)&&void 0!==r?r:{};return jt(i)||$(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:lt(n),description:t.description,type:t.type,args:Ut(i),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:ze(t.extensions),astNode:t.astNode}}))}function Ut(e){return Object.entries(e).map((([e,t])=>({name:lt(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:ze(t.extensions),astNode:t.astNode})))}function jt(e){return V(e)&&!Array.isArray(e)}function Mt(e){return Pe(e,(e=>({description:e.description,type:e.type,args:Pt(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Pt(e){return Me(e,(e=>e.name),(e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode})))}function Bt(e){return gt(e.type)&&void 0===e.defaultValue}class Gt{constructor(e){var t;this.name=lt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=Vt.bind(void 0,e),this._interfaces=Ct.bind(void 0,e),null==e.resolveType||"function"==typeof e.resolveType||$(!1,`${this.name} must provide "resolveType" as a function, but got: ${De(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:Mt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class Jt{constructor(e){var t;this.name=lt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ze(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||$(!1,`${this.name} must provide "resolveType" as a function, but got: ${De(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)||$(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}class Qt{constructor(e){var t,n,r;this.name=lt(e.name),this.description=e.description,this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._values=(n=this.name,jt(r=e.values)||$(!1,`${n} values must be an object with value names as keys.`),Object.entries(r).map((([e,t])=>(jt(t)||$(!1,`${n}.${e} must refer to an object with a "value" key representing an internal value but got: ${De(t)}.`),{name:pt(e),description:t.description,value:void 0!==t.value?t.value:e,deprecationReason:t.deprecationReason,extensions:ze(t.extensions),astNode:t.astNode})))),this._valueLookup=new Map(this._values.map((e=>[e.value,e]))),this._nameLookup=je(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 G(`Enum "${this.name}" cannot represent value: ${De(e)}`);return t.name}parseValue(e){if("string"!=typeof e){const t=De(e);throw new G(`Enum "${this.name}" cannot represent non-string value: ${t}.`+qt(this,t))}const t=this.getValue(e);if(null==t)throw new G(`Value "${e}" does not exist in "${this.name}" enum.`+qt(this,e));return t.value}parseLiteral(e,t){if(e.kind!==Z.ENUM){const t=nt(e);throw new G(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+qt(this,t),{nodes:e})}const n=this.getValue(e.value);if(null==n){const t=nt(e);throw new G(`Value "${t}" does not exist in "${this.name}" enum.`+qt(this,t),{nodes:e})}return n.value}toConfig(){const e=Me(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 qt(e,t){return Ve("the enum value",Qe(t,e.getValues().map((e=>e.name))))}class Kt{constructor(e){var t;this.name=lt(e.name),this.description=e.description,this.extensions=ze(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=null!==(t=e.extensionASTNodes)&&void 0!==t?t:[],this._fields=zt.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return"function"==typeof this._fields&&(this._fields=this._fields()),this._fields}toConfig(){const e=Pe(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 zt(e){const t=Ft(e.fields);return jt(t)||$(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Pe(t,((t,n)=>(!("resolve"in t)||$(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:lt(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:ze(t.extensions),astNode:t.astNode})))}function Xt(e){return gt(e.type)&&void 0===e.defaultValue}function Ht(e,t){return e===t||(gt(e)&&gt(t)||!(!Et(e)||!Et(t)))&&Ht(e.ofType,t.ofType)}function Wt(e,t,n){return t===n||(gt(n)?!!gt(t)&&Wt(e,t.ofType,n.ofType):gt(t)?Wt(e,t.ofType,n):Et(n)?!!Et(t)&&Wt(e,t.ofType,n.ofType):!Et(t)&&(Ot(n)&&(mt(t)||ht(t))&&e.isSubType(n,t)))}function Zt(e,t,n){return t===n||(Ot(t)?Ot(n)?e.getPossibleTypes(t).some((t=>e.isSubType(n,t))):e.isSubType(t,n):!!Ot(n)&&e.isSubType(n,t))}const en=2147483647,tn=-2147483648,nn=new Lt({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=un(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 G(`Int cannot represent non-integer value: ${De(t)}`);if(n>en||n<tn)throw new G("Int cannot represent non 32-bit signed integer value: "+De(t));return n},parseValue(e){if("number"!=typeof e||!Number.isInteger(e))throw new G(`Int cannot represent non-integer value: ${De(e)}`);if(e>en||e<tn)throw new G(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==Z.INT)throw new G(`Int cannot represent non-integer value: ${nt(e)}`,{nodes:e});const t=parseInt(e.value,10);if(t>en||t<tn)throw new G(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),rn=new Lt({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=un(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 G(`Float cannot represent non numeric value: ${De(t)}`);return n},parseValue(e){if("number"!=typeof e||!Number.isFinite(e))throw new G(`Float cannot represent non numeric value: ${De(e)}`);return e},parseLiteral(e){if(e.kind!==Z.FLOAT&&e.kind!==Z.INT)throw new G(`Float cannot represent non numeric value: ${nt(e)}`,e);return parseFloat(e.value)}}),sn=new Lt({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=un(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 G(`String cannot represent value: ${De(e)}`)},parseValue(e){if("string"!=typeof e)throw new G(`String cannot represent a non string value: ${De(e)}`);return e},parseLiteral(e){if(e.kind!==Z.STRING)throw new G(`String cannot represent a non string value: ${nt(e)}`,{nodes:e});return e.value}}),on=new Lt({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){const t=un(e);if("boolean"==typeof t)return t;if(Number.isFinite(t))return 0!==t;throw new G(`Boolean cannot represent a non boolean value: ${De(t)}`)},parseValue(e){if("boolean"!=typeof e)throw new G(`Boolean cannot represent a non boolean value: ${De(e)}`);return e},parseLiteral(e){if(e.kind!==Z.BOOLEAN)throw new G(`Boolean cannot represent a non boolean value: ${nt(e)}`,{nodes:e});return e.value}}),an=new Lt({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=un(e);if("string"==typeof t)return t;if(Number.isInteger(t))return String(t);throw new G(`ID cannot represent value: ${De(e)}`)},parseValue(e){if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e.toString();throw new G(`ID cannot represent value: ${De(e)}`)},parseLiteral(e){if(e.kind!==Z.STRING&&e.kind!==Z.INT)throw new G("ID cannot represent a non-string and non-integer value: "+nt(e),{nodes:e});return e.value}}),cn=Object.freeze([sn,nn,rn,on,an]);function un(e){if(V(e)){if("function"==typeof e.valueOf){const t=e.valueOf();if(!V(t))return t}if("function"==typeof e.toJSON)return e.toJSON()}return e}function ln(e){return ke(e,pn)}class pn{constructor(e){var t,n;this.name=lt(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=null!==(t=e.isRepeatable)&&void 0!==t&&t,this.extensions=ze(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||$(!1,`@${e.name} locations must be an Array.`);const r=null!==(n=e.args)&&void 0!==n?n:{};V(r)&&!Array.isArray(r)||$(!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:Pt(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const dn=new pn({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[W.FIELD,W.FRAGMENT_SPREAD,W.INLINE_FRAGMENT],args:{if:{type:new wt(on),description:"Included when true."}}}),fn=new pn({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[W.FIELD,W.FRAGMENT_SPREAD,W.INLINE_FRAGMENT],args:{if:{type:new wt(on),description:"Skipped when true."}}}),hn=new pn({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[W.FIELD_DEFINITION,W.ARGUMENT_DEFINITION,W.INPUT_FIELD_DEFINITION,W.ENUM_VALUE],args:{reason:{type:sn,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"}}}),mn=new pn({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[W.SCALAR],args:{url:{type:new wt(sn),description:"The URL that specifies the behavior of this scalar."}}}),yn=Object.freeze([dn,fn,hn,mn]);function vn(e){return"object"==typeof e&&"function"==typeof(null==e?void 0:e[Symbol.iterator])}function Tn(e,t){if(gt(t)){const n=Tn(e,t.ofType);return(null==n?void 0:n.kind)===Z.NULL?null:n}if(null===e)return{kind:Z.NULL};if(void 0===e)return null;if(Et(t)){const n=t.ofType;if(vn(e)){const t=[];for(const r of e){const e=Tn(r,n);null!=e&&t.push(e)}return{kind:Z.LIST,values:t}}return Tn(e,n)}if(Tt(t)){if(!V(e))return null;const n=[];for(const r of Object.values(t.getFields())){const t=Tn(e[r.name],r.type);t&&n.push({kind:Z.OBJECT_FIELD,name:{kind:Z.NAME,value:r.name},value:t})}return{kind:Z.OBJECT,fields:n}}if(bt(t)){const n=t.serialize(e);if(null==n)return null;if("boolean"==typeof n)return{kind:Z.BOOLEAN,value:n};if("number"==typeof n&&Number.isFinite(n)){const e=String(n);return En.test(e)?{kind:Z.INT,value:e}:{kind:Z.FLOAT,value:e}}if("string"==typeof n)return vt(t)?{kind:Z.ENUM,value:n}:t===an&&En.test(n)?{kind:Z.INT,value:n}:{kind:Z.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${De(n)}.`)}U(!1,"Unexpected input type: "+De(t))}const En=/^-?(?:0|[1-9][0-9]*)$/,gn=new $t({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:sn,resolve:e=>e.description},types:{description:"A list of all types supported by this server.",type:new wt(new St(new wt(bn))),resolve:e=>Object.values(e.getTypeMap())},queryType:{description:"The type that query operations will be rooted at.",type:new wt(bn),resolve:e=>e.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:bn,resolve:e=>e.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:bn,resolve:e=>e.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new wt(new St(new wt(Nn))),resolve:e=>e.getDirectives()}})}),Nn=new $t({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 wt(sn),resolve:e=>e.name},description:{type:sn,resolve:e=>e.description},isRepeatable:{type:new wt(on),resolve:e=>e.isRepeatable},locations:{type:new wt(new St(new wt(In))),resolve:e=>e.locations},args:{type:new wt(new St(new wt(On))),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))}})}),In=new Qt({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:W.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:W.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:W.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:W.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:W.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:W.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:W.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:W.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:W.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:W.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:W.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:W.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:W.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:W.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:W.UNION,description:"Location adjacent to a union definition."},ENUM:{value:W.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:W.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:W.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:W.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),bn=new $t({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 wt(An),resolve:e=>ft(e)?wn.SCALAR:ht(e)?wn.OBJECT:mt(e)?wn.INTERFACE:yt(e)?wn.UNION:vt(e)?wn.ENUM:Tt(e)?wn.INPUT_OBJECT:Et(e)?wn.LIST:gt(e)?wn.NON_NULL:void U(!1,`Unexpected type: "${De(e)}".`)},name:{type:sn,resolve:e=>"name"in e?e.name:void 0},description:{type:sn,resolve:e=>"description"in e?e.description:void 0},specifiedByURL:{type:sn,resolve:e=>"specifiedByURL"in e?e.specifiedByURL:void 0},fields:{type:new St(new wt(_n)),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(ht(e)||mt(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},interfaces:{type:new St(new wt(bn)),resolve(e){if(ht(e)||mt(e))return e.getInterfaces()}},possibleTypes:{type:new St(new wt(bn)),resolve(e,t,n,{schema:r}){if(Ot(e))return r.getPossibleTypes(e)}},enumValues:{type:new St(new wt(Sn)),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(vt(e)){const n=e.getValues();return t?n:n.filter((e=>null==e.deprecationReason))}}},inputFields:{type:new St(new wt(On)),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Tt(e)){const n=Object.values(e.getFields());return t?n:n.filter((e=>null==e.deprecationReason))}}},ofType:{type:bn,resolve:e=>"ofType"in e?e.ofType:void 0}})}),_n=new $t({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 wt(sn),resolve:e=>e.name},description:{type:sn,resolve:e=>e.description},args:{type:new wt(new St(new wt(On))),args:{includeDeprecated:{type:on,defaultValue:!1}},resolve:(e,{includeDeprecated:t})=>t?e.args:e.args.filter((e=>null==e.deprecationReason))},type:{type:new wt(bn),resolve:e=>e.type},isDeprecated:{type:new wt(on),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:sn,resolve:e=>e.deprecationReason}})}),On=new $t({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 wt(sn),resolve:e=>e.name},description:{type:sn,resolve:e=>e.description},type:{type:new wt(bn),resolve:e=>e.type},defaultValue:{type:sn,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(e){const{type:t,defaultValue:n}=e,r=Tn(n,t);return r?nt(r):null}},isDeprecated:{type:new wt(on),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:sn,resolve:e=>e.deprecationReason}})}),Sn=new $t({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 wt(sn),resolve:e=>e.name},description:{type:sn,resolve:e=>e.description},isDeprecated:{type:new wt(on),resolve:e=>null!=e.deprecationReason},deprecationReason:{type:sn,resolve:e=>e.deprecationReason}})});var wn;!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"}(wn||(wn={}));const An=new Qt({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:wn.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:wn.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:wn.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:wn.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:wn.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:wn.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:wn.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:wn.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),Dn={name:"__schema",type:new wt(gn),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},xn={name:"__type",type:bn,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new wt(sn),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},kn={name:"__typename",type:new wt(sn),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},Rn=Object.freeze([gn,Nn,In,bn,_n,On,Sn,An]);function Fn(e){return Rn.some((({name:t})=>e.name===t))}function Ln(e){if(!function(e){return ke(e,$n)}(e))throw new Error(`Expected ${De(e)} to be a GraphQL schema.`);return e}class $n{constructor(e){var t,n;this.__validationErrors=!0===e.assumeValid?[]:void 0,V(e)||$(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||$(!1,`"types" must be Array if provided but got: ${De(e.types)}.`),!e.directives||Array.isArray(e.directives)||$(!1,`"directives" must be Array if provided but got: ${De(e.directives)}.`),this.description=e.description,this.extensions=ze(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:yn;const r=new Set(e.types);if(null!=e.types)for(const t of e.types)r.delete(t),Cn(t,r);null!=this._queryType&&Cn(this._queryType,r),null!=this._mutationType&&Cn(this._mutationType,r),null!=this._subscriptionType&&Cn(this._subscriptionType,r);for(const e of this._directives)if(ln(e))for(const t of e.args)Cn(t.type,r);Cn(gn,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||$(!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,mt(e)){for(const t of e.getInterfaces())if(mt(t)){let n=this._implementationsMap[t.name];void 0===n&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(ht(e))for(const t of e.getInterfaces())if(mt(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 H.QUERY:return this.getQueryType();case H.MUTATION:return this.getMutationType();case H.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return yt(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),yt(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 Cn(e,t){const n=kt(e);if(!t.has(n))if(t.add(n),yt(n))for(const e of n.getTypes())Cn(e,t);else if(ht(n)||mt(n)){for(const e of n.getInterfaces())Cn(e,t);for(const e of Object.values(n.getFields())){Cn(e.type,t);for(const n of e.args)Cn(n.type,t)}}else if(Tt(n))for(const e of Object.values(n.getFields()))Cn(e.type,t);return t}function Vn(e){if(Ln(e),e.__validationErrors)return e.__validationErrors;const t=new jn(e);!function(e){const t=e.schema,n=t.getQueryType();if(n){if(!ht(n)){var r;e.reportError(`Query root type must be Object type, it cannot be ${De(n)}.`,null!==(r=Mn(t,H.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&&!ht(i)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${De(i)}.`,null!==(s=Mn(t,H.MUTATION))&&void 0!==s?s:i.astNode);const o=t.getSubscriptionType();var a;o&&!ht(o)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${De(o)}.`,null!==(a=Mn(t,H.SUBSCRIPTION))&&void 0!==a?a:o.astNode)}(t),function(e){for(const n of e.schema.getDirectives())if(ln(n)){Pn(e,n);for(const r of n.args){var t;if(Pn(e,r),Nt(r.type)||e.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${De(r.type)}.`,r.astNode),Bt(r)&&null!=r.deprecationReason)e.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[Hn(r.astNode),null===(t=r.astNode)||void 0===t?void 0:t.type])}}else e.reportError(`Expected directive but got: ${De(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(gt(t.type)&&Tt(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))xt(r)?(Fn(r)||Pn(e,r),ht(r)||mt(r)?(Bn(e,r),Gn(e,r)):yt(r)?Qn(e,r):vt(r)?qn(e,r):Tt(r)&&(Kn(e,r),t(r))):e.reportError(`Expected GraphQL named type but got: ${De(r)}.`,r.astNode)}(t);const n=t.getErrors();return e.__validationErrors=n,n}function Un(e){const t=Vn(e);if(0!==t.length)throw new Error(t.map((e=>e.message)).join("\n\n"))}class jn{constructor(e){this._errors=[],this.schema=e}reportError(e,t){const n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new G(e,{nodes:n}))}getErrors(){return this._errors}}function Mn(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 Pn(e,t){t.name.startsWith("__")&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function Bn(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(Pn(e,o),!It(o.type))e.reportError(`The type of ${t.name}.${o.name} must be Output Type but got: ${De(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(Pn(e,n),!Nt(n.type))e.reportError(`The type of ${t.name}.${o.name}(${r}:) must be Input Type but got: ${De(n.type)}.`,null===(i=n.astNode)||void 0===i?void 0:i.type);if(Bt(n)&&null!=n.deprecationReason)e.reportError(`Required argument ${t.name}.${o.name}(${r}:) cannot be deprecated.`,[Hn(n.astNode),null===(s=n.astNode)||void 0===s?void 0:s.type])}}}function Gn(e,t){const n=Object.create(null);for(const r of t.getInterfaces())mt(r)?t!==r?n[r.name]?e.reportError(`Type ${t.name} can only implement ${r.name} once.`,zn(t,r)):(n[r.name]=!0,Yn(e,t,r),Jn(e,t,r)):e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,zn(t,r)):e.reportError(`Type ${De(t)} must only implement Interface types, it cannot implement ${De(r)}.`,zn(t,r))}function Jn(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(!Wt(e.schema,l.type,c.type))e.reportError(`Interface field ${n.name}.${u} expects type ${De(c.type)} but ${t.name}.${u} is type ${De(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(!Ht(r.type,s.type))e.reportError(`Interface field argument ${n.name}.${u}(${i}:) expects type ${De(r.type)} but ${t.name}.${u}(${i}:) is type ${De(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))&&Bt(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}.`,[...zn(n,i),...zn(t,n)])}function Qn(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.`,Xn(t,i.name)):(r[i.name]=!0,ht(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${De(i)}.`,Xn(t,String(i))))}function qn(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)Pn(e,t)}function Kn(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(Pn(e,s),!Nt(s.type))e.reportError(`The type of ${t.name}.${s.name} must be Input Type but got: ${De(s.type)}.`,null===(r=s.astNode)||void 0===r?void 0:r.type);if(Xt(s)&&null!=s.deprecationReason)e.reportError(`Required input field ${t.name}.${s.name} cannot be deprecated.`,[Hn(s.astNode),null===(i=s.astNode)||void 0===i?void 0:i.type])}}function zn(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 Xn(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 Hn(e){var t;return null==e||null===(t=e.directives)||void 0===t?void 0:t.find((e=>e.name.value===hn.name))}function Wn(e,t){switch(t.kind){case Z.LIST_TYPE:{const n=Wn(e,t.type);return n&&new St(n)}case Z.NON_NULL_TYPE:{const n=Wn(e,t.type);return n&&new wt(n)}case Z.NAMED_TYPE:return e.getType(t.name.value)}}class Zn{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:er,t&&(Nt(t)&&this._inputTypeStack.push(t),_t(t)&&this._parentTypeStack.push(t),It(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 Z.SELECTION_SET:{const e=kt(this.getType());this._parentTypeStack.push(_t(e)?e:void 0);break}case Z.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(It(i)?i:void 0);break}case Z.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case Z.OPERATION_DEFINITION:{const n=t.getRootType(e.operation);this._typeStack.push(ht(n)?n:void 0);break}case Z.INLINE_FRAGMENT:case Z.FRAGMENT_DEFINITION:{const n=e.typeCondition,r=n?Wn(t,n):kt(this.getType());this._typeStack.push(It(r)?r:void 0);break}case Z.VARIABLE_DEFINITION:{const n=Wn(t,e.type);this._inputTypeStack.push(Nt(n)?n:void 0);break}case Z.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(Nt(r)?r:void 0);break}case Z.LIST:{const e=Dt(this.getInputType()),t=Et(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(Nt(t)?t:void 0);break}case Z.OBJECT_FIELD:{const t=kt(this.getInputType());let n,r;Tt(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(Nt(n)?n:void 0);break}case Z.ENUM:{const t=kt(this.getInputType());let n;vt(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}}}leave(e){switch(e.kind){case Z.SELECTION_SET:this._parentTypeStack.pop();break;case Z.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case Z.DIRECTIVE:this._directive=null;break;case Z.OPERATION_DEFINITION:case Z.INLINE_FRAGMENT:case Z.FRAGMENT_DEFINITION:this._typeStack.pop();break;case Z.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case Z.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case Z.LIST:case Z.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case Z.ENUM:this._enumValue=null}}}function er(e,t,n){const r=n.name.value;return r===Dn.name&&e.getQueryType()===t?Dn:r===xn.name&&e.getQueryType()===t?xn:r===kn.name&&_t(t)?kn:ht(t)||mt(t)?t.getFields()[r]:void 0}function tr(e,t){return{enter(...n){const r=n[0];e.enter(r);const i=tt(t,r.kind).enter;if(i){const s=i.apply(t,n);return void 0!==s&&(e.leave(r),X(s)&&e.enter(s)),s}},leave(...n){const r=n[0],i=tt(t,r.kind).leave;let s;return i&&(s=i.apply(t,n)),e.leave(r),s}}}function nr(e){return e.kind===Z.OPERATION_DEFINITION||e.kind===Z.FRAGMENT_DEFINITION}function rr(e){return e.kind===Z.SCALAR_TYPE_DEFINITION||e.kind===Z.OBJECT_TYPE_DEFINITION||e.kind===Z.INTERFACE_TYPE_DEFINITION||e.kind===Z.UNION_TYPE_DEFINITION||e.kind===Z.ENUM_TYPE_DEFINITION||e.kind===Z.INPUT_OBJECT_TYPE_DEFINITION}function ir(e){return e.kind===Z.SCALAR_TYPE_EXTENSION||e.kind===Z.OBJECT_TYPE_EXTENSION||e.kind===Z.INTERFACE_TYPE_EXTENSION||e.kind===Z.UNION_TYPE_EXTENSION||e.kind===Z.ENUM_TYPE_EXTENSION||e.kind===Z.INPUT_OBJECT_TYPE_EXTENSION}function sr(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():yn;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===Z.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=Qe(n,i);e.reportError(new G(`Unknown argument "${n}" on directive "@${r}".`+Ve(s),{nodes:t}))}}return!1}}}const or=[...cn,...Rn].map((e=>e.name));function ar(e){switch(e.kind){case Z.OBJECT:return{...e,fields:(t=e.fields,t.map((e=>({...e,value:ar(e.value)}))).sort(((e,t)=>Be(e.name.value,t.name.value))))};case Z.LIST:return{...e,values:e.values.map(ar)};case Z.INT:case Z.FLOAT:case Z.STRING:case Z.BOOLEAN:case Z.NULL:case Z.ENUM:case Z.VARIABLE:return e}var t}function cr(e){return Array.isArray(e)?e.map((([e,t])=>`subfields "${e}" conflict because `+cr(t))).join(" and "):e}function ur(e,t,n,r,i,s,o){const a=e.getFragment(o);if(!a)return;const[c,u]=yr(e,n,a);if(s!==c){pr(e,t,n,r,i,s,c);for(const a of u)r.has(a,o,i)||(r.add(a,o,i),ur(e,t,n,r,i,s,a))}}function lr(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]=yr(e,n,a),[p,d]=yr(e,n,c);pr(e,t,n,r,i,u,p);for(const o of d)lr(e,t,n,r,i,s,o);for(const s of l)lr(e,t,n,r,i,s,o)}function pr(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=dr(e,n,r,i,a,o,c);s&&t.push(s)}}}function dr(e,t,n,r,i,s,o){const[a,c,u]=s,[l,p,d]=o,f=r||a!==l&&ht(a)&&ht(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(fr(c)!==fr(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&&hr(h,m))return[[i,`they return conflicting types "${De(h)}" and "${De(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]=mr(e,t,i,s),[p,d]=mr(e,t,o,a);pr(e,c,t,n,r,u,p);for(const i of d)ur(e,c,t,n,r,u,i);for(const i of l)ur(e,c,t,n,r,p,i);for(const i of l)for(const s of d)lr(e,c,t,n,r,i,s);return c}(e,t,n,f,kt(h),y,kt(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 fr(e){var t;const n=null!==(t=e.arguments)&&void 0!==t?t:[];return nt(ar({kind:Z.OBJECT,fields:n.map((e=>({kind:Z.OBJECT_FIELD,name:e.name,value:e.value})))}))}function hr(e,t){return Et(e)?!Et(t)||hr(e.ofType,t.ofType):!!Et(t)||(gt(e)?!gt(t)||hr(e.ofType,t.ofType):!!gt(t)||!(!bt(e)&&!bt(t))&&e!==t)}function mr(e,t,n,r){const i=t.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);vr(e,n,r,s,o);const a=[s,Object.keys(o)];return t.set(r,a),a}function yr(e,t,n){const r=t.get(n.selectionSet);if(r)return r;const i=Wn(e.getSchema(),n.typeCondition);return mr(e,t,i,n.selectionSet)}function vr(e,t,n,r,i){for(const s of n.selections)switch(s.kind){case Z.FIELD:{const e=s.name.value;let n;(ht(t)||mt(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 Z.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case Z.INLINE_FRAGMENT:{const n=s.typeCondition,o=n?Wn(e.getSchema(),n):t;vr(e,o,s.selectionSet,r,i);break}}}class Tr{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 Er(e){var t;const n=Object.create(null),r=e.getSchema(),i=null!==(t=null==r?void 0:r.getDirectives())&&void 0!==t?t:yn;for(const e of i)n[e.name]=je(e.args.filter(Bt),(e=>e.name));const s=e.getDocument().definitions;for(const e of s)if(e.kind===Z.DIRECTIVE_DEFINITION){var o;const t=null!==(o=e.arguments)&&void 0!==o?o:[];n[e.name.value]=je(t.filter(gr),(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=dt(s.type)?De(s.type):nt(s.type);e.reportError(new G(`Directive "@${r}" argument "${n}" of type "${i}" is required, but it was not provided.`,{nodes:t}))}}}}}}function gr(e){return e.type.kind===Z.NON_NULL_TYPE&&null==e.defaultValue}function Nr(e){return e.map((e=>"number"==typeof e?"["+e.toString()+"]":"."+e)).join("")}function Ir(e,t,n){return{prev:e,key:t,typename:n}}function br(e){const t=[];let n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function _r(e,t,n=Or){return Sr(e,t,n,void 0)}function Or(e,t,n){let r="Invalid value "+De(t);throw e.length>0&&(r+=` at "value${Nr(e)}"`),n.message=r+": "+n.message,n}function Sr(e,t,n,r){if(gt(t))return null!=e?Sr(e,t.ofType,n,r):void n(br(r),e,new G(`Expected non-nullable type "${De(t)}" not to be null.`));if(null==e)return null;if(Et(t)){const i=t.ofType;return vn(e)?Array.from(e,((e,t)=>{const s=Ir(r,t,void 0);return Sr(e,i,n,s)})):[Sr(e,i,n,r)]}if(Tt(t)){if(!V(e))return void n(br(r),e,new G(`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]=Sr(s,o.type,n,Ir(r,o.name,t.name));else if(void 0!==o.defaultValue)i[o.name]=o.defaultValue;else if(gt(o.type)){const t=De(o.type);n(br(r),e,new G(`Field "${o.name}" of required type "${t}" was not provided.`))}}for(const i of Object.keys(e))if(!s[i]){const s=Qe(i,Object.keys(t.getFields()));n(br(r),e,new G(`Field "${i}" is not defined by type "${t.name}".`+Ve(s)))}return i}if(bt(t)){let i;try{i=t.parseValue(e)}catch(i){return void n(br(r),e,i instanceof G?i:new G(`Expected type "${t.name}". `+i.message,{originalError:i}))}return void 0===i&&n(br(r),e,new G(`Expected type "${t.name}".`)),i}U(!1,"Unexpected input type: "+De(t))}function wr(e,t,n){if(e){if(e.kind===Z.VARIABLE){const r=e.name.value;if(null==n||void 0===n[r])return;const i=n[r];if(null===i&&gt(t))return;return i}if(gt(t)){if(e.kind===Z.NULL)return;return wr(e,t.ofType,n)}if(e.kind===Z.NULL)return null;if(Et(t)){const r=t.ofType;if(e.kind===Z.LIST){const t=[];for(const i of e.values)if(Ar(i,n)){if(gt(r))return;t.push(null)}else{const e=wr(i,r,n);if(void 0===e)return;t.push(e)}return t}const i=wr(e,r,n);if(void 0===i)return;return[i]}if(Tt(t)){if(e.kind!==Z.OBJECT)return;const r=Object.create(null),i=je(e.fields,(e=>e.name.value));for(const e of Object.values(t.getFields())){const t=i[e.name];if(!t||Ar(t.value,n)){if(void 0!==e.defaultValue)r[e.name]=e.defaultValue;else if(gt(e.type))return;continue}const s=wr(t.value,e.type,n);if(void 0===s)return;r[e.name]=s}return r}if(bt(t)){let r;try{r=t.parseLiteral(e,n)}catch(e){return}if(void 0===r)return;return r}U(!1,"Unexpected input type: "+De(t))}}function Ar(e,t){return e.kind===Z.VARIABLE&&(null==t||void 0===t[e.name.value])}function Dr(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=Wn(e,s.type);if(!Nt(o)){const e=nt(s.type);r(new G(`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]=wr(s.defaultValue,o);else if(gt(o)){const e=De(o);r(new G(`Variable "$${t}" of required type "${e}" was not provided.`,{nodes:s}))}continue}const a=n[t];if(null===a&&gt(o)){const e=De(o);r(new G(`Variable "$${t}" of non-null type "${e}" must not be null.`,{nodes:s}))}else i[t]=_r(a,o,((e,n,i)=>{let o=`Variable "$${t}" got invalid value `+De(n);e.length>0&&(o+=` at "${t}${Nr(e)}"`),r(new G(o+"; "+i.message,{nodes:s,originalError:i.originalError}))}))}return i}(e,t,n,(e=>{if(null!=s&&i.length>=s)throw new G("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 xr(e,t,n){var r;const i={},s=je(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(gt(o))throw new G(`Argument "${e}" of required type "${De(o)}" was not provided.`,{nodes:t});continue}const c=a.value;let u=c.kind===Z.NULL;if(c.kind===Z.VARIABLE){const t=c.name.value;if(null==n||!Rr(n,t)){if(void 0!==r.defaultValue)i[e]=r.defaultValue;else if(gt(o))throw new G(`Argument "${e}" of required type "${De(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}u=null==n[t]}if(u&&gt(o))throw new G(`Argument "${e}" of non-null type "${De(o)}" must not be null.`,{nodes:c});const l=wr(c,o,n);if(void 0===l)throw new G(`Argument "${e}" has invalid value ${nt(c)}.`,{nodes:c});i[e]=l}return i}function kr(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 xr(e,i,n)}function Rr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Fr(e,t,n,r,i){const s=new Map;return Lr(e,t,n,r,i,s,new Set),s}function Lr(e,t,n,r,i,s,o){for(const c of i.selections)switch(c.kind){case Z.FIELD:{if(!$r(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 Z.INLINE_FRAGMENT:if(!$r(n,c)||!Cr(e,c,r))continue;Lr(e,t,n,r,c.selectionSet,s,o);break;case Z.FRAGMENT_SPREAD:{const i=c.name.value;if(o.has(i)||!$r(n,c))continue;o.add(i);const a=t[i];if(!a||!Cr(e,a,r))continue;Lr(e,t,n,r,a.selectionSet,s,o);break}}var a}function $r(e,t){const n=kr(fn,t,e);if(!0===(null==n?void 0:n.if))return!1;const r=kr(dn,t,e);return!1!==(null==r?void 0:r.if)}function Cr(e,t,n){const r=t.typeCondition;if(!r)return!0;const i=Wn(e,r);return i===n||!!Ot(i)&&e.isSubType(i,n)}function Vr(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=kt(n);if(bt(r))try{if(void 0===r.parseLiteral(t,void 0)){const r=De(n);e.reportError(new G(`Expected value of type "${r}", found ${nt(t)}.`,{nodes:t}))}}catch(r){const i=De(n);r instanceof G?e.reportError(r):e.reportError(new G(`Expected value of type "${i}", found ${nt(t)}; `+r.message,{nodes:t,originalError:r}))}else{const r=De(n);e.reportError(new G(`Expected value of type "${r}", found ${nt(t)}.`,{nodes:t}))}}function jr(e,t,n,r,i){if(gt(r)&&!gt(t)){if(!(null!=n&&n.kind!==Z.NULL)&&!(void 0!==i))return!1;return Wt(e,t,r.ofType)}return Wt(e,t,r)}const Mr=Object.freeze([function(e){return{Document(t){for(const n of t.definitions)if(!nr(n)){const t=n.kind===Z.SCHEMA_DEFINITION||n.kind===Z.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';e.reportError(new G(`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 G(`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===Z.OPERATION_DEFINITION)).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new G("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===Z.FRAGMENT_DEFINITION&&(a[e.name.value]=e);const c=Fr(n,a,s,r,t.selectionSet);if(c.size>1){const t=[...c.values()].slice(1).flat();e.reportError(new G(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 G(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)rr(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===Z.SCHEMA_DEFINITION||rr(e)||e.kind===Z.DIRECTIVE_DEFINITION}(p)||function(e){return e.kind===Z.SCHEMA_EXTENSION||ir(e)}(p)));if(r&&or.includes(u))return;const s=Qe(u,r?or.concat(i):i);e.reportError(new G(`Unknown type "${u}".`+Ve(s),{nodes:t}))}var p}}},function(e){return{InlineFragment(t){const n=t.typeCondition;if(n){const t=Wn(e.getSchema(),n);if(t&&!_t(t)){const t=nt(n);e.reportError(new G(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){const n=Wn(e.getSchema(),t.typeCondition);if(n&&!_t(n)){const n=nt(t.typeCondition);e.reportError(new G(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}},function(e){return{VariableDefinition(t){const n=Wn(e.getSchema(),t.type);if(void 0!==n&&!Nt(n)){const n=t.variable.name.value,r=nt(t.type);e.reportError(new G(`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(bt(kt(n))){if(r){const i=t.name.value,s=De(n);e.reportError(new G(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(!r){const r=t.name.value,i=De(n);e.reportError(new G(`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=Ve("to use an inline fragment on",function(e,t,n){if(!Ot(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:mt(t)&&e.isSubType(t,n)?-1:mt(n)&&e.isSubType(n,t)?1:Be(t.name,n.name)})).map((e=>e.name))}(r,n,i));""===s&&(s=Ve(function(e,t){if(ht(e)||mt(e)){return Qe(t,Object.keys(e.getFields()))}return[]}(n,i))),e.reportError(new G(`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 G(`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 G(`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 G(`Fragment "${n}" is never used.`,{nodes:t}))}}}}},function(e){return{InlineFragment(t){const n=e.getType(),r=e.getParentType();if(_t(n)&&_t(r)&&!Zt(e.getSchema(),n,r)){const i=De(r),s=De(n);e.reportError(new G(`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=Wn(e.getSchema(),n.typeCondition);if(_t(t))return t}}(e,n),i=e.getParentType();if(r&&i&&!Zt(e.getSchema(),r,i)){const s=De(i),o=De(r);e.reportError(new G(`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 G(`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=Vr(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 G(`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 G(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 G(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():yn;for(const e of r)t[e.name]=e.locations;const i=e.getDocument().definitions;for(const e of i)e.kind===Z.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 G(`Unknown directive "@${a}".`,{nodes:n}));const u=function(e){const t=e[e.length-1];switch("kind"in t||U(!1),t.kind){case Z.OPERATION_DEFINITION:return function(e){switch(e){case H.QUERY:return W.QUERY;case H.MUTATION:return W.MUTATION;case H.SUBSCRIPTION:return W.SUBSCRIPTION}}(t.operation);case Z.FIELD:return W.FIELD;case Z.FRAGMENT_SPREAD:return W.FRAGMENT_SPREAD;case Z.INLINE_FRAGMENT:return W.INLINE_FRAGMENT;case Z.FRAGMENT_DEFINITION:return W.FRAGMENT_DEFINITION;case Z.VARIABLE_DEFINITION:return W.VARIABLE_DEFINITION;case Z.SCHEMA_DEFINITION:case Z.SCHEMA_EXTENSION:return W.SCHEMA;case Z.SCALAR_TYPE_DEFINITION:case Z.SCALAR_TYPE_EXTENSION:return W.SCALAR;case Z.OBJECT_TYPE_DEFINITION:case Z.OBJECT_TYPE_EXTENSION:return W.OBJECT;case Z.FIELD_DEFINITION:return W.FIELD_DEFINITION;case Z.INTERFACE_TYPE_DEFINITION:case Z.INTERFACE_TYPE_EXTENSION:return W.INTERFACE;case Z.UNION_TYPE_DEFINITION:case Z.UNION_TYPE_EXTENSION:return W.UNION;case Z.ENUM_TYPE_DEFINITION:case Z.ENUM_TYPE_EXTENSION:return W.ENUM;case Z.ENUM_VALUE_DEFINITION:return W.ENUM_VALUE;case Z.INPUT_OBJECT_TYPE_DEFINITION:case Z.INPUT_OBJECT_TYPE_EXTENSION:return W.INPUT_OBJECT;case Z.INPUT_VALUE_DEFINITION:{const t=e[e.length-3];return"kind"in t||U(!1),t.kind===Z.INPUT_OBJECT_TYPE_DEFINITION?W.INPUT_FIELD_DEFINITION:W.ARGUMENT_DEFINITION}default:U(!1,"Unexpected kind: "+De(t.kind))}}(o);u&&!c.includes(u)&&e.reportError(new G(`Directive "@${a}" may not be used on ${u}.`,{nodes:n}))}}},function(e){const t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():yn;for(const e of r)t[e.name]=!e.isRepeatable;const i=e.getDocument().definitions;for(const e of i)e.kind===Z.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===Z.SCHEMA_DEFINITION||n.kind===Z.SCHEMA_EXTENSION)r=s;else if(rr(n)||ir(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 G(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}},function(e){return{...sr(e),Argument(t){const n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){const n=t.name.value,s=Qe(n,r.args.map((e=>e.name)));e.reportError(new G(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+Ve(s),{nodes:t}))}}}},function(e){return{Field:t,Directive:t};function t(t){var n;const r=Vr(null!==(n=t.arguments)&&void 0!==n?n:[],(e=>e.name.value));for(const[t,n]of r)n.length>1&&e.reportError(new G(`There can be only one argument named "${t}".`,{nodes:n.map((e=>e.name))}))}},function(e){return{ListValue(t){if(!Et(Dt(e.getParentInputType())))return Ur(e,t),!1},ObjectValue(t){const n=kt(e.getInputType());if(!Tt(n))return Ur(e,t),!1;const r=je(t.fields,(e=>e.name.value));for(const i of Object.values(n.getFields())){if(!r[i.name]&&Xt(i)){const r=De(i.type);e.reportError(new G(`Field "${n.name}.${i.name}" of required type "${r}" was not provided.`,{nodes:t}))}}},ObjectField(t){const n=kt(e.getParentInputType());if(!e.getInputType()&&Tt(n)){const r=Qe(t.name.value,Object.keys(n.getFields()));e.reportError(new G(`Field "${t.name.value}" is not defined by type "${n.name}".`+Ve(r),{nodes:t}))}},NullValue(t){const n=e.getInputType();gt(n)&&e.reportError(new G(`Expected value of type "${De(n)}", found ${nt(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{...Er(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)&&Bt(n)){const i=De(n.type);e.reportError(new G(`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=Wn(t,o.type);if(a&&!jr(t,a,o.defaultValue,i,s)){const t=De(a),s=De(i);e.reportError(new G(`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 Tr,n=new Map;return{SelectionSet(r){const i=function(e,t,n,r,i){const s=[],[o,a]=mr(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=dr(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++){ur(e,s,t,n,!1,o,a[r]);for(let i=r+1;i<a.length;i++)lr(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=cr(n);e.reportError(new G(`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 G(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}]);class Pr{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===Z.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===Z.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 Br extends Pr{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 Zn(this._schema);et(e,tr(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 Gr(e,t,n=Mr,r,i=new Zn(e)){var s;const o=null!==(s=null==r?void 0:r.maxErrors)&&void 0!==s?s:100;t||$(!1,"Must provide document."),Un(e);const a=Object.freeze({}),c=[],u=new Br(e,t,i,(e=>{if(c.length>=o)throw c.push(new G("Too many validation errors, error limit reached. Validation aborted.")),a;c.push(e)})),l=function(e){const t=new Array(e.length).fill(null),n=Object.create(null);for(const r of Object.values(Z)){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}=tt(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===Ze)t[o]=Ze;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===Ze)t[s]=Ze;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(u))));try{et(t,tr(i,l))}catch(e){if(e!==a)throw e}return c}class Jr extends Error{constructor(e){super("Unexpected error value: "+De(e)),this.name="NonErrorThrown",this.thrownValue=e}}function Yr(e,t,n){var r;const i=(s=e)instanceof Error?s:new Jr(s);var s,o;return o=i,Array.isArray(o.path)?i:new G(i.message,{nodes:null!==(r=i.nodes)&&void 0!==r?r:t,source:i.source,positions:i.positions,path:n,originalError:i})}const Qr=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&&Lr(e,t,n,r,a.selectionSet,s,o);return s}(e.schema,e.fragments,e.variableValues,t,n)));function qr(e){arguments.length<2||$(!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||$(!1,"Must provide document."),Un(e),null==n||V(n)||$(!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 Z.OPERATION_DEFINITION:if(null==c){if(void 0!==d)return[new G("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 Z.FRAGMENT_DEFINITION:f[e.name.value]=e}if(!d)return null!=c?[new G(`Unknown operation named "${c}".`)]:[new G("Must provide an operation.")];const h=null!==(n=d.variableDefinitions)&&void 0!==n?n:[],m=Dr(r,h,null!=a?a:{},{maxErrors:50});if(m.errors)return m.errors;return{schema:r,fragments:f,rootValue:s,contextValue:o,operation:d,variableValues:m.coerced,fieldResolver:null!=u?u:ri,typeResolver:null!=l?l:ni,subscribeFieldResolver:null!=p?p:ri,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 G(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});const i=Fr(e.schema,e.fragments,e.variableValues,r,t.selectionSet),s=void 0;switch(t.operation){case H.QUERY:return zr(e,r,n,s,i);case H.MUTATION:return function(e,t,n,r,i){return function(e,t,n){let r=n;for(const n of e)r=C(r)?r.then((e=>t(e,n))):t(r,n);return r}(i.entries(),((i,[s,o])=>{const a=Ir(r,s,t.name),c=Xr(e,t,n,o,a);return void 0===c?i:C(c)?c.then((e=>(i[s]=e,i))):(i[s]=c,i)}),Object.create(null))}(e,r,n,s,i);case H.SUBSCRIPTION:return zr(e,r,n,s,i)}}(s,e,i);return C(t)?t.then((e=>Kr(e,s.errors)),(e=>(s.errors.push(e),Kr(null,s.errors)))):Kr(t,s.errors)}catch(e){return s.errors.push(e),Kr(null,s.errors)}}function Kr(e,t){return 0===t.length?{data:e}:{errors:t,data:e}}function zr(e,t,n,r,i){const s=Object.create(null);let o=!1;for(const[a,c]of i.entries()){const i=Xr(e,t,n,c,Ir(r,a,t.name));void 0!==i&&(s[a]=i,C(i)&&(o=!0))}return o?(a=s,Promise.all(Object.values(a)).then((e=>{const t=Object.create(null);for(const[n,r]of Object.keys(a).entries())t[r]=e[n];return t}))):s;var a}function Xr(e,t,n,r,i){var s;const o=function(e,t,n){const r=n.name.value;if(r===Dn.name&&e.getQueryType()===t)return Dn;if(r===xn.name&&e.getQueryType()===t)return xn;if(r===kn.name)return kn;return t.getFields()[r]}(e.schema,t,r[0]);if(!o)return;const a=o.type,c=null!==(s=o.resolve)&&void 0!==s?s:e.fieldResolver,u=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=xr(o,r[0],e.variableValues),s=c(n,t,e.contextValue,u);let l;return l=C(s)?s.then((t=>Wr(e,a,r,u,i,t))):Wr(e,a,r,u,i,s),C(l)?l.then(void 0,(t=>Hr(Yr(t,r,br(i)),a,e))):l}catch(t){return Hr(Yr(t,r,br(i)),a,e)}}function Hr(e,t,n){if(gt(t))throw e;return n.errors.push(e),null}function Wr(e,t,n,r,i,s){if(s instanceof Error)throw s;if(gt(t)){const o=Wr(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:Et(t)?function(e,t,n,r,i,s){if(!vn(s))throw new G(`Expected Iterable, but did not find one for field "${r.parentType.name}.${r.fieldName}".`);const o=t.ofType;let a=!1;const c=Array.from(s,((t,s)=>{const c=Ir(i,s,void 0);try{let i;return i=C(t)?t.then((t=>Wr(e,o,n,r,c,t))):Wr(e,o,n,r,c,t),C(i)?(a=!0,i.then(void 0,(t=>Hr(Yr(t,n,br(c)),o,e)))):i}catch(t){return Hr(Yr(t,n,br(c)),o,e)}}));return a?Promise.all(c):c}(e,t,n,r,i,s):bt(t)?function(e,t){const n=e.serialize(t);if(null==n)throw new Error(`Expected \`${De(e)}.serialize(${De(t)})\` to return non-nullable value, returned: ${De(n)}`);return n}(t,s):Ot(t)?function(e,t,n,r,i,s){var o;const a=null!==(o=t.resolveType)&&void 0!==o?o:e.typeResolver,c=e.contextValue,u=a(s,c,r,t);if(C(u))return u.then((o=>ei(e,Zr(o,e,t,n,r,s),n,r,i,s)));return ei(e,Zr(u,e,t,n,r,s),n,r,i,s)}(e,t,n,r,i,s):ht(t)?ei(e,t,n,r,i,s):void U(!1,"Cannot complete value of unexpected output type: "+De(t))}function Zr(e,t,n,r,i,s){if(null==e)throw new G(`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(ht(e))throw new G("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 G(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${De(s)}, received "${De(e)}".`);const o=t.schema.getType(e);if(null==o)throw new G(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!ht(o))throw new G(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw new G(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function ei(e,t,n,r,i,s){const o=Qr(e,t,n);if(t.isTypeOf){const a=t.isTypeOf(s,e.contextValue,r);if(C(a))return a.then((r=>{if(!r)throw ti(t,s,n);return zr(e,t,s,i,o)}));if(!a)throw ti(t,s,n)}return zr(e,t,s,i,o)}function ti(e,t,n){return new G(`Expected value of type "${e.name}" but got: ${De(t)}.`,{nodes:n})}const ni=function(e,t,n,r){if(V(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(C(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},ri=function(e,t,n,r){if(V(e)||"function"==typeof e){const i=e[r.fieldName];return"function"==typeof i?e[r.fieldName](t,n,r):i}};const ii={base64Binary:sn,boolean:on,canonical:sn,code:sn,date:sn,dateTime:sn,decimal:rn,id:an,instant:sn,integer:rn,markdown:sn,number:rn,positiveInt:rn,string:sn,time:sn,unsignedInt:rn,uri:sn,url:sn,xhtml:sn,"http://hl7.org/fhirpath/System.Boolean":on,"http://hl7.org/fhirpath/System.Date":sn,"http://hl7.org/fhirpath/System.DateTime":sn,"http://hl7.org/fhirpath/System.Decimal":rn,"http://hl7.org/fhirpath/System.Integer":rn,"http://hl7.org/fhirpath/System.String":sn,"http://hl7.org/fhirpath/System.Time":sn},si=new u;let oi;async function ai(e,n){const{query:r,operationName:i,variables:s}=e.body;if(!r)return[t("Must provide query.")];let o;try{o=new Fe(r,a).parseDocument()}catch(e){return[t("GraphQL syntax error.")]}var a;const u=function(){oi||(oi=function(){for(const e of p())ii[e]=ui(e);const e={};for(const t of p()){const n=ci(t);e[t]={type:n,args:{id:{type:new wt(an),description:t+" ID"}},resolve:vi},e[t+"List"]={type:new St(n),args:di(t),resolve:mi},e[t+"Connection"]={type:hi(t,n),args:di(t),resolve:yi}}return new $n({query:new $t({name:"QueryType",fields:e})})}());return oi}(),d=Gr(u,o,[...Mr,bi]);if(d.length>0)return[(f=d,{resourceType:"OperationOutcome",issue:f.map((e=>({severity:"error",code:"invalid",details:{text:e.message}})))})];var f;const h=function(e){return e.includes("query IntrospectionQuery")||e.includes("__schema")||e.includes("__type")}(r);if(h)return[l];const m=new k((e=>n.readReferences(e)));let y=h&&si.get(r);return y||(y=await qr({schema:u,document:o,contextValue:{repo:n,dataLoader:m},operationName:i,variableValues:s})),[c,y]}function ci(e){let t=ii[e];return t||(t=ui(e),ii[e]=t),t}function ui(e){if("ResourceList"===e)return new Jt({name:"ResourceList",types:()=>p().map(ci).filter((e=>!!e)),resolveType:Ei});const t=d(e);return new $t({name:e,description:t.description,fields:()=>function(e){const t={};return function(e,t){const n=d(e),r=n.properties;f(n)&&(t.resourceType={type:new wt(sn),description:"Resource Type"});"Reference"===e&&(t.resource={description:"Reference",type:ci("ResourceList"),resolve:Ti});for(const n of Object.keys(r)){const r=h(e,n);for(const e of r.type)li(t,n,r,e)}}(e,t),function(e,t){for(const n of p()){const r=ci(n),i=E(n),s={};let o=0;if(i)for(const[t,n]of Object.entries(i))n.target&&n.target.includes(e)&&(s[Ii(t)]={value:t},o++);if(o>0){const i=new Qt({name:e+"_"+n+"_reference",values:s}),o=di(n);o._reference={type:new wt(i),description:`Specify which property to use for reverse lookup for ${n}`},t[n+"List"]={type:new St(r),args:o,resolve:mi}}}}(e,t),t}(e)})}function li(e,t,n,r){let i=r.code;"Element"!==i&&"BackboneElement"!==i||(i=m(n.path?.split(".")));const s={description:n.short,type:fi(n,i),resolve:gi};"*"===n.max&&(s.args=function(e){const t={_count:{type:nn,description:"Specify how many elements to return from a repeating list."},_offset:{type:nn,description:"Specify the offset to start at for a repeating element."}};if(!v(e.charAt(0))){t.fhirpath={type:sn,description:"A FHIRPath statement selecting which of the subnodes is to be included"};const n=T.types[e];if(n.properties)for(const r of Object.keys(n.properties)){const n=h(e,r);for(const e of n.type)pi(t,r,n,e)}}return t}(i));e[t.replace("[x]",y(r.code))]=s}function pi(e,t,n,r){const i=r.code,s=t.replace("[x]",y(i));switch(i){case"canonical":case"code":case"id":case"oid":case"string":case"uri":case"url":case"uuid":case"http://hl7.org/fhirpath/System.String":e[s]={type:sn,description:n.short}}}function di(e){const t={_count:{type:nn,description:"Specify how many elements to return from a repeating list."},_offset:{type:nn,description:"Specify the offset to start at for a repeating element."},_sort:{type:sn,description:"Specify the sort order by comma-separated list of sort rules in priority order."},_id:{type:sn,description:"Select resources based on the logical id of the resource."},_lastUpdated:{type:sn,description:"Select resources based on the last time they were changed."}},n=E(e);if(n)for(const[e,r]of Object.entries(n))t[Ii(e)]={type:sn,description:r.description};return t}function fi(e,t){const n=ci(t);return"*"===e.max?new St(n):n}function hi(e,t){return new $t({name:e+"Connection",fields:{count:{type:nn},offset:{type:nn},pageSize:{type:nn},first:{type:sn},previous:{type:sn},next:{type:sn},last:{type:sn},edges:{type:new St(new $t({name:e+"ConnectionEdge",fields:{mode:{type:sn},score:{type:rn},resource:{type:t}}}))}}})}async function mi(e,t,n,r){const i=r.fieldName,s=Ni(i.substring(0,i.length-4),e,t),o=await n.repo.search(s);return o.entry?.map((e=>e.resource))}async function yi(e,t,n,r){const i=r.fieldName,s=Ni(i.substring(0,i.length-10),e,t);(function(e,t){return e.fieldNodes.some((e=>e.selectionSet?.selections.some((e=>"Field"===e.kind&&e.name.value===t))))})(r,"count")&&(s.total="accurate");const o=await n.repo.search(s);return{count:o.total,offset:s.offset||0,pageSize:s.count||g,edges:o.entry?.map((e=>({mode:e.search?.mode,score:e.search?.score,resource:e.resource})))}}async function vi(t,r,i,s){try{return await i.dataLoader.load({reference:`${s.fieldName}/${r.id}`})}catch(t){throw new e(n(t),t)}}async function Ti(t,r,i){try{return await i.dataLoader.load(t)}catch(t){throw new e(n(t),t)}}function Ei(e){const t=e?.resourceType;if(t)return ci(t).name}async function gi(e,t,n,r){const i=e?.[r.fieldName];if(!t||!i)return i;const{_offset:s,_count:o,fhirpath:a,...c}=t;let u=i;for(const[e,t]of Object.entries(c))u=u.filter((n=>n[e]===t));return a&&(u=u.filter((e=>N(I(a,[b(e)]))))),s&&(u=u.slice(s)),o&&(u=u.slice(0,o)),u}function Ni(e,t,n){let r;if(t){const e=n._reference;delete n._reference,r={code:e,operator:_.EQUALS,value:i(t)}}n=Object.fromEntries(Object.entries(n).map((([e,t])=>{return[(n=e,n.startsWith("_")?n:n.replaceAll("_","-")),t];var n})));const s=O(e,n);if(r){const e=s.filters||[];s.filters=[r,...e]}return s}function Ii(e){return e.replaceAll("-","_")}const bi=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 G(`Field "${n}" exceeds max depth (depth=${s}, max=12)`,{nodes:t}))}}});class _i{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=Oi(t,e,n);s>i&&(r=t,i=s)}if(r)return{handler:r.handler,params:Si(r,n)}}}function Oi(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 Si(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 wi(e,n,r){const i=e.body;if("Bundle"!==i.resourceType)return[t("Not a bundle")];const s=await async function(e,t,n){return new F(e,t,n).processBatch()}(r,n,i);return[c,s]}async function Ai(e,t){const{resourceType:n}=e.params,r=e.query,i=await t.search(O(n,r));return[c,i]}async function Di(e,t){const{resourceType:n}=e.params,r=e.body,i=await t.search(O(n,r));return[c,i]}async function xi(e,n){const{resourceType:r}=e.params,i=e.body;if(i.resourceType!==r)return[t("Incorrect resource type")];const s=await n.createResource(i);return[w,s]}async function ki(e,t){const{resourceType:n,id:r}=e.params,i=await t.readResource(n,r);return[c,i]}async function Ri(e,t){const{resourceType:n,id:r}=e.params,i=await t.readHistory(n,r);return[c,i]}async function Fi(e,t){const{resourceType:n,id:r,vid:i}=e.params,s=await t.readVersion(n,r,i);return[c,s]}async function Li(e,n){const{resourceType:r,id:i}=e.params,s=e.body;if(s.resourceType!==r)return[t("Incorrect resource type")];if(s.id!==i)return[t("Incorrect ID")];const o=await n.updateResource(s);return[c,o]}async function $i(e,t){const{resourceType:n,id:r}=e.params;return await t.deleteResource(n,r),[c]}async function Ci(e,t){const{resourceType:n,id:r}=e.params,i=e.body,s=await t.patchResource(n,r,i);return[c,s]}class Vi{constructor(){this.router=new _i,this.router.add("POST","",wi),this.router.add("GET",":resourceType",Ai),this.router.add("POST",":resourceType/_search",Di),this.router.add("POST",":resourceType",xi),this.router.add("GET",":resourceType/:id",ki),this.router.add("GET",":resourceType/:id/_history",Ri),this.router.add("GET",":resourceType/:id/_history/:vid",Fi),this.router.add("PUT",":resourceType/:id",Li),this.router.add("DELETE",":resourceType/:id",$i),this.router.add("PATCH",":resourceType/:id",Ci),this.router.add("POST","$graphql",ai)}async handleRequest(e,t){const r=this.router.find(e.method,e.pathname);if(!r)return[S];const{handler:i,params:s}=r;e.params=s;try{return await i(e,t,this)}catch(e){return[n(e)]}}}class Ui{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))||[]}}class ji extends Ui{constructor(){super(),this.resources=new Map,this.history=new Map}async createResource(e){const t=A(e);t.id||(t.id=Pi()),t.meta||(t.meta={}),t.meta?.versionId||(t.meta.versionId=Pi()),t.meta?.lastUpdated||(t.meta.lastUpdated=(new Date).toISOString());const{resourceType:n,id:r}=t;let i=this.resources.get(n);i||(i=new Map,this.resources.set(n,i)),i.set(r,t);let s=this.history.get(n);s||(s=new Map,this.history.set(n,s));let o=s.get(r);return o||(o=[],s.set(r,o)),o.push(t),A(t)}updateResource(e){const t=A(e);return t.meta&&(t.meta.versionId&&delete t.meta.versionId,t.meta.lastUpdated&&delete t.meta.lastUpdated),this.createResource(t)}async patchResource(r,i,s){const o=await this.readResource(r,i);try{const n=R(o,s).filter(Boolean);if(n.length>0)throw new e(t(n.map((e=>e.message)).join("\n")))}catch(t){throw new e(n(t))}return this.updateResource(o)}async readResource(t,n){const r=this.resources.get(t)?.get(n);if(!r)throw new e(S);return A(r)}async readReference(n){const r=n.reference?.split("/");if(!r||2!==r.length)throw new e(t("Invalid reference"));return this.readResource(r[0],r[1])}async readReferences(e){return Promise.all(e.map((e=>this.readReference(e))))}async readHistory(e,t){return await this.readResource(e,t),{resourceType:"Bundle",type:"history",entry:(this.history.get(e)?.get(t)||[]).reverse().map((e=>({resource:A(e)})))}}async readVersion(t,n,r){await this.readResource(t,n);const i=this.history.get(t)?.get(n)?.find((e=>e.meta?.versionId===r));if(!i)throw new e(S);return A(i)}async search(e){const{resourceType:t}=e,n=this.resources.get(t)||new Map,r=[];for(const t of n.values())D(t,e)&&r.push(t);let i=r.map((e=>({resource:A(e)})));if(e.sortRules)for(const t of e.sortRules)i=i.sort(((e,n)=>Mi(e.resource,n.resource,t)));return void 0!==e.offset&&(i=i.slice(e.offset)),void 0!==e.count&&(i=i.slice(0,e.count)),{resourceType:"Bundle",type:"searchset",entry:i,total:r.length}}async deleteResource(t,n){if(!this.resources.get(t)?.get(n))throw new e(S);this.resources.get(t)?.delete(n)}}const Mi=(e,t,n)=>{const r=T.types[e.resourceType]?.searchParams?.[n.code],i=r?.expression;if(!i)return 0;const s=JSON.stringify(x(i,e)),o=JSON.stringify(x(i,t));return s.localeCompare(o)*(n.descending?-1:1)},Pi=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}));export{Ui as BaseRepository,Vi as FhirRouter,ji as MemoryRepository,_i as Router};
2
2
  //# sourceMappingURL=index.min.mjs.map