"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var TokenStream_exports = {};
__export(TokenStream_exports, {
  TokenStream: () => TokenStream
});
module.exports = __toCommonJS(TokenStream_exports);
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function TokenStream(iterator) {
  let done = false;
  function next() {
    if (done) {
      return void 0;
    }
    const n = iterator.next();
    if (n.done) {
      done = true;
    }
    return n.value;
  }
  return {
    token: next(),
    peeked: next(),
    get done() {
      return this.token === void 0;
    },
    next() {
      this.token = this.peeked;
      this.peeked = next();
    },
    get description() {
      switch (this.token?.type) {
        case void 0:
          return "end of statement";
        case "word":
          return `word "${this.token.value}"`;
        case "value":
          return `value "${this.token.value}"`;
        default:
          if (this.token?.type.match(/[a-z]/i)) {
            return `keyword "${this.token?.type}"`;
          }
          return `operator "${this.token?.type}"`;
      }
    }
  };
}
//# sourceMappingURL=TokenStream.js.map
