"use strict";var c=Object.defineProperty;var s=(e,r)=>c(e,"name",{value:r,configurable:!0});const u=require("./codemirror.cjs.js"),d=require("./SchemaReference.cjs.js");require("./codemirror.cjs2.js");require("graphql");require("./forEachState.cjs.js");u.CodeMirror.defineOption("jump",!1,(e,r,n)=>{if(n&&n!==u.CodeMirror.Init){const t=e.state.jump.onMouseOver;u.CodeMirror.off(e.getWrapperElement(),"mouseover",t);const i=e.state.jump.onMouseOut;u.CodeMirror.off(e.getWrapperElement(),"mouseout",i),u.CodeMirror.off(document,"keydown",e.state.jump.onKeyDown),delete e.state.jump}if(r){const t=e.state.jump={options:r,onMouseOver:M.bind(null,e),onMouseOut:g.bind(null,e),onKeyDown:m.bind(null,e)};u.CodeMirror.on(e.getWrapperElement(),"mouseover",t.onMouseOver),u.CodeMirror.on(e.getWrapperElement(),"mouseout",t.onMouseOut),u.CodeMirror.on(document,"keydown",t.onKeyDown)}});function M(e,r){const n=r.target||r.srcElement;if(!(n instanceof HTMLElement)||(n==null?void 0:n.nodeName)!=="SPAN")return;const t=n.getBoundingClientRect(),i={left:(t.left+t.right)/2,top:(t.top+t.bottom)/2};e.state.jump.cursor=i,e.state.jump.isHoldingModifier&&l(e)}s(M,"onMouseOver");function g(e){if(!e.state.jump.isHoldingModifier&&e.state.jump.cursor){e.state.jump.cursor=null;return}e.state.jump.isHoldingModifier&&e.state.jump.marker&&p(e)}s(g,"onMouseOut");function m(e,r){if(e.state.jump.isHoldingModifier||!k(r.key))return;e.state.jump.isHoldingModifier=!0,e.state.jump.cursor&&l(e);const n=s(o=>{o.code===r.code&&(e.state.jump.isHoldingModifier=!1,e.state.jump.marker&&p(e),u.CodeMirror.off(document,"keyup",n),u.CodeMirror.off(document,"click",t),e.off("mousedown",i))},"onKeyUp"),t=s(o=>{const{destination:a,options:f}=e.state.jump;a&&f.onClick(a,o)},"onClick"),i=s((o,a)=>{e.state.jump.destination&&(a.codemirrorIgnore=!0)},"onMouseDown");u.CodeMirror.on(document,"keyup",n),u.CodeMirror.on(document,"click",t),e.on("mousedown",i)}s(m,"onKeyDown");const j=typeof navigator<"u"&&(navigator==null?void 0:navigator.appVersion.includes("Mac"));function k(e){return e===(j?"Meta":"Control")}s(k,"isJumpModifier");function l(e){if(e.state.jump.marker)return;const{cursor:r,options:n}=e.state.jump,t=e.coordsChar(r),i=e.getTokenAt(t,!0),o=n.getDestination||e.getHelper(t,"jump");if(o){const a=o(i,n,e);if(a){const f=e.markText({line:t.line,ch:i.start},{line:t.line,ch:i.end},{className:"CodeMirror-jump-token"});e.state.jump.marker=f,e.state.jump.destination=a}}}s(l,"enableJumpMode");function p(e){const{marker:r}=e.state.jump;e.state.jump.marker=null,e.state.jump.destination=null,r.clear()}s(p,"disableJumpMode");u.CodeMirror.registerHelper("jump","graphql",(e,r)=>{if(!r.schema||!r.onClick||!e.state)return;const{state:n}=e,{kind:t,step:i}=n,o=d.getTypeInfo(r.schema,n);if(t==="Field"&&i===0&&o.fieldDef||t==="AliasedField"&&i===2&&o.fieldDef)return d.getFieldReference(o);if(t==="Directive"&&i===1&&o.directiveDef)return d.getDirectiveReference(o);if(t==="Argument"&&i===0&&o.argDef)return d.getArgumentReference(o);if(t==="EnumValue"&&o.enumValue)return d.getEnumValueReference(o);if(t==="NamedType"&&o.type)return d.getTypeReference(o)});
//# sourceMappingURL=jump.cjs.js.map
