oniguruma-to-es
Advanced tools
Comparing version 0.10.0 to 1.0.0
@@ -1,2 +0,2 @@ | ||
var OnigurumaToES=(()=>{var he=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var Gt=(e,t)=>{for(var r in t)he(e,r,{get:t[r],enumerable:!0})},Mt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ft(t))!It.call(e,n)&&n!==r&&he(e,n,{get:()=>t[n],enumerable:!(s=vt(t,n))||s.enumerable});return e};var Nt=e=>Mt(he({},"__esModule",{value:!0}),e);var Yr={};Gt(Yr,{EmulatedRegExp:()=>te,toDetails:()=>St,toOnigurumaAst:()=>Zr,toRegExp:()=>Jr});var x=String.fromCodePoint,h=String.raw,Oe=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),Te=(()=>{try{new RegExp("","v")}catch{return!1}return!0})();function L(e,{enable:t,disable:r}){return{dotAll:!r?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!r?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function B(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}function H(e,t){return de[e]>=de[t]}function I(e,t){if(!e)throw new Error(t??"Value expected");return e}var de={ES2025:2025,ES2024:2024,ES2018:2018},Pt={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function ne(e){if(e?.target!==void 0&&!Pt[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,asciiWordBoundaries:!1,captureGroup:!1,ignoreUnsupportedGAnchors:!1,...e?.rules}};return t.target==="auto"&&(t.target=Oe?"ES2025":Te?"ES2024":"ES2018"),t}var Rt=new Set([x(304),x(305)]);function me(e){if(Rt.has(e))return[e];let t=new Set,r=e.toLowerCase(),s=r.toUpperCase(),n=Dt.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 we=new Set(`C Other | ||
var OnigurumaToES=(()=>{var he=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var Gt=(e,t)=>{for(var r in t)he(e,r,{get:t[r],enumerable:!0})},Mt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ft(t))!It.call(e,n)&&n!==r&&he(e,n,{get:()=>t[n],enumerable:!(s=vt(t,n))||s.enumerable});return e};var Nt=e=>Mt(he({},"__esModule",{value:!0}),e);var Yr={};Gt(Yr,{EmulatedRegExp:()=>te,toDetails:()=>St,toOnigurumaAst:()=>Zr,toRegExp:()=>Jr});var x=String.fromCodePoint,h=String.raw,Oe=(()=>{try{new RegExp("(?i:)")}catch{return!1}return!0})(),Ue=(()=>{try{new RegExp("","v")}catch{return!1}return!0})();function D(e,{enable:t,disable:r}){return{dotAll:!r?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!r?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function B(e,t,r){return e.has(t)||e.set(t,r),e.get(t)}function H(e,t){return de[e]>=de[t]}function I(e,t){if(!e)throw new Error(t??"Value expected");return e}var de={ES2025:2025,ES2024:2024,ES2018:2018},Pt={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function ne(e){if(e?.target!==void 0&&!Pt[e.target])throw new Error(`Unexpected target "${e.target}"`);let t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,ignoreUnsupportedGAnchors:!1,recursionLimit:20,...e?.rules}};return t.target==="auto"&&(t.target=Oe?"ES2025":Ue?"ES2024":"ES2018"),t}var Lt=new Set([x(304),x(305)]);function me(e){if(Lt.has(e))return[e];let t=new Set,r=e.toLowerCase(),s=r.toUpperCase(),n=Tt.get(r),a=Ot.get(r),o=Ut.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 ke=new Set(`C Other | ||
Cc Control cntrl | ||
@@ -91,3 +91,3 @@ Cf Format | ||
XID_Continue XIDC | ||
XID_Start XIDS`.split(/\s/)),ke=new Map;for(let e of we)ke.set(K(e),e);var Ut=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"]),ye=new Map;for(let e of Ut)ye.set(K(e),e);var Ot=new Map([["s",x(383)],[x(383),"s"]]),Tt=new Map([[x(223),x(7838)],[x(107),x(8490)],[x(229),x(8491)],[x(969),x(8486)]]),Dt=new Map([U(453),U(456),U(459),U(498),...Ce(8072,8079),...Ce(8088,8095),...Ce(8104,8111),U(8124),U(8140),U(8188)]),se=new Map([["alnum",h`[\p{Alpha}\p{Nd}]`],["alpha",h`\p{Alpha}`],["ascii",h`\p{ASCII}`],["blank",h`[\p{Zs}\t]`],["cntrl",h`\p{cntrl}`],["digit",h`\p{Nd}`],["graph",h`[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]`],["lower",h`\p{Lower}`],["print",h`[[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",h`[\p{P}\p{S}]`],["space",h`\p{space}`],["upper",h`\p{Upper}`],["word",h`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",h`\p{AHex}`]]),De=new Set(["alnum","blank","graph","print","word","xdigit"]);function Lt(e,t){let r=[];for(let s=e;s<=t;s++)r.push(s);return r}function K(e){return e.replace(/[- _]+/g,"").toLowerCase()}function U(e){let t=x(e);return[t.toLowerCase(),t]}function Ce(e,t){return Lt(e,t).map(r=>U(r))}var be=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var d={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"},Q={flags:"flags",keep:"keep"},A={atomic:"atomic",capturing:"capturing",group:"group",lookahead:"lookahead",lookbehind:"lookbehind"},Le=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]),Ve=h`\[\^?`,je=`c.? | C(?:-.?)?|${h`[pP]\{(?:\^?[\x20\w]+\})?`}|${h`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${h`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${h`o\{[^\}]*\}?`}|${h`\d{1,3}`}`,We=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,ae=new RegExp(h` | ||
XID_Start XIDS`.split(/\s/)),we=new Map;for(let e of ke)we.set(K(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"]),be=new Map;for(let e of Rt)be.set(K(e),e);var Ot=new Map([["s",x(383)],[x(383),"s"]]),Ut=new Map([[x(223),x(7838)],[x(107),x(8490)],[x(229),x(8491)],[x(969),x(8486)]]),Tt=new Map([R(453),R(456),R(459),R(498),...Ce(8072,8079),...Ce(8088,8095),...Ce(8104,8111),R(8124),R(8140),R(8188)]),se=new Map([["alnum",h`[\p{Alpha}\p{Nd}]`],["alpha",h`\p{Alpha}`],["ascii",h`\p{ASCII}`],["blank",h`[\p{Zs}\t]`],["cntrl",h`\p{cntrl}`],["digit",h`\p{Nd}`],["graph",h`[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]`],["lower",h`\p{Lower}`],["print",h`[[\P{space}&&\P{cntrl}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",h`[\p{P}\p{S}]`],["space",h`\p{space}`],["upper",h`\p{Upper}`],["word",h`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",h`\p{AHex}`]]),Te=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 K(e){return e.replace(/[- _]+/g,"").toLowerCase()}function R(e){let t=x(e);return[t.toLowerCase(),t]}function Ce(e,t){return Dt(e,t).map(r=>R(r))}var ye=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);var d={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"},Q={flags:"flags",keep:"keep"},A={atomic:"atomic",capturing:"capturing",group:"group",lookahead:"lookahead",lookbehind:"lookbehind"},De=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]),Ve=h`\[\^?`,je=`c.? | C(?:-.?)?|${h`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${h`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${h`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${h`o\{[^\}]*\}?`}|${h`\d{1,3}`}`,We=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,ae=new RegExp(h` | ||
\\ (?: | ||
@@ -119,4 +119,4 @@ ${je} | ||
| . | ||
`.replace(/\s+/g,""),"gsu");function X(e,t="",r){if(r={captureGroup:!1,...r},typeof e!="string")throw new Error("String expected as pattern");if(!/^[imxDSW]*$/.test(t))throw new Error(`Flags "${t}" includes unsupported value`);let s=t.includes("x"),n=[s],a={captureGroup:r.captureGroup,getCurrentModX:()=>n.at(-1),numOpenGroups:0,popModX(){n.pop()},pushModX(f){n.push(f)},replaceCurrentModX(f){n[n.length-1]=f}},o=[],i;for(ae.lastIndex=0;i=ae.exec(e);){let f=Bt(a,e,i[0],ae.lastIndex);f.tokens?o.push(...f.tokens):f.token&&o.push(f.token),f.lastIndex!==void 0&&(ae.lastIndex=f.lastIndex)}let c=[],p=0;o.forEach(f=>{f.type===d.GroupOpen&&(f.kind===A.capturing?f.number=++p:f.raw==="("&&c.push(f))}),p||c.forEach((f,w)=>{f.kind=A.capturing,f.number=w+1});let l=p||c.length;return o=o.map(f=>f.type===d.EscapedNumber?zt(f,l):f).flat(),{tokens:o,flags:{ignoreCase:t.includes("i"),dotAll:t.includes("m"),extended:s,digitIsAscii:t.includes("D"),spaceIsAscii:t.includes("S"),wordIsAscii:t.includes("W")},rules:r}}function Bt(e,t,r,s){let[n,a,o]=r;if(n==="["){let i=Vt(t,r,s);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(n==="\\"){if("AbBGzZ".includes(a))return{token:C(d.Assertion,r,{kind:r})};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:C(d.Subroutine,r)}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:C(d.Backreference,r)}}if(a==="K")return{token:C(d.Directive,r,{kind:Q.keep})};if(a==="N")return{token:C(d.CharacterSet,r,{kind:E.non_newline})};if(a==="O")return{token:C(d.CharacterSet,r,{kind:E.any})};if("RX".includes(a))return{token:C(d.VariableLengthCharacterSet,r,{kind:r})};if("yY".includes(a))throw new Error(`Unsupported grapheme boundary "${r}"`);let i=He(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:Ht(r,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,r==="("&&!e.captureGroup||r==="(?:")return{token:C(d.GroupOpen,r,{kind:A.group})};if(r==="(?>")return{token:C(d.GroupOpen,r,{kind:A.atomic})};if(r==="(?="||r==="(?!"||r==="(?<="||r==="(?<!")return{token:C(d.GroupOpen,r,{kind:o==="<"?A.lookbehind:A.lookahead,negate:r.endsWith("!")})};if(o==="<"||o==="'"||r==="("&&e.captureGroup){let i=C(d.GroupOpen,r,{kind:A.capturing});return r!=="("&&(i.name=r.slice(3,-1)),{token:i}}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:C(d.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:C(d.CharacterSet,r,{kind:E.dot})}:r==="^"||r==="$"?{token:C(d.Assertion,r,{kind:r})}:r==="|"?{token:C(d.Alternator,r)}:We.test(r)?{token:Kt(r)}:(Ke(r),{token:C(d.Character,r,{value:r.codePointAt(0)})})}function Vt(e,t,r){let s=[C(d.CharacterClassOpen,t,{negate:t[1]==="^"})],n=1,a;for(xe.lastIndex=r;a=xe.exec(e);){let o=a[0];if(o[0]==="["&&o[1]!==":")n++,s.push(C(d.CharacterClassOpen,o,{negate:o[1]==="^"}));else if(o==="]"){if(s.at(-1).type===d.CharacterClassOpen)s.push(C(d.Character,o,{value:93}));else if(n--,s.push(C(d.CharacterClassClose,o)),!n)break}else{let i=jt(o);Array.isArray(i)?s.push(...i):s.push(i)}}return{tokens:s,lastIndex:xe.lastIndex||e.length}}function jt(e){if(e[0]==="\\")return He(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!se.get(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return C(d.CharacterSet,e,{kind:E.posix,negate:!!t.groups.negate,value:t.groups.name})}return e==="-"?C(d.CharacterClassHyphen,e):e==="&&"?C(d.CharacterClassIntersector,e):(Ke(e),C(d.Character,e,{value:e.codePointAt(0)}))}function He(e,{inCharClass:t}){let r=e[1];if(r==="c"||r==="C")return Wt(e);if("dDhHsSwW".includes(r))return Qt(e);if(e.startsWith(h`\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 Xt(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(p=>`\\x${p.toString(16)}`).join("");return C(d.Character,c,{value:i.codePointAt(0)})})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(r==="u"||r==="x")return C(d.Character,e,{value:qt(e)});if(Le.has(r))return C(d.Character,e,{value:Le.get(r)});if(/\d/.test(r))return C(d.EscapedNumber,e,{inCharClass:t});if(e==="\\")throw new Error(h`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return C(d.Character,e,{value:e.codePointAt(1)});throw new Error(`Unexpected escape "${e}"`)}function C(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 C(d.Character,e,{value:t.toUpperCase().codePointAt(0)-64})}function Ht(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=Be(r),o=Be(s),i={};if(a&&(i.enable=a),o&&(i.disable=o),e.endsWith(")"))return t.replaceCurrentModX(n),C(d.Directive,e,{kind:Q.flags,flags:i});if(e.endsWith(":")){t.pushModX(n),t.numOpenGroups++;let c=C(d.GroupOpen,e,{kind:A.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 C(d.Quantifier,e,t)}function Qt(e){let t=e[1].toLowerCase();return C(d.CharacterSet,e,{kind:{d:E.digit,h:E.hex,s:E.space,w:E.word}[t],negate:e[1]!==t})}function Xt(e){let{p:t,neg:r,value:s}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[ \w]+)/.exec(e).groups,n=t==="P"&&!r||t==="p"&&!!r;return C(d.CharacterSet,e,{kind:E.property,negate:n,value:s})}function Be(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 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[C(d.Backreference,r)];let a=[],o=n.match(/^[0-7]+|\d/g);for(let i=0;i<o.length;i++){let c=o[i],p;if(i===0&&c!=="8"&&c!=="9"){if(p=parseInt(c,8),p>127)throw new Error(h`Octal encoded byte above 177 unsupported "${r}"`)}else p=c.codePointAt(0);a.push(C(d.Character,(i===0?"\\":"")+c,{value:p}))}return a}function Ke(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`)}function q({alternatives:e},t){return e.length===1&&e[0].elements.length===1&&(!t||t(e[0].elements[0]))}function M({type:e,kind:t}){return e===u.Assertion&&(t===m.lookahead||t===m.lookbehind)}function oe({type:e,min:t}){return e===u.Assertion||e===u.Directive||e===u.Quantifier&&!t}function N(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 p=a(o[c],i,c,o);c=Math.max(-1,c+p)}}function a(o,i=null,c=null,p=null){let l=0,f=!1,w={node:o,parent:i,key:c,container:p,ast:s,remove(){I(p,"Container expected").splice(Math.max(0,c+l),1),l-=1},removeAllNextSiblings(){return I(p,"Container expected").splice(c+1)},removeAllPrevSiblings(){let _=c+l;return l-=_,I(p,"Container expected").splice(0,Math.max(0,_))},replaceWith(_){Jt(_,i),p?p[Math.max(0,c+l)]=_:i[c]=_},skip(){f=!0}},g=Zt(o).find(_=>!!r[_]),y=g&&r[g],b=typeof y=="function"?y:y?.enter,F=y?.exit;if(b?.(w,t),!f)switch(o.type){case u.Regex:a(o.pattern,o,"pattern"),a(o.flags,o,"flags");break;case u.Alternative:case u.CharacterClass:n(o.elements,o);break;case u.Assertion:M(o)&&n(o.alternatives,o);break;case u.Backreference:case u.Character:case u.CharacterSet:case u.Directive:case u.Flags:case u.Recursion:case u.Subroutine:case u.VariableLengthCharacterSet:break;case u.CapturingGroup:case u.Group:case u.Pattern:n(o.alternatives,o);break;case u.CharacterClassIntersection:n(o.classes,o);break;case u.CharacterClassRange:a(o.min,o,"min"),a(o.max,o,"max");break;case u.Quantifier:a(o.element,o,"element");break;default:throw new Error(`Unexpected node type "${o.type}"`)}return F?.(w,t),l}a(e.node,e.parent,e.key,e.container)}var Qe={AnyGroup:"AnyGroup",AnyNode:"AnyNode"};function Zt(e){let{type:t}=e,r=[Qe.AnyNode];return(t===u.CapturingGroup||t===u.Group||M(e))&&r.push(Qe.AnyGroup),r.push(t),r}function Jt(e,t){"parent"in t&&(e.parent=t)}var u={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"},m={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=E,Z=Q,z={grapheme:"grapheme",newline:"newline"};function J({tokens:e,flags:t,rules:r},s){let n={skipBackrefValidation:!1,skipPropertyNameValidation:!1,verbose:!1,...s},a={capturingGroups:[],current:0,hasNumberedRef:!1,namedGroupsByName:new Map,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],token:null,tokens:e,verbose:n.verbose,walk:o};function o(g,y){let b=e[a.current];switch(a.parent=g,a.token=b,a.current++,b.type){case d.Alternator:return O();case d.Assertion:return ze(b);case d.Backreference:return Yt(a);case d.Character:return Ze(b.value);case d.CharacterClassHyphen:return er(a,y);case d.CharacterClassOpen:return tr(a,y);case d.CharacterSet:return rr(a);case d.Directive:return ur(b);case d.GroupOpen:return nr(a,y);case d.Quantifier:return sr(a);case d.Subroutine:return ar(a);case d.VariableLengthCharacterSet:return dr(b.kind);default:throw new Error(`Unexpected token type "${b.type}"`)}}let i=gr(pr(),lr(t)),c=i.pattern.alternatives[0];for(;a.current<e.length;){let g=o(c,{});g.type===u.Alternative?(i.pattern.alternatives.push(g),c=g):c.elements.push(g)}let{capturingGroups:p,hasNumberedRef:l,namedGroupsByName:f,subroutines:w}=a;if(l&&f.size&&!r.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:g}of w)if(typeof g=="number"){if(g>p.length)throw new Error("Subroutine uses a group number that's not defined")}else if(f.has(g)){if(f.get(g).length>1)throw new Error(h`Subroutine uses a duplicate group name "\g<${g}>"`)}else throw new Error(h`Subroutine uses a group name that's not defined "\g<${g}>"`);return N({node:i},null,{AnyNode({node:g,parent:y}){g.parent=y}}),i}function Yt(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,ie(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 ie(s)}return n(+s)}function er(e,t){let{parent:r,tokens:s,walk:n}=e,a=r.elements.at(-1),o=s[e.current];if(a&&a.type!==u.CharacterClass&&a.type!==u.CharacterClassRange&&o&&o.type!==d.CharacterClassOpen&&o.type!==d.CharacterClassClose&&o.type!==d.CharacterClassIntersector){let i=n(r,t);if(a.type===u.Character&&i.type===u.Character)return r.elements.pop(),cr(a,i);throw new Error("Invalid character class range")}return Ze(45)}function tr(e,t){let{token:r,tokens:s,verbose:n,walk:a}=e,o=s[e.current],i=Ee({negate:r.negate}),c=i.elements[0],p=Xe(o);for(;p.type!==d.CharacterClassClose;){if(p.type===d.CharacterClassIntersector)c.classes.push(Ee({negate:!1,baseOnly:!0})),e.current++;else{let l=c.classes.at(-1);l.elements.push(a(l,t))}p=Xe(s[e.current],o)}if(n||kr(c),c.classes.length===1){let l=c.classes[0];l.negate=i.negate!==l.negate,i=l}return e.current++,i}function rr({token:e,skipPropertyNameValidation:t}){let{kind:r,negate:s,value:n}=e;if(r===E.property){let a=K(n);if(De.has(a))r=E.posix,n=a;else return V(n,{negate:s,skipPropertyNameValidation:t})}return r===E.posix?{type:u.CharacterSet,kind:k.posix,negate:s,value:n}:ce(r,{negate:s})}function nr(e,t){let{token:r,tokens:s,capturingGroups:n,namedGroupsByName:a,verbose:o,walk:i}=e,c=or(r);c.type===u.CapturingGroup&&(n.push(c),c.name&&B(a,c.name,[]).push(c));let p=qe(s[e.current]);for(;p.type!==d.GroupClose;){if(p.type===d.Alternator)c.alternatives.push(O()),e.current++;else{let l=c.alternatives.at(-1);l.elements.push(i(l,t))}p=qe(s[e.current])}return o||(c=mr(c)),e.current++,c}function sr({token:e,parent:t}){let{min:r,max:s,greedy:n,possessive:a}=e,o=t.elements.at(-1);if(!o||o.type===u.Assertion||o.type===u.Directive)throw new Error("Quantifier requires a repeatable token");let i=fr(o,r,s,n,a);return t.elements.pop(),i}function ar(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=hr(n);return s.push(o),o}function O(){return{type:u.Alternative,elements:[]}}function ze({type:e,kind:t,negate:r}){if(e===d.GroupOpen)return ue({behind:t===A.lookbehind,negate:r});let s=I({"^":m.line_start,$:m.line_end,"\\A":m.string_start,"\\b":m.word_boundary,"\\B":m.word_boundary,"\\G":m.search_start,"\\z":m.string_end,"\\Z":m.string_end_newline}[t],`Unexpected assertion kind "${t}"`),n={type:u.Assertion,kind:s};return s===m.word_boundary&&(n.negate=t===h`\B`),n}function ie(e,t){let r=!!t?.orphan;return{type:u.Backreference,...r&&{orphan:r},ref:e}}function or(e){let{kind:t,number:r,name:s,flags:n}=e;switch(t){case A.atomic:return P({atomic:!0});case A.capturing:return Ae(r,s);case A.group:return P({flags:n});case A.lookahead:case A.lookbehind:return ze(e);default:throw new Error(`Unexpected group kind "${t}"`)}}function Ae(e,t){let r=t!==void 0;if(r&&!wr(t))throw new Error(`Group name "${t}" invalid in Oniguruma`);return{type:u.CapturingGroup,number:e,...r&&{name:t},alternatives:[O()]}}function Ze(e){return{type:u.Character,value:e}}function Ee(e){let t={baseOnly:!1,negate:!1,...e};return{type:u.CharacterClass,negate:t.negate,elements:t.baseOnly?[]:[ir()]}}function ir(){return{type:u.CharacterClassIntersection,classes:[Ee({negate:!1,baseOnly:!0})]}}function cr(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:u.CharacterClassRange,min:e,max:t}}function ce(e,{negate:t}){let r={type:u.CharacterSet,kind:I(k[e],`Unexpected character set kind "${e}"`)};return(e===E.digit||e===E.hex||e===E.space||e===E.word)&&(r.negate=t),r}function ur({kind:e,flags:t}){let r={type:u.Directive,kind:I(Z[e],`Unexpected directive kind "${e}"`)};return e===Q.flags&&(r.flags=t),r}function lr({ignoreCase:e,dotAll:t,extended:r,digitIsAscii:s,spaceIsAscii:n,wordIsAscii:a}){return{type:u.Flags,ignoreCase:e,dotAll:t,extended:r,digitIsAscii:s,spaceIsAscii:n,wordIsAscii:a}}function P(e){let t=e?.atomic,r=e?.flags;return{type:u.Group,...t&&{atomic:t},...r&&{flags:r},alternatives:[O()]}}function ue(e){let t={behind:!1,negate:!1,...e};return{type:u.Assertion,kind:t.behind?m.lookbehind:m.lookahead,negate:t.negate,alternatives:[O()]}}function pr(){return{type:u.Pattern,alternatives:[O()]}}function fr(e,t,r,s,n){if(r<t)throw new Error("Quantifier range out of order");return{type:u.Quantifier,min:t,max:r,greedy:s,possessive:n,element:e}}function gr(e,t){return{type:u.Regex,pattern:e,flags:t}}function hr(e){return{type:u.Subroutine,ref:e}}function V(e,t){let r={negate:!1,skipPropertyNameValidation:!1,...t};return{type:u.CharacterSet,kind:k.property,value:r.skipPropertyNameValidation?e:Cr(e),negate:r.negate}}function dr(e){return{type:u.VariableLengthCharacterSet,kind:I({"\\R":z.newline,"\\X":z.grapheme}[e],`Unexpected varcharset kind "${e}"`)}}function Cr(e){let t=K(e);if(ye.has(t))throw new Error(h`Unicode property "\p{${e}}" unsupported in Oniguruma`);let r=ke.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 mr(e){let t=e.alternatives[0].elements[0];return e.type===u.Group&&q(e,r=>r.type===u.Group)&&!(e.atomic&&t.flags)&&!(e.flags&&(t.atomic||t.flags))?(e.atomic?t.atomic=!0:e.flags&&(t.flags=e.flags),t):e}function wr(e){return!/^(?:[-\d]|$)/.test(e)}function kr(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===u.CharacterClass&&(e.classes[t]=s,s.negate=r.negate!==s.negate)}}function Xe(e,t){return I(e,`${t?.value===93?"Empty":"Unclosed"} character class`)}function qe(e){return I(e,"Unclosed group")}var S=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function D(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:p,groups:{$skip:l}}=c;if(!l&&(!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}p[0]==="["?(o++,a.push(p[1]==="^")):p==="]"&&o&&(o--,a.pop()),i+=p}return i}function Je(e,t,r,s){D(e,t,r,s)}function yr(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 Y(e,t,r){return!!yr(e,t,0,r)}function Ye(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 v="$E$",ee=class e extends RegExp{_captureMap;_namesByIndex;constructor(t,r,s){if(t instanceof RegExp&&s)throw new Error("Cannot provide options when copying a regexp");let n=!!s?.useEmulationGroups,a=n?br(t):null;super(a?.expression||t,r);let o=n?a:t instanceof e?t:null;o&&(this._captureMap=o._captureMap,this._namesByIndex=o._namesByIndex)}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++)if(this._captureMap[a].exclude){let o=this._captureMap[a].transfer;if(o&&r.length>o){r[o]=s[a];let i=this._namesByIndex[o];i&&(r.groups[i]=s[a],this.hasIndices&&(r.indices.groups[i]=n[a])),this.hasIndices&&(r.indices[o]=n[a])}}else r.push(s[a]),this.hasIndices&&r.indices.push(n[a]);return r}};function br(e){let t=v.replace(/\$/g,"\\$"),r=[{exclude:!1}],s={0:""},n=0;return e=D(e,String.raw`\((?:(?!\?)|\?<(?![=!])(?<name>[^>]+)>)(?<mark>(?:\$(?<transfer>[1-9]\d*))?${t})?`,({0:a,groups:{name:o,mark:i,transfer:c}})=>i?(r.push({exclude:!0,transfer:c&&+c}),a.slice(0,-i.length)):(n++,o&&(s[n]=o),r.push({exclude:!1}),a),S.DEFAULT),{_captureMap:r,_namesByIndex:s,expression:e}}var et=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function tt(e,t,r,s){return e.slice(0,t)+s+e.slice(t+r.length)}var rt=new RegExp(String.raw`(?<noncapturingStart>${et})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function $e(e,t){if(!/\(\?>/.test(e))return e;let r="(?>",s=`(?:(?=(${t?.useEmulationGroups?v:""}`,n=[0],a=0,o=0,i=NaN,c;do{c=!1;let p=0,l=0,f=!1,w;for(rt.lastIndex=Number.isNaN(i)?0:i+s.length;w=rt.exec(e);){let{0:g,index:y,groups:{capturingStart:b,noncapturingStart:F}}=w;if(g==="[")p++;else if(p)g==="]"&&p--;else if(g===r&&!f)i=y,f=!0;else if(f&&F)l++;else if(b)f?l++:(a++,n.push(a+o));else if(g===")"&&f){if(!l){o++,e=`${e.slice(0,i)}${s}${e.slice(i+r.length,y)}))<$$${o+a}>)${e.slice(y+1)}`,c=!0;break}l--}}}while(c);return e=D(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:p,groups:{backrefNum:l,wrappedBackrefNum:f}})=>{if(l){let w=+l;if(w>n.length-1)throw new Error(`Backref "${p}" greater than number of captures`);return`\\${n[w]}`}return`\\${f}`},S.DEFAULT),e}var nt=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Se=new RegExp(String.raw` | ||
`.replace(/\s+/g,""),"gsu");function z(e,t="",r){if(r={captureGroup:!1,...r},typeof e!="string")throw new Error("String expected as pattern");if(!/^[imxDSW]*$/.test(t))throw new Error(`Flags "${t}" includes unsupported value`);let s=t.includes("x"),n=[s],a={captureGroup:r.captureGroup,getCurrentModX:()=>n.at(-1),numOpenGroups:0,popModX(){n.pop()},pushModX(f){n.push(f)},replaceCurrentModX(f){n[n.length-1]=f}},o=[],i;for(ae.lastIndex=0;i=ae.exec(e);){let f=Bt(a,e,i[0],ae.lastIndex);f.tokens?o.push(...f.tokens):f.token&&o.push(f.token),f.lastIndex!==void 0&&(ae.lastIndex=f.lastIndex)}let c=[],l=0;o.forEach(f=>{f.type===d.GroupOpen&&(f.kind===A.capturing?f.number=++l:f.raw==="("&&c.push(f))}),l||c.forEach((f,k)=>{f.kind=A.capturing,f.number=k+1});let p=l||c.length;return o=o.map(f=>f.type===d.EscapedNumber?qt(f,p):f).flat(),{tokens:o,flags:{ignoreCase:t.includes("i"),dotAll:t.includes("m"),extended:s,digitIsAscii:t.includes("D"),spaceIsAscii:t.includes("S"),wordIsAscii:t.includes("W")},rules:r}}function Bt(e,t,r,s){let[n,a,o]=r;if(n==="["){let i=Vt(t,r,s);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(n==="\\"){if("AbBGzZ".includes(a))return{token:m(d.Assertion,r,{kind:r})};if(/^\\g[<']/.test(r)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:m(d.Subroutine,r)}}if(/^\\k[<']/.test(r)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(r))throw new Error(`Invalid group name "${r}"`);return{token:m(d.Backreference,r)}}if(a==="K")return{token:m(d.Directive,r,{kind:Q.keep})};if(a==="N")return{token:m(d.CharacterSet,r,{kind:E.non_newline})};if(a==="O")return{token:m(d.CharacterSet,r,{kind:E.any})};if("RX".includes(a))return{token:m(d.VariableLengthCharacterSet,r,{kind:r})};if("yY".includes(a))throw new Error(`Unsupported grapheme boundary "${r}"`);let i=He(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:Ht(r,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,r==="("&&!e.captureGroup||r==="(?:")return{token:m(d.GroupOpen,r,{kind:A.group})};if(r==="(?>")return{token:m(d.GroupOpen,r,{kind:A.atomic})};if(r==="(?="||r==="(?!"||r==="(?<="||r==="(?<!")return{token:m(d.GroupOpen,r,{kind:o==="<"?A.lookbehind:A.lookahead,negate:r.endsWith("!")})};if(o==="<"||o==="'"||r==="("&&e.captureGroup){let i=m(d.GroupOpen,r,{kind:A.capturing});return r!=="("&&(i.name=r.slice(3,-1)),{token:i}}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(d.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(d.CharacterSet,r,{kind:E.dot})}:r==="^"||r==="$"?{token:m(d.Assertion,r,{kind:r})}:r==="|"?{token:m(d.Alternator,r)}:We.test(r)?{token:Kt(r)}:(Ke(r),{token:m(d.Character,r,{value:r.codePointAt(0)})})}function Vt(e,t,r){let s=[m(d.CharacterClassOpen,t,{negate:t[1]==="^"})],n=1,a;for(xe.lastIndex=r;a=xe.exec(e);){let o=a[0];if(o[0]==="["&&o[1]!==":")n++,s.push(m(d.CharacterClassOpen,o,{negate:o[1]==="^"}));else if(o==="]"){if(s.at(-1).type===d.CharacterClassOpen)s.push(m(d.Character,o,{value:93}));else if(n--,s.push(m(d.CharacterClassClose,o)),!n)break}else{let i=jt(o);Array.isArray(i)?s.push(...i):s.push(i)}}return{tokens:s,lastIndex:xe.lastIndex||e.length}}function jt(e){if(e[0]==="\\")return He(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!se.get(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return m(d.CharacterSet,e,{kind:E.posix,negate:!!t.groups.negate,value:t.groups.name})}return e==="-"?m(d.CharacterClassHyphen,e):e==="&&"?m(d.CharacterClassIntersector,e):(Ke(e),m(d.Character,e,{value:e.codePointAt(0)}))}function He(e,{inCharClass:t}){let r=e[1];if(r==="c"||r==="C")return Wt(e);if("dDhHsSwW".includes(r))return Qt(e);if(e.startsWith(h`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return 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(l=>`\\x${l.toString(16)}`).join("");return m(d.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(d.Character,e,{value:Xt(e)});if(De.has(r))return m(d.Character,e,{value:De.get(r)});if(/\d/.test(r))return m(d.EscapedNumber,e,{inCharClass:t});if(e==="\\")throw new Error(h`Incomplete escape "\"`);if(r==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return m(d.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(d.Character,e,{value:t.toUpperCase().codePointAt(0)-64})}function Ht(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=Be(r),o=Be(s),i={};if(a&&(i.enable=a),o&&(i.disable=o),e.endsWith(")"))return t.replaceCurrentModX(n),m(d.Directive,e,{kind:Q.flags,flags:i});if(e.endsWith(":")){t.pushModX(n),t.numOpenGroups++;let c=m(d.GroupOpen,e,{kind:A.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(d.Quantifier,e,t)}function Qt(e){let t=e[1].toLowerCase();return m(d.CharacterSet,e,{kind:{d:E.digit,h:E.hex,s:E.space,w:E.word}[t],negate:e[1]!==t})}function zt(e){let{p:t,neg:r,value:s}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups,n=t==="P"&&!r||t==="p"&&!!r;return m(d.CharacterSet,e,{kind:E.property,negate:n,value:s})}function Be(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 Xt(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);return parseInt(t,16)}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(d.Backreference,r)];let a=[],o=n.match(/^[0-7]+|\d/g);for(let i=0;i<o.length;i++){let c=o[i],l;if(i===0&&c!=="8"&&c!=="9"){if(l=parseInt(c,8),l>127)throw new Error(h`Octal encoded byte above 177 unsupported "${r}"`)}else l=c.codePointAt(0);a.push(m(d.Character,(i===0?"\\":"")+c,{value:l}))}return a}function Ke(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`)}function X({alternatives:e},t){return e.length===1&&e[0].elements.length===1&&(!t||t(e[0].elements[0]))}function M({type:e,kind:t}){return e===u.Assertion&&(t===C.lookahead||t===C.lookbehind)}function oe({type:e,min:t}){return e===u.Assertion||e===u.Directive||e===u.Quantifier&&!t}function N(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 l=a(o[c],i,c,o);c=Math.max(-1,c+l)}}function a(o,i=null,c=null,l=null){let p=0,f=!1,k={node:o,parent:i,key:c,container:l,ast:s,remove(){I(l,"Container expected").splice(Math.max(0,c+p),1),p-=1},removeAllNextSiblings(){return I(l,"Container expected").splice(c+1)},removeAllPrevSiblings(){let $=c+p;return p-=$,I(l,"Container expected").splice(0,Math.max(0,$))},replaceWith($){Jt($,i),l?l[Math.max(0,c+p)]=$:i[c]=$},skip(){f=!0}},g=Zt(o).find($=>!!r[$]),w=g&&r[g],b=typeof w=="function"?w:w?.enter,F=w?.exit;if(b?.(k,t),!f)switch(o.type){case u.Regex:a(o.pattern,o,"pattern"),a(o.flags,o,"flags");break;case u.Alternative:case u.CharacterClass:n(o.elements,o);break;case u.Assertion:M(o)&&n(o.alternatives,o);break;case u.Backreference:case u.Character:case u.CharacterSet:case u.Directive:case u.Flags:case u.Recursion:case u.Subroutine:case u.VariableLengthCharacterSet:break;case u.CapturingGroup:case u.Group:case u.Pattern:n(o.alternatives,o);break;case u.CharacterClassIntersection:n(o.classes,o);break;case u.CharacterClassRange:a(o.min,o,"min"),a(o.max,o,"max");break;case u.Quantifier:a(o.element,o,"element");break;default:throw new Error(`Unexpected node type "${o.type}"`)}return F?.(k,t),p}a(e.node,e.parent,e.key,e.container)}var Qe={AnyGroup:"AnyGroup",AnyNode:"AnyNode"};function Zt(e){let{type:t}=e,r=[Qe.AnyNode];return(t===u.CapturingGroup||t===u.Group||M(e))&&r.push(Qe.AnyGroup),r.push(t),r}function Jt(e,t){"parent"in t&&(e.parent=t)}var u={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"},C={line_end:"line_end",line_start:"line_start",lookahead:"lookahead",lookbehind:"lookbehind",search_start:"search_start",string_end:"string_end",string_end_newline:"string_end_newline",string_start:"string_start",word_boundary:"word_boundary"},y=E,Z=Q,q={grapheme:"grapheme",newline:"newline"};function J({tokens:e,flags:t,rules:r},s){let n={skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,verbose:!1,...s},a={capturingGroups:[],current:0,hasNumberedRef:!1,namedGroupsByName:new Map,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],token:null,tokens:e,verbose:n.verbose,walk:o};function o(g,w){let b=e[a.current];switch(a.parent=g,a.token=b,a.current++,b.type){case d.Alternator:return O();case d.Assertion:return qe(b);case d.Backreference:return Yt(a);case d.Character:return Ze(b.value,{useLastValid:!!w.isCheckingRangeEnd});case d.CharacterClassHyphen:return er(a,w);case d.CharacterClassOpen:return tr(a,w);case d.CharacterSet:return rr(a);case d.Directive:return ur(b);case d.GroupOpen:return nr(a,w);case d.Quantifier:return sr(a);case d.Subroutine:return ar(a);case d.VariableLengthCharacterSet:return dr(b.kind);default:throw new Error(`Unexpected token type "${b.type}"`)}}let i=gr(pr(),lr(t)),c=i.pattern.alternatives[0];for(;a.current<e.length;){let g=o(c,{});g.type===u.Alternative?(i.pattern.alternatives.push(g),c=g):c.elements.push(g)}let{capturingGroups:l,hasNumberedRef:p,namedGroupsByName:f,subroutines:k}=a;if(p&&f.size&&!r.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:g}of k)if(typeof g=="number"){if(g>l.length)throw new Error("Subroutine uses a group number that's not defined")}else if(f.has(g)){if(f.get(g).length>1)throw new Error(h`Subroutine uses a duplicate group name "\g<${g}>"`)}else throw new Error(h`Subroutine uses a group name that's not defined "\g<${g}>"`);return N({node:i},null,{AnyNode({node:g,parent:w}){g.parent=w}}),i}function Yt(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,ie(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 ie(s)}return n(+s)}function er(e,t){let{parent:r,tokens:s,walk:n}=e,a=r.elements.at(-1),o=s[e.current];if(!t.isCheckingRangeEnd&&a&&a.type!==u.CharacterClass&&a.type!==u.CharacterClassRange&&o&&o.type!==d.CharacterClassOpen&&o.type!==d.CharacterClassClose&&o.type!==d.CharacterClassIntersector){let i=n(r,{...t,isCheckingRangeEnd:!0});if(a.type===u.Character&&i.type===u.Character)return r.elements.pop(),cr(a,i);throw new Error("Invalid character class range")}return Ze(45)}function tr(e,t){let{token:r,tokens:s,verbose:n,walk:a}=e,o=s[e.current],i=Ee({negate:r.negate}),c=i.elements[0],l=ze(o);for(;l.type!==d.CharacterClassClose;){if(l.type===d.CharacterClassIntersector)c.classes.push(Ee({negate:!1,baseOnly:!0})),e.current++;else{let p=c.classes.at(-1);p.elements.push(a(p,t))}l=ze(s[e.current],o)}if(n||wr(c),c.classes.length===1){let p=c.classes[0];p.negate=i.negate!==p.negate,i=p}return e.current++,i}function rr({token:e,skipPropertyNameValidation:t}){let{kind:r,negate:s,value:n}=e;if(r===E.property){let a=K(n);if(Te.has(a))r=E.posix,n=a;else return V(n,{negate:s,skipPropertyNameValidation:t})}return r===E.posix?{type:u.CharacterSet,kind:y.posix,negate:s,value:n}:ce(r,{negate:s})}function nr(e,t){let{token:r,tokens:s,capturingGroups:n,namedGroupsByName:a,skipLookbehindValidation:o,verbose:i,walk:c}=e,l=or(r);l.type===u.CapturingGroup&&(n.push(l),l.name&&B(a,l.name,[]).push(l));let p=Xe(s[e.current]);for(;p.type!==d.GroupClose;){if(p.type===d.Alternator)l.alternatives.push(O()),e.current++;else{let f=l.alternatives.at(-1),k=l.kind===C.lookbehind,g=k&&l.negate,w=c(f,{...t,isInLookbehind:t.isInLookbehind||k,isInNegLookbehind:t.isInNegLookbehind||g});if(f.elements.push(w),(k||t.isInLookbehind)&&!o){let b="Lookbehind includes a pattern not allowed by Oniguruma";if(g||t.isInNegLookbehind){if(w.kind===C.lookahead||w.type===u.CapturingGroup)throw new Error(b)}else if(w.kind===C.lookahead||w.kind===C.lookbehind&&w.negate)throw new Error(b)}}p=Xe(s[e.current])}return i||(l=mr(l)),e.current++,l}function sr({token:e,parent:t}){let{min:r,max:s,greedy:n,possessive:a}=e,o=t.elements.at(-1);if(!o||o.type===u.Assertion||o.type===u.Directive)throw new Error("Quantifier requires a repeatable token");let i=fr(o,r,s,n,a);return t.elements.pop(),i}function ar(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=hr(n);return s.push(o),o}function O(){return{type:u.Alternative,elements:[]}}function qe({type:e,kind:t,negate:r}){if(e===d.GroupOpen)return ue({behind:t===A.lookbehind,negate:r});let s=I({"^":C.line_start,$:C.line_end,"\\A":C.string_start,"\\b":C.word_boundary,"\\B":C.word_boundary,"\\G":C.search_start,"\\z":C.string_end,"\\Z":C.string_end_newline}[t],`Unexpected assertion kind "${t}"`),n={type:u.Assertion,kind:s};return s===C.word_boundary&&(n.negate=t===h`\B`),n}function ie(e,t){let r=!!t?.orphan;return{type:u.Backreference,...r&&{orphan:r},ref:e}}function or(e){let{kind:t,number:r,name:s,flags:n}=e;switch(t){case A.atomic:return P({atomic:!0});case A.capturing:return Ae(r,s);case A.group:return P({flags:n});case A.lookahead:case A.lookbehind:return qe(e);default:throw new Error(`Unexpected group kind "${t}"`)}}function Ae(e,t){let r=t!==void 0;if(r&&!kr(t))throw new Error(`Group name "${t}" invalid in Oniguruma`);return{type:u.CapturingGroup,number:e,...r&&{name:t},alternatives:[O()]}}function Ze(e,t){let r={useLastValid:!1,...t};if(e>1114111){let s=e.toString(16);if(r.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${s}}"`):new Error(`Invalid code point out of range in JS "\\x{${s}}"`)}return{type:u.Character,value:e}}function Ee(e){let t={baseOnly:!1,negate:!1,...e};return{type:u.CharacterClass,negate:t.negate,elements:t.baseOnly?[]:[ir()]}}function ir(){return{type:u.CharacterClassIntersection,classes:[Ee({negate:!1,baseOnly:!0})]}}function cr(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:u.CharacterClassRange,min:e,max:t}}function ce(e,{negate:t}){let r={type:u.CharacterSet,kind:I(y[e],`Unexpected character set kind "${e}"`)};return(e===E.digit||e===E.hex||e===E.space||e===E.word)&&(r.negate=t),r}function ur({kind:e,flags:t}){let r={type:u.Directive,kind:I(Z[e],`Unexpected directive kind "${e}"`)};return e===Q.flags&&(r.flags=t),r}function lr({ignoreCase:e,dotAll:t,extended:r,digitIsAscii:s,spaceIsAscii:n,wordIsAscii:a}){return{type:u.Flags,ignoreCase:e,dotAll:t,extended:r,digitIsAscii:s,spaceIsAscii:n,wordIsAscii:a}}function P(e){let t=e?.atomic,r=e?.flags;return{type:u.Group,...t&&{atomic:t},...r&&{flags:r},alternatives:[O()]}}function ue(e){let t={behind:!1,negate:!1,...e};return{type:u.Assertion,kind:t.behind?C.lookbehind:C.lookahead,negate:t.negate,alternatives:[O()]}}function pr(){return{type:u.Pattern,alternatives:[O()]}}function fr(e,t,r,s,n){let a={type:u.Quantifier,min:t,max:r,greedy:s,possessive:n,element:e};return r<t?{...a,min:r,max:t,possessive:!0}:a}function gr(e,t){return{type:u.Regex,pattern:e,flags:t}}function hr(e){return{type:u.Subroutine,ref:e}}function V(e,t){let r={negate:!1,skipPropertyNameValidation:!1,...t};return{type:u.CharacterSet,kind:y.property,value:r.skipPropertyNameValidation?e:Cr(e),negate:r.negate}}function dr(e){return{type:u.VariableLengthCharacterSet,kind:I({"\\R":q.newline,"\\X":q.grapheme}[e],`Unexpected varcharset kind "${e}"`)}}function Cr(e){let t=K(e);if(be.has(t))throw new Error(h`Unicode property "\p{${e}}" unsupported in Oniguruma`);let r=we.get(t);return r||e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,s=>s[0].toUpperCase()+s.slice(1).toLowerCase())}function mr(e){let t=e.alternatives[0].elements[0];return e.type===u.Group&&X(e,r=>r.type===u.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 kr(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===u.CharacterClass&&(e.classes[t]=s,s.negate=r.negate!==s.negate)}}function ze(e,t){return I(e,`${t?.value===93?"Empty":"Unclosed"} character class`)}function Xe(e){return I(e,"Unclosed group")}var S=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function T(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:l,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}l[0]==="["?(o++,a.push(l[1]==="^")):l==="]"&&o&&(o--,a.pop()),i+=l}return i}function Je(e,t,r,s){T(e,t,r,s)}function br(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 Y(e,t,r){return!!br(e,t,0,r)}function Ye(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 v="$E$",ee=class e extends RegExp{_captureMap;_namesByIndex;constructor(t,r,s){if(t instanceof RegExp&&s)throw new Error("Cannot provide options when copying a regexp");let n=!!s?.useEmulationGroups,a=n?yr(t):null;super(a?.expression||t,r);let o=n?a:t instanceof e?t:null;o&&(this._captureMap=o._captureMap,this._namesByIndex=o._namesByIndex)}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++)if(this._captureMap[a].exclude){let o=this._captureMap[a].transfer;if(o&&r.length>o){r[o]=s[a];let i=this._namesByIndex[o];i&&(r.groups[i]=s[a],this.hasIndices&&(r.indices.groups[i]=n[a])),this.hasIndices&&(r.indices[o]=n[a])}}else r.push(s[a]),this.hasIndices&&r.indices.push(n[a]);return r}};function yr(e){let t=v.replace(/\$/g,"\\$"),r=[{exclude:!1}],s={0:""},n=0;return e=T(e,String.raw`\((?:(?!\?)|\?<(?![=!])(?<name>[^>]+)>)(?<mark>(?:\$(?<transfer>[1-9]\d*))?${t})?`,({0:a,groups:{name:o,mark:i,transfer:c}})=>i?(r.push({exclude:!0,transfer:c&&+c}),a.slice(0,-i.length)):(n++,o&&(s[n]=o),r.push({exclude:!1}),a),S.DEFAULT),{_captureMap:r,_namesByIndex:s,expression:e}}var et=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function tt(e,t,r,s){return e.slice(0,t)+s+e.slice(t+r.length)}var rt=new RegExp(String.raw`(?<noncapturingStart>${et})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function _e(e,t){if(!/\(\?>/.test(e))return e;let r="(?>",s=`(?:(?=(${t?.useEmulationGroups?v:""}`,n=[0],a=0,o=0,i=NaN,c;do{c=!1;let l=0,p=0,f=!1,k;for(rt.lastIndex=Number.isNaN(i)?0:i+s.length;k=rt.exec(e);){let{0:g,index:w,groups:{capturingStart:b,noncapturingStart:F}}=k;if(g==="[")l++;else if(l)g==="]"&&l--;else if(g===r&&!f)i=w,f=!0;else if(f&&F)p++;else if(b)f?p++:(a++,n.push(a+o));else if(g===")"&&f){if(!p){o++,e=`${e.slice(0,i)}${s}${e.slice(i+r.length,w)}))<$$${o+a}>)${e.slice(w+1)}`,c=!0;break}p--}}}while(c);return e=T(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:l,groups:{backrefNum:p,wrappedBackrefNum:f}})=>{if(p){let k=+p;if(k>n.length-1)throw new Error(`Backref "${l}" greater than number of captures`);return`\\${n[k]}`}return`\\${f}`},S.DEFAULT),e}var nt=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Se=new RegExp(String.raw` | ||
\\(?: \d+ | ||
@@ -136,5 +136,5 @@ | c[A-Za-z] | ||
| \\?. | ||
`.replace(/\s+/g,""),"gsu");function _e(e){if(!new RegExp(`${nt}\\+`).test(e))return e;let t=[],r=null,s=null,n="",a=0,o;for(Se.lastIndex=0;o=Se.exec(e);){let{0:i,index:c,groups:{qBase:p,qMod:l,invalidQ:f}}=o;if(i==="[")a||(s=c),a++;else if(i==="]")a?a--:s=null;else if(!a)if(l==="+"&&n&&!n.startsWith("(")){if(f)throw new Error(`Invalid quantifier "${i}"`);let w=-1;if(/^\{\d+\}$/.test(p))e=tt(e,c+p.length,l,"");else{if(n===")"||n==="]"){let g=n===")"?r:s;if(g===null)throw new Error(`Invalid unmatched "${n}"`);e=`${e.slice(0,g)}(?>${e.slice(g,c)}${p})${e.slice(c+i.length)}`}else e=`${e.slice(0,c-n.length)}(?>${n}${p})${e.slice(c+i.length)}`;w+=4}Se.lastIndex+=w}else i[0]==="("?t.push(c):i===")"&&(r=t.length?t.pop():null);n=i}return e}var te=class e extends ee{#e;rawArgs;constructor(t,r,s){if(t instanceof RegExp){if(s)throw new Error("Cannot provide options when copying a regexp");super(t,r),t instanceof e?(this.#e=t.#e,this.rawArgs=t.rawArgs):(this.#e=null,this.rawArgs={pattern:t.source,flags:t.flags,options:{}}),r!==void 0&&(this.rawArgs.flags=r)}else{let n={strategy:null,useEmulationGroups:!1,...s};super(t,r,{useEmulationGroups:n.useEmulationGroups}),this.#e=n.strategy,this.rawArgs={pattern:t,flags:r??"",options:{...n.strategy?{strategy:n.strategy}:null,...n.useEmulationGroups?{useEmulationGroups:!0}:null}}}}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&&xr(t,this,o,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 xr(e,t,r,s){if(r.input=e,r.index+=s,t.lastIndex+=s,t.hasIndices){let n=r.indices;for(let o=0;o<n.length;o++){let i=n[o];n[o]=[i[0]+s,i[1]+s]}let a=n.groups;a&&Object.keys(a).forEach(o=>{let i=a[o];a[o]=[i[0]+s,i[1]+s]})}}function st(e){let t=e.pattern.alternatives,r=t[0].elements[0];if(t.length>1||!r)return null;let s=q(e.pattern,o=>o.type===u.CapturingGroup||o.type===u.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===u.CapturingGroup||a.type===u.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===m.line_start&&i.kind===m.search_start||o.kind===m.search_start&&i.kind===m.line_start)return o.kind===m.line_start?a.alternatives.pop():a.alternatives.shift(),"line_or_search_start"}if(le(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(!oe(i))break;if(le(i,{negate:!0}))return n.elements.splice(o,1),"not_search_start"}return null}function le(e,t){return M(e)&&e.negate===t.negate&&q(e,r=>r.kind===m.search_start)}var ve=String.raw,at=ve`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`,ot=ve`\u{E0061}-\u{E007A}`,it=()=>new RegExp(ve`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${ot}]{2}[\u{E0030}-\u{E0039}${ot}]{1,3}\u{E007F}|${at}(?:\u200D${at})*`,"gu");function ut(e,t){let r={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",ignoreUnsupportedGAnchors:!1,...t},s=r.avoidSubclass?null:st(e),n={accuracy:r.accuracy,asciiWordBoundaries:r.asciiWordBoundaries,flagDirectivesByAlt:new Map,ignoreUnsupportedGAnchors:r.ignoreUnsupportedGAnchors,minTargetEs2024:H(r.bestEffortTarget,"ES2024"),subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};N({node:e},n,lt);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};N({node:e},o,pt);let i={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return N({node:e},i,Er),s&&(e._strategy=s),e}var lt={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];B(s,o,[]).push(...n)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let r=gt(t.get(e));if(r){let s=re(P({flags:r}),e.elements);s.parent=e,e.elements=[s]}}}},Assertion({node:e,ast:t,remove:r,replaceWith:s},{asciiWordBoundaries:n,ignoreUnsupportedGAnchors:a,supportedGNodes:o,wordIsAscii:i}){let{kind:c,negate:p}=e;if(c===m.line_end)s(G(h`(?=\z|\n)`));else if(c===m.line_start)s(G(h`(?<=\A|\n(?!\z))`));else if(c===m.search_start){if(o.has(e))t.flags.sticky=!0;else if(!a)throw new Error(h`Uses "\G" in a way that's unsupported`);r()}else if(c===m.string_end_newline)s(G(h`(?=\n?\z)`));else if(c===m.word_boundary&&!i&&!n){let l=`(?:(?<=${R})(?!${R})|(?<!${R})(?=${R}))`,f=`(?:(?<=${R})(?=${R})|(?<!${R})(?!${R}))`;s(G(p?f:l))}},CapturingGroup({node:e},{subroutineRefMap:t}){let{name:r,number:s}=e;if(r&&!Fr(r))throw new Error(`Group name "${r}" invalid in JS`);t.set(s,e),r&&t.set(r,e)},CharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s,digitIsAscii:n,spaceIsAscii:a,wordIsAscii:o}){let{kind:i,negate:c,value:p}=e;if(n&&(i===k.digit||p==="digit")){t(ce(k.digit,{negate:c}));return}if(a&&(i===k.space||p==="space")){t(Fe(G(Ar),c));return}if(o&&(i===k.word||p==="word")){t(ce(k.word,{negate:c}));return}if(i===k.any)t(V("Any"));else if(i===k.digit)t(V("Nd",{negate:c}));else if(i===k.hex)t(V("AHex",{negate:c}));else if(i===k.non_newline)t(G(h`[^\n]`));else if(i===k.space)t(V("space",{negate:c}));else if(i===k.word)t(Fe(G(R),c));else if(i===k.property)we.has(p)||(e.key="sc");else if(i===k.posix)if(!s&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let l={graph:"!-~",print:" -~"}[p];c&&(l=`\0-${x(l.codePointAt(0)-1)}${x(l.codePointAt(2)+1)}-\u{10FFFF}`),t(G(`[${l}]`))}else t(Fe(G(se.get(p)),c))},Directive(e,t){let{node:r,parent:s,ast:n,remove:a,replaceWith:o,removeAllPrevSiblings:i,removeAllNextSiblings:c}=e,{kind:p,flags:l}=r;if(p===Z.flags)if(!l.enable&&!l.disable)a();else{let f=re(P({flags:l}),c());o(f),mt(f,e,t,lt)}else if(p===Z.keep){if(s.parent!==n.pattern||n.pattern.alternatives.length>1)throw new Error(h`Uses "\K" in a way that's unsupported`);o(re(ue({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},{ignoreUnsupportedGAnchors:t,supportedGNodes:r}){let s=[],n=!1,a=!1;for(let o of e.alternatives)if(o.elements.length===1&&o.elements[0].kind===m.search_start)o.elements.pop();else{let i=dt(o.elements);i?(n=!0,Array.isArray(i)?s.push(...i):s.push(i)):a=!0}if(n){if(!a)s.forEach(o=>r.add(o));else if(!t)throw new Error(h`Uses "\G" in a way that's unsupported`)}},Quantifier({node:e}){if(e.element.type===u.Quantifier){let t=re(P(),[e.element]);t.parent=e,e.element=t}},VariableLengthCharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s}){let{kind:n}=e;if(n===z.newline)t(G(`(?>\r | ||
`.replace(/\s+/g,""),"gsu");function $e(e){if(!new RegExp(`${nt}\\+`).test(e))return e;let t=[],r=null,s=null,n="",a=0,o;for(Se.lastIndex=0;o=Se.exec(e);){let{0:i,index:c,groups:{qBase:l,qMod:p,invalidQ:f}}=o;if(i==="[")a||(s=c),a++;else if(i==="]")a?a--:s=null;else if(!a)if(p==="+"&&n&&!n.startsWith("(")){if(f)throw new Error(`Invalid quantifier "${i}"`);let k=-1;if(/^\{\d+\}$/.test(l))e=tt(e,c+l.length,p,"");else{if(n===")"||n==="]"){let g=n===")"?r:s;if(g===null)throw new Error(`Invalid unmatched "${n}"`);e=`${e.slice(0,g)}(?>${e.slice(g,c)}${l})${e.slice(c+i.length)}`}else e=`${e.slice(0,c-n.length)}(?>${n}${l})${e.slice(c+i.length)}`;k+=4}Se.lastIndex+=k}else i[0]==="("?t.push(c):i===")"&&(r=t.length?t.pop():null);n=i}return e}var te=class e extends ee{#e;rawArgs;constructor(t,r,s){if(t instanceof RegExp){if(s)throw new Error("Cannot provide options when copying a regexp");super(t,r),t instanceof e?(this.#e=t.#e,this.rawArgs=t.rawArgs):(this.#e=null,this.rawArgs={pattern:t.source,flags:t.flags,options:{}}),r!==void 0&&(this.rawArgs.flags=r)}else{let n={strategy:null,useEmulationGroups:!1,...s};super(t,r,{useEmulationGroups:n.useEmulationGroups}),this.#e=n.strategy,this.rawArgs={pattern:t,flags:r??"",options:{...n.strategy?{strategy:n.strategy}:null,...n.useEmulationGroups?{useEmulationGroups:!0}:null}}}}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&&xr(t,this,o,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 xr(e,t,r,s){if(r.input=e,r.index+=s,t.lastIndex+=s,t.hasIndices){let n=r.indices;for(let o=0;o<n.length;o++){let i=n[o];n[o]=[i[0]+s,i[1]+s]}let a=n.groups;a&&Object.keys(a).forEach(o=>{let i=a[o];a[o]=[i[0]+s,i[1]+s]})}}function st(e){let t=e.pattern.alternatives,r=t[0].elements[0];if(t.length>1||!r)return null;let s=X(e.pattern,o=>o.type===u.CapturingGroup||o.type===u.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===u.CapturingGroup||a.type===u.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===C.line_start&&i.kind===C.search_start||o.kind===C.search_start&&i.kind===C.line_start)return o.kind===C.line_start?a.alternatives.pop():a.alternatives.shift(),"line_or_search_start"}if(le(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(!oe(i))break;if(le(i,{negate:!0}))return n.elements.splice(o,1),"not_search_start"}return null}function le(e,t){return M(e)&&e.negate===t.negate&&X(e,r=>r.kind===C.search_start)}var ve=String.raw,at=ve`(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})`,ot=ve`\u{E0061}-\u{E007A}`,it=()=>new RegExp(ve`[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[${ot}]{2}[\u{E0030}-\u{E0039}${ot}]{1,3}\u{E007F}|${at}(?:\u200D${at})*`,"gu");function ut(e,t){let r={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",ignoreUnsupportedGAnchors:!1,...t},s=r.avoidSubclass?null:st(e),n={accuracy:r.accuracy,asciiWordBoundaries:r.asciiWordBoundaries,flagDirectivesByAlt:new Map,ignoreUnsupportedGAnchors:r.ignoreUnsupportedGAnchors,minTargetEs2024:H(r.bestEffortTarget,"ES2024"),subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};N({node:e},n,lt);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};N({node:e},o,pt);let i={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return N({node:e},i,Er),s&&(e._strategy=s),e}var lt={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];B(s,o,[]).push(...n)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let r=gt(t.get(e));if(r){let s=re(P({flags:r}),e.elements);s.parent=e,e.elements=[s]}}}},Assertion({node:e,ast:t,remove:r,replaceWith:s},{asciiWordBoundaries:n,ignoreUnsupportedGAnchors:a,supportedGNodes:o,wordIsAscii:i}){let{kind:c,negate:l}=e;if(c===C.line_end)s(G(h`(?=\z|\n)`));else if(c===C.line_start)s(G(h`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}));else if(c===C.search_start){if(o.has(e))t.flags.sticky=!0;else if(!a)throw new Error(h`Uses "\G" in a way that's unsupported`);r()}else if(c===C.string_end_newline)s(G(h`(?=\n?\z)`));else if(c===C.word_boundary&&!i&&!n){let p=`(?:(?<=${L})(?!${L})|(?<!${L})(?=${L}))`,f=`(?:(?<=${L})(?=${L})|(?<!${L})(?!${L}))`;s(G(l?f:p))}},CapturingGroup({node:e},{subroutineRefMap:t}){let{name:r,number:s}=e;if(r&&!Fr(r))throw new Error(`Group name "${r}" invalid in JS`);t.set(s,e),r&&t.set(r,e)},CharacterSet({node:e,replaceWith:t},{accuracy:r,minTargetEs2024:s,digitIsAscii:n,spaceIsAscii:a,wordIsAscii:o}){let{kind:i,negate:c,value:l}=e;if(n&&(i===y.digit||l==="digit")){t(ce(y.digit,{negate:c}));return}if(a&&(i===y.space||l==="space")){t(Fe(G(Ar),c));return}if(o&&(i===y.word||l==="word")){t(ce(y.word,{negate:c}));return}if(i===y.any)t(V("Any"));else if(i===y.digit)t(V("Nd",{negate:c}));else if(i===y.hex)t(V("AHex",{negate:c}));else if(i===y.non_newline)t(G(h`[^\n]`));else if(i===y.space)t(V("space",{negate:c}));else if(i===y.word)t(Fe(G(L),c));else if(i===y.property)ke.has(l)||(e.key="sc");else if(i===y.posix)if(!s&&(l==="graph"||l==="print")){if(r==="strict")throw new Error(`POSIX class "${l}" requires min target ES2024 or non-strict accuracy`);let p={graph:"!-~",print:" -~"}[l];c&&(p=`\0-${x(p.codePointAt(0)-1)}${x(p.codePointAt(2)+1)}-\u{10FFFF}`),t(G(`[${p}]`))}else t(Fe(G(se.get(l)),c))},Directive(e,t){let{node:r,parent:s,ast:n,remove:a,replaceWith:o,removeAllPrevSiblings:i,removeAllNextSiblings:c}=e,{kind:l,flags:p}=r;if(l===Z.flags)if(!p.enable&&!p.disable)a();else{let f=re(P({flags:p}),c());o(f),mt(f,e,t,lt)}else if(l===Z.keep){if(s.parent!==n.pattern||n.pattern.alternatives.length>1)throw new Error(h`Uses "\K" in a way that's unsupported`);o(re(ue({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},{ignoreUnsupportedGAnchors:t,supportedGNodes:r}){let s=[],n=!1,a=!1;for(let o of e.alternatives)if(o.elements.length===1&&o.elements[0].kind===C.search_start)o.elements.pop();else{let i=dt(o.elements);i?(n=!0,Array.isArray(i)?s.push(...i):s.push(i)):a=!0}if(n){if(!a)s.forEach(o=>r.add(o));else if(!t)throw new Error(h`Uses "\G" in a way that's unsupported`)}},Quantifier({node:e}){if(e.element.type===u.Quantifier){let t=re(P(),[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(G(`(?>\r | ||
?|[ | ||
\v\f\x85\u2028\u2029])`));else if(n===z.grapheme){if(r==="strict")throw new Error(h`Use of "\X" requires non-strict accuracy`);let a=s?h`\p{RGI_Emoji}`:it().source.replace(/\\u\{/g,"\\x{");t(G(h`(?>\r\n|${a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}))}else throw new Error(`Unexpected varcharset kind "${n}"`)}},pt={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:r}){let{orphan:s,ref:n}=e;s||r.set(e,[...t.get(n).map(({node:a})=>a)])},CapturingGroup:{enter({node:e,replaceWith:t,skip:r},{groupOriginByCopy:s,groupsByName:n,multiplexCapturesToLeftByRef:a,openRefs:o,reffedNodesByReferencer:i}){let c=s.get(e);if(c&&o.has(e.number)){let l=ct(e.number);i.set(l,o.get(e.number)),t(l),r();return}o.set(e.number,e),a.set(e.number,[]),e.name&&B(a,e.name,[]);let p=a.get(e.name??e.number);for(let l=0;l<p.length;l++){let f=p[l];if(c===f.node||c&&c===f.origin||e===f.origin){p.splice(l,1);break}}if(a.get(e.number).push({node:e,origin:c}),e.name&&a.get(e.name).push({node:e,origin:c}),e.name){let l=B(n,e.name,new Map),f=!1;if(c)f=!0;else for(let w of l.values())if(!w.hasDuplicateNameToRemove){f=!0;break}n.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:f})}c&&(e._originNumber=c.number)},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=L(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Recursion({node:e,parent:t},{reffedNodesByReferencer:r}){let{ref:s}=e,n=t;for(;(n=n.parent)&&!(n.type===u.CapturingGroup&&(n.name===s||n.number===s)););r.set(e,n)},Subroutine(e,t){let{node:r,replaceWith:s}=e,{ref:n}=r,a=t.subroutineRefMap.get(n),o=n===0,i=o?ct(0):ft(a,t.groupOriginByCopy,null),c=i;if(!o){let p=gt(_r(a,f=>f.type===u.Group&&!!f.flags)),l=p?L(t.globalFlags,p):t.globalFlags;Sr(l,t.currentFlags)||(c=re(P({flags:vr(l)}),[i]))}s(c),o||mt(c,e,t,pt)}},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=>$r(a,e));if(!n.length)t(ue({negate:!0}));else if(n.length>1){let a=n.map(o=>pe(O(),[ie(o.number)]));t(pe(P(),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=Ae();e.pattern.alternatives.at(-1).elements.push(n)}}}},Ar="[ -\r ]",R=h`[\p{L}\p{M}\p{N}\p{Pc}]`;function pe(e,t){return t.forEach(r=>r.parent=e),e[Ie(e)]=t,e}function Sr(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function $r(e,t){let r=t;do{if(r.type===u.Pattern)return!1;if(r.type===u.Alternative)continue;if(r===e)return!1;let s=ht(r.parent);for(let n of s){if(n===r)break;if(n===e||Ct(n,e))return!0}}while(r=r.parent);throw new Error("Unexpected path")}function ft(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]=ft(o,t,n,r):(a==="type"&&o===u.CapturingGroup&&t.set(n,t.get(e)??e),n[a]=o);return n}function ct(e){return{type:u.Recursion,ref:e}}function _r(e,t){let r=[];for(;e=e.parent;)(!t||t(e))&&r.push(e);return r}function Ie(e){for(let t of["alternatives","classes","elements"])if(e[t])return t;return null}function gt(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 vr({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 ht(e){if(!e)throw new Error("Node expected");if(e.type===u.Quantifier)return[e.element];let t=Ie(e);return t&&e[t]}function dt(e){let t=e.find(r=>r.kind===m.search_start||le(r,{negate:!1})||!oe(r));if(!t)return null;if(t.kind===m.search_start)return t;if(M(t))return t.alternatives[0].elements[0];if(t.type===u.Group||t.type===u.CapturingGroup){let r=[];for(let s of t.alternatives){let n=dt(s.elements);if(!n)return null;Array.isArray(n)?r.push(...n):r.push(n)}return r}return null}function Ct(e,t){let r=ht(e)??[];for(let s of r)if(s===t||Ct(s,t))return!0;return!1}function Fr(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function G(e,t){let s=J(X(e),t).pattern.alternatives;return s.length>1||s[0].elements.length>1?pe(P(),s):s[0].elements[0]}function re(e,t){let r=Ie(e);return e[r][0].parent=e,t&&pe(e[r][0],t),e}function Fe(e,t){return e.negate=t,e}function mt(e,{parent:t,key:r,container:s},n,a){N({node:e,parent:t,key:r,container:s},n,a)}function kt(e,t){let r=ne(t),s=H(r.target,"ES2024"),n=H(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 g=[e.flags.ignoreCase];N({node:e},{getCurrentModI:()=>g.at(-1),popModI(){g.pop()},pushModI(y){g.push(y)},setHasCasedChar(){g.at(-1)?o=!0:i=!0}},Ir)}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!i)},p=null,l={accuracy:r.accuracy,appliedGlobalFlags:c,avoidSubclass:r.avoidSubclass,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:p,maxRecursionDepth:a,useAppliedIgnoreCase:!!(!n&&o&&i),useFlagMods:n,useFlagV:s,verbose:r.verbose};function f(g){switch(l.lastNode=p,p=g,g.type){case u.Regex:return{pattern:f(g.pattern),flags:f(g.flags),options:{...g.options}};case u.Alternative:return g.elements.map(f).join("");case u.Assertion:return Rr(g,l,f);case u.Backreference:return Ur(g,l);case u.CapturingGroup:return Or(g,l,f);case u.Character:return Tr(g,l);case u.CharacterClass:return Dr(g,l,f);case u.CharacterClassIntersection:if(!l.useFlagV)throw new Error("Use of class intersection requires min target ES2024");return g.classes.map(f).join("&&");case u.CharacterClassRange:return Lr(g,l);case u.CharacterSet:return Br(g,l);case u.Flags:return Vr(g,l);case u.Group:return jr(g,l,f);case u.Pattern:return g.alternatives.map(f).join("|");case u.Quantifier:return f(g.element)+Qr(g);case u.Recursion:return Wr(g,l);default:throw new Error(`Unexpected node type "${g.type}"`)}}let w=f(e);return s||(delete w.options.force.v,w.options.disable.v=!0,w.options.unicodeSetsPlugin=null),w}var Ir={AnyGroup:{enter({node:e},t){let r=t.getCurrentModI();t.pushModI(e.flags?L({ignoreCase:r},e.flags).ignoreCase:r)},exit(e,t){t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Ge(x(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},r){t(),yt(e,{firstOnly:!0}).length&&r.setHasCasedChar()},CharacterSet({node:e},t){e.kind===k.property&&be.has(e.value)&&t.setHasCasedChar()}},Gr=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Mr=new Set(["-","\\","]","^","["]),Nr=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),wt=new Map([[9,h`\t`],[10,h`\n`],[11,h`\v`],[12,h`\f`],[13,h`\r`],[8232,h`\u2028`],[8233,h`\u2029`],[65279,h`\uFEFF`]]),Pr=/^\p{Cased}$/u;function Ge(e){return Pr.test(e)}function Rr(e,t,r){let{kind:s,negate:n,alternatives:a}=e;if(M(e))return`(?${`${s===m.lookahead?"":"<"}${n?"!":"="}`}${a.map(r).join("|")})`;if(s===m.string_end)return"$";if(s===m.string_start)return"^";if(s===m.word_boundary)return n?h`\B`:h`\b`;throw new Error(`Unexpected assertion kind "${s}"`)}function Ur({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e}function Or({name:e,number:t,alternatives:r,_originNumber:s},n,a){return n.captureMap.set(t,{ignoreCase:n.currentFlags.ignoreCase}),`(${e?`?<${e}>`:""}${!n.avoidSubclass&&s?`${s<t?`$${s}`:""}${v}`:""}${r.map(a).join("|")})`}function Tr({value:e},t){let r=x(e),s=j(e,{isAfterBackref:t.lastNode.type===u.Backreference,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(s!==r)return s;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Ge(r)){let n=me(r);return t.inCharClass?n.join(""):n.length>1?`[${n.join("")}]`:n[0]}return r}function Dr({negate:e,parent:t,elements:r},s,n){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===u.CharacterClass&&o!==u.CharacterClassIntersection||!s.verbose&&t.type===u.CharacterClassIntersection&&r.length===1&&o!==u.CharacterClass&&o!==u.CharacterClassRange)return r.map(n).join("");if(!s.useFlagV&&t.type===u.CharacterClass)throw new Error("Use of nested character class requires min target ES2024");return a()}function Lr(e,t){let r=e.min.value,s=e.max.value,n={isAfterBackref:!1,inCharClass:!0,useFlagV:t.useFlagV},a=j(r,n),o=j(s,n),i=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let c=yt(e);Hr(c).forEach(l=>{i.add(Array.isArray(l)?`${j(l[0],n)}-${j(l[1],n)}`:j(l,n))})}return`${a}-${o}${[...i].join("")}`}function Br({kind:e,negate:t,value:r,key:s},n){if(e===k.dot)return n.currentFlags.dotAll?n.appliedGlobalFlags.dotAll||n.useFlagMods?".":"[^]":h`[^\n]`;if(e===k.digit)return t?h`\D`:h`\d`;if(e===k.property){if(n.useAppliedIgnoreCase&&n.currentFlags.ignoreCase&&be.has(r))throw new Error(`Unicode property "${r}" can't be case-insensitive when other chars have specific case`);return`${t?h`\P`:h`\p`}{${s?`${s}=`:""}${r}}`}if(e===k.word)return t?h`\W`:h`\w`;throw new Error(`Unexpected character set kind "${e}"`)}function Vr(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")}function jr({atomic:e,flags:t,parent:r,alternatives:s},n,a){let o=n.currentFlags;t&&(n.currentFlags=L(o,t));let i=s.map(a).join("|"),c=!n.verbose&&s.length===1&&r.type!==u.Quantifier&&!e&&(!n.useFlagMods||!t)?i:`(?${Kr(e,t,n.useFlagMods)}${i})`;return n.currentFlags=o,c}function Wr({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})`:h`\g<${e}&R=${r}>`}function yt(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=x(o);if(!Ge(i))continue;let c=me(i).filter(p=>{let l=p.codePointAt(0);return l<s||l>n});if(c.length&&(a.push(...c),r))break}return a}function j(e,{isAfterBackref:t,inCharClass:r,useFlagV:s}){if(wt.has(e))return wt.get(e);if(e<32||e>126&&e<160||e>262143||t&&Xr(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let n=r?s?Nr:Mr:Gr,a=x(e);return(n.has(a)?"\\":"")+a}function Hr(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 Kr(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 Qr({min:e,max:t,greedy:r,possessive:s}){let n;return!e&&t===1?n="?":!e&&t===1/0?n="*":e===1&&t===1/0?n="+":e===t?n=`{${e}}`:n=`{${e},${t===1/0?"":t}}`,n+(s?"+":r?"":"?")}function Xr(e){return e>47&&e<58}var $=String.raw,qr=$`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Ne=$`\(\?R=(?<rDepth>[^\)]+)\)|${qr}`,fe=$`\(\?<(?![=!])(?<captureName>[^>]+)>`,T=new RegExp($`${fe}|${Ne}|\(\?|\\?.`,"gsu"),Me="Cannot use multiple overlapping recursions",Pe=new RegExp($`(?:\$[1-9]\d*)?${v.replace(/\$/g,$`\$`)}`,"y");function At(e,t){if(!new RegExp(Ne,"su").test(e))return e;if(Y(e,$`\(\?\(DEFINE\)`,S.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let r=!!t?.useEmulationGroups,s=Y(e,$`\\[1-9]`,S.DEFAULT),n=new Map,a=[],o=!1,i=0,c=0,p;for(T.lastIndex=0;p=T.exec(e);){let{0:l,groups:{captureName:f,rDepth:w,gRNameOrNum:g,gRDepth:y}}=p;if(l==="[")i++;else if(i)l==="]"&&i--;else if(w){if(bt(w),o)throw new Error(Me);if(s)throw new Error("Numbered backrefs cannot be used with global recursion");let b=e.slice(0,p.index),F=e.slice(T.lastIndex);if(Y(F,Ne,S.DEFAULT))throw new Error(Me);return xt(b,F,+w,!1,r)}else if(g){bt(y);let b=!1;for(let W of a)if(W.name===g||W.num===+g){if(b=!0,W.hasRecursedWithin)throw new Error(Me);break}if(!b)throw new Error($`Recursive \g cannot be used outside the referenced group "\g<${g}&R=${y}>"`);let F=n.get(g),_=Ye(e,F);if(s&&Y(_,$`${fe}|\((?!\?)`,S.DEFAULT))throw new Error("Numbered backrefs cannot be used with recursion of capturing groups");let ge=e.slice(F,p.index),Re=_.slice(ge.length+l.length),Ue=xt(ge,Re,+y,!0,r),$t=e.slice(0,F),_t=e.slice(F+_.length);e=`${$t}${Ue}${_t}`,T.lastIndex+=Ue.length-l.length-ge.length-Re.length,a.forEach(W=>W.hasRecursedWithin=!0),o=!0}else if(f)c++,n.set(String(c),T.lastIndex),n.set(f,T.lastIndex),a.push({num:c,name:f});else if(l.startsWith("(")){let b=l==="(";b&&(c++,n.set(String(c),T.lastIndex+(r?zr(e,T.lastIndex):0))),a.push(b?{num:c}:{})}else l===")"&&a.pop()}return e}function bt(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 xt(e,t,r,s,n){let a=new Set;s&&Je(e+t,fe,({groups:{captureName:i}})=>{a.add(i)},S.DEFAULT);let o=r-1;return`${e}${Et(`(?:${e}`,o,s?a:null,"forward",n)}(?:)${Et(`${t})`,o,s?a:null,"backward",n)}${t}`}function Et(e,t,r,s,n){let o=c=>s==="backward"?t-c+2-1:c+2,i="";for(let c=0;c<t;c++){let p=o(c);i+=D(e,$`${fe}|\\k<(?<backref>[^>]+)>${n?$`|(?<unnamed>\()(?!\?)(?:${Pe.source})?`:""}`,({0:l,index:f,groups:{captureName:w,backref:g,unnamed:y}})=>{if(g&&r&&!r.has(g))return l;if(y)return`(${v}`;let b=`_$${p}`;return w?`(?<${w}${b}>${n?v:""}`:$`\k<${g}${b}>`},S.DEFAULT)}return i}function zr(e,t){Pe.lastIndex=t;let r=Pe.exec(e);return r?r[0].length:0}function St(e,t){let r=ne(t),s=r.avoidSubclass,n=X(e,r.flags,{captureGroup:r.rules.captureGroup}),a=J(n,{skipBackrefValidation:r.rules.allowOrphanBackrefs,verbose:r.verbose}),o=ut(a,{accuracy:r.accuracy,asciiWordBoundaries:r.rules.asciiWordBoundaries,avoidSubclass:s,bestEffortTarget:r.target,ignoreUnsupportedGAnchors:r.rules.ignoreUnsupportedGAnchors}),i=kt(o,r),c={useEmulationGroups:!s},p={pattern:$e(_e(At(i.pattern,c)),c),flags:`${r.hasIndices?"d":""}${r.global?"g":""}${i.flags}${i.options.disable.v?"u":"v"}`},l=!s&&p.pattern.includes(v),f=o._strategy;return(l||f)&&(p.options={...f?{strategy:f}:null,...l?{useEmulationGroups:l}:null}),p}function Zr(e,t){let r=t?.flags??"",s=t?.rules?.captureGroup??!1;return J(X(e,r,{captureGroup:s}))}function Jr(e,t){let r=St(e,t);return r.options?new te(r.pattern,r.flags,r.options):new RegExp(r.pattern,r.flags)}return Nt(Yr);})(); | ||
\v\f\x85\u2028\u2029])`));else if(n===q.grapheme){if(r==="strict")throw new Error(h`Use of "\X" requires non-strict accuracy`);let a=s?h`\p{RGI_Emoji}`:it().source.replace(/\\u\{/g,"\\x{");t(G(h`(?>\r\n|${a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}))}else throw new Error(`Unexpected varcharset kind "${n}"`)}},pt={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:r}){let{orphan:s,ref:n}=e;s||r.set(e,[...t.get(n).map(({node:a})=>a)])},CapturingGroup:{enter({node:e,replaceWith:t,skip:r},{groupOriginByCopy:s,groupsByName:n,multiplexCapturesToLeftByRef:a,openRefs:o,reffedNodesByReferencer:i}){let c=s.get(e);if(c&&o.has(e.number)){let p=ct(e.number);i.set(p,o.get(e.number)),t(p),r();return}o.set(e.number,e),a.set(e.number,[]),e.name&&B(a,e.name,[]);let l=a.get(e.name??e.number);for(let p=0;p<l.length;p++){let f=l[p];if(c===f.node||c&&c===f.origin||e===f.origin){l.splice(p,1);break}}if(a.get(e.number).push({node:e,origin:c}),e.name&&a.get(e.name).push({node:e,origin:c}),e.name){let p=B(n,e.name,new Map),f=!1;if(c)f=!0;else for(let k of p.values())if(!k.hasDuplicateNameToRemove){f=!0;break}n.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:f})}c&&(e._originNumber=c.number)},exit({node:e},{openRefs:t}){t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=D(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Recursion({node:e,parent:t},{reffedNodesByReferencer:r}){let{ref:s}=e,n=t;for(;(n=n.parent)&&!(n.type===u.CapturingGroup&&(n.name===s||n.number===s)););r.set(e,n)},Subroutine(e,t){let{node:r,replaceWith:s}=e,{ref:n}=r,a=t.subroutineRefMap.get(n),o=n===0,i=o?ct(0):ft(a,t.groupOriginByCopy,null),c=i;if(!o){let l=gt($r(a,f=>f.type===u.Group&&!!f.flags)),p=l?D(t.globalFlags,l):t.globalFlags;Sr(p,t.currentFlags)||(c=re(P({flags:vr(p)}),[i]))}s(c),o||mt(c,e,t,pt)}},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=>_r(a,e));if(!n.length)t(ue({negate:!0}));else if(n.length>1){let a=n.map(o=>pe(O(),[ie(o.number)]));t(pe(P(),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=Ae();e.pattern.alternatives.at(-1).elements.push(n)}}}},Ar="[ -\r ]",L=h`[\p{L}\p{M}\p{N}\p{Pc}]`;function pe(e,t){return t.forEach(r=>r.parent=e),e[Ie(e)]=t,e}function Sr(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function _r(e,t){let r=t;do{if(r.type===u.Pattern)return!1;if(r.type===u.Alternative)continue;if(r===e)return!1;let s=ht(r.parent);for(let n of s){if(n===r)break;if(n===e||Ct(n,e))return!0}}while(r=r.parent);throw new Error("Unexpected path")}function ft(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]=ft(o,t,n,r):(a==="type"&&o===u.CapturingGroup&&t.set(n,t.get(e)??e),n[a]=o);return n}function ct(e){return{type:u.Recursion,ref:e}}function $r(e,t){let r=[];for(;e=e.parent;)(!t||t(e))&&r.push(e);return r}function Ie(e){for(let t of["alternatives","classes","elements"])if(e[t])return t;return null}function gt(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 vr({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 ht(e){if(!e)throw new Error("Node expected");if(e.type===u.Quantifier)return[e.element];let t=Ie(e);return t&&e[t]}function dt(e){let t=e.find(r=>r.kind===C.search_start||le(r,{negate:!1})||!oe(r));if(!t)return null;if(t.kind===C.search_start)return t;if(M(t))return t.alternatives[0].elements[0];if(t.type===u.Group||t.type===u.CapturingGroup){let r=[];for(let s of t.alternatives){let n=dt(s.elements);if(!n)return null;Array.isArray(n)?r.push(...n):r.push(n)}return r}return null}function Ct(e,t){let r=ht(e)??[];for(let s of r)if(s===t||Ct(s,t))return!0;return!1}function Fr(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function G(e,t){let s=J(z(e),t).pattern.alternatives;return s.length>1||s[0].elements.length>1?pe(P(),s):s[0].elements[0]}function re(e,t){let r=Ie(e);return e[r][0].parent=e,t&&pe(e[r][0],t),e}function Fe(e,t){return e.negate=t,e}function mt(e,{parent:t,key:r,container:s},n,a){N({node:e,parent:t,key:r,container:s},n,a)}function wt(e,t){let r=ne(t),s=H(r.target,"ES2024"),n=H(r.target,"ES2025"),a=r.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw new Error("Invalid recursionLimit; use 2-20");let o=null,i=null;if(!n){let g=[e.flags.ignoreCase];N({node:e},{getCurrentModI:()=>g.at(-1),popModI(){g.pop()},pushModI(w){g.push(w)},setHasCasedChar(){g.at(-1)?o=!0:i=!0}},Ir)}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!i)},l=null,p={accuracy:r.accuracy,appliedGlobalFlags:c,avoidSubclass:r.avoidSubclass,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,recursionLimit:a,useAppliedIgnoreCase:!!(!n&&o&&i),useFlagMods:n,useFlagV:s,verbose:r.verbose};function f(g){switch(p.lastNode=l,l=g,g.type){case u.Regex:return{pattern:f(g.pattern),flags:f(g.flags),options:{...g.options}};case u.Alternative:return g.elements.map(f).join("");case u.Assertion:return Lr(g,p,f);case u.Backreference:return Rr(g,p);case u.CapturingGroup:return Or(g,p,f);case u.Character:return Ur(g,p);case u.CharacterClass:return Tr(g,p,f);case u.CharacterClassIntersection:if(!p.useFlagV)throw new Error("Use of class intersection requires min target ES2024");return g.classes.map(f).join("&&");case u.CharacterClassRange:return Dr(g,p);case u.CharacterSet:return Br(g,p);case u.Flags:return Vr(g,p);case u.Group:return jr(g,p,f);case u.Pattern:return g.alternatives.map(f).join("|");case u.Quantifier:return f(g.element)+Qr(g);case u.Recursion:return Wr(g,p);default:throw new Error(`Unexpected node type "${g.type}"`)}}let k=f(e);return s||(delete k.options.force.v,k.options.disable.v=!0,k.options.unicodeSetsPlugin=null),k}var Ir={AnyGroup:{enter({node:e},t){let r=t.getCurrentModI();t.pushModI(e.flags?D({ignoreCase:r},e.flags).ignoreCase:r)},exit(e,t){t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Ge(x(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},r){t(),bt(e,{firstOnly:!0}).length&&r.setHasCasedChar()},CharacterSet({node:e},t){e.kind===y.property&&ye.has(e.value)&&t.setHasCasedChar()}},Gr=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Mr=new Set(["-","\\","]","^","["]),Nr=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),kt=new Map([[9,h`\t`],[10,h`\n`],[11,h`\v`],[12,h`\f`],[13,h`\r`],[8232,h`\u2028`],[8233,h`\u2029`],[65279,h`\uFEFF`]]),Pr=/^\p{Cased}$/u;function Ge(e){return Pr.test(e)}function Lr(e,t,r){let{kind:s,negate:n,alternatives:a}=e;if(M(e))return`(?${`${s===C.lookahead?"":"<"}${n?"!":"="}`}${a.map(r).join("|")})`;if(s===C.string_end)return"$";if(s===C.string_start)return"^";if(s===C.word_boundary)return n?h`\B`:h`\b`;throw new Error(`Unexpected assertion kind "${s}"`)}function Rr({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e}function Or({name:e,number:t,alternatives:r,_originNumber:s},n,a){return n.captureMap.set(t,{ignoreCase:n.currentFlags.ignoreCase}),`(${e?`?<${e}>`:""}${!n.avoidSubclass&&s?`${s<t?`$${s}`:""}${v}`:""}${r.map(a).join("|")})`}function Ur({value:e},t){let r=x(e),s=j(e,{isAfterBackref:t.lastNode.type===u.Backreference,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(s!==r)return s;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Ge(r)){let n=me(r);return t.inCharClass?n.join(""):n.length>1?`[${n.join("")}]`:n[0]}return r}function Tr({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&&o&&((!s.useFlagV||!s.verbose)&&t.type===u.CharacterClass&&o!==u.CharacterClassIntersection||!s.verbose&&t.type===u.CharacterClassIntersection&&r.length===1&&o!==u.CharacterClass&&o!==u.CharacterClassRange))return r.map(n).join("");if(!s.useFlagV&&t.type===u.CharacterClass)throw new Error("Use of nested character class requires min target ES2024");return a()}function Dr(e,t){let r=e.min.value,s=e.max.value,n={isAfterBackref:!1,inCharClass:!0,useFlagV:t.useFlagV},a=j(r,n),o=j(s,n),i=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let c=bt(e);Hr(c).forEach(p=>{i.add(Array.isArray(p)?`${j(p[0],n)}-${j(p[1],n)}`:j(p,n))})}return`${a}-${o}${[...i].join("")}`}function Br({kind:e,negate:t,value:r,key:s},n){if(e===y.dot)return n.currentFlags.dotAll?n.appliedGlobalFlags.dotAll||n.useFlagMods?".":"[^]":h`[^\n]`;if(e===y.digit)return t?h`\D`:h`\d`;if(e===y.property){if(n.useAppliedIgnoreCase&&n.currentFlags.ignoreCase&&ye.has(r))throw new Error(`Unicode property "${r}" can't be case-insensitive when other chars have specific case`);return`${t?h`\P`:h`\p`}{${s?`${s}=`:""}${r}}`}if(e===y.word)return t?h`\W`:h`\w`;throw new Error(`Unexpected character set kind "${e}"`)}function Vr(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")}function jr({atomic:e,flags:t,parent:r,alternatives:s},n,a){let o=n.currentFlags;t&&(n.currentFlags=D(o,t));let i=s.map(a).join("|"),c=!n.verbose&&s.length===1&&r.type!==u.Quantifier&&!e&&(!n.useFlagMods||!t)?i:`(?${Kr(e,t,n.useFlagMods)}${i})`;return n.currentFlags=o,c}function Wr({ref:e},t){let r=t.recursionLimit;return e===0?`(?R=${r})`:h`\g<${e}&R=${r}>`}function bt(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=x(o);if(!Ge(i))continue;let c=me(i).filter(l=>{let p=l.codePointAt(0);return p<s||p>n});if(c.length&&(a.push(...c),r))break}return a}function j(e,{isAfterBackref:t,inCharClass:r,useFlagV:s}){if(kt.has(e))return kt.get(e);if(e<32||e>126&&e<160||e>262143||t&&zr(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let n=r?s?Nr:Mr:Gr,a=x(e);return(n.has(a)?"\\":"")+a}function Hr(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 Kr(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 Qr({min:e,max:t,greedy:r,possessive:s}){let n;return!e&&t===1?n="?":!e&&t===1/0?n="*":e===1&&t===1/0?n="+":e===t?n=`{${e}}`:n=`{${e},${t===1/0?"":t}}`,n+(s?"+":r?"":"?")}function zr(e){return e>47&&e<58}var _=String.raw,Xr=_`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,Ne=_`\(\?R=(?<rDepth>[^\)]+)\)|${Xr}`,fe=_`\(\?<(?![=!])(?<captureName>[^>]+)>`,U=new RegExp(_`${fe}|${Ne}|\(\?|\\?.`,"gsu"),Me="Cannot use multiple overlapping recursions",Pe=new RegExp(_`(?:\$[1-9]\d*)?${v.replace(/\$/g,_`\$`)}`,"y");function At(e,t){if(!new RegExp(Ne,"su").test(e))return e;if(Y(e,_`\(\?\(DEFINE\)`,S.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let r=!!t?.useEmulationGroups,s=Y(e,_`\\[1-9]`,S.DEFAULT),n=new Map,a=[],o=!1,i=0,c=0,l;for(U.lastIndex=0;l=U.exec(e);){let{0:p,groups:{captureName:f,rDepth:k,gRNameOrNum:g,gRDepth:w}}=l;if(p==="[")i++;else if(i)p==="]"&&i--;else if(k){if(yt(k),o)throw new Error(Me);if(s)throw new Error("Numbered backrefs cannot be used with global recursion");let b=e.slice(0,l.index),F=e.slice(U.lastIndex);if(Y(F,Ne,S.DEFAULT))throw new Error(Me);return xt(b,F,+k,!1,r)}else if(g){yt(w);let b=!1;for(let W of a)if(W.name===g||W.num===+g){if(b=!0,W.hasRecursedWithin)throw new Error(Me);break}if(!b)throw new Error(_`Recursive \g cannot be used outside the referenced group "\g<${g}&R=${w}>"`);let F=n.get(g),$=Ye(e,F);if(s&&Y($,_`${fe}|\((?!\?)`,S.DEFAULT))throw new Error("Numbered backrefs cannot be used with recursion of capturing groups");let ge=e.slice(F,l.index),Le=$.slice(ge.length+p.length),Re=xt(ge,Le,+w,!0,r),_t=e.slice(0,F),$t=e.slice(F+$.length);e=`${_t}${Re}${$t}`,U.lastIndex+=Re.length-p.length-ge.length-Le.length,a.forEach(W=>W.hasRecursedWithin=!0),o=!0}else if(f)c++,n.set(String(c),U.lastIndex),n.set(f,U.lastIndex),a.push({num:c,name:f});else if(p.startsWith("(")){let b=p==="(";b&&(c++,n.set(String(c),U.lastIndex+(r?qr(e,U.lastIndex):0))),a.push(b?{num:c}:{})}else p===")"&&a.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 xt(e,t,r,s,n){let a=new Set;s&&Je(e+t,fe,({groups:{captureName:i}})=>{a.add(i)},S.DEFAULT);let o=r-1;return`${e}${Et(`(?:${e}`,o,s?a:null,"forward",n)}(?:)${Et(`${t})`,o,s?a:null,"backward",n)}${t}`}function Et(e,t,r,s,n){let o=c=>s==="backward"?t-c+2-1:c+2,i="";for(let c=0;c<t;c++){let l=o(c);i+=T(e,_`${fe}|\\k<(?<backref>[^>]+)>${n?_`|(?<unnamed>\()(?!\?)(?:${Pe.source})?`:""}`,({0:p,index:f,groups:{captureName:k,backref:g,unnamed:w}})=>{if(g&&r&&!r.has(g))return p;if(w)return`(${v}`;let b=`_$${l}`;return k?`(?<${k}${b}>${n?v:""}`:_`\k<${g}${b}>`},S.DEFAULT)}return i}function qr(e,t){Pe.lastIndex=t;let r=Pe.exec(e);return r?r[0].length:0}function St(e,t){let r=ne(t),s=r.avoidSubclass,n=z(e,r.flags,{captureGroup:r.rules.captureGroup}),a=J(n,{skipBackrefValidation:r.rules.allowOrphanBackrefs,verbose:r.verbose}),o=ut(a,{accuracy:r.accuracy,asciiWordBoundaries:r.rules.asciiWordBoundaries,avoidSubclass:s,bestEffortTarget:r.target,ignoreUnsupportedGAnchors:r.rules.ignoreUnsupportedGAnchors}),i=wt(o,r),c={useEmulationGroups:!s},l={pattern:_e($e(At(i.pattern,c)),c),flags:`${r.hasIndices?"d":""}${r.global?"g":""}${i.flags}${i.options.disable.v?"u":"v"}`},p=!s&&l.pattern.includes(v),f=o._strategy;return(p||f)&&(l.options={...f?{strategy:f}:null,...p?{useEmulationGroups:p}:null}),l}function Zr(e,t){let r=t?.flags??"",s=t?.rules?.captureGroup??!1;return J(z(e,r,{captureGroup:s}))}function Jr(e,t){let r=St(e,t);return r.options?new te(r.pattern,r.flags,r.options):new RegExp(r.pattern,r.flags)}return Nt(Yr);})(); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "oniguruma-to-es", | ||
"version": "0.10.0", | ||
"version": "1.0.0", | ||
"description": "Convert Oniguruma patterns to native JavaScript RegExp", | ||
@@ -5,0 +5,0 @@ "author": "Steven Levithan", |
@@ -19,3 +19,3 @@ # Oniguruma-To-ES (鬼車➟ES) | ||
Depending on features used, Oniguruma-To-ES might use advanced emulation via a `RegExp` subclass (that remains a native JavaScript regular expression). A few uncommon features can't be perfectly emulated and allow rare differences, but if you don't want to allow this, you can set the `accuracy` option to throw for such patterns (see details below). | ||
Depending on features used, Oniguruma-To-ES might use advanced emulation via a `RegExp` subclass (that remains a native JavaScript regular expression). | ||
@@ -84,3 +84,2 @@ <sup>✳︎: Ruby 2.0+ uses [Onigmo](https://github.com/k-takata/Onigmo), a fork of Oniguruma with similar syntax and behavior.</sup> | ||
hasIndices?: boolean; | ||
maxRecursionDepth?: number | null; | ||
rules?: { | ||
@@ -91,2 +90,3 @@ allowOrphanBackrefs?: boolean; | ||
ignoreUnsupportedGAnchors?: boolean; | ||
recursionLimit?: number; | ||
}; | ||
@@ -151,3 +151,3 @@ target?: 'auto' | 'ES2025' | 'ES2024' | 'ES2018'; | ||
The `rawArgs` property of `EmulatedRegExp` instances can be used to serialize the object as a string. | ||
The `rawArgs` property of `EmulatedRegExp` instances can be used to serialize the object. | ||
@@ -174,3 +174,2 @@ ## 🔩 Options | ||
- Enables use of `\X` using a close approximation of a Unicode extended grapheme cluster. | ||
- Enables recursion (ex: `\g<0>`) with a depth limit specified by option `maxRecursionDepth`. | ||
- `ES2024` and earlier: | ||
@@ -213,25 +212,14 @@ - Enables use of case-insensitive backreferences to case-sensitive groups. | ||
### `maxRecursionDepth` | ||
*Default: `5`.* | ||
Specifies the recursion depth limit. Supported values are integers `2`–`100` and `null`. If `null`, any use of recursion results in an error. | ||
Since recursion isn't infinite-depth like in Oniguruma, use of recursion also results in an error if using strict `accuracy`. | ||
<details> | ||
<summary>More details</summary> | ||
Using a high limit has a small impact on performance. Generally, this is only a problem if the regex has an existing issue with runaway backtracking that recursion exacerbates. Higher limits have no effect on regexes that don't use recursion, so you should feel free to increase this if helpful. | ||
</details> | ||
### `rules` | ||
Advanced pattern options that override standard error checking and flags when enabled. | ||
Advanced options that override standard behavior, error checking, and flags when enabled. | ||
- `allowOrphanBackrefs`: Useful with TextMate grammars that merge backreferences across patterns. | ||
- `asciiWordBoundaries`: Use ASCII-based `\b` and `\B`, which increases search performance of generated regexes. | ||
- `captureGroup`: Oniguruma option `ONIG_OPTION_CAPTURE_GROUP`. Unnamed captures and numbered calls allowed when using named capture. | ||
- `ignoreUnsupportedGAnchors`: Removes unsupported uses of `\G`, rather than erroring. | ||
- `captureGroup`: Allow unnamed captures and numbered calls (backreferences and subroutines) when using named capture. | ||
- Oniguruma option `ONIG_OPTION_CAPTURE_GROUP`. | ||
- On by default in `vscode-oniguruma`. | ||
- `ignoreUnsupportedGAnchors`: Remove 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. This might lead to some false positive matches, but is useful for non-critical matching (like syntax highlighting) when having some mismatches is better than not working. | ||
- `recursionLimit`: Change the recursion depth limit from Oniguruma's default of `20` to an integer `2`–`20`. | ||
@@ -542,3 +530,3 @@ ### `target` | ||
✔ Invert with <code>\p{^…}</code>, <code>\P{^…}</code><br> | ||
✔ Insignificant spaces, underscores, and casing in names<br> | ||
✔ Insignificant spaces, hyphens, underscores, and casing in names<br> | ||
✔ <code>\p</code>, <code>\P</code> without <code>{</code> is an identity escape<br> | ||
@@ -601,2 +589,3 @@ ✔ Error for key prefixes<br> | ||
✔ Same as JS with flag <code>u</code>, <code>v</code><br> | ||
✔ Allows <code>\x{…}</code> above <code>10FFFF</code> at end of range to mean last valid code point<br> | ||
</td> | ||
@@ -632,2 +621,3 @@ </tr> | ||
✔ Doesn't require nested classes for intersection of union and ranges<br> | ||
✔ Allows empty segments<br> | ||
</td> | ||
@@ -686,4 +676,6 @@ </tr> | ||
<td> | ||
✔ Same as JS<br> | ||
✔ Allows variable-length quantifiers and alternation within lookbehind<br> | ||
✔ Lookahead invalid within lookbehind<br> | ||
✔ Capturing groups invalid within negative lookbehind<br> | ||
✔ Negative lookbehind invalid within positive lookbehind<br> | ||
</td> | ||
@@ -873,6 +865,6 @@ </tr> | ||
</td> | ||
<td align="middle">☑️</td> | ||
<td align="middle">☑️</td> | ||
<td align="middle">☑️<sup>[6]</sup></td> | ||
<td align="middle">☑️<sup>[6]</sup></td> | ||
<td> | ||
● Has depth limit<sup>[6]</sup><br> | ||
✔ 20-level depth limit<br> | ||
</td> | ||
@@ -887,6 +879,6 @@ </tr> | ||
</td> | ||
<td align="middle">☑️</td> | ||
<td align="middle">☑️</td> | ||
<td align="middle">☑️<sup>[6]</sup></td> | ||
<td align="middle">☑️<sup>[6]</sup></td> | ||
<td> | ||
● Has depth limit<sup>[6]</sup><br> | ||
✔ 20-level depth limit<br> | ||
</td> | ||
@@ -955,30 +947,38 @@ </tr> | ||
The table above doesn't include all aspects that Oniguruma-To-ES emulates (including error handling, subpattern details on match results, most aspects that work the same as in JavaScript, and many aspects of non-JavaScript features that work the same in the other regex flavors that support them). Where applicable, Oniguruma-To-ES follows the latest version of Oniguruma (currently 6.9.9). | ||
The table above doesn't include all aspects that Oniguruma-To-ES emulates (including error handling, subpattern details on match results, most aspects that work the same as in JavaScript, and many aspects of non-JavaScript features that work the same in the other regex flavors that support them). Where applicable, Oniguruma-To-ES follows the latest version of Oniguruma (currently 6.9.10). | ||
### Footnotes | ||
1. Unicode blocks (which in Oniguruma are specified with an `In…` prefix) are easily emulatable but their character data would significantly increase library weight. They're also rarely used, fundamentally flawed, and arguably unuseful given the availability of Unicode scripts and other properties. | ||
1. Unicode blocks (which in Oniguruma are specified with an `In` prefix) are easily emulatable but their character data would significantly increase library weight. They're also rarely used, fundamentally flawed, and arguably unuseful given the availability of Unicode scripts and other properties. | ||
2. With target `ES2018`, the specific POSIX classes `[:graph:]` and `[:print:]` use ASCII-based versions rather than the Unicode versions available for target `ES2024` and later, and they result in an error if using strict `accuracy`. | ||
3. Target `ES2018` doesn't support nested *negated* character classes. | ||
4. Examples of supported uses of `\G` include `\G…`, `\G…|\G…`, `(?<=…)\G…`, `(^|\G)…`, `(?!\G)…`, and many others. | ||
5. It's not an error for *numbered* backreferences to come before their referenced group in Oniguruma, but an error is the best path for Oniguruma-To-ES because (1) most placements are mistakes and can never match (based on the Oniguruma behavior for backreferences to nonparticipating groups), (2) erroring matches the behavior of named backreferences, and (3) the edge cases where they're matchable rely on rules for backreference resetting within quantified groups that are different in JavaScript and aren't emulatable. Note that it's not a backreference in the first place if using `\10` or higher and not as many capturing groups are defined to the left (it's an octal or identity escape). | ||
6. The recursion depth limit is specified by option `maxRecursionDepth`. Overlapping recursions and the use of backreferences when the recursed subpattern contains captures aren't yet supported. Patterns that would error in Oniguruma due to triggering infinite recursion might find a match in Oniguruma-To-ES since recursion is bounded (future versions will detect this and error at transpilation time). | ||
4. Supported uses of `\G` include `\G…`, `\G…|\G…`, `(?<=…)\G…`, `(^|\G)…`, `(?!\G)…`, and many others. | ||
5. It's not an error for *numbered* backreferences to come before their referenced group in Oniguruma, but an error is the best path for Oniguruma-To-ES because ① most placements are mistakes and can never match (based on the Oniguruma behavior for backreferences to nonparticipating groups), ② erroring matches the behavior of named backreferences, and ③ the edge cases where they're matchable rely on rules for backreference resetting within quantified groups that are different in JavaScript and aren't emulatable. Note that it's not a backreference in the first place if using `\10` or higher and not as many capturing groups are defined to the left (it's an octal or identity escape). | ||
6. Oniguruma's recursion depth limit is `20`. Oniguruma-To-ES uses the same limit by default but allows customizing it via the `rules.recursionLimit` option. Two rare uses of recursion aren't yet supported: overlapping recursions, and use of backreferences when a recursed subpattern contains captures. Patterns that would trigger an infinite recursion error in Oniguruma might find a match in Oniguruma-To-ES (since recursion is bounded), but future versions will detect this and error at transpilation time. | ||
## ❌ Unsupported features | ||
The following don't yet have any support, and throw errors. They're all uncommonly-used features, with most being *extremely* rare. Note that Oniguruma-To-ES can handle 99.9+% of real-world Oniguruma regexes, based on a sample of tens of thousands of regexes used in TextMate grammars. | ||
The following throw errors since they aren't yet supported. They're all extremely rare. | ||
- Supportable: | ||
- Rarely-used character specifiers: Non-A-Za-z with `\cx`, `\C-x`; meta `\M-x`, `\M-\C-x`; bracketed octals `\o{…}`; octal UTF-8 encoded bytes (≥ `\200`). | ||
- Code point sequences: `\x{H H …}`, `\o{O O …}`. | ||
- Grapheme boundaries: `\y`, `\Y`. | ||
- Flags `P` (POSIX is ASCII) and `y{g}`/`y{w}` (grapheme boundary modes). | ||
- Rarely-used character specifiers: Non-A-Za-z with `\cx`, `\C-x`; meta `\M-x`, `\M-\C-x`; bracketed octals `\o{…}`; octal UTF-8 encoded bytes (≥ `\200`). | ||
- Code point sequences: `\x{H H …}`, `\o{O O …}`. | ||
- Whole-pattern modifier: Don't capture group `(?C)`. | ||
- Callout: `(*FAIL)`. | ||
- Supportable for some uses: | ||
- Absence functions: `(?~…)`, etc. | ||
- Absence operators: `(?~…)`, etc. | ||
- Conditionals: `(?(…)…)`, etc. | ||
- Whole-pattern modifiers: Ignore-case is ASCII `(?I)`, find longest `(?L)`. | ||
- Callout pair: `(*SKIP)(*FAIL)`. | ||
- Not supportable: | ||
- Callout functions: `(?{…})`, etc. | ||
- Other callouts: `(?{…})`, `(*…)`, etc. | ||
Note that Oniguruma-To-ES can handle 99.9% of real-world Oniguruma regexes, based on a sample of tens of thousands of regexes used in TextMate grammars. Of the features listed above, absence operators and conditionals were used in 2–3 regexes each, and the rest weren't used at all. | ||
See also the [supported features](#-supported-features) table (above) which describes some additional rarely-used sub-features that aren't currently supported. | ||
Contributions are welcome if you want to add support for currently unsupported features. | ||
<a name="unicode"></a> | ||
@@ -995,3 +995,3 @@ ## ㊗️ Unicode | ||
- Using these properties case-insensitively is basically never done intentionally, so you're unlikely to encounter this error unless it's catching a mistake. | ||
- Oniguruma-To-ES uses the version of Unicode supported natively by your JavaScript environment. Using Unicode properties via `\p{…}` that require a later version of Unicode than the environment supports results in a runtime error. This is an extreme edge case since modern JavaScript environments support recent versions of Unicode, often ahead of Oniguruma. | ||
- Oniguruma-To-ES uses the version of Unicode supported natively by your JavaScript environment. Using Unicode properties via `\p{…}` that were added in a later version of Unicode than the environment supports results in a runtime error. This is an extreme edge case since modern JavaScript environments support recent versions of Unicode. | ||
@@ -1008,3 +1008,3 @@ ## 👀 Similar projects | ||
© 2024–present. MIT License. | ||
MIT License. | ||
@@ -1011,0 +1011,0 @@ <!-- Badges --> |
@@ -7,3 +7,2 @@ export type OnigurumaToEsOptions = { | ||
hasIndices?: boolean; | ||
maxRecursionDepth?: number | null; | ||
rules?: { | ||
@@ -14,2 +13,3 @@ allowOrphanBackrefs?: boolean; | ||
ignoreUnsupportedGAnchors?: boolean; | ||
recursionLimit?: number; | ||
}; | ||
@@ -27,3 +27,2 @@ target?: "auto" | "ES2025" | "ES2024" | "ES2018"; | ||
hasIndices?: boolean; | ||
maxRecursionDepth?: number | null; | ||
rules?: { | ||
@@ -34,2 +33,3 @@ allowOrphanBackrefs?: boolean; | ||
ignoreUnsupportedGAnchors?: boolean; | ||
recursionLimit?: number; | ||
}; | ||
@@ -36,0 +36,0 @@ target?: keyof Target; |
@@ -75,3 +75,3 @@ export type OnigurumaAst = { | ||
}; | ||
export function createCharacter(charCode: any): { | ||
export function createCharacter(charCode: any, options: any): { | ||
type: string; | ||
@@ -78,0 +78,0 @@ value: 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
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
647785
3816
1