// src/registry.ts
var tokenizers = /* @__PURE__ */ new Map();
var profiles = /* @__PURE__ */ new Map();
var patternCache = /* @__PURE__ */ new Map();
function registerLanguage(code, tokenizer, profile) {
  tokenizers.set(code, tokenizer);
  profiles.set(code, profile);
  patternCache.delete(code);
}

// src/tokenizers/base.ts
var TokenStreamImpl = class {
  constructor(tokens, language) {
    this.pos = 0;
    this.tokens = tokens;
    this.language = language;
  }
  peek(offset = 0) {
    const index = this.pos + offset;
    if (index < 0 || index >= this.tokens.length) {
      return null;
    }
    return this.tokens[index];
  }
  advance() {
    if (this.isAtEnd()) {
      throw new Error("Unexpected end of token stream");
    }
    return this.tokens[this.pos++];
  }
  isAtEnd() {
    return this.pos >= this.tokens.length;
  }
  mark() {
    return { position: this.pos };
  }
  reset(mark) {
    this.pos = mark.position;
  }
  position() {
    return this.pos;
  }
  /**
   * Get remaining tokens as an array.
   */
  remaining() {
    return this.tokens.slice(this.pos);
  }
  /**
   * Consume tokens while predicate is true.
   */
  takeWhile(predicate) {
    const result = [];
    while (!this.isAtEnd() && predicate(this.peek())) {
      result.push(this.advance());
    }
    return result;
  }
  /**
   * Skip tokens while predicate is true.
   */
  skipWhile(predicate) {
    while (!this.isAtEnd() && predicate(this.peek())) {
      this.advance();
    }
  }
};
function createPosition(start, end) {
  return { start, end };
}
function createToken(value, kind, position, normalizedOrOptions) {
  if (typeof normalizedOrOptions === "string") {
    return { value, kind, position, normalized: normalizedOrOptions };
  }
  if (normalizedOrOptions) {
    const { normalized, stem, stemConfidence } = normalizedOrOptions;
    const token = { value, kind, position };
    if (normalized !== void 0) {
      token.normalized = normalized;
    }
    if (stem !== void 0) {
      token.stem = stem;
      if (stemConfidence !== void 0) {
        token.stemConfidence = stemConfidence;
      }
    }
    return token;
  }
  return { value, kind, position };
}
function isWhitespace(char) {
  return /\s/.test(char);
}
function isSelectorStart(char) {
  return char === "#" || char === "." || char === "[" || char === "@" || char === "*" || char === "<";
}
function isQuote(char) {
  return char === '"' || char === "'" || char === "`" || char === "\u300C" || char === "\u300D";
}
function isDigit(char) {
  return /\d/.test(char);
}
function isAsciiLetter(char) {
  return /[a-zA-Z]/.test(char);
}
function isAsciiIdentifierChar(char) {
  return /[a-zA-Z0-9_-]/.test(char);
}
function createUnicodeRangeClassifier(ranges) {
  return (char) => {
    const code = char.charCodeAt(0);
    return ranges.some(([start, end]) => code >= start && code <= end);
  };
}
function extractCssSelector(input, startPos) {
  if (startPos >= input.length) return null;
  const char = input[startPos];
  if (!isSelectorStart(char)) return null;
  let pos = startPos;
  let selector = "";
  if (char === "#" || char === ".") {
    selector += input[pos++];
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      selector += input[pos++];
    }
    if (selector.length <= 1) return null;
    if (pos < input.length && input[pos] === "." && char === "#") {
      const methodStart = pos + 1;
      let methodEnd = methodStart;
      while (methodEnd < input.length && isAsciiIdentifierChar(input[methodEnd])) {
        methodEnd++;
      }
      if (methodEnd < input.length && input[methodEnd] === "(") {
        return selector;
      }
    }
  } else if (char === "[") {
    let depth = 1;
    let inQuote = false;
    let quoteChar = null;
    let escaped = false;
    selector += input[pos++];
    while (pos < input.length && depth > 0) {
      const c = input[pos];
      selector += c;
      if (escaped) {
        escaped = false;
      } else if (c === "\\") {
        escaped = true;
      } else if (inQuote) {
        if (c === quoteChar) {
          inQuote = false;
          quoteChar = null;
        }
      } else {
        if (c === '"' || c === "'" || c === "`") {
          inQuote = true;
          quoteChar = c;
        } else if (c === "[") {
          depth++;
        } else if (c === "]") {
          depth--;
        }
      }
      pos++;
    }
    if (depth !== 0) return null;
  } else if (char === "@") {
    selector += input[pos++];
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      selector += input[pos++];
    }
    if (selector.length <= 1) return null;
  } else if (char === "*") {
    selector += input[pos++];
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      selector += input[pos++];
    }
    if (selector.length <= 1) return null;
  } else if (char === "<") {
    selector += input[pos++];
    if (pos >= input.length || !isAsciiLetter(input[pos])) return null;
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      selector += input[pos++];
    }
    while (pos < input.length) {
      const modChar = input[pos];
      if (modChar === ".") {
        selector += input[pos++];
        if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {
          return null;
        }
        while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
          selector += input[pos++];
        }
      } else if (modChar === "#") {
        selector += input[pos++];
        if (pos >= input.length || !isAsciiIdentifierChar(input[pos])) {
          return null;
        }
        while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
          selector += input[pos++];
        }
      } else if (modChar === "[") {
        let depth = 1;
        let inQuote = false;
        let quoteChar = null;
        let escaped = false;
        selector += input[pos++];
        while (pos < input.length && depth > 0) {
          const c = input[pos];
          selector += c;
          if (escaped) {
            escaped = false;
          } else if (c === "\\") {
            escaped = true;
          } else if (inQuote) {
            if (c === quoteChar) {
              inQuote = false;
              quoteChar = null;
            }
          } else {
            if (c === '"' || c === "'" || c === "`") {
              inQuote = true;
              quoteChar = c;
            } else if (c === "[") {
              depth++;
            } else if (c === "]") {
              depth--;
            }
          }
          pos++;
        }
        if (depth !== 0) return null;
      } else {
        break;
      }
    }
    while (pos < input.length && isWhitespace(input[pos])) {
      selector += input[pos++];
    }
    if (pos < input.length && input[pos] === "/") {
      selector += input[pos++];
      while (pos < input.length && isWhitespace(input[pos])) {
        selector += input[pos++];
      }
    }
    if (pos >= input.length || input[pos] !== ">") return null;
    selector += input[pos++];
  }
  return selector || null;
}
function isPossessiveMarker(input, pos) {
  if (pos >= input.length || input[pos] !== "'") return false;
  if (pos + 1 >= input.length) return false;
  const nextChar = input[pos + 1].toLowerCase();
  if (nextChar !== "s") return false;
  if (pos + 2 >= input.length) return true;
  const afterS = input[pos + 2];
  return isWhitespace(afterS) || afterS === "*" || !isAsciiIdentifierChar(afterS);
}
function extractStringLiteral(input, startPos) {
  if (startPos >= input.length) return null;
  const openQuote = input[startPos];
  if (!isQuote(openQuote)) return null;
  if (openQuote === "'" && isPossessiveMarker(input, startPos)) {
    return null;
  }
  const closeQuoteMap = {
    '"': '"',
    "'": "'",
    "`": "`",
    "\u300C": "\u300D"
  };
  const closeQuote = closeQuoteMap[openQuote];
  if (!closeQuote) return null;
  let pos = startPos + 1;
  let literal = openQuote;
  let escaped = false;
  while (pos < input.length) {
    const char = input[pos];
    literal += char;
    if (escaped) {
      escaped = false;
    } else if (char === "\\") {
      escaped = true;
    } else if (char === closeQuote) {
      return literal;
    }
    pos++;
  }
  return literal;
}
function isUrlStart(input, pos) {
  if (pos >= input.length) return false;
  const char = input[pos];
  const next = input[pos + 1] || "";
  const third = input[pos + 2] || "";
  if (char === "/" && next !== "/" && /[a-zA-Z0-9._-]/.test(next)) {
    return true;
  }
  if (char === "/" && next === "/" && /[a-zA-Z]/.test(third)) {
    return true;
  }
  if (char === "." && (next === "/" || next === "." && third === "/")) {
    return true;
  }
  const slice = input.slice(pos, pos + 8).toLowerCase();
  if (slice.startsWith("http://") || slice.startsWith("https://")) {
    return true;
  }
  return false;
}
function extractUrl(input, startPos) {
  if (!isUrlStart(input, startPos)) return null;
  let pos = startPos;
  let url = "";
  const urlChars = /[a-zA-Z0-9/:._\-?&=%@+~!$'()*,;[\]]/;
  while (pos < input.length) {
    const char = input[pos];
    if (char === "#") {
      if (url.length > 0 && /[a-zA-Z0-9/.]$/.test(url)) {
        url += char;
        pos++;
        while (pos < input.length && /[a-zA-Z0-9_-]/.test(input[pos])) {
          url += input[pos++];
        }
      }
      break;
    }
    if (urlChars.test(char)) {
      url += char;
      pos++;
    } else {
      break;
    }
  }
  if (url.length < 2) return null;
  return url;
}
function extractNumber(input, startPos) {
  if (startPos >= input.length) return null;
  const char = input[startPos];
  if (!isDigit(char) && char !== "-" && char !== "+") return null;
  let pos = startPos;
  let number = "";
  if (input[pos] === "-" || input[pos] === "+") {
    number += input[pos++];
  }
  if (pos >= input.length || !isDigit(input[pos])) {
    return null;
  }
  while (pos < input.length && isDigit(input[pos])) {
    number += input[pos++];
  }
  if (pos < input.length && input[pos] === ".") {
    number += input[pos++];
    while (pos < input.length && isDigit(input[pos])) {
      number += input[pos++];
    }
  }
  if (pos < input.length) {
    const suffix = input.slice(pos, pos + 2);
    if (suffix === "ms") {
      number += "ms";
    } else if (input[pos] === "s" || input[pos] === "m" || input[pos] === "h") {
      number += input[pos];
    }
  }
  return number;
}
var _BaseTokenizer = class _BaseTokenizer {
  constructor() {
    /** Keywords derived from profile, sorted longest-first for greedy matching */
    this.profileKeywords = [];
    /** Map for O(1) keyword lookups by lowercase native word */
    this.profileKeywordMap = /* @__PURE__ */ new Map();
  }
  /**
   * Initialize keyword mappings from a language profile.
   * Builds a list of native→english mappings from:
   * - profile.keywords (primary + alternatives)
   * - profile.references (me, it, you, etc.)
   * - profile.roleMarkers (into, from, with, etc.)
   *
   * Results are sorted longest-first for greedy matching (important for non-space languages).
   * Extras take precedence over profile entries when there are duplicates.
   *
   * @param profile - Language profile containing keyword translations
   * @param extras - Additional keyword entries to include (literals, positional, events)
   */
  initializeKeywordsFromProfile(profile, extras = []) {
    const keywordMap = /* @__PURE__ */ new Map();
    if (profile.keywords) {
      for (const [normalized, translation] of Object.entries(profile.keywords)) {
        keywordMap.set(translation.primary, {
          native: translation.primary,
          normalized: translation.normalized || normalized
        });
        if (translation.alternatives) {
          for (const alt of translation.alternatives) {
            keywordMap.set(alt, {
              native: alt,
              normalized: translation.normalized || normalized
            });
          }
        }
      }
    }
    if (profile.references) {
      for (const [normalized, native] of Object.entries(profile.references)) {
        keywordMap.set(native, { native, normalized });
      }
    }
    if (profile.roleMarkers) {
      for (const [role, marker] of Object.entries(profile.roleMarkers)) {
        if (marker.primary) {
          keywordMap.set(marker.primary, { native: marker.primary, normalized: role });
        }
        if (marker.alternatives) {
          for (const alt of marker.alternatives) {
            keywordMap.set(alt, { native: alt, normalized: role });
          }
        }
      }
    }
    for (const extra of extras) {
      keywordMap.set(extra.native, extra);
    }
    this.profileKeywords = Array.from(keywordMap.values()).sort(
      (a, b) => b.native.length - a.native.length
    );
    this.profileKeywordMap = /* @__PURE__ */ new Map();
    for (const keyword of this.profileKeywords) {
      this.profileKeywordMap.set(keyword.native.toLowerCase(), keyword);
      const normalized = this.removeDiacritics(keyword.native);
      if (normalized !== keyword.native && !this.profileKeywordMap.has(normalized.toLowerCase())) {
        this.profileKeywordMap.set(normalized.toLowerCase(), keyword);
      }
    }
  }
  /**
   * Remove diacritical marks from a word for normalization.
   * Primarily for Arabic (shadda, fatha, kasra, damma, sukun, etc.)
   * but could be extended for other languages.
   *
   * @param word - Word to normalize
   * @returns Word without diacritics
   */
  removeDiacritics(word) {
    return word.replace(/[\u064B-\u0652\u0670]/g, "");
  }
  /**
   * Try to match a keyword from profile at the current position.
   * Uses longest-first greedy matching (important for non-space languages).
   *
   * @param input - Input string
   * @param pos - Current position
   * @returns Token if matched, null otherwise
   */
  tryProfileKeyword(input, pos) {
    for (const entry of this.profileKeywords) {
      if (input.slice(pos).startsWith(entry.native)) {
        return createToken(
          entry.native,
          "keyword",
          createPosition(pos, pos + entry.native.length),
          entry.normalized
        );
      }
    }
    return null;
  }
  /**
   * Check if the remaining input starts with any known keyword.
   * Useful for non-space languages to detect word boundaries.
   *
   * @param input - Input string
   * @param pos - Current position
   * @returns true if a keyword starts at this position
   */
  isKeywordStart(input, pos) {
    const remaining = input.slice(pos);
    return this.profileKeywords.some((entry) => remaining.startsWith(entry.native));
  }
  /**
   * Look up a keyword by native word (case-insensitive).
   * O(1) lookup using the keyword map.
   *
   * @param native - Native word to look up
   * @returns KeywordEntry if found, undefined otherwise
   */
  lookupKeyword(native) {
    return this.profileKeywordMap.get(native.toLowerCase());
  }
  /**
   * Check if a word is a known keyword (case-insensitive).
   * O(1) lookup using the keyword map.
   *
   * @param native - Native word to check
   * @returns true if the word is a keyword
   */
  isKeyword(native) {
    return this.profileKeywordMap.has(native.toLowerCase());
  }
  /**
   * Set the morphological normalizer for this tokenizer.
   */
  setNormalizer(normalizer) {
    this.normalizer = normalizer;
  }
  /**
   * Try to normalize a word using the morphological normalizer.
   * Returns null if no normalizer is set or normalization fails.
   *
   * Note: We don't check isNormalizable() here because the individual tokenizers
   * historically called normalize() directly without that check. The normalize()
   * method itself handles returning noChange() for words that can't be normalized.
   */
  tryNormalize(word) {
    if (!this.normalizer) return null;
    const result = this.normalizer.normalize(word);
    if (result.stem !== word && result.confidence >= 0.7) {
      return result;
    }
    return null;
  }
  /**
   * Try morphological normalization and keyword lookup.
   *
   * If the word can be normalized to a stem that matches a known keyword,
   * returns a keyword token with morphological metadata (stem, stemConfidence).
   *
   * This is the common pattern for handling conjugated verbs across languages:
   * 1. Normalize the word (e.g., "toggled" → "toggle")
   * 2. Look up the stem in the keyword map
   * 3. Create a token with both the original form and stem metadata
   *
   * @param word - The word to normalize and look up
   * @param startPos - Start position for the token
   * @param endPos - End position for the token
   * @returns Token if stem matches a keyword, null otherwise
   */
  tryMorphKeywordMatch(word, startPos, endPos) {
    const result = this.tryNormalize(word);
    if (!result) return null;
    const stemEntry = this.lookupKeyword(result.stem);
    if (!stemEntry) return null;
    const tokenOptions = {
      normalized: stemEntry.normalized,
      stem: result.stem,
      stemConfidence: result.confidence
    };
    return createToken(word, "keyword", createPosition(startPos, endPos), tokenOptions);
  }
  /**
   * Try to extract a CSS selector at the current position.
   */
  trySelector(input, pos) {
    const selector = extractCssSelector(input, pos);
    if (selector) {
      return createToken(selector, "selector", createPosition(pos, pos + selector.length));
    }
    return null;
  }
  /**
   * Try to extract an event modifier at the current position.
   * Event modifiers are .once, .debounce(N), .throttle(N), .queue(strategy)
   */
  tryEventModifier(input, pos) {
    if (input[pos] !== ".") {
      return null;
    }
    const match = input.slice(pos).match(/^\.(?:once|debounce|throttle|queue)(?:\(([^)]+)\))?(?:\s|$|\.)/);
    if (!match) {
      return null;
    }
    const fullMatch = match[0].replace(/(\s|\.)$/, "");
    const modifierName = fullMatch.slice(1).split("(")[0];
    const value = match[1];
    const token = createToken(
      fullMatch,
      "event-modifier",
      createPosition(pos, pos + fullMatch.length)
    );
    return {
      ...token,
      metadata: {
        modifierName,
        value: value ? modifierName === "queue" ? value : parseInt(value, 10) : void 0
      }
    };
  }
  /**
   * Try to extract a string literal at the current position.
   */
  tryString(input, pos) {
    const literal = extractStringLiteral(input, pos);
    if (literal) {
      return createToken(literal, "literal", createPosition(pos, pos + literal.length));
    }
    return null;
  }
  /**
   * Try to extract a number at the current position.
   */
  tryNumber(input, pos) {
    const number = extractNumber(input, pos);
    if (number) {
      return createToken(number, "literal", createPosition(pos, pos + number.length));
    }
    return null;
  }
  /**
   * Try to match a time unit from a list of patterns.
   *
   * @param input - Input string
   * @param pos - Position after the number
   * @param timeUnits - Array of time unit mappings (native pattern → standard suffix)
   * @param skipWhitespace - Whether to skip whitespace before time unit (default: false)
   * @returns Object with matched suffix and new position, or null if no match
   */
  tryMatchTimeUnit(input, pos, timeUnits, skipWhitespace = false) {
    let unitPos = pos;
    if (skipWhitespace) {
      while (unitPos < input.length && isWhitespace(input[unitPos])) {
        unitPos++;
      }
    }
    const remaining = input.slice(unitPos);
    for (const unit of timeUnits) {
      const candidate = remaining.slice(0, unit.length);
      const matches = unit.caseInsensitive ? candidate.toLowerCase() === unit.pattern.toLowerCase() : candidate === unit.pattern;
      if (matches) {
        if (unit.notFollowedBy) {
          const nextChar = remaining[unit.length] || "";
          if (nextChar === unit.notFollowedBy) continue;
        }
        if (unit.checkBoundary) {
          const nextChar = remaining[unit.length] || "";
          if (isAsciiIdentifierChar(nextChar)) continue;
        }
        return { suffix: unit.suffix, endPos: unitPos + unit.length };
      }
    }
    return null;
  }
  /**
   * Parse a base number (sign, integer, decimal) without time units.
   * Returns the number string and end position.
   *
   * @param input - Input string
   * @param startPos - Start position
   * @param allowSign - Whether to allow +/- sign (default: true)
   * @returns Object with number string and end position, or null
   */
  parseBaseNumber(input, startPos, allowSign = true) {
    let pos = startPos;
    let number = "";
    if (allowSign && (input[pos] === "-" || input[pos] === "+")) {
      number += input[pos++];
    }
    if (pos >= input.length || !isDigit(input[pos])) {
      return null;
    }
    while (pos < input.length && isDigit(input[pos])) {
      number += input[pos++];
    }
    if (pos < input.length && input[pos] === ".") {
      number += input[pos++];
      while (pos < input.length && isDigit(input[pos])) {
        number += input[pos++];
      }
    }
    if (!number || number === "-" || number === "+") return null;
    return { number, endPos: pos };
  }
  /**
   * Try to extract a number with native language time units.
   *
   * This is a template method that handles the common pattern:
   * 1. Parse the base number (sign, integer, decimal)
   * 2. Try to match native language time units
   * 3. Fall back to standard time units (ms, s, m, h)
   *
   * @param input - Input string
   * @param pos - Start position
   * @param nativeTimeUnits - Language-specific time unit mappings
   * @param options - Configuration options
   * @returns Token if number found, null otherwise
   */
  tryNumberWithTimeUnits(input, pos, nativeTimeUnits, options = {}) {
    const { allowSign = true, skipWhitespace = false } = options;
    const baseResult = this.parseBaseNumber(input, pos, allowSign);
    if (!baseResult) return null;
    let { number, endPos } = baseResult;
    const allUnits = [...nativeTimeUnits, ..._BaseTokenizer.STANDARD_TIME_UNITS];
    const timeMatch = this.tryMatchTimeUnit(input, endPos, allUnits, skipWhitespace);
    if (timeMatch) {
      number += timeMatch.suffix;
      endPos = timeMatch.endPos;
    }
    return createToken(number, "literal", createPosition(pos, endPos));
  }
  /**
   * Try to extract a URL at the current position.
   * Handles /path, ./path, ../path, //domain.com, http://, https://
   */
  tryUrl(input, pos) {
    const url = extractUrl(input, pos);
    if (url) {
      return createToken(url, "url", createPosition(pos, pos + url.length));
    }
    return null;
  }
  /**
   * Try to extract a variable reference (:varname) at the current position.
   * In hyperscript, :x refers to a local variable named x.
   */
  tryVariableRef(input, pos) {
    if (input[pos] !== ":") return null;
    if (pos + 1 >= input.length) return null;
    if (!isAsciiIdentifierChar(input[pos + 1])) return null;
    let endPos = pos + 1;
    while (endPos < input.length && isAsciiIdentifierChar(input[endPos])) {
      endPos++;
    }
    const varRef = input.slice(pos, endPos);
    return createToken(varRef, "identifier", createPosition(pos, endPos));
  }
  /**
   * Try to extract an operator or punctuation token at the current position.
   * Handles two-character operators (==, !=, etc.) and single-character operators.
   */
  tryOperator(input, pos) {
    const twoChar = input.slice(pos, pos + 2);
    if (["==", "!=", "<=", ">=", "&&", "||", "->"].includes(twoChar)) {
      return createToken(twoChar, "operator", createPosition(pos, pos + 2));
    }
    const oneChar = input[pos];
    if (["<", ">", "!", "+", "-", "*", "/", "="].includes(oneChar)) {
      return createToken(oneChar, "operator", createPosition(pos, pos + 1));
    }
    if (["(", ")", "{", "}", ",", ";", ":"].includes(oneChar)) {
      return createToken(oneChar, "punctuation", createPosition(pos, pos + 1));
    }
    return null;
  }
  /**
   * Try to match a multi-character particle from a list.
   *
   * Used by languages like Japanese, Korean, and Chinese that have
   * multi-character particles (e.g., Japanese から, まで, より).
   *
   * @param input - Input string
   * @param pos - Current position
   * @param particles - Array of multi-character particles to match
   * @returns Token if matched, null otherwise
   */
  tryMultiCharParticle(input, pos, particles) {
    for (const particle of particles) {
      if (input.slice(pos, pos + particle.length) === particle) {
        return createToken(particle, "particle", createPosition(pos, pos + particle.length));
      }
    }
    return null;
  }
};
/**
 * Configuration for native language time units.
 * Maps patterns to their standard suffix (ms, s, m, h).
 */
_BaseTokenizer.STANDARD_TIME_UNITS = [
  { pattern: "ms", suffix: "ms", length: 2 },
  { pattern: "s", suffix: "s", length: 1, checkBoundary: true },
  { pattern: "m", suffix: "m", length: 1, checkBoundary: true, notFollowedBy: "s" },
  { pattern: "h", suffix: "h", length: 1, checkBoundary: true }
];
var BaseTokenizer = _BaseTokenizer;

// src/generators/profiles/hebrew.ts
var hebrewProfile = {
  code: "he",
  name: "Hebrew",
  nativeName: "\u05E2\u05D1\u05E8\u05D9\u05EA",
  direction: "rtl",
  wordOrder: "SVO",
  markingStrategy: "preposition",
  usesSpaces: true,
  verb: {
    position: "second",
    // SVO - verb comes after subject
    subjectDrop: true
  },
  references: {
    me: "\u05D0\u05E0\u05D9",
    // "I/me"
    it: "\u05D6\u05D4",
    // "it" (masculine) / "this"
    you: "\u05D0\u05EA\u05D4",
    // "you" (masculine singular)
    result: "\u05EA\u05D5\u05E6\u05D0\u05D4",
    event: "\u05D0\u05D9\u05E8\u05D5\u05E2",
    target: "\u05D9\u05E2\u05D3",
    body: "\u05D2\u05D5\u05E3"
  },
  possessive: {
    marker: "\u05E9\u05DC",
    // "of" - used for general possession
    markerPosition: "before-property",
    usePossessiveAdjectives: true,
    specialForms: {
      // Hebrew: "property שלי" (property of-me) - possessive follows property
      me: "\u05E9\u05DC\u05D9",
      // "of me" / "mine"
      it: "\u05E9\u05DC\u05D5",
      // "of it" / "its" (masculine)
      you: "\u05E9\u05DC\u05DA"
      // "of you" / "yours"
    },
    keywords: {
      // "my" / "mine"
      \u05E9\u05DC\u05D9: "me",
      // "your" / "yours"
      \u05E9\u05DC\u05DA: "you",
      // "its/his/her"
      \u05E9\u05DC\u05D5: "it",
      // his/its (masculine)
      \u05E9\u05DC\u05D4: "it"
      // her/its (feminine)
    }
  },
  roleMarkers: {
    destination: { primary: "\u05E2\u05DC", alternatives: ["\u05D1", "\u05D0\u05DC", "\u05DC"], position: "before" },
    source: { primary: "\u05DE", alternatives: ["\u05DE\u05DF", "\u05DE\u05D0\u05EA"], position: "before" },
    patient: { primary: "\u05D0\u05EA", position: "before" },
    // Direct object marker
    style: { primary: "\u05E2\u05DD", alternatives: ["\u05D1"], position: "before" }
  },
  keywords: {
    // Class/Attribute operations
    toggle: { primary: "\u05D4\u05D7\u05DC\u05E3", alternatives: ["\u05E9\u05E0\u05D4", "\u05D4\u05E4\u05D5\u05DA"], normalized: "toggle" },
    add: { primary: "\u05D4\u05D5\u05E1\u05E3", alternatives: ["\u05D4\u05DB\u05E0\u05E1"], normalized: "add" },
    remove: { primary: "\u05D4\u05E1\u05E8", alternatives: ["\u05DE\u05D7\u05E7", "\u05D4\u05D5\u05E8\u05D3"], normalized: "remove" },
    // Content operations
    put: { primary: "\u05E9\u05D9\u05DD", alternatives: ["\u05D4\u05E0\u05D7", "\u05D4\u05DB\u05E0\u05E1"], normalized: "put" },
    append: { primary: "\u05E6\u05E8\u05E3", alternatives: ["\u05D4\u05D5\u05E1\u05E3 \u05D1\u05E1\u05D5\u05E3"], normalized: "append" },
    prepend: { primary: "\u05D4\u05E7\u05D3\u05DD", alternatives: ["\u05D4\u05D5\u05E1\u05E3 \u05D1\u05D4\u05EA\u05D7\u05DC\u05D4"], normalized: "prepend" },
    take: { primary: "\u05E7\u05D7", normalized: "take" },
    make: { primary: "\u05E6\u05D5\u05E8", alternatives: ["\u05D4\u05DB\u05DF"], normalized: "make" },
    clone: { primary: "\u05E9\u05DB\u05E4\u05DC", alternatives: ["\u05D4\u05E2\u05EA\u05E7"], normalized: "clone" },
    swap: { primary: "\u05D4\u05D7\u05DC\u05E3", alternatives: ["\u05D4\u05DE\u05E8"], normalized: "swap" },
    morph: { primary: "\u05D4\u05E4\u05D5\u05DA", alternatives: ["\u05E9\u05E0\u05D4"], normalized: "morph" },
    // Variable operations
    set: { primary: "\u05E7\u05D1\u05E2", alternatives: ["\u05D4\u05D2\u05D3\u05E8"], normalized: "set" },
    get: { primary: "\u05E7\u05D1\u05DC", alternatives: ["\u05D4\u05E9\u05D2"], normalized: "get" },
    increment: { primary: "\u05D4\u05D2\u05D3\u05DC", alternatives: ["\u05D4\u05D5\u05E1\u05E3 \u05D0\u05D7\u05D3"], normalized: "increment" },
    decrement: { primary: "\u05D4\u05E7\u05D8\u05DF", alternatives: ["\u05D4\u05E4\u05D7\u05EA"], normalized: "decrement" },
    log: { primary: "\u05E8\u05E9\u05D5\u05DD", normalized: "log" },
    // Visibility
    show: { primary: "\u05D4\u05E8\u05D0\u05D4", alternatives: ["\u05D4\u05E6\u05D2"], normalized: "show" },
    hide: { primary: "\u05D4\u05E1\u05EA\u05E8", alternatives: ["\u05D4\u05D7\u05D1\u05D0"], normalized: "hide" },
    transition: { primary: "\u05DE\u05E2\u05D1\u05E8", alternatives: ["\u05D4\u05E0\u05E4\u05E9"], normalized: "transition" },
    // Events
    on: { primary: "\u05D1", alternatives: ["\u05DB\u05E9", "\u05DB\u05D0\u05E9\u05E8", "\u05E2\u05DD"], normalized: "on" },
    trigger: { primary: "\u05D4\u05E4\u05E2\u05DC", alternatives: ["\u05E9\u05D2\u05E8"], normalized: "trigger" },
    send: { primary: "\u05E9\u05DC\u05D7", normalized: "send" },
    // DOM focus
    focus: { primary: "\u05DE\u05E7\u05D3", alternatives: ["\u05D4\u05EA\u05DE\u05E7\u05D3"], normalized: "focus" },
    blur: { primary: "\u05D8\u05E9\u05D8\u05E9", alternatives: ["\u05D4\u05E1\u05E8 \u05DE\u05D9\u05E7\u05D5\u05D3"], normalized: "blur" },
    // Navigation
    go: { primary: "\u05DC\u05DA", alternatives: ["\u05E0\u05D5\u05D5\u05D8", "\u05E2\u05D1\u05D5\u05E8"], normalized: "go" },
    // Async
    wait: { primary: "\u05D7\u05DB\u05D4", alternatives: ["\u05D4\u05DE\u05EA\u05DF"], normalized: "wait" },
    fetch: { primary: "\u05D4\u05D1\u05D0", alternatives: ["\u05D8\u05E2\u05DF"], normalized: "fetch" },
    settle: { primary: "\u05D4\u05EA\u05D9\u05D9\u05E6\u05D1", normalized: "settle" },
    // Control flow
    if: { primary: "\u05D0\u05DD", normalized: "if" },
    when: { primary: "\u05DB\u05D0\u05E9\u05E8", alternatives: ["\u05DB\u05E9"], normalized: "when" },
    where: { primary: "\u05D0\u05D9\u05E4\u05D4", alternatives: ["\u05D4\u05D9\u05DB\u05DF"], normalized: "where" },
    else: { primary: "\u05D0\u05D7\u05E8\u05EA", alternatives: ["\u05D0\u05DD \u05DC\u05D0"], normalized: "else" },
    repeat: { primary: "\u05D7\u05D6\u05D5\u05E8", normalized: "repeat" },
    for: { primary: "\u05E2\u05D1\u05D5\u05E8", alternatives: ["\u05DC\u05DB\u05DC"], normalized: "for" },
    while: { primary: "\u05DB\u05DC \u05E2\u05D5\u05D3", alternatives: ["\u05D1\u05D6\u05DE\u05DF"], normalized: "while" },
    continue: { primary: "\u05D4\u05DE\u05E9\u05DA", normalized: "continue" },
    halt: { primary: "\u05E2\u05E6\u05D5\u05E8", alternatives: ["\u05D4\u05E4\u05E1\u05E7"], normalized: "halt" },
    throw: { primary: "\u05D6\u05E8\u05D5\u05E7", normalized: "throw" },
    call: { primary: "\u05E7\u05E8\u05D0", alternatives: ["\u05D4\u05E4\u05E2\u05DC"], normalized: "call" },
    return: { primary: "\u05D4\u05D7\u05D6\u05E8", alternatives: ["\u05D7\u05D6\u05D5\u05E8"], normalized: "return" },
    then: { primary: "\u05D0\u05D6", alternatives: ["\u05D0\u05D7\u05E8\u05D9", "\u05D5\u05D0\u05D6"], normalized: "then" },
    and: { primary: "\u05D5\u05D2\u05DD", alternatives: ["\u05D2\u05DD"], normalized: "and" },
    end: { primary: "\u05E1\u05D5\u05E3", alternatives: ["\u05E1\u05D9\u05D5\u05DD"], normalized: "end" },
    // Advanced
    js: { primary: "js", alternatives: ["\u05D2\u05F3\u05D0\u05D5\u05D5\u05D4\u05E1\u05E7\u05E8\u05D9\u05E4\u05D8"], normalized: "js" },
    async: { primary: "\u05D0\u05E1\u05D9\u05E0\u05DB\u05E8\u05D5\u05E0\u05D9", normalized: "async" },
    tell: { primary: "\u05D0\u05DE\u05D5\u05E8", normalized: "tell" },
    default: { primary: "\u05D1\u05E8\u05D9\u05E8\u05EA \u05DE\u05D7\u05D3\u05DC", normalized: "default" },
    init: { primary: "\u05D0\u05EA\u05D7\u05DC", alternatives: ["\u05D4\u05EA\u05D7\u05DC"], normalized: "init" },
    behavior: { primary: "\u05D4\u05EA\u05E0\u05D4\u05D2\u05D5\u05EA", normalized: "behavior" },
    install: { primary: "\u05D4\u05EA\u05E7\u05DF", normalized: "install" },
    measure: { primary: "\u05DE\u05D3\u05D5\u05D3", normalized: "measure" },
    // Modifiers
    into: { primary: "\u05DC\u05EA\u05D5\u05DA", alternatives: ["\u05D0\u05DC"], normalized: "into" },
    before: { primary: "\u05DC\u05E4\u05E0\u05D9", normalized: "before" },
    after: { primary: "\u05D0\u05D7\u05E8\u05D9", normalized: "after" },
    // Common event names (for event handler patterns)
    click: { primary: "\u05DC\u05D7\u05D9\u05E6\u05D4", alternatives: ["\u05E7\u05DC\u05D9\u05E7"], normalized: "click" },
    hover: { primary: "\u05E8\u05D9\u05D7\u05D5\u05E3", alternatives: ["\u05DE\u05E2\u05D1\u05E8"], normalized: "hover" },
    submit: { primary: "\u05E9\u05DC\u05D9\u05D7\u05D4", alternatives: ["\u05D4\u05D2\u05E9\u05D4"], normalized: "submit" },
    input: { primary: "\u05E7\u05DC\u05D8", alternatives: ["\u05D4\u05D6\u05E0\u05D4"], normalized: "input" },
    change: { primary: "\u05E9\u05D9\u05E0\u05D5\u05D9", alternatives: ["\u05E2\u05D3\u05DB\u05D5\u05DF"], normalized: "change" },
    // Event modifiers (for repeat until event)
    until: { primary: "\u05E2\u05D3", normalized: "until" },
    event: { primary: "\u05D0\u05D9\u05E8\u05D5\u05E2", normalized: "event" },
    from: { primary: "\u05DE", alternatives: ["\u05DE\u05D0\u05EA"], normalized: "from" }
  },
  tokenization: {
    prefixes: ["\u05D4", "\u05D5", "\u05D1", "\u05DB", "\u05DC", "\u05DE", "\u05E9"]
    // Common Hebrew prefixes
  },
  eventHandler: {
    keyword: { primary: "\u05D1", alternatives: ["\u05DB\u05E9", "\u05DB\u05D0\u05E9\u05E8", "\u05E2\u05DD"], normalized: "on" },
    sourceMarker: { primary: "\u05DE", alternatives: ["\u05DE\u05D0\u05EA"], position: "before" },
    conditionalKeyword: { primary: "\u05DB\u05D0\u05E9\u05E8", alternatives: ["\u05DB\u05E9", "\u05D0\u05DD"] },
    // Event marker: ב (at/upon), used in SVO pattern
    // Pattern: ב [event] [verb] [patient] על [destination?]
    // Example: בלחיצה החלף .active על #button
    eventMarker: { primary: "\u05D1", alternatives: ["\u05DB\u05E9", "\u05E2\u05DD"], position: "before" },
    temporalMarkers: ["\u05DB\u05D0\u05E9\u05E8", "\u05DB\u05E9", "\u05E2\u05DD"]
    // temporal conjunctions (when)
  }
};

// src/tokenizers/he.ts
var isHebrew = createUnicodeRangeClassifier([
  [1424, 1535],
  // Hebrew
  [64285, 64335]
  // Hebrew Presentation Forms
]);
var CONJUNCTIONS = /* @__PURE__ */ new Map([
  ["\u05D5", "and"]
  // v' - conjunction "and"
]);
var EVENT_MARKER_PREFIXES = /* @__PURE__ */ new Map([
  ["\u05D1", "on"],
  // b' - "at/in/on" (event marker)
  ["\u05DB", "when"]
  // k' - "as/when" (temporal)
]);
var EVENT_NAMES = /* @__PURE__ */ new Set([
  "\u05DC\u05D7\u05D9\u05E6\u05D4",
  // click
  "\u05E7\u05DC\u05D9\u05E7",
  // click (loanword)
  "\u05E9\u05DC\u05D9\u05D7\u05D4",
  // submit
  "\u05D4\u05D2\u05E9\u05D4",
  // submit (alternative)
  "\u05E8\u05D9\u05D7\u05D5\u05E3",
  // hover
  "\u05DE\u05E2\u05D1\u05E8",
  // hover/transition
  "\u05E9\u05D9\u05E0\u05D5\u05D9",
  // change
  "\u05E2\u05D3\u05DB\u05D5\u05DF",
  // update/change
  "\u05E7\u05DC\u05D8",
  // input
  "\u05D4\u05D6\u05E0\u05D4",
  // input (alternative)
  "\u05DE\u05D9\u05E7\u05D5\u05D3",
  // focus
  "\u05D8\u05E9\u05D8\u05D5\u05E9",
  // blur
  "\u05D8\u05E2\u05D9\u05E0\u05D4",
  // load
  "\u05D2\u05DC\u05D9\u05DC\u05D4"
  // scroll
]);
var PREPOSITIONS = /* @__PURE__ */ new Set([
  "\u05E2\u05DC",
  // al (on, upon)
  "\u05D0\u05EA",
  // et (direct object marker)
  "\u05D0\u05DC",
  // el (to, toward)
  "\u05DE\u05DF",
  // min (from)
  "\u05E2\u05DD",
  // im (with)
  "\u05D1\u05EA\u05D5\u05DA",
  // betoch (inside)
  "\u05DE\u05EA\u05D5\u05DA",
  // mitoch (from inside)
  "\u05DC\u05D9\u05D3",
  // leyad (next to)
  "\u05D0\u05D7\u05E8\u05D9",
  // acharey (after)
  "\u05DC\u05E4\u05E0\u05D9",
  // lifney (before)
  "\u05D1\u05D9\u05DF",
  // beyn (between)
  "\u05E2\u05D3",
  // ad (until)
  "\u05E9\u05DC"
  // shel (of - possessive)
]);
var HEBREW_EXTRAS = [
  // Values/Literals
  { native: "\u05D0\u05DE\u05EA", normalized: "true" },
  { native: "\u05E9\u05E7\u05E8", normalized: "false" },
  { native: "null", normalized: "null" },
  { native: "\u05E8\u05D9\u05E7", normalized: "null" },
  { native: "\u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8", normalized: "undefined" },
  // Positional
  { native: "\u05E8\u05D0\u05E9\u05D5\u05DF", normalized: "first" },
  { native: "\u05D0\u05D7\u05E8\u05D5\u05DF", normalized: "last" },
  { native: "\u05D4\u05D1\u05D0", normalized: "next" },
  { native: "\u05D4\u05E7\u05D5\u05D3\u05DD", normalized: "previous" },
  { native: "\u05D4\u05E7\u05E8\u05D5\u05D1", normalized: "closest" },
  { native: "\u05D4\u05D5\u05E8\u05D4", normalized: "parent" },
  // Events
  { native: "\u05DC\u05D7\u05D9\u05E6\u05D4", normalized: "click" },
  { native: "\u05E7\u05DC\u05D9\u05E7", normalized: "click" },
  { native: "\u05E7\u05DC\u05D8", normalized: "input" },
  { native: "\u05E9\u05D9\u05E0\u05D5\u05D9", normalized: "change" },
  { native: "\u05E9\u05DC\u05D9\u05D7\u05D4", normalized: "submit" },
  { native: "\u05DE\u05D9\u05E7\u05D5\u05D3", normalized: "focus" },
  { native: "\u05D8\u05E9\u05D8\u05D5\u05E9", normalized: "blur" },
  { native: "\u05DC\u05D7\u05D9\u05E6\u05EA \u05DE\u05E7\u05E9", normalized: "keydown" },
  { native: "\u05E9\u05D7\u05E8\u05D5\u05E8 \u05DE\u05E7\u05E9", normalized: "keyup" },
  { native: "\u05DE\u05E2\u05D1\u05E8 \u05E2\u05DB\u05D1\u05E8", normalized: "mouseover" },
  { native: "\u05D9\u05E6\u05D9\u05D0\u05EA \u05E2\u05DB\u05D1\u05E8", normalized: "mouseout" },
  { native: "\u05D8\u05E2\u05D9\u05E0\u05D4", normalized: "load" },
  { native: "\u05D2\u05DC\u05D9\u05DC\u05D4", normalized: "scroll" },
  // References (feminine forms not in profile)
  { native: "\u05D4\u05D9\u05D0", normalized: "it" },
  // feminine "it"
  { native: "\u05D4\u05D5\u05D0", normalized: "it" },
  // masculine "it"
  { native: "\u05D0\u05EA", normalized: "you" },
  // feminine "you"
  // Time units
  { native: "\u05E9\u05E0\u05D9\u05D9\u05D4", normalized: "s" },
  { native: "\u05E9\u05E0\u05D9\u05D5\u05EA", normalized: "s" },
  { native: "\u05DE\u05D9\u05DC\u05D9\u05E9\u05E0\u05D9\u05D9\u05D4", normalized: "ms" },
  { native: "\u05D3\u05E7\u05D4", normalized: "m" },
  { native: "\u05D3\u05E7\u05D5\u05EA", normalized: "m" },
  { native: "\u05E9\u05E2\u05D4", normalized: "h" },
  { native: "\u05E9\u05E2\u05D5\u05EA", normalized: "h" }
];
var HEBREW_TIME_UNITS = [
  { pattern: "\u05DE\u05D9\u05DC\u05D9\u05E9\u05E0\u05D9\u05D9\u05D4", suffix: "ms", length: 8, caseInsensitive: false },
  { pattern: "\u05DE\u05D9\u05DC\u05D9\u05E9\u05E0\u05D9\u05D5\u05EA", suffix: "ms", length: 9, caseInsensitive: false },
  { pattern: "\u05E9\u05E0\u05D9\u05D5\u05EA", suffix: "s", length: 5, caseInsensitive: false },
  { pattern: "\u05E9\u05E0\u05D9\u05D9\u05D4", suffix: "s", length: 5, caseInsensitive: false },
  { pattern: "\u05D3\u05E7\u05D5\u05EA", suffix: "m", length: 4, caseInsensitive: false },
  { pattern: "\u05D3\u05E7\u05D4", suffix: "m", length: 3, caseInsensitive: false },
  { pattern: "\u05E9\u05E2\u05D5\u05EA", suffix: "h", length: 4, caseInsensitive: false },
  { pattern: "\u05E9\u05E2\u05D4", suffix: "h", length: 3, caseInsensitive: false }
];
var HebrewTokenizer = class extends BaseTokenizer {
  constructor() {
    super();
    this.language = "he";
    this.direction = "rtl";
    this.initializeKeywordsFromProfile(hebrewProfile, HEBREW_EXTRAS);
  }
  tokenize(input) {
    const tokens = [];
    let pos = 0;
    while (pos < input.length) {
      if (isWhitespace(input[pos])) {
        pos++;
        continue;
      }
      if (isSelectorStart(input[pos])) {
        const modifierToken = this.tryEventModifier(input, pos);
        if (modifierToken) {
          tokens.push(modifierToken);
          pos = modifierToken.position.end;
          continue;
        }
        const selectorToken = this.trySelector(input, pos);
        if (selectorToken) {
          tokens.push(selectorToken);
          pos = selectorToken.position.end;
          continue;
        }
      }
      if (isQuote(input[pos])) {
        const stringToken = this.tryString(input, pos);
        if (stringToken) {
          tokens.push(stringToken);
          pos = stringToken.position.end;
          continue;
        }
      }
      if (isUrlStart(input, pos)) {
        const urlToken = this.tryUrl(input, pos);
        if (urlToken) {
          tokens.push(urlToken);
          pos = urlToken.position.end;
          continue;
        }
      }
      if (isDigit(input[pos])) {
        const numberToken = this.extractHebrewNumber(input, pos);
        if (numberToken) {
          tokens.push(numberToken);
          pos = numberToken.position.end;
          continue;
        }
      }
      const varToken = this.tryVariableRef(input, pos);
      if (varToken) {
        tokens.push(varToken);
        pos = varToken.position.end;
        continue;
      }
      const prepToken = this.tryPreposition(input, pos);
      if (prepToken) {
        tokens.push(prepToken);
        pos = prepToken.position.end;
        continue;
      }
      if (isHebrew(input[pos])) {
        const eventMarkerResult = this.tryEventMarkerPrefix(input, pos);
        if (eventMarkerResult) {
          tokens.push(eventMarkerResult.marker);
          tokens.push(eventMarkerResult.event);
          pos = eventMarkerResult.event.position.end;
          continue;
        }
        const prefixResult = this.tryPrefixConjunction(input, pos);
        if (prefixResult) {
          tokens.push(prefixResult.conjunction);
          pos = prefixResult.conjunction.position.end;
          continue;
        }
        const wordToken = this.extractHebrewWord(input, pos);
        if (wordToken) {
          tokens.push(wordToken);
          pos = wordToken.position.end;
          continue;
        }
      }
      if (isAsciiIdentifierChar(input[pos])) {
        const asciiToken = this.extractAsciiWord(input, pos);
        if (asciiToken) {
          tokens.push(asciiToken);
          pos = asciiToken.position.end;
          continue;
        }
      }
      pos++;
    }
    return new TokenStreamImpl(tokens, "he");
  }
  classifyToken(token) {
    if (PREPOSITIONS.has(token)) return "particle";
    if (this.isKeyword(token)) return "keyword";
    if (token.startsWith("#") || token.startsWith(".") || token.startsWith("[")) return "selector";
    if (token.startsWith('"') || token.startsWith("'")) return "literal";
    if (/^\d/.test(token)) return "literal";
    return "identifier";
  }
  /**
   * Try to match a Hebrew preposition.
   */
  tryPreposition(input, pos) {
    const sortedPreps = Array.from(PREPOSITIONS).sort((a, b) => b.length - a.length);
    for (const prep of sortedPreps) {
      if (input.slice(pos, pos + prep.length) === prep) {
        const nextPos = pos + prep.length;
        if (nextPos >= input.length || isWhitespace(input[nextPos]) || !isHebrew(input[nextPos])) {
          const token = createToken(prep, "particle", createPosition(pos, nextPos));
          return {
            ...token,
            metadata: {
              prepositionValue: prep
            }
          };
        }
      }
    }
    return null;
  }
  /**
   * Try to extract a prefix conjunction (ו - "and") that's attached to the following word.
   *
   * Hebrew conjunction prefix attaches directly to words without space:
   * - והחלף → ו + החלף (and + toggle)
   * - ולחיצה → ו + לחיצה (and + click)
   */
  tryPrefixConjunction(input, pos) {
    let wordEnd = pos;
    while (wordEnd < input.length && isHebrew(input[wordEnd])) {
      wordEnd++;
    }
    const fullWord = input.slice(pos, wordEnd);
    if (this.lookupKeyword(fullWord)) {
      return null;
    }
    if (PREPOSITIONS.has(fullWord)) {
      return null;
    }
    const char = input[pos];
    const conjEntry = CONJUNCTIONS.get(char);
    if (!conjEntry) return null;
    const nextPos = pos + 1;
    if (nextPos >= input.length || !isHebrew(input[nextPos])) {
      return null;
    }
    let remainingLength = 0;
    let checkPos = nextPos;
    while (checkPos < input.length && isHebrew(input[checkPos])) {
      remainingLength++;
      checkPos++;
    }
    if (remainingLength < 2) {
      return null;
    }
    const afterPrefix = input.slice(nextPos, wordEnd);
    if (this.lookupKeyword(afterPrefix)) {
      return {
        conjunction: createToken(char, "conjunction", createPosition(pos, nextPos), conjEntry)
      };
    }
    return null;
  }
  /**
   * Try to extract an event marker prefix (ב, כ) attached to an event name.
   *
   * Hebrew event markers attach directly to event names without space:
   * - בלחיצה → ב + לחיצה (on + click)
   * - כשינוי → כ + שינוי (when + change)
   *
   * Returns both the marker token and the event name token if successful.
   */
  tryEventMarkerPrefix(input, pos) {
    const char = input[pos];
    const markerNormalized = EVENT_MARKER_PREFIXES.get(char);
    if (!markerNormalized) return null;
    const nextPos = pos + 1;
    if (nextPos >= input.length || !isHebrew(input[nextPos])) {
      return null;
    }
    let wordEnd = nextPos;
    while (wordEnd < input.length && isHebrew(input[wordEnd])) {
      wordEnd++;
    }
    const afterPrefix = input.slice(nextPos, wordEnd);
    if (EVENT_NAMES.has(afterPrefix)) {
      const markerToken = createToken(
        char,
        "keyword",
        createPosition(pos, nextPos),
        markerNormalized
        // normalized to 'on' or 'when'
      );
      const eventKeywordEntry = this.lookupKeyword(afterPrefix);
      const eventToken = eventKeywordEntry ? createToken(
        afterPrefix,
        "keyword",
        createPosition(nextPos, wordEnd),
        eventKeywordEntry.normalized
      ) : createToken(afterPrefix, "keyword", createPosition(nextPos, wordEnd));
      return { marker: markerToken, event: eventToken };
    }
    return null;
  }
  /**
   * Extract a Hebrew word.
   */
  extractHebrewWord(input, startPos) {
    let pos = startPos;
    let word = "";
    while (pos < input.length && isHebrew(input[pos])) {
      word += input[pos++];
    }
    if (!word) return null;
    const keywordEntry = this.lookupKeyword(word);
    if (keywordEntry) {
      return createToken(word, "keyword", createPosition(startPos, pos), keywordEntry.normalized);
    }
    if (PREPOSITIONS.has(word)) {
      const token = createToken(word, "particle", createPosition(startPos, pos));
      return {
        ...token,
        metadata: {
          prepositionValue: word
        }
      };
    }
    const morphToken = this.tryMorphKeywordMatch(word, startPos, pos);
    if (morphToken) return morphToken;
    return createToken(word, "identifier", createPosition(startPos, pos));
  }
  /**
   * Extract an ASCII word.
   */
  extractAsciiWord(input, startPos) {
    let pos = startPos;
    let word = "";
    while (pos < input.length && isAsciiIdentifierChar(input[pos])) {
      word += input[pos++];
    }
    if (!word) return null;
    return createToken(word, "identifier", createPosition(startPos, pos));
  }
  /**
   * Extract a number, including Hebrew time unit suffixes.
   */
  extractHebrewNumber(input, startPos) {
    return this.tryNumberWithTimeUnits(input, startPos, HEBREW_TIME_UNITS, {
      allowSign: false,
      skipWhitespace: true
    });
  }
};
var hebrewTokenizer = new HebrewTokenizer();

// src/languages/he.ts
registerLanguage("he", hebrewTokenizer, hebrewProfile);
export {
  hebrewProfile,
  hebrewTokenizer
};
//# sourceMappingURL=he.js.map