import{g as e,h as t,i as n,n as r,t as i,v as a}from"./definition-C7QrKMH2.js";import{i as o,r as s,t as c}from"./introspection-Bq-pnKaY.js";import{t as l}from"./forEachState-CVF2k4ot.js";function u(a,o){let s={schema:a,type:null,parentType:null,inputType:null,directiveDef:null,fieldDef:null,argDef:null,argDefs:null,objectFieldDefs:null};return l(o,o=>{switch(o.kind){case`Query`:case`ShortQuery`:s.type=a.getQueryType();break;case`Mutation`:s.type=a.getMutationType();break;case`Subscription`:s.type=a.getSubscriptionType();break;case`InlineFragment`:case`FragmentDefinition`:o.type&&(s.type=a.getType(o.type));break;case`Field`:case`AliasedField`:s.fieldDef=s.type&&o.name?d(a,s.parentType,o.name):null,s.type=s.fieldDef?.type;break;case`SelectionSet`:s.parentType=s.type?t(s.type):null;break;case`Directive`:s.directiveDef=o.name?a.getDirective(o.name):null;break;case`Arguments`:let c=o.prevState?o.prevState.kind===`Field`?s.fieldDef:o.prevState.kind===`Directive`?s.directiveDef:o.prevState.kind===`AliasedField`?o.prevState.name&&d(a,s.parentType,o.prevState.name):null:null;s.argDefs=c?c.args:null;break;case`Argument`:if(s.argDef=null,s.argDefs){for(let e=0;e<s.argDefs.length;e++)if(s.argDefs[e].name===o.name){s.argDef=s.argDefs[e];break}}s.inputType=s.argDef?.type;break;case`EnumValue`:let l=s.inputType?t(s.inputType):null;s.enumValue=l instanceof i?f(l.getValues(),e=>e.value===o.name):null;break;case`ListValue`:let u=s.inputType?e(s.inputType):null;s.inputType=u instanceof n?u.ofType:null;break;case`ObjectValue`:let p=s.inputType?t(s.inputType):null;s.objectFieldDefs=p instanceof r?p.getFields():null;break;case`ObjectField`:let m=o.name&&s.objectFieldDefs?s.objectFieldDefs[o.name]:null;s.inputType=m?.type,s.fieldDef=m;break;case`NamedType`:s.type=o.name?a.getType(o.name):null;break}}),s}function d(e,t,n){if(n===c.name&&e.getQueryType()===t)return c;if(n===s.name&&e.getQueryType()===t)return s;if(n===o.name&&a(t))return o;if(t&&t.getFields)return t.getFields()[n]}function f(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n]}function p(e){return{kind:`Field`,schema:e.schema,field:e.fieldDef,type:v(e.fieldDef)?null:e.parentType}}function m(e){return{kind:`Directive`,schema:e.schema,directive:e.directiveDef}}function h(e){return e.directiveDef?{kind:`Argument`,schema:e.schema,argument:e.argDef,directive:e.directiveDef}:{kind:`Argument`,schema:e.schema,argument:e.argDef,field:e.fieldDef,type:v(e.fieldDef)?null:e.parentType}}function g(e){return{kind:`EnumValue`,value:e.enumValue||void 0,type:e.inputType?t(e.inputType):void 0}}function _(e,t){return{kind:`Type`,schema:e.schema,type:t||e.type}}function v(e){return e.name.slice(0,2)===`__`}export{_ as a,p as i,m as n,u as o,g as r,h as t};
//# sourceMappingURL=SchemaReference-DSzhn1RO.js.map