const de=String.raw,Ee=de`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`,ve=de`\u{E0061}-\u{E007A}`,dt=()=>new RegExp(de`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${ve}]{2}[\u{E0030}-\u{E0039}${ve}]{1,3}\u{E007F}|${Ee}(?:\u200D${Ee})*`,"gu"),x=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function K(e,t,r,s){const n=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1];let i=0,o="";for(const c of e.matchAll(n)){const{0:u,groups:{$skip:l}}=c;if(!l&&(!s||s===x.DEFAULT==!i)){r instanceof Function?o+=r(c,{context:i?x.CHAR_CLASS:x.DEFAULT,negated:a[a.length-1]}):o+=r;continue}u[0]==="["?(i++,a.push(u[1]==="^")):u==="]"&&i&&(i--,a.pop()),o+=u}return o}function Ct(e,t,r,s){K(e,t,r,s)}function mt(e,t,r=0,s){if(!new RegExp(t,"su").test(e))return null;const n=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");n.lastIndex=r;let a=0,i;for(;i=n.exec(e);){const{0:o,groups:{$skip:c}}=i;if(!c&&(!s||s===x.DEFAULT==!a))return i;o==="["?a++:o==="]"&&a&&a--,n.lastIndex==i.index&&n.lastIndex++}return null}function H(e,t,r){return!!mt(e,t,0,r)}function wt(e,t){const r=/\\?./gsu;r.lastIndex=t;let s=e.length,n=0,a=1,i;for(;i=r.exec(e);){const[o]=i;if(o==="[")n++;else if(n)o==="]"&&n--;else if(o==="(")a++;else if(o===")"&&(a--,!a)){s=i.index;break}}return e.slice(t,s)}const O="$E$";class Ce extends RegExp{_captureMap;_namesByIndex;constructor(t,r,s){if(t instanceof RegExp&&s)throw new Error("Cannot provide options when copying a regexp");const n=!!s?.useEmulationGroups,a=n?bt(t):null;super(a?.expression||t,r);const i=n?a:t instanceof Ce?t:null;i&&(this._captureMap=i._captureMap,this._namesByIndex=i._namesByIndex)}exec(t){const r=RegExp.prototype.exec.call(this,t);if(!r||!this._captureMap)return r;const s=[...r];r.length=1;let n;this.hasIndices&&(n=[...r.indices],r.indices.length=1);for(let a=1;a<s.length;a++)if(this._captureMap[a].exclude){const i=this._captureMap[a].transfer;if(i&&r.length>i){r[i]=s[a];const o=this._namesByIndex[i];o&&(r.groups[o]=s[a],this.hasIndices&&(r.indices.groups[o]=n[a])),this.hasIndices&&(r.indices[i]=n[a])}}else r.push(s[a]),this.hasIndices&&r.indices.push(n[a]);return r}}function bt(e){const t=O.replace(/\$/g,"\\$"),r=[{exclude:!1}],s={0:""};let n=0;return e=K(e,String.raw`\((?:(?!\?)|\?<(?![=!])(?<name>[^>]+)>)(?<mark>(?:\$(?<transfer>[1-9]\d*))?${t})?`,({0:a,groups:{name:i,mark:o,transfer:c}})=>o?(r.push({exclude:!0,transfer:c&&+c}),a.slice(0,-o.length)):(n++,i&&(s[n]=i),r.push({exclude:!1}),a),x.DEFAULT),{_captureMap:r,_namesByIndex:s,expression:e}}const kt=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function yt(e,t,r,s){return e.slice(0,t)+s+e.slice(t+r.length)}const Ae=new RegExp(String.raw`(?<noncapturingStart>${kt})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function Et(e,t){if(!/\(\?>/.test(e))return e;const r="(?>",s=`(?:(?=(${t?.useEmulationGroups?O:""}`,n=[0];let a=0,i=0,o=NaN,c;do{c=!1;let u=0,l=0,f=!1,m;for(Ae.lastIndex=Number.isNaN(o)?0:o+s.length;m=Ae.exec(e);){const{0:g,index:b,groups:{capturingStart:k,noncapturingStart:S}}=m;if(g==="[")u++;else if(u)g==="]"&&u--;else if(g===r&&!f)o=b,f=!0;else if(f&&S)l++;else if(k)f?l++:(a++,n.push(a+i));else if(g===")"&&f){if(!l){i++,e=`${e.slice(0,o)}${s}${e.slice(o+r.length,b)}))<$$${i+a}>)${e.slice(b+1)}`,c=!0;break}l--}}}while(c);return e=K(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:u,groups:{backrefNum:l,wrappedBackrefNum:f}})=>{if(l){const m=+l;if(m>n.length-1)throw new Error(`Backref "${u}" greater than number of captures`);return`\\${n[m]}`}return`\\${f}`},x.DEFAULT),e}const Oe=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,re=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>${Oe})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
| \\?.
`.replace(/\s+/g,""),"gsu");function vt(e){if(!new RegExp(`${Oe}\\+`).test(e))return e;const t=[];let r=null,s=null,n="",a=0,i;for(re.lastIndex=0;i=re.exec(e);){const{0:o,index:c,groups:{qBase:u,qMod:l,invalidQ:f}}=i;if(o==="[")a||(s=c),a++;else if(o==="]")a?a--:s=null;else if(!a)if(l==="+"&&n&&!n.startsWith("(")){if(f)throw new Error(`Invalid quantifier "${o}"`);let m=-1;if(/^\{\d+\}$/.test(u))e=yt(e,c+u.length,l,"");else{if(n===")"||n==="]"){const g=n===")"?r:s;if(g===null)throw new Error(`Invalid unmatched "${n}"`);e=`${e.slice(0,g)}(?>${e.slice(g,c)}${u})${e.slice(c+o.length)}`}else e=`${e.slice(0,c-n.length)}(?>${n}${u})${e.slice(c+o.length)}`;m+=4}re.lastIndex+=m}else o[0]==="("?t.push(c):o===")"&&(r=t.length?t.pop():null);n=o}return e}const $=String.raw,At=$`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,ue=$`\(\?R=(?<rDepth>[^\)]+)\)|${At}`,J=$`\(\?<(?![=!])(?<captureName>[^>]+)>`,R=new RegExp($`${J}|${ue}|\(\?|\\?.`,"gsu"),ne="Cannot use multiple overlapping recursions",le=new RegExp($`(?:\$[1-9]\d*)?${O.replace(/\$/g,$`\$`)}`,"y");function St(e,t){if(!new RegExp(ue,"su").test(e))return e;if(H(e,$`\(\?\(DEFINE\)`,x.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const r=!!t?.useEmulationGroups,s=H(e,$`\\[1-9]`,x.DEFAULT),n=new Map,a=[];let i=!1,o=0,c=0,u;for(R.lastIndex=0;u=R.exec(e);){const{0:l,groups:{captureName:f,rDepth:m,gRNameOrNum:g,gRDepth:b}}=u;if(l==="[")o++;else if(o)l==="]"&&o--;else if(m){if(Se(m),i)throw new Error(ne);if(s)throw new Error("Numbered backrefs cannot be used with global recursion");const k=e.slice(0,u.index),S=e.slice(R.lastIndex);if(H(S,ue,x.DEFAULT))throw new Error(ne);return $e(k,S,+m,!1,r)}else if(g){Se(b);let k=!1;for(const T of a)if(T.name===g||T.num===+g){if(k=!0,T.hasRecursedWithin)throw new Error(ne);break}if(!k)throw new Error($`Recursive \g cannot be used outside the referenced group "\g<${g}&R=${b}>"`);const S=n.get(g),_=wt(e,S);if(s&&H(_,$`${J}|\((?!\?)`,x.DEFAULT))throw new Error("Numbered backrefs cannot be used with recursion of capturing groups");const te=e.slice(S,u.index),ke=_.slice(te.length+l.length),ye=$e(te,ke,+b,!0,r),gt=e.slice(0,S),ht=e.slice(S+_.length);e=`${gt}${ye}${ht}`,R.lastIndex+=ye.length-l.length-te.length-ke.length,a.forEach(T=>T.hasRecursedWithin=!0),i=!0}else if(f)c++,n.set(String(c),R.lastIndex),n.set(f,R.lastIndex),a.push({num:c,name:f});else if(l.startsWith("(")){const k=l==="(";k&&(c++,n.set(String(c),R.lastIndex+(r?$t(e,R.lastIndex):0))),a.push(k?{num:c}:{})}else l===")"&&a.pop()}return e}function Se(e){const t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function $e(e,t,r,s,n){const a=new Set;s&&Ct(e+t,J,({groups:{captureName:o}})=>{a.add(o)},x.DEFAULT);const i=r-1;return`${e}${_e(`(?:${e}`,i,s?a:null,"forward",n)}(?:)${_e(`${t})`,i,s?a:null,"backward",n)}${t}`}function _e(e,t,r,s,n){const i=c=>s==="backward"?t-c+2-1:c+2;let o="";for(let c=0;c<t;c++){const u=i(c);o+=K(e,$`${J}|\\k<(?<backref>[^>]+)>${n?$`|(?<unnamed>\()(?!\?)(?:${le.source})?`:""}`,({0:l,index:f,groups:{captureName:m,backref:g,unnamed:b}})=>{if(g&&r&&!r.has(g))return l;if(b)return`(${O}`;const k=`_$${u}`;return m?`(?<${m}${k}>${n?O:""}`:$`\k<${g}${k}>`},x.DEFAULT)}return o}function $t(e,t){le.lastIndex=t;const r=le.exec(e);return r?r[0].length:0}var E=String.fromCodePoint,d=String.raw,_t=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),xt=(()=>{try{new RegExp("","v")}catch{return!1}return!0})();function X(e,{enable:t,disable:r}){return{dotAll:!r?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!r?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function z(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}function pe(e,t){return xe[e]>=xe[t]}function M(e,t){if(!e)throw new Error(t??"Value expected");return e}var xe={ES2025:2025,ES2024:2024,ES2018:2018},It={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function De(e){if(e?.target!==void 0&&!It[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e?.rules}};return t.target==="auto"&&(t.target=_t?"ES2025":xt?"ES2024":"ES2018"),t}var Gt=new Set([E(304),E(305)]);function Ue(e){if(Gt.has(e))return[e];const t=new Set,r=e.toLowerCase(),s=r.toUpperCase(),n=Rt.get(r),a=Nt.get(r),i=Mt.get(r);return[...s].length===1&&t.add(s),i&&t.add(i),n&&t.add(n),t.add(r),a&&t.add(a),[...t]}var Be=new Set(`C Other
Cc Control cntrl
Cf Format
Cn Unassigned
Co Private_Use
Cs Surrogate
L Letter
LC Cased_Letter
Ll Lowercase_Letter
Lm Modifier_Letter
Lo Other_Letter
Lt Titlecase_Letter
Lu Uppercase_Letter
M Mark Combining_Mark
Mc Spacing_Mark
Me Enclosing_Mark
Mn Nonspacing_Mark
N Number
Nd Decimal_Number digit
Nl Letter_Number
No Other_Number
P Punctuation punct
Pc Connector_Punctuation
Pd Dash_Punctuation
Pe Close_Punctuation
Pf Final_Punctuation
Pi Initial_Punctuation
Po Other_Punctuation
Ps Open_Punctuation
S Symbol
Sc Currency_Symbol
Sk Modifier_Symbol
Sm Math_Symbol
So Other_Symbol
Z Separator
Zl Line_Separator
Zp Paragraph_Separator
Zs Space_Separator
ASCII
ASCII_Hex_Digit AHex
Alphabetic Alpha
Any
Assigned
Bidi_Control Bidi_C
Bidi_Mirrored Bidi_M
Case_Ignorable CI
Cased
Changes_When_Casefolded CWCF
Changes_When_Casemapped CWCM
Changes_When_Lowercased CWL
Changes_When_NFKC_Casefolded CWKCF
Changes_When_Titlecased CWT
Changes_When_Uppercased CWU
Dash
Default_Ignorable_Code_Point DI
Deprecated Dep
Diacritic Dia
Emoji
Emoji_Component EComp
Emoji_Modifier EMod
Emoji_Modifier_Base EBase
Emoji_Presentation EPres
Extended_Pictographic ExtPict
Extender Ext
Grapheme_Base Gr_Base
Grapheme_Extend Gr_Ext
Hex_Digit Hex
IDS_Binary_Operator IDSB
IDS_Trinary_Operator IDST
ID_Continue IDC
ID_Start IDS
Ideographic Ideo
Join_Control Join_C
Logical_Order_Exception LOE
Lowercase Lower
Math
Noncharacter_Code_Point NChar
Pattern_Syntax Pat_Syn
Pattern_White_Space Pat_WS
Quotation_Mark QMark
Radical
Regional_Indicator RI
Sentence_Terminal STerm
Soft_Dotted SD
Terminal_Punctuation Term
Unified_Ideograph UIdeo
Uppercase Upper
Variation_Selector VS
White_Space space
XID_Continue XIDC
XID_Start XIDS`.split(/\s/)),Te=new Map;for(const e of Be)Te.set(Y(e),e);var Ft=new Set(["Basic_Emoji","Emoji_Keycap_Sequence","RGI_Emoji","RGI_Emoji_Flag_Sequence","RGI_Emoji_Modifier_Sequence","RGI_Emoji_Tag_Sequence","RGI_Emoji_ZWJ_Sequence"]),Ve=new Map;for(const e of Ft)Ve.set(Y(e),e);var Nt=new Map([["s",E(383)],[E(383),"s"]]),Mt=new Map([[E(223),E(7838)],[E(107),E(8490)],[E(229),E(8491)],[E(969),E(8486)]]),Rt=new Map([L(453),L(456),L(459),L(498),...se(8072,8079),...se(8088,8095),...se(8104,8111),L(8124),L(8140),L(8188)]),je=new Map([["alnum",d`[\p{Alpha}\p{Nd}]`],["alpha",d`\p{Alpha}`],["ascii",d`\p{ASCII}`],["blank",d`[\p{Zs}\t]`],["cntrl",d`\p{cntrl}`],["digit",d`\p{Nd}`],["graph",d`[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]`],["lower",d`\p{Lower}`],["print",d`[[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",d`[\p{P}\p{S}]`],["space",d`\p{space}`],["upper",d`\p{Upper}`],["word",d`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",d`\p{AHex}`]]),Lt=new Set(["alnum","blank","graph","print","word","xdigit"]);function Pt(e,t){const r=[];for(let s=e;s<=t;s++)r.push(s);return r}function Y(e){return e.replace(/[- _]+/g,"").toLowerCase()}function L(e){const t=E(e);return[t.toLowerCase(),t]}function se(e,t){return Pt(e,t).map(r=>L(r))}var We=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]),h={Alternator:"Alternator",Assertion:"Assertion",Backreference:"Backreference",Character:"Character",CharacterClassClose:"CharacterClassClose",CharacterClassHyphen:"CharacterClassHyphen",CharacterClassIntersector:"CharacterClassIntersector",CharacterClassOpen:"CharacterClassOpen",CharacterSet:"CharacterSet",Directive:"Directive",GroupClose:"GroupClose",GroupOpen:"GroupOpen",Subroutine:"Subroutine",Quantifier:"Quantifier",VariableLengthCharacterSet:"VariableLengthCharacterSet",EscapedNumber:"EscapedNumber"},v={any:"any",digit:"digit",dot:"dot",hex:"hex",non_newline:"non_newline",posix:"posix",property:"property",space:"space",word:"word"},ee={flags:"flags",keep:"keep"},A={absent_repeater:"absent_repeater",atomic:"atomic",capturing:"capturing",group:"group",lookahead:"lookahead",lookbehind:"lookbehind"},Ie=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]),He=d`\[\^?`,Qe=`c.? | C(?:-.?)?|${d`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${d`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${d`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${d`o\{[^\}]*\}?`}|${d`\d{1,3}`}`,qe=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Q=new RegExp(d`
  \\ (?:
    ${Qe}
    | [gk]<[^>]*>?
    | [gk]'[^']*'?
    | .
  )
  | \( (?: \? (?:
    [:=!>(]
    | <[=!]
    | <[^>]*>
    | '[^']*'
    | ~\|?
    | # (?:[^)\\] | \\.?)*
    | [imx\-]+[:)]
  )?)?
  | ${qe.source}
  | ${He}
  | .
`.replace(/\s+/g,""),"gsu"),ae=new RegExp(d`
  \\ (?:
    ${Qe}
    | .
  )
  | \[:[^:]*:\]
  | ${He}
  | &&
  | .
`.replace(/\s+/g,""),"gsu");function Xe(e,t="",r){if(r={captureGroup:!1,singleline:!1,...r},typeof e!="string")throw new Error("String expected as pattern");if(!/^[imxDSW]*$/.test(t))throw new Error(`Flags "${t}" includes unsupported value`);const s=t.includes("x"),n=[s],a={captureGroup:r.captureGroup,getCurrentModX:()=>n.at(-1),numOpenGroups:0,popModX(){n.pop()},pushModX(f){n.push(f)},replaceCurrentModX(f){n[n.length-1]=f},singleline:r.singleline};let i=[],o;for(Q.lastIndex=0;o=Q.exec(e);){const f=Ot(a,e,o[0],Q.lastIndex);f.tokens?i.push(...f.tokens):f.token&&i.push(f.token),f.lastIndex!==void 0&&(Q.lastIndex=f.lastIndex)}const c=[];let u=0;i.forEach(f=>{f.type===h.GroupOpen&&(f.kind===A.capturing?f.number=++u:f.raw==="("&&c.push(f))}),u||c.forEach((f,m)=>{f.kind=A.capturing,f.number=m+1});const l=u||c.length;return i=i.map(f=>f.type===h.EscapedNumber?Qt(f,l):f).flat(),{tokens:i,flags:{ignoreCase:t.includes("i"),dotAll:t.includes("m"),extended:s,digitIsAscii:t.includes("D"),spaceIsAscii:t.includes("S"),wordIsAscii:t.includes("W")},rules:r}}function Ot(e,t,r,s){const[n,a,i]=r;if(n==="["){const o=Dt(t,r,s);return{tokens:o.tokens,lastIndex:o.lastIndex}}if(n==="\\"){if("AbBGzZ".includes(a))return{token:C(h.Assertion,r,{kind:r})};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:C(h.Subroutine,r)}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:C(h.Backreference,r)}}if(a==="K")return{token:C(h.Directive,r,{kind:ee.keep})};if(a==="N")return{token:C(h.CharacterSet,r,{kind:v.non_newline})};if(a==="O")return{token:C(h.CharacterSet,r,{kind:v.any})};if("RX".includes(a))return{token:C(h.VariableLengthCharacterSet,r,{kind:r})};if("yY".includes(a))throw new Error(`Unsupported grapheme boundary "${r}"`);const o=ze(r,{inCharClass:!1});return Array.isArray(o)?{tokens:o}:{token:o}}if(n==="("){if(i==="#"){if(t[s]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:s+1}}if("-imx".includes(i))return{token:Tt(r,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,r==="("&&!e.captureGroup||r==="(?:")return{token:C(h.GroupOpen,r,{kind:A.group})};if(r==="(?>")return{token:C(h.GroupOpen,r,{kind:A.atomic})};if(r==="(?="||r==="(?!"||r==="(?<="||r==="(?<!")return{token:C(h.GroupOpen,r,{kind:i==="<"?A.lookbehind:A.lookahead,negate:r.endsWith("!")})};if(i==="<"||i==="'"||r==="("&&e.captureGroup){const o=C(h.GroupOpen,r,{kind:A.capturing});return r!=="("&&(o.name=r.slice(3,-1)),{token:o}}if(i==="~"){if(r==="(?~|")throw new Error(`Unsupported absent function kind "${r}"`);return{token:C(h.GroupOpen,r,{kind:A.absent_repeater})}}throw i==="("?new Error(`Unsupported conditional "${r}"`):r==="(?"?new Error("Invalid group"):new Error(`Unexpected group "${r}"`)}if(r===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:C(h.GroupClose,r)}}if(r==="#"&&e.getCurrentModX()){const o=t.indexOf(`
`,s);return{lastIndex:o===-1?t.length:o}}if(/^\s$/.test(r)&&e.getCurrentModX()){const o=/\s+/y;return o.lastIndex=s,{lastIndex:o.exec(t)?o.lastIndex:s}}if(r===".")return{token:C(h.CharacterSet,r,{kind:v.dot})};if(r==="^"||r==="$"){const o=e.singleline?{"^":d`\A`,$:d`\Z`}[r]:r;return{token:C(h.Assertion,r,{kind:o})}}return r==="|"?{token:C(h.Alternator,r)}:qe.test(r)?{token:Vt(r)}:(Ze(r),{token:C(h.Character,r,{value:r.codePointAt(0)})})}function Dt(e,t,r){const s=[C(h.CharacterClassOpen,t,{negate:t[1]==="^"})];let n=1,a;for(ae.lastIndex=r;a=ae.exec(e);){const i=a[0];if(i[0]==="["&&i[1]!==":")n++,s.push(C(h.CharacterClassOpen,i,{negate:i[1]==="^"}));else if(i==="]"){if(s.at(-1).type===h.CharacterClassOpen)s.push(C(h.Character,i,{value:93}));else if(n--,s.push(C(h.CharacterClassClose,i)),!n)break}else{const o=Ut(i);Array.isArray(o)?s.push(...o):s.push(o)}}return{tokens:s,lastIndex:ae.lastIndex||e.length}}function Ut(e){if(e[0]==="\\")return ze(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!je.get(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return C(h.CharacterSet,e,{kind:v.posix,negate:!!t.groups.negate,value:t.groups.name})}return e==="-"?C(h.CharacterClassHyphen,e):e==="&&"?C(h.CharacterClassIntersector,e):(Ze(e),C(h.Character,e,{value:e.codePointAt(0)}))}function ze(e,{inCharClass:t}){const r=e[1];if(r==="c"||r==="C")return Bt(e);if("dDhHsSwW".includes(r))return jt(e);if(e.startsWith(d`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Wt(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const s=e.split(/\\x/).slice(1).map(o=>parseInt(o,16)),n=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(s)),a=new TextEncoder;return[...n].map(o=>{const c=[...a.encode(o)].map(u=>`\\x${u.toString(16)}`).join("");return C(h.Character,c,{value:o.codePointAt(0)})})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(r==="u"||r==="x")return C(h.Character,e,{value:Ht(e)});if(Ie.has(r))return C(h.Character,e,{value:Ie.get(r)});if(/\d/.test(r))return C(h.EscapedNumber,e,{inCharClass:t});if(e==="\\")throw new Error(d`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return C(h.Character,e,{value:e.codePointAt(1)});throw new Error(`Unexpected escape "${e}"`)}function C(e,t,r){return{type:e,raw:t,...r}}function Bt(e){const t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return C(h.Character,e,{value:t.toUpperCase().codePointAt(0)-64})}function Tt(e,t){let{on:r,off:s}=/^\(\?(?<on>[imx]*)(?:-(?<off>[imx\-]*))?/.exec(e).groups;s??="";const n=(t.getCurrentModX()||r.includes("x"))&&!s.includes("x"),a=Ge(r),i=Ge(s),o={};if(a&&(o.enable=a),i&&(o.disable=i),e.endsWith(")"))return t.replaceCurrentModX(n),C(h.Directive,e,{kind:ee.flags,flags:o});if(e.endsWith(":")){t.pushModX(n),t.numOpenGroups++;const c=C(h.GroupOpen,e,{kind:A.group});return(a||i)&&(c.flags=o),c}throw new Error(`Unexpected flag modifier "${e}"`)}function Vt(e){const t={};if(e[0]==="{"){const{min:r,max:s}=/^\{(?<min>\d*)(?:,(?<max>\d*))?/.exec(e).groups,n=1e5;if(+r>n||+s>n)throw new Error("Quantifier value unsupported in Oniguruma");t.min=+r,t.max=s===void 0?+r:s===""?1/0:+s,t.greedy=!e.endsWith("?"),t.possessive=!1}else t.min=e[0]==="+"?1:0,t.max=e[0]==="?"?1:1/0,t.greedy=e[1]!=="?",t.possessive=e[1]==="+";return C(h.Quantifier,e,t)}function jt(e){const t=e[1].toLowerCase();return C(h.CharacterSet,e,{kind:{d:v.digit,h:v.hex,s:v.space,w:v.word}[t],negate:e[1]!==t})}function Wt(e){const{p:t,neg:r,value:s}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups,n=t==="P"&&!r||t==="p"&&!!r;return C(h.CharacterSet,e,{kind:v.property,negate:n,value:s})}function Ge(e){const t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function Ht(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 t=e[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Qt(e,t){const{raw:r,inCharClass:s}=e,n=r.slice(1);if(!s&&(n!=="0"&&n.length===1||n[0]!=="0"&&+n<=t))return[C(h.Backreference,r)];const a=[],i=n.match(/^[0-7]+|\d/g);for(let o=0;o<i.length;o++){const c=i[o];let u;if(o===0&&c!=="8"&&c!=="9"){if(u=parseInt(c,8),u>127)throw new Error(d`Octal encoded byte above 177 unsupported "${r}"`)}else u=c.codePointAt(0);a.push(C(h.Character,(o===0?"\\":"")+c,{value:u}))}return a}function Ze(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`)}function me({alternatives:e},t){return e.length===1&&e[0].elements.length===1&&(!t||t(e[0].elements[0]))}function qt({type:e}){return e===p.Assertion||e===p.Directive}function Xt(e){const t=[p.Character,p.CharacterClass,p.CharacterSet];return t.includes(e.type)||e.type===p.Quantifier&&e.min&&t.includes(e.element.type)}function Ke({type:e}){return e===p.CapturingGroup||e===p.Group}function W({type:e,kind:t}){return e===p.Assertion&&(t===w.lookahead||t===w.lookbehind)}function B(e,t,r){let s=e.node;for(;s.parent;)s=s.parent;function n(i,o){for(let c=0;c<i.length;c++){const u=a(i[c],o,c,i);c=Math.max(-1,c+u)}}function a(i,o=null,c=null,u=null){let l=0,f=!1;const m={node:i,parent:o,key:c,container:u,ast:s,remove(){M(u,"Container expected").splice(Math.max(0,c+l),1),l-=1},removeAllNextSiblings(){return M(u,"Container expected").splice(c+1)},removeAllPrevSiblings(){const _=c+l;return l-=_,M(u,"Container expected").splice(0,Math.max(0,_))},replaceWith(_){Zt(_,o),u?u[Math.max(0,c+l)]=_:o[c]=_},skip(){f=!0}},g=zt(i).find(_=>!!r[_]),b=g&&r[g],k=typeof b=="function"?b:b?.enter,S=b?.exit;if(k?.(m,t),!f)switch(i.type){case p.Regex:a(i.pattern,i,"pattern"),a(i.flags,i,"flags");break;case p.Alternative:case p.CharacterClass:n(i.elements,i);break;case p.Assertion:W(i)&&n(i.alternatives,i);break;case p.Backreference:case p.Character:case p.CharacterSet:case p.Directive:case p.Flags:case p.Recursion:case p.Subroutine:case p.VariableLengthCharacterSet:break;case p.AbsentFunction:case p.CapturingGroup:case p.Group:case p.Pattern:n(i.alternatives,i);break;case p.CharacterClassIntersection:n(i.classes,i);break;case p.CharacterClassRange:a(i.min,i,"min"),a(i.max,i,"max");break;case p.Quantifier:a(i.element,i,"element");break;default:throw new Error(`Unexpected node type "${i.type}"`)}return S?.(m,t),l}a(e.node,e.parent,e.key,e.container)}var Fe={AnyGroup:"AnyGroup",AnyNode:"AnyNode"};function zt(e){const t=[Fe.AnyNode];return(Ke(e)||W(e))&&t.push(Fe.AnyGroup),t.push(e.type),t}function Zt(e,t){"parent"in t&&(e.parent=t)}var p={AbsentFunction:"AbsentFunction",Alternative:"Alternative",Assertion:"Assertion",Backreference:"Backreference",CapturingGroup:"CapturingGroup",Character:"Character",CharacterClass:"CharacterClass",CharacterClassIntersection:"CharacterClassIntersection",CharacterClassRange:"CharacterClassRange",CharacterSet:"CharacterSet",Directive:"Directive",Flags:"Flags",Group:"Group",Pattern:"Pattern",Quantifier:"Quantifier",Regex:"Regex",Subroutine:"Subroutine",VariableLengthCharacterSet:"VariableLengthCharacterSet",Recursion:"Recursion"},Kt={repeater:"repeater"},w={line_end:"line_end",line_start:"line_start",lookahead:"lookahead",lookbehind:"lookbehind",search_start:"search_start",string_end:"string_end",string_end_newline:"string_end_newline",string_start:"string_start",word_boundary:"word_boundary"},y=v,q=ee,Z={grapheme:"grapheme",newline:"newline"};function Je({tokens:e,flags:t,rules:r},s){const n={skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,verbose:!1,...s},a={capturingGroups:[],current:0,hasNumberedRef:!1,namedGroupsByName:new Map,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],token:null,tokens:e,verbose:n.verbose,walk:i};function i(g,b){const k=e[a.current];switch(a.parent=g,a.token=k,a.current++,k.type){case h.Alternator:return P();case h.Assertion:return ir(k);case h.Backreference:return Jt(a);case h.Character:return tt(k.value,{useLastValid:!!b.isCheckingRangeEnd});case h.CharacterClassHyphen:return Yt(a,b);case h.CharacterClassOpen:return er(a,b);case h.CharacterSet:return tr(a);case h.Directive:return lr(k);case h.GroupOpen:return rr(a,b);case h.Quantifier:return nr(a);case h.Subroutine:return sr(a);case h.VariableLengthCharacterSet:return dr(k.kind);default:throw new Error(`Unexpected token type "${k.type}"`)}}const o=gr(fr(),pr(t));let c=o.pattern.alternatives[0];for(;a.current<e.length;){const g=i(c,{});g.type===p.Alternative?(o.pattern.alternatives.push(g),c=g):c.elements.push(g)}const{capturingGroups:u,hasNumberedRef:l,namedGroupsByName:f,subroutines:m}=a;if(l&&f.size&&!r.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:g}of m)if(typeof g=="number"){if(g>u.length)throw new Error("Subroutine uses a group number that's not defined")}else if(f.has(g)){if(f.get(g).length>1)throw new Error(d`Subroutine uses a duplicate group name "\g<${g}>"`)}else throw new Error(d`Subroutine uses a group name that's not defined "\g<${g}>"`);return B({node:o},null,{AnyNode({node:g,parent:b}){g.parent=b}}),o}function Jt(e){const{raw:t}=e.token,r=/^\\k[<']/.test(t),s=r?t.slice(3,-1):t.slice(1),n=(a,i=!1)=>{const o=e.capturingGroups.length;let c=!1;if(a>o)if(e.skipBackrefValidation)c=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,fe(i?o+1-a:a,{orphan:c})};if(r){const a=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(s);if(a)return n(+a.groups.num,!!a.groups.sign);if(/[-+]/.test(s))throw new Error(`Invalid backref name "${t}"`);if(!e.namedGroupsByName.has(s))throw new Error(`Group name not defined to the left "${t}"`);return fe(s)}return n(+s)}function Yt(e,t){const{parent:r,tokens:s,walk:n}=e,a=r.elements.at(-1),i=s[e.current];if(!t.isCheckingRangeEnd&&a&&a.type!==p.CharacterClass&&a.type!==p.CharacterClassRange&&i&&i.type!==h.CharacterClassOpen&&i.type!==h.CharacterClassClose&&i.type!==h.CharacterClassIntersector){const o=n(r,{...t,isCheckingRangeEnd:!0});if(a.type===p.Character&&o.type===p.Character)return r.elements.pop(),ur(a,o);throw new Error("Invalid character class range")}return tt(45)}function er(e,t){const{token:r,tokens:s,verbose:n,walk:a}=e,i=s[e.current];let o=ge({negate:r.negate});const c=o.elements[0];let u=Ne(i);for(;u.type!==h.CharacterClassClose;){if(u.type===h.CharacterClassIntersector)c.classes.push(ge({negate:!1,baseOnly:!0})),e.current++;else{const l=c.classes.at(-1);l.elements.push(a(l,t))}u=Ne(s[e.current],i)}if(n||br(c),c.classes.length===1){const l=c.classes[0];l.negate=o.negate!==l.negate,o=l}return e.current++,o}function tr({token:e,skipPropertyNameValidation:t}){let{kind:r,negate:s,value:n}=e;if(r===v.property){const a=Y(n);if(Lt.has(a))r=v.posix,n=a;else return D(n,{negate:s,skipPropertyNameValidation:t})}return r===v.posix?{type:p.CharacterSet,kind:y.posix,negate:s,value:n}:he(r,{negate:s})}function rr(e,t){const{token:r,tokens:s,capturingGroups:n,namedGroupsByName:a,skipLookbehindValidation:i,verbose:o,walk:c}=e;let u=or(r);const l=u.type===p.AbsentFunction,f=u.kind===w.lookbehind,m=f&&u.negate;if(u.type===p.CapturingGroup&&(n.push(u),u.name&&z(a,u.name,[]).push(u)),l&&t.isInAbsentFunction)throw new Error("Nested absent function not supported by Oniguruma");let g=Me(s[e.current]);for(;g.type!==h.GroupClose;){if(g.type===h.Alternator)u.alternatives.push(P()),e.current++;else{const b=u.alternatives.at(-1),k=c(b,{...t,isInAbsentFunction:t.isInAbsentFunction||l,isInLookbehind:t.isInLookbehind||f,isInNegLookbehind:t.isInNegLookbehind||m});if(b.elements.push(k),(f||t.isInLookbehind)&&!i){const S="Lookbehind includes a pattern not allowed by Oniguruma";if(m||t.isInNegLookbehind){if(k.kind===w.lookahead||k.type===p.CapturingGroup)throw new Error(S)}else if(k.kind===w.lookahead||k.kind===w.lookbehind&&k.negate)throw new Error(S)}}g=Me(s[e.current])}return o||(u=mr(u)),e.current++,u}function nr({token:e,parent:t}){const{min:r,max:s,greedy:n,possessive:a}=e,i=t.elements.at(-1);if(!i||i.type===p.Assertion||i.type===p.Directive)throw new Error("Quantifier requires a repeatable token");const o=rt(i,r,s,n,a);return t.elements.pop(),o}function sr(e){const{token:t,capturingGroups:r,subroutines:s}=e;let n=t.raw.slice(3,-1);const a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(n);if(a){const o=+a.groups.num,c=r.length;if(e.hasNumberedRef=!0,n={"":o,"+":c+o,"-":c+1-o}[a.groups.sign],n<1)throw new Error("Invalid subroutine number")}else n==="0"&&(n=0);const i=hr(n);return s.push(i),i}function ar(e){return{type:p.AbsentFunction,kind:e,alternatives:[P()]}}function P(){return{type:p.Alternative,elements:[]}}function Ye(e,t){const r=!!t?.negate;return{type:p.Assertion,kind:e,...e===w.word_boundary&&{negate:r}}}function ir({kind:e}){return Ye(M({"^":w.line_start,$:w.line_end,"\\A":w.string_start,"\\b":w.word_boundary,"\\B":w.word_boundary,"\\G":w.search_start,"\\z":w.string_end,"\\Z":w.string_end_newline}[e],`Unexpected assertion kind "${e}"`),{negate:e===d`\B`})}function fe(e,t){const r=!!t?.orphan;return{type:p.Backreference,...r&&{orphan:r},ref:e}}function or({flags:e,kind:t,name:r,negate:s,number:n}){switch(t){case A.absent_repeater:return ar(Kt.repeater);case A.atomic:return G({atomic:!0});case A.capturing:return et(n,r);case A.group:return G({flags:e});case A.lookahead:case A.lookbehind:return V({behind:t===A.lookbehind,negate:s});default:throw new Error(`Unexpected group kind "${t}"`)}}function et(e,t){const r=t!==void 0;if(r&&!wr(t))throw new Error(`Group name "${t}" invalid in Oniguruma`);return{type:p.CapturingGroup,number:e,...r&&{name:t},alternatives:[P()]}}function tt(e,t){const r={useLastValid:!1,...t};if(e>1114111){const s=e.toString(16);if(r.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${s}}"`):new Error(`Invalid code point out of range in JS "\\x{${s}}"`)}return{type:p.Character,value:e}}function ge(e){const t={baseOnly:!1,negate:!1,...e};return{type:p.CharacterClass,negate:t.negate,elements:t.baseOnly?[]:[cr()]}}function cr(){return{type:p.CharacterClassIntersection,classes:[ge({negate:!1,baseOnly:!0})]}}function ur(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:p.CharacterClassRange,min:e,max:t}}function he(e,{negate:t}){const r={type:p.CharacterSet,kind:M(y[e],`Unexpected character set kind "${e}"`)};return(e===v.digit||e===v.hex||e===v.space||e===v.word)&&(r.negate=t),r}function lr({kind:e,flags:t}){const r={type:p.Directive,kind:M(q[e],`Unexpected directive kind "${e}"`)};return e===ee.flags&&(r.flags=t),r}function pr({ignoreCase:e,dotAll:t,extended:r,digitIsAscii:s,spaceIsAscii:n,wordIsAscii:a}){return{type:p.Flags,ignoreCase:e,dotAll:t,extended:r,digitIsAscii:s,spaceIsAscii:n,wordIsAscii:a}}function G(e){const t=e?.atomic,r=e?.flags;return{type:p.Group,...t&&{atomic:t},...r&&{flags:r},alternatives:[P()]}}function V(e){const t={behind:!1,negate:!1,...e};return{type:p.Assertion,kind:t.behind?w.lookbehind:w.lookahead,negate:t.negate,alternatives:[P()]}}function fr(){return{type:p.Pattern,alternatives:[P()]}}function rt(e,t,r,s=!0,n=!1){const a={type:p.Quantifier,min:t,max:r,greedy:s,possessive:n,element:e};return r<t?{...a,min:r,max:t,possessive:!0}:a}function gr(e,t){return{type:p.Regex,pattern:e,flags:t}}function hr(e){return{type:p.Subroutine,ref:e}}function D(e,t){const r={negate:!1,skipPropertyNameValidation:!1,...t};return{type:p.CharacterSet,kind:y.property,value:r.skipPropertyNameValidation?e:Cr(e),negate:r.negate}}function dr(e){return{type:p.VariableLengthCharacterSet,kind:M({"\\R":Z.newline,"\\X":Z.grapheme}[e],`Unexpected varcharset kind "${e}"`)}}function Cr(e){const t=Y(e);if(Ve.has(t))throw new Error(d`Unicode property "\p{${e}}" unsupported in Oniguruma`);const r=Te.get(t);return r||e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,s=>s[0].toUpperCase()+s.slice(1).toLowerCase())}function mr(e){const t=e.alternatives[0].elements[0];return e.type===p.Group&&me(e,r=>r.type===p.Group)&&!(e.atomic&&t.flags)&&!(e.flags&&(t.atomic||t.flags))?(e.atomic?t.atomic=!0:e.flags&&(t.flags=e.flags),t):e}function wr(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function br(e){for(let t=0;t<e.classes.length;t++){const r=e.classes[t],s=r.elements[0];r.elements.length===1&&s.type===p.CharacterClass&&(e.classes[t]=s,s.negate=r.negate!==s.negate)}}function Ne(e,t){return M(e,`${t?.value===93?"Empty":"Unclosed"} character class`)}function Me(e){return M(e,"Unclosed group")}function kr(e,t){const r={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t},s={accuracy:r.accuracy,asciiWordBoundaries:r.asciiWordBoundaries,avoidSubclass:r.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:pe(r.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};B({node:e},s,nt);const n={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:n,prevFlags:null,globalFlags:n,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:s.subroutineRefMap};B({node:e},a,st);const i={groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer};return B({node:e},i,yr),e._strategy=s.strategy,e}var nt={AbsentFunction({node:e,replaceWith:t}){const r=N(G(),[j(V({negate:!0}),e.alternatives),D("Any")]),s=rt(r,0,1/0);r.parent=s,t(N(G(),[s]))},Alternative:{enter({node:e,parent:t,key:r},{flagDirectivesByAlt:s}){const n=e.elements.filter(a=>a.kind===q.flags);for(let a=r+1;a<t.alternatives.length;a++){const i=t.alternatives[a];z(s,i,[]).push(...n)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){const r=it(t.get(e));if(r){const s=N(G({flags:r}),e.elements);s.parent=e,e.elements=[s]}}}},Assertion({node:e,key:t,container:r,ast:s,remove:n,replaceWith:a},i){const{kind:o,negate:c}=e,{asciiWordBoundaries:u,avoidSubclass:l,supportedGNodes:f,wordIsAscii:m}=i;if(o===w.line_end)a(I(d`(?=\z|\n)`));else if(o===w.line_start)a(I(d`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}));else if(o===w.lookbehind)i.passedLookbehind=!0;else if(o===w.search_start)if(f.has(e))s.flags.sticky=!0,n();else{const g=r[t-1];if(g&&Xt(g))a(N(V({negate:!0})));else{if(l)throw new Error(d`Uses "\G" in a way that requires a subclass`);a(Ye(w.string_start)),i.strategy="search_start_clip"}}else if(o===w.string_end_newline)a(I(d`(?=\n?\z)`));else if(o===w.word_boundary&&!m&&!u){const g=`(?:(?<=${F})(?!${F})|(?<!${F})(?=${F}))`,b=`(?:(?<=${F})(?=${F})|(?<!${F})(?!${F}))`;a(I(c?b:g))}},Backreference({node:e},{jsGroupNameMap:t}){let{ref:r}=e;typeof r=="string"&&!oe(r)&&(r=ie(r,t),e.ref=r)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:r}){let{name:s}=e;s&&!oe(s)&&(s=ie(s,t),e.name=s),r.set(e.number,e),s&&r.set(s,e)},CharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s,digitIsAscii:n,spaceIsAscii:a,wordIsAscii:i}){const{kind:o,negate:c,value:u}=e;if(n&&(o===y.digit||u==="digit")){t(he(y.digit,{negate:c}));return}if(a&&(o===y.space||u==="space")){t(ce(I(Er),c));return}if(i&&(o===y.word||u==="word")){t(he(y.word,{negate:c}));return}if(o===y.any)t(D("Any"));else if(o===y.digit)t(D("Nd",{negate:c}));else if(o===y.hex)t(D("AHex",{negate:c}));else if(o===y.non_newline)t(I(d`[^\n]`));else if(o===y.space)t(D("space",{negate:c}));else if(o===y.word)t(ce(I(F),c));else if(o===y.property)Be.has(u)||(e.key="sc");else if(o===y.posix)if(!s&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let l={graph:"!-~",print:" -~"}[u];c&&(l=`\0-${E(l.codePointAt(0)-1)}${E(l.codePointAt(2)+1)}-􏿿`),t(I(`[${l}]`))}else t(ce(I(je.get(u)),c))},Directive(e,t){const{node:r,parent:s,ast:n,remove:a,replaceWith:i,removeAllPrevSiblings:o,removeAllNextSiblings:c}=e,{kind:u,flags:l}=r;if(u===q.flags)if(!l.enable&&!l.disable)a();else{const f=N(G({flags:l}),c());i(f),lt(f,e,t,nt)}else if(u===q.keep){const f=n.pattern.alternatives[0].elements[0],g=me(n.pattern,b=>b.type===p.Group)&&f.alternatives.length===1?f:n.pattern;if(s.parent!==g||g.alternatives.length>1)throw new Error(d`Uses "\K" in a way that's unsupported`);i(N(V({behind:!0}),o()))}},Flags({node:e,parent:t}){["digitIsAscii","extended","spaceIsAscii","wordIsAscii"].forEach(r=>delete e[r]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:r}=e.flags;t?.extended&&delete t.extended,r?.extended&&delete r.extended,t?.dotAll&&r?.dotAll&&delete t.dotAll,t?.ignoreCase&&r?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,r&&!Object.keys(r).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},Pattern:{enter({node:e},{supportedGNodes:t}){const r=[];let s=!1,n=!1;for(const a of e.alternatives)if(a.elements.length===1&&a.elements[0].kind===w.search_start)a.elements.pop();else{const i=ct(a.elements);i?(s=!0,Array.isArray(i)?r.push(...i):r.push(i)):n=!0}s&&!n&&r.forEach(a=>t.add(a))},exit(e,{accuracy:t,passedLookbehind:r,strategy:s}){if(t==="strict"&&r&&s)throw new Error(d`Uses "\G" in a way that requires non-strict accuracy`)}},Quantifier({node:e}){if(e.element.type===p.Quantifier){const t=N(G(),[e.element]);t.parent=e,e.element=t}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:r}=e;typeof r=="string"&&!oe(r)&&(r=ie(r,t),e.ref=r)},VariableLengthCharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s}){const{kind:n}=e;if(n===Z.newline)t(I(`(?>\r
?|[
\v\f\u2028\u2029])`));else if(n===Z.grapheme){if(r==="strict")throw new Error(d`Use of "\X" requires non-strict accuracy`);const a=s?d`\p{RGI_Emoji}`:dt().source.replace(/\\u\{/g,"\\x{");t(I(d`(?>\r\n|${a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}))}else throw new Error(`Unexpected varcharset kind "${n}"`)}},st={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:r}){const{orphan:s,ref:n}=e;s||r.set(e,[...t.get(n).map(({node:a})=>a)])},CapturingGroup:{enter({node:e,replaceWith:t,skip:r},{groupOriginByCopy:s,groupsByName:n,multiplexCapturesToLeftByRef:a,openRefs:i,reffedNodesByReferencer:o}){const c=s.get(e);if(c&&i.has(e.number)){const l=Re(e.number);o.set(l,i.get(e.number)),t(l),r();return}i.set(e.number,e),a.set(e.number,[]),e.name&&z(a,e.name,[]);const u=a.get(e.name??e.number);for(let l=0;l<u.length;l++){const f=u[l];if(c===f.node||c&&c===f.origin||e===f.origin){u.splice(l,1);break}}if(a.get(e.number).push({node:e,origin:c}),e.name&&a.get(e.name).push({node:e,origin:c}),e.name){const l=z(n,e.name,new Map);let f=!1;if(c)f=!0;else for(const m of l.values())if(!m.hasDuplicateNameToRemove){f=!0;break}n.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:f})}c&&(e._originNumber=c.number)},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=X(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Recursion({node:e,parent:t},{reffedNodesByReferencer:r}){const{ref:s}=e;let n=t;for(;(n=n.parent)&&!(n.type===p.CapturingGroup&&(n.name===s||n.number===s)););r.set(e,n)},Subroutine(e,t){const{node:r,replaceWith:s}=e,{ref:n}=r,a=t.subroutineRefMap.get(n),i=n===0,o=i?Re(0):at(a,t.groupOriginByCopy,null);let c=o;if(!i){const u=it(Sr(a,f=>f.type===p.Group&&!!f.flags)),l=u?X(t.globalFlags,u):t.globalFlags;vr(l,t.currentFlags)||(c=N(G({flags:$r(l)}),[o]))}s(c),i||lt(c,e,t,st)}},yr={Backreference({node:e,replaceWith:t},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const n=r.reffedNodesByReferencer.get(e).filter(a=>Ar(a,e));if(!n.length)t(N(V({negate:!0})));else if(n.length>1){const a=n.map(i=>j(P(),[fe(i.number)]));t(j(G(),a))}else e.ref=n[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Recursion({node:e},t){e.ref!==0&&(e.ref=t.reffedNodesByReferencer.get(e).number)},Regex:{exit({node:e},t){const r=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let s=0;s<r;s++){const n=et();e.pattern.alternatives.at(-1).elements.push(n)}}}},Er="[	-\r ]",F=d`[\p{L}\p{M}\p{N}\p{Pc}]`;function j(e,t){return t.forEach(r=>r.parent=e),e[we(e)]=t,e}function vr(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Ar(e,t){let r=t;do{if(r.type===p.Pattern)return!1;if(r.type===p.Alternative)continue;if(r===e)return!1;const s=ot(r.parent);for(const n of s){if(n===r)break;if(n===e||ut(n,e))return!0}}while(r=r.parent);throw new Error("Unexpected path")}function at(e,t,r,s){const n=Array.isArray(e)?[]:{};for(const[a,i]of Object.entries(e))a==="parent"?n.parent=Array.isArray(r)?s:r:i&&typeof i=="object"?n[a]=at(i,t,n,r):(a==="type"&&i===p.CapturingGroup&&t.set(n,t.get(e)??e),n[a]=i);return n}function Re(e){return{type:p.Recursion,ref:e}}function Sr(e,t){const r=[];for(;e=e.parent;)(!t||t(e))&&r.push(e);return r}function ie(e,t){if(t.has(e))return t.get(e);const r=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,r),r}function we(e){for(const t of["alternatives","classes","elements"])if(e[t])return t;return null}function it(e){const t=["dotAll","ignoreCase"],r={enable:{},disable:{}};return e.forEach(({flags:s})=>{t.forEach(n=>{s.enable?.[n]&&(delete r.disable[n],r.enable[n]=!0),s.disable?.[n]&&(r.disable[n]=!0)})}),Object.keys(r.enable).length||delete r.enable,Object.keys(r.disable).length||delete r.disable,r.enable||r.disable?r:null}function $r({dotAll:e,ignoreCase:t}){const r={};return(e||t)&&(r.enable={},e&&(r.enable.dotAll=!0),t&&(r.enable.ignoreCase=!0)),(!e||!t)&&(r.disable={},!e&&(r.disable.dotAll=!0),!t&&(r.disable.ignoreCase=!0)),r}function ot(e){if(!e)throw new Error("Node expected");if(e.type===p.Quantifier)return[e.element];const t=we(e);return t&&e[t]}function ct(e){const t=e.find(r=>r.kind===w.search_start||_r(r,{negate:!1})||!qt(r));if(!t)return null;if(t.kind===w.search_start)return t;if(W(t))return t.alternatives[0].elements[0];if(Ke(t)){const r=[];for(const s of t.alternatives){const n=ct(s.elements);if(!n)return null;Array.isArray(n)?r.push(...n):r.push(n)}return r}return null}function ut(e,t){const r=ot(e)??[];for(const s of r)if(s===t||ut(s,t))return!0;return!1}function _r(e,t){const r={negate:null,...t};return W(e)&&(r.negate===null||e.negate===r.negate)&&me(e,s=>s.kind===w.search_start)}function oe(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function I(e,t){const s=Je(Xe(e),t).pattern.alternatives;return s.length>1||s[0].elements.length>1?j(G(),s):s[0].elements[0]}function N(e,t){const r=we(e);return e[r][0].parent=e,t&&j(e[r][0],t),e}function ce(e,t){return e.negate=t,e}function lt(e,{parent:t,key:r,container:s},n,a){B({node:e,parent:t,key:r,container:s},n,a)}function xr(e,t){const r=De(t),s=pe(r.target,"ES2024"),n=pe(r.target,"ES2025"),a=r.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,o=null;if(!n){const g=[e.flags.ignoreCase];B({node:e},{getCurrentModI:()=>g.at(-1),popModI(){g.pop()},pushModI(b){g.push(b)},setHasCasedChar(){g.at(-1)?i=!0:o=!0}},Ir)}const c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||i)&&!o)};let u=null;const l={accuracy:r.accuracy,appliedGlobalFlags:c,avoidSubclass:r.avoidSubclass,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:u,recursionLimit:a,useAppliedIgnoreCase:!!(!n&&i&&o),useFlagMods:n,useFlagV:s,verbose:r.verbose};function f(g){switch(l.lastNode=u,u=g,g.type){case p.Regex:return{pattern:f(g.pattern),flags:f(g.flags),options:{...g.options}};case p.Alternative:return g.elements.map(f).join("");case p.Assertion:return Rr(g,l,f);case p.Backreference:return Lr(g,l);case p.CapturingGroup:return Pr(g,l,f);case p.Character:return Or(g,l);case p.CharacterClass:return Dr(g,l,f);case p.CharacterClassIntersection:if(!l.useFlagV)throw new Error("Use of class intersection requires min target ES2024");return g.classes.map(f).join("&&");case p.CharacterClassRange:return Ur(g,l);case p.CharacterSet:return Br(g,l);case p.Flags:return Tr(g,l);case p.Group:return Vr(g,l,f);case p.Pattern:return g.alternatives.map(f).join("|");case p.Quantifier:return f(g.element)+Qr(g);case p.Recursion:return jr(g,l);default:throw new Error(`Unexpected node type "${g.type}"`)}}const m=f(e);return s||(delete m.options.force.v,m.options.disable.v=!0,m.options.unicodeSetsPlugin=null),m}var Ir={AnyGroup:{enter({node:e},t){const r=t.getCurrentModI();t.pushModI(e.flags?X({ignoreCase:r},e.flags).ignoreCase:r)},exit(e,t){t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){be(E(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},r){t(),pt(e,{firstOnly:!0}).length&&r.setHasCasedChar()},CharacterSet({node:e},t){e.kind===y.property&&We.has(e.value)&&t.setHasCasedChar()}},Gr=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Fr=new Set(["-","\\","]","^","["]),Nr=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Le=new Map([[9,d`\t`],[10,d`\n`],[11,d`\v`],[12,d`\f`],[13,d`\r`],[8232,d`\u2028`],[8233,d`\u2029`],[65279,d`\uFEFF`]]),Mr=new RegExp("^\\p{Cased}$","u");function be(e){return Mr.test(e)}function Rr(e,t,r){const{kind:s,negate:n,alternatives:a}=e;if(W(e))return`(?${`${s===w.lookahead?"":"<"}${n?"!":"="}`}${a.map(r).join("|")})`;if(s===w.string_end)return"$";if(s===w.string_start)return"^";if(s===w.word_boundary)return n?d`\B`:d`\b`;throw new Error(`Unexpected assertion kind "${s}"`)}function Lr({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.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}function Pr({name:e,number:t,alternatives:r,_originNumber:s},n,a){return n.captureMap.set(t,{ignoreCase:n.currentFlags.ignoreCase}),`(${e?`?<${e}>`:""}${!n.avoidSubclass&&s?`${s<t?`$${s}`:""}${O}`:""}${r.map(a).join("|")})`}function Or({value:e},t){const r=E(e),s=U(e,{isAfterBackref:t.lastNode.type===p.Backreference,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(s!==r)return s;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&be(r)){const n=Ue(r);return t.inCharClass?n.join(""):n.length>1?`[${n.join("")}]`:n[0]}return r}function Dr({negate:e,parent:t,elements:r},s,n){const a=()=>`[${e?"^":""}${r.map(n).join("")}]`;if(!s.inCharClass){s.inCharClass=!0;const o=a();return s.inCharClass=!1,o}const i=r[0]?.type;if(!e&&i&&((!s.useFlagV||!s.verbose)&&t.type===p.CharacterClass&&i!==p.CharacterClassIntersection||!s.verbose&&t.type===p.CharacterClassIntersection&&r.length===1&&i!==p.CharacterClass&&i!==p.CharacterClassRange))return r.map(n).join("");if(!s.useFlagV&&t.type===p.CharacterClass)throw new Error("Use of nested character class requires min target ES2024");return a()}function Ur(e,t){const r=e.min.value,s=e.max.value,n={isAfterBackref:!1,inCharClass:!0,useFlagV:t.useFlagV},a=U(r,n),i=U(s,n),o=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const c=pt(e);Wr(c).forEach(l=>{o.add(Array.isArray(l)?`${U(l[0],n)}-${U(l[1],n)}`:U(l,n))})}return`${a}-${i}${[...o].join("")}`}function Br({kind:e,negate:t,value:r,key:s},n){if(e===y.dot)return n.currentFlags.dotAll?n.appliedGlobalFlags.dotAll||n.useFlagMods?".":"[^]":d`[^\n]`;if(e===y.digit)return t?d`\D`:d`\d`;if(e===y.property){if(n.useAppliedIgnoreCase&&n.currentFlags.ignoreCase&&We.has(r))throw new Error(`Unicode property "${r}" can't be case-insensitive when other chars have specific case`);return`${t?d`\P`:d`\p`}{${s?`${s}=`:""}${r}}`}if(e===y.word)return t?d`\W`:d`\w`;throw new Error(`Unexpected character set kind "${e}"`)}function Tr(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")}function Vr({atomic:e,flags:t,parent:r,alternatives:s},n,a){const i=n.currentFlags;t&&(n.currentFlags=X(i,t));const o=s.map(a).join("|"),c=!n.verbose&&s.length===1&&r.type!==p.Quantifier&&!e&&(!n.useFlagMods||!t)?o:`(?${Hr(e,t,n.useFlagMods)}${o})`;return n.currentFlags=i,c}function jr({ref:e},t){const r=t.recursionLimit;return e===0?`(?R=${r})`:d`\g<${e}&R=${r}>`}function pt(e,t){const r=!!t?.firstOnly,s=e.min.value,n=e.max.value,a=[];if(s<65&&(n===65535||n>=131071)||s===65536&&n>=131071)return a;for(let i=s;i<=n;i++){const o=E(i);if(!be(o))continue;const c=Ue(o).filter(u=>{const l=u.codePointAt(0);return l<s||l>n});if(c.length&&(a.push(...c),r))break}return a}function U(e,{isAfterBackref:t,inCharClass:r,useFlagV:s}){if(Le.has(e))return Le.get(e);if(e<32||e>126&&e<160||e>262143||t&&qr(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const n=r?s?Nr:Fr:Gr,a=E(e);return(n.has(a)?"\\":"")+a}function Wr(e){const t=e.map(n=>n.codePointAt(0)).sort((n,a)=>n-a),r=[];let s=null;for(let n=0;n<t.length;n++)t[n+1]===t[n]+1?s??=t[n]:s===null?r.push(t[n]):(r.push([s,t[n]]),s=null);return r}function Hr(e,t,r){if(e)return">";let s="";if(t&&r){const{enable:n,disable:a}=t;s=(n?.ignoreCase?"i":"")+(n?.dotAll?"s":"")+(a?"-":"")+(a?.ignoreCase?"i":"")+(a?.dotAll?"s":"")}return`${s}:`}function Qr({min:e,max:t,greedy:r,possessive:s}){let n;return!e&&t===1?n="?":!e&&t===1/0?n="*":e===1&&t===1/0?n="+":e===t?n=`{${e}}`:n=`{${e},${t===1/0?"":t}}`,n+(s?"+":r?"":"?")}function qr(e){return e>47&&e<58}var Xr=class ft extends Ce{#e;rawArgs;constructor(t,r,s){if(t instanceof RegExp){if(s)throw new Error("Cannot provide options when copying a regexp");super(t,r),t instanceof ft?(this.#e=t.#e,this.rawArgs=t.rawArgs):(this.#e=null,this.rawArgs={pattern:t.source,flags:t.flags,options:{}}),r!==void 0&&(this.rawArgs.flags=r)}else{const n={strategy:null,useEmulationGroups:!1,...s};super(t,r,{useEmulationGroups:n.useEmulationGroups}),this.#e=n.strategy,this.rawArgs={pattern:t,flags:r??"",options:{...n.strategy&&{strategy:n.strategy},...n.useEmulationGroups&&{useEmulationGroups:!0}}}}}exec(t){const r=super.exec,s=this.global||this.sticky,n=this.lastIndex;if(this.#e==="search_start_clip"&&s&&n){this.lastIndex=0;const a=r.call(this,t.slice(n));return a&&(zr(a,this,t,n),this.lastIndex+=n),a}return r.call(this,t)}};function zr(e,t,r,s){if(e.input=r,e.index+=s,t.hasIndices){const n=e.indices;for(let i=0;i<n.length;i++){const o=n[i];o&&(n[i]=[o[0]+s,o[1]+s])}const a=n.groups;a&&Object.keys(a).forEach(i=>{const o=a[i];o&&(a[i]=[o[0]+s,o[1]+s])})}}function Zr(e,t){const r=De(t),s=r.avoidSubclass,n=Xe(e,r.flags,{captureGroup:r.rules.captureGroup,singleline:r.rules.singleline}),a=Je(n,{skipBackrefValidation:r.rules.allowOrphanBackrefs,verbose:r.verbose}),i=kr(a,{accuracy:r.accuracy,asciiWordBoundaries:r.rules.asciiWordBoundaries,avoidSubclass:s,bestEffortTarget:r.target}),o=xr(i,r),c={useEmulationGroups:!s},u={pattern:Et(vt(St(o.pattern,c)),c),flags:`${r.hasIndices?"d":""}${r.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`},l=!s&&u.pattern.includes(O),f=i._strategy;return(l||f)&&(u.options={...f&&{strategy:f},...l&&{useEmulationGroups:l}}),u}function Kr(e,t){const r=Zr(e,t);return r.options?new Xr(r.pattern,r.flags,r.options):new RegExp(r.pattern,r.flags)}const Pe=4294967295;class Jr{constructor(t,r={}){this.patterns=t,this.options=r;const{forgiving:s=!1,cache:n,regexConstructor:a}=r;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=t.map(i=>{if(typeof i!="string")return i;const o=n?.get(i);if(o){if(o instanceof RegExp)return o;if(s)return null;throw o}try{const c=a(i);return n?.set(i,c),c}catch(c){if(n?.set(i,c),s)return null;throw c}})}regexps;findNextMatchSync(t,r,s){const n=typeof t=="string"?t:t.content,a=[];function i(o,c,u=0){return{index:o,captureIndices:c.indices.map(l=>l==null?{start:Pe,end:Pe,length:0}:{start:l[0]+u,end:l[1]+u,length:l[1]-l[0]})}}for(let o=0;o<this.regexps.length;o++){const c=this.regexps[o];if(c)try{c.lastIndex=r;const u=c.exec(n);if(!u)continue;if(u.index===r)return i(o,u,0);a.push([o,u,0])}catch(u){if(this.options.forgiving)continue;throw u}}if(a.length){const o=Math.min(...a.map(c=>c[1].index));for(const[c,u,l]of a)if(u.index===o)return i(c,u,l)}return null}}function Yr(e,t){return Kr(e,{global:!0,hasIndices:!0,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function en(e={}){const t=Object.assign({target:"auto",cache:new Map},e);return t.regexConstructor||=r=>Yr(r,{target:t.target}),{createScanner(r){return new Jr(r,t)},createString(r){return{content:r}}}}export{Jr as J,en as c,Yr as d};
