oniguruma-to-es
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -1,4 +0,4 @@ | ||
var OnigurumaToES=(()=>{var ue=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var $t=Object.prototype.hasOwnProperty;var vt=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},Ft=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _t(t))!$t.call(e,n)&&n!==r&&ue(e,n,{get:()=>t[n],enumerable:!(s=At(t,n))||s.enumerable});return e};var It=e=>Ft(ue({},"__esModule",{value:!0}),e);var Hr={};vt(Hr,{EmulatedRegExp:()=>X,toDetails:()=>bt,toOnigurumaAst:()=>Kr,toRegExp:()=>Wr});var k=String.fromCodePoint,f=String.raw,Ie=(()=>{try{new RegExp("(?<n>)|(?<n>)")}catch{return!1}return!0})(),Ge=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),Pe=(()=>{try{new RegExp("","v")}catch{return!1}return!0})();function O(e,{enable:t,disable:r}){return{dotAll:!r?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!r?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function U(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}function B(e,t){return le[e]>=le[t]}function _(e,t){if(!e)throw new Error(t??"Value expected");return e}var le={ES2018:2018,ES2024:2024,ES2025:2025},Gt={auto:"auto",ES2018:"ES2018",ES2024:"ES2024",ES2025:"ES2025"};function J(e){if(e?.target!==void 0&&!Gt[e.target])throw new Error(`Unexpected target "${e.target}"`);let t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,maxRecursionDepth:5,target:"auto",tmGrammar:!1,verbose:!1,...e};return t.target==="auto"&&(t.target=Ie&&Ge?"ES2025":Pe?"ES2024":"ES2018"),t}var Pt=new Set([k(304),k(305)]);function fe(e){if(Pt.has(e))return[e];let t=new Set,r=e.toLowerCase(),s=r.toUpperCase(),n=Tt.get(r),a=Mt.get(r),o=Rt.get(r);return[...s].length===1&&t.add(s),o&&t.add(o),n&&t.add(n),t.add(r),a&&t.add(a),[...t]}var ge=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"]),he=new Map;for(let e of ge)he.set(V(e),e);var Nt=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"]),de=new Map;for(let e of Nt)de.set(V(e),e);var Ne=new Set("Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo Extended_Pictographic Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi EBase EComp EMod EPres ExtPict Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz".split(" ")),Mt=new Map([["s",k(383)],[k(383),"s"]]),Rt=new Map([[k(223),k(7838)],[k(107),k(8490)],[k(229),k(8491)],[k(969),k(8486)]]),Tt=new Map([G(453),G(456),G(459),G(498),...pe(8072,8079),...pe(8088,8095),...pe(8104,8111),G(8124),G(8140),G(8188)]),Y=new Map([["alnum",f`[\p{Alpha}\p{Nd}]`],["alpha",f`\p{Alpha}`],["ascii",f`\p{ASCII}`],["blank",f`[\p{Zs}\t]`],["cntrl",f`\p{cntrl}`],["digit",f`\p{Nd}`],["graph",f`[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]`],["lower",f`\p{Lower}`],["print",f`[[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",f`[\p{P}\p{S}]`],["space",f`\p{space}`],["upper",f`\p{Upper}`],["word",f`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",f`\p{AHex}`]]),Me=new Set(["alnum","blank","graph","print","word","xdigit"]);function Ot(e,t){let r=[];for(let s=e;s<=t;s++)r.push(s);return r}function V(e){return e.replace(/[- _]+/g,"").toLowerCase()}function G(e){let t=k(e);return[t.toLowerCase(),t]}function pe(e,t){return Ot(e,t).map(r=>G(r))}var Ce=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var g={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"},E={any:"any",digit:"digit",dot:"dot",hex:"hex",non_newline:"non_newline",posix:"posix",property:"property",space:"space",word:"word"},j={flags:"flags",keep:"keep"},x={atomic:"atomic",capturing:"capturing",group:"group",lookahead:"lookahead",lookbehind:"lookbehind"},Re=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]),Ue=f`\[\^?\]?`,De=`c.? | C(?:-.?)?|${f`[pP]\{(?:\^?[\x20\w]+\})?`}|${f`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${f`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${f`o\{[^\}]*\}?`}|${f`\d{1,3}`}`,Le=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,ee=new RegExp(f` | ||
var OnigurumaToES=(()=>{var pe=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var It=(e,t)=>{for(var r in t)pe(e,r,{get:t[r],enumerable:!0})},Gt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of vt(t))!Ft.call(e,n)&&n!==r&&pe(e,n,{get:()=>t[n],enumerable:!(s=$t(t,n))||s.enumerable});return e};var Pt=e=>Gt(pe({},"__esModule",{value:!0}),e);var qr={};It(qr,{EmulatedRegExp:()=>J,toDetails:()=>St,toOnigurumaAst:()=>zr,toRegExp:()=>Qr});var y=String.fromCodePoint,f=String.raw,Pe=(()=>{try{new RegExp("(?<n>)|(?<n>)")}catch{return!1}return!0})(),Ne=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),Me=(()=>{try{new RegExp("","v")}catch{return!1}return!0})();function U(e,{enable:t,disable:r}){return{dotAll:!r?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!r?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function D(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}function W(e,t){return fe[e]>=fe[t]}function _(e,t){if(!e)throw new Error(t??"Value expected");return e}var fe={ES2025:2025,ES2024:2024,ES2018:2018},Nt={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function ee(e){if(e?.target!==void 0&&!Nt[e.target])throw new Error(`Unexpected target "${e.target}"`);let t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,maxRecursionDepth:5,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,allowUnhandledGAnchors:!1,asciiWordBoundaries:!1,...e?.rules}};return t.target==="auto"&&(t.target=Pe&&Ne?"ES2025":Me?"ES2024":"ES2018"),t}var Mt=new Set([y(304),y(305)]);function he(e){if(Mt.has(e))return[e];let t=new Set,r=e.toLowerCase(),s=r.toUpperCase(),n=Ut.get(r),a=Ot.get(r),o=Tt.get(r);return[...s].length===1&&t.add(s),o&&t.add(o),n&&t.add(n),t.add(r),a&&t.add(a),[...t]}var de=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"]),Ce=new Map;for(let e of de)Ce.set(j(e),e);var Rt=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"]),me=new Map;for(let e of Rt)me.set(j(e),e);var Re=new Set("Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo Extended_Pictographic Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi EBase EComp EMod EPres ExtPict Cpmn Cypro_Minoan Old_Uyghur Ougr Tangsa Tnsa Toto Vith Vithkuqi Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz".split(" ")),Ot=new Map([["s",y(383)],[y(383),"s"]]),Tt=new Map([[y(223),y(7838)],[y(107),y(8490)],[y(229),y(8491)],[y(969),y(8486)]]),Ut=new Map([P(453),P(456),P(459),P(498),...ge(8072,8079),...ge(8088,8095),...ge(8104,8111),P(8124),P(8140),P(8188)]),te=new Map([["alnum",f`[\p{Alpha}\p{Nd}]`],["alpha",f`\p{Alpha}`],["ascii",f`\p{ASCII}`],["blank",f`[\p{Zs}\t]`],["cntrl",f`\p{cntrl}`],["digit",f`\p{Nd}`],["graph",f`[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]`],["lower",f`\p{Lower}`],["print",f`[[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",f`[\p{P}\p{S}]`],["space",f`\p{space}`],["upper",f`\p{Upper}`],["word",f`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",f`\p{AHex}`]]),Oe=new Set(["alnum","blank","graph","print","word","xdigit"]);function Dt(e,t){let r=[];for(let s=e;s<=t;s++)r.push(s);return r}function j(e){return e.replace(/[- _]+/g,"").toLowerCase()}function P(e){let t=y(e);return[t.toLowerCase(),t]}function ge(e,t){return Dt(e,t).map(r=>P(r))}var we=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var g={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"},b={any:"any",digit:"digit",dot:"dot",hex:"hex",non_newline:"non_newline",posix:"posix",property:"property",space:"space",word:"word"},K={flags:"flags",keep:"keep"},x={atomic:"atomic",capturing:"capturing",group:"group",lookahead:"lookahead",lookbehind:"lookbehind"},Te=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]),Le=f`\[\^?\]?`,Be=`c.? | C(?:-.?)?|${f`[pP]\{(?:\^?[\x20\w]+\})?`}|${f`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${f`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${f`o\{[^\}]*\}?`}|${f`\d{1,3}`}`,Ve=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,re=new RegExp(f` | ||
\\ (?: | ||
${De} | ||
${Be} | ||
| [gk]<[^>]*>? | ||
@@ -16,16 +16,16 @@ | [gk]'[^']*'? | ||
)?)? | ||
| ${Le.source} | ||
| ${Ue} | ||
| ${Ve.source} | ||
| ${Le} | ||
| . | ||
`.replace(/\s+/g,""),"gsu"),me=new RegExp(f` | ||
`.replace(/\s+/g,""),"gsu"),ke=new RegExp(f` | ||
\\ (?: | ||
${De} | ||
${Be} | ||
| . | ||
) | ||
| \[:[^:]*:\] | ||
| ${Ue} | ||
| ${Le} | ||
| && | ||
| . | ||
`.replace(/\s+/g,""),"gsu");function K(e,t=""){if(typeof e!="string")throw new Error("String expected as pattern");if(!/^[imxW]*$/.test(t))throw new Error(`Flags "${t}" unsupported`);let r=[t.includes("x")],s={getCurrentModX:()=>r.at(-1),numOpenGroups:0,popModX(){r.pop()},pushModX(u){r.push(u)},replaceCurrentModX(u){r[r.length-1]=u}},n=[],a;for(ee.lastIndex=0;a=ee.exec(e);){let u=Ut(s,e,a[0],ee.lastIndex);u.tokens?n.push(...u.tokens):u.token&&n.push(u.token),u.lastIndex!==void 0&&(ee.lastIndex=u.lastIndex)}let o=[],i=0;n.forEach(u=>{u.type===g.GroupOpen&&(u.kind===x.capturing?(i++,u.number=i):u.raw==="("&&o.push(u))}),i||o.forEach((u,p)=>{u.kind=x.capturing,u.number=p+1});let c=i||o.length;return n=n.map(u=>u.type===g.EscapedNumber?zt(u,c):u).flat(),{tokens:n,flags:{ignoreCase:t.includes("i"),dotAll:t.includes("m"),extended:t.includes("x"),wordIsAscii:t.includes("W")}}}function Ut(e,t,r,s){let[n,a,o]=r;if(n==="["){let i=Dt(t,r,s);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(n==="\\"){if("AbBGzZ".includes(a))return{token:m(g.Assertion,r,{kind:r})};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:m(g.Subroutine,r)}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:m(g.Backreference,r)}}if(a==="K")return{token:m(g.Directive,r,{kind:j.keep})};if(a==="N")return{token:m(g.CharacterSet,r,{kind:E.non_newline})};if(a==="O")return{token:m(g.CharacterSet,r,{kind:E.any})};if("RX".includes(a))return{token:m(g.VariableLengthCharacterSet,r,{kind:r})};if("yY".includes(a))throw new Error(`Unsupported grapheme boundary "${r}"`);let i=Be(r,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(n==="("){if(o==="#"){if(t[s]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:s+1}}if("-imx".includes(o))return{token:Vt(r,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,r==="("||r==="(?:")return{token:m(g.GroupOpen,r,{kind:x.group})};if(r==="(?>")return{token:m(g.GroupOpen,r,{kind:x.atomic})};if(r==="(?="||r==="(?!"||r==="(?<="||r==="(?<!")return{token:m(g.GroupOpen,r,{kind:o==="<"?x.lookbehind:x.lookahead,negate:r.endsWith("!")})};if(o==="<"||o==="'")return{token:m(g.GroupOpen,r,{kind:x.capturing,name:r.slice(3,-1)})};throw o==="("?new Error(`Unsupported conditional "${r}"`):o==="~"?new Error(`Unsupported absence operator "${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:m(g.GroupClose,r)}}if(r==="#"&&e.getCurrentModX()){let i=t.indexOf(` | ||
`,s);return{lastIndex:i===-1?t.length:i}}if(/^\s$/.test(r)&&e.getCurrentModX()){let i=/\s+/y;return i.lastIndex=s,{lastIndex:i.exec(t)?i.lastIndex:s}}return r==="."?{token:m(g.CharacterSet,r,{kind:E.dot})}:r==="^"||r==="$"?{token:m(g.Assertion,r,{kind:r})}:r==="|"?{token:m(g.Alternator,r)}:Le.test(r)?{token:jt(r)}:(Ve(r),{token:m(g.Character,r,{value:r.codePointAt(0)})})}function Dt(e,t,r){Oe(t);let s=[m(g.CharacterClassOpen,t,{negate:t[1]==="^"})],n=1,a;for(me.lastIndex=r;a=me.exec(e);){let o=a[0];if(o[0]==="["&&o[1]!==":")Oe(o),n++,s.push(m(g.CharacterClassOpen,o,{negate:o[1]==="^"}));else if(o==="]"){if(n--,s.push(m(g.CharacterClassClose,o)),!n)break}else{let i=Lt(o);Array.isArray(i)?s.push(...i):s.push(i)}}return{tokens:s,lastIndex:me.lastIndex||e.length}}function Lt(e){if(e[0]==="\\")return Be(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Y.get(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return m(g.CharacterSet,e,{kind:E.posix,negate:!!t.groups.negate,value:t.groups.name})}return e==="-"?m(g.CharacterClassHyphen,e):e==="&&"?m(g.CharacterClassIntersector,e):(Ve(e),m(g.Character,e,{value:e.codePointAt(0)}))}function Be(e,{inCharClass:t}){let r=e[1];if(r==="c"||r==="C")return Bt(e);if("dDhHsSwW".includes(r))return Kt(e);if(e.startsWith(f`\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");return Wt(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let s=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),n=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(s)),a=new TextEncoder;return[...n].map(i=>{let c=[...a.encode(i)].map(u=>`\\x${u.toString(16)}`).join("");return m(g.Character,c,{value:i.codePointAt(0)})})}catch{throw new Error(`Too short or invalid multibyte code "${e}"`)}if(r==="u"||r==="x")return m(g.Character,e,{value:Ht(e)});if(Re.has(r))return m(g.Character,e,{value:Re.get(r)});if(/\d/.test(r))return m(g.EscapedNumber,e,{inCharClass:t});if(e==="\\")throw new Error(f`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return m(g.Character,e,{value:e.codePointAt(1)});throw new Error(`Unexpected escape "${e}"`)}function m(e,t,r){return{type:e,raw:t,...r}}function Bt(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return m(g.Character,e,{value:t.toUpperCase().codePointAt(0)-64})}function Vt(e,t){let{on:r,off:s}=/^\(\?(?<on>[imx]*)(?:-(?<off>[imx\-]*))?/.exec(e).groups;s??="";let n=(t.getCurrentModX()||r.includes("x"))&&!s.includes("x"),a=Te(r),o=Te(s),i={};if(a&&(i.enable=a),o&&(i.disable=o),e.endsWith(")"))return t.replaceCurrentModX(n),m(g.Directive,e,{kind:j.flags,flags:i});if(e.endsWith(":")){t.pushModX(n),t.numOpenGroups++;let c=m(g.GroupOpen,e,{kind:x.group});return(a||o)&&(c.flags=i),c}throw new Error(`Unexpected flag modifier "${e}"`)}function jt(e){let t={};if(e[0]==="{"){let{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 m(g.Quantifier,e,t)}function Kt(e){let t=e[1].toLowerCase();return m(g.CharacterSet,e,{kind:{d:E.digit,h:E.hex,s:E.space,w:E.word}[t],negate:e[1]!==t})}function Wt(e){let{p:t,neg:r,value:s}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[ \w]+)/.exec(e).groups,n=t==="P"&&!r||t==="p"&&!!r;return m(g.CharacterSet,e,{kind:E.property,negate:n,value:s})}function Te(e){let 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(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2),r=parseInt(t,16);if(r>1310719)throw new Error(`Invalid out of range "${e}"`);if(r>1114111)throw new Error(`Invalid out of range in JS "${e}"`);return r}function zt(e,t){let{raw:r,inCharClass:s}=e,n=r.slice(1);if(!s&&(n!=="0"&&n.length===1||n[0]!=="0"&&+n<=t))return[m(g.Backreference,r)];let a=[],o=n.match(/^[0-7]+|\d/g);for(let i=0;i<o.length;i++){let c=o[i],u;if(i===0&&c!=="8"&&c!=="9"){if(u=parseInt(c,8),u>127)throw new Error(f`Octal encoded byte above 177 unsupported "${r}"`)}else u=c.codePointAt(0);a.push(m(g.Character,(i===0?"\\":"")+c,{value:u}))}return a}function Oe(e){if(e.endsWith("]"))throw new Error(`Empty character class "${e}" unsupported in Oniguruma`)}function Ve(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`)}function W({alternatives:e},t){return e.length===1&&e[0].elements.length===1&&(!t||t(e[0].elements[0]))}function v({type:e,kind:t}){return e===l.Assertion&&(t===w.lookahead||t===w.lookbehind)}function te({type:e,min:t}){return e===l.Assertion||e===l.Directive||e===l.Quantifier&&!t}function F(e,t,r){let s=e.node;for(;s.parent;)s=s.parent;function n(o,i){for(let c=0;c<o.length;c++){let u=a(o[c],i,c,o);c=Math.max(-1,c+u)}}function a(o,i=null,c=null,u=null){let p=0,h=!1,C={node:o,parent:i,key:c,container:u,ast:s,remove(){_(u,"Container expected").splice(Math.max(0,c+p),1),p-=1},removeAllNextSiblings(){return _(u,"Container expected").splice(c+1)},removeAllPrevSiblings(){let A=c+p;return p-=A,_(u,"Container expected").splice(0,Math.max(0,A))},replaceWith(A){qt(A,i),u?u[Math.max(0,c+p)]=A:i[c]=A},skip(){h=!0}},d=Qt(o).find(A=>!!r[A]),y=d&&r[d],N=typeof y=="function"?y:y?.enter,T=y?.exit;if(N?.(C,t),!h)switch(o.type){case l.Regex:a(o.pattern,o,"pattern"),a(o.flags,o,"flags");break;case l.Alternative:case l.CharacterClass:n(o.elements,o);break;case l.Assertion:v(o)&&n(o.alternatives,o);break;case l.Backreference:case l.Character:case l.CharacterSet:case l.Directive:case l.Flags:case l.Recursion:case l.Subroutine:case l.VariableLengthCharacterSet:break;case l.CapturingGroup:case l.Group:case l.Pattern:n(o.alternatives,o);break;case l.CharacterClassIntersection:n(o.classes,o);break;case l.CharacterClassRange:a(o.min,o,"min"),a(o.max,o,"max");break;case l.Quantifier:a(o.element,o,"element");break;default:throw new Error(`Unexpected node type "${o.type}"`)}return T?.(C,t),p}a(e.node,e.parent,e.key,e.container)}var je={AnyGroup:"AnyGroup",AnyNode:"AnyNode"};function Qt(e){let{type:t}=e,r=[je.AnyNode];return(t===l.CapturingGroup||t===l.Group||v(e))&&r.push(je.AnyGroup),r.push(t),r}function qt(e,t){"parent"in t&&(e.parent=t)}var l={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"},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"},b=E,z=j,H={grapheme:"grapheme",newline:"newline"};function Q({tokens:e,flags:t},r){let s={skipBackrefValidation:!1,skipPropertyNameValidation:!1,verbose:!1,...r},n={capturingGroups:[],current:0,hasNumberedRef:!1,namedGroupsByName:new Map,parent:null,skipBackrefValidation:s.skipBackrefValidation,skipPropertyNameValidation:s.skipPropertyNameValidation,subroutines:[],token:null,tokens:e,verbose:s.verbose,walk:a};function a(C,d){let y=e[n.current];switch(n.parent=C,n.token=y,n.current++,y.type){case g.Alternator:return P();case g.Assertion:return He(y);case g.Backreference:return Xt(n);case g.Character:return ze(y.value);case g.CharacterClassHyphen:return Zt(n,d);case g.CharacterClassOpen:return Jt(n,d);case g.CharacterSet:return Yt(n);case g.Directive:return or(y);case g.GroupOpen:return er(n,d);case g.Quantifier:return tr(n);case g.Subroutine:return rr(n);case g.VariableLengthCharacterSet:return fr(y.kind);default:throw new Error(`Unexpected token type "${y.type}"`)}}let o=lr(cr(),ir(t)),i=o.pattern.alternatives[0];for(;n.current<e.length;){let C=a(i,{});C.type===l.Alternative?(o.pattern.alternatives.push(C),i=C):i.elements.push(C)}let{capturingGroups:c,hasNumberedRef:u,namedGroupsByName:p,subroutines:h}=n;if(u&&p.size)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:C}of h)if(typeof C=="number"){if(C>c.length)throw new Error("Subroutine uses a group number that's not defined")}else if(p.has(C)){if(p.get(C).length>1)throw new Error(f`Subroutine uses a duplicate group name "\g<${C}>"`)}else throw new Error(f`Subroutine uses a group name that's not defined "\g<${C}>"`);return F({node:o},null,{AnyNode({node:C,parent:d}){C.parent=d}}),o}function Xt(e){let{raw:t}=e.token,r=/^\\k[<']/.test(t),s=r?t.slice(3,-1):t.slice(1),n=(a,o=!1)=>{let i=e.capturingGroups.length,c=!1;if(a>i)if(e.skipBackrefValidation)c=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,re(o?i+1-a:a,{orphan:c})};if(r){let 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 re(s)}return n(+s)}function Zt(e,t){let{parent:r,tokens:s,walk:n}=e,a=r.elements.at(-1),o=s[e.current];if(a&&a.type!==l.CharacterClass&&a.type!==l.CharacterClassRange&&o&&o.type!==g.CharacterClassOpen&&o.type!==g.CharacterClassClose&&o.type!==g.CharacterClassIntersector){let i=n(r,t);if(a.type===l.Character&&i.type===l.Character)return r.elements.pop(),ar(a,i);throw new Error("Invalid character class range")}return ze(45)}function Jt(e,t){let{token:r,tokens:s,verbose:n,walk:a}=e,o=we({negate:r.negate}),i=o.elements[0],c=Ke(s[e.current]);for(;c.type!==g.CharacterClassClose;){if(c.type===g.CharacterClassIntersector)i.classes.push(we({negate:!1,baseOnly:!0})),e.current++;else{let u=i.classes.at(-1);u.elements.push(a(u,t))}c=Ke(s[e.current])}if(n||Cr(i),i.classes.length===1){let u=i.classes[0];u.negate=o.negate!==u.negate,o=u}return e.current++,o}function Yt({token:e,skipPropertyNameValidation:t}){let{kind:r,negate:s,value:n}=e;if(r===E.property){let a=V(n);if(Me.has(a))r=E.posix,n=a;else return se(n,{negate:s,skipPropertyNameValidation:t})}return r===E.posix?{type:l.CharacterSet,kind:b.posix,negate:s,value:n}:ye(r,{negate:s})}function er(e,t){let{token:r,tokens:s,capturingGroups:n,namedGroupsByName:a,verbose:o,walk:i}=e,c=nr(r);c.type===l.CapturingGroup&&(n.push(c),c.name&&U(a,c.name,[]).push(c));let u=We(s[e.current]);for(;u.type!==g.GroupClose;){if(u.type===g.Alternator)c.alternatives.push(P()),e.current++;else{let p=c.alternatives.at(-1);p.elements.push(i(p,t))}u=We(s[e.current])}return o||(c=hr(c)),e.current++,c}function tr({token:e,parent:t}){let{min:r,max:s,greedy:n,possessive:a}=e,o=t.elements.at(-1);if(!o||o.type===l.Assertion||o.type===l.Directive)throw new Error("Quantifier requires a repeatable token");let i=ur(o,r,s,n,a);return t.elements.pop(),i}function rr(e){let{token:t,capturingGroups:r,subroutines:s}=e,n=t.raw.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(n);if(a){let i=+a.groups.num,c=r.length;if(e.hasNumberedRef=!0,n={"":i,"+":c+i,"-":c+1-i}[a.groups.sign],n<1)throw new Error("Invalid subroutine number")}else n==="0"&&(n=0);let o=pr(n);return s.push(o),o}function P(){return{type:l.Alternative,elements:[]}}function He({type:e,kind:t,negate:r}){if(e===g.GroupOpen)return ne({behind:t===x.lookbehind,negate:r});let s=_({"^":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}[t],`Unexpected assertion kind "${t}"`),n={type:l.Assertion,kind:s};return s===w.word_boundary&&(n.negate=t===f`\B`),n}function re(e,t){let r=!!t?.orphan;return{type:l.Backreference,...r&&{orphan:r},ref:e}}function nr(e){let{kind:t,number:r,name:s,flags:n}=e;switch(t){case x.atomic:return I({atomic:!0});case x.capturing:return ke(r,s);case x.group:return I({flags:n});case x.lookahead:case x.lookbehind:return He(e);default:throw new Error(`Unexpected group kind "${t}"`)}}function ke(e,t){let r=t!==void 0;if(r&&!dr(t))throw new Error(`Group name "${t}" invalid in Oniguruma`);return{type:l.CapturingGroup,number:e,...r&&{name:t},alternatives:[P()]}}function ze(e){return{type:l.Character,value:e}}function we(e){let t={baseOnly:!1,negate:!1,...e};return{type:l.CharacterClass,negate:t.negate,elements:t.baseOnly?[]:[sr()]}}function sr(){return{type:l.CharacterClassIntersection,classes:[we({negate:!1,baseOnly:!0})]}}function ar(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:l.CharacterClassRange,min:e,max:t}}function ye(e,{negate:t}){let r={type:l.CharacterSet,kind:_(b[e],`Unexpected character set kind "${e}"`)};return(e===E.digit||e===E.hex||e===E.space||e===E.word)&&(r.negate=t),r}function or({kind:e,flags:t}){let r={type:l.Directive,kind:_(z[e],`Unexpected directive kind "${e}"`)};return e===j.flags&&(r.flags=t),r}function ir({ignoreCase:e,dotAll:t,extended:r,wordIsAscii:s}){return{type:l.Flags,ignoreCase:e,dotAll:t,extended:r,wordIsAscii:s}}function I(e){let t=e?.atomic,r=e?.flags;return{type:l.Group,...t&&{atomic:t},...r&&{flags:r},alternatives:[P()]}}function ne(e){let t={behind:!1,negate:!1,...e};return{type:l.Assertion,kind:t.behind?w.lookbehind:w.lookahead,negate:t.negate,alternatives:[P()]}}function cr(){return{type:l.Pattern,alternatives:[P()]}}function ur(e,t,r,s,n){if(r<t)throw new Error("Quantifier range out of order");return{type:l.Quantifier,min:t,max:r,greedy:s,possessive:n,element:e}}function lr(e,t){return{type:l.Regex,pattern:e,flags:t}}function pr(e){return{type:l.Subroutine,ref:e}}function se(e,t){let r={negate:!1,skipPropertyNameValidation:!1,...t};return{type:l.CharacterSet,kind:b.property,value:r.skipPropertyNameValidation?e:gr(e),negate:r.negate}}function fr(e){return{type:l.VariableLengthCharacterSet,kind:_({"\\R":H.newline,"\\X":H.grapheme}[e],`Unexpected varcharset kind "${e}"`)}}function gr(e){let t=V(e);if(de.has(t))throw new Error(f`Unicode property "\p{${e}}" unsupported in Oniguruma`);let r=he.get(t);return r||e.trim().replace(/\s+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,s=>s[0].toUpperCase()+s.slice(1).toLowerCase())}function hr(e){let t=e.alternatives[0].elements[0];return e.type===l.Group&&W(e,r=>r.type===l.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 dr(e){return!/^(?:[-\d]|$)/.test(e)}function Cr(e){for(let t=0;t<e.classes.length;t++){let r=e.classes[t],s=r.elements[0];r.elements.length===1&&s.type===l.CharacterClass&&(e.classes[t]=s,s.negate=r.negate!==s.negate)}}function Ke(e){return _(e,"Unclosed character class")}function We(e){return _(e,"Unclosed group")}var S=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function M(e,t,r,s){let n=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1],o=0,i="";for(let c of e.matchAll(n)){let{0:u,groups:{$skip:p}}=c;if(!p&&(!s||s===S.DEFAULT==!o)){r instanceof Function?i+=r(c,{context:o?S.CHAR_CLASS:S.DEFAULT,negated:a[a.length-1]}):i+=r;continue}u[0]==="["?(o++,a.push(u[1]==="^")):u==="]"&&o&&(o--,a.pop()),i+=u}return i}function Qe(e,t,r,s){M(e,t,r,s)}function mr(e,t,r=0,s){if(!new RegExp(t,"su").test(e))return null;let n=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");n.lastIndex=r;let a=0,o;for(;o=n.exec(e);){let{0:i,groups:{$skip:c}}=o;if(!c&&(!s||s===S.DEFAULT==!a))return o;i==="["?a++:i==="]"&&a&&a--,n.lastIndex==o.index&&n.lastIndex++}return null}function ae(e,t,r){return!!mr(e,t,0,r)}function qe(e,t){let r=/\\?./gsu;r.lastIndex=t;let s=e.length,n=0,a=1,o;for(;o=r.exec(e);){let[i]=o;if(i==="[")n++;else if(n)i==="]"&&n--;else if(i==="(")a++;else if(i===")"&&(a--,!a)){s=o.index;break}}return e.slice(t,s)}var oe="$E$",q=class e extends RegExp{_captureMap;constructor(t,r,s){if(t instanceof RegExp&&s)throw new Error("Cannot provide options when copying regexp");let n;s?.useEmulationGroups&&({expression:t,captureMap:n}=wr(t)),super(t,r),n?this._captureMap=n:t instanceof e&&(this._captureMap=t._captureMap)}exec(t){let r=RegExp.prototype.exec.call(this,t);if(!r||!this._captureMap)return r;let s=[...r];r.length=1;let n;this.hasIndices&&(n=[...r.indices],r.indices.length=1);for(let a=1;a<s.length;a++)this._captureMap[a]&&(r.push(s[a]),this.hasIndices&&r.indices.push(n[a]));return r}};function wr(e){let t=oe.replace(/\$/g,"\\$"),r=[!0];return e=M(e,String.raw`\((?:(?!\?)|\?<(?![=!])[^>]+>)(?<mark>${t})?`,({0:s,groups:{mark:n}})=>n?(r.push(!1),s.slice(0,-oe.length)):(r.push(!0),s),S.DEFAULT),{captureMap:r,expression:e}}var Xe=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Ze(e,t,r,s){return e.slice(0,t)+s+e.slice(t+r.length)}var Je=new RegExp(String.raw`(?<noncapturingStart>${Xe})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function be(e,t){if(!/\(\?>/.test(e))return e;let r="(?>",s=`(?:(?=(${t?.useEmulationGroups?oe:""}`,n=[0],a=0,o=0,i=NaN,c;do{c=!1;let u=0,p=0,h=!1,C;for(Je.lastIndex=Number.isNaN(i)?0:i+s.length;C=Je.exec(e);){let{0:d,index:y,groups:{capturingStart:N,noncapturingStart:T}}=C;if(d==="[")u++;else if(u)d==="]"&&u--;else if(d===r&&!h)i=y,h=!0;else if(h&&T)p++;else if(N)h?p++:(a++,n.push(a+o));else if(d===")"&&h){if(!p){o++,e=`${e.slice(0,i)}${s}${e.slice(i+r.length,y)}))<$$${o+a}>)${e.slice(y+1)}`,c=!0;break}p--}}}while(c);return e=M(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:u,groups:{backrefNum:p,wrappedBackrefNum:h}})=>{if(p){let C=+p;if(C>n.length-1)throw new Error(`Backref "${u}" greater than number of captures`);return`\\${n[C]}`}return`\\${h}`},S.DEFAULT),e}var Ye=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Ee=new RegExp(String.raw` | ||
`.replace(/\s+/g,""),"gsu");function H(e,t=""){if(typeof e!="string")throw new Error("String expected as pattern");if(!/^[imxDSW]*$/.test(t))throw new Error(`Flags "${t}" includes unsupported value`);let r=[t.includes("x")],s={getCurrentModX:()=>r.at(-1),numOpenGroups:0,popModX(){r.pop()},pushModX(u){r.push(u)},replaceCurrentModX(u){r[r.length-1]=u}},n=[],a;for(re.lastIndex=0;a=re.exec(e);){let u=Lt(s,e,a[0],re.lastIndex);u.tokens?n.push(...u.tokens):u.token&&n.push(u.token),u.lastIndex!==void 0&&(re.lastIndex=u.lastIndex)}let o=[],i=0;n.forEach(u=>{u.type===g.GroupOpen&&(u.kind===x.capturing?(i++,u.number=i):u.raw==="("&&o.push(u))}),i||o.forEach((u,p)=>{u.kind=x.capturing,u.number=p+1});let c=i||o.length;return n=n.map(u=>u.type===g.EscapedNumber?qt(u,c):u).flat(),{tokens:n,flags:{ignoreCase:t.includes("i"),dotAll:t.includes("m"),extended:t.includes("x"),digitIsAscii:t.includes("D"),spaceIsAscii:t.includes("S"),wordIsAscii:t.includes("W")}}}function Lt(e,t,r,s){let[n,a,o]=r;if(n==="["){let i=Bt(t,r,s);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(n==="\\"){if("AbBGzZ".includes(a))return{token:m(g.Assertion,r,{kind:r})};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:m(g.Subroutine,r)}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:m(g.Backreference,r)}}if(a==="K")return{token:m(g.Directive,r,{kind:K.keep})};if(a==="N")return{token:m(g.CharacterSet,r,{kind:b.non_newline})};if(a==="O")return{token:m(g.CharacterSet,r,{kind:b.any})};if("RX".includes(a))return{token:m(g.VariableLengthCharacterSet,r,{kind:r})};if("yY".includes(a))throw new Error(`Unsupported grapheme boundary "${r}"`);let i=We(r,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(n==="("){if(o==="#"){if(t[s]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:s+1}}if("-imx".includes(o))return{token:jt(r,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,r==="("||r==="(?:")return{token:m(g.GroupOpen,r,{kind:x.group})};if(r==="(?>")return{token:m(g.GroupOpen,r,{kind:x.atomic})};if(r==="(?="||r==="(?!"||r==="(?<="||r==="(?<!")return{token:m(g.GroupOpen,r,{kind:o==="<"?x.lookbehind:x.lookahead,negate:r.endsWith("!")})};if(o==="<"||o==="'")return{token:m(g.GroupOpen,r,{kind:x.capturing,name:r.slice(3,-1)})};throw o==="("?new Error(`Unsupported conditional "${r}"`):o==="~"?new Error(`Unsupported absence operator "${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:m(g.GroupClose,r)}}if(r==="#"&&e.getCurrentModX()){let i=t.indexOf(` | ||
`,s);return{lastIndex:i===-1?t.length:i}}if(/^\s$/.test(r)&&e.getCurrentModX()){let i=/\s+/y;return i.lastIndex=s,{lastIndex:i.exec(t)?i.lastIndex:s}}return r==="."?{token:m(g.CharacterSet,r,{kind:b.dot})}:r==="^"||r==="$"?{token:m(g.Assertion,r,{kind:r})}:r==="|"?{token:m(g.Alternator,r)}:Ve.test(r)?{token:Kt(r)}:(je(r),{token:m(g.Character,r,{value:r.codePointAt(0)})})}function Bt(e,t,r){De(t);let s=[m(g.CharacterClassOpen,t,{negate:t[1]==="^"})],n=1,a;for(ke.lastIndex=r;a=ke.exec(e);){let o=a[0];if(o[0]==="["&&o[1]!==":")De(o),n++,s.push(m(g.CharacterClassOpen,o,{negate:o[1]==="^"}));else if(o==="]"){if(n--,s.push(m(g.CharacterClassClose,o)),!n)break}else{let i=Vt(o);Array.isArray(i)?s.push(...i):s.push(i)}}return{tokens:s,lastIndex:ke.lastIndex||e.length}}function Vt(e){if(e[0]==="\\")return We(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!te.get(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return m(g.CharacterSet,e,{kind:b.posix,negate:!!t.groups.negate,value:t.groups.name})}return e==="-"?m(g.CharacterClassHyphen,e):e==="&&"?m(g.CharacterClassIntersector,e):(je(e),m(g.Character,e,{value:e.codePointAt(0)}))}function We(e,{inCharClass:t}){let r=e[1];if(r==="c"||r==="C")return Wt(e);if("dDhHsSwW".includes(r))return Ht(e);if(e.startsWith(f`\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");return zt(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let s=e.split(/\\x/).slice(1).map(i=>parseInt(i,16)),n=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(s)),a=new TextEncoder;return[...n].map(i=>{let c=[...a.encode(i)].map(u=>`\\x${u.toString(16)}`).join("");return m(g.Character,c,{value:i.codePointAt(0)})})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(r==="u"||r==="x")return m(g.Character,e,{value:Qt(e)});if(Te.has(r))return m(g.Character,e,{value:Te.get(r)});if(/\d/.test(r))return m(g.EscapedNumber,e,{inCharClass:t});if(e==="\\")throw new Error(f`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return m(g.Character,e,{value:e.codePointAt(1)});throw new Error(`Unexpected escape "${e}"`)}function m(e,t,r){return{type:e,raw:t,...r}}function Wt(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return m(g.Character,e,{value:t.toUpperCase().codePointAt(0)-64})}function jt(e,t){let{on:r,off:s}=/^\(\?(?<on>[imx]*)(?:-(?<off>[imx\-]*))?/.exec(e).groups;s??="";let n=(t.getCurrentModX()||r.includes("x"))&&!s.includes("x"),a=Ue(r),o=Ue(s),i={};if(a&&(i.enable=a),o&&(i.disable=o),e.endsWith(")"))return t.replaceCurrentModX(n),m(g.Directive,e,{kind:K.flags,flags:i});if(e.endsWith(":")){t.pushModX(n),t.numOpenGroups++;let c=m(g.GroupOpen,e,{kind:x.group});return(a||o)&&(c.flags=i),c}throw new Error(`Unexpected flag modifier "${e}"`)}function Kt(e){let t={};if(e[0]==="{"){let{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 m(g.Quantifier,e,t)}function Ht(e){let t=e[1].toLowerCase();return m(g.CharacterSet,e,{kind:{d:b.digit,h:b.hex,s:b.space,w:b.word}[t],negate:e[1]!==t})}function zt(e){let{p:t,neg:r,value:s}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[ \w]+)/.exec(e).groups,n=t==="P"&&!r||t==="p"&&!!r;return m(g.CharacterSet,e,{kind:b.property,negate:n,value:s})}function Ue(e){let 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 Qt(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2),r=parseInt(t,16);if(r>1310719)throw new Error(`Invalid out of range "${e}"`);if(r>1114111)throw new Error(`Invalid out of range in JS "${e}"`);return r}function qt(e,t){let{raw:r,inCharClass:s}=e,n=r.slice(1);if(!s&&(n!=="0"&&n.length===1||n[0]!=="0"&&+n<=t))return[m(g.Backreference,r)];let a=[],o=n.match(/^[0-7]+|\d/g);for(let i=0;i<o.length;i++){let c=o[i],u;if(i===0&&c!=="8"&&c!=="9"){if(u=parseInt(c,8),u>127)throw new Error(f`Octal encoded byte above 177 unsupported "${r}"`)}else u=c.codePointAt(0);a.push(m(g.Character,(i===0?"\\":"")+c,{value:u}))}return a}function De(e){if(e.endsWith("]"))throw new Error(`Empty character class "${e}" unsupported in Oniguruma`)}function je(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`)}function z({alternatives:e},t){return e.length===1&&e[0].elements.length===1&&(!t||t(e[0].elements[0]))}function v({type:e,kind:t}){return e===l.Assertion&&(t===w.lookahead||t===w.lookbehind)}function ne({type:e,min:t}){return e===l.Assertion||e===l.Directive||e===l.Quantifier&&!t}function F(e,t,r){let s=e.node;for(;s.parent;)s=s.parent;function n(o,i){for(let c=0;c<o.length;c++){let u=a(o[c],i,c,o);c=Math.max(-1,c+u)}}function a(o,i=null,c=null,u=null){let p=0,h=!1,C={node:o,parent:i,key:c,container:u,ast:s,remove(){_(u,"Container expected").splice(Math.max(0,c+p),1),p-=1},removeAllNextSiblings(){return _(u,"Container expected").splice(c+1)},removeAllPrevSiblings(){let A=c+p;return p-=A,_(u,"Container expected").splice(0,Math.max(0,A))},replaceWith(A){Zt(A,i),u?u[Math.max(0,c+p)]=A:i[c]=A},skip(){h=!0}},d=Xt(o).find(A=>!!r[A]),E=d&&r[d],M=typeof E=="function"?E:E?.enter,T=E?.exit;if(M?.(C,t),!h)switch(o.type){case l.Regex:a(o.pattern,o,"pattern"),a(o.flags,o,"flags");break;case l.Alternative:case l.CharacterClass:n(o.elements,o);break;case l.Assertion:v(o)&&n(o.alternatives,o);break;case l.Backreference:case l.Character:case l.CharacterSet:case l.Directive:case l.Flags:case l.Recursion:case l.Subroutine:case l.VariableLengthCharacterSet:break;case l.CapturingGroup:case l.Group:case l.Pattern:n(o.alternatives,o);break;case l.CharacterClassIntersection:n(o.classes,o);break;case l.CharacterClassRange:a(o.min,o,"min"),a(o.max,o,"max");break;case l.Quantifier:a(o.element,o,"element");break;default:throw new Error(`Unexpected node type "${o.type}"`)}return T?.(C,t),p}a(e.node,e.parent,e.key,e.container)}var Ke={AnyGroup:"AnyGroup",AnyNode:"AnyNode"};function Xt(e){let{type:t}=e,r=[Ke.AnyNode];return(t===l.CapturingGroup||t===l.Group||v(e))&&r.push(Ke.AnyGroup),r.push(t),r}function Zt(e,t){"parent"in t&&(e.parent=t)}var l={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"},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"},k=b,q=K,Q={grapheme:"grapheme",newline:"newline"};function X({tokens:e,flags:t},r){let s={skipBackrefValidation:!1,skipPropertyNameValidation:!1,verbose:!1,...r},n={capturingGroups:[],current:0,hasNumberedRef:!1,namedGroupsByName:new Map,parent:null,skipBackrefValidation:s.skipBackrefValidation,skipPropertyNameValidation:s.skipPropertyNameValidation,subroutines:[],token:null,tokens:e,verbose:s.verbose,walk:a};function a(C,d){let E=e[n.current];switch(n.parent=C,n.token=E,n.current++,E.type){case g.Alternator:return N();case g.Assertion:return Qe(E);case g.Backreference:return Jt(n);case g.Character:return qe(E.value);case g.CharacterClassHyphen:return Yt(n,d);case g.CharacterClassOpen:return er(n,d);case g.CharacterSet:return tr(n);case g.Directive:return cr(E);case g.GroupOpen:return rr(n,d);case g.Quantifier:return nr(n);case g.Subroutine:return sr(n);case g.VariableLengthCharacterSet:return hr(E.kind);default:throw new Error(`Unexpected token type "${E.type}"`)}}let o=fr(lr(),ur(t)),i=o.pattern.alternatives[0];for(;n.current<e.length;){let C=a(i,{});C.type===l.Alternative?(o.pattern.alternatives.push(C),i=C):i.elements.push(C)}let{capturingGroups:c,hasNumberedRef:u,namedGroupsByName:p,subroutines:h}=n;if(u&&p.size)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:C}of h)if(typeof C=="number"){if(C>c.length)throw new Error("Subroutine uses a group number that's not defined")}else if(p.has(C)){if(p.get(C).length>1)throw new Error(f`Subroutine uses a duplicate group name "\g<${C}>"`)}else throw new Error(f`Subroutine uses a group name that's not defined "\g<${C}>"`);return F({node:o},null,{AnyNode({node:C,parent:d}){C.parent=d}}),o}function Jt(e){let{raw:t}=e.token,r=/^\\k[<']/.test(t),s=r?t.slice(3,-1):t.slice(1),n=(a,o=!1)=>{let i=e.capturingGroups.length,c=!1;if(a>i)if(e.skipBackrefValidation)c=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,se(o?i+1-a:a,{orphan:c})};if(r){let 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 se(s)}return n(+s)}function Yt(e,t){let{parent:r,tokens:s,walk:n}=e,a=r.elements.at(-1),o=s[e.current];if(a&&a.type!==l.CharacterClass&&a.type!==l.CharacterClassRange&&o&&o.type!==g.CharacterClassOpen&&o.type!==g.CharacterClassClose&&o.type!==g.CharacterClassIntersector){let i=n(r,t);if(a.type===l.Character&&i.type===l.Character)return r.elements.pop(),ir(a,i);throw new Error("Invalid character class range")}return qe(45)}function er(e,t){let{token:r,tokens:s,verbose:n,walk:a}=e,o=ye({negate:r.negate}),i=o.elements[0],c=He(s[e.current]);for(;c.type!==g.CharacterClassClose;){if(c.type===g.CharacterClassIntersector)i.classes.push(ye({negate:!1,baseOnly:!0})),e.current++;else{let u=i.classes.at(-1);u.elements.push(a(u,t))}c=He(s[e.current])}if(n||wr(i),i.classes.length===1){let u=i.classes[0];u.negate=o.negate!==u.negate,o=u}return e.current++,o}function tr({token:e,skipPropertyNameValidation:t}){let{kind:r,negate:s,value:n}=e;if(r===b.property){let a=j(n);if(Oe.has(a))r=b.posix,n=a;else return L(n,{negate:s,skipPropertyNameValidation:t})}return r===b.posix?{type:l.CharacterSet,kind:k.posix,negate:s,value:n}:ae(r,{negate:s})}function rr(e,t){let{token:r,tokens:s,capturingGroups:n,namedGroupsByName:a,verbose:o,walk:i}=e,c=ar(r);c.type===l.CapturingGroup&&(n.push(c),c.name&&D(a,c.name,[]).push(c));let u=ze(s[e.current]);for(;u.type!==g.GroupClose;){if(u.type===g.Alternator)c.alternatives.push(N()),e.current++;else{let p=c.alternatives.at(-1);p.elements.push(i(p,t))}u=ze(s[e.current])}return o||(c=Cr(c)),e.current++,c}function nr({token:e,parent:t}){let{min:r,max:s,greedy:n,possessive:a}=e,o=t.elements.at(-1);if(!o||o.type===l.Assertion||o.type===l.Directive)throw new Error("Quantifier requires a repeatable token");let i=pr(o,r,s,n,a);return t.elements.pop(),i}function sr(e){let{token:t,capturingGroups:r,subroutines:s}=e,n=t.raw.slice(3,-1),a=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(n);if(a){let i=+a.groups.num,c=r.length;if(e.hasNumberedRef=!0,n={"":i,"+":c+i,"-":c+1-i}[a.groups.sign],n<1)throw new Error("Invalid subroutine number")}else n==="0"&&(n=0);let o=gr(n);return s.push(o),o}function N(){return{type:l.Alternative,elements:[]}}function Qe({type:e,kind:t,negate:r}){if(e===g.GroupOpen)return oe({behind:t===x.lookbehind,negate:r});let s=_({"^":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}[t],`Unexpected assertion kind "${t}"`),n={type:l.Assertion,kind:s};return s===w.word_boundary&&(n.negate=t===f`\B`),n}function se(e,t){let r=!!t?.orphan;return{type:l.Backreference,...r&&{orphan:r},ref:e}}function ar(e){let{kind:t,number:r,name:s,flags:n}=e;switch(t){case x.atomic:return I({atomic:!0});case x.capturing:return Ee(r,s);case x.group:return I({flags:n});case x.lookahead:case x.lookbehind:return Qe(e);default:throw new Error(`Unexpected group kind "${t}"`)}}function Ee(e,t){let r=t!==void 0;if(r&&!mr(t))throw new Error(`Group name "${t}" invalid in Oniguruma`);return{type:l.CapturingGroup,number:e,...r&&{name:t},alternatives:[N()]}}function qe(e){return{type:l.Character,value:e}}function ye(e){let t={baseOnly:!1,negate:!1,...e};return{type:l.CharacterClass,negate:t.negate,elements:t.baseOnly?[]:[or()]}}function or(){return{type:l.CharacterClassIntersection,classes:[ye({negate:!1,baseOnly:!0})]}}function ir(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:l.CharacterClassRange,min:e,max:t}}function ae(e,{negate:t}){let r={type:l.CharacterSet,kind:_(k[e],`Unexpected character set kind "${e}"`)};return(e===b.digit||e===b.hex||e===b.space||e===b.word)&&(r.negate=t),r}function cr({kind:e,flags:t}){let r={type:l.Directive,kind:_(q[e],`Unexpected directive kind "${e}"`)};return e===K.flags&&(r.flags=t),r}function ur({ignoreCase:e,dotAll:t,extended:r,digitIsAscii:s,spaceIsAscii:n,wordIsAscii:a}){return{type:l.Flags,ignoreCase:e,dotAll:t,extended:r,digitIsAscii:s,spaceIsAscii:n,wordIsAscii:a}}function I(e){let t=e?.atomic,r=e?.flags;return{type:l.Group,...t&&{atomic:t},...r&&{flags:r},alternatives:[N()]}}function oe(e){let t={behind:!1,negate:!1,...e};return{type:l.Assertion,kind:t.behind?w.lookbehind:w.lookahead,negate:t.negate,alternatives:[N()]}}function lr(){return{type:l.Pattern,alternatives:[N()]}}function pr(e,t,r,s,n){if(r<t)throw new Error("Quantifier range out of order");return{type:l.Quantifier,min:t,max:r,greedy:s,possessive:n,element:e}}function fr(e,t){return{type:l.Regex,pattern:e,flags:t}}function gr(e){return{type:l.Subroutine,ref:e}}function L(e,t){let r={negate:!1,skipPropertyNameValidation:!1,...t};return{type:l.CharacterSet,kind:k.property,value:r.skipPropertyNameValidation?e:dr(e),negate:r.negate}}function hr(e){return{type:l.VariableLengthCharacterSet,kind:_({"\\R":Q.newline,"\\X":Q.grapheme}[e],`Unexpected varcharset kind "${e}"`)}}function dr(e){let t=j(e);if(me.has(t))throw new Error(f`Unicode property "\p{${e}}" unsupported in Oniguruma`);let r=Ce.get(t);return r||e.trim().replace(/\s+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,s=>s[0].toUpperCase()+s.slice(1).toLowerCase())}function Cr(e){let t=e.alternatives[0].elements[0];return e.type===l.Group&&z(e,r=>r.type===l.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 mr(e){return!/^(?:[-\d]|$)/.test(e)}function wr(e){for(let t=0;t<e.classes.length;t++){let r=e.classes[t],s=r.elements[0];r.elements.length===1&&s.type===l.CharacterClass&&(e.classes[t]=s,s.negate=r.negate!==s.negate)}}function He(e){return _(e,"Unclosed character class")}function ze(e){return _(e,"Unclosed group")}var S=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function R(e,t,r,s){let n=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),a=[!1],o=0,i="";for(let c of e.matchAll(n)){let{0:u,groups:{$skip:p}}=c;if(!p&&(!s||s===S.DEFAULT==!o)){r instanceof Function?i+=r(c,{context:o?S.CHAR_CLASS:S.DEFAULT,negated:a[a.length-1]}):i+=r;continue}u[0]==="["?(o++,a.push(u[1]==="^")):u==="]"&&o&&(o--,a.pop()),i+=u}return i}function Xe(e,t,r,s){R(e,t,r,s)}function kr(e,t,r=0,s){if(!new RegExp(t,"su").test(e))return null;let n=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");n.lastIndex=r;let a=0,o;for(;o=n.exec(e);){let{0:i,groups:{$skip:c}}=o;if(!c&&(!s||s===S.DEFAULT==!a))return o;i==="["?a++:i==="]"&&a&&a--,n.lastIndex==o.index&&n.lastIndex++}return null}function ie(e,t,r){return!!kr(e,t,0,r)}function Ze(e,t){let r=/\\?./gsu;r.lastIndex=t;let s=e.length,n=0,a=1,o;for(;o=r.exec(e);){let[i]=o;if(i==="[")n++;else if(n)i==="]"&&n--;else if(i==="(")a++;else if(i===")"&&(a--,!a)){s=o.index;break}}return e.slice(t,s)}var ce="$E$",Z=class e extends RegExp{_captureMap;constructor(t,r,s){if(t instanceof RegExp&&s)throw new Error("Cannot provide options when copying regexp");let n;s?.useEmulationGroups&&({expression:t,captureMap:n}=yr(t)),super(t,r),n?this._captureMap=n:t instanceof e&&(this._captureMap=t._captureMap)}exec(t){let r=RegExp.prototype.exec.call(this,t);if(!r||!this._captureMap)return r;let s=[...r];r.length=1;let n;this.hasIndices&&(n=[...r.indices],r.indices.length=1);for(let a=1;a<s.length;a++)this._captureMap[a]&&(r.push(s[a]),this.hasIndices&&r.indices.push(n[a]));return r}};function yr(e){let t=ce.replace(/\$/g,"\\$"),r=[!0];return e=R(e,String.raw`\((?:(?!\?)|\?<(?![=!])[^>]+>)(?<mark>${t})?`,({0:s,groups:{mark:n}})=>n?(r.push(!1),s.slice(0,-ce.length)):(r.push(!0),s),S.DEFAULT),{captureMap:r,expression:e}}var Je=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function Ye(e,t,r,s){return e.slice(0,t)+s+e.slice(t+r.length)}var et=new RegExp(String.raw`(?<noncapturingStart>${Je})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function xe(e,t){if(!/\(\?>/.test(e))return e;let r="(?>",s=`(?:(?=(${t?.useEmulationGroups?ce:""}`,n=[0],a=0,o=0,i=NaN,c;do{c=!1;let u=0,p=0,h=!1,C;for(et.lastIndex=Number.isNaN(i)?0:i+s.length;C=et.exec(e);){let{0:d,index:E,groups:{capturingStart:M,noncapturingStart:T}}=C;if(d==="[")u++;else if(u)d==="]"&&u--;else if(d===r&&!h)i=E,h=!0;else if(h&&T)p++;else if(M)h?p++:(a++,n.push(a+o));else if(d===")"&&h){if(!p){o++,e=`${e.slice(0,i)}${s}${e.slice(i+r.length,E)}))<$$${o+a}>)${e.slice(E+1)}`,c=!0;break}p--}}}while(c);return e=R(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:u,groups:{backrefNum:p,wrappedBackrefNum:h}})=>{if(p){let C=+p;if(C>n.length-1)throw new Error(`Backref "${u}" greater than number of captures`);return`\\${n[C]}`}return`\\${h}`},S.DEFAULT),e}var tt=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,be=new RegExp(String.raw` | ||
\\(?: \d+ | ||
@@ -43,8 +43,7 @@ | c[A-Za-z] | ||
))? | ||
| (?<qBase>${Ye})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?) | ||
| (?<qBase>${tt})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?) | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function xe(e){if(!new RegExp(`${Ye}\\+`).test(e))return e;let t=[],r=null,s=null,n="",a=0,o;for(Ee.lastIndex=0;o=Ee.exec(e);){let{0:i,index:c,groups:{qBase:u,qMod:p,invalidQ:h}}=o;if(i==="[")a||(s=c),a++;else if(i==="]")a?a--:s=null;else if(!a)if(p==="+"&&n&&!n.startsWith("(")){if(h)throw new Error(`Invalid quantifier "${i}"`);let C=-1;if(/^\{\d+\}$/.test(u))e=Ze(e,c+u.length,p,"");else{if(n===")"||n==="]"){let d=n===")"?r:s;if(d===null)throw new Error(`Invalid unmatched "${n}"`);e=`${e.slice(0,d)}(?>${e.slice(d,c)}${u})${e.slice(c+i.length)}`}else e=`${e.slice(0,c-n.length)}(?>${n}${u})${e.slice(c+i.length)}`;C+=4}Ee.lastIndex+=C}else i[0]==="("?t.push(c):i===")"&&(r=t.length?t.pop():null);n=i}return e}function et(e){let t=e.pattern.alternatives,r=t[0].elements[0];if(t.length>1||!r)return null;let s=W(e.pattern,o=>o.type===l.CapturingGroup||o.type===l.Group)&&r.alternatives.length===1,n=s?r.alternatives[0]:t[0],a=s?n.elements[0]:r;if(!a)return null;if((a.type===l.CapturingGroup||a.type===l.Group)&&a.alternatives.length===2&&a.alternatives[0].elements.length===1&&a.alternatives[1].elements.length===1){let o=a.alternatives[0].elements[0],i=a.alternatives[1].elements[0];if(o.kind===w.line_start&&i.kind===w.search_start||o.kind===w.search_start&&i.kind===w.line_start)return o.kind===w.line_start?a.alternatives.pop():a.alternatives.shift(),"line_or_search_start"}if(ie(a,{negate:!0}))return a.parent.elements.shift(),"not_search_start";for(let o=0;o<n.elements.length;o++){let i=n.elements[o];if(!te(i))break;if(ie(i,{negate:!0}))return n.elements.splice(o,1),"not_search_start"}return null}var X=class e extends q{#e;constructor(t,r,s){let n={useEmulationGroups:!1,strategy:null,...s};super(t,r,{useEmulationGroups:n.useEmulationGroups}),n.strategy?this.#e=n.strategy:t instanceof e&&(this.#e=t.#e)}exec(t){let r=super.exec,s=this.global||this.sticky,n=this.lastIndex,a=this.#e;if(a==="line_or_search_start"&&s&&this.lastIndex){this.lastIndex=0;let o=r.call(this,t.slice(n));return o&&(o.input=t,o.index+=n,this.lastIndex+=n),o}if(a==="not_search_start"){let o=r.call(this,t);if(o?.index===n){let i=s?this:new RegExp(this.source,`g${this.flags}`);i.lastIndex=o.index+1,o=r.call(i,t)}return o}return r.call(this,t)}};function ie(e,t){return v(e)&&e.negate===t.negate&&W(e,r=>r.kind===w.search_start)}var Se=String.raw,tt=Se`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`,rt=Se`\u{E0061}-\u{E007A}`,nt=()=>new RegExp(Se`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${rt}]{2}[\u{E0030}-\u{E0039}${rt}]{1,3}\u{E007F}|${tt}(?:\u200D${tt})*`,"gu");function at(e,t){let r={accuracy:"default",avoidSubclass:!1,bestEffortTarget:"ES2025",...t},s=r.avoidSubclass?null:et(e),n={accuracy:r.accuracy,flagDirectivesByAlt:new Map,minTargetEs2024:B(r.bestEffortTarget,"ES2024"),subroutineRefMap:new Map,supportedGNodes:new Set,wordIsAscii:e.flags.wordIsAscii};F({node:e},n,ot);let a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:n.subroutineRefMap};F({node:e},o,it);let i={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return F({node:e},i,kr),s&&(e._strategy=s),e}var ot={Alternative:{enter({node:e,parent:t,key:r},{flagDirectivesByAlt:s}){let n=e.elements.filter(a=>a.kind===z.flags);for(let a=r+1;a<t.alternatives.length;a++){let o=t.alternatives[a];U(s,o,[]).push(...n)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let r=lt(t.get(e));if(r){let s=Z(I({flags:r}),e.elements);s.parent=e,e.elements=[s]}}}},Assertion({node:e,ast:t,remove:r,replaceWith:s},{accuracy:n,supportedGNodes:a,wordIsAscii:o}){let{kind:i,negate:c}=e;if(i===w.line_end)s($(f`(?=\z|\n)`));else if(i===w.line_start)s($(f`(?<=\A|\n)`));else if(i===w.search_start){if(!a.has(e)&&n!=="loose")throw new Error(f`Uses "\G" in a way that's unsupported`);t.flags.sticky=!0,r()}else if(i===w.string_end_newline)s($(f`(?=\n?\z)`));else if(i===w.word_boundary&&!o){let u=f`[\p{L}\p{N}\p{Pc}]`,p=`(?:(?<=${u})(?!${u})|(?<!${u})(?=${u}))`,h=`(?:(?<=${u})(?=${u})|(?<!${u})(?!${u}))`;s($(c?h:p))}},CapturingGroup({node:e},{subroutineRefMap:t}){let{name:r,number:s}=e;if(r&&!xr(r))throw new Error(`Group name "${r}" invalid in JS`);t.set(r??s,e)},CharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s,wordIsAscii:n}){let{kind:a,negate:o,value:i}=e;if(a===b.any)t(se("Any"));else if(a===b.hex)t(se("AHex",{negate:o}));else if(a===b.non_newline)t($(f`[^\n]`));else if(a===b.posix)if(!s&&(i==="graph"||i==="print")){if(r==="strict")throw new Error(`POSIX class "${i}" requires min target ES2024 or non-strict accuracy`);let c={graph:"!-~",print:" -~"}[i];o&&(c=`\0-${k(c.codePointAt(0)-1)}${k(c.codePointAt(2)+1)}-\u{10FFFF}`),t($(`[${c}]`))}else if(i==="word"&&n)t(ye(b.word,{negate:o}));else{let c=$(Y.get(i));c.negate=o,t(c)}else if(a===b.property)ge.has(i)||(e.key="sc");else if(a===b.space){let c=$(`[ | ||
\v\f\r]`);c.negate=o,t(c)}},Directive(e,t){let{node:r,parent:s,ast:n,remove:a,replaceWith:o,removeAllPrevSiblings:i,removeAllNextSiblings:c}=e,{kind:u,flags:p}=r;if(u===z.flags)if(!p.enable&&!p.disable)a();else{let h=Z(I({flags:p}),c());o(h),ht(h,e,t,ot)}else if(u===z.keep){if(s.parent!==n.pattern||n.pattern.alternatives.length>1)throw new Error(f`Uses "\K" in a way that's unsupported`);o(Z(ne({behind:!0}),i()))}},Flags({node:e,parent:t}){delete e.extended,delete e.wordIsAscii,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;let{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({node:e},{accuracy:t,supportedGNodes:r}){let s=[],n=!1,a=!1;for(let o of e.alternatives){let i=ft(o.elements);i?(n=!0,Array.isArray(i)?s.push(...i):s.push(i)):a=!0}if(n&&a&&t!=="loose")throw new Error(f`Uses "\G" in a way that's unsupported`);s.forEach(o=>r.add(o))},Quantifier({node:e}){if(e.element.type===l.Quantifier){let t=Z(I(),[e.element]);t.parent=e,e.element=t}},VariableLengthCharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s}){let{kind:n}=e;if(n===H.newline)t($(`(?>\r | ||
`.replace(/\s+/g,""),"gsu");function Se(e){if(!new RegExp(`${tt}\\+`).test(e))return e;let t=[],r=null,s=null,n="",a=0,o;for(be.lastIndex=0;o=be.exec(e);){let{0:i,index:c,groups:{qBase:u,qMod:p,invalidQ:h}}=o;if(i==="[")a||(s=c),a++;else if(i==="]")a?a--:s=null;else if(!a)if(p==="+"&&n&&!n.startsWith("(")){if(h)throw new Error(`Invalid quantifier "${i}"`);let C=-1;if(/^\{\d+\}$/.test(u))e=Ye(e,c+u.length,p,"");else{if(n===")"||n==="]"){let d=n===")"?r:s;if(d===null)throw new Error(`Invalid unmatched "${n}"`);e=`${e.slice(0,d)}(?>${e.slice(d,c)}${u})${e.slice(c+i.length)}`}else e=`${e.slice(0,c-n.length)}(?>${n}${u})${e.slice(c+i.length)}`;C+=4}be.lastIndex+=C}else i[0]==="("?t.push(c):i===")"&&(r=t.length?t.pop():null);n=i}return e}function rt(e){let t=e.pattern.alternatives,r=t[0].elements[0];if(t.length>1||!r)return null;let s=z(e.pattern,o=>o.type===l.CapturingGroup||o.type===l.Group)&&r.alternatives.length===1,n=s?r.alternatives[0]:t[0],a=s?n.elements[0]:r;if(!a)return null;if((a.type===l.CapturingGroup||a.type===l.Group)&&a.alternatives.length===2&&a.alternatives[0].elements.length===1&&a.alternatives[1].elements.length===1){let o=a.alternatives[0].elements[0],i=a.alternatives[1].elements[0];if(o.kind===w.line_start&&i.kind===w.search_start||o.kind===w.search_start&&i.kind===w.line_start)return o.kind===w.line_start?a.alternatives.pop():a.alternatives.shift(),"line_or_search_start"}if(ue(a,{negate:!0}))return a.parent.elements.shift(),"not_search_start";for(let o=0;o<n.elements.length;o++){let i=n.elements[o];if(!ne(i))break;if(ue(i,{negate:!0}))return n.elements.splice(o,1),"not_search_start"}return null}var J=class e extends Z{#e;constructor(t,r,s){let n={useEmulationGroups:!1,strategy:null,...s};super(t,r,{useEmulationGroups:n.useEmulationGroups}),n.strategy?this.#e=n.strategy:t instanceof e&&(this.#e=t.#e)}exec(t){let r=super.exec,s=this.global||this.sticky,n=this.lastIndex,a=this.#e;if(a==="line_or_search_start"&&s&&this.lastIndex){this.lastIndex=0;let o=r.call(this,t.slice(n));return o&&(o.input=t,o.index+=n,this.lastIndex+=n),o}if(a==="not_search_start"){let o=r.call(this,t);if(o?.index===n){let i=s?this:new RegExp(this.source,`g${this.flags}`);i.lastIndex=o.index+1,o=r.call(i,t)}return o}return r.call(this,t)}};function ue(e,t){return v(e)&&e.negate===t.negate&&z(e,r=>r.kind===w.search_start)}var Ae=String.raw,nt=Ae`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`,st=Ae`\u{E0061}-\u{E007A}`,at=()=>new RegExp(Ae`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${st}]{2}[\u{E0030}-\u{E0039}${st}]{1,3}\u{E007F}|${nt}(?:\u200D${nt})*`,"gu");function it(e,t){let r={accuracy:"default",allowUnhandledGAnchors:!1,asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t},s=r.avoidSubclass?null:rt(e),n={accuracy:r.accuracy,allowUnhandledGAnchors:r.allowUnhandledGAnchors,asciiWordBoundaries:r.asciiWordBoundaries,flagDirectivesByAlt:new Map,minTargetEs2024:W(r.bestEffortTarget,"ES2024"),subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};F({node:e},n,ct);let a={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:a,prevFlags:null,globalFlags:a,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:n.subroutineRefMap};F({node:e},o,ut);let i={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return F({node:e},i,Er),s&&(e._strategy=s),e}var ct={Alternative:{enter({node:e,parent:t,key:r},{flagDirectivesByAlt:s}){let n=e.elements.filter(a=>a.kind===q.flags);for(let a=r+1;a<t.alternatives.length;a++){let o=t.alternatives[a];D(s,o,[]).push(...n)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let r=ft(t.get(e));if(r){let s=Y(I({flags:r}),e.elements);s.parent=e,e.elements=[s]}}}},Assertion({node:e,ast:t,remove:r,replaceWith:s},{allowUnhandledGAnchors:n,asciiWordBoundaries:a,supportedGNodes:o,wordIsAscii:i}){let{kind:c,negate:u}=e;if(c===w.line_end)s($(f`(?=\z|\n)`));else if(c===w.line_start)s($(f`(?<=\A|\n)`));else if(c===w.search_start){if(!o.has(e)&&!n)throw new Error(f`Uses "\G" in a way that's unsupported`);t.flags.sticky=!0,r()}else if(c===w.string_end_newline)s($(f`(?=\n?\z)`));else if(c===w.word_boundary&&!i&&!a){let p=`(?:(?<=${G})(?!${G})|(?<!${G})(?=${G}))`,h=`(?:(?<=${G})(?=${G})|(?<!${G})(?!${G}))`;s($(u?h:p))}},CapturingGroup({node:e},{subroutineRefMap:t}){let{name:r,number:s}=e;if(r&&!_r(r))throw new Error(`Group name "${r}" invalid in JS`);t.set(r??s,e)},CharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s,digitIsAscii:n,spaceIsAscii:a,wordIsAscii:o}){let{kind:i,negate:c,value:u}=e;if(n&&(i===k.digit||u==="digit")){t(ae(k.digit,{negate:c}));return}if(a&&(i===k.space||u==="space")){t(_e($(br),c));return}if(o&&(i===k.word||u==="word")){t(ae(k.word,{negate:c}));return}if(i===k.any)t(L("Any"));else if(i===k.digit)t(L("Nd",{negate:c}));else if(i===k.hex)t(L("AHex",{negate:c}));else if(i===k.non_newline)t($(f`[^\n]`));else if(i===k.space)t(L("space",{negate:c}));else if(i===k.word)t(_e($(G),c));else if(i===k.property)de.has(u)||(e.key="sc");else if(i===k.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 p={graph:"!-~",print:" -~"}[u];c&&(p=`\0-${y(p.codePointAt(0)-1)}${y(p.codePointAt(2)+1)}-\u{10FFFF}`),t($(`[${p}]`))}else t(_e($(te.get(u)),c))},Directive(e,t){let{node:r,parent:s,ast:n,remove:a,replaceWith:o,removeAllPrevSiblings:i,removeAllNextSiblings:c}=e,{kind:u,flags:p}=r;if(u===q.flags)if(!p.enable&&!p.disable)a();else{let h=Y(I({flags:p}),c());o(h),Ct(h,e,t,ct)}else if(u===q.keep){if(s.parent!==n.pattern||n.pattern.alternatives.length>1)throw new Error(f`Uses "\K" in a way that's unsupported`);o(Y(oe({behind:!0}),i()))}},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;let{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({node:e},{allowUnhandledGAnchors:t,supportedGNodes:r}){let s=[],n=!1,a=!1;for(let o of e.alternatives){let i=ht(o.elements);i?(n=!0,Array.isArray(i)?s.push(...i):s.push(i)):a=!0}if(n&&a&&!t)throw new Error(f`Uses "\G" in a way that's unsupported`);s.forEach(o=>r.add(o))},Quantifier({node:e}){if(e.element.type===l.Quantifier){let t=Y(I(),[e.element]);t.parent=e,e.element=t}},VariableLengthCharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s}){let{kind:n}=e;if(n===Q.newline)t($(`(?>\r | ||
?|[ | ||
\v\f\x85\u2028\u2029])`));else if(n===H.grapheme){if(r==="strict")throw new Error(f`Use of "\X" requires non-strict accuracy`);let a=s?f`\p{RGI_Emoji}`:nt().source.replace(/\\u\{/g,"\\x{");t($(f`(?>\r\n|${a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}))}else throw new Error(`Unexpected varcharset kind "${n}"`)}},it={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:r}){let{orphan:s,ref:n}=e;s||r.set(e,[...t.get(n).map(({node:a})=>a)])},Recursion({node:e,parent:t},{reffedNodesByReferencer:r}){let{ref:s}=e,n=t;for(;(n=n.parent)&&!(n.type===l.CapturingGroup&&(n.name===s||n.number===s)););r.set(e,n)},CapturingGroup:{enter({node:e,replaceWith:t,skip:r},{groupOriginByCopy:s,groupsByName:n,multiplexCapturesToLeftByRef:a,openRefs:o,reffedNodesByReferencer:i}){let c=s.get(e),u=e.name??e.number;if(c&&o.has(u)){let h=st(u);i.set(h,o.get(u)),t(h),r();return}o.set(u,e);let p=U(a,u,[]);for(let h=0;h<p.length;h++){let C=p[h];if(c===C.node||c&&c===C.origin||e===C.origin){p.splice(h,1);break}}if(p.push({node:e,origin:c}),e.name){let h=U(n,e.name,new Map);for(let C of h.values())!C.hasDuplicateNameToRemove&&ct(C.node,e,{ancestorsParticipate:!0})&&(C.hasDuplicateNameToRemove=!0);n.get(e.name).set(e,{node:e})}},exit({node:e},{openRefs:t}){t.delete(e.name??e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=O(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine(e,t){let{node:r,replaceWith:s}=e,{ref:n}=r,a=t.subroutineRefMap.get(n),o=n===0,i=o?st(n):ut(a,t.groupOriginByCopy,null),c=i;if(!o){let u=lt(Er(a,h=>h.type===l.Group&&!!h.flags)),p=u?O(t.globalFlags,u):t.globalFlags;yr(p,t.currentFlags)||(c=Z(I({flags:br(p)}),[i]))}s(c),o||ht(c,e,t,it)}},kr={Backreference({node:e,replaceWith:t},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let n=r.reffedNodesByReferencer.get(e).filter(a=>ct(a,e,{ancestorsParticipate:!1}));if(!n.length)t(ne({negate:!0}));else if(n.length>1){let a=n.map(o=>ce(P(),[re(o.number)]));t(ce(I(),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){let r=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let s=0;s<r;s++){let n=ke();e.pattern.alternatives.at(-1).elements.push(n)}}}};function ce(e,t){return t.forEach(r=>r.parent=e),e[Ae(e)]=t,e}function yr(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function ct(e,t,{ancestorsParticipate:r}){let s=t;do{if(s.type===l.Pattern)return!1;if(s.type===l.Alternative)continue;if(s===e)return r;let n=pt(s.parent);for(let a of n){if(a===s)break;if(a===e||gt(a,e))return!0}}while(s=s.parent);throw new Error("Unexpected path")}function ut(e,t,r,s){let n=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a==="parent"?n.parent=Array.isArray(r)?s:r:o&&typeof o=="object"?n[a]=ut(o,t,n,r):(a==="type"&&o===l.CapturingGroup&&t.set(n,t.get(e)??e),n[a]=o);return n}function st(e){return{type:l.Recursion,ref:e}}function Er(e,t){let r=[];for(;e=e.parent;)(!t||t(e))&&r.push(e);return r}function Ae(e){for(let t of["alternatives","classes","elements"])if(e[t])return t;return null}function lt(e){let 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 br({dotAll:e,ignoreCase:t}){let 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 pt(e){if(!e)throw new Error("Node expected");if(e.type===l.Quantifier)return[e.element];let t=Ae(e);return t&&e[t]}function ft(e){let t=e.find(r=>r.kind===w.search_start||ie(r,{negate:!1})||!te(r));if(!t)return null;if(t.kind===w.search_start)return t;if(v(t))return t.alternatives[0].elements[0];if(t.type===l.Group||t.type===l.CapturingGroup){let r=[];for(let s of t.alternatives){let n=ft(s.elements);if(!n)return null;Array.isArray(n)?r.push(...n):r.push(n)}return r}return null}function gt(e,t){let r=pt(e)??[];for(let s of r)if(s===t||gt(s,t))return!0;return!1}function xr(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function $(e,t){let r=!!t?.skipPropertyNameValidation,n=Q(K(e),{skipPropertyNameValidation:r}).pattern.alternatives;return n.length>1||n[0].elements.length>1?ce(I(),n):n[0].elements[0]}function Z(e,t){let r=Ae(e);return e[r][0].parent=e,t&&ce(e[r][0],t),e}function ht(e,{parent:t,key:r,container:s},n,a){F({node:e,parent:t,key:r,container:s},n,a)}function Ct(e,t){let r=J(t),s=B(r.target,"ES2024"),n=B(r.target,"ES2025"),a=r.maxRecursionDepth;if(a!==null&&(!Number.isInteger(a)||a<2||a>100))throw new Error("Invalid maxRecursionDepth; use 2-100 or null");let o=null,i=null;if(!n){let d=[e.flags.ignoreCase];F({node:e},{getCurrentModI:()=>d.at(-1),popModI(){d.pop()},pushModI(y){d.push(y)},setHasCasedChar(){d.at(-1)?o=!0:i=!0}},Sr)}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!i)},u=null,p={accuracy:r.accuracy,appliedGlobalFlags:c,captureFlagIMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},groupNames:new Set,inCharClass:!1,lastNode:u,maxRecursionDepth:a,useAppliedIgnoreCase:!!(!n&&o&&i),useDuplicateNames:n,useFlagMods:n,useFlagV:s,usePostEs2018Properties:s,verbose:r.verbose};function h(d){switch(p.lastNode=u,u=d,d.type){case l.Regex:return{pattern:h(d.pattern),flags:h(d.flags),options:{...d.options}};case l.Alternative:return d.elements.map(h).join("");case l.Assertion:return Fr(d,p,h);case l.Backreference:return Ir(d,p);case l.CapturingGroup:return Gr(d,p,h);case l.Character:return Pr(d,p);case l.CharacterClass:return Nr(d,p,h);case l.CharacterClassIntersection:if(!p.useFlagV)throw new Error("Use of class intersection requires min target ES2024");return d.classes.map(h).join("&&");case l.CharacterClassRange:return Mr(d,p);case l.CharacterSet:return Rr(d,p);case l.Flags:return Tr(d,p);case l.Group:return Or(d,p,h);case l.Pattern:return d.alternatives.map(h).join("|");case l.Quantifier:return h(d.element)+Br(d);case l.Recursion:return Ur(d,p);default:throw new Error(`Unexpected node type "${d.type}"`)}}let C=h(e);return s||(delete C.options.force.v,C.options.disable.v=!0,C.options.unicodeSetsPlugin=null),C}var Sr={AnyGroup:{enter({node:e},t){let r=t.getCurrentModI();t.pushModI(e.flags?O({ignoreCase:r},e.flags).ignoreCase:r)},exit(e,t){t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){_e(k(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},r){t(),mt(e,{firstOnly:!0}).length&&r.setHasCasedChar()},CharacterSet({node:e},t){e.kind===b.property&&Ce.has(e.value)&&t.setHasCasedChar()}},Ar=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),_r=new Set(["-","\\","]","^"]),$r=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),dt=new Map([[9,f`\t`],[10,f`\n`],[11,f`\v`],[12,f`\f`],[13,f`\r`],[8232,f`\u2028`],[8233,f`\u2029`],[65279,f`\uFEFF`]]),vr=/^\p{Cased}$/u;function _e(e){return vr.test(e)}function Fr(e,t,r){let{kind:s,negate:n,alternatives:a}=e;if(v(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?f`\B`:f`\b`;throw new Error(`Unexpected assertion kind "${s}"`)}function Ir({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.captureFlagIMap.get(e))throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e}function Gr({name:e,number:t,alternatives:r},s,n){return e&&(s.groupNames.has(e)?s.useDuplicateNames||(e=null):s.groupNames.add(e)),s.captureFlagIMap.set(t,s.currentFlags.ignoreCase),`(${e?`?<${e}>`:""}${r.map(n).join("|")})`}function Pr({value:e},t){let r=k(e),s=D(e,{isAfterBackref:t.lastNode.type===l.Backreference,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(s!==r)return s;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&_e(r)){let n=fe(r);return t.inCharClass?n.join(""):n.length>1?`[${n.join("")}]`:n[0]}return r}function Nr({negate:e,parent:t,elements:r},s,n){if(!e&&(!s.useFlagV||!s.verbose)&&t.type===l.CharacterClass&&r[0].type!==l.CharacterClassIntersection||!s.verbose&&t.type===l.CharacterClassIntersection&&r.length===1&&r[0].type!==l.CharacterClassRange)return r.map(n).join("");if(!s.useFlagV&&t.type===l.CharacterClass)throw new Error("Use of nested character class requires min target ES2024");s.inCharClass=!0;let a=`[${e?"^":""}${r.map(n).join("")}]`;return s.inCharClass=!1,a}function Mr(e,t){let r=e.min.value,s=e.max.value,n={isAfterBackref:!1,inCharClass:!0,useFlagV:t.useFlagV},a=D(r,n),o=D(s,n),i="";if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let c=mt(e);Dr(c).forEach(p=>{i+=Array.isArray(p)?`${D(p[0],n)}-${D(p[1],n)}`:D(p,n)})}return`${a}-${o}${i}`}function Rr({kind:e,negate:t,value:r,key:s},n){if(e===b.dot)return n.currentFlags.dotAll?n.appliedGlobalFlags.dotAll||n.useFlagMods?".":"[^]":f`[^\n]`;if(e===b.digit)return t?f`\D`:f`\d`;if(e===b.property){if(!n.usePostEs2018Properties&&Ne.has(r))throw new Error(`Unicode property "${r}" unavailable in target ES2018`);if(n.useAppliedIgnoreCase&&n.currentFlags.ignoreCase&&Ce.has(r))throw new Error(`Unicode property "${r}" can't be case-insensitive when other chars have specific case`);return`${t?f`\P`:f`\p`}{${s?`${s}=`:""}${r}}`}if(e===b.word)return t?f`\W`:f`\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 Or({atomic:e,flags:t,parent:r,alternatives:s},n,a){let o=n.currentFlags;t&&(n.currentFlags=O(o,t));let i=s.map(a).join("|"),c=!n.verbose&&s.length===1&&r.type!==l.Quantifier&&!e&&(!n.useFlagMods||!t)?i:`(?${Lr(e,t,n.useFlagMods)}${i})`;return n.currentFlags=o,c}function Ur({ref:e},t){let r=t.maxRecursionDepth;if(!r)throw new Error("Use of recursion disabled");if(t.accuracy==="strict")throw new Error("Use of recursion requires non-strict accuracy due to depth limit");return e===0?`(?R=${r})`:f`\g<${e}&R=${r}>`}function mt(e,t){let 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 o=s;o<=n;o++){let i=k(o);if(!_e(i))continue;let c=fe(i).filter(u=>{let p=u.codePointAt(0);return p<s||p>n});if(c.length&&(a.push(...c),r))break}return a}function D(e,{isAfterBackref:t,inCharClass:r,useFlagV:s}){if(dt.has(e))return dt.get(e);if(e<32||e>126&&e<160||e>262143||t&&Vr(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let n=r?s?$r:_r:Ar,a=k(e);return(n.has(a)?"\\":"")+a}function Dr(e){let t=e.map(n=>n.codePointAt(0)).sort((n,a)=>n-a),r=[],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 Lr(e,t,r){if(e)return">";let s="";if(t&&r){let{enable:n,disable:a}=t;s=(n?.ignoreCase?"i":"")+(n?.dotAll?"s":"")+(a?"-":"")+(a?.ignoreCase?"i":"")+(a?.dotAll?"s":"")}return`${s}:`}function Br({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 Vr(e){return e>47&&e<58}var jr=String.raw`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,ve=String.raw`\(\?R=(?<rDepth>[^\)]+)\)|${jr}`,Fe=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,R=new RegExp(String.raw`${Fe}|${ve}|\(\?|\\?.`,"gsu"),$e="Cannot use multiple overlapping recursions";function Et(e){if(!new RegExp(ve,"su").test(e))return e;if(ae(e,String.raw`\\[1-9]`,S.DEFAULT))throw new Error("Numbered backrefs cannot be used with recursion");if(ae(e,String.raw`\(\?\(DEFINE\)`,S.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let t=new Map,r=[],s=!1,n=0,a=0,o;for(R.lastIndex=0;o=R.exec(e);){let{0:i,groups:{captureName:c,rDepth:u,gRNameOrNum:p,gRDepth:h}}=o;if(i==="[")n++;else if(n)i==="]"&&n--;else if(u){if(wt(u),s)throw new Error($e);let C=e.slice(0,o.index),d=e.slice(R.lastIndex);if(ae(d,ve,S.DEFAULT))throw new Error($e);return kt(C,d,+u,!1)}else if(p){wt(h);let C=!1;for(let L of r)if(L.name===p||L.num===+p){if(C=!0,L.hasRecursedWithin)throw new Error($e);break}if(!C)throw new Error(`Recursive \\g cannot be used outside the referenced group "\\g<${p}&R=${h}>"`);let d=t.get(p),y=qe(e,d),N=e.slice(d,o.index),T=y.slice(N.length+i.length),A=kt(N,T,+h,!0),xt=e.slice(0,d),St=e.slice(d+y.length);e=`${xt}${A}${St}`,R.lastIndex+=A.length-i.length-N.length-T.length,r.forEach(L=>L.hasRecursedWithin=!0),s=!0}else if(c)a++,t.set(String(a),R.lastIndex),t.set(c,R.lastIndex),r.push({num:a,name:c});else if(i.startsWith("(")){let C=i==="(";C&&(a++,t.set(String(a),R.lastIndex)),r.push(C?{num:a}:{})}else i===")"&&r.pop()}return e}function wt(e){let 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 kt(e,t,r,s){let n=new Set;s&&Qe(e+t,Fe,({groups:{captureName:o}})=>{n.add(o)},S.DEFAULT);let a=r-1;return`${e}${yt(`(?:${e}`,a,s?n:null)}(?:)${yt(`${t})`,a,s?n:null,"backward")}${t}`}function yt(e,t,r,s="forward"){let a=i=>s==="backward"?t-i+2-1:i+2,o="";for(let i=0;i<t;i++){let c=a(i);o+=M(e,String.raw`${Fe}|\\k<(?<backref>[^>]+)>`,({0:u,groups:{captureName:p,backref:h}})=>{if(h&&r&&!r.has(h))return u;let C=`_$${c}`;return p?`(?<${p}${C}>`:`\\k<${h}${C}>`},S.DEFAULT)}return o}function bt(e,t){let r=J(t),s=K(e,r.flags),n=Q(s,{skipBackrefValidation:r.tmGrammar,verbose:r.verbose}),a=at(n,{accuracy:r.accuracy,avoidSubclass:r.avoidSubclass,bestEffortTarget:r.target}),o=Ct(a,r);e=xe(Et(o.pattern));let i=be(e,{useEmulationGroups:!r.avoidSubclass}),c=i!==e&&!r.avoidSubclass;e=i;let u={pattern:e,flags:`${r.hasIndices?"d":""}${r.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};return(c||a._strategy)&&(u.subclass={useEmulationGroups:c,strategy:a._strategy??null}),u}function Kr(e,t){return Q(K(e,t?.flags))}function Wr(e,t){let r=bt(e,t);return r.subclass?new X(r.pattern,r.flags,r.subclass):new RegExp(r.pattern,r.flags)}return It(Hr);})(); | ||
\v\f\x85\u2028\u2029])`));else if(n===Q.grapheme){if(r==="strict")throw new Error(f`Use of "\X" requires non-strict accuracy`);let a=s?f`\p{RGI_Emoji}`:at().source.replace(/\\u\{/g,"\\x{");t($(f`(?>\r\n|${a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}))}else throw new Error(`Unexpected varcharset kind "${n}"`)}},ut={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:r}){let{orphan:s,ref:n}=e;s||r.set(e,[...t.get(n).map(({node:a})=>a)])},Recursion({node:e,parent:t},{reffedNodesByReferencer:r}){let{ref:s}=e,n=t;for(;(n=n.parent)&&!(n.type===l.CapturingGroup&&(n.name===s||n.number===s)););r.set(e,n)},CapturingGroup:{enter({node:e,replaceWith:t,skip:r},{groupOriginByCopy:s,groupsByName:n,multiplexCapturesToLeftByRef:a,openRefs:o,reffedNodesByReferencer:i}){let c=s.get(e),u=e.name??e.number;if(c&&o.has(u)){let h=ot(u);i.set(h,o.get(u)),t(h),r();return}o.set(u,e);let p=D(a,u,[]);for(let h=0;h<p.length;h++){let C=p[h];if(c===C.node||c&&c===C.origin||e===C.origin){p.splice(h,1);break}}if(p.push({node:e,origin:c}),e.name){let h=D(n,e.name,new Map);for(let C of h.values())!C.hasDuplicateNameToRemove&<(C.node,e,{ancestorsParticipate:!0})&&(C.hasDuplicateNameToRemove=!0);n.get(e.name).set(e,{node:e})}},exit({node:e},{openRefs:t}){t.delete(e.name??e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=U(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine(e,t){let{node:r,replaceWith:s}=e,{ref:n}=r,a=t.subroutineRefMap.get(n),o=n===0,i=o?ot(n):pt(a,t.groupOriginByCopy,null),c=i;if(!o){let u=ft(Sr(a,h=>h.type===l.Group&&!!h.flags)),p=u?U(t.globalFlags,u):t.globalFlags;xr(p,t.currentFlags)||(c=Y(I({flags:Ar(p)}),[i]))}s(c),o||Ct(c,e,t,ut)}},Er={Backreference({node:e,replaceWith:t},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let n=r.reffedNodesByReferencer.get(e).filter(a=>lt(a,e,{ancestorsParticipate:!1}));if(!n.length)t(oe({negate:!0}));else if(n.length>1){let a=n.map(o=>le(N(),[se(o.number)]));t(le(I(),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){let r=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let s=0;s<r;s++){let n=Ee();e.pattern.alternatives.at(-1).elements.push(n)}}}},br="[ -\r ]",G=f`[\p{L}\p{M}\p{N}\p{Pc}]`;function le(e,t){return t.forEach(r=>r.parent=e),e[$e(e)]=t,e}function xr(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function lt(e,t,{ancestorsParticipate:r}){let s=t;do{if(s.type===l.Pattern)return!1;if(s.type===l.Alternative)continue;if(s===e)return r;let n=gt(s.parent);for(let a of n){if(a===s)break;if(a===e||dt(a,e))return!0}}while(s=s.parent);throw new Error("Unexpected path")}function pt(e,t,r,s){let n=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a==="parent"?n.parent=Array.isArray(r)?s:r:o&&typeof o=="object"?n[a]=pt(o,t,n,r):(a==="type"&&o===l.CapturingGroup&&t.set(n,t.get(e)??e),n[a]=o);return n}function ot(e){return{type:l.Recursion,ref:e}}function Sr(e,t){let r=[];for(;e=e.parent;)(!t||t(e))&&r.push(e);return r}function $e(e){for(let t of["alternatives","classes","elements"])if(e[t])return t;return null}function ft(e){let 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 Ar({dotAll:e,ignoreCase:t}){let 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 gt(e){if(!e)throw new Error("Node expected");if(e.type===l.Quantifier)return[e.element];let t=$e(e);return t&&e[t]}function ht(e){let t=e.find(r=>r.kind===w.search_start||ue(r,{negate:!1})||!ne(r));if(!t)return null;if(t.kind===w.search_start)return t;if(v(t))return t.alternatives[0].elements[0];if(t.type===l.Group||t.type===l.CapturingGroup){let r=[];for(let s of t.alternatives){let n=ht(s.elements);if(!n)return null;Array.isArray(n)?r.push(...n):r.push(n)}return r}return null}function dt(e,t){let r=gt(e)??[];for(let s of r)if(s===t||dt(s,t))return!0;return!1}function _r(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function $(e,t){let r=!!t?.skipPropertyNameValidation,n=X(H(e),{skipPropertyNameValidation:r}).pattern.alternatives;return n.length>1||n[0].elements.length>1?le(I(),n):n[0].elements[0]}function Y(e,t){let r=$e(e);return e[r][0].parent=e,t&&le(e[r][0],t),e}function _e(e,t){return e.negate=t,e}function Ct(e,{parent:t,key:r,container:s},n,a){F({node:e,parent:t,key:r,container:s},n,a)}function wt(e,t){let r=ee(t),s=W(r.target,"ES2024"),n=W(r.target,"ES2025"),a=r.maxRecursionDepth;if(a!==null&&(!Number.isInteger(a)||a<2||a>100))throw new Error("Invalid maxRecursionDepth; use 2-100 or null");let o=null,i=null;if(!n){let d=[e.flags.ignoreCase];F({node:e},{getCurrentModI:()=>d.at(-1),popModI(){d.pop()},pushModI(E){d.push(E)},setHasCasedChar(){d.at(-1)?o=!0:i=!0}},$r)}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!i)},u=null,p={accuracy:r.accuracy,appliedGlobalFlags:c,captureFlagIMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},groupNames:new Set,inCharClass:!1,lastNode:u,maxRecursionDepth:a,useAppliedIgnoreCase:!!(!n&&o&&i),useDuplicateNames:n,useFlagMods:n,useFlagV:s,usePostEs2018Properties:s,verbose:r.verbose};function h(d){switch(p.lastNode=u,u=d,d.type){case l.Regex:return{pattern:h(d.pattern),flags:h(d.flags),options:{...d.options}};case l.Alternative:return d.elements.map(h).join("");case l.Assertion:return Pr(d,p,h);case l.Backreference:return Nr(d,p);case l.CapturingGroup:return Mr(d,p,h);case l.Character:return Rr(d,p);case l.CharacterClass:return Or(d,p,h);case l.CharacterClassIntersection:if(!p.useFlagV)throw new Error("Use of class intersection requires min target ES2024");return d.classes.map(h).join("&&");case l.CharacterClassRange:return Tr(d,p);case l.CharacterSet:return Ur(d,p);case l.Flags:return Dr(d,p);case l.Group:return Lr(d,p,h);case l.Pattern:return d.alternatives.map(h).join("|");case l.Quantifier:return h(d.element)+jr(d);case l.Recursion:return Br(d,p);default:throw new Error(`Unexpected node type "${d.type}"`)}}let C=h(e);return s||(delete C.options.force.v,C.options.disable.v=!0,C.options.unicodeSetsPlugin=null),C}var $r={AnyGroup:{enter({node:e},t){let r=t.getCurrentModI();t.pushModI(e.flags?U({ignoreCase:r},e.flags).ignoreCase:r)},exit(e,t){t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){ve(y(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},r){t(),kt(e,{firstOnly:!0}).length&&r.setHasCasedChar()},CharacterSet({node:e},t){e.kind===k.property&&we.has(e.value)&&t.setHasCasedChar()}},vr=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Fr=new Set(["-","\\","]","^"]),Ir=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),mt=new Map([[9,f`\t`],[10,f`\n`],[11,f`\v`],[12,f`\f`],[13,f`\r`],[8232,f`\u2028`],[8233,f`\u2029`],[65279,f`\uFEFF`]]),Gr=/^\p{Cased}$/u;function ve(e){return Gr.test(e)}function Pr(e,t,r){let{kind:s,negate:n,alternatives:a}=e;if(v(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?f`\B`:f`\b`;throw new Error(`Unexpected assertion kind "${s}"`)}function Nr({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.captureFlagIMap.get(e))throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e}function Mr({name:e,number:t,alternatives:r},s,n){return e&&(s.groupNames.has(e)?s.useDuplicateNames||(e=null):s.groupNames.add(e)),s.captureFlagIMap.set(t,s.currentFlags.ignoreCase),`(${e?`?<${e}>`:""}${r.map(n).join("|")})`}function Rr({value:e},t){let r=y(e),s=B(e,{isAfterBackref:t.lastNode.type===l.Backreference,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(s!==r)return s;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&ve(r)){let n=he(r);return t.inCharClass?n.join(""):n.length>1?`[${n.join("")}]`:n[0]}return r}function Or({negate:e,parent:t,elements:r},s,n){let a=()=>`[${e?"^":""}${r.map(n).join("")}]`;if(!s.inCharClass){s.inCharClass=!0;let i=a();return s.inCharClass=!1,i}let o=r[0].type;if(!e&&(!s.useFlagV||!s.verbose)&&t.type===l.CharacterClass&&o!==l.CharacterClassIntersection||!s.verbose&&t.type===l.CharacterClassIntersection&&r.length===1&&o!==l.CharacterClass&&o!==l.CharacterClassRange)return r.map(n).join("");if(!s.useFlagV&&t.type===l.CharacterClass)throw new Error("Use of nested character class requires min target ES2024");return a()}function Tr(e,t){let r=e.min.value,s=e.max.value,n={isAfterBackref:!1,inCharClass:!0,useFlagV:t.useFlagV},a=B(r,n),o=B(s,n),i="";if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let c=kt(e);Vr(c).forEach(p=>{i+=Array.isArray(p)?`${B(p[0],n)}-${B(p[1],n)}`:B(p,n)})}return`${a}-${o}${i}`}function Ur({kind:e,negate:t,value:r,key:s},n){if(e===k.dot)return n.currentFlags.dotAll?n.appliedGlobalFlags.dotAll||n.useFlagMods?".":"[^]":f`[^\n]`;if(e===k.digit)return t?f`\D`:f`\d`;if(e===k.property){if(!n.usePostEs2018Properties&&Re.has(r))throw new Error(`Unicode property "${r}" unavailable in target ES2018`);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?f`\P`:f`\p`}{${s?`${s}=`:""}${r}}`}if(e===k.word)return t?f`\W`:f`\w`;throw new Error(`Unexpected character set kind "${e}"`)}function Dr(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")}function Lr({atomic:e,flags:t,parent:r,alternatives:s},n,a){let o=n.currentFlags;t&&(n.currentFlags=U(o,t));let i=s.map(a).join("|"),c=!n.verbose&&s.length===1&&r.type!==l.Quantifier&&!e&&(!n.useFlagMods||!t)?i:`(?${Wr(e,t,n.useFlagMods)}${i})`;return n.currentFlags=o,c}function Br({ref:e},t){let r=t.maxRecursionDepth;if(!r)throw new Error("Use of recursion disabled");if(t.accuracy==="strict")throw new Error("Use of recursion requires non-strict accuracy due to depth limit");return e===0?`(?R=${r})`:f`\g<${e}&R=${r}>`}function kt(e,t){let 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 o=s;o<=n;o++){let i=y(o);if(!ve(i))continue;let c=he(i).filter(u=>{let p=u.codePointAt(0);return p<s||p>n});if(c.length&&(a.push(...c),r))break}return a}function B(e,{isAfterBackref:t,inCharClass:r,useFlagV:s}){if(mt.has(e))return mt.get(e);if(e<32||e>126&&e<160||e>262143||t&&Kr(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let n=r?s?Ir:Fr:vr,a=y(e);return(n.has(a)?"\\":"")+a}function Vr(e){let t=e.map(n=>n.codePointAt(0)).sort((n,a)=>n-a),r=[],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 Wr(e,t,r){if(e)return">";let s="";if(t&&r){let{enable:n,disable:a}=t;s=(n?.ignoreCase?"i":"")+(n?.dotAll?"s":"")+(a?"-":"")+(a?.ignoreCase?"i":"")+(a?.dotAll?"s":"")}return`${s}:`}function jr({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 Kr(e){return e>47&&e<58}var Hr=String.raw`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Ie=String.raw`\(\?R=(?<rDepth>[^\)]+)\)|${Hr}`,Ge=String.raw`\(\?<(?![=!])(?<captureName>[^>]+)>`,O=new RegExp(String.raw`${Ge}|${Ie}|\(\?|\\?.`,"gsu"),Fe="Cannot use multiple overlapping recursions";function xt(e){if(!new RegExp(Ie,"su").test(e))return e;if(ie(e,String.raw`\\[1-9]`,S.DEFAULT))throw new Error("Numbered backrefs cannot be used with recursion");if(ie(e,String.raw`\(\?\(DEFINE\)`,S.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let t=new Map,r=[],s=!1,n=0,a=0,o;for(O.lastIndex=0;o=O.exec(e);){let{0:i,groups:{captureName:c,rDepth:u,gRNameOrNum:p,gRDepth:h}}=o;if(i==="[")n++;else if(n)i==="]"&&n--;else if(u){if(yt(u),s)throw new Error(Fe);let C=e.slice(0,o.index),d=e.slice(O.lastIndex);if(ie(d,Ie,S.DEFAULT))throw new Error(Fe);return Et(C,d,+u,!1)}else if(p){yt(h);let C=!1;for(let V of r)if(V.name===p||V.num===+p){if(C=!0,V.hasRecursedWithin)throw new Error(Fe);break}if(!C)throw new Error(`Recursive \\g cannot be used outside the referenced group "\\g<${p}&R=${h}>"`);let d=t.get(p),E=Ze(e,d),M=e.slice(d,o.index),T=E.slice(M.length+i.length),A=Et(M,T,+h,!0),At=e.slice(0,d),_t=e.slice(d+E.length);e=`${At}${A}${_t}`,O.lastIndex+=A.length-i.length-M.length-T.length,r.forEach(V=>V.hasRecursedWithin=!0),s=!0}else if(c)a++,t.set(String(a),O.lastIndex),t.set(c,O.lastIndex),r.push({num:a,name:c});else if(i.startsWith("(")){let C=i==="(";C&&(a++,t.set(String(a),O.lastIndex)),r.push(C?{num:a}:{})}else i===")"&&r.pop()}return e}function yt(e){let 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 Et(e,t,r,s){let n=new Set;s&&Xe(e+t,Ge,({groups:{captureName:o}})=>{n.add(o)},S.DEFAULT);let a=r-1;return`${e}${bt(`(?:${e}`,a,s?n:null)}(?:)${bt(`${t})`,a,s?n:null,"backward")}${t}`}function bt(e,t,r,s="forward"){let a=i=>s==="backward"?t-i+2-1:i+2,o="";for(let i=0;i<t;i++){let c=a(i);o+=R(e,String.raw`${Ge}|\\k<(?<backref>[^>]+)>`,({0:u,groups:{captureName:p,backref:h}})=>{if(h&&r&&!r.has(h))return u;let C=`_$${c}`;return p?`(?<${p}${C}>`:`\\k<${h}${C}>`},S.DEFAULT)}return o}function St(e,t){let r=ee(t),s=H(e,r.flags),n=X(s,{skipBackrefValidation:r.rules.allowOrphanBackrefs,verbose:r.verbose}),a=it(n,{accuracy:r.accuracy,allowUnhandledGAnchors:r.rules.allowUnhandledGAnchors,asciiWordBoundaries:r.rules.asciiWordBoundaries,avoidSubclass:r.avoidSubclass,bestEffortTarget:r.target}),o=wt(a,r);e=Se(xt(o.pattern));let i=xe(e,{useEmulationGroups:!r.avoidSubclass}),c=i!==e&&!r.avoidSubclass;e=i;let u={pattern:e,flags:`${r.hasIndices?"d":""}${r.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};return(c||a._strategy)&&(u.subclass={useEmulationGroups:c,strategy:a._strategy??null}),u}function zr(e,t){return X(H(e,t?.flags))}function Qr(e,t){let r=St(e,t);return r.subclass?new J(r.pattern,r.flags,r.subclass):new RegExp(r.pattern,r.flags)}return Pt(qr);})(); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "oniguruma-to-es", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Convert Oniguruma patterns to native JavaScript RegExp", | ||
@@ -5,0 +5,0 @@ "author": "Steven Levithan", |
198
README.md
@@ -10,3 +10,3 @@ # Oniguruma-To-ES | ||
- Take advantage of Oniguruma's many extended regex features in JavaScript. | ||
- Run regexes written for Oniguruma from JavaScript, such as those used in TextMate grammars (used by VS Code, [Shiki](https://shiki.matsu.io/) syntax highlighter, etc.). | ||
- Run regexes written for Oniguruma from JavaScript, such as those used in TextMate grammars (used by VS Code, [Shiki](https://shiki.style/) syntax highlighter, etc.). | ||
- Share regexes across your Ruby and JavaScript code. | ||
@@ -26,2 +26,3 @@ | ||
- [Supported features](#-supported-features) | ||
- [Unsupported features](#-unsupported-features) | ||
- [Unicode / mixed case-sensitivity](#️-unicode--mixed-case-sensitivity) | ||
@@ -75,3 +76,3 @@ | ||
type OnigurumaToEsOptions = { | ||
accuracy?: 'strict' | 'default' | 'loose'; | ||
accuracy?: 'default' | 'strict'; | ||
avoidSubclass?: boolean; | ||
@@ -82,4 +83,8 @@ flags?: string; | ||
maxRecursionDepth?: number | null; | ||
rules?: { | ||
allowOrphanBackrefs?: boolean; | ||
allowUnhandledGAnchors?: boolean; | ||
asciiWordBoundaries?: boolean; | ||
}; | ||
target?: 'auto' | 'ES2025' | 'ES2024' | 'ES2018'; | ||
tmGrammar?: boolean; | ||
verbose?: boolean; | ||
@@ -143,37 +148,21 @@ }; | ||
One of `'strict'`, `'default'` *(default)*, or `'loose'`. | ||
One of `'default'` *(default)* or `'strict'`. | ||
Sets the level of emulation rigor/strictness. | ||
- **Strict:** Throw if the pattern can't be emulated with identical behavior (even in rare edge cases) for the given `target`. | ||
- **Default:** The best choice in most cases. Permits a few close approximations of Oniguruma in order to support additional features. | ||
- **Loose:** Useful for non-critical matching like syntax highlighting where having some mismatches is better than not working. | ||
- **Default:** Permits a few close approximations in order to support additional features. | ||
- **Strict:** Error if the pattern can't be emulated with identical behavior (even in rare edge cases) for the given `target`. | ||
Each level of increased accuracy supports a subset of patterns supported by lower accuracies. If a given pattern doesn't produce an error for a particular accuracy, its generated result will be identical with all lower levels of accuracy (given the same `target`). | ||
<details> | ||
<summary>More details</summary> | ||
#### `strict` | ||
Using default `accuracy` adds support for the following features, depending on `target`: | ||
Supports slightly fewer features, but the missing features are all relatively uncommon (see below). | ||
#### `default` | ||
Supports all features of `strict`, plus the following additional features, depending on `target`: | ||
- All targets (`ES2025` and earlier): | ||
- Enables use of `\X` using a close approximation of a Unicode extended grapheme cluster. | ||
- Enables recursion (e.g. via `\g<0>`) with a depth limit specified by option `maxRecursionDepth`. | ||
- Enables recursion (ex: `\g<0>`) with a depth limit specified by option `maxRecursionDepth`. | ||
- `ES2024` and earlier: | ||
- Enables use of case-insensitive backreferences to case-sensitive groups. | ||
- `ES2018`: | ||
- Enables use of POSIX classes `[:graph:]` and `[:print:]` using ASCII-based versions rather than the Unicode versions available for `ES2024` and later. Other POSIX classes are always based on Unicode. | ||
#### `loose` | ||
Supports all features of `default`, plus the following: | ||
- Silences errors for unsupported uses of the search-start anchor `\G` (a flexible assertion that doesn’t have a direct equivalent in JavaScript). | ||
- Oniguruma-To-ES uses a variety of strategies to accurately emulate many common uses of `\G`. When using `loose` accuracy, if a `\G` assertion is found that doesn't have a known emulation strategy, the `\G` is simply removed and JavaScript's `y` (`sticky`) flag is added. This might lead to some false positives and negatives. | ||
- Enables use of POSIX classes `[:graph:]` and `[:print:]` using ASCII-based versions rather than the Unicode versions available for `ES2024` and later. Other POSIX classes are always Unicode-based. | ||
</details> | ||
@@ -189,3 +178,3 @@ | ||
Oniguruma flags; a string with `i`, `m`, and `x` in any order (all optional). | ||
Oniguruma flags; a string with `i`, `m`, `x`, `D`, `S`, `W` in any order (all optional). | ||
@@ -223,2 +212,11 @@ Flags can also be specified via modifiers in the pattern. | ||
### `rules` | ||
Advanced pattern options that override standard error checking and flags when enabled. | ||
- `allowOrphanBackrefs`: Useful with TextMate grammars that merge backreferences across patterns. | ||
- `allowUnhandledGAnchors`: Applies flag `y` for unsupported uses of `\G`, rather than erroring. | ||
- Oniguruma-To-ES uses a variety of strategies to accurately emulate many common uses of `\G`. When using this option, if a `\G` is found that doesn't have a known emulation strategy, the `\G` is simply removed and JavaScript's `y` (`sticky`) flag is added. This might lead to some false positives and negatives, but is useful for non-critical matching (like syntax highlighting) when having some mismatches is better than not working. | ||
- `asciiWordBoundaries`: Use ASCII-based `\b` and `\B`, which increases performance. | ||
### `target` | ||
@@ -244,8 +242,2 @@ | ||
### `tmGrammar` | ||
*Default: `false`.* | ||
Leave disabled unless the regex will be used in a TextMate grammar processor that merges backreferences across `begin` and `end` patterns. | ||
### `verbose` | ||
@@ -264,3 +256,3 @@ | ||
Notice that nearly every feature below has at least subtle differences from JavaScript. Some features and subfeatures listed as unsupported are not emulatable using native JavaScript regexes, but support for others might be added in future versions of this library. Unsupported features throw an error. | ||
Notice that nearly every feature below has at least subtle differences from JavaScript. Some features listed as unsupported are not emulatable using native JavaScript regexes, but support for others might be added in future versions of this library. Unsupported features throw an error. | ||
@@ -277,5 +269,8 @@ <table> | ||
<tr valign="top"> | ||
<th align="left" rowspan="4">Flags</th> | ||
<th align="left" rowspan="8">Flags</th> | ||
<td colspan="5"><i>Supported in top-level flags and pattern modifiers</i></td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Ignore case</td> | ||
<td><code>i</code></td> | ||
<td><code>i</code></td> | ||
<td align="middle">✅</td> | ||
@@ -288,13 +283,13 @@ <td align="middle">✅</td> | ||
<tr valign="top"> | ||
<td>Dot all</td> | ||
<td><code>m</code></td> | ||
<td><code>m</code></td> | ||
<td align="middle">✅</td> | ||
<td align="middle">✅</td> | ||
<td> | ||
✔ Equivalent to JS flag <code>s</code> (<code>dotAll</code>)<br> | ||
✔ Equivalent to JS flag <code>s</code><br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Extended</td> | ||
<td><code>x</code></td> | ||
<td><code>x</code></td> | ||
<td align="middle">✅</td> | ||
@@ -312,10 +307,29 @@ <td align="middle">✅</td> | ||
<tr valign="top"> | ||
<td colspan="5"><i>Currently supported only in top-level flags</i></td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Digit is ASCII</td> | ||
<td><code>D</code></td> | ||
<td align="middle">✅</td> | ||
<td align="middle">✅</td> | ||
<td> | ||
✔ ASCII <code>\d</code>, <code>\p{Digit}</code>, <code>[[:digit:]]</code><br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Space is ASCII</td> | ||
<td><code>S</code></td> | ||
<td align="middle">✅</td> | ||
<td align="middle">✅</td> | ||
<td> | ||
✔ ASCII <code>\s</code>, <code>\p{Space}</code>, <code>[[:space:]]</code><br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Word is ASCII</td> | ||
<td><code>W</code></td> | ||
<td><code>W</code></td> | ||
<td align="middle">✅</td> | ||
<td align="middle">✅</td> | ||
<td> | ||
● Currently supported only as a top-level flag<br> | ||
✔ ASCII <code>[[:word:]]</code>, <code>\p{Word}</code><br> | ||
✔ ASCII <code>\b</code><br> | ||
✔ ASCII <code>\b</code>, <code>\w</code>, <code>\p{Word}</code>, <code>[[:word:]]</code><br> | ||
</td> | ||
@@ -325,3 +339,3 @@ </tr> | ||
<tr valign="top"> | ||
<th align="left" rowspan="2" valign="top">Flag modifiers</th> | ||
<th align="left" rowspan="2" valign="top">Pattern modifiers</th> | ||
<td>Group</td> | ||
@@ -348,3 +362,3 @@ <td><code>(?im-x:…)</code></td> | ||
<tr valign="top"> | ||
<th align="left" rowspan="10">Characters</th> | ||
<th align="left" rowspan="9">Characters</th> | ||
<td>Literal</td> | ||
@@ -379,3 +393,3 @@ <td><code>E</code>, <code>!</code></td> | ||
<tr valign="top"> | ||
<td>Shorthand</td> | ||
<td>Control code escape</td> | ||
<td><code>\t</code></td> | ||
@@ -395,3 +409,3 @@ <td align="middle">✅</td> | ||
✔ Allows 1 hex digit<br> | ||
✔ Above <code>7F</code>, is UTF-8 encoded byte (unlike JS)<br> | ||
✔ Above <code>7F</code>, is UTF-8 encoded byte (≠ JS)<br> | ||
✔ Error for invalid encoded bytes<br> | ||
@@ -439,23 +453,11 @@ </td> | ||
</tr> | ||
<tr valign="top"> | ||
<td colspan="2">Other (extremely rare)</td> | ||
<td align="middle">❌</td> | ||
<td align="middle">❌</td> | ||
<td> | ||
Not yet supported:<br> | ||
● Non-A-Za-z with <code>\cx</code>, <code>\C-x</code><br> | ||
● Meta <code>\M-x</code>, <code>\M-\C-x</code><br> | ||
● Octal code point <code>\o{…}</code><br> | ||
● Octal UTF-8 encoded bytes<br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<th align="left" rowspan="7">Character sets</th> | ||
<td>Digit, word</td> | ||
<td><code>\d</code>, <code>\w</code>, etc.</td> | ||
<th align="left" rowspan="8">Character sets</th> | ||
<td>Digit</td> | ||
<td><code>\d</code>, <code>\D</code></td> | ||
<td align="middle">✅</td> | ||
<td align="middle">✅</td> | ||
<td> | ||
✔ Same as JS (ASCII)<br> | ||
✔ Unicode by default (≠ JS)<br> | ||
</td> | ||
@@ -478,6 +480,16 @@ </tr> | ||
<td> | ||
✔ ASCII (unlike JS)<br> | ||
✔ Unicode by default<br> | ||
✔ No JS adjustments to Unicode set (−<code>\uFEFF</code>, +<code>\x85</code>)<br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Word</td> | ||
<td><code>\w</code>, <code>\W</code></td> | ||
<td align="middle">✅</td> | ||
<td align="middle">✅</td> | ||
<td> | ||
✔ Unicode by default (≠ JS)<br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Dot</td> | ||
@@ -488,3 +500,3 @@ <td><code>.</code></td> | ||
<td> | ||
✔ Excludes only <code>\n</code> (unlike JS)<br> | ||
✔ Excludes only <code>\n</code> (≠ JS)<br> | ||
</td> | ||
@@ -618,3 +630,3 @@ </tr> | ||
<tr valign="top"> | ||
<th align="left" rowspan="7">Assertions</th> | ||
<th align="left" rowspan="6">Assertions</th> | ||
<td>Line start, end</td> | ||
@@ -677,14 +689,5 @@ <td><code>^</code>, <code>$</code></td> | ||
<td> | ||
✔ Unicode based (unlike JS)<br> | ||
✔ Unicode based (≠ JS)<br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Grapheme boundary (extremely rare)</td> | ||
<td><code>\y</code>, <code>\Y</code></td> | ||
<td align="middle">❌</td> | ||
<td align="middle">❌</td> | ||
<td> | ||
● Not yet supported<br> | ||
</td> | ||
</tr> | ||
@@ -884,3 +887,3 @@ <tr valign="top"> | ||
<tr valign="top"> | ||
<th align="left" rowspan="8">Other</th> | ||
<th align="left" rowspan="5">Other</th> | ||
<td>Comment group</td> | ||
@@ -915,32 +918,2 @@ <td><code>(?#…)</code></td> | ||
<tr valign="top"> | ||
<td>Absence operator</td> | ||
<td><code>(?~…)</code></td> | ||
<td align="middle">❌</td> | ||
<td align="middle">❌</td> | ||
<td> | ||
● Some forms are supportable<br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Conditional</td> | ||
<td><code>(?(1)…)</code></td> | ||
<td align="middle">❌</td> | ||
<td align="middle">❌</td> | ||
<td> | ||
● Some forms are supportable<br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td>Char sequence</td> | ||
<td> | ||
<code>\x{1 2 …N}</code>,<br> | ||
<code>\o{1 2 …N}</code><br> | ||
</td> | ||
<td align="middle">❌</td> | ||
<td align="middle">❌</td> | ||
<td> | ||
● Not yet supported<br> | ||
</td> | ||
</tr> | ||
<tr valign="top"> | ||
<td colspan="2">JS features unknown to Oniguruma are handled using Oniguruma syntax</td> | ||
@@ -976,2 +949,15 @@ <td align="middle">✅</td> | ||
## ❌ Unsupported features | ||
The following don't yet have any support, and throw errors. They're all infrequently-used features, with most being *extremely* rare. | ||
- Grapheme boundaries: <code>\y</code>, <code>\Y</code>. | ||
- Flags <code>P</code> (ASCII-based POSIX classes) and <code>y{g}</code>/<code>y{w}</code> (grapheme boundary modes). | ||
- Whole-pattern modifiers: Don't capture <code>(?C)</code>, ignore-case is ASCII <code>(?I)</code>, find longest <code>(?L)</code>. | ||
- Absence functions: <code>(?\~…)</code>, etc. | ||
- Conditionals: <code>(?(…)…)</code>, etc. | ||
- Rarely-used character specifiers: Non-A-Za-z with <code>\cx</code>, <code>\C-x</code>; meta <code>\M-x</code>, <code>\M-\C-x</code>; bracketed octals <code>\o{…}</code>; octal UTF-8 encoded bytes (≥ <code>\200</code>). | ||
- Code point sequences: <code>\x{H H …}</code>, <code>\o{O O …}</code>. | ||
- Callout functions: <code>(?{…})</code>, etc. | ||
## ㊗️ Unicode / mixed case-sensitivity | ||
@@ -978,0 +964,0 @@ |
export type OnigurumaToEsOptions = { | ||
accuracy?: "default" | "strict" | "loose"; | ||
accuracy?: "default" | "strict"; | ||
avoidSubclass?: boolean; | ||
@@ -8,4 +8,8 @@ flags?: string; | ||
maxRecursionDepth?: number | null; | ||
target?: "auto" | "ES2018" | "ES2024" | "ES2025"; | ||
tmGrammar?: boolean; | ||
rules?: { | ||
allowOrphanBackrefs?: boolean; | ||
allowUnhandledGAnchors?: boolean; | ||
asciiWordBoundaries?: boolean; | ||
}; | ||
target?: "auto" | "ES2025" | "ES2024" | "ES2018"; | ||
verbose?: boolean; | ||
@@ -22,4 +26,8 @@ }; | ||
maxRecursionDepth?: number | null; | ||
rules?: { | ||
allowOrphanBackrefs?: boolean; | ||
allowUnhandledGAnchors?: boolean; | ||
asciiWordBoundaries?: boolean; | ||
}; | ||
target?: keyof Target; | ||
tmGrammar?: boolean; | ||
verbose?: boolean; | ||
@@ -26,0 +34,0 @@ }} OnigurumaToEsOptions |
export namespace Accuracy { | ||
export let strict: "strict"; | ||
let _default: "default"; | ||
export { _default as default }; | ||
export let loose: "loose"; | ||
export let strict: "strict"; | ||
} | ||
export namespace EsVersion { | ||
let ES2025: number; | ||
let ES2024: number; | ||
let ES2018: number; | ||
let ES2024: number; | ||
let ES2025: number; | ||
} | ||
@@ -20,8 +19,8 @@ /** | ||
export let auto: "auto"; | ||
let ES2025_1: "ES2025"; | ||
export { ES2025_1 as ES2025 }; | ||
let ES2024_1: "ES2024"; | ||
export { ES2024_1 as ES2024 }; | ||
let ES2018_1: "ES2018"; | ||
export { ES2018_1 as ES2018 }; | ||
let ES2024_1: "ES2024"; | ||
export { ES2024_1 as ES2024 }; | ||
let ES2025_1: "ES2025"; | ||
export { ES2025_1 as ES2025 }; | ||
} |
@@ -92,6 +92,8 @@ export type OnigurumaAst = { | ||
}; | ||
export function createFlags({ ignoreCase, dotAll, extended, wordIsAscii }: { | ||
export function createFlags({ ignoreCase, dotAll, extended, digitIsAscii, spaceIsAscii, wordIsAscii }: { | ||
ignoreCase: any; | ||
dotAll: any; | ||
extended: any; | ||
digitIsAscii: any; | ||
spaceIsAscii: any; | ||
wordIsAscii: any; | ||
@@ -103,2 +105,4 @@ }): { | ||
extended: any; | ||
digitIsAscii: any; | ||
spaceIsAscii: any; | ||
wordIsAscii: any; | ||
@@ -105,0 +109,0 @@ }; |
@@ -32,2 +32,4 @@ export type RegexAst = { | ||
accuracy?: keyof Accuracy; | ||
allowUnhandledGAnchors?: boolean; | ||
asciiWordBoundaries?: boolean; | ||
avoidSubclass?: boolean; | ||
@@ -39,5 +41,7 @@ bestEffortTarget?: keyof Target; | ||
export function transform(ast: import("./parse.js").OnigurumaAst, options?: { | ||
accuracy?: "default" | "strict" | "loose"; | ||
accuracy?: "default" | "strict"; | ||
allowUnhandledGAnchors?: boolean; | ||
asciiWordBoundaries?: boolean; | ||
avoidSubclass?: boolean; | ||
bestEffortTarget?: "auto" | "ES2018" | "ES2024" | "ES2025"; | ||
bestEffortTarget?: "auto" | "ES2025" | "ES2024" | "ES2018"; | ||
}): RegexAst; |
@@ -18,4 +18,4 @@ export const cp: any; | ||
*/ | ||
export function isMinTarget(target: "auto" | "ES2018" | "ES2024" | "ES2025", min: "auto" | "ES2018" | "ES2024" | "ES2025"): boolean; | ||
export function isMinTarget(target: "auto" | "ES2025" | "ES2024" | "ES2018", min: "auto" | "ES2025" | "ES2024" | "ES2018"): boolean; | ||
export const r: any; | ||
export function throwIfNot(value: any, msg: any): any; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
674454
4110
970