import{f as o}from"./forEachState-DETpARGm.js";import{m as t,W as b,E as v,V as k,X as F,Y as g,Z as y,_ as D,e as S}from"./index-Cq7z4i0o.js";function Q(n,l){const e={schema:n,type:null,parentType:null,inputType:null,directiveDef:null,fieldDef:null,argDef:null,argDefs:null,objectFieldDefs:null};return o(l,i=>{var u,p;switch(i.kind){case"Query":case"ShortQuery":e.type=n.getQueryType();break;case"Mutation":e.type=n.getMutationType();break;case"Subscription":e.type=n.getSubscriptionType();break;case"InlineFragment":case"FragmentDefinition":i.type&&(e.type=n.getType(i.type));break;case"Field":case"AliasedField":e.fieldDef=e.type&&i.name?m(n,e.parentType,i.name):null,e.type=(u=e.fieldDef)===null||u===void 0?void 0:u.type;break;case"SelectionSet":e.parentType=e.type?t(e.type):null;break;case"Directive":e.directiveDef=i.name?n.getDirective(i.name):null;break;case"Arguments":const c=i.prevState?i.prevState.kind==="Field"?e.fieldDef:i.prevState.kind==="Directive"?e.directiveDef:i.prevState.kind==="AliasedField"?i.prevState.name&&m(n,e.parentType,i.prevState.name):null:null;e.argDefs=c?c.args:null;break;case"Argument":if(e.argDef=null,e.argDefs){for(let r=0;r<e.argDefs.length;r++)if(e.argDefs[r].name===i.name){e.argDef=e.argDefs[r];break}}e.inputType=(p=e.argDef)===null||p===void 0?void 0:p.type;break;case"EnumValue":const f=e.inputType?t(e.inputType):null;e.enumValue=f instanceof F?h(f.getValues(),r=>r.value===i.name):null;break;case"ListValue":const d=e.inputType?v(e.inputType):null;e.inputType=d instanceof k?d.ofType:null;break;case"ObjectValue":const s=e.inputType?t(e.inputType):null;e.objectFieldDefs=s instanceof b?s.getFields():null;break;case"ObjectField":const a=i.name&&e.objectFieldDefs?e.objectFieldDefs[i.name]:null;e.inputType=a?.type,e.fieldDef=a;break;case"NamedType":e.type=i.name?n.getType(i.name):null;break}}),e}function m(n,l,e){if(e===g.name&&n.getQueryType()===l)return g;if(e===y.name&&n.getQueryType()===l)return y;if(e===D.name&&S(l))return D;if(l&&l.getFields)return l.getFields()[e]}function h(n,l){for(let e=0;e<n.length;e++)if(l(n[e]))return n[e]}function A(n){return{kind:"Field",schema:n.schema,field:n.fieldDef,type:T(n.fieldDef)?null:n.parentType}}function E(n){return{kind:"Directive",schema:n.schema,directive:n.directiveDef}}function M(n){return n.directiveDef?{kind:"Argument",schema:n.schema,argument:n.argDef,directive:n.directiveDef}:{kind:"Argument",schema:n.schema,argument:n.argDef,field:n.fieldDef,type:T(n.fieldDef)?null:n.parentType}}function L(n){return{kind:"EnumValue",value:n.enumValue||void 0,type:n.inputType?t(n.inputType):void 0}}function R(n,l){return{kind:"Type",schema:n.schema,type:l||n.type}}function T(n){return n.name.slice(0,2)==="__"}export{A as a,M as b,L as c,R as d,E as e,Q as g};
//# sourceMappingURL=SchemaReference-CsUj6pfG.js.map
