var e,n,t,r,o,a,s,i,u=Object.defineProperty,l=Object.defineProperties,c=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,h=Reflect.get,w=(e,n,t)=>n in e?u(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,y=(e,n)=>{for(var t in n||(n={}))f.call(n,t)&&w(e,t,n[t]);if(p)for(var t of p(n))g.call(n,t)&&w(e,t,n[t]);return e},m=(e,n)=>l(e,c(n)),b=(e,n,t)=>(w(e,"symbol"!=typeof n?n+"":n,t),t),C=(e,n,t)=>{if(!n.has(e))throw TypeError("Cannot "+t)},x=(e,n,t)=>(C(e,n,"read from private field"),t?t.call(e):n.get(e)),k=(e,n,t)=>{if(n.has(e))throw TypeError("Cannot add the same private member more than once");n instanceof WeakSet?n.add(e):n.set(e,t)},E=(e,n,t,r)=>(C(e,n,"write to private field"),r?r.call(e,t):n.set(e,t),t),v=(e,n,t)=>(C(e,n,"access private method"),t);const $=4294967295;var A=class{constructor(e,n={}){b(this,"patterns"),b(this,"options"),b(this,"regexps"),this.patterns=e,this.options=n;const{forgiving:t=!1,cache:r,regexConstructor:o}=n;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if("string"!=typeof e)return e;const n=null==r?void 0:r.get(e);if(n){if(n instanceof RegExp)return n;if(t)return null;throw n}try{const n=o(e);return null==r||r.set(e,n),n}catch(a){if(null==r||r.set(e,a),t)return null;throw a}})}findNextMatchSync(e,n,t){const r="string"==typeof e?e:e.content,o=[];function a(e,n,t=0){return{index:e,captureIndices:n.indices.map(e=>null==e?{start:$,end:$,length:0}:{start:e[0]+t,end:e[1]+t,length:e[1]-e[0]})}}for(let i=0;i<this.regexps.length;i++){const e=this.regexps[i];if(e)try{e.lastIndex=n;const t=e.exec(r);if(!t)continue;if(t.index===n)return a(i,t,0);o.push([i,t,0])}catch(s){if(this.options.forgiving)continue;throw s}}if(o.length){const e=Math.min(...o.map(e=>e[1].index));for(const[n,t,r]of o)if(t.index===e)return a(n,t,r)}return null}};function I(e){if(1!==[...e].length)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}const S=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),_=String.raw;function M(e,n){if(null==e)throw new Error(null!=n?n:"Value expected");return e}const N=_`\[\^?`,L=`c.? | C(?:-.?)?|${_`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${_`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${_`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${_`o\{[^\}]*\}?`}|${_`\d{1,3}`}`,R=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,P=new RegExp(_`
  \\ (?:
    ${L}
    | [gk]<[^>]*>?
    | [gk]'[^']*'?
    | .
  )
  | \( (?:
    \? (?:
      [:=!>({]
      | <[=!]
      | <[^>]*>
      | '[^']*'
      | ~\|?
      | #(?:[^)\\]|\\.?)*
      | [^:)]*[:)]
    )?
    | \*[^\)]*\)?
  )?
  | (?:${R.source})+
  | ${N}
  | .
`.replace(/\s+/g,""),"gsu"),F=new RegExp(_`
  \\ (?:
    ${L}
    | .
  )
  | \[:(?:\^?\p{Alpha}+|\^):\]
  | ${N}
  | &&
  | .
`.replace(/\s+/g,""),"gsu");function U(e,n={}){const t=m(y({flags:""},n),{rules:y({captureGroup:!1,singleline:!1},n.rules)});if("string"!=typeof e)throw new Error("String expected as pattern");const r=function(e){const n={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let t=0;t<e.length;t++){const r=e[t];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if("y"!==r)n[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0;else{if(!/^y{[gw]}/.test(e.slice(t)))throw new Error('Invalid or unspecified flag "y" mode');n.textSegmentMode="g"===e[t+2]?"grapheme":"word",t+=3}}return n}(t.flags),o=[r.extended],a={captureGroup:t.rules.captureGroup,getCurrentModX:()=>o.at(-1),numOpenGroups:0,popModX(){o.pop()},pushModX(e){o.push(e)},replaceCurrentModX(e){o[o.length-1]=e},singleline:t.rules.singleline};let s,i=[];for(P.lastIndex=0;s=P.exec(e);){const n=O(a,e,s[0],P.lastIndex);n.tokens?i.push(...n.tokens):n.token&&i.push(n.token),void 0!==n.lastIndex&&(P.lastIndex=n.lastIndex)}const u=[];let l=0;i.filter(e=>"GroupOpen"===e.type).forEach(e=>{"capturing"===e.kind?e.number=++l:"("===e.raw&&u.push(e)}),l||u.forEach((e,n)=>{e.kind="capturing",e.number=n+1});const c=l||u.length;return{tokens:i.map(e=>"EscapedNumber"===e.type?function(e,n){const{raw:t,inCharClass:r}=e,o=t.slice(1);if(!r&&("0"!==o&&1===o.length||"0"!==o[0]&&+o<=n))return[W(t)];const a=[],s=o.match(/^[0-7]+|\d/g);for(let i=0;i<s.length;i++){const e=s[i];let n;if(0===i&&"8"!==e&&"9"!==e){if(n=parseInt(e,8),n>127)throw new Error(_`Octal encoded byte above 177 unsupported "${t}"`)}else n=I(e);a.push(z(n,(0===i?"\\":"")+e))}return a}(e,c):e).flat(),flags:r}}function O(e,n,t,r){const[o,a]=t;if("["===t||"[^"===t){const e=function(e,n,t){const r=[V("^"===n[1],n)];let o,a=1;for(F.lastIndex=t;o=F.exec(e);){const e=o[0];if("["===e[0]&&":"!==e[1])a++,r.push(V("^"===e[1],e));else if("]"===e){if("CharacterClassOpen"===r.at(-1).type)r.push(z(93,e));else if(a--,r.push(j(e)),!a)break}else{const n=B(e);Array.isArray(n)?r.push(...n):r.push(n)}}return{tokens:r,lastIndex:F.lastIndex||e.length}}(n,t,r);return{tokens:e.tokens,lastIndex:e.lastIndex}}if("\\"===o){if("AbBGyYzZ".includes(a))return{token:T(t,t)};if(/^\\g[<']/.test(t)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return{token:Q(t)}}if(/^\\k[<']/.test(t)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(t))throw new Error(`Invalid group name "${t}"`);return{token:W(t)}}if("K"===a)return{token:X("keep",t)};if("N"===a||"R"===a)return{token:H("newline",t,{negate:"N"===a})};if("O"===a)return{token:H("any",t)};if("X"===a)return{token:H("text_segment",t)};const e=G(t,{inCharClass:!1});return Array.isArray(e)?{tokens:e}:{token:e}}if("("===o){if("*"===a)return{token:ee(t)};if("(?{"===t)throw new Error(`Unsupported callout "${t}"`);if(t.startsWith("(?#")){if(")"!==n[r])throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(t))return{token:Y(t,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,"("===t&&!e.captureGroup||"(?:"===t)return{token:q("group",t)};if("(?>"===t)return{token:q("atomic",t)};if("(?="===t||"(?!"===t||"(?<="===t||"(?<!"===t)return{token:q("<"===t[2]?"lookbehind":"lookahead",t,{negate:t.endsWith("!")})};if("("===t&&e.captureGroup||t.startsWith("(?<")&&t.endsWith(">")||t.startsWith("(?'")&&t.endsWith("'"))return{token:q("capturing",t,y({},"("!==t&&{name:t.slice(3,-1)}))};if(t.startsWith("(?~")){if("(?~|"===t)throw new Error(`Unsupported absence function kind "${t}"`);return{token:q("absence_repeater",t)}}throw"(?("===t?new Error(`Unsupported conditional "${t}"`):new Error(`Invalid or unsupported group option "${t}"`)}if(")"===t){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Z(t)}}if(e.getCurrentModX()){if("#"===t){const e=n.indexOf("\n",r);return{lastIndex:-1===e?n.length:e}}if(/^\s$/.test(t)){const e=/\s+/y;return e.lastIndex=r,{lastIndex:e.exec(n)?e.lastIndex:r}}}if("."===t)return{token:H("dot",t)};if("^"===t||"$"===t){return{token:T(e.singleline?{"^":_`\A`,$:_`\Z`}[t]:t,t)}}return"|"===t?{token:D(t)}:R.test(t)?{tokens:re(t)}:{token:z(I(t),t)}}function B(e){if("\\"===e[0])return G(e,{inCharClass:!0});if("["===e[0]){const n=new RegExp("\\[:(?<negate>\\^?)(?<name>[a-z]+):\\]").exec(e);if(!n||!S.has(n.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return H("posix",e,{value:n.groups.name,negate:!!n.groups.negate})}return"-"===e?function(e){return{type:"CharacterClassHyphen",raw:e}}(e):"&&"===e?function(e){return{type:"CharacterClassIntersector",raw:e}}(e):z(I(e),e)}function G(e,{inCharClass:n}){const t=e[1];if("c"===t||"C"===t)return function(e){const n="c"===e[1]?e[2]:e[3];if(!n||!/[A-Za-z]/.test(n))throw new Error(`Unsupported control character "${e}"`);return z(I(n.toUpperCase())-64,e)}(e);if("dDhHsSwW".includes(t))return function(e){const n=e[1].toLowerCase();return H({d:"digit",h:"hex",s:"space",w:"word"}[n],e,{negate:e[1]!==n})}(e);if(e.startsWith(_`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(3===e.length)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return function(e){const{p:n,neg:t,value:r}=new RegExp("^\\\\(?<p>[pP])\\{(?<neg>\\^?)(?<value>[^}]+)").exec(e).groups;return H("property",e,{value:r,negate:"P"===n&&!t||"p"===n&&!!t})}(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const n=e.split(/\\x/).slice(1).map(e=>parseInt(e,16)),t=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(n)),r=new TextEncoder;return[...t].map(e=>{const n=[...r.encode(e)].map(e=>`\\x${e.toString(16)}`).join("");return z(I(e),n)})}catch(r){throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if("u"===t||"x"===t)return z(function(e){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(e))throw new Error(`Incomplete or invalid escape "${e}"`);const n="{"===e[2]?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(n,16)}(e),e);if(J.has(t))return z(J.get(t),e);if(/\d/.test(t))return function(e,n){return{type:"EscapedNumber",inCharClass:e,raw:n}}(n,e);if("\\"===e)throw new Error(_`Incomplete escape "\"`);if("M"===t)throw new Error(`Unsupported meta "${e}"`);if(2===[...e].length)return z(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function D(e){return{type:"Alternator",raw:e}}function T(e,n){return{type:"Assertion",kind:e,raw:n}}function W(e){return{type:"Backreference",raw:e}}function z(e,n){return{type:"Character",value:e,raw:n}}function j(e){return{type:"CharacterClassClose",raw:e}}function V(e,n){return{type:"CharacterClassOpen",negate:e,raw:n}}function H(e,n,t={}){return m(y({type:"CharacterSet",kind:e},t),{raw:n})}function X(e,n,t={}){return"keep"===e?{type:"Directive",kind:e,raw:n}:{type:"Directive",kind:e,flags:M(t.flags),raw:n}}function Z(e){return{type:"GroupClose",raw:e}}function q(e,n,t={}){return m(y({type:"GroupOpen",kind:e},t),{raw:n})}function Q(e){return{type:"Subroutine",raw:e}}const K=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),J=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Y(e,n){let{on:t,off:r}=new RegExp("^\\(\\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?").exec(e).groups;null!=r||(r="");const o=(n.getCurrentModX()||t.includes("x"))&&!r.includes("x"),a=te(t),s=te(r),i={};if(a&&(i.enable=a),s&&(i.disable=s),e.endsWith(")"))return n.replaceCurrentModX(o),X("flags",e,{flags:i});if(e.endsWith(":"))return n.pushModX(o),n.numOpenGroups++,q("group",e,y({},(a||s)&&{flags:i}));throw new Error(`Unexpected flag modifier "${e}"`)}function ee(e){var n;const t=new RegExp("\\(\\*(?<name>[A-Za-z_]\\w*)?(?:\\[(?<tag>(?:[A-Za-z_]\\w*)?)\\])?(?:\\{(?<args>[^}]*)\\})?\\)").exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:r,tag:o,args:a}=t.groups;if(!r)throw new Error(`Invalid named callout "${e}"`);if(""===o)throw new Error(`Named callout tag with empty value not allowed "${e}"`);const s=a?a.split(",").filter(e=>""!==e).map(e=>/^[+-]?\d+$/.test(e)?+e:e):[],[i,u,l]=s,c=K.has(r)?r.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(s.length>0)throw new Error(`Named callout arguments not allowed "${s}"`);break;case"error":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if("string"==typeof i)throw new Error(`Named callout argument must be a number "${i}"`);break;case"max":if(!s.length||s.length>2)throw new Error(`Named callout must have one or two arguments "${s}"`);if("string"==typeof i&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(2===s.length&&("number"==typeof u||!/^[<>X]$/.test(u)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${u}"`);break;case"count":case"total_count":if(s.length>1)throw new Error(`Named callout allows only one argument "${s}"`);if(1===s.length&&("number"==typeof i||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${i}"`);break;case"cmp":if(3!==s.length)throw new Error(`Named callout must have three arguments "${s}"`);if("string"==typeof i&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if("number"==typeof u||!/^(?:[<>!=]=|[<>])$/.test(u))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${u}"`);if("string"==typeof l&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${r}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return function(e,n,t,r){return{type:"NamedCallout",kind:e,tag:n,arguments:t,raw:r}}(c,null!=o?o:null,null!=(n=null==a?void 0:a.split(","))?n:null,e)}function ne(e){let n,t,r=null;if("{"===e[0]){const{minStr:o,maxStr:a}=new RegExp("^\\{(?<minStr>\\d*)(?:,(?<maxStr>\\d*))?").exec(e).groups,s=1e5;if(+o>s||a&&+a>s)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+o,t=void 0===a?+o:""===a?1/0:+a,n>t&&(r="possessive",[n,t]=[t,n]),e.endsWith("?")){if("possessive"===r)throw new Error('Unsupported possessive interval quantifier chain with "?"');r="lazy"}else r||(r="greedy")}else n="+"===e[0]?1:0,t="?"===e[0]?1:1/0,r="+"===e[1]?"possessive":"?"===e[1]?"lazy":"greedy";return function(e,n,t,r){return{type:"Quantifier",kind:e,min:n,max:t,raw:r}}(r,n,t,e)}function te(e){const n={};return e.includes("i")&&(n.ignoreCase=!0),e.includes("m")&&(n.dotAll=!0),e.includes("x")&&(n.extended=!0),Object.keys(n).length?n:null}function re(e){const n=[],t=new RegExp(R,"gy");let r;for(;r=t.exec(e);){const e=r[0];if("{"===e[0]){const r=new RegExp("^\\{(?<min>\\d+),(?<max>\\d+)\\}\\??$").exec(e);if(r){const{min:o,max:a}=r.groups;if(+o>+a&&e.endsWith("?")){t.lastIndex--,n.push(ne(e.slice(0,-1)));continue}}}n.push(ne(e))}return n}function oe(e,n){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(1!==e.body.length)return!1;const t=e.body[0];return!n||Object.keys(n).every(e=>n[e]===t[e])}const ae=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function se(e,n={}){const t=m(y({flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null},n),{rules:y({captureGroup:!1,singleline:!1},n.rules)}),r=U(e,{flags:t.flags,rules:{captureGroup:t.rules.captureGroup,singleline:t.rules.singleline}}),o=(e,n)=>{const t=r.tokens[a.nextIndex];switch(a.parent=e,a.nextIndex++,t.type){case"Alternator":return ie();case"Assertion":return function({kind:e}){return ue(M({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===_`\B`||e===_`\Y`})}(t);case"Backreference":return function({raw:e},n){const t=/^\\k[<']/.test(e),r=t?e.slice(3,-1):e.slice(1),o=(t,r=!1)=>{const o=n.capturingGroups.length;let a=!1;if(t>o){if(!n.skipBackrefValidation)throw new Error(`Not enough capturing groups defined to the left "${e}"`);a=!0}return n.hasNumberedRef=!0,le(r?o+1-t:t,{orphan:a})};if(t){const t=new RegExp("^(?<sign>-?)0*(?<num>[1-9]\\d*)$").exec(r);if(t)return o(+t.groups.num,!!t.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!n.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return le(r)}return o(+r)}(t,a);case"Character":return pe(t.value,{useLastValid:!!n.isCheckingRangeEnd});case"CharacterClassHyphen":return function(e,n,t){const{tokens:r,walk:o}=n,a=n.parent,s=a.body.at(-1),i=r[n.nextIndex];if(!t.isCheckingRangeEnd&&s&&"CharacterClass"!==s.type&&"CharacterClassRange"!==s.type&&i&&"CharacterClassOpen"!==i.type&&"CharacterClassClose"!==i.type&&"CharacterClassIntersector"!==i.type){const e=o(a,m(y({},t),{isCheckingRangeEnd:!0}));if("Character"===s.type&&"Character"===e.type)return a.body.pop(),function(e,n){if(n.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:n}}(s,e);throw new Error("Invalid character class range")}return pe(I("-"))}(0,a,n);case"CharacterClassOpen":return function({negate:e},n,t){const{tokens:r,walk:o}=n,a=[de()],s=r[n.nextIndex];let i=ve(s);for(;"CharacterClassClose"!==i.type;){if("CharacterClassIntersector"===i.type)a.push(de()),n.nextIndex++;else{const e=a.at(-1);e.body.push(o(e,t))}i=ve(r[n.nextIndex],s)}const u=de({negate:e});return 1===a.length?u.body=a[0].body:(u.kind="intersection",u.body=a.map(e=>1===e.body.length?e.body[0]:e)),n.nextIndex++,u}(t,a,n);case"CharacterSet":return function({kind:e,negate:n,value:t},r){const{normalizeUnknownPropertyNames:o,skipPropertyNameValidation:a,unicodePropertyMap:s}=r;if("property"===e){const r=Ee(t);if(!S.has(r)||(null==s?void 0:s.has(r)))return me(t,{negate:n,normalizeUnknownPropertyNames:o,skipPropertyNameValidation:a,unicodePropertyMap:s});e="posix",t=r}return"posix"===e?function(e,n){const t=!!(null==n?void 0:n.negate);if(!S.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:t}}(t,{negate:n}):fe(e,{negate:n})}(t,a);case"Directive":return function(e,n={}){if("keep"===e)return{type:"Directive",kind:e};if("flags"===e)return{type:"Directive",kind:e,flags:M(n.flags)};throw new Error(`Unexpected directive kind "${e}"`)}(t.kind,{flags:t.flags});case"GroupOpen":return function(e,n,t){const{tokens:r,capturingGroups:o,namedGroupsByName:a,skipLookbehindValidation:s,walk:i}=n,u=function({flags:e,kind:n,name:t,negate:r,number:o}){switch(n){case"absence_repeater":return function(e,n){if("repeater"!==e)throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:be(null==n?void 0:n.body)}}("repeater");case"atomic":return ge({atomic:!0});case"capturing":return ce(o,{name:t});case"group":return ge({flags:e});case"lookahead":case"lookbehind":return he({behind:"lookbehind"===n,negate:r});default:throw new Error(`Unexpected group kind "${n}"`)}}(e),l="AbsenceFunction"===u.type,c=ke(u),p=c&&u.negate;if("CapturingGroup"===u.type&&(o.push(u),u.name&&function(e,n,t){return e.has(n)||e.set(n,t),e.get(n)}(a,u.name,[]).push(u)),l&&t.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let d=$e(r[n.nextIndex]);for(;"GroupClose"!==d.type;){if("Alternator"===d.type)u.body.push(ie()),n.nextIndex++;else{const e=u.body.at(-1),n=i(e,m(y({},t),{isInAbsenceFunction:t.isInAbsenceFunction||l,isInLookbehind:t.isInLookbehind||c,isInNegLookbehind:t.isInNegLookbehind||p}));if(e.body.push(n),(c||t.isInLookbehind)&&!s){const e="Lookbehind includes a pattern not allowed by Oniguruma";if(p||t.isInNegLookbehind){if(xe(n)||"CapturingGroup"===n.type)throw new Error(e)}else if(xe(n)||ke(n)&&n.negate)throw new Error(e)}}d=$e(r[n.nextIndex])}return n.nextIndex++,u}(t,a,n);case"NamedCallout":return function(e,n,t){return{type:"NamedCallout",kind:e,tag:n,arguments:t}}(t.kind,t.tag,t.arguments);case"Quantifier":return function({kind:e,min:n,max:t},r){const o=r.parent,a=o.body.at(-1);if(!a||!function(e){return ae.has(e.type)}(a))throw new Error("Quantifier requires a repeatable token");const s=we(e,n,t,a);return o.body.pop(),s}(t,a);case"Subroutine":return function({raw:e},n){const{capturingGroups:t,subroutines:r}=n;let o=e.slice(3,-1);const a=new RegExp("^(?<sign>[-+]?)0*(?<num>[1-9]\\d*)$").exec(o);if(a){const e=+a.groups.num,r=t.length;if(n.hasNumberedRef=!0,o={"":e,"+":r+e,"-":r+1-e}[a.groups.sign],o<1)throw new Error("Invalid subroutine number")}else"0"===o&&(o=0);const s=ye(o);return r.push(s),s}(t,a);default:throw new Error(`Unexpected token type "${t.type}"`)}},a={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:t.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:t.skipBackrefValidation,skipLookbehindValidation:t.skipLookbehindValidation,skipPropertyNameValidation:t.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:t.unicodePropertyMap,walk:o},s=function(e,n){return{type:"Regex",body:be(null==n?void 0:n.body),flags:e}}(function(e){return y({type:"Flags"},e)}(r.flags));let i=s.body[0];for(;a.nextIndex<r.tokens.length;){const e=o(i,{});"Alternative"===e.type?(s.body.push(e),i=e):i.body.push(e)}const{capturingGroups:u,hasNumberedRef:l,namedGroupsByName:c,subroutines:p}=a;if(l&&c.size&&!t.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:d}of p)if("number"==typeof d){if(d>u.length)throw new Error("Subroutine uses a group number that's not defined");d&&(u[d-1].isSubroutined=!0)}else{if(!c.has(d))throw new Error(_`Subroutine uses a group name that's not defined "\g<${d}>"`);if(c.get(d).length>1)throw new Error(_`Subroutine uses a duplicate group name "\g<${d}>"`);c.get(d)[0].isSubroutined=!0}return s}function ie(e){return{type:"Alternative",body:Ce(null==e?void 0:e.body)}}function ue(e,n){const t={type:"Assertion",kind:e};return("word_boundary"===e||"text_segment_boundary"===e)&&(t.negate=!!(null==n?void 0:n.negate)),t}function le(e,n){const t=!!(null==n?void 0:n.orphan);return y({type:"Backreference",ref:e},t&&{orphan:t})}function ce(e,n){const t=y({name:void 0,isSubroutined:!1},n);if(void 0!==t.name&&!function(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}(t.name))throw new Error(`Group name "${t.name}" invalid in Oniguruma`);return m(y(y({type:"CapturingGroup",number:e},t.name&&{name:t.name}),t.isSubroutined&&{isSubroutined:t.isSubroutined}),{body:be(null==n?void 0:n.body)})}function pe(e,n){const t=y({useLastValid:!1},n);if(e>1114111){const n=e.toString(16);if(!t.useLastValid)throw e>1310719?new Error(`Invalid code point out of range "\\x{${n}}"`):new Error(`Invalid code point out of range in JS "\\x{${n}}"`);e=1114111}return{type:"Character",value:e}}function de(e){const n=y({kind:"union",negate:!1},e);return{type:"CharacterClass",kind:n.kind,negate:n.negate,body:Ce(null==e?void 0:e.body)}}function fe(e,n){const t=!!(null==n?void 0:n.negate),r={type:"CharacterSet",kind:e};return("digit"===e||"hex"===e||"newline"===e||"space"===e||"word"===e)&&(r.negate=t),("text_segment"===e||"newline"===e&&!t)&&(r.variableLength=!0),r}function ge(e){const n=null==e?void 0:e.atomic,t=null==e?void 0:e.flags;if(n&&t)throw new Error("Atomic group cannot have flags");return m(y(y({type:"Group"},n&&{atomic:n}),t&&{flags:t}),{body:be(null==e?void 0:e.body)})}function he(e){const n=y({behind:!1,negate:!1},e);return{type:"LookaroundAssertion",kind:n.behind?"lookbehind":"lookahead",negate:n.negate,body:be(null==e?void 0:e.body)}}function we(e,n,t,r){if(n>t)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:n,max:t,body:r}}function ye(e){return{type:"Subroutine",ref:e}}function me(e,n){var t;const r=y({negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null},n);let o=null==(t=r.unicodePropertyMap)?void 0:t.get(Ee(e));if(!o)if(r.normalizeUnknownPropertyNames)o=function(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}(e);else if(r.unicodePropertyMap&&!r.skipPropertyNameValidation)throw new Error(_`Invalid Unicode property "\p{${e}}"`);return{type:"CharacterSet",kind:"property",value:null!=o?o:e,negate:r.negate}}function be(e){if(void 0===e)e=[ie()];else if(!Array.isArray(e)||!e.length||!e.every(e=>"Alternative"===e.type))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function Ce(e){if(void 0===e)e=[];else if(!Array.isArray(e)||!e.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return e}function xe(e){return"LookaroundAssertion"===e.type&&"lookahead"===e.kind}function ke(e){return"LookaroundAssertion"===e.type&&"lookbehind"===e.kind}function Ee(e){return e.replace(/[- _]+/g,"").toLowerCase()}function ve(e,n){const t=n;return M(e,"Unclosed character class"+("Character"===(null==t?void 0:t.type)&&93===t.value&&"]"===t.raw?' (started with "]")':""))}function $e(e){return M(e,"Unclosed group")}function Ae(e,n,t=null){function r(e,n){for(let t=0;t<e.length;t++){const r=o(e[t],n,t,e);t=Math.max(-1,t+r)}}function o(a,s=null,i=null,u=null){var l,c;let p=0,d=!1;const f={node:a,parent:s,key:i,container:u,root:e,remove(){Ie(u).splice(Math.max(0,Se(i)+p),1),p--,d=!0},removeAllNextSiblings:()=>Ie(u).splice(Se(i)+1),removeAllPrevSiblings(){const e=Se(i)+p;return p-=e,Ie(u).splice(0,Math.max(0,e))},replaceWith(e,n={}){const t=!!n.traverse;u?u[Math.max(0,Se(i)+p)]=e:M(s,"Can't replace root node")[i]=e,t&&o(e,s,i,u),d=!0},replaceWithMultiple(e,n={}){const t=!!n.traverse;if(Ie(u).splice(Math.max(0,Se(i)+p),1,...e),p+=e.length-1,t){let n=0;for(let t=0;t<e.length;t++)n+=o(e[t],s,Se(i)+t+n,u)}d=!0},skip(){d=!0}},{type:g}=a,h=n["*"],w=n[g],y="function"==typeof h?h:null==h?void 0:h.enter,m="function"==typeof w?w:null==w?void 0:w.enter;if(null==y||y(f,t),null==m||m(f,t),!d)switch(g){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(a.body,a);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":o(a.min,a,"min"),o(a.max,a,"max");break;case"Quantifier":o(a.body,a,"body");break;case"Regex":r(a.body,a),o(a.flags,a,"flags");break;default:throw new Error(`Unexpected node type "${g}"`)}return null==(l=null==w?void 0:w.exit)||l.call(w,f,t),null==(c=null==h?void 0:h.exit)||c.call(h,f,t),p}return o(e),e}function Ie(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Se(e){if("number"!=typeof e)throw new Error("Numeric key expected");return e}const _e=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Me(e,n){for(let t=0;t<e.length;t++)e[t]>=n&&e[t]++}function Ne(e,n,t,r){return e.slice(0,n)+r+e.slice(n+t.length)}const Le=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Re(e,n,t,r){const o=new RegExp(String.raw`${n}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1];let s=0,i="";for(const u of e.matchAll(o)){const{0:e,groups:{$skip:n}}=u;n||r&&r===Le.DEFAULT!=!s?("["===e[0]?(s++,a.push("^"===e[1])):"]"===e&&s&&(s--,a.pop()),i+=e):i+=t instanceof Function?t(u,{context:s?Le.CHAR_CLASS:Le.DEFAULT,negated:a[a.length-1]}):t}return i}function Pe(e,n,t,r){Re(e,n,t,r)}function Fe(e,n,t){return!!function(e,n,t=0,r){if(!new RegExp(n,"su").test(e))return null;const o=new RegExp(`${n}|(?<$skip>\\\\?.)`,"gsu");o.lastIndex=t;let a,s=0;for(;a=o.exec(e);){const{0:e,groups:{$skip:n}}=a;if(!(n||r&&r===Le.DEFAULT!=!s))return a;"["===e?s++:"]"===e&&s&&s--,o.lastIndex==a.index&&o.lastIndex++}return null}(e,n,0,t)}function Ue(e,n){const t=new RegExp("\\\\?.","gsu");t.lastIndex=n;let r,o=e.length,a=0,s=1;for(;r=t.exec(e);){const[e]=r;if("["===e)a++;else if(a)"]"===e&&a--;else if("("===e)s++;else if(")"===e&&(s--,!s)){o=r.index;break}}return e.slice(n,o)}const Oe=new RegExp(String.raw`(?<noncapturingStart>${_e})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");const Be=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Ge=new RegExp(String.raw`
\\(?: \d+
  | c[A-Za-z]
  | [gk]<[^>]+>
  | [pPu]\{[^\}]+\}
  | u[A-Fa-f\d]{4}
  | x[A-Fa-f\d]{2}
  )
| \((?: \? (?: [:=!>]
  | <(?:[=!]|[^>]+>)
  | [A-Za-z\-]+:
  | \(DEFINE\)
  ))?
| (?<qBase>${Be})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
| \\?.
`.replace(/\s+/g,""),"gsu");const De=String.raw,Te=De`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,We=De`\(\?R=(?<rDepth>[^\)]+)\)|${Te}`,ze=De`\(\?<(?![=!])(?<captureName>[^>]+)>`,je=De`${ze}|(?<unnamed>\()(?!\?)`,Ve=new RegExp(De`${ze}|${We}|\(\?|\\?.`,"gsu"),He="Cannot use multiple overlapping recursions";function Xe(e){const n=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(n);if((e=+e)<2||e>100)throw new Error(n)}function Ze(e,n,t,r,o,a,s){const i=new Set;r&&Pe(e+n,ze,({groups:{captureName:e}})=>{i.add(e)},Le.DEFAULT);const u=[t,r?i:null,o,a,s];return`${e}${qe(`(?:${e}`,"forward",...u)}(?:)${qe(`${n})`,"backward",...u)}${n}`}function qe(e,n,t,r,o,a,s){const i=e=>"forward"===n?e+2:t-e+2-1;let u="";for(let l=0;l<t;l++){const n=i(l);u+=Re(e,De`${je}|\\k<(?<backref>[^>]+)>`,({0:e,groups:{captureName:t,unnamed:i,backref:u}})=>{if(u&&r&&!r.has(u))return e;const l=`_$${n}`;if(i||t){const n=s+a.length+1;return a.push(n),Qe(o,n),i?e:`(?<${t}${l}>`}return De`\k<${u}${l}>`},Le.DEFAULT)}return u}function Qe(e,n){for(let t=0;t<e.length;t++)e[t]>=n&&e[t]++}function Ke(e,n,t,r,o,a){if(e.size&&r){let s=0;Pe(n,je,()=>s++,Le.DEFAULT);const i=a-s+o,u=new Map;return e.forEach((e,n)=>{const o=(r-s*t)/t,a=s*t,l=n>i+s?n+r:n,c=[];for(const u of e)if(u<=i)c.push(u);else if(u>i+s+o)c.push(u+r);else if(u<=i+s)for(let e=0;e<=t;e++)c.push(u+s*e);else for(let e=0;e<=t;e++)c.push(u+a+o*e);u.set(l,c)}),u}return e}var Je=String.fromCodePoint,Ye=String.raw,en={},nn=globalThis.RegExp;function tn(e,{enable:n,disable:t}){return{dotAll:!((null==t?void 0:t.dotAll)||!(null==n?void 0:n.dotAll)&&!e.dotAll),ignoreCase:!((null==t?void 0:t.ignoreCase)||!(null==n?void 0:n.ignoreCase)&&!e.ignoreCase)}}function rn(e,n,t){return e.has(n)||e.set(n,t),e.get(n)}function on(e,n){return an[e]>=an[n]}en.flagGroups=(()=>{try{new nn("(?i:)")}catch(e){return!1}return!0})(),en.unicodeSets=(()=>{try{new nn("[[]]","v")}catch(e){return!1}return!0})(),en.bugFlagVLiteralHyphenIsRange=!!en.unicodeSets&&(()=>{try{new nn(Ye`[\d\-a]`,"v")}catch(e){return!0}return!1})(),en.bugNestedClassIgnoresNegation=en.unicodeSets&&new nn("[[^a]]","v").test("a");var an={ES2025:2025,ES2024:2024,ES2018:2018},sn={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function un(e={}){if("[object Object]"!=={}.toString.call(e))throw new Error("Unexpected options");if(void 0!==e.target&&!sn[e.target])throw new Error(`Unexpected target "${e.target}"`);const n=m(y({accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1},e),{rules:y({allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1},e.rules)});return"auto"===n.target&&(n.target=en.flagGroups?"ES2025":en.unicodeSets?"ES2024":"ES2018"),n}var ln=new Set([Je(304),Je(305)]),cn=Ye`[\p{L}\p{M}\p{N}\p{Pc}]`;function pn(e){if(ln.has(e))return[e];const n=new Set,t=e.toLowerCase(),r=t.toUpperCase(),o=hn.get(t),a=fn.get(t),s=gn.get(t);return 1===[...r].length&&n.add(r),s&&n.add(s),o&&n.add(o),n.add(t),a&&n.add(a),[...n]}var dn=new Map("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".split(/\s/).map(e=>[Ee(e),e])),fn=new Map([["s",Je(383)],[Je(383),"s"]]),gn=new Map([[Je(223),Je(7838)],[Je(107),Je(8490)],[Je(229),Je(8491)],[Je(969),Je(8486)]]),hn=new Map([yn(453),yn(456),yn(459),yn(498),...mn(8072,8079),...mn(8088,8095),...mn(8104,8111),yn(8124),yn(8140),yn(8188)]),wn=new Map([["alnum",Ye`[\p{Alpha}\p{Nd}]`],["alpha",Ye`\p{Alpha}`],["ascii",Ye`\p{ASCII}`],["blank",Ye`[\p{Zs}\t]`],["cntrl",Ye`\p{Cc}`],["digit",Ye`\p{Nd}`],["graph",Ye`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",Ye`\p{Lower}`],["print",Ye`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",Ye`[\p{P}\p{S}]`],["space",Ye`\p{space}`],["upper",Ye`\p{Upper}`],["word",Ye`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",Ye`\p{AHex}`]]);function yn(e){const n=Je(e);return[n.toLowerCase(),n]}function mn(e,n){return function(e,n){const t=[];for(let r=e;r<=n;r++)t.push(r);return t}(e,n).map(e=>yn(e))}var bn=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var Cn={AbsenceFunction({node:e,parent:n,replaceWith:t}){const{body:r,kind:o}=e;if("repeater"!==o)throw new Error('Unsupported absence function "(?~|"');{const e=ge();e.body[0].body.push(he({negate:!0,body:r}),me("Any"));const o=ge();o.body[0].body.push(we("greedy",0,1/0,e)),t(Un(o,n),{traverse:!0})}},Alternative:{enter({node:e,parent:n,key:t},{flagDirectivesByAlt:r}){const o=e.body.filter(e=>"flags"===e.kind);for(let a=t+1;a<n.body.length;a++){rn(r,n.body[a],[]).push(...o)}},exit({node:e},{flagDirectivesByAlt:n}){var t;if(null==(t=n.get(e))?void 0:t.length){const t=In(n.get(e));if(t){const n=ge({flags:t});n.body[0].body=e.body,e.body=[Un(n,e)]}}}},Assertion({node:e,parent:n,key:t,container:r,root:o,remove:a,replaceWith:s},i){const{kind:u,negate:l}=e,{asciiWordBoundaries:c,avoidSubclass:p,supportedGNodes:d,wordIsAscii:f}=i;if("text_segment_boundary"===u)throw new Error(`Unsupported text segment boundary "\\${l?"Y":"y"}"`);if("line_end"===u)s(Un(he({body:[ie({body:[ue("string_end")]}),ie({body:[pe(10)]})]}),n));else if("line_start"===u)s(Un(Rn(Ye`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),n));else if("search_start"===u)if(d.has(e))o.flags.sticky=!0,a();else{const e=r[t-1];if(e&&function(e){const n=["Character","CharacterClass","CharacterSet"];return n.includes(e.type)||"Quantifier"===e.type&&e.min&&n.includes(e.body.type)}(e))s(Un(he({negate:!0}),n));else{if(p)throw new Error(Ye`Uses "\G" in a way that requires a subclass`);s(Fn(ue("string_start"),n)),i.strategy="clip_search"}}else if("string_end"===u||"string_start"===u);else if("string_end_newline"===u)s(Un(Rn(Ye`(?=\n?\z)`),n));else{if("word_boundary"!==u)throw new Error(`Unexpected assertion kind "${u}"`);if(!f&&!c){s(Un(Rn(l?`(?:(?<=${cn})(?=${cn})|(?<!${cn})(?!${cn}))`:`(?:(?<=${cn})(?!${cn})|(?<!${cn})(?=${cn}))`),n))}}},Backreference({node:e},{jsGroupNameMap:n}){let{ref:t}=e;"string"!=typeof t||Ln(t)||(t=An(t,n),e.ref=t)},CapturingGroup({node:e},{jsGroupNameMap:n,subroutineRefMap:t}){let{name:r}=e;r&&!Ln(r)&&(r=An(r,n),e.name=r),t.set(e.number,e),r&&t.set(r,e)},CharacterClassRange({node:e,parent:n,replaceWith:t}){if("intersection"===n.kind){t(Un(de({body:[e]}),n),{traverse:!0})}},CharacterSet({node:e,parent:n,replaceWith:t},{accuracy:r,minTargetEs2024:o,digitIsAscii:a,spaceIsAscii:s,wordIsAscii:i}){const{kind:u,negate:l,value:c}=e;if(!a||"digit"!==u&&"digit"!==c)if(!s||"space"!==u&&"space"!==c)if(!i||"word"!==u&&"word"!==c)if("any"===u)t(Fn(me("Any"),n));else if("digit"===u)t(Fn(me("Nd",{negate:l}),n));else if("dot"===u);else if("text_segment"===u){if("strict"===r)throw new Error(Ye`Use of "\X" requires non-strict accuracy`);const e="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",a=Ye`\p{RI}{2}|${e}(?:\u200D${e})*`;t(Un(Rn(Ye`(?>\r\n|${o?Ye`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),n))}else if("hex"===u)t(Fn(me("AHex",{negate:l}),n));else if("newline"===u)t(Un(Rn(l?"[^\n]":"(?>\r\n?|[\n\v\f\u2028\u2029])"),n));else if("posix"===u)if(o||"graph"!==c&&"print"!==c)t(Un(Pn(Rn(wn.get(c)),l),n));else{if("strict"===r)throw new Error(`POSIX class "${c}" requires min target ES2024 or non-strict accuracy`);let e={graph:"!-~",print:" -~"}[c];l&&(e=`\0-${Je(e.codePointAt(0)-1)}${Je(e.codePointAt(2)+1)}-􏿿`),t(Un(Rn(`[${e}]`),n))}else if("property"===u)dn.has(Ee(c))||(e.key="sc");else if("space"===u)t(Fn(me("space",{negate:l}),n));else{if("word"!==u)throw new Error(`Unexpected character set kind "${u}"`);t(Un(Pn(Rn(cn),l),n))}else t(Fn(fe("word",{negate:l}),n));else t(Un(Pn(Rn("[\t-\r ]"),l),n));else t(Fn(fe("digit",{negate:l}),n))},Directive({node:e,parent:n,root:t,remove:r,replaceWith:o,removeAllPrevSiblings:a,removeAllNextSiblings:s}){const{kind:i,flags:u}=e;if("flags"===i)if(u.enable||u.disable){const e=ge({flags:u});e.body[0].body=s(),o(Un(e,n),{traverse:!0})}else r();else{if("keep"!==i)throw new Error(`Unexpected directive kind "${i}"`);{const e=t.body[0],r=1===t.body.length&&oe(e,{type:"Group"})&&1===e.body[0].body.length?e.body[0]:t;if(n.parent!==r||r.body.length>1)throw new Error(Ye`Uses "\K" in a way that's unsupported`);const s=he({behind:!0});s.body[0].body=a(),o(Un(s,n))}}},Flags({node:e,parent:n}){var t;if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if("word"===e.textSegmentMode)throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:null!=(t=e.sticky)&&t}),n.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:n,disable:t}=e.flags;(null==n?void 0:n.extended)&&delete n.extended,(null==t?void 0:t.extended)&&delete t.extended,(null==n?void 0:n.dotAll)&&(null==t?void 0:t.dotAll)&&delete n.dotAll,(null==n?void 0:n.ignoreCase)&&(null==t?void 0:t.ignoreCase)&&delete n.ignoreCase,n&&!Object.keys(n).length&&delete e.flags.enable,t&&!Object.keys(t).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},n){const{kind:t}=e;"lookbehind"===t&&(n.passedLookbehind=!0)},NamedCallout({node:e,parent:n,replaceWith:t}){const{kind:r}=e;if("fail"!==r)throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`);t(Un(he({negate:!0}),n))},Quantifier({node:e}){if("Quantifier"===e.body.type){const n=ge();n.body[0].body.push(e.body),e.body=Un(n,e)}},Regex:{enter({node:e},{supportedGNodes:n}){const t=[];let r=!1,o=!1;for(const a of e.body)if(1===a.body.length&&"search_start"===a.body[0].kind)a.body.pop();else{const e=Mn(a.body);e?(r=!0,Array.isArray(e)?t.push(...e):t.push(e)):o=!0}r&&!o&&t.forEach(e=>n.add(e))},exit(e,{accuracy:n,passedLookbehind:t,strategy:r}){if("strict"===n&&t&&r)throw new Error(Ye`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:n}){let{ref:t}=e;"string"!=typeof t||Ln(t)||(t=An(t,n),e.ref=t)}},xn={Backreference({node:e},{multiplexCapturesToLeftByRef:n,reffedNodesByReferencer:t}){const{orphan:r,ref:o}=e;r||t.set(e,[...n.get(o).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:n,replaceWith:t,skip:r},{groupOriginByCopy:o,groupsByName:a,multiplexCapturesToLeftByRef:s,openRefs:i,reffedNodesByReferencer:u}){var l;const c=o.get(e);if(c&&i.has(e.number)){const r=Fn($n(e.number),n);return u.set(r,i.get(e.number)),void t(r)}i.set(e.number,e),s.set(e.number,[]),e.name&&rn(s,e.name,[]);const p=s.get(null!=(l=e.name)?l:e.number);for(let d=0;d<p.length;d++){const n=p[d];if(c===n.node||c&&c===n.origin||e===n.origin){p.splice(d,1);break}}if(s.get(e.number).push({node:e,origin:c}),e.name&&s.get(e.name).push({node:e,origin:c}),e.name){const n=rn(a,e.name,new Map);let t=!1;if(c)t=!0;else for(const e of n.values())if(!e.hasDuplicateNameToRemove){t=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:t})}},exit({node:e},{openRefs:n}){n.get(e.number)===e&&n.delete(e.number)}},Group:{enter({node:e},n){n.prevFlags=n.currentFlags,e.flags&&(n.currentFlags=tn(n.currentFlags,e.flags))},exit(e,n){n.currentFlags=n.prevFlags}},Subroutine({node:e,parent:n,replaceWith:t},r){const{isRecursive:o,ref:a}=e;if(o){let t=n;for(;(t=t.parent)&&("CapturingGroup"!==t.type||t.name!==a&&t.number!==a););return void r.reffedNodesByReferencer.set(e,t)}const s=r.subroutineRefMap.get(a),i=0===a,u=i?$n(0):vn(s,r.groupOriginByCopy,null);let l=u;if(!i){const e=In(function(e,n){const t=[];for(;e=e.parent;)n&&!n(e)||t.push(e);return t}(s,e=>"Group"===e.type&&!!e.flags)),n=e?tn(r.globalFlags,e):r.globalFlags;c=n,p=r.currentFlags,(c.dotAll!==p.dotAll||c.ignoreCase!==p.ignoreCase)&&(l=ge({flags:Sn(n)}),l.body[0].body.push(u))}var c,p;t(Un(l,n),{traverse:!i})}},kn={Backreference({node:e,parent:n,replaceWith:t},r){if(e.orphan)return void(r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref));const o=r.reffedNodesByReferencer.get(e).filter(n=>function(e,n){let t=n;do{if("Regex"===t.type)return!1;if("Alternative"===t.type)continue;if(t===e)return!1;const n=_n(t.parent);for(const r of n){if(r===t)break;if(r===e||Nn(r,e))return!0}}while(t=t.parent);throw new Error("Unexpected path")}(n,e));if(o.length)if(o.length>1){t(Un(ge({atomic:!0,body:o.reverse().map(e=>ie({body:[le(e.number)]}))}),n))}else e.ref=o[0].number;else t(Un(he({negate:!0}),n))},CapturingGroup({node:e},n){e.number=++n.numCapturesToLeft,e.name&&n.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},n){const t=Math.max(n.highestOrphanBackref-n.numCapturesToLeft,0);for(let r=0;r<t;r++){const n=ce();e.body.at(-1).body.push(n)}}},Subroutine({node:e},n){e.isRecursive&&0!==e.ref&&(e.ref=n.reffedNodesByReferencer.get(e).number)}};function En(e){Ae(e,{"*"({node:e,parent:n}){e.parent=n}})}function vn(e,n,t,r){var o;const a=Array.isArray(e)?[]:{};for(const[s,i]of Object.entries(e))"parent"===s?a.parent=Array.isArray(t)?r:t:i&&"object"==typeof i?a[s]=vn(i,n,a,t):("type"===s&&"CapturingGroup"===i&&n.set(a,null!=(o=n.get(e))?o:e),a[s]=i);return a}function $n(e){const n=ye(e);return n.isRecursive=!0,n}function An(e,n){if(n.has(e))return n.get(e);const t=`$${n.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,"_")}`;return n.set(e,t),t}function In(e){const n=["dotAll","ignoreCase"],t={enable:{},disable:{}};return e.forEach(({flags:e})=>{n.forEach(n=>{var r,o;(null==(r=e.enable)?void 0:r[n])&&(delete t.disable[n],t.enable[n]=!0),(null==(o=e.disable)?void 0:o[n])&&(t.disable[n]=!0)})}),Object.keys(t.enable).length||delete t.enable,Object.keys(t.disable).length||delete t.disable,t.enable||t.disable?t:null}function Sn({dotAll:e,ignoreCase:n}){const t={};return(e||n)&&(t.enable={},e&&(t.enable.dotAll=!0),n&&(t.enable.ignoreCase=!0)),e&&n||(t.disable={},!e&&(t.disable.dotAll=!0),!n&&(t.disable.ignoreCase=!0)),t}function _n(e){if(!e)throw new Error("Node expected");const{body:n}=e;return Array.isArray(n)?n:n?[n]:null}function Mn(e){const n=e.find(e=>"search_start"===e.kind||function(e,n){const t=y({negate:null},n);return"LookaroundAssertion"===e.type&&(null===t.negate||e.negate===t.negate)&&1===e.body.length&&oe(e.body[0],{type:"Assertion",kind:"search_start"})}(e,{negate:!1})||!function({type:e}){return"Assertion"===e||"Directive"===e||"LookaroundAssertion"===e}(e));if(!n)return null;if("search_start"===n.kind)return n;if("LookaroundAssertion"===n.type)return n.body[0].body[0];if("CapturingGroup"===n.type||"Group"===n.type){const e=[];for(const t of n.body){const n=Mn(t.body);if(!n)return null;Array.isArray(n)?e.push(...n):e.push(n)}return e}return null}function Nn(e,n){var t;const r=null!=(t=_n(e))?t:[];for(const o of r)if(o===n||Nn(o,n))return!0;return!1}function Ln(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Rn(e,n){const t=se(e,m(y({},n),{unicodePropertyMap:dn})).body;return t.length>1||t[0].body.length>1?ge({body:t}):t[0].body[0]}function Pn(e,n){return e.negate=n,e}function Fn(e,n){return e.parent=n,e}function Un(e,n){return En(e),e.parent=n,e}function On(e,n){const t=un(n),r=on(t.target,"ES2024"),o=on(t.target,"ES2025"),a=t.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw new Error("Invalid recursionLimit; use 2-20");let s=null,i=null;if(!o){const n=[e.flags.ignoreCase];Ae(e,Bn,{getCurrentModI:()=>n.at(-1),popModI(){n.pop()},pushModI(e){n.push(e)},setHasCasedChar(){n.at(-1)?s=!0:i=!0}})}const u={dotAll:e.flags.dotAll,ignoreCase:!(!e.flags.ignoreCase&&!s||i)};let l=e;const c={accuracy:t.accuracy,appliedGlobalFlags:u,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!(o||!s||!i),useFlagMods:o,useFlagV:r,verbose:t.verbose};function p(e){c.lastNode=l,l=e;return function(e,n){if(null==e)throw new Error(null!=n?n:"Value expected");return e}(Gn[e.type],`Unexpected node type "${e.type}"`)(e,c,p)}const d={pattern:e.body.map(p).join("|"),flags:p(e.flags),options:y({},e.options)};return r||(delete d.options.force.v,d.options.disable.v=!0,d.options.unicodeSetsPlugin=null),d._captureTransfers=new Map,d._hiddenCaptures=[],c.captureMap.forEach((e,n)=>{e.hidden&&d._hiddenCaptures.push(n),e.transferTo&&rn(d._captureTransfers,e.transferTo,[]).push(n)}),d}var Bn={"*":{enter({node:e},n){if(Zn(e)){const t=n.getCurrentModI();n.pushModI(e.flags?tn({ignoreCase:t},e.flags).ignoreCase:t)}},exit({node:e},n){Zn(e)&&n.popModI()}},Backreference(e,n){n.setHasCasedChar()},Character({node:e},n){Vn(Je(e.value))&&n.setHasCasedChar()},CharacterClassRange({node:e,skip:n},t){n(),Hn(e,{firstOnly:!0}).length&&t.setHasCasedChar()},CharacterSet({node:e},n){"property"===e.kind&&bn.has(e.value)&&n.setHasCasedChar()}},Gn={Alternative:({body:e},n,t)=>e.map(t).join(""),Assertion({kind:e,negate:n}){if("string_end"===e)return"$";if("string_start"===e)return"^";if("word_boundary"===e)return n?Ye`\B`:Ye`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},n){if("number"!=typeof e)throw new Error("Unexpected named backref in transformed AST");if(!n.useFlagMods&&"strict"===n.accuracy&&n.currentFlags.ignoreCase&&!n.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,n,t){const{body:r,name:o,number:a}=e,s={ignoreCase:n.currentFlags.ignoreCase},i=n.originMap.get(e);return i&&(s.hidden=!0,a>i.number&&(s.transferTo=i.number)),n.captureMap.set(a,s),`(${o?`?<${o}>`:""}${r.map(t).join("|")})`},Character({value:e},n){const t=Je(e),r=Xn(e,{escDigit:"Backreference"===n.lastNode.type,inCharClass:n.inCharClass,useFlagV:n.useFlagV});if(r!==t)return r;if(n.useAppliedIgnoreCase&&n.currentFlags.ignoreCase&&Vn(t)){const e=pn(t);return n.inCharClass?e.join(""):e.length>1?`[${e.join("")}]`:e[0]}return t},CharacterClass(e,n,t){const{kind:r,negate:o,parent:a}=e;let{body:s}=e;if("intersection"===r&&!n.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");en.bugFlagVLiteralHyphenIsRange&&n.useFlagV&&s.some(qn)&&(s=[pe(45),...s.filter(e=>!qn(e))]);const i=()=>`[${o?"^":""}${s.map(t).join("intersection"===r?"&&":"")}]`;if(!n.inCharClass){if((!n.useFlagV||en.bugNestedClassIgnoresNegation)&&!o){const n=s.filter(e=>"CharacterClass"===e.type&&"union"===e.kind&&e.negate);if(n.length){const r=ge(),o=r.body[0];return r.parent=a,o.parent=r,s=s.filter(e=>!n.includes(e)),e.body=s,s.length?(e.parent=o,o.body.push(e)):r.body.pop(),n.forEach(e=>{const n=ie({body:[e]});e.parent=n,n.parent=r,r.body.push(n)}),t(r)}}n.inCharClass=!0;const r=i();return n.inCharClass=!1,r}const u=s[0];if("union"===r&&!o&&u&&((!n.useFlagV||!n.verbose)&&"union"===a.kind&&(!en.bugFlagVLiteralHyphenIsRange||!n.useFlagV)||!n.verbose&&"intersection"===a.kind&&1===s.length&&"CharacterClassRange"!==u.type))return s.map(t).join("");if(!n.useFlagV&&"CharacterClass"===a.type)throw new Error("Uses nested character class in a way that requires min target ES2024");return i()},CharacterClassRange(e,n){const t=e.min.value,r=e.max.value,o={escDigit:!1,inCharClass:!0,useFlagV:n.useFlagV},a=Xn(t,o),s=Xn(r,o),i=new Set;if(n.useAppliedIgnoreCase&&n.currentFlags.ignoreCase){(function(e){const n=e.map(e=>e.codePointAt(0)).sort((e,n)=>e-n),t=[];let r=null;for(let o=0;o<n.length;o++)n[o+1]===n[o]+1?null!=r||(r=n[o]):null===r?t.push(n[o]):(t.push([r,n[o]]),r=null);return t})(Hn(e)).forEach(e=>{i.add(Array.isArray(e)?`${Xn(e[0],o)}-${Xn(e[1],o)}`:Xn(e,o))})}return`${a}-${s}${[...i].join("")}`},CharacterSet({kind:e,negate:n,value:t,key:r},o){if("dot"===e)return o.currentFlags.dotAll?o.appliedGlobalFlags.dotAll||o.useFlagMods?".":"[^]":Ye`[^\n]`;if("digit"===e)return n?Ye`\D`:Ye`\d`;if("property"===e){if(o.useAppliedIgnoreCase&&o.currentFlags.ignoreCase&&bn.has(t))throw new Error(`Unicode property "${t}" can't be case-insensitive when other chars have specific case`);return`${n?Ye`\P`:Ye`\p`}{${r?`${r}=`:""}${t}}`}if("word"===e)return n?Ye`\W`:Ye`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags:(e,n)=>(n.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":""),Group({atomic:e,body:n,flags:t,parent:r},o,a){const s=o.currentFlags;t&&(o.currentFlags=tn(s,t));const i=n.map(a).join("|"),u=o.verbose||1!==n.length||"Quantifier"===r.type||e||o.useFlagMods&&t?`(?${function(e,n,t){if(e)return">";let r="";if(n&&t){const{enable:e,disable:t}=n;r=((null==e?void 0:e.ignoreCase)?"i":"")+((null==e?void 0:e.dotAll)?"s":"")+(t?"-":"")+((null==t?void 0:t.ignoreCase)?"i":"")+((null==t?void 0:t.dotAll)?"s":"")}return`${r}:`}(e,t,o.useFlagMods)}${i})`:i;return o.currentFlags=s,u},LookaroundAssertion:({body:e,kind:n,negate:t},r,o)=>`(?${`${"lookahead"===n?"":"<"}${t?"!":"="}`}${e.map(o).join("|")})`,Quantifier:(e,n,t)=>t(e.body)+function({kind:e,max:n,min:t}){let r;r=t||1!==n?t||n!==1/0?1===t&&n===1/0?"+":t===n?`{${t}}`:`{${t},${n===1/0?"":n}}`:"*":"?";return r+{greedy:"",lazy:"?",possessive:"+"}[e]}(e),Subroutine({isRecursive:e,ref:n},t){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=t.recursionLimit;return 0===n?`(?R=${r})`:Ye`\g<${n}&R=${r}>`}},Dn=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Tn=new Set(["-","\\","]","^","["]),Wn=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),zn=new Map([[9,Ye`\t`],[10,Ye`\n`],[11,Ye`\v`],[12,Ye`\f`],[13,Ye`\r`],[8232,Ye`\u2028`],[8233,Ye`\u2029`],[65279,Ye`\uFEFF`]]),jn=new RegExp("^\\p{Cased}$","u");function Vn(e){return jn.test(e)}function Hn(e,n){const t=!!(null==n?void 0:n.firstOnly),r=e.min.value,o=e.max.value,a=[];if(r<65&&(65535===o||o>=131071)||65536===r&&o>=131071)return a;for(let s=r;s<=o;s++){const e=Je(s);if(!Vn(e))continue;const n=pn(e).filter(e=>{const n=e.codePointAt(0);return n<r||n>o});if(n.length&&(a.push(...n),t))break}return a}function Xn(e,{escDigit:n,inCharClass:t,useFlagV:r}){if(zn.has(e))return zn.get(e);if(e<32||e>126&&e<160||e>262143||n&&((o=e)>47&&o<58))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;var o;const a=t?r?Wn:Tn:Dn,s=Je(e);return(a.has(s)?"\\":"")+s}function Zn({type:e}){return"CapturingGroup"===e||"Group"===e||"LookaroundAssertion"===e}function qn({type:e,value:n}){return"Character"===e&&45===n}var Qn=(i=class extends RegExp{constructor(s,u,l){var c=(...s)=>{super(...s),k(this,a),k(this,e,new Map),k(this,n,null),k(this,t,void 0),k(this,r,null),k(this,o,null),b(this,"rawOptions",{})};const p=!!(null==l?void 0:l.lazyCompile);if(s instanceof RegExp){if(l)throw new Error("Cannot provide options when copying a regexp");const n=s;c(n,u),E(this,t,n.source),n instanceof i&&(E(this,e,x(n,e)),E(this,r,x(n,r)),E(this,o,x(n,o)),this.rawOptions=n.rawOptions)}else{const n=y({hiddenCaptures:[],strategy:null,transfers:[]},l);c(p?"":s,u),E(this,t,s),E(this,e,function(e,n){const t=new Map;for(const r of e)t.set(r,{hidden:!0});for(const[r,o]of n)for(const e of o)rn(t,e,{}).transferTo=r;return t}(n.hiddenCaptures,n.transfers)),E(this,o,n.strategy),this.rawOptions=null!=l?l:{}}p||E(this,n,this)}get source(){return x(this,t)||"(?:)"}exec(e){if(!x(this,n)){const e=this.rawOptions,{lazyCompile:r}=e,o=((e,n)=>{var t={};for(var r in e)f.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&p)for(var r of p(e))n.indexOf(r)<0&&g.call(e,r)&&(t[r]=e[r]);return t})(e,["lazyCompile"]);E(this,n,new i(x(this,t),this.flags,o))}const r=this.global||this.sticky,u=this.lastIndex;if("clip_search"===x(this,o)&&r&&u){this.lastIndex=0;const n=v(this,a,s).call(this,e.slice(u));return n&&(!function(e,n,t,r){if(e.index+=n,e.input=t,r){const t=e.indices;for(let e=0;e<t.length;e++){const r=t[e];r&&(t[e]=[r[0]+n,r[1]+n])}const r=t.groups;r&&Object.keys(r).forEach(e=>{const t=r[e];t&&(r[e]=[t[0]+n,t[1]+n])})}}(n,u,e,this.hasIndices),this.lastIndex+=u),n}return v(this,a,s).call(this,e)}},e=new WeakMap,n=new WeakMap,t=new WeakMap,r=new WeakMap,o=new WeakMap,a=new WeakSet,s=function(t){var o;x(this,n).lastIndex=this.lastIndex;const a=(s=i.prototype,u=this,l="exec",h(d(s),l,u)).call(x(this,n),t);var s,u,l;if(this.lastIndex=x(this,n).lastIndex,!a||!x(this,e).size)return a;const c=[...a];let p;a.length=1,this.hasIndices&&(p=[...a.indices],a.indices.length=1);const f=[0];for(let n=1;n<c.length;n++){const{hidden:t,transferTo:s}=null!=(o=x(this,e).get(n))?o:{};if(t?f.push(null):(f.push(a.length),a.push(c[n]),this.hasIndices&&a.indices.push(p[n])),s&&void 0!==c[n]){const e=f[s];if(!e)throw new Error(`Invalid capture transfer to "${e}"`);if(a[e]=c[n],this.hasIndices&&(a.indices[e]=p[n]),a.groups){x(this,r)||E(this,r,Kn(this.source));const e=x(this,r).get(s);e&&(a.groups[e]=c[n],this.hasIndices&&(a.indices.groups[e]=p[n]))}}}return a},i);function Kn(e){const n=new RegExp("(?<capture>\\((?:\\?<(?![=!])(?<name>[^>]+)>|(?!\\?)))|\\\\?.","gsu"),t=new Map;let r,o=0,a=0;for(;r=n.exec(e);){const{0:e,groups:{capture:n,name:s}}=r;"["===e?o++:o?"]"===e&&o--:n&&(a++,s&&t.set(a,s))}return t}function Jn(e,n){const t=function(e,n){const t=un(n),r=se(e,{flags:t.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:t.rules.captureGroup,singleline:t.rules.singleline},skipBackrefValidation:t.rules.allowOrphanBackrefs,unicodePropertyMap:dn}),o=function(e,n){const t=y({accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025"},n);En(e);const r={accuracy:t.accuracy,asciiWordBoundaries:t.asciiWordBoundaries,avoidSubclass:t.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:on(t.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Ae(e,Cn,r);const o={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:o,prevFlags:null,globalFlags:o,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};return Ae(e,xn,a),Ae(e,kn,{groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer}),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}(r,{accuracy:t.accuracy,asciiWordBoundaries:t.rules.asciiWordBoundaries,avoidSubclass:t.avoidSubclass,bestEffortTarget:t.target}),a=On(o,t),s=function(e,n){var t;const{hiddenCaptures:r,mode:o}=y({hiddenCaptures:[],mode:"plugin"},n);let a=null!=(t=null==n?void 0:n.captureTransfers)?t:new Map;if(!new RegExp(We,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:r};if("plugin"===o&&Fe(e,De`\(\?\(DEFINE\)`,Le.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const s=[],i=Fe(e,De`\\[1-9]`,Le.DEFAULT),u=new Map,l=[];let c,p=!1,d=0,f=0;for(Ve.lastIndex=0;c=Ve.exec(e);){const{0:n,groups:{captureName:t,rDepth:g,gRNameOrNum:h,gRDepth:w}}=c;if("["===n)d++;else if(d)"]"===n&&d--;else{if(g){if(Xe(g),p)throw new Error(He);if(i)throw new Error(("external"===o?"Backrefs":"Numbered backrefs")+" cannot be used with global recursion");const n=e.slice(0,c.index),t=e.slice(Ve.lastIndex);if(Fe(t,We,Le.DEFAULT))throw new Error(He);const u=+g-1;e=Ze(n,t,u,!1,r,s,f),a=Ke(a,n,u,s.length,0,f);break}if(h){Xe(w);let t=!1;for(const e of l)if(e.name===h||e.num===+h){if(t=!0,e.hasRecursedWithin)throw new Error(He);break}if(!t)throw new Error(De`Recursive \g cannot be used outside the referenced group "${"external"===o?h:De`\g<${h}&R=${w}>`}"`);const d=u.get(h),g=Ue(e,d);if(i&&Fe(g,De`${ze}|\((?!\?)`,Le.DEFAULT))throw new Error(("external"===o?"Backrefs":"Numbered backrefs")+" cannot be used with recursion of capturing groups");const y=e.slice(d,c.index),m=g.slice(y.length+n.length),b=s.length,C=+w-1,x=Ze(y,m,C,!0,r,s,f);a=Ke(a,y,C,s.length-b,b,f);const k=e.slice(0,d),E=e.slice(d+g.length);e=`${k}${x}${E}`,Ve.lastIndex+=x.length-n.length-y.length-m.length,l.forEach(e=>e.hasRecursedWithin=!0),p=!0}else if(t)f++,u.set(String(f),Ve.lastIndex),u.set(t,Ve.lastIndex),l.push({num:f,name:t});else if("("===n[0]){const e="("===n;e&&(f++,u.set(String(f),Ve.lastIndex)),l.push(e?{num:f}:{})}else")"===n&&l.pop()}}return r.push(...s),{pattern:e,captureTransfers:a,hiddenCaptures:r}}(a.pattern,{captureTransfers:a._captureTransfers,hiddenCaptures:a._hiddenCaptures,mode:"external"}),i=function(e,n){var t,r;const o=null!=(t=null==n?void 0:n.hiddenCaptures)?t:[];let a=null!=(r=null==n?void 0:n.captureTransfers)?r:new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:o};const s="(?:(?=(",i=[0],u=[];let l,c=0,p=0,d=NaN;do{l=!1;let n,t=0,r=0,f=!1;for(Oe.lastIndex=Number.isNaN(d)?0:d+7;n=Oe.exec(e);){const{0:g,index:h,groups:{capturingStart:w,noncapturingStart:y}}=n;if("["===g)t++;else if(t)"]"===g&&t--;else if("(?>"!==g||f){if(f&&y)r++;else if(w)f?r++:(c++,i.push(c+p));else if(")"===g&&f){if(!r){p++;const n=c+p;if(e=`${e.slice(0,d)}${s}${e.slice(d+3,h)}))<$$${n}>)${e.slice(h+1)}`,l=!0,u.push(n),Me(o,n),a.size){const e=new Map;a.forEach((t,r)=>{e.set(r>=n?r+1:r,t.map(e=>e>=n?e+1:e))}),a=e}break}r--}}else d=h,f=!0}}while(l);return o.push(...u),{pattern:e=Re(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:e,groups:{backrefNum:n,wrappedBackrefNum:t}})=>{if(n){const t=+n;if(t>i.length-1)throw new Error(`Backref "${e}" greater than number of captures`);return`\\${i[t]}`}return`\\${t}`},Le.DEFAULT),captureTransfers:a,hiddenCaptures:o}}(function(e){if(!new RegExp(`${Be}\\+`).test(e))return{pattern:e};const n=[];let t,r=null,o=null,a="",s=0;for(Ge.lastIndex=0;t=Ge.exec(e);){const{0:i,index:u,groups:{qBase:l,qMod:c,invalidQ:p}}=t;if("["===i)s||(o=u),s++;else if("]"===i)s?s--:o=null;else if(!s)if("+"===c&&a&&!a.startsWith("(")){if(p)throw new Error(`Invalid quantifier "${i}"`);let n=-1;if(/^\{\d+\}$/.test(l))e=Ne(e,u+l.length,c,"");else{if(")"===a||"]"===a){const n=")"===a?r:o;if(null===n)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,n)}(?>${e.slice(n,u)}${l})${e.slice(u+i.length)}`}else e=`${e.slice(0,u-a.length)}(?>${a}${l})${e.slice(u+i.length)}`;n+=4}Ge.lastIndex+=n}else"("===i[0]?n.push(u):")"===i&&(r=n.length?n.pop():null);a=i}return{pattern:e}}(s.pattern).pattern,{captureTransfers:s.captureTransfers,hiddenCaptures:s.hiddenCaptures}),u={pattern:i.pattern,flags:`${t.hasIndices?"d":""}${t.global?"g":""}${a.flags}${a.options.disable.v?"u":"v"}`};if(t.avoidSubclass){if(t.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const e=i.hiddenCaptures.sort((e,n)=>e-n),n=Array.from(i.captureTransfers),r=o._strategy,a=u.pattern.length>=t.lazyCompileLength;(e.length||n.length||r||a)&&(u.options=y(y(y(y({},e.length&&{hiddenCaptures:e}),n.length&&{transfers:n}),r&&{strategy:r}),a&&{lazyCompile:a}))}return u}(e,n);return t.options?new Qn(t.pattern,t.flags,t.options):new RegExp(t.pattern,t.flags)}function Yn(e,n){return Jn(e,y({global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0}},n))}function et(e={}){const n=y({target:"auto",cache:new Map},e);return n.regexConstructor||(n.regexConstructor=e=>Yn(e,{target:n.target})),{createScanner:e=>new A(e,n),createString:e=>({content:e})}}function nt(){const e={cache:new Map,regexConstructor:()=>{throw new Error("JavaScriptRawEngine: only support precompiled grammar")}};return{createScanner:n=>new A(n,e),createString:e=>({content:e})}}export{A as JavaScriptScanner,nt as createJavaScriptRawEngine,et as createJavaScriptRegexEngine,Yn as defaultJavaScriptRegexConstructor};
