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U3J,GAAYmI,KAC3DuC,EAAQ,QAAU,CAChB,GAAIhB,EAAe,QAAU,CAAC,eAAAA,CAAc,EAC5C,GAAIC,EAAU,QAAU,CAAC,UAAAA,CAAS,EAClC,GAAI3J,GAAY,CAAC,SAAAA,CAAQ,EACzB,GAAImI,GAAe,CAAC,YAAAA,CAAW,CACjC,EAEJ,CACA,OAAOuC,CACT","names":["slug","createAlternative","createAssertion","createBackreference","createCapturingGroup","createCharacter","createCharacterClass","createCharacterSet","createGroup","createLookaroundAssertion","createQuantifier","createSubroutine","createUnicodeProperty","hasOnlyChild","parse","traverse","atomic","possessive","recursion","cp","r","envFlags","globalRegExp","getNewCurrentFlags","current","enable","disable","getOrInsert","map","key","defaultValue","isMinTarget","target","min","EsVersion","throwIfNullish","value","msg","Target","getOptions","options","opts","asciiSpaceChar","CharsWithoutIgnoreCaseExpansion","defaultWordChar","getIgnoreCaseMatchChars","char","set","lower","upper","title","LowerToTitleCaseMap","altLower","LowerToAlternativeLowerCaseMap","altUpper","LowerToAlternativeUpperCaseMap","JsUnicodePropertyMap","p","titleEntry","titleRange","PosixClassMap","range","start","end","i","codePoint","UnicodePropertiesWithSpecificCase","transform","ast","addParentProperties","firstPassState","FirstPassVisitor","globalFlags","secondPassState","SecondPassVisitor","thirdPassState","ThirdPassVisitor","node","parent","replaceWith","body","kind","innerGroup","outerGroup","setParentDeep","flagDirectivesByAlt","flagDirectives","el","forwardSiblingAlt","flags","getCombinedFlagModsFromFlagNodes","flagGroup","container","root","remove","state","negate","asciiWordBoundaries","avoidSubclass","supportedGNodes","wordIsAscii","parseFragment","prev","isAlwaysNonZeroLength","setParent","b","B","jsGroupNameMap","ref","isValidJsGroupName","getAndStoreJsGroupName","subroutineRefMap","name","cc","accuracy","minTargetEs2024","digitIsAscii","spaceIsAscii","setNegate","eBase","emoji","ascii","removeAllPrevSiblings","removeAllNextSiblings","firstAlt","topLevel","lookbehind","f","group","leadingGs","hasAltWithLeadG","hasAltWithoutLeadG","alt","leadingG","getLeadingG","g","_","passedLookbehind","strategy","multiplexCapturesToLeftByRef","reffedNodesByReferencer","orphan","skip","groupOriginByCopy","groupsByName","openRefs","origin","createRecursion","multiplexNodes","multiplex","groupsWithSameName","hasDuplicateNameToRemove","groupInfo","isRecursive","reffed","reffedGroupNode","isGlobalRecursion","expandedSubroutine","cloneCapturingGroup","replacement","reffedGroupFlagMods","getAllParents","reffedGroupFlags","areFlagsEqual","getFlagModsFromFlags","participants","canParticipateWithNode","numCapsNeeded","emptyCapture","a","capture","rightmostPoint","kidsOfParent","getKids","kid","isAncestorOf","obj","originMap","up","up2","store","filterFn","results","jsName","flagNodes","flagProps","combinedFlags","prop","dotAll","ignoreCase","mods","els","firstToConsider","isLoneGLookaround","isAlwaysZeroLength","gNodesForGroup","descendant","kids","type","types","pattern","alts","generate","minTargetEs2025","recursionLimit","hasCaseInsensitiveNode","hasCaseSensitiveNode","iStack","FlagModifierVisitor","isIOn","appliedGlobalFlags","lastNode","gen","generator","result","isAnyGroup","currentModI","charHasCase","getCasesOutsideCharClassRange","number","data","escaped","getCharEscape","cases","isLiteralHyphen","genClass","negatedChildClasses","groupFirstAlt","newAlt","firstEl","max","escOpts","minStr","maxStr","extraChars","charsOutsideRange","getCodePointRangesFromChars","currentFlags","contents","getGroupPrefix","getQuantifierStr","limit","BaseEscapeChars","CharClassEscapeChars","CharClassEscapeCharsFlagV","CharCodeEscapeMap","casedRe","firstOnly","found","caseOfChar","num","escDigit","inCharClass","useFlagV","isDigitCharCode","escapeChars","chars","codePoints","values","flagMods","useFlagMods","base","EmulatedRegExp","_EmulatedRegExp","#captureMap","#compiled","#pattern","#nameMap","#strategy","lazyCompile","re","createCaptureMap","str","rest","useLastIndex","pos","match","#execCore","adjustMatchDetailsForOffset","matchCopy","indicesCopy","mappedNums","hidden","transferTo","to","createNameMap","offset","input","hasIndices","indices","arr","groupIndices","hiddenCaptures","transfers","captureMap","from","numCharClassesOpen","numCaptures","m","toRegExp","d","toRegExpDetails","onigurumaAst","regexPlusAst","generated","recursionResult","possessiveResult","atomicResult","details"],"sources":["../esm/npm/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/src/utils.js","../esm/npm/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/src/options.js","../esm/npm/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/src/unicode.js","../esm/npm/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/src/transform.js","../esm/npm/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/src/generate.js","../esm/npm/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/src/subclass.js","../esm/npm/oniguruma-to-es@4.3.6/node_modules/oniguruma-to-es/src/index.js"],"sourcesContent":["import {EsVersion, Target} from './options.js';\n\nconst cp = String.fromCodePoint;\nconst r = String.raw;\n\nconst envFlags = {};\n// Use `globalThis` to prevent env-testing fns from being replaced with constants during bundling\n// with Rolldown; see \u003cgithub.com/slevithan/oniguruma-to-es/issues/42\u003e\nconst globalRegExp = globalThis.RegExp;\nenvFlags.flagGroups = (() =\u003e {\n  try {\n    new globalRegExp('(?i:)');\n  } catch {\n    return false;\n  }\n  return true;\n})();\nenvFlags.unicodeSets = (() =\u003e {\n  try {\n    // Check for flag v support and also that nested classes can be parsed\n    // See \u003cgithub.com/slevithan/oniguruma-to-es/pull/41\u003e\n    new globalRegExp('[[]]', 'v');\n  } catch {\n    return false;\n  }\n  return true;\n})();\n// Detect WebKit bug: \u003cgithub.com/slevithan/oniguruma-to-es/issues/30\u003e\nenvFlags.bugFlagVLiteralHyphenIsRange = envFlags.unicodeSets ? (() =\u003e {\n  try {\n    new globalRegExp(r`[\\d\\-a]`, 'v');\n  } catch {\n    return true;\n  }\n  return false;\n})() : false;\n// Detect WebKit bug: \u003cgithub.com/slevithan/oniguruma-to-es/issues/38\u003e\nenvFlags.bugNestedClassIgnoresNegation = envFlags.unicodeSets \u0026\u0026 new globalRegExp('[[^a]]', 'v').test('a');\n\nfunction getNewCurrentFlags(current, {enable, disable}) {\n  return {\n    dotAll: !disable?.dotAll \u0026\u0026 !!(enable?.dotAll || current.dotAll),\n    ignoreCase: !disable?.ignoreCase \u0026\u0026 !!(enable?.ignoreCase || current.ignoreCase),\n  };\n}\n\nfunction getOrInsert(map, key, defaultValue) {\n  if (!map.has(key)) {\n    map.set(key, defaultValue);\n  }\n  return map.get(key);\n}\n\n/**\n@param {keyof Target} target\n@param {keyof Target} min\n@returns {boolean}\n*/\nfunction isMinTarget(target, min) {\n  return EsVersion[target] \u003e= EsVersion[min];\n}\n\nfunction throwIfNullish(value, msg) {\n  if (value == null) {\n    throw new Error(msg ?? 'Value expected');\n  }\n  return value;\n}\n\nexport {\n  cp,\n  envFlags,\n  getNewCurrentFlags,\n  getOrInsert,\n  isMinTarget,\n  r,\n  throwIfNullish,\n};\n","import {envFlags} from './utils.js';\n/**\n@import {ToRegExpOptions} from './index.js';\n*/\n\nconst Accuracy = /** @type {const} */ ({\n  default: 'default',\n  strict: 'strict',\n});\n\nconst EsVersion = {\n  ES2025: 2025,\n  ES2024: 2024,\n  ES2018: 2018,\n};\n\nconst Target = /** @type {const} */ ({\n  auto: 'auto',\n  ES2025: 'ES2025',\n  ES2024: 'ES2024',\n  ES2018: 'ES2018',\n});\n\n/**\nReturns a complete set of options, with default values set for options that weren't provided.\n@param {ToRegExpOptions} [options]\n@returns {Required\u003cToRegExpOptions\u003e}\n*/\nfunction getOptions(options = {}) {\n  if ({}.toString.call(options) !== '[object Object]') {\n    throw new Error('Unexpected options');\n  }\n  if (options.target !== undefined \u0026\u0026 !Target[options.target]) {\n    throw new Error(`Unexpected target \"${options.target}\"`)\n  }\n  // Set default values\n  const opts = {\n    // Sets the level of emulation rigor/strictness.\n    accuracy: 'default',\n    // Disables advanced emulation that relies on returning a `RegExp` subclass, resulting in\n    // certain patterns not being emulatable.\n    avoidSubclass: false,\n    // Oniguruma flags; a string with `i`, `m`, `x`, `D`, `S`, `W`, `y{g}` in any order (all\n    // optional). Oniguruma's `m` is equivalent to JavaScript's `s` (`dotAll`).\n    flags: '',\n    // Include JavaScript flag `g` (`global`) in the result.\n    global: false,\n    // Include JavaScript flag `d` (`hasIndices`) in the result.\n    hasIndices: false,\n    // Delay regex construction until first use if the transpiled pattern is at least this length.\n    lazyCompileLength: Infinity,\n    // JavaScript version used for generated regexes. Using `auto` detects the best value based on\n    // your environment. Later targets allow faster processing, simpler generated source, and\n    // support for additional features.\n    target: 'auto',\n    // Disables minifications that simplify the pattern without changing the meaning.\n    verbose: false,\n    ...options,\n    // Advanced options that override standard behavior, error checking, and flags when enabled.\n    rules: {\n      // Useful with TextMate grammars that merge backreferences across patterns.\n      allowOrphanBackrefs: false,\n      // Use ASCII `\\b` and `\\B`, which increases search performance of generated regexes.\n      asciiWordBoundaries: false,\n      // Allow unnamed captures and numbered calls (backreferences and subroutines) when using\n      // named capture. This is Oniguruma option `ONIG_OPTION_CAPTURE_GROUP`; on by default in\n      // `vscode-oniguruma`.\n      captureGroup: false,\n      // Change the recursion depth limit from Oniguruma's `20` to an integer `2`–`20`.\n      recursionLimit: 20,\n      // `^` as `\\A`; `$` as`\\Z`. Improves search performance of generated regexes without changing\n      // the meaning if searching line by line. This is Oniguruma option `ONIG_OPTION_SINGLELINE`.\n      singleline: false,\n      ...options.rules,\n    },\n  };\n  if (opts.target === 'auto') {\n    opts.target = envFlags.flagGroups ? 'ES2025' : (envFlags.unicodeSets ? 'ES2024' : 'ES2018');\n  }\n  return opts;\n}\n\nexport {\n  Accuracy,\n  EsVersion,\n  getOptions,\n  Target,\n};\n","import {cp, r} from './utils.js';\nimport {slug} from 'oniguruma-parser/parser';\n\n// `\\t\\n\\v\\f\\r\\x20`\nconst asciiSpaceChar = '[\\t-\\r ]';\n\nconst CharsWithoutIgnoreCaseExpansion = new Set([\n  cp(0x130), // İ\n  cp(0x131), // ı\n]);\n\n// Different than `PosixClassMap`'s `word`\nconst defaultWordChar = r`[\\p{L}\\p{M}\\p{N}\\p{Pc}]`;\n\nfunction getIgnoreCaseMatchChars(char) {\n  // Some chars should not match the chars they case swap to\n  if (CharsWithoutIgnoreCaseExpansion.has(char)) {\n    return [char];\n  }\n  const set = new Set();\n  const lower = char.toLowerCase();\n  // Everything else is based on `lower`\n  const upper = lower.toUpperCase();\n  const title = LowerToTitleCaseMap.get(lower);\n  const altLower = LowerToAlternativeLowerCaseMap.get(lower);\n  const altUpper = LowerToAlternativeUpperCaseMap.get(lower);\n  // Exclude ucase if multiple chars; count code point length. Excludes ucase versions of German\n  // es-zed 'ß', ligatures like 'ﬀ', and chars with no precomposed ucase like 'ŉ'. See\n  // \u003cunicode.org/Public/UNIDATA/SpecialCasing.txt\u003e\n  if ([...upper].length === 1) {\n    set.add(upper);\n  }\n  altUpper \u0026\u0026 set.add(altUpper);\n  title \u0026\u0026 set.add(title);\n  // Lcase of 'İ' is multiple chars, but it's excluded by `CharsWithoutIgnoreCaseExpansion`\n  set.add(lower);\n  altLower \u0026\u0026 set.add(altLower);\n  return [...set];\n}\n\n// The following set includes:\n// - All ES2024 general categories and their aliases (all are supported by Oniguruma). See\n//   \u003cgithub.com/mathiasbynens/unicode-match-property-value-ecmascript/blob/main/data/mappings.js\u003e\n// - All ES2024 binary properties and their aliases (all are supported by Oniguruma). See\n//   \u003ctc39.es/ecma262/multipage/text-processing.html#table-binary-unicode-properties\u003e\n// Unicode properties must be mapped to property names supported by JS, and must also apply JS's\n// stricter rules for casing, whitespace, hyphens, and underscores in Unicode property names. In\n// order to remain lightweight, this library assumes properties not in this list are Unicode script\n// names (which require a `Script=` or `sc=` prefix in JS). Unlike JS, Oniguruma doesn't support\n// script extensions, and it supports some properties that aren't supported in JS (including blocks\n// with an `In_` prefix). See also:\n// - Properties supported in Oniguruma: \u003cgithub.com/kkos/oniguruma/blob/master/doc/UNICODE_PROPERTIES\u003e\n// - Properties supported in JS by spec version: \u003cgithub.com/eslint-community/regexpp/blob/main/src/unicode/properties.ts\u003e\nconst JsUnicodePropertyMap = /* @__PURE__ */ new Map(\n`C Other\nCc Control cntrl\nCf Format\nCn Unassigned\nCo Private_Use\nCs Surrogate\nL Letter\nLC Cased_Letter\nLl Lowercase_Letter\nLm Modifier_Letter\nLo Other_Letter\nLt Titlecase_Letter\nLu Uppercase_Letter\nM Mark Combining_Mark\nMc Spacing_Mark\nMe Enclosing_Mark\nMn Nonspacing_Mark\nN Number\nNd Decimal_Number digit\nNl Letter_Number\nNo Other_Number\nP Punctuation punct\nPc Connector_Punctuation\nPd Dash_Punctuation\nPe Close_Punctuation\nPf Final_Punctuation\nPi Initial_Punctuation\nPo Other_Punctuation\nPs Open_Punctuation\nS Symbol\nSc Currency_Symbol\nSk Modifier_Symbol\nSm Math_Symbol\nSo Other_Symbol\nZ Separator\nZl Line_Separator\nZp Paragraph_Separator\nZs Space_Separator\nASCII\nASCII_Hex_Digit AHex\nAlphabetic Alpha\nAny\nAssigned\nBidi_Control Bidi_C\nBidi_Mirrored Bidi_M\nCase_Ignorable CI\nCased\nChanges_When_Casefolded CWCF\nChanges_When_Casemapped CWCM\nChanges_When_Lowercased CWL\nChanges_When_NFKC_Casefolded CWKCF\nChanges_When_Titlecased CWT\nChanges_When_Uppercased CWU\nDash\nDefault_Ignorable_Code_Point DI\nDeprecated Dep\nDiacritic Dia\nEmoji\nEmoji_Component EComp\nEmoji_Modifier EMod\nEmoji_Modifier_Base EBase\nEmoji_Presentation EPres\nExtended_Pictographic ExtPict\nExtender Ext\nGrapheme_Base Gr_Base\nGrapheme_Extend Gr_Ext\nHex_Digit Hex\nIDS_Binary_Operator IDSB\nIDS_Trinary_Operator IDST\nID_Continue IDC\nID_Start IDS\nIdeographic Ideo\nJoin_Control Join_C\nLogical_Order_Exception LOE\nLowercase Lower\nMath\nNoncharacter_Code_Point NChar\nPattern_Syntax Pat_Syn\nPattern_White_Space Pat_WS\nQuotation_Mark QMark\nRadical\nRegional_Indicator RI\nSentence_Terminal STerm\nSoft_Dotted SD\nTerminal_Punctuation Term\nUnified_Ideograph UIdeo\nUppercase Upper\nVariation_Selector VS\nWhite_Space space\nXID_Continue XIDC\nXID_Start XIDS`.\n  split(/\\s/).\n  map(p =\u003e [slug(p), p])\n);\n\nconst LowerToAlternativeLowerCaseMap = new Map([\n  ['s', cp(0x17F)], // s, ſ\n  [cp(0x17F), 's'], // ſ, s\n]);\n\nconst LowerToAlternativeUpperCaseMap = new Map([\n  [cp(0xDF), cp(0x1E9E)], // ß, ẞ\n  [cp(0x6B), cp(0x212A)], // k, K (Kelvin)\n  [cp(0xE5), cp(0x212B)], // å, Å (Angstrom)\n  [cp(0x3C9), cp(0x2126)], // ω, Ω (Ohm)\n]);\n\n// See \u003cgithub.com/node-unicode/unicode-16.0.0/tree/main/General_Category/Titlecase_Letter\u003e\nconst LowerToTitleCaseMap = new Map([\n  titleEntry(0x1C5),\n  titleEntry(0x1C8),\n  titleEntry(0x1CB),\n  titleEntry(0x1F2),\n  ...titleRange(0x1F88, 0x1F8F),\n  ...titleRange(0x1F98, 0x1F9F),\n  ...titleRange(0x1FA8, 0x1FAF),\n  titleEntry(0x1FBC),\n  titleEntry(0x1FCC),\n  titleEntry(0x1FFC),\n]);\n\n// Unlike Onig's Unicode properties via `\\p` and `\\P`, these names are case sensitive and don't\n// allow inserting whitespace and underscores. Definitions at\n// \u003cgithub.com/kkos/oniguruma/blob/master/doc/RE\u003e (see: POSIX bracket: Unicode Case)\n// Note: Handling in the transformer assumes all values here are a single, negateable node that's\n// not pre-negated at the top level. It also uses ASCII versions of `graph` and `print` for target\n// `ES2018` (which doesn't allow intersection) if `accuracy` isn't `strict`\nconst PosixClassMap = new Map([\n  ['alnum', r`[\\p{Alpha}\\p{Nd}]`],\n  ['alpha', r`\\p{Alpha}`],\n  ['ascii', r`\\p{ASCII}`],\n  ['blank', r`[\\p{Zs}\\t]`],\n  ['cntrl', r`\\p{Cc}`],\n  ['digit', r`\\p{Nd}`],\n  ['graph', r`[\\P{space}\u0026\u0026\\P{Cc}\u0026\u0026\\P{Cn}\u0026\u0026\\P{Cs}]`],\n  ['lower', r`\\p{Lower}`],\n  ['print', r`[[\\P{space}\u0026\u0026\\P{Cc}\u0026\u0026\\P{Cn}\u0026\u0026\\P{Cs}]\\p{Zs}]`],\n  ['punct', r`[\\p{P}\\p{S}]`], // Updated value from Onig 6.9.9; changed from Unicode `\\p{punct}`\n  ['space', r`\\p{space}`],\n  ['upper', r`\\p{Upper}`],\n  ['word', r`[\\p{Alpha}\\p{M}\\p{Nd}\\p{Pc}]`],\n  ['xdigit', r`\\p{AHex}`],\n]);\n\nfunction range(start, end) {\n  // const range = Array.from(Array(end + 1 - start), (_, i) =\u003e i + start);\n  // const range = Array(end + 1 - start).fill(start).map((x, i) =\u003e x + i);\n  const range = [];\n  for (let i = start; i \u003c= end; i++) {\n    range.push(i);\n  }\n  return range;\n}\n\nfunction titleEntry(codePoint) {\n  const char = cp(codePoint);\n  return [char.toLowerCase(), char];\n}\n\nfunction titleRange(start, end) {\n  return range(start, end).map(codePoint =\u003e titleEntry(codePoint));\n}\n\nconst UnicodePropertiesWithSpecificCase = new Set([\n  'Lower', 'Lowercase',\n  'Upper', 'Uppercase',\n  'Ll', 'Lowercase_Letter',\n  'Lt', 'Titlecase_Letter',\n  'Lu', 'Uppercase_Letter',\n  // The `Changes_When_*` properties (and their aliases) could be included, but they're very rare.\n  // Some other properties include a handful of chars with specific cases only, but these chars are\n  // generally extreme edge cases and using such properties case insensitively generally produces\n  // undesired behavior anyway\n]);\n\nexport {\n  asciiSpaceChar,\n  defaultWordChar,\n  getIgnoreCaseMatchChars,\n  JsUnicodePropertyMap,\n  PosixClassMap,\n  UnicodePropertiesWithSpecificCase,\n};\n","import {Accuracy, Target} from './options.js';\nimport {asciiSpaceChar, defaultWordChar, JsUnicodePropertyMap, PosixClassMap} from './unicode.js';\nimport {cp, getNewCurrentFlags, getOrInsert, isMinTarget, r} from './utils.js';\nimport {createAlternative, createAssertion, createBackreference, createCapturingGroup, createCharacter, createCharacterClass, createCharacterSet, createGroup, createLookaroundAssertion, createQuantifier, createSubroutine, createUnicodeProperty, hasOnlyChild, parse, slug} from 'oniguruma-parser/parser';\nimport {traverse} from 'oniguruma-parser/traverser';\n/**\n@import {CapturingGroupNode, OnigurumaAst, Node} from 'oniguruma-parser/parser';\n@import {Visitor} from 'oniguruma-parser/traverser';\n*/\n\n/**\n@typedef {\n  OnigurumaAst \u0026 {\n    options: {\n      disable: {[key: string]: boolean};\n      force: {[key: string]: boolean};\n    };\n    _originMap: Map\u003cCapturingGroupNode, CapturingGroupNode\u003e;\n    _strategy: string | null;\n  }\n} RegexPlusAst\n*/\n/**\nTransforms an Oniguruma AST in-place to a [Regex+](https://github.com/slevithan/regex) AST.\nAssumes target ES2025, expecting the generator to down-convert to the desired JS target version.\n\nRegex+'s syntax and behavior is a strict superset of native JavaScript, so the AST is very close\nto representing native ES2025 `RegExp` but with some added features (atomic groups, possessive\nquantifiers, recursion). The AST doesn't use some of Regex+'s extended features like flag x or\nsubroutines because they follow PCRE behavior and work somewhat differently than in Oniguruma. The\nAST represents what's needed to precisely reproduce Oniguruma behavior using Regex+.\n@param {OnigurumaAst} ast\n@param {{\n  accuracy?: keyof Accuracy;\n  asciiWordBoundaries?: boolean;\n  avoidSubclass?: boolean;\n  bestEffortTarget?: keyof Target;\n}} [options]\n@returns {RegexPlusAst}\n*/\nfunction transform(ast, options) {\n  const opts = {\n    // A couple edge cases exist where options `accuracy` and `bestEffortTarget` are used:\n    // - `CharacterSet` kind `text_segment` (`\\X`): An exact representation would require heavy\n    //   Unicode data; a best-effort approximation requires knowing the target.\n    // - `CharacterSet` kind `posix` with values `graph` and `print`: Their complex Unicode\n    //   representations would be hard to change to ASCII versions after the fact in the generator\n    //   based on `target`/`accuracy`, so produce the appropriate structure here.\n    accuracy: 'default',\n    asciiWordBoundaries: false,\n    avoidSubclass: false,\n    bestEffortTarget: 'ES2025',\n    ...options,\n  };\n  // Add `parent` properties to all nodes to help during traversal; also expected by the generator\n  addParentProperties(ast);\n  const firstPassState = {\n    accuracy: opts.accuracy,\n    asciiWordBoundaries: opts.asciiWordBoundaries,\n    avoidSubclass: opts.avoidSubclass,\n    flagDirectivesByAlt: new Map(),\n    jsGroupNameMap: new Map(),\n    minTargetEs2024: isMinTarget(opts.bestEffortTarget, 'ES2024'),\n    passedLookbehind: false,\n    strategy: null,\n    // Subroutines can appear before the groups they ref, so collect reffed nodes for a second pass \n    subroutineRefMap: new Map(),\n    supportedGNodes: new Set(),\n    digitIsAscii: ast.flags.digitIsAscii,\n    spaceIsAscii: ast.flags.spaceIsAscii,\n    wordIsAscii: ast.flags.wordIsAscii,\n  };\n  traverse(ast, FirstPassVisitor, firstPassState);\n  // Global flags modified by the first pass\n  const globalFlags = {\n    dotAll: ast.flags.dotAll,\n    ignoreCase: ast.flags.ignoreCase,\n  };\n  // The interplay of subroutines (with Onig's unique rules/behavior for them; see comments in the\n  // parser for details) with backref multiplexing (a unique Onig feature), flag modifiers, and\n  // duplicate group names (which might be indirectly referenced by subroutines even though\n  // subroutines can't directly reference duplicate names) is extremely complicated to emulate in\n  // JS in a way that handles all edge cases, so we need multiple passes to do it\n  const secondPassState = {\n    currentFlags: globalFlags,\n    prevFlags: null,\n    globalFlags,\n    groupOriginByCopy: new Map(),\n    groupsByName: new Map(),\n    multiplexCapturesToLeftByRef: new Map(),\n    openRefs: new Map(),\n    reffedNodesByReferencer: new Map(),\n    subroutineRefMap: firstPassState.subroutineRefMap,\n  };\n  traverse(ast, SecondPassVisitor, secondPassState);\n  const thirdPassState = {\n    groupsByName: secondPassState.groupsByName,\n    highestOrphanBackref: 0,\n    numCapturesToLeft: 0,\n    reffedNodesByReferencer: secondPassState.reffedNodesByReferencer,\n  };\n  traverse(ast, ThirdPassVisitor, thirdPassState);\n  ast._originMap = secondPassState.groupOriginByCopy;\n  ast._strategy = firstPassState.strategy;\n  return ast;\n}\n\nconst /** @type {Visitor} */ FirstPassVisitor = {\n  AbsenceFunction({node, parent, replaceWith}) {\n    const {body, kind} = node;\n    if (kind === 'repeater') {\n      // Convert `(?~…)` to `(?:(?:(?!…)\\p{Any})*)`\n      const innerGroup = createGroup();\n      innerGroup.body[0].body.push(\n        // Insert own alts as `body`\n        createLookaroundAssertion({negate: true, body}),\n        createUnicodeProperty('Any')\n      );\n      const outerGroup = createGroup();\n      outerGroup.body[0].body.push(\n        createQuantifier('greedy', 0, Infinity, innerGroup)\n      );\n      replaceWith(setParentDeep(outerGroup, parent), {traverse: true});\n    } else {\n      throw new Error(`Unsupported absence function \"(?~|\"`);\n    }\n  },\n\n  Alternative: {\n    enter({node, parent, key}, {flagDirectivesByAlt}) {\n      // Look for own-level flag directives when entering an alternative because after traversing\n      // the directive itself, any subsequent flag directives will no longer be at the same level\n      const flagDirectives = node.body.filter(el =\u003e el.kind === 'flags');\n      for (let i = key + 1; i \u003c parent.body.length; i++) {\n        const forwardSiblingAlt = parent.body[i];\n        getOrInsert(flagDirectivesByAlt, forwardSiblingAlt, []).push(...flagDirectives);\n      }\n    },\n    exit({node}, {flagDirectivesByAlt}) {\n      // Wait until exiting to wrap an alternative's nodes with flag groups that extend flag\n      // directives from prior sibling alternatives, because doing this at the end allows inner\n      // nodes to accurately check their level in the tree\n      if (flagDirectivesByAlt.get(node)?.length) {\n        const flags = getCombinedFlagModsFromFlagNodes(flagDirectivesByAlt.get(node));\n        if (flags) {\n          const flagGroup = createGroup({flags});\n          flagGroup.body[0].body = node.body;\n          node.body = [setParentDeep(flagGroup, node)];\n        }\n      }\n    },\n  },\n\n  Assertion({node, parent, key, container, root, remove, replaceWith}, state) {\n    const {kind, negate} = node;\n    const {asciiWordBoundaries, avoidSubclass, supportedGNodes, wordIsAscii} = state;\n    if (kind === 'text_segment_boundary') {\n      // Supported by the parser but not yet for transpilation\n      throw new Error(`Unsupported text segment boundary \"\\\\${negate ? 'Y' : 'y'}\"`);\n    } else if (kind === 'line_end') {\n      replaceWith(setParentDeep(createLookaroundAssertion({body: [\n        createAlternative({body: [createAssertion('string_end')]}),\n        createAlternative({body: [createCharacter(10)]}), // `\\n`\n      ]}), parent));\n    } else if (kind === 'line_start') {\n      // Onig's `^` doesn't match after a string-terminating line feed\n      replaceWith(setParentDeep(parseFragment(r`(?\u003c=\\A|\\n(?!\\z))`, {skipLookbehindValidation: true}), parent));\n    } else if (kind === 'search_start') {\n      if (supportedGNodes.has(node)) {\n        root.flags.sticky = true;\n        remove();\n      } else {\n        const prev = container[key - 1]; // parent.body[key - 1]\n        // Not all ways of blocking the `\\G` from matching are covered here (ex: a node prior to\n        // the `prev` node could block), but blocked `\\G` is an edge case and it's okay if some\n        // blocked cases result in the standard error for being unsupported without a subclass\n        if (prev \u0026\u0026 isAlwaysNonZeroLength(prev)) {\n          replaceWith(setParentDeep(createLookaroundAssertion({negate: true}), parent));\n        } else if (avoidSubclass) {\n          throw new Error(r`Uses \"\\G\" in a way that requires a subclass`);\n        } else {\n          replaceWith(setParent(createAssertion('string_start'), parent));\n          state.strategy = 'clip_search';\n        }\n      }\n    } else if (kind === 'string_end' || kind === 'string_start') {\n      // Don't need transformation since JS flag m isn't used\n    } else if (kind === 'string_end_newline') {\n      replaceWith(setParentDeep(parseFragment(r`(?=\\n?\\z)`), parent));\n    } else if (kind === 'word_boundary') {\n      if (!wordIsAscii \u0026\u0026 !asciiWordBoundaries) {\n        const b = `(?:(?\u003c=${defaultWordChar})(?!${defaultWordChar})|(?\u003c!${defaultWordChar})(?=${defaultWordChar}))`;\n        const B = `(?:(?\u003c=${defaultWordChar})(?=${defaultWordChar})|(?\u003c!${defaultWordChar})(?!${defaultWordChar}))`;\n        replaceWith(setParentDeep(parseFragment(negate ? B : b), parent));\n      }\n    } else {\n      throw new Error(`Unexpected assertion kind \"${kind}\"`);\n    }\n  },\n\n  Backreference({node}, {jsGroupNameMap}) {\n    let {ref} = node;\n    if (typeof ref === 'string' \u0026\u0026 !isValidJsGroupName(ref)) {\n      ref = getAndStoreJsGroupName(ref, jsGroupNameMap);\n      node.ref = ref;\n    }\n  },\n\n  CapturingGroup({node}, {jsGroupNameMap, subroutineRefMap}) {\n    let {name} = node;\n    if (name \u0026\u0026 !isValidJsGroupName(name)) {\n      name = getAndStoreJsGroupName(name, jsGroupNameMap);\n      node.name = name;\n    }\n    subroutineRefMap.set(node.number, node);\n    if (name) {\n      subroutineRefMap.set(name, node);\n    }\n  },\n\n  CharacterClassRange({node, parent, replaceWith}) {\n    if (parent.kind === 'intersection') {\n      // JS doesn't allow intersection with ranges without a wrapper class\n      const cc = createCharacterClass({body: [node]});\n      replaceWith(setParentDeep(cc, parent), {traverse: true});\n    }\n  },\n\n  CharacterSet({node, parent, replaceWith}, {accuracy, minTargetEs2024, digitIsAscii, spaceIsAscii, wordIsAscii}) {\n    const {kind, negate, value} = node;\n    // Flag D with `\\d`, `\\p{Digit}`, `[[:digit:]]`\n    if (digitIsAscii \u0026\u0026 (kind === 'digit' || value === 'digit')) {\n      replaceWith(setParent(createCharacterSet('digit', {negate}), parent));\n      return;\n    }\n    // Flag S with `\\s`, `\\p{Space}`, `[[:space:]]`\n    if (spaceIsAscii \u0026\u0026 (kind === 'space' || value === 'space')) {\n      replaceWith(setParentDeep(setNegate(parseFragment(asciiSpaceChar), negate), parent));\n      return;\n    }\n    // Flag W with `\\w`, `\\p{Word}`, `[[:word:]]`\n    if (wordIsAscii \u0026\u0026 (kind === 'word' || value === 'word')) {\n      replaceWith(setParent(createCharacterSet('word', {negate}), parent));\n      return;\n    }\n    if (kind === 'any') {\n      replaceWith(setParent(createUnicodeProperty('Any'), parent));\n    } else if (kind === 'digit') {\n      replaceWith(setParent(createUnicodeProperty('Nd', {negate}), parent));\n    } else if (kind === 'dot') {\n      // No-op; doesn't need transformation\n    } else if (kind === 'text_segment') {\n      if (accuracy === 'strict') {\n        throw new Error(r`Use of \"\\X\" requires non-strict accuracy`);\n      }\n      // Emoji pattern based on \u003cgithub.com/slevithan/emoji-regex-xs\u003e but adapted for our use case\n      // Note: Not using raw strings to work around Bun ≤ 1.1.34 issue \u003cgithub.com/oven-sh/bun/issues/7540\u003e\n      const eBase = '\\\\p{Emoji}(?:\\\\p{EMod}|\\\\uFE0F\\\\u20E3?|[\\\\x{E0020}-\\\\x{E007E}]+\\\\x{E007F})?';\n      const emoji = r`\\p{RI}{2}|${eBase}(?:\\u200D${eBase})*`;\n      replaceWith(setParentDeep(parseFragment(\n        // Close approximation of an extended grapheme cluster; see \u003cunicode.org/reports/tr29/\u003e\n        r`(?\u003e\\r\\n|${minTargetEs2024 ? r`\\p{RGI_Emoji}` : emoji}|\\P{M}\\p{M}*)`,\n        // Allow JS property `RGI_Emoji` through\n        {skipPropertyNameValidation: true}\n      ), parent));\n    } else if (kind === 'hex') {\n      replaceWith(setParent(createUnicodeProperty('AHex', {negate}), parent));\n    } else if (kind === 'newline') {\n      replaceWith(setParentDeep(parseFragment(negate ? '[^\\n]' : '(?\u003e\\r\\n?|[\\n\\v\\f\\x85\\u2028\\u2029])'), parent));\n    } else if (kind === 'posix') {\n      if (!minTargetEs2024 \u0026\u0026 (value === 'graph' || value === 'print')) {\n        if (accuracy === 'strict') {\n          throw new Error(`POSIX class \"${value}\" requires min target ES2024 or non-strict accuracy`);\n        }\n        let ascii = {\n          graph: '!-~',\n          print: ' -~',\n        }[value];\n        if (negate) {\n          // POSIX classes are always nested in a char class; manually invert the range rather than\n          // using `[^…]` so it can be unwrapped since ES2018 doesn't support nested classes\n          ascii = `\\0-${cp(ascii.codePointAt(0) - 1)}${cp(ascii.codePointAt(2) + 1)}-\\u{10FFFF}`;\n        }\n        replaceWith(setParentDeep(parseFragment(`[${ascii}]`), parent));\n      } else {\n        replaceWith(setParentDeep(setNegate(parseFragment(PosixClassMap.get(value)), negate), parent));\n      }\n    } else if (kind === 'property') {\n      if (!JsUnicodePropertyMap.has(slug(value))) {\n        // Assume it's a script; no error checking is the price for avoiding heavyweight Unicode\n        // data for all script names\n        node.key = 'sc';\n      }\n    } else if (kind === 'space') {\n      // Can't use JS's Unicode `\\s` since unlike Onig it includes `\\uFEFF` and excludes `\\x85`\n      replaceWith(setParent(createUnicodeProperty('space', {negate}), parent));\n    } else if (kind === 'word') {\n      replaceWith(setParentDeep(setNegate(parseFragment(defaultWordChar), negate), parent));\n    } else {\n      throw new Error(`Unexpected character set kind \"${kind}\"`);\n    }\n  },\n\n  Directive({node, parent, root, remove, replaceWith, removeAllPrevSiblings, removeAllNextSiblings}) {\n    const {kind, flags} = node;\n    if (kind === 'flags') {\n      if (!flags.enable \u0026\u0026 !flags.disable) {\n        // Flag directive without flags; ex: `(?-)`, `(?--)`\n        remove();\n      } else {\n        const flagGroup = createGroup({flags});\n        flagGroup.body[0].body = removeAllNextSiblings();\n        replaceWith(setParentDeep(flagGroup, parent), {traverse: true});\n      }\n    } else if (kind === 'keep') {\n      const firstAlt = root.body[0];\n      // Supporting a full-pattern wrapper around `\\K` enables use with flag modifiers\n      const hasWrapperGroup =\n        root.body.length === 1 \u0026\u0026\n        // Not emulatable if within a `CapturingGroup`\n        hasOnlyChild(firstAlt, {type: 'Group'}) \u0026\u0026\n        firstAlt.body[0].body.length === 1;\n      const topLevel = hasWrapperGroup ? firstAlt.body[0] : root;\n      if (parent.parent !== topLevel || topLevel.body.length \u003e 1) {\n        throw new Error(r`Uses \"\\K\" in a way that's unsupported`);\n      }\n      const lookbehind = createLookaroundAssertion({behind: true});\n      lookbehind.body[0].body = removeAllPrevSiblings();\n      replaceWith(setParentDeep(lookbehind, parent));\n    } else {\n      throw new Error(`Unexpected directive kind \"${kind}\"`);\n    }\n  },\n\n  Flags({node, parent}) {\n    // Throw for flags supported by the parser but not yet for transpilation\n    if (node.posixIsAscii) {\n      throw new Error('Unsupported flag \"P\"');\n    }\n    if (node.textSegmentMode === 'word') {\n      throw new Error('Unsupported flag \"y{w}\"');\n    }\n    // Remove Onig flags that aren't available in JS\n    [ 'digitIsAscii', // Flag D\n      'extended', // Flag x\n      'posixIsAscii', // Flag P\n      'spaceIsAscii', // Flag S\n      'wordIsAscii', // Flag W\n      'textSegmentMode', // Flag y{g} or y{w}\n    ].forEach(f =\u003e delete node[f]);\n    Object.assign(node, {\n      // JS flag g; no Onig equiv\n      global: false,\n      // JS flag d; no Onig equiv\n      hasIndices: false,\n      // JS flag m; no Onig equiv but its behavior is always on in Onig. Onig's only line break\n      // char is line feed, unlike JS, so this flag isn't used since it would produce inaccurate\n      // results (also allows `^` and `$` to be used in the generator for string start and end)\n      multiline: false,\n      // JS flag y; no Onig equiv, but used for `\\G` emulation\n      sticky: node.sticky ?? false,\n      // Note: Regex+ doesn't allow explicitly adding flags it handles implicitly, so leave out\n      // properties `unicode` (JS flag u) and `unicodeSets` (JS flag v). Keep the existing values\n      // for `ignoreCase` (flag i) and `dotAll` (JS flag s, but Onig flag m)\n    });\n    // Options accepted by Regex+; see \u003cgithub.com/slevithan/regex#-options\u003e\n    parent.options = {\n      disable: {\n        // Onig uses different rules for flag x than Regex+, so disable the implicit flag\n        x: true,\n        // Onig has no flag to control \"named capture only\" mode but contextually applies its\n        // behavior when named capturing is used, so disable Regex+'s implicit flag for it\n        n: true,\n      },\n      force: {\n        // Always add flag v because we're generating an AST that relies on it (it enables JS\n        // support for Onig features nested classes, intersection, Unicode properties, etc.).\n        // However, the generator might disable flag v based on its `target` option\n        v: true,\n      },\n    };\n  },\n\n  Group({node}) {\n    if (!node.flags) {\n      return;\n    }\n    const {enable, disable} = node.flags;\n    // Onig's flag x (`extended`) isn't available in JS\n    enable?.extended \u0026\u0026 delete enable.extended;\n    disable?.extended \u0026\u0026 delete disable.extended;\n    // JS doesn't support flag groups that enable and disable the same flag; ex: `(?i-i:)`\n    enable?.dotAll \u0026\u0026 disable?.dotAll \u0026\u0026 delete enable.dotAll;\n    enable?.ignoreCase \u0026\u0026 disable?.ignoreCase \u0026\u0026 delete enable.ignoreCase;\n    // Cleanup\n    enable \u0026\u0026 !Object.keys(enable).length \u0026\u0026 delete node.flags.enable;\n    disable \u0026\u0026 !Object.keys(disable).length \u0026\u0026 delete node.flags.disable;\n    !node.flags.enable \u0026\u0026 !node.flags.disable \u0026\u0026 delete node.flags;\n  },\n\n  LookaroundAssertion({node}, state) {\n    const {kind} = node;\n    if (kind === 'lookbehind') {\n      state.passedLookbehind = true;\n    }\n  },\n\n  NamedCallout({node, parent, replaceWith}) {\n    const {kind} = node;\n    if (kind === 'fail') {\n      replaceWith(setParentDeep(createLookaroundAssertion({negate: true}), parent));\n    } else {\n      throw new Error(`Unsupported named callout \"(*${kind.toUpperCase()}\"`);\n    }\n  },\n\n  Quantifier({node}) {\n    if (node.body.type === 'Quantifier') {\n      // Change e.g. `a**` to `(?:a*)*`\n      const group = createGroup();\n      group.body[0].body.push(node.body);\n      node.body = setParentDeep(group, node);\n    }\n  },\n\n  Regex: {\n    enter({node}, {supportedGNodes}) {\n      // For `\\G` to be accurately emulatable using JS flag y, it must be at (and only at) the start\n      // of every top-level alternative (with complex rules for what determines being at the start).\n      // Additional `\\G` error checking in `Assertion` visitor\n      const leadingGs = [];\n      let hasAltWithLeadG = false;\n      let hasAltWithoutLeadG = false;\n      for (const alt of node.body) {\n        if (alt.body.length === 1 \u0026\u0026 alt.body[0].kind === 'search_start') {\n          // Remove the `\\G` (leaving behind an empty alternative, and without adding JS flag y)\n          // since a top-level alternative that includes only `\\G` always matches at the start of the\n          // match attempt. Note that this is based on Oniguruma's rules, and is different than other\n          // regex flavors where `\\G` matches at the end of the previous match (a subtle distinction\n          // that's relevant after zero-length matches)\n          alt.body.pop();\n        } else {\n          const leadingG = getLeadingG(alt.body);\n          if (leadingG) {\n            hasAltWithLeadG = true;\n            Array.isArray(leadingG) ?\n              leadingGs.push(...leadingG) :\n              leadingGs.push(leadingG);\n          } else {\n            hasAltWithoutLeadG = true;\n          }\n        }\n      }\n      if (hasAltWithLeadG \u0026\u0026 !hasAltWithoutLeadG) {\n        // Supported `\\G` nodes will be removed (and add flag y) when traversed\n        leadingGs.forEach(g =\u003e supportedGNodes.add(g));\n      }\n    },\n    exit(_, {accuracy, passedLookbehind, strategy}) {\n      if (accuracy === 'strict' \u0026\u0026 passedLookbehind \u0026\u0026 strategy) {\n        throw new Error(r`Uses \"\\G\" in a way that requires non-strict accuracy`);\n      }\n    },\n  },\n\n  Subroutine({node}, {jsGroupNameMap}) {\n    let {ref} = node;\n    if (typeof ref === 'string' \u0026\u0026 !isValidJsGroupName(ref)) {\n      ref = getAndStoreJsGroupName(ref, jsGroupNameMap);\n      node.ref = ref;\n    }\n  },\n};\n\nconst /** @type {Visitor} */ SecondPassVisitor = {\n  Backreference({node}, {multiplexCapturesToLeftByRef, reffedNodesByReferencer}) {\n    const {orphan, ref} = node;\n    if (!orphan) {\n      // Copy the current state for later multiplexing expansion. That's done in a subsequent pass\n      // because backref numbers need to be recalculated after subroutine expansion\n      reffedNodesByReferencer.set(node, [...multiplexCapturesToLeftByRef.get(ref).map(({node}) =\u003e node)]);\n    }\n  },\n\n  CapturingGroup: {\n    enter(\n      { node,\n        parent,\n        replaceWith,\n        skip,\n      },\n      { groupOriginByCopy,\n        groupsByName,\n        multiplexCapturesToLeftByRef,\n        openRefs,\n        reffedNodesByReferencer,\n      }\n    ) {\n      // Has value if we're within a subroutine expansion\n      const origin = groupOriginByCopy.get(node);\n\n      // ## Handle recursion; runs after subroutine expansion\n      if (origin \u0026\u0026 openRefs.has(node.number)) {\n        // Recursive subroutines don't affect any following backrefs to their `ref` (unlike other\n        // subroutines), so don't wrap with a capture. The reffed group might have its name removed\n        // due to later subroutine expansion\n        const recursion = setParent(createRecursion(node.number), parent);\n        reffedNodesByReferencer.set(recursion, openRefs.get(node.number));\n        replaceWith(recursion);\n        return;\n      }\n      openRefs.set(node.number, node);\n\n      // ## Track data for backref multiplexing\n      multiplexCapturesToLeftByRef.set(node.number, []);\n      if (node.name) {\n        getOrInsert(multiplexCapturesToLeftByRef, node.name, []);\n      }\n      const multiplexNodes = multiplexCapturesToLeftByRef.get(node.name ?? node.number);\n      for (let i = 0; i \u003c multiplexNodes.length; i++) {\n        // Captures added via subroutine expansion (maybe indirectly because they were descendant\n        // captures of the reffed group or in a nested subroutine expansion) form a set with their\n        // origin group and any other copies of it added via subroutines. Only the most recently\n        // matched within this set is added to backref multiplexing. So search the list of already-\n        // tracked multiplexed nodes for this group name or number to see if there's a node being\n        // replaced by this capture\n        const multiplex = multiplexNodes[i];\n        if (\n          // This group is from subroutine expansion, and there's a multiplex value from either the\n          // origin node or a prior subroutine expansion group with the same origin\n          (origin === multiplex.node || (origin \u0026\u0026 origin === multiplex.origin)) ||\n          // This group is not from subroutine expansion, and it comes after a subroutine expansion\n          // group that refers to this group\n          node === multiplex.origin\n        ) {\n          multiplexNodes.splice(i, 1);\n          break;\n        }\n      }\n      multiplexCapturesToLeftByRef.get(node.number).push({node, origin});\n      if (node.name) {\n        multiplexCapturesToLeftByRef.get(node.name).push({node, origin});\n      }\n\n      // ## Track data for duplicate names\n      // Pre-ES2025 doesn't allow duplicate names, but ES2025 allows duplicate names that are\n      // unique per mutually exclusive alternation path. However, Oniguruma's handling for named\n      // subpatterns on match results means we can't use this ES2025 feature even when in an ES2025\n      // env. So, if using a duplicate name, remove the name from all but the first instance that\n      // wasn't created by subroutine expansion\n      if (node.name) {\n        const groupsWithSameName = getOrInsert(groupsByName, node.name, new Map());\n        let hasDuplicateNameToRemove = false;\n        if (origin) {\n          // Subroutines and their child captures shouldn't hold duplicate names in the final state\n          hasDuplicateNameToRemove = true;\n        } else {\n          for (const groupInfo of groupsWithSameName.values()) {\n            if (!groupInfo.hasDuplicateNameToRemove) {\n              // Will change to an unnamed capture in a later pass\n              hasDuplicateNameToRemove = true;\n              break;\n            }\n          }\n        }\n        groupsByName.get(node.name).set(node, {node, hasDuplicateNameToRemove});\n      }\n    },\n    exit({node}, {openRefs}) {\n      // During `enter`, ownership of `openRefs` isn't claimed when recursive clones are replaced,\n      // so only the node that inserted the current entry should clear it on exit\n      if (openRefs.get(node.number) === node) {\n        openRefs.delete(node.number);\n      }\n    },\n  },\n\n  Group: {\n    enter({node}, state) {\n      // Flag directives have already been converted to flag groups by the previous pass\n      state.prevFlags = state.currentFlags;\n      if (node.flags) {\n        state.currentFlags = getNewCurrentFlags(state.currentFlags, node.flags);\n      }\n    },\n    exit(_, state) {\n      state.currentFlags = state.prevFlags;\n    },\n  },\n\n  Subroutine({node, parent, replaceWith}, state) {\n    const {isRecursive, ref} = node;\n\n    // Subroutine nodes with `isRecursive` are created during the current traversal; they're only\n    // traversed here if a recursive subroutine created during traversal is then copied by a\n    // subroutine expansion, e.g. with `(?\u003ca\u003e\\g\u003ca\u003e)\\g\u003ca\u003e`\n    if (isRecursive) {\n      // Immediate parent is an alternative or quantifier; can skip\n      let reffed = parent;\n      while ((reffed = reffed.parent)) {\n        if (reffed.type === 'CapturingGroup' \u0026\u0026 (reffed.name === ref || reffed.number === ref)) {\n          break;\n        }\n      }\n      // Track the referenced node because `ref`s are rewritten in a subsequent pass; capturing\n      // group names and numbers might change due to subroutine expansion and duplicate group names\n      state.reffedNodesByReferencer.set(node, reffed);\n      return;\n    }\n\n    const reffedGroupNode = state.subroutineRefMap.get(ref);\n    // Other forms of recursion are handled by the `CapturingGroup` visitor\n    const isGlobalRecursion = ref === 0;\n    const expandedSubroutine = isGlobalRecursion ?\n      createRecursion(0) :\n      // The reffed group might itself contain subroutines, which are expanded during sub-traversal\n      cloneCapturingGroup(reffedGroupNode, state.groupOriginByCopy, null);\n    let replacement = expandedSubroutine;\n    if (!isGlobalRecursion) {\n      // Subroutines take their flags from the reffed group, not the flags surrounding themselves\n      const reffedGroupFlagMods = getCombinedFlagModsFromFlagNodes(getAllParents(\n        reffedGroupNode,\n        p =\u003e p.type === 'Group' \u0026\u0026 !!p.flags\n      ));\n      const reffedGroupFlags = reffedGroupFlagMods ?\n        getNewCurrentFlags(state.globalFlags, reffedGroupFlagMods) :\n        state.globalFlags;\n      if (!areFlagsEqual(reffedGroupFlags, state.currentFlags)) {\n        replacement = createGroup({\n          flags: getFlagModsFromFlags(reffedGroupFlags),\n        });\n        replacement.body[0].body.push(expandedSubroutine);\n      }\n    }\n    replaceWith(setParentDeep(replacement, parent), {traverse: !isGlobalRecursion});\n  },\n};\n\nconst /** @type {Visitor} */ ThirdPassVisitor = {\n  Backreference({node, parent, replaceWith}, state) {\n    if (node.orphan) {\n      state.highestOrphanBackref = Math.max(state.highestOrphanBackref, node.ref);\n      // Don't renumber; used with `allowOrphanBackrefs`\n      return;\n    }\n    const reffedNodes = state.reffedNodesByReferencer.get(node);\n    const participants = reffedNodes.filter(reffed =\u003e canParticipateWithNode(reffed, node));\n    // For the backref's `ref`, use `number` rather than `name` because group names might have been\n    // removed if they're duplicates within their alternation path, or they might be removed later\n    // by the generator (depending on target) if they're duplicates within the overall pattern.\n    // Backrefs must come after groups they ref, so reffed node `number`s are already recalculated\n    if (!participants.length) {\n      // If no participating capture, convert backref to to `(?!)`; backrefs to nonparticipating\n      // groups can't match in Onig but match the empty string in JS\n      replaceWith(setParentDeep(createLookaroundAssertion({negate: true}), parent));\n    } else if (participants.length \u003e 1) {\n      // Multiplex for backrefs to duplicate capture names; try them in reverse order\n      const group = createGroup({\n        atomic: true,\n        body: participants.reverse().map(reffed =\u003e createAlternative({\n          body: [createBackreference(reffed.number)],\n        })),\n      });\n      replaceWith(setParentDeep(group, parent));\n    } else {\n      node.ref = participants[0].number;\n    }\n  },\n\n  CapturingGroup({node}, state) {\n    // Recalculate the number since the current value might be wrong due to subroutine expansion\n    node.number = ++state.numCapturesToLeft;\n    if (node.name) {\n      // Removing duplicate names here rather than in an earlier pass avoids extra complexity when\n      // handling subroutine expansion and backref multiplexing\n      if (state.groupsByName.get(node.name).get(node).hasDuplicateNameToRemove) {\n        delete node.name;\n      }\n    }\n  },\n\n  Regex: {\n    exit({node}, state) {\n      // HACK: Add unnamed captures to the end of the regex if needed to allow orphaned backrefs\n      // to be valid in JS with flag u/v. This is needed to support TextMate grammars, which\n      // replace numbered backrefs in their `end` pattern with values matched by captures in their\n      // `begin` pattern! See \u003cgithub.com/microsoft/vscode-textmate/blob/7e0ea282f4f25fef12a6c84fa4fa7266f67b58dc/src/rule.ts#L661-L663\u003e\n      // An `end` pattern, prior to this substitution, might have backrefs to a group that doesn't\n      // exist within `end`. This presents a dilemma since both Oniguruma and JS (with flag u/v)\n      // error for backrefs to undefined captures. So adding captures to the end is a solution that\n      // doesn't change what the regex matches, and lets invalid numbered backrefs through. Note:\n      // Orphan backrefs are only allowed if `allowOrphanBackrefs` is enabled\n      const numCapsNeeded = Math.max(state.highestOrphanBackref - state.numCapturesToLeft, 0);\n      for (let i = 0; i \u003c numCapsNeeded; i++) {\n        const emptyCapture = createCapturingGroup();\n        node.body.at(-1).body.push(emptyCapture);\n      }\n    },\n  },\n\n  Subroutine({node}, state) {\n    if (!node.isRecursive || node.ref === 0) {\n      return;\n    }\n    // For the recursion's `ref`, use `number` rather than `name` because group names might have\n    // been removed if they're duplicates within their alternation path, or they might be removed\n    // later by the generator (depending on target) if they're duplicates within the overall\n    // pattern. Since recursion appears within the group it refs, the reffed node's `number` has\n    // already been recalculated\n    node.ref = state.reffedNodesByReferencer.get(node).number;\n  },\n};\n\n// ---------------\n// --- Helpers ---\n// ---------------\n\nfunction addParentProperties(root) {\n  traverse(root, {\n    '*'({node, parent}) {\n      node.parent = parent;\n    },\n  });\n}\n\nfunction areFlagsEqual(a, b) {\n  return a.dotAll === b.dotAll \u0026\u0026 a.ignoreCase === b.ignoreCase;\n}\n\nfunction canParticipateWithNode(capture, node) {\n  // Walks to the left (prev siblings), down (sibling descendants), up (parent), then back down\n  // (parent's prev sibling descendants) the tree in a loop\n  let rightmostPoint = node;\n  do {\n    if (rightmostPoint.type === 'Regex') {\n      // End of the line; capture is not in node's alternation path\n      return false;\n    }\n    if (rightmostPoint.type === 'Alternative') {\n      // Skip past alts to their parent because we don't want to look at the kids of preceding alts\n      continue;\n    }\n    if (rightmostPoint === capture) {\n      // Capture is ancestor of node\n      return false;\n    }\n    const kidsOfParent = getKids(rightmostPoint.parent);\n    for (const kid of kidsOfParent) {\n      if (kid === rightmostPoint) {\n        // Reached rightmost node in sibling list that we want to consider; break to parent loop\n        break;\n      }\n      if (kid === capture || isAncestorOf(kid, capture)) {\n        return true;\n      }\n    }\n  } while ((rightmostPoint = rightmostPoint.parent));\n  throw new Error('Unexpected path');\n}\n\n// Creates a deep copy of the provided node, with special handling:\n// - Make `parent` props point to their parent in the copy\n// - Update the provided `originMap` for each cloned capturing group (outer and nested)\nfunction cloneCapturingGroup(obj, originMap, up, up2) {\n  const store = Array.isArray(obj) ? [] : {};\n  for (const [key, value] of Object.entries(obj)) {\n    if (key === 'parent') {\n      // If the last cloned item was a container array (for holding kids), use the object above it\n      store.parent = Array.isArray(up) ? up2 : up;\n    } else if (value \u0026\u0026 typeof value === 'object') {\n      store[key] = cloneCapturingGroup(value, originMap, store, up);\n    } else {\n      if (key === 'type' \u0026\u0026 value === 'CapturingGroup') {\n        // Key is the copied node, value is the origin node\n        originMap.set(store, originMap.get(obj) ?? obj);\n      }\n      store[key] = value;\n    }\n  }\n  return store;\n}\n\nfunction createRecursion(ref) {\n  const node = createSubroutine(ref);\n  // In the future, the parser will set a `recursive` property on subroutines:\n  // \u003cgithub.com/slevithan/oniguruma-parser/issues/3\u003e. When that's available, this function won't\n  // be needed and the related logic in this transformer should change (simplify) to use it\n  node.isRecursive = true;\n  return node;\n}\n\nfunction getAllParents(node, filterFn) {\n  const results = [];\n  while ((node = node.parent)) {\n    if (!filterFn || filterFn(node)) {\n      results.push(node);\n    }\n  }\n  return results;\n}\n\n// See also `isValidJsGroupName`\nfunction getAndStoreJsGroupName(name, map) {\n  if (map.has(name)) {\n    return map.get(name);\n  }\n  // Onig group names can't start with `$`, but JS names can\n  const jsName = `$${map.size}_${name.replace(/^[^$_\\p{IDS}]|[^$\\u200C\\u200D\\p{IDC}]/ug, '_')}`;\n  map.set(name, jsName);\n  return jsName;\n}\n\nfunction getCombinedFlagModsFromFlagNodes(flagNodes) {\n  const flagProps = ['dotAll', 'ignoreCase'];\n  const combinedFlags = {enable: {}, disable: {}};\n  flagNodes.forEach(({flags}) =\u003e {\n    flagProps.forEach(prop =\u003e {\n      if (flags.enable?.[prop]) {\n        // Need to remove `disable` since disabled flags take precedence\n        delete combinedFlags.disable[prop];\n        combinedFlags.enable[prop] = true;\n      }\n      if (flags.disable?.[prop]) {\n        combinedFlags.disable[prop] = true;\n      }\n    });\n  });\n  if (!Object.keys(combinedFlags.enable).length) {\n    delete combinedFlags.enable;\n  }\n  if (!Object.keys(combinedFlags.disable).length) {\n    delete combinedFlags.disable;\n  }\n  if (combinedFlags.enable || combinedFlags.disable) {\n    return combinedFlags;\n  }\n  return null;\n}\n\nfunction getFlagModsFromFlags({dotAll, ignoreCase}) {\n  const mods = {};\n  if (dotAll || ignoreCase) {\n    mods.enable = {};\n    dotAll \u0026\u0026 (mods.enable.dotAll = true);\n    ignoreCase \u0026\u0026 (mods.enable.ignoreCase = true);\n  }\n  if (!dotAll || !ignoreCase) {\n    mods.disable = {};\n    !dotAll \u0026\u0026 (mods.disable.dotAll = true);\n    !ignoreCase \u0026\u0026 (mods.disable.ignoreCase = true);\n  }\n  return mods;\n}\n\nfunction getKids(node) {\n  if (!node) {\n    throw new Error('Node expected');\n  }\n  // NOTE: Not handling `CharacterClassRange`'s `min`/`max` and `Regex`'s `flags`, only because\n  // they haven't been needed by current callers\n  const {body} = node;\n  return Array.isArray(body) ? body : (body ? [body] : null);\n}\n\nfunction getLeadingG(els) {\n  const firstToConsider = els.find(el =\u003e (\n    el.kind === 'search_start' ||\n    isLoneGLookaround(el, {negate: false}) ||\n    !isAlwaysZeroLength(el)\n  ));\n  if (!firstToConsider) {\n    return null;\n  }\n  if (firstToConsider.kind === 'search_start') {\n    return firstToConsider;\n  }\n  if (firstToConsider.type === 'LookaroundAssertion') {\n    return firstToConsider.body[0].body[0];\n  }\n  if (firstToConsider.type === 'CapturingGroup' || firstToConsider.type === 'Group') {\n    const gNodesForGroup = [];\n    // Recursively find `\\G` nodes for all alternatives in the group\n    for (const alt of firstToConsider.body) {\n      const leadingG = getLeadingG(alt.body);\n      if (!leadingG) {\n        // Don't return `gNodesForGroup` collected so far since this alt didn't qualify\n        return null;\n      }\n      Array.isArray(leadingG) ?\n        gNodesForGroup.push(...leadingG) :\n        gNodesForGroup.push(leadingG);\n    }\n    return gNodesForGroup;\n  }\n  return null;\n}\n\nfunction isAncestorOf(node, descendant) {\n  const kids = getKids(node) ?? [];\n  for (const kid of kids) {\n    if (kid === descendant || isAncestorOf(kid, descendant)) {\n      return true;\n    }\n  }\n  return false;\n}\n\n/**\n@param {Node} node\n@returns {boolean}\n*/\nfunction isAlwaysZeroLength({type}) {\n  return (\n    type === 'Assertion' ||\n    type === 'Directive' ||\n    type === 'LookaroundAssertion'\n  );\n}\n\n/**\n@param {Node} node\n@returns {boolean}\n*/\nfunction isAlwaysNonZeroLength(node) {\n  const types = [\n    'Character',\n    'CharacterClass',\n    'CharacterSet',\n  ];\n  return types.includes(node.type) || (\n    node.type === 'Quantifier' \u0026\u0026\n    node.min \u0026\u0026\n    types.includes(node.body.type)\n  );\n}\n\nfunction isLoneGLookaround(node, options) {\n  const opts = {\n    negate: null,\n    ...options,\n  };\n  return (\n    node.type === 'LookaroundAssertion' \u0026\u0026\n    (opts.negate === null || node.negate === opts.negate) \u0026\u0026\n    node.body.length === 1 \u0026\u0026\n    hasOnlyChild(node.body[0], {\n      type: 'Assertion',\n      kind: 'search_start',\n    })\n  );\n}\n\n// See also `getAndStoreJsGroupName`\nfunction isValidJsGroupName(name) {\n  // JS group names are more restrictive than Onig; see\n  // \u003cdeveloper.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\u003e\n  return /^[$_\\p{IDS}][$\\u200C\\u200D\\p{IDC}]*$/u.test(name);\n}\n\n// Returns a single node, either the given node or all nodes wrapped in a noncapturing group\nfunction parseFragment(pattern, options) {\n  const ast = parse(pattern, {\n    ...options,\n    // Providing a custom set of Unicode property names avoids converting some JS Unicode\n    // properties (ex: `\\p{Alpha}`) to Onig POSIX classes\n    unicodePropertyMap: JsUnicodePropertyMap,\n  });\n  const alts = ast.body;\n  if (alts.length \u003e 1 || alts[0].body.length \u003e 1) {\n    return createGroup({body: alts});\n  }\n  return alts[0].body[0];\n}\n\nfunction setNegate(node, negate) {\n  node.negate = negate;\n  return node;\n}\n\nfunction setParent(node, parent) {\n  node.parent = parent;\n  return node;\n}\n\nfunction setParentDeep(node, parent) {\n  addParentProperties(node);\n  node.parent = parent;\n  return node;\n}\n\nexport {\n  transform,\n};\n","import {getOptions} from './options.js';\nimport {getIgnoreCaseMatchChars, UnicodePropertiesWithSpecificCase} from './unicode.js';\nimport {cp, envFlags, getNewCurrentFlags, getOrInsert, isMinTarget, r, throwIfNullish} from './utils.js';\nimport {createAlternative, createCharacter, createGroup} from 'oniguruma-parser/parser';\nimport {traverse} from 'oniguruma-parser/traverser';\n/**\n@import {ToRegExpOptions} from './index.js';\n@import {RegexPlusAst} from './transform.js';\n@import {AlternativeNode, AssertionNode, BackreferenceNode, CapturingGroupNode, CharacterClassNode, CharacterClassRangeNode, CharacterNode, CharacterSetNode, FlagsNode, GroupNode, LookaroundAssertionNode, Node, QuantifierNode, SubroutineNode} from 'oniguruma-parser/parser';\n@import {Visitor} from 'oniguruma-parser/traverser';\n*/\n\n/**\nGenerates a Regex+ compatible `pattern`, `flags`, and `options` from a Regex+ AST.\n@param {RegexPlusAst} ast\n@param {ToRegExpOptions} [options]\n@returns {{\n  pattern: string;\n  flags: string;\n  options: Object;\n  _captureTransfers: Map\u003cnumber, Array\u003cnumber\u003e\u003e;\n  _hiddenCaptures: Array\u003cnumber\u003e;\n}}\n*/\nfunction generate(ast, options) {\n  const opts = getOptions(options);\n  const minTargetEs2024 = isMinTarget(opts.target, 'ES2024');\n  const minTargetEs2025 = isMinTarget(opts.target, 'ES2025');\n  const recursionLimit = opts.rules.recursionLimit;\n  if (!Number.isInteger(recursionLimit) || recursionLimit \u003c 2 || recursionLimit \u003e 20) {\n    throw new Error('Invalid recursionLimit; use 2-20');\n  }\n\n  // If the output can't use flag groups, we need a pre-pass to check for the use of chars with\n  // case in case sensitive/insensitive states. This minimizes the need for case expansions (though\n  // expansions are lossless, even given Unicode case complexities) and allows supporting case\n  // insensitive backrefs in more cases\n  // TODO: Consider gathering this data in the transformer's final traversal to avoid work here\n  let hasCaseInsensitiveNode = null;\n  let hasCaseSensitiveNode = null;\n  if (!minTargetEs2025) {\n    const iStack = [ast.flags.ignoreCase];\n    traverse(ast, FlagModifierVisitor, {\n      getCurrentModI: () =\u003e iStack.at(-1),\n      popModI() {iStack.pop()},\n      pushModI(isIOn) {iStack.push(isIOn)},\n      setHasCasedChar() {\n        if (iStack.at(-1)) {\n          hasCaseInsensitiveNode = true;\n        } else {\n          hasCaseSensitiveNode = true;\n        }\n      },\n    });\n  }\n\n  const appliedGlobalFlags = {\n    dotAll: ast.flags.dotAll,\n    // - Turn global flag i on if a case insensitive node was used and no case sensitive nodes were\n    //   used (to avoid unnecessary node expansion).\n    // - Turn global flag i off if a case sensitive node was used (since case sensitivity can't be\n    //   forced without the use of ES2025 flag groups)\n    ignoreCase: !!((ast.flags.ignoreCase || hasCaseInsensitiveNode) \u0026\u0026 !hasCaseSensitiveNode),\n  };\n  let /** @type {Node} */ lastNode = ast;\n  const state = {\n    accuracy: opts.accuracy,\n    appliedGlobalFlags,\n    captureMap: new Map(),\n    currentFlags: {\n      dotAll: ast.flags.dotAll,\n      ignoreCase: ast.flags.ignoreCase,\n    },\n    inCharClass: false,\n    lastNode,\n    originMap: ast._originMap,\n    recursionLimit,\n    useAppliedIgnoreCase: !!(!minTargetEs2025 \u0026\u0026 hasCaseInsensitiveNode \u0026\u0026 hasCaseSensitiveNode),\n    useFlagMods: minTargetEs2025,\n    useFlagV: minTargetEs2024,\n    verbose: opts.verbose,\n  };\n  function gen(/** @type {Node} */ node) {\n    state.lastNode = lastNode;\n    lastNode = node; // For the next iteration\n    const fn = throwIfNullish(generator[node.type], `Unexpected node type \"${node.type}\"`);\n    return fn(node, state, gen);\n  }\n\n  const result = {\n    pattern: ast.body.map(gen).join('|'),\n    // Could reset `lastNode` at this point via `lastNode = ast`, but it isn't needed by flags\n    flags: gen(ast.flags),\n    options: {...ast.options},\n  };\n  if (!minTargetEs2024) {\n    // Switch from flag v to u; Regex+ implicitly chooses by default\n    delete result.options.force.v;\n    result.options.disable.v = true;\n    result.options.unicodeSetsPlugin = null;\n  }\n  result._captureTransfers = new Map();\n  result._hiddenCaptures = [];\n  state.captureMap.forEach((value, key) =\u003e {\n    if (value.hidden) {\n      result._hiddenCaptures.push(key);\n    }\n    if (value.transferTo) {\n      getOrInsert(result._captureTransfers, value.transferTo, []).push(key);\n    }\n  });\n\n  return result;\n}\n\nconst /** @type {Visitor} */ FlagModifierVisitor = {\n  '*': {\n    enter({node}, state) {\n      if (isAnyGroup(node)) {\n        const currentModI = state.getCurrentModI();\n        state.pushModI(\n          node.flags ?\n            getNewCurrentFlags({ignoreCase: currentModI}, node.flags).ignoreCase :\n            currentModI\n        );\n      }\n    },\n    exit({node}, state) {\n      if (isAnyGroup(node)) {\n        state.popModI();\n      }\n    },\n  },\n  Backreference(_, state) {\n    // Can't know for sure, so assume the backref will include chars with case (best that could be\n    // done is not calling `setHasCasedChar` if the reffed group doesn't contain a char with case\n    // or most kinds of char sets)\n    state.setHasCasedChar();\n  },\n  Character({node}, state) {\n    if (charHasCase(cp(node.value))) {\n      state.setHasCasedChar();\n    }\n  },\n  CharacterClassRange({node, skip}, state) {\n    skip();\n    if (getCasesOutsideCharClassRange(node, {firstOnly: true}).length) {\n      state.setHasCasedChar();\n    }\n  },\n  CharacterSet({node}, state) {\n    if (\n      node.kind === 'property' \u0026\u0026\n      UnicodePropertiesWithSpecificCase.has(node.value)\n    ) {\n      state.setHasCasedChar();\n    }\n  },\n};\n\n// `AbsenceFunction`, `Directive`, and `NamedCallout` nodes aren't included in transformer output\nconst generator = {\n  /**\n  @param {AlternativeNode} node\n  */\n  Alternative({body}, _, gen) {\n    return body.map(gen).join('');\n  },\n\n  /**\n  @param {AssertionNode} node\n  */\n  Assertion({kind, negate}) {\n    // Can always use `^` and `$` for string boundaries since JS flag m is never used (Onig uses\n    // different line break chars)\n    if (kind === 'string_end') {\n      return '$';\n    }\n    if (kind === 'string_start') {\n      return '^';\n    }\n    // If a word boundary came through the transformer unaltered, that means `wordIsAscii` or\n    // `asciiWordBoundaries` is enabled\n    if (kind === 'word_boundary') {\n      return negate ? r`\\B` : r`\\b`;\n    }\n    // Kinds `line_end`, `line_start`, `search_start`, `string_end_newline`, and\n    // `text_segment_boundary` are never included in transformer output\n    throw new Error(`Unexpected assertion kind \"${kind}\"`);\n  },\n\n  /**\n  @param {BackreferenceNode} node\n  */\n  Backreference({ref}, state) {\n    if (typeof ref !== 'number') {\n      throw new Error('Unexpected named backref in transformed AST');\n    }\n    if (\n      !state.useFlagMods \u0026\u0026\n      state.accuracy === 'strict' \u0026\u0026\n      state.currentFlags.ignoreCase \u0026\u0026\n      !state.captureMap.get(ref).ignoreCase\n    ) {\n      throw new Error('Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy');\n    }\n    return '\\\\' + ref;\n  },\n\n  /**\n  @param {CapturingGroupNode} node\n  */\n  CapturingGroup(node, state, gen) {\n    const {body, name, number} = node;\n    const data = {ignoreCase: state.currentFlags.ignoreCase};\n    // Has origin if the capture is from an expanded subroutine\n    const origin = state.originMap.get(node);\n    if (origin) {\n      // All captures from/within expanded subroutines are marked as hidden\n      data.hidden = true;\n      // If a subroutine (or descendant capture) occurs after its origin group, it's marked to have\n      // its captured value transferred to the origin's capture slot. `number` and `origin.number`\n      // are the capture numbers *after* subroutine expansion\n      if (number \u003e origin.number) {\n        data.transferTo = origin.number;\n      }\n    }\n    state.captureMap.set(number, data);\n    return `(${name ? `?\u003c${name}\u003e` : ''}${body.map(gen).join('|')})`;\n  },\n\n  /**\n  @param {CharacterNode} node\n  */\n  Character({value}, state) {\n    const char = cp(value);\n    const escaped = getCharEscape(value, {\n      escDigit: state.lastNode.type === 'Backreference',\n      inCharClass: state.inCharClass,\n      useFlagV: state.useFlagV,\n    });\n    if (escaped !== char) {\n      return escaped;\n    }\n    if (state.useAppliedIgnoreCase \u0026\u0026 state.currentFlags.ignoreCase \u0026\u0026 charHasCase(char)) {\n      const cases = getIgnoreCaseMatchChars(char);\n      return state.inCharClass ?\n        cases.join('') :\n        (cases.length \u003e 1 ? `[${cases.join('')}]` : cases[0]);\n    }\n    return char;\n  },\n\n  /**\n  @param {CharacterClassNode} node\n  */\n  CharacterClass(node, state, gen) {\n    const {kind, negate, parent} = node;\n    let {body} = node;\n    if (kind === 'intersection' \u0026\u0026 !state.useFlagV) {\n      throw new Error('Use of character class intersection requires min target ES2024');\n    }\n    // Work around a WebKit parser bug by moving literal hyphens to the beginning of the class; see\n    // \u003cgithub.com/slevithan/oniguruma-to-es/issues/30\u003e\n    if (envFlags.bugFlagVLiteralHyphenIsRange \u0026\u0026 state.useFlagV \u0026\u0026 body.some(isLiteralHyphen)) {\n      body = [createCharacter(45), ...body.filter(kid =\u003e !isLiteralHyphen(kid))];\n    }\n    const genClass = () =\u003e `[${negate ? '^' : ''}${\n      body.map(gen).join(kind === 'intersection' ? '\u0026\u0026' : '')\n    }]`;\n    if (!state.inCharClass) {\n      // HACK: Transform the AST to support top-level-nested, negated classes in non-negated\n      // classes (ex: `[…[^…]]`) with pre-ES2024 `target`, via `(?:[…]|[^…])` or `(?:[^…])`,\n      // possibly with multiple alts that contain negated classes. Would be better to do this in\n      // the transformer, but it doesn't have true `target` since that's supposed to be a concern\n      // of the generator\n      if (\n        // Already established `kind !== 'intersection'` if `!state.useFlagV`; don't check again\n        (!state.useFlagV || envFlags.bugNestedClassIgnoresNegation) \u0026\u0026\n        !negate\n      ) {\n        const negatedChildClasses = body.filter(\n          kid =\u003e kid.type === 'CharacterClass' \u0026\u0026 kid.kind === 'union' \u0026\u0026 kid.negate\n        );\n        if (negatedChildClasses.length) {\n          const group = createGroup();\n          const groupFirstAlt = group.body[0];\n          group.parent = parent;\n          groupFirstAlt.parent = group;\n          body = body.filter(kid =\u003e !negatedChildClasses.includes(kid));\n          node.body = body;\n          if (body.length) {\n            node.parent = groupFirstAlt;\n            groupFirstAlt.body.push(node);\n          } else {\n            // Remove the group's only alt thus far, but since the class's `body` is empty, that\n            // implies there's at least one negated class we removed from it, so we'll add at least\n            // one alt back to the group, next\n            group.body.pop();\n          }\n          negatedChildClasses.forEach(cc =\u003e {\n            const newAlt = createAlternative({body: [cc]});\n            cc.parent = newAlt;\n            newAlt.parent = group;\n            group.body.push(newAlt);\n          });\n          return gen(group);\n        }\n      }\n      // For the outermost char class, set state\n      state.inCharClass = true;\n      const result = genClass();\n      state.inCharClass = false;\n      return result;\n    }\n    // No first element for implicit class in empty intersection like `[\u0026\u0026]`\n    const firstEl = body[0];\n    if (\n      // Already established that the parent is a char class via `inCharClass`; don't check again\n      kind === 'union' \u0026\u0026\n      !negate \u0026\u0026\n      firstEl \u0026\u0026\n      (\n        ( // Allows many nested classes to work with `target` ES2018 which doesn't support nesting\n          (!state.useFlagV || !state.verbose) \u0026\u0026\n          parent.kind === 'union' \u0026\u0026\n          !(envFlags.bugFlagVLiteralHyphenIsRange \u0026\u0026 state.useFlagV)\n        ) ||\n        ( !state.verbose \u0026\u0026\n          parent.kind === 'intersection' \u0026\u0026\n          // JS doesn't allow intersection with union or ranges\n          body.length === 1 \u0026\u0026\n          firstEl.type !== 'CharacterClassRange'\n        )\n      )\n    ) {\n      // Remove unnecessary nesting; unwrap kids into the parent char class\n      return body.map(gen).join('');\n    }\n    if (!state.useFlagV \u0026\u0026 parent.type === 'CharacterClass') {\n      throw new Error('Uses nested character class in a way that requires min target ES2024');\n    }\n    return genClass();\n  },\n\n  /**\n  @param {CharacterClassRangeNode} node\n  */\n  CharacterClassRange(node, state) {\n    const min = node.min.value;\n    const max = node.max.value;\n    const escOpts = {\n      escDigit: false,\n      inCharClass: true,\n      useFlagV: state.useFlagV,\n    };\n    const minStr = getCharEscape(min, escOpts);\n    const maxStr = getCharEscape(max, escOpts);\n    const extraChars = new Set();\n    if (state.useAppliedIgnoreCase \u0026\u0026 state.currentFlags.ignoreCase) {\n      // TODO: Avoid duplication by considering other chars in the parent char class when expanding\n      const charsOutsideRange = getCasesOutsideCharClassRange(node);\n      const ranges = getCodePointRangesFromChars(charsOutsideRange);\n      ranges.forEach(value =\u003e {\n        extraChars.add(\n          Array.isArray(value) ?\n            `${getCharEscape(value[0], escOpts)}-${getCharEscape(value[1], escOpts)}` :\n            getCharEscape(value, escOpts)\n        );\n      });\n    }\n    // Create the range without calling `gen` on the `min`/`max` kids\n    return `${minStr}-${maxStr}${[...extraChars].join('')}`;\n  },\n\n  /**\n  @param {CharacterSetNode} node\n  */\n  CharacterSet({kind, negate, value, key}, state) {\n    if (kind === 'dot') {\n      return state.currentFlags.dotAll ?\n        ((state.appliedGlobalFlags.dotAll || state.useFlagMods) ? '.' : '[^]') :\n        // Onig's only line break char is line feed, unlike JS\n        r`[^\\n]`;\n    }\n    if (kind === 'digit') {\n      return negate ? r`\\D` : r`\\d`;\n    }\n    if (kind === 'property') {\n      if (\n        state.useAppliedIgnoreCase \u0026\u0026\n        state.currentFlags.ignoreCase \u0026\u0026\n        UnicodePropertiesWithSpecificCase.has(value)\n      ) {\n        // Support for this would require heavy Unicode data. Could change e.g. `\\p{Lu}` to\n        // `\\p{LC}` if not using strict `accuracy` (since it's close but not 100%), but this\n        // wouldn't work for e.g. `\\p{Lt}`, and in any case, it's probably user error if using\n        // these case-specific props case-insensitively\n        throw new Error(`Unicode property \"${value}\" can't be case-insensitive when other chars have specific case`);\n      }\n      return `${negate ? r`\\P` : r`\\p`}{${key ? `${key}=` : ''}${value}}`;\n    }\n    if (kind === 'word') {\n      return negate ? r`\\W` : r`\\w`;\n    }\n    // Kinds `any`, `hex`, `newline`, `posix`, `space`, and `text_segment` are never included in\n    // transformer output\n    throw new Error(`Unexpected character set kind \"${kind}\"`);\n  },\n\n  /**\n  @param {FlagsNode} node\n  */\n  Flags(node, state) {\n    return (\n      // The transformer should never turn on the properties for flags d, g, m since Onig doesn't\n      // have equivs. Flag m is never used since Onig uses different line break chars than JS\n      // (node.hasIndices ? 'd' : '') +\n      // (node.global ? 'g' : '') +\n      // (node.multiline ? 'm' : '') +\n      (state.appliedGlobalFlags.ignoreCase ? 'i' : '') +\n      (node.dotAll ? 's' : '') +\n      (node.sticky ? 'y' : '')\n      // Regex+ doesn't allow explicitly adding flags it handles implicitly, so there are no\n      // `unicode` (flag u) or `unicodeSets` (flag v) props; those flags are added separately\n    );\n  },\n\n  /**\n  @param {GroupNode} node\n  */\n  Group({atomic, body, flags, parent}, state, gen) {\n    const currentFlags = state.currentFlags;\n    if (flags) {\n      state.currentFlags = getNewCurrentFlags(currentFlags, flags);\n    }\n    const contents = body.map(gen).join('|');\n    const result = (\n      !state.verbose \u0026\u0026\n      body.length === 1 \u0026\u0026 // Single alt\n      parent.type !== 'Quantifier' \u0026\u0026\n      !atomic \u0026\u0026\n      (!state.useFlagMods || !flags)\n     ) ? contents : `(?${getGroupPrefix(atomic, flags, state.useFlagMods)}${contents})`;\n    state.currentFlags = currentFlags;\n    return result;\n  },\n\n  /**\n  @param {LookaroundAssertionNode} node\n  */\n  LookaroundAssertion({body, kind, negate}, _, gen) {\n    const prefix = `${kind === 'lookahead' ? '' : '\u003c'}${negate ? '!' : '='}`;\n    return `(?${prefix}${body.map(gen).join('|')})`;\n  },\n\n  /**\n  @param {QuantifierNode} node\n  */\n  Quantifier(node, _, gen) {\n    return gen(node.body) + getQuantifierStr(node);\n  },\n\n  /**\n  @param {SubroutineNode \u0026 {isRecursive: true}} node\n  */\n  Subroutine({isRecursive, ref}, state) {\n    if (!isRecursive) {\n      throw new Error('Unexpected non-recursive subroutine in transformed AST');\n    }\n    const limit = state.recursionLimit;\n    // Using the syntax supported by `regex-recursion`\n    return ref === 0 ? `(?R=${limit})` : r`\\g\u003c${ref}\u0026R=${limit}\u003e`;\n  },\n};\n\n// ---------------\n// --- Helpers ---\n// ---------------\n\nconst BaseEscapeChars = new Set([\n  '$', '(', ')', '*', '+', '.', '?', '[', '\\\\', ']', '^', '{', '|', '}',\n]);\n\nconst CharClassEscapeChars = new Set([\n  '-', '\\\\', ']', '^',\n  // Literal `[` doesn't require escaping with flag u, but this can help work around regex source\n  // linters and regex syntax processors that expect unescaped `[` to create a nested class\n  '[',\n]);\n\nconst CharClassEscapeCharsFlagV = new Set([\n  '(', ')', '-', '/', '[', '\\\\', ']', '^', '{', '|', '}',\n  // Double punctuators; also includes already-listed `-` and `^`\n  '!', '#', '$', '%', '\u0026', '*', '+', ',', '.', ':', ';', '\u003c', '=', '\u003e', '?', '@', '`', '~',\n]);\n\nconst CharCodeEscapeMap = new Map([\n  [ 9, r`\\t`], // horizontal tab\n  [10, r`\\n`], // line feed\n  [11, r`\\v`], // vertical tab\n  [12, r`\\f`], // form feed\n  [13, r`\\r`], // carriage return\n  [0x2028, r`\\u2028`], // line separator\n  [0x2029, r`\\u2029`], // paragraph separator\n  [0xFEFF, r`\\uFEFF`], // ZWNBSP/BOM\n]);\n\nconst casedRe = /^\\p{Cased}$/u;\nfunction charHasCase(char) {\n  return casedRe.test(char);\n}\n\n/**\nGiven a `CharacterClassRange` node, returns an array of chars that are a case variant of a char in\nthe range, and aren't already in the range.\n*/\nfunction getCasesOutsideCharClassRange(node, options) {\n  const firstOnly = !!options?.firstOnly;\n  const min = node.min.value;\n  const max = node.max.value;\n  const found = [];\n  // Avoid unneeded work. Assumptions (per Unicode 16):\n  // - No case variants cross the Basic Multilingual Plane boundary\n  // - No cased chars appear beyond the Supplementary Multilingual Plane\n  if ((min \u003c 65 \u0026\u0026 (max === 0xFFFF || max \u003e= 0x1FFFF)) || (min === 0x10000 \u0026\u0026 max \u003e= 0x1FFFF)) {\n    return found;\n  }\n  for (let i = min; i \u003c= max; i++) {\n    const char = cp(i);\n    if (!charHasCase(char)) {\n      continue;\n    }\n    const charsOutsideRange = getIgnoreCaseMatchChars(char).filter(caseOfChar =\u003e {\n      const num = caseOfChar.codePointAt(0);\n      return num \u003c min || num \u003e max;\n    });\n    if (charsOutsideRange.length) {\n      found.push(...charsOutsideRange);\n      if (firstOnly) {\n        break;\n      }\n    }\n  }\n  return found;\n}\n\n// This shouldn't modifiy any char that has case\nfunction getCharEscape(codePoint, {escDigit, inCharClass, useFlagV}) {\n  if (CharCodeEscapeMap.has(codePoint)) {\n    return CharCodeEscapeMap.get(codePoint);\n  }\n  if (\n    // Control chars, etc.; condition modeled on the Chrome developer console's display for strings\n    codePoint \u003c 32 || (codePoint \u003e 126 \u0026\u0026 codePoint \u003c 160) ||\n    // Unicode planes 4-16; unassigned, special purpose, and private use area\n    codePoint \u003e 0x3FFFF ||\n    // Avoid corrupting a preceding backref by immediately following it with a literal digit\n    (escDigit \u0026\u0026 isDigitCharCode(codePoint))\n  ) {\n    // Don't convert codePoint `0` to `\\0` since that's corruptible by following literal digits\n    // Note: Not using raw strings to work around Bun ≤ 1.1.34 issue \u003cgithub.com/oven-sh/bun/issues/7540\u003e\n    return codePoint \u003e 0xFF ?\n      `\\\\u{${codePoint.toString(16).toUpperCase()}}` :\n      `\\\\x${codePoint.toString(16).toUpperCase().padStart(2, '0')}`;\n  }\n  const escapeChars = inCharClass ?\n    (useFlagV ? CharClassEscapeCharsFlagV : CharClassEscapeChars) :\n    BaseEscapeChars;\n  const char = cp(codePoint);\n  return (escapeChars.has(char) ? '\\\\' : '') + char;\n}\n\nfunction getCodePointRangesFromChars(chars) {\n  const codePoints = chars.map(char =\u003e char.codePointAt(0)).sort((a, b) =\u003e a - b);\n  const values = [];\n  let start = null;\n  for (let i = 0; i \u003c codePoints.length; i++) {\n    if (codePoints[i + 1] === codePoints[i] + 1) {\n      start ??= codePoints[i];\n    } else if (start === null) {\n      values.push(codePoints[i]);\n    } else {\n      values.push([start, codePoints[i]]);\n      start = null;\n    }\n  }\n  return values;\n}\n\nfunction getGroupPrefix(atomic, flagMods, useFlagMods) {\n  if (atomic) {\n    return '\u003e';\n  }\n  let mods = '';\n  if (flagMods \u0026\u0026 useFlagMods) {\n    const {enable, disable} = flagMods;\n    mods =\n      (enable?.ignoreCase ? 'i' : '') +\n      (enable?.dotAll ? 's' : '') +\n      (disable ? '-' : '') +\n      (disable?.ignoreCase ? 'i' : '') +\n      (disable?.dotAll ? 's' : '');\n  }\n  return `${mods}:`;\n}\n\n/**\n@param {QuantifierNode} node\n@returns {string}\n*/\nfunction getQuantifierStr({kind, max, min}) {\n  let base;\n  if (!min \u0026\u0026 max === 1) {\n    base = '?';\n  } else if (!min \u0026\u0026 max === Infinity) {\n    base = '*';\n  } else if (min === 1 \u0026\u0026 max === Infinity) {\n    base = '+';\n  } else if (min === max) {\n    base = `{${min}}`;\n  } else {\n    base = `{${min},${max === Infinity ? '' : max}}`;\n  }\n  return base + {\n    greedy: '',\n    lazy: '?',\n    possessive: '+',\n  }[kind];\n}\n\n/**\n@param {Node} node\n@returns {boolean}\n*/\nfunction isAnyGroup({type}) {\n  return type === 'CapturingGroup' ||\n    type === 'Group' ||\n    type === 'LookaroundAssertion';\n}\n\nfunction isDigitCharCode(value) {\n  return value \u003e 47 \u0026\u0026 value \u003c 58;\n}\n\n/**\n@param {Node} node\n@returns {boolean}\n*/\nfunction isLiteralHyphen({type, value}) {\n  return type === 'Character' \u0026\u0026 value === 45;\n}\n\nexport {\n  generate,\n};\n","import {getOrInsert} from './utils.js';\n\n/**\n@typedef {{\n  hiddenCaptures?: Array\u003cnumber\u003e;\n  lazyCompile?: boolean;\n  strategy?: string | null;\n  transfers?: Array\u003c[number, Array\u003cnumber\u003e]\u003e;\n}} EmulatedRegExpOptions\n*/\n\n/**\nWorks the same as JavaScript's native `RegExp` constructor in all contexts, but can be given\nresults from `toRegExpDetails` to produce the same result as `toRegExp`.\n*/\nclass EmulatedRegExp extends RegExp {\n  /**\n  @type {Map\u003cnumber, {\n    hidden?: true;\n    transferTo?: number;\n  }\u003e}\n  */\n  #captureMap = new Map();\n\n  /**\n  @type {RegExp | EmulatedRegExp | null}\n  */\n  #compiled = null;\n\n  /**\n  @type {string}\n  */\n  #pattern;\n\n  /**\n  @type {Map\u003cnumber, string\u003e?}\n  */\n  #nameMap = null;\n\n  /**\n  @type {string?}\n  */\n  #strategy = null;\n\n  /**\n  Can be used to serialize the instance.\n  @type {EmulatedRegExpOptions}\n  */\n  rawOptions = {};\n\n  // Override the getter with one that works with lazy-compiled regexes\n  get source() {\n    return this.#pattern || '(?:)';\n  }\n\n  /**\n  @overload\n  @param {string} pattern\n  @param {string} [flags]\n  @param {EmulatedRegExpOptions} [options]\n  */\n  /**\n  @overload\n  @param {EmulatedRegExp} pattern\n  @param {string} [flags]\n  */\n  constructor(pattern, flags, options) {\n    const lazyCompile = !!options?.lazyCompile;\n    if (pattern instanceof RegExp) {\n      // Argument `options` isn't provided when regexes are copied, including as part of the\n      // internal handling of string methods `matchAll` and `split`\n      if (options) {\n        throw new Error('Cannot provide options when copying a regexp');\n      }\n      const re = pattern; // Alias for readability\n      super(re, flags);\n      this.#pattern = re.source;\n      if (re instanceof EmulatedRegExp) {\n        this.#captureMap = re.#captureMap;\n        this.#nameMap = re.#nameMap;\n        this.#strategy = re.#strategy;\n        this.rawOptions = re.rawOptions;\n      }\n    } else {\n      const opts = {\n        hiddenCaptures: [],\n        strategy: null,\n        transfers: [],\n        ...options,\n      };\n      super(lazyCompile ? '' : pattern, flags);\n      this.#pattern = pattern;\n      this.#captureMap = createCaptureMap(opts.hiddenCaptures, opts.transfers);\n      this.#strategy = opts.strategy;\n      // Don't add default values from `opts` since this gets serialized\n      this.rawOptions = options ?? {};\n    }\n    if (!lazyCompile) {\n      this.#compiled = this;\n    }\n  }\n\n  /**\n  Called internally by all String/RegExp methods that use regexes.\n  @override\n  @param {string} str\n  @returns {RegExpExecArray?}\n  */\n  exec(str) {\n    // Lazy compilation\n    if (!this.#compiled) {\n      const {lazyCompile, ...rest} = this.rawOptions;\n      this.#compiled = new EmulatedRegExp(this.#pattern, this.flags, rest);\n    }\n\n    const useLastIndex = this.global || this.sticky;\n    const pos = this.lastIndex;\n\n    if (this.#strategy === 'clip_search' \u0026\u0026 useLastIndex \u0026\u0026 pos) {\n      // Reset since this tests on a sliced string that we want to match at the start of\n      this.lastIndex = 0;\n      // Slicing the string can lead to mismatches when three edge cases are stacked on each other:\n      // 1. An uncommon use of `\\G` that relies on `clip_search`, combined with...\n      // 2. Lookbehind that searches behind the search start (not match start) position...\n      // 3. During a search when the regex's `lastIndex` isn't `0`.\n      // The `clip_search` strategy is therefore only allowed when lookbehind isn't present, if\n      // using strict `accuracy`\n      const match = this.#execCore(str.slice(pos));\n      if (match) {\n        adjustMatchDetailsForOffset(match, pos, str, this.hasIndices);\n        this.lastIndex += pos;\n      }\n      return match;\n    }\n\n    return this.#execCore(str);\n  }\n\n  /**\n  Adds support for hidden and transfer captures.\n  @param {string} str\n  @returns\n  */\n  #execCore(str) {\n    // Support lazy compilation\n    this.#compiled.lastIndex = this.lastIndex;\n    const match = super.exec.call(this.#compiled, str);\n    this.lastIndex = this.#compiled.lastIndex;\n\n    if (!match || !this.#captureMap.size) {\n      return match;\n    }\n\n    const matchCopy = [...match];\n    // Empty all but the first value of the array while preserving its other properties\n    match.length = 1;\n    let indicesCopy;\n    if (this.hasIndices) {\n      indicesCopy = [...match.indices];\n      match.indices.length = 1;\n    }\n    const mappedNums = [0];\n    for (let i = 1; i \u003c matchCopy.length; i++) {\n      const {hidden, transferTo} = this.#captureMap.get(i) ?? {};\n      if (hidden) {\n        mappedNums.push(null);\n      } else {\n        mappedNums.push(match.length);\n        match.push(matchCopy[i]);\n        if (this.hasIndices) {\n          match.indices.push(indicesCopy[i]);\n        }\n      }\n\n      // Only transfer if the capture participated in the match\n      if (transferTo \u0026\u0026 matchCopy[i] !== undefined) {\n        const to = mappedNums[transferTo];\n        if (!to) {\n          throw new Error(`Invalid capture transfer to \"${to}\"`);\n        }\n        match[to] = matchCopy[i];\n        if (this.hasIndices) {\n          match.indices[to] = indicesCopy[i];\n        }\n        if (match.groups) {\n          if (!this.#nameMap) {\n            // Generate and cache the first time it's needed\n            this.#nameMap = createNameMap(this.source);\n          }\n          const name = this.#nameMap.get(transferTo);\n          if (name) {\n            match.groups[name] = matchCopy[i];\n            if (this.hasIndices) {\n              match.indices.groups[name] = indicesCopy[i];\n            }\n          }\n        }\n      }\n    }\n\n    return match;\n  }\n}\n\nfunction adjustMatchDetailsForOffset(match, offset, input, hasIndices) {\n  match.index += offset;\n  match.input = input;\n  if (hasIndices) {\n    const indices = match.indices;\n    for (let i = 0; i \u003c indices.length; i++) {\n      const arr = indices[i];\n      if (arr) {\n        // Replace the array rather than updating values since the keys of `match.indices` and\n        // `match.indices.groups` share their value arrays by reference. Need to be precise in case\n        // they were previously altered separately\n        indices[i] = [arr[0] + offset, arr[1] + offset];\n      }\n    }\n    const groupIndices = indices.groups;\n    if (groupIndices) {\n      Object.keys(groupIndices).forEach(key =\u003e {\n        const arr = groupIndices[key];\n        if (arr) {\n          groupIndices[key] = [arr[0] + offset, arr[1] + offset];\n        }\n      });\n    }\n  }\n}\n\n/**\nBuild the capturing group map, with hidden/transfer groups marked to indicate their submatches\nshould get special handling in match results.\n@param {Array\u003cnumber\u003e} hiddenCaptures\n@param {Array\u003c[number, Array\u003cnumber\u003e]\u003e} transfers\n@returns {Map\u003cnumber, {\n  hidden?: true;\n  transferTo?: number;\n}\u003e}\n*/\nfunction createCaptureMap(hiddenCaptures, transfers) {\n  const captureMap = new Map();\n  for (const num of hiddenCaptures) {\n    captureMap.set(num, {\n      hidden: true,\n    });\n  }\n  for (const [to, from] of transfers) {\n    for (const num of from) {\n      getOrInsert(captureMap, num, {}).transferTo = to;\n    }\n  }\n  return captureMap;\n}\n\n/**\n@param {string} pattern\n@returns {Map\u003cnumber, string\u003e}\n*/\nfunction createNameMap(pattern) {\n  const re = /(?\u003ccapture\u003e\\((?:\\?\u003c(?![=!])(?\u003cname\u003e[^\u003e]+)\u003e|(?!\\?)))|\\\\?./gsu;\n  const map = new Map();\n  let numCharClassesOpen = 0;\n  let numCaptures = 0;\n  let match;\n  while ((match = re.exec(pattern))) {\n    const {0: m, groups: {capture, name}} = match;\n    // Relies on no unescaped literal `[` in char classes (valid in JS if not using flag v), but\n    // this library's generator never produces unescaped literal `[` even with `target` ES2018 (see\n    // `CharClassEscapeChars`)\n    if (m === '[') {\n      numCharClassesOpen++;\n    } else if (!numCharClassesOpen) {\n      if (capture) {\n        numCaptures++;\n        if (name) {\n          map.set(numCaptures, name);\n        }\n      }\n    } else if (m === ']') {\n      numCharClassesOpen--;\n    }\n  }\n  return map;\n}\n\nexport {\n  EmulatedRegExp,\n};\n","import {transform} from './transform.js';\nimport {generate} from './generate.js';\nimport {Accuracy, getOptions, Target} from './options.js';\nimport {EmulatedRegExp} from './subclass.js';\nimport {JsUnicodePropertyMap} from './unicode.js';\nimport {parse} from 'oniguruma-parser/parser';\nimport {atomic, possessive} from 'regex/internals';\nimport {recursion} from 'regex-recursion';\n/**\n@import {EmulatedRegExpOptions} from './subclass.js';\n*/\n\n// The validation and transformation for Oniguruma's unique syntax and behavior differences\n// compared to native JS RegExp is layered into all steps of the compilation process:\n// 1. Parser: Uses `oniguruma-parser` to build an Oniguruma AST, which accounts for many\n//    differences between Oniguruma and JS.\n// 2. Transformer: Converts the Oniguruma AST to a Regex+ AST that preserves all Oniguruma\n//    behavior. This is true even in cases of non-native-JS features that are supported by both\n//    Regex+ and Oniguruma but with subtly different behavior in each (subroutines, flag x).\n// 3. Generator: Converts the Regex+ AST to a Regex+ pattern, flags, and options.\n// 4. Postprocessing: Regex+ internals and plugins are used to transpile several remaining features\n//    (atomic groups, possessive quantifiers, recursion). Regex+ uses a strict superset of JS\n//    RegExp syntax, so using it allows this library to benefit from not reinventing the wheel for\n//    complex features that Regex+ already knows how to transpile to JS.\n\n/**\n@typedef {{\n  accuracy?: keyof Accuracy;\n  avoidSubclass?: boolean;\n  flags?: string;\n  global?: boolean;\n  hasIndices?: boolean;\n  lazyCompileLength?: number;\n  rules?: {\n    allowOrphanBackrefs?: boolean;\n    asciiWordBoundaries?: boolean;\n    captureGroup?: boolean;\n    recursionLimit?: number;\n    singleline?: boolean;\n  };\n  target?: keyof Target;\n  verbose?: boolean;\n}} ToRegExpOptions\n*/\n\n/**\nAccepts an Oniguruma pattern and returns an equivalent JavaScript `RegExp`.\n@param {string} pattern Oniguruma regex pattern.\n@param {ToRegExpOptions} [options]\n@returns {RegExp | EmulatedRegExp}\n*/\nfunction toRegExp(pattern, options) {\n  const d = toRegExpDetails(pattern, options);\n  if (d.options) {\n    return new EmulatedRegExp(d.pattern, d.flags, d.options);\n  }\n  return new RegExp(d.pattern, d.flags);\n}\n\n/**\nAccepts an Oniguruma pattern and returns the details for an equivalent JavaScript `RegExp`.\n@param {string} pattern Oniguruma regex pattern.\n@param {ToRegExpOptions} [options]\n@returns {{\n  pattern: string;\n  flags: string;\n  options?: EmulatedRegExpOptions;\n}}\n*/\nfunction toRegExpDetails(pattern, options) {\n  const opts = getOptions(options);\n  const onigurumaAst = parse(pattern, {\n    flags: opts.flags,\n    normalizeUnknownPropertyNames: true,\n    rules: {\n      captureGroup: opts.rules.captureGroup,\n      singleline: opts.rules.singleline,\n    },\n    skipBackrefValidation: opts.rules.allowOrphanBackrefs,\n    unicodePropertyMap: JsUnicodePropertyMap,\n  });\n  const regexPlusAst = transform(onigurumaAst, {\n    accuracy: opts.accuracy,\n    asciiWordBoundaries: opts.rules.asciiWordBoundaries,\n    avoidSubclass: opts.avoidSubclass,\n    bestEffortTarget: opts.target,\n  });\n  const generated = generate(regexPlusAst, opts);\n  const recursionResult = recursion(generated.pattern, {\n    captureTransfers: generated._captureTransfers,\n    hiddenCaptures: generated._hiddenCaptures,\n    mode: 'external',\n  });\n  const possessiveResult = possessive(recursionResult.pattern);\n  const atomicResult = atomic(possessiveResult.pattern, {\n    captureTransfers: recursionResult.captureTransfers,\n    hiddenCaptures: recursionResult.hiddenCaptures,\n  });\n  const details = {\n    pattern: atomicResult.pattern,\n    flags: `${opts.hasIndices ? 'd' : ''}${opts.global ? 'g' : ''}${generated.flags}${generated.options.disable.v ? 'u' : 'v'}`,\n  };\n  if (opts.avoidSubclass) {\n    if (opts.lazyCompileLength !== Infinity) {\n      throw new Error('Lazy compilation requires subclass');\n    }\n  } else {\n    // Sort isn't required; only for readability when serialized\n    const hiddenCaptures = atomicResult.hiddenCaptures.sort((a, b) =\u003e a - b);\n    // Change the map to the `EmulatedRegExp` format, serializable as JSON\n    const transfers = Array.from(atomicResult.captureTransfers);\n    const strategy = regexPlusAst._strategy;\n    const lazyCompile = details.pattern.length \u003e= opts.lazyCompileLength;\n    if (hiddenCaptures.length || transfers.length || strategy || lazyCompile) {\n      details.options = {\n        ...(hiddenCaptures.length \u0026\u0026 {hiddenCaptures}),\n        ...(transfers.length \u0026\u0026 {transfers}),\n        ...(strategy \u0026\u0026 {strategy}),\n        ...(lazyCompile \u0026\u0026 {lazyCompile}),\n      };\n    }\n  }\n  return details;\n}\n\n// function toOnigurumaAst(pattern, options) {\n//   return parse(pattern, {\n//     flags: options?.flags ?? '',\n//     normalizeUnknownPropertyNames: true,\n//     rules: options?.rules ?? {},\n//     unicodePropertyMap: JsUnicodePropertyMap,\n//   });\n// }\n\n// function toRegexPlusAst(pattern, options) {\n//   return transform(toOnigurumaAst(pattern, options));\n// }\n\nexport {\n  EmulatedRegExp,\n  toRegExp,\n  toRegExpDetails,\n  // toOnigurumaAst,\n  // toRegexPlusAst,\n};\n"],"version":3}
