{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/language/source.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,iCAAgC;AACpD,OAAO,EAAE,UAAU,EAAE,kCAAiC;AAQtD,MAAM,YAAY,GAAkB,MAAM,CAAC,QAAQ,CAAC,CAAC;AASrD,MAAM,OAAO,MAAM;IAiCjB,YACE,IAAY,EACZ,OAAe,iBAAiB,EAChC,iBAA2B,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QAEjD,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;cAEnC,IAAI,CAAC,cAAc,CAAC,IAAI,GAAG,CAAC;YAD9B,SAAS,QAEP,2DAA2D;cAG3D,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC;YADhC,SAAS,QAEP,6DAA6D;IAEjE,CAAC;IAMD,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAOD,MAAM,UAAU,QAAQ,CAAC,MAAe;IACtC,OAAO,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/** @category Source */\n\nimport { devAssert } from '../jsutils/devAssert.ts';\nimport { instanceOf } from '../jsutils/instanceOf.ts';\n\ninterface Location {\n  line: number;\n  column: number;\n}\n\n/** @private */\nconst sourceSymbol: unique symbol = Symbol('Source');\n\n/**\n * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are\n * optional, but they are useful for clients who store GraphQL documents in source files.\n * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might\n * be useful for `name` to be `\"Foo.graphql\"` and location to be `{ line: 40, column: 1 }`.\n * The `line` and `column` properties in `locationOffset` are 1-indexed.\n */\nexport class Source {\n  /**\n   * Internal runtime marker used to identify Source instances.\n   * @private\n   */\n  readonly __kind: symbol;\n\n  /** The GraphQL source text. */\n  body: string;\n  /** Name used in diagnostics for this source, such as a file path or request name. */\n  name: string;\n  /** One-indexed line and column where this source begins. */\n  locationOffset: Location;\n\n  /**\n   * Creates a Source instance.\n   * @param body - The GraphQL source text.\n   * @param name - Name used in diagnostics for this source.\n   * @param locationOffset - One-indexed line and column where this source begins.\n   * @example\n   * ```ts\n   * import { Source } from 'graphql/language';\n   *\n   * const source = new Source('type Query { greeting: String }', 'schema.graphql', {\n   *   line: 10,\n   *   column: 1,\n   * });\n   *\n   * source.body; // => 'type Query { greeting: String }'\n   * source.name; // => 'schema.graphql'\n   * source.locationOffset; // => { line: 10, column: 1 }\n   * ```\n   */\n  constructor(\n    body: string,\n    name: string = 'GraphQL request',\n    locationOffset: Location = { line: 1, column: 1 },\n  ) {\n    this.__kind = sourceSymbol;\n    this.body = body;\n    this.name = name;\n    this.locationOffset = locationOffset;\n    devAssert(\n      this.locationOffset.line > 0,\n      'line in locationOffset is 1-indexed and must be positive.',\n    );\n    devAssert(\n      this.locationOffset.column > 0,\n      'column in locationOffset is 1-indexed and must be positive.',\n    );\n  }\n\n  /**\n   * Returns the value used by `Object.prototype.toString`.\n   * @returns The built-in string tag for this object.\n   */\n  get [Symbol.toStringTag](): string {\n    return 'Source';\n  }\n}\n\n/**\n * Test if the given value is a Source object.\n *\n * @internal\n */\nexport function isSource(source: unknown): source is Source {\n  return instanceOf(source, sourceSymbol, Source);\n}\n"]}