import{C as u}from"./codemirror-CVZ5hDL3.js";import{g as d,a as l,e as m,b as g,c,d as j}from"./SchemaReference-CsUj6pfG.js";import"./index-Cq7z4i0o.js";import"./codemirror-DpyRu-EA.js";import"./forEachState-DETpARGm.js";u.defineOption("jump",!1,(e,r,n)=>{if(n&&n!==u.Init){const t=e.state.jump.onMouseOver;u.off(e.getWrapperElement(),"mouseover",t);const i=e.state.jump.onMouseOut;u.off(e.getWrapperElement(),"mouseout",i),u.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:k.bind(null,e),onKeyDown:y.bind(null,e)};u.on(e.getWrapperElement(),"mouseover",t.onMouseOver),u.on(e.getWrapperElement(),"mouseout",t.onMouseOut),u.on(document,"keydown",t.onKeyDown)}});function M(e,r){const n=r.target||r.srcElement;if(!(n instanceof HTMLElement)||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&&f(e)}function k(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)}function y(e,r){if(e.state.jump.isHoldingModifier||!O(r.key))return;e.state.jump.isHoldingModifier=!0,e.state.jump.cursor&&f(e);const n=o=>{o.code===r.code&&(e.state.jump.isHoldingModifier=!1,e.state.jump.marker&&p(e),u.off(document,"keyup",n),u.off(document,"click",t),e.off("mousedown",i))},t=o=>{const{destination:s,options:a}=e.state.jump;s&&a.onClick(s,o)},i=(o,s)=>{e.state.jump.destination&&(s.codemirrorIgnore=!0)};u.on(document,"keyup",n),u.on(document,"click",t),e.on("mousedown",i)}const D=typeof navigator<"u"&&navigator.userAgent.includes("Mac");function O(e){return e===(D?"Meta":"Control")}function f(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 s=o(i,n,e);if(s){const a=e.markText({line:t.line,ch:i.start},{line:t.line,ch:i.end},{className:"CodeMirror-jump-token"});e.state.jump.marker=a,e.state.jump.destination=s}}}function p(e){const{marker:r}=e.state.jump;e.state.jump.marker=null,e.state.jump.destination=null,r.clear()}u.registerHelper("jump","graphql",(e,r)=>{if(!r.schema||!r.onClick||!e.state)return;const{state:n}=e,{kind:t,step:i}=n,o=d(r.schema,n);if(t==="Field"&&i===0&&o.fieldDef||t==="AliasedField"&&i===2&&o.fieldDef)return l(o);if(t==="Directive"&&i===1&&o.directiveDef)return m(o);if(t==="Argument"&&i===0&&o.argDef)return g(o);if(t==="EnumValue"&&o.enumValue)return c(o);if(t==="NamedType"&&o.type)return j(o)});
//# sourceMappingURL=jump-CyecrQSy.js.map
