guessit-js 4.7.1 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";var Ya=Object.defineProperty;var Za=(u,e,t)=>e in u?Ya(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var _=(u,e,t)=>Za(u,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Js(u){return u}function Le(...u){return e=>{let t=e;for(const n of u)t=n(t);return t}}function ka(u){return u?Array.isArray(u)?u:[u]:[]}function Nt(u,e,t=null){return u||(u=e),typeof u!="object"||u===null||Array.isArray(u)?(u&&(e=u),[{[t??void 0]:u},e]):[u,e]}function U(u,e,t){typeof e=="number"&&(t=e,e=null);let n=e?u.filter(e):[...u];return t!=null?t<0?n[n.length+t]:n[t]:n}function W(u,e,t=!1){if("clear"in u&&u.clear){for(const n of Object.keys(e))delete e[n];delete u.clear}for(const[n,r]of Object.entries(u)){if(n in e){if(Array.isArray(r)&&Array.isArray(e[n])){e[n]=[...r,...e[n]];continue}if(r&&typeof r=="object"&&!Array.isArray(r)&&e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])){W(r,e[n]);continue}}(!(n in e)||t)&&(e[n]=r)}}function Da(u){return u==null||typeof u=="string"?!1:typeof u[Symbol.iterator]=="function"}function*Rt(u,e,t=0,n,r=!1){let s=u,a=e;r&&(s=s.toLowerCase(),a=a.toLowerCase());const i=n!==void 0?n:s.length;let o=t;for(;;){const c=s.indexOf(a,o);if(c===-1||c>=i)return;yield c,o=c+a.length}}function Ot(u,e,t=void 0){for(const n of e)if(n!=null&&n in u)return u[n];return t}function Ja(u,e){for(const t of e)u.includes(t)||u.push(t)}class Qa{constructor(e){_(this,"_map",new Map);if(e)for(const t of e)this.add(t)}add(e){return this._map.set(e,!0),this}delete(e){return this._map.delete(e)}has(e){return this._map.has(e)}get size(){return this._map.size}[Symbol.iterator](){return this._map.keys()}}function Qs(u){return!0}function Ca(u,e){if(!e.inputString)return!0;const t=e.start-1;return t<0?!0:u.includes(e.inputString[t])}function Ma(u,e){if(!e.inputString)return!0;const t=e.end;return t>=e.inputString.length?!0:u.includes(e.inputString[t])}function ei(u,e){return Ca(u,e)&&Ma(u,e)}class P{constructor(e,t,n={}){_(this,"start");_(this,"end");_(this,"name");_(this,"tags");_(this,"marker");_(this,"private");_(this,"inputString");_(this,"formatter");_(this,"pattern");_(this,"parent");_(this,"conflictSolver");_(this,"defined_at");_(this,"matchIndex",0);_(this,"_value");_(this,"_children");_(this,"_rawStart");_(this,"_rawEnd");this.start=e,this.end=t,this.name=n.name,this.tags=ka(n.tags),this.marker=n.marker??!1,this.private=n.private??!1,this.inputString=n.inputString,this.formatter=n.formatter,this._value=n.value,this.conflictSolver=n.conflictSolver,this.pattern=n.pattern,this.parent=n.parent,this.defined_at=n.pattern?n.pattern.defined_at:void 0}get span(){return[this.start,this.end]}get rawStart(){return this._rawStart!==void 0?this._rawStart:this.start}set rawStart(e){this._rawStart=e}get rawEnd(){return this._rawEnd!==void 0?this._rawEnd:this.end}set rawEnd(e){this._rawEnd=e}get raw(){if(this.inputString!==void 0)return this.inputString.slice(this.rawStart,this.rawEnd)}get value(){return this._value?this._value:this.formatter&&typeof this.formatter=="function"?this.formatter(this.raw??""):this.raw}set value(e){this._value=e}get children(){return this._children||(this._children=new Fe(void 0,this.inputString)),this._children}set children(e){this._children=e}get names(){if(!this._children||this._children.length===0)return this.name?new Set([this.name]):new Set;const e=new Set;for(const t of this._children)for(const n of t.names)e.add(n);return e}get initiator(){let e=this;for(;e.parent;)e=e.parent;return e}get length(){return this.end-this.start}tagged(...e){return e.some(t=>this.tags.includes(t))}named(...e){return e.some(t=>this.names.has(t))}crop(e,t,n){const r=Array.isArray(e)&&e.length===2&&typeof e[0]=="number"?[e]:Array.isArray(e)?e:[e];let a=[this._clone()];for(const i of r){const[o,c]="span"in i?i.span:i;for(const l of[...a])if(o<=l.start&&c>=l.end)a.splice(a.indexOf(l),1);else if(o>=l.start&&c<=l.end){const d=l._clone();l.end=o,l.length===0&&a.splice(a.indexOf(l),1),d.start=c,d.length>0&&a.push(d)}else l.end>=c&&c>l.start?l.start=c:l.start<=o&&o<l.end&&(l.end=o)}return U(a,t??null,n??null)}split(e,t,n){const r=[];let s=null;for(let a=0;a<(this.raw?.length??0);a++){const i=this.raw[a];if(e.includes(i)){if(s!==null){const o=this._clone();o.start=this.start+s,o.end=this.start+a,r.push(o),s=null}}else s===null&&(s=a)}if(s!==null){const a=this._clone();a.start=this.start+s,r.push(a)}return U(r,t??null,n??null)}clone(){return this._clone()}_clone(){const e=new P(this.start,this.end,{name:this.name,tags:[...this.tags],marker:this.marker,private:this.private,inputString:this.inputString,formatter:this.formatter,value:this._value,conflictSolver:this.conflictSolver,pattern:this.pattern,parent:this.parent});return e.matchIndex=this.matchIndex,e._rawStart=this._rawStart,e._rawEnd=this._rawEnd,e}equals(e){return this.start===e.start&&this.end===e.end&&this.value===e.value&&this.name===e.name&&this.parent===e.parent}toString(){let e="";const t=this.initiator.value;t!==this.value&&(e+=`+initiator=${String(t)}`),this.private&&(e+="+private");const n=this.name?`+name=${this.name}`:"",r=this.tags.length?`+tags=${JSON.stringify(this.tags)}`:"",s=this.defined_at?`@${this.defined_at.filename.split("/").pop()}#L${this.defined_at.lineno}`:"";return`<${String(this.value)}:(${this.start}, ${this.end})${e}${n}${r}${s}>`}}class ti extends Map{constructor(){super(...arguments);_(this,"matches",new Map);_(this,"valuesList",new Map)}}class Ea{constructor(e,t){_(this,"inputString");_(this,"_delegate",[]);_(this,"_maxEnd",0);_(this,"_nameDict",null);_(this,"_tagDict",null);_(this,"_startDict",null);_(this,"_endDict",null);_(this,"_indexDict",null);this.inputString=t,e&&this.extend(e)}get length(){return this._delegate.length}[Symbol.iterator](){return this._delegate[Symbol.iterator]()}toArray(){return[...this._delegate]}get matches(){return[...this._delegate]}get nameDict(){if(!this._nameDict){this._nameDict=new Map;for(const e of this._delegate)if(e.name){const t=this._nameDict.get(e.name)??[];t.push(e),this._nameDict.set(e.name,t)}}return this._nameDict}get startDict(){if(!this._startDict){this._startDict=new Map;for(const e of this._delegate){const t=this._startDict.get(e.start)??[];t.push(e),this._startDict.set(e.start,t)}}return this._startDict}get endDict(){if(!this._endDict){this._endDict=new Map;for(const e of this._delegate){const t=this._endDict.get(e.end)??[];t.push(e),this._endDict.set(e.end,t)}}return this._endDict}get tagDict(){if(!this._tagDict){this._tagDict=new Map;for(const e of this._delegate)for(const t of e.tags){const n=this._tagDict.get(t)??[];n.push(e),this._tagDict.set(t,n)}}return this._tagDict}get indexDict(){if(!this._indexDict){this._indexDict=new Map;for(const e of this._delegate)for(let t=e.start;t<e.end;t++){const n=this._indexDict.get(t)??[];n.push(e),this._indexDict.set(t,n)}}return this._indexDict}get maxEnd(){return this.inputString?Math.max(this.inputString.length,this._maxEnd):this._maxEnd}_addMatch(e){if(this._nameDict&&e.name){const t=this._nameDict.get(e.name)??[];t.push(e),this._nameDict.set(e.name,t)}if(this._tagDict)for(const t of e.tags){const n=this._tagDict.get(t)??[];n.push(e),this._tagDict.set(t,n)}if(this._startDict){const t=this._startDict.get(e.start)??[];t.push(e),this._startDict.set(e.start,t)}if(this._endDict){const t=this._endDict.get(e.end)??[];t.push(e),this._endDict.set(e.end,t)}if(this._indexDict)for(let t=e.start;t<e.end;t++){const n=this._indexDict.get(t)??[];n.push(e),this._indexDict.set(t,n)}e.end>this._maxEnd&&(this._maxEnd=e.end)}_removeMatch(e){if(this._nameDict&&e.name){const t=this._nameDict.get(e.name);if(t){const n=t.findIndex(r=>r===e);n!==-1&&t.splice(n,1)}}if(this._tagDict)for(const t of e.tags){const n=this._tagDict.get(t);if(n){const r=n.findIndex(s=>s===e);r!==-1&&n.splice(r,1)}}if(this._startDict){const t=this._startDict.get(e.start);if(t){const n=t.findIndex(r=>r===e);n!==-1&&t.splice(n,1)}}if(this._endDict){const t=this._endDict.get(e.end);if(t){const n=t.findIndex(r=>r===e);n!==-1&&t.splice(n,1)}}if(this._indexDict)for(let t=e.start;t<e.end;t++){const n=this._indexDict.get(t);if(n){const r=n.findIndex(s=>s===e);r!==-1&&n.splice(r,1)}}if(e.end>=this._maxEnd){this._maxEnd=0;for(const t of this._delegate)t.end>this._maxEnd&&(this._maxEnd=t.end)}}append(e){this._delegate.push(e),this._addMatch(e)}extend(e){for(const t of e)this.append(t)}remove(e){const t=this._delegate.findIndex(n=>n===e);t!==-1&&(this._delegate.splice(t,1),this._removeMatch(e))}includes(e){return this._delegate.some(t=>t===e||t.equals(e))}at(e){return this._delegate[e]}get(e){return this._delegate[e]}clear(){this._delegate.length=0,this._nameDict=null,this._tagDict=null,this._startDict=null,this._endDict=null,this._indexDict=null,this._maxEnd=0}slice(e,t){return new Fe(this._delegate.slice(e,t),this.inputString)}deleteSlice(e,t){const n=this._delegate.splice(e,t-e);for(const r of n)this._removeMatch(r)}setSlice(e,t,...n){const r=this._delegate.splice(e,t-e,...n);for(const s of r)this._removeMatch(s);for(const s of n)this._addMatch(s)}setAt(e,t){const n=this._delegate[e];n&&this._removeMatch(n),this._delegate[e]=t,this._addMatch(t)}insert(e,t){this._delegate.splice(e,0,t),this._addMatch(t)}sort(){return[...this._delegate].sort((e,t)=>e.start!==t.start?e.start-t.start:e.end-t.end)}named(e,t,n){const r=this.nameDict.get(e)??[];return U(r,t,n)}tagged(e,t,n){const r=this.tagDict.get(e)??[];return U(r,t,n)}starting(e,t,n){const r=this.startDict.get(e)??[];return U(r,t,n)}ending(e,t,n){const r=this.endDict.get(e)??[];return U(r,t,n)}atIndex(e,t,n){const r=this.indexDict.get(e)??[];return U(r,t,n)}atSpan(e,t,n){const r=this.indexDict.get(e[0])??[],s=this.indexDict.get(e[1]-1)??[],a=[...r];for(const i of s)a.includes(i)||a.push(i);return U(a,t,n)}atMatch(e,t,n){return this.atSpan(e.span,t,n)}range(e=0,t,n,r){const s=t!==void 0?Math.min(this.maxEnd,t):this.maxEnd,a=[];for(const i of this.sort())i.start<s&&i.end>e&&(!n||n(i))&&a.push(i);return U(a,null,r)}previous(e,t,n){let r=e.start;for(;r>-1;){const s=this.ending(r);if(s.length>0)return U(s,t,n);r--}return U([],t,n)}next(e,t,n){let r=e.start+1;for(;r<=this.maxEnd;){const s=this.starting(r);if(s.length>0)return U(s,t,n);r++}return U([],t,n)}conflicting(e,t,n){const r=[],s=new Set;for(let a=e.start;a<e.end;a++)for(const i of this.indexDict.get(a)??[])i!==e&&!s.has(i)&&(s.add(i),r.push(i));return U(r,t,n)}chainBefore(e,t,n=0,r,s){const a=typeof e=="number"?e:e.start,i=[];for(let o=Math.min(this.maxEnd,a)-1;o>=n;o--){const c=this.indexDict.get(o)??[],l=r?c.filter(r):[...c];if(l.length>0)for(const d of l)i.includes(d)||i.push(d);else if(!this.inputString||!t.includes(this.inputString[o]))break}return U(i,null,s)}chainAfter(e,t,n,r,s){const a=typeof e=="number"?e:e.end,i=n!==void 0?Math.min(this.maxEnd,n):this.maxEnd,o=[];for(let c=a;c<i;c++){const l=this.indexDict.get(c)??[],d=r?l.filter(r):[...l];if(d.length>0)for(const p of d)o.includes(p)||o.push(p);else if(!this.inputString||!t.includes(this.inputString[c]))break}return U(o,null,s)}holes(e=0,t,n={}){const{formatter:r,ignore:s,seps:a,predicate:i,index:o}=n,c=t!==void 0?Math.min(this.maxEnd,t):this.maxEnd,l=[];let d=!1,p=0;for(let f=e-1;f>=0;f--){const v=this.starting(f);let h=!1;for(const m of v)if(!s||!s(m)){p=f,h=!0;break}if(h)break}for(let f=p;f<c;f++){const v=this.indexDict.get(f)??[],h=s?v.filter(m=>!s(m)):[...v];a&&d&&this.inputString&&a.includes(this.inputString[f])?(d=!1,l[l.length-1].end=f):h.length===0&&!d?(d=!0,l.push(new P(Math.max(f,e),0,{inputString:this.inputString,formatter:r}))):h.length>0&&d&&(d=!1,l[l.length-1].end=f)}if(l.length>0&&d){let f=this.maxEnd;const v=c>p?c-1:p;for(let h=v;h<this.maxEnd;h++){const m=this.starting(h);let D=!1;for(const b of m)if(!s||!s(b)){f=h,D=!0;break}if(D)break}l[l.length-1].end=Math.min(f,c)}const g=l.filter(f=>f.end>f.start);return U(g,i??null,o??null)}get names(){return new Set(this.nameDict.keys())}get allTags(){return new Set(this.tagDict.keys())}toDict(e=!1,t=!1,n=!1){const r=new ti;for(const s of this.sort()){const a=e?s:s.value,i=r.matches.get(s.name??"")??[];i.push(s),r.matches.set(s.name??"",i);const o=(l,d)=>e&&l instanceof P&&d instanceof P?l.equals(d):l===d;if(!n){const l=r.valuesList.get(s.name??"")??[];l.some(d=>o(d,a))||l.push(a),r.valuesList.set(s.name??"",l)}const c=r.get(s.name??"");c!==void 0?t||(Array.isArray(c)?c.some(l=>o(l,a))||c.push(a):o(c,a)||r.set(s.name,[c,a])):r.set(s.name,n&&!Array.isArray(a)?[a]:a)}return r}toString(){return`[${this._delegate.map(String).join(", ")}]`}}class Fe extends Ea{constructor(t,n){super(void 0,n);_(this,"markers");this.markers=new ni(void 0,n),t&&this.extend(t)}_addMatch(t){if(t.marker)throw new Error("A marker match should not be added to Matches");super._addMatch(t)}}class ni extends Ea{constructor(e,t){super(void 0,t),e&&this.extend(e)}_addMatch(e){if(!e.marker)throw new Error("A non-marker match should not be added to Markers");super._addMatch(e)}}function _e(u,e=!1){const t={...u};return delete t.pattern,delete t.start,delete t.end,delete t.parent,delete t.formatter,delete t.value,e&&delete t.name,t}function ri(u){return u.replace(/\(\?P</g,"(?<")}function si(u,e){let t=u;for(const[n,r]of e)t=t.split(n).join(r);return t}function ai(u,e){let t=ri(u);e.abbreviations&&(t=si(t,e.abbreviations));let n=e.flags??"";return e.ignoreCase&&!n.includes("i")&&(n+="i"),n.includes("g")||(n+="g"),n.includes("d")||(n+="d"),new RegExp(t,n)}function ea(u){const e=[];let t=0;for(;t<u.length;){if(u[t]==="\\"){t+=2;continue}if(u[t]==="["){for(t++;t<u.length&&u[t]!=="]";)u[t]==="\\"&&t++,t++;t++;continue}if(u[t]==="("){if(u[t+1]!=="?")e.push(void 0);else if(u[t+2]==="<"){const s=u[t+3];if(s!=="="&&s!=="!"){const a=u.indexOf(">",t+3);e.push(a!==-1?u.slice(t+3,a):void 0)}}}t++}return e}class Pa{}class de extends Pa{constructor(t={}){super();_(this,"name");_(this,"tags");_(this,"formatters");_(this,"defaultFormatterFn");_(this,"values");_(this,"defaultValue");_(this,"validators");_(this,"defaultValidator");_(this,"children");_(this,"every");_(this,"private_");_(this,"privateNames");_(this,"ignoreNames");_(this,"privateParent");_(this,"privateChildren");_(this,"marker");_(this,"formatAll");_(this,"validateAll");_(this,"disabled");_(this,"logLevel");_(this,"properties_");_(this,"postProcessor");_(this,"preMatchProcessor");_(this,"postMatchProcessor");_(this,"defined_at");_(this,"_opts");this._opts=t,this.name=t.name,this.tags=ka(t.tags);const[n,r]=Nt(t.formatter,Js);this.formatters=n,this.defaultFormatterFn=r??Js;const[s,a]=Nt(t.value,void 0);this.values=s,this.defaultValue=a;const[i,o]=Nt(t.validator,Qs);this.validators=i,this.defaultValidator=o??Qs,this.every=t.every??!1,this.children=t.children??!1,this.private_=t.private??!1,this.privateNames=t.privateNames??[],this.ignoreNames=t.ignoreNames??[],this.privateParent=t.privateParent??!1,this.privateChildren=t.privateChildren??!1,this.marker=t.marker??!1,this.formatAll=t.formatAll??!1,this.validateAll=t.validateAll??!1;const c=t.disabled;typeof c=="function"?this.disabled=c:typeof c=="boolean"?this.disabled=()=>c:this.disabled=()=>!1,this.logLevel=t.logLevel??0,this.properties_=t.properties,this.postProcessor=typeof t.postProcessor=="function"?t.postProcessor:void 0,this.preMatchProcessor=typeof t.preMatchProcessor=="function"?t.preMatchProcessor:void 0,this.postMatchProcessor=typeof t.postMatchProcessor=="function"?t.postMatchProcessor:void 0,this.defined_at=void 0}get shouldIncludeChildren(){return this.children||this.every}get shouldIncludeParent(){return!this.children||this.every}_matchConfigPropertyKeys(t,n=!1){const r=[];return t.name&&r.push(t.name),r.push(n?"__children__":"__parent__"),r.push(null),r}_processMatchPrivate(t,n=!1){(t.name&&this.privateNames.includes(t.name)||!n&&this.privateParent||n&&this.privateChildren)&&(t.private=!0)}_processMatchValue(t,n=!1){const r=this._matchConfigPropertyKeys(t,n),s=Ot(this.values,r,this.defaultValue);s!=null&&(t.value=s)}_processMatchFormatter(t,n=!1){if((n?this.shouldIncludeChildren:this.shouldIncludeParent)||this.formatAll){const s=this._matchConfigPropertyKeys(t,n);t.formatter=Ot(this.formatters,s,this.defaultFormatterFn)}}_processMatchValidator(t,n=!1){if((n?this.shouldIncludeChildren:this.shouldIncludeParent)||this.validateAll){const s=this._matchConfigPropertyKeys(t,n),a=Ot(this.validators,s,this.defaultValidator);if(a&&!a(t))return!1}return!0}_processMatch(t,n,r=!1){return t.matchIndex=n,this._processMatchPrivate(t,r),this._processMatchValue(t,r),this._processMatchFormatter(t,r),this._processMatchValidator(t,r)}static _applyProcessor(t,n){if(!n||!t)return t;const r=n(t);return r!==void 0?r:t}*_processMatches(t,n){const r=de._applyProcessor(t,this.preMatchProcessor);if(!r||!this._processMatch(r,n))return;for(const a of r.children)if(!this._processMatch(a,n,!0))return;const s=de._applyProcessor(r,this.postMatchProcessor);if(s&&((this.shouldIncludeParent||this.privateParent)&&!this.ignoreNames.includes(s.name??"")&&(yield s),this.shouldIncludeChildren||this.privateChildren))for(const a of s.children)this.ignoreNames.includes(a.name??"")||(yield a)}_postProcessMatches(t){return this.postProcessor?this.postProcessor(t,this):t}matches(t,n,r=!1){const s=[],a=[];for(const o of this.patterns){let c=0;for(const l of this._match(o,t,n)){a.push(l);for(const d of this._processMatches(l,c))s.push(d);c++}}const i=this._postProcessMatches(s);return r?[i,a]:i}get properties(){return this.properties_??{}}}class Na extends de{constructor(t,...n){var e=(...El)=>(super(...El),_(this,"_patterns"),_(this,"_matchKwargs"),this);typeof t=="string"?(e({}),this._patterns=[t,...n],this._matchKwargs=_e({})):(e(t),this._patterns=n,this._matchKwargs=_e(t))}get patterns(){return this._patterns}get matchOptions(){return this._matchKwargs}*_match(t,n,r){const s=(this._opts.ignoreCase??!1)||(this._opts.flags?.includes("i")??!1),a=this._opts.start??0,i=this._opts.end??void 0;for(const o of Rt(n,t,a,i,s)){const c=new P(o,o+t.length,{...this._matchKwargs,pattern:this,inputString:n});c.length>0&&(yield c)}}toString(){return`<StringPattern:(${this._patterns.map(t=>`'${t}'`).join(", ")})>`}}class Oa extends de{constructor(t,...n){super(t);_(this,"_regexes");_(this,"_matchKwargs");_(this,"_childrenMatchKwargs");_(this,"_groupNamesList");this._matchKwargs=_e(t),this._childrenMatchKwargs=_e(t,!0),this._regexes=[],this._groupNamesList=[];for(const r of n)if(r instanceof RegExp)this._regexes.push(r),this._groupNamesList.push(ea(r.source));else{const s=ai(r,{flags:t.flags,ignoreCase:t.ignoreCase,abbreviations:t.abbreviations});this._regexes.push(s),this._groupNamesList.push(ea(s.source))}}get patterns(){return this._regexes}get matchOptions(){return this._matchKwargs}*_match(t,n,r){const s=this._groupNamesList[this._regexes.indexOf(t)]??[];t.lastIndex=0;let a;for(;(a=t.exec(n))!==null;){const i=a.index,o=a.index+a[0].length,c=new P(i,o,{...this._matchKwargs,pattern:this,inputString:n});if(s.length>0){const l=a.indices;for(let d=0;d<s.length;d++){const p=d+1,g=s[d]??this.name,f=l?.[p];if(f&&f[0]!==-1){const[v,h]=f,m=new P(v,h,{...this._childrenMatchKwargs,name:g,parent:c,pattern:this,inputString:n});m.length>0&&c.children.append(m)}}}(c.length>0||a[0].length===0)&&c.length>0&&(yield c),a[0].length===0&&t.lastIndex++}}toString(){return`<RePattern:(${this._regexes.map(t=>t.source).join(", ")})>`}}class Ia extends de{constructor(t,...n){super(t);_(this,"_fns");_(this,"_matchKwargs");this._fns=n,this._matchKwargs=_e(t)}get patterns(){return this._fns}get matchOptions(){return this._matchKwargs}*_match(t,n,r){const s=t(n,r);if(!s)return;const i=(o=>!Array.isArray(o)||o.length>=2&&typeof o[0]=="number"&&typeof o[1]=="number")(s)?[s]:s;for(const o of i)if(o){if(typeof o=="object"&&!Array.isArray(o)){const{start:c,end:l,...d}=o,p={...this._matchKwargs,...d},g=new P(c??0,l??0,{...p,pattern:this,inputString:n});g.length>0&&(yield g)}else if(Array.isArray(o)){let c=this._matchKwargs,l,d;o.length>=3&&typeof o[2]=="object"&&!Array.isArray(o[2])?(c={...this._matchKwargs,...o[2]},[l,d]=o):[l,d]=o;const p=new P(l,d,{...c,pattern:this,inputString:n});p.length>0&&(yield p)}}}toString(){return`<FunctionalPattern:(${this._fns.map(t=>t.name||"anonymous").join(", ")})>`}}let Ta=null;function ii(u){Ta=u}function oi(){return Ta}function ta(u){if(u.length===0)return[[],{}];const e=u[0],t=u[u.length-1];return typeof e=="object"&&e!==null?[u.slice(1),e]:u.length>1&&typeof t=="object"&&t!==null?[u.slice(0,-1),t]:[u,{}]}class li{constructor(){_(this,"_defaults",{});_(this,"_regexDefaults",{});_(this,"_stringDefaults",{});_(this,"_functionalDefaults",{});_(this,"_chainDefaults",{})}reset(){return this._defaults={},this._regexDefaults={},this._stringDefaults={},this._functionalDefaults={},this._chainDefaults={},this}defaults(e){return W(e,this._defaults,!0),this}regexDefaults(e){return W(e,this._regexDefaults,!0),this}stringDefaults(e){return W(e,this._stringDefaults,!0),this}functionalDefaults(e){return W(e,this._functionalDefaults,!0),this}chainDefaults(e){return W(e,this._chainDefaults,!0),this}_applyOverrides(e){const t=e.overrides??[];delete e.overrides;const n={};for(const r of t)n[r]=e[r];return[e,n]}buildRe(e,...t){const n={...e},[,r]=this._applyOverrides(n);return W(this._regexDefaults,n),W(this._defaults,n),Object.assign(n,r),new Oa(n,...t)}buildString(e,...t){const n={...e},[,r]=this._applyOverrides(n);return W(this._stringDefaults,n),W(this._defaults,n),Object.assign(n,r),new Na(n,...t)}buildFunctional(e,...t){const n={...e},[,r]=this._applyOverrides(n);return W(this._functionalDefaults,n),W(this._defaults,n),Object.assign(n,r),new Ia(n,...t)}regex(...e){const[t,n]=ta(e),r=this.buildRe(n,...t);return this.pattern(r)}string(...e){const[t,n]=ta(e),r=this.buildString(n,...t);return this.pattern(r)}functional(e,...t){let n;if(typeof e=="function"){const r=t[t.length-1];if(t.length>0&&typeof r=="object"&&r!==null&&!Array.isArray(r)){const s=r,a=t.slice(0,-1);n=this.buildFunctional(s,e,...a)}else n=this.buildFunctional({},e,...t)}else n=this.buildFunctional(e,...t);return this.pattern(n)}chain(e={}){const t=oi();if(!t)throw new Error("Chain class not registered. Import chain.ts before calling chain().");const n={...e};W(this._chainDefaults,n),W(this._defaults,n);const r=new t(this,n);return r._defaults={...this._defaults},r._regexDefaults={...this._regexDefaults},r._stringDefaults={...this._stringDefaults},r._functionalDefaults={...this._functionalDefaults},r._chainDefaults={...this._chainDefaults},this.pattern(r),r}}class ci extends Error{constructor(t){const n=[...t.entries()].map(([r,s])=>`${String(r)} -> ${[...s].map(String).join(", ")}`);super(`Cyclic dependencies exist among these items: ${n.join("; ")}`);_(this,"cyclic");this.cyclic=t,this.name="CyclicDependency"}}function*ui(u){if(u.size===0)return;const e=new Map;for(const[n,r]of u){const s=new Set(r);s.delete(n),e.set(n,s)}const t=new Set;for(const n of e.values())for(const r of n)t.add(r);for(const n of t)e.has(n)||e.set(n,new Set);for(;e.size>0;){const n=new Set;for(const[r,s]of e)s.size===0&&n.add(r);if(n.size===0)throw new ci(e);yield n;for(const r of n)e.delete(r);for(const r of e.values())for(const s of n)r.delete(s)}}class Mt{}class di{}class Y extends di{constructor(){super();_(this,"priority",this.constructor.priority);_(this,"name_",this.constructor.name);_(this,"dependency_",this.constructor.dependency);_(this,"logLevel",0);_(this,"defined_at");this.defined_at=void 0}enabled(t){return!0}toString(){const t=this.defined_at?`@${this.defined_at.filename.split("/").pop()}#L${this.defined_at.lineno}`:"";return`<${this.name_??this.constructor.name}${t}>`}equals(t){return this.constructor===t.constructor}}_(Y,"priority",0),_(Y,"ruleName"),_(Y,"dependency",null),_(Y,"properties",{});class x extends Y{constructor(){super(...arguments);_(this,"consequence",null)}then(t,n,r){const s=this.consequence??this.constructor.consequence;if(Array.isArray(s)){const i=(Array.isArray(n)?n:[n])[Symbol.iterator]();for(const o of s)(typeof o=="function"?new o:o).then(t,i.next().value,r)}else{const a=typeof s=="function"?new s:s;a&&a.then(t,n,r)}}}class w extends Mt{then(e,t,n){if(!t)return;if(Da(t)&&!(t instanceof String)){const s=[];for(const a of t)e.includes(a)&&(e.remove(a),s.push(a));return s}const r=t;if(e.includes(r))return e.remove(r),r}}class L extends Mt{constructor(t){super();_(this,"matchName");this.matchName=t}then(t,n,r){if(!n)return;if(Da(n)&&!(n instanceof String)){const a=[];for(const i of n)t.includes(i)||(this.matchName&&(i.name=this.matchName),t.append(i),a.push(i));return a}const s=n;if(this.matchName&&(s.name=this.matchName),!t.includes(s))return t.append(s),s}}class he extends Mt{constructor(t){super();_(this,"matchName");_(this,"_remove",new w);_(this,"_append",new L);this.matchName=t}then(t,n,r){const s=this._remove.then(t,n,r);if(s)if(Array.isArray(s)){for(const a of s)a.name=this.matchName;this._append.then(t,s,r)}else s.name=this.matchName,this._append.then(t,s,r)}}class na extends Mt{constructor(t){super();_(this,"tags");_(this,"_remove",new w);_(this,"_append",new L);this.tags=t}then(t,n,r){const s=this._remove.then(t,n,r);if(s){if(Array.isArray(s))for(const a of s)a.tags.push(...this.tags);else s.tags.push(...this.tags);this._append.then(t,s,r)}}}class ra{constructor(...e){_(this,"_list",[]);this.load(...e)}load(...e){for(const t of e)typeof t=="function"&&t.prototype instanceof Y?this._list.push(new t):typeof t=="object"&&t!==null&&!(t instanceof Y)?this.loadModule(t):t instanceof Y?this._list.push(t):typeof t=="function"&&this._list.push(new t)}loadModule(e){for(const t of Object.values(e))typeof t=="function"&&t.prototype instanceof Y&&this._list.push(new t)}extend(e){for(const t of e._list)this._list.some(n=>n.equals(t))||this._list.push(t)}indexOf(e){return this._list.indexOf(e)}[Symbol.iterator](){return this._list[Symbol.iterator]()}get length(){return this._list.length}executeAllRules(e,t){const n=[],r=new Map;for(const a of this._list){const i=a.priority,o=r.get(i)??[];o.push(a),r.set(i,o)}const s=[...r.keys()].sort((a,i)=>i-a);for(const a of s){const i=r.get(a),o=fi(i);for(const c of o){const l=[...c].sort((d,p)=>this.indexOf(d)-this.indexOf(p));for(const d of l){const p=pi(d,e,t);p!=null&&p!==!1&&n.push([d,p])}}}return n}}function pi(u,e,t){if(!u.enabled(t))return null;const n=u.when(e,t);return n!=null&&n!==!1?(u.then(e,n,t),n):null}function fi(u){const e=new Map,t=new Map;for(const n of u){const r=n.constructor;t.set(r,[...t.get(r)??[],n])}for(const n of u){const r=new Set,s=n.dependency_;if(s){const a=Array.isArray(s)?s:[s];for(const i of a){let o=[];if(typeof i=="string"){for(const[c,l]of t)if(c.name===i){o=l;break}}else o=t.get(i)??[];for(const c of o)c!==n&&r.add(c)}}e.set(n,r)}return[...ui(e)]}const gi="__default__",Lt=2048,N=-2048;function hi(u,e){return e.initiator.length<u.initiator.length?e:u.initiator.length<e.initiator.length?u:null}class Ra extends x{constructor(){super(...arguments);_(this,"priority",Lt);_(this,"consequence",w)}get defaultConflictSolverFn(){return hi}when(t,n){const r=new Qa,s=t.toArray().filter(a=>!a.private).sort((a,i)=>a.length-i.length);for(const a of s){const i=t.conflicting(a)??[];if(!i.length)continue;const o=i.filter(c=>!c.private).sort((c,l)=>c.length-l.length);for(const c of o){const l=[[this.defaultConflictSolverFn,!1]];a.conflictSolver&&l.push([a.conflictSolver,!1]),c.conflictSolver&&l.push([c.conflictSolver,!0]);for(let d=l.length-1;d>=0;d--){const[p,g]=l[d],f=g?p(c,a):p(a,c);if(f!==gi){if(f&&!r.has(f)){const v=f===a?c:a;r.has(v)||r.add(f)}break}}}}return r}}_(Ra,"priority",Lt);class La extends x{constructor(){super(...arguments);_(this,"priority",N);_(this,"consequence",w)}when(t,n){return t.toArray().filter(r=>r.private)}}_(La,"priority",N);class Fa extends Error{constructor(){super("Invalid chain")}}class mi extends Pa{constructor(t,n){super();_(this,"_chain");_(this,"pattern");_(this,"repeaterStart",1);_(this,"repeaterEnd",1);_(this,"_hidden",!1);this._chain=t,this.pattern=n}get isChainStart(){return this._chain.parts[0]===this}get isHidden(){return this._hidden}hidden(t=!0){return this._hidden=t,this}matches(t,n,r=!1){const s=this.pattern.matches(t,n,!0);let[a,i]=s;return a=this._truncateRepeater(a,t),i=this._truncateRepeater(i,t),this._validateRepeater(i),r?[a,i]:a}_truncateRepeater(t,n){if(!t.length)return t;if(!this.isChainStart&&n.slice(0,t[0].initiator.rawStart))return[];let r=1;for(let a=0;a<t.length-1&&!n.slice(t[a].initiator.rawEnd,t[a+1].initiator.rawStart);a++)r++;let s=t.slice(0,r);return this.repeaterEnd!==null&&(s=s.filter(a=>a.matchIndex<this.repeaterEnd)),s}_validateRepeater(t){if((t.length>0?Math.max(...t.map(r=>r.matchIndex)):-1)+1<this.repeaterStart)throw new Fa}repeater(t){if(typeof t=="number")return this.repeaterStart=t,this.repeaterEnd=t,this;const n=String(t);if(n==="+")this.repeaterStart=1,this.repeaterEnd=null;else if(n==="*")this.repeaterStart=0,this.repeaterEnd=null;else if(n==="?")this.repeaterStart=0,this.repeaterEnd=1;else{const r=/\{\s*(\d*)\s*,?\s*(\d*)\s*\}/.exec(n);r&&(this.repeaterStart=r[1]?parseInt(r[1]):0,this.repeaterEnd=r[2]?parseInt(r[2]):null)}return this}regex(t,...n){return this._chain.regex(t,...n)}string(t,...n){return this._chain.string(t,...n)}functional(t,...n){return this._chain.functional(t,...n)}chain(t){return this._chain.chain(t)}close(){return this._chain.close()}toString(){return`${this.pattern}({${this.repeaterStart},${this.repeaterEnd}})`}}class Q extends de{constructor(t,n={}){super(n);_(this,"parts",[]);_(this,"_defaults",{});_(this,"_regexDefaults",{});_(this,"_stringDefaults",{});_(this,"_functionalDefaults",{});_(this,"_chainDefaults",{});_(this,"_parent");_(this,"_chainBreaker");_(this,"_matchKwargs");this._parent=t,this._matchKwargs=_e(n),this._chainBreaker=n.chainBreaker??null}defaults(t){return W(t,this._defaults,!0),"children"in t&&(this.children=t.children),"privateParent"in t&&(this.privateParent=t.privateParent),"privateChildren"in t&&(this.privateChildren=t.privateChildren),"conflictSolver"in t&&(this._matchKwargs.conflictSolver=t.conflictSolver),"privateNames"in t&&(this.privateNames=t.privateNames),this}regexDefaults(t){return W(t,this._regexDefaults,!0),this}regex(...t){const n=t[t.length-1],r=typeof n=="object"&&n!==null&&!Array.isArray(n)?n:{},s=typeof n=="object"&&n!==null&&!Array.isArray(n)?t.slice(0,-1):t,a={...this._regexDefaults,...this._defaults,...r},i=new Oa(a,...s);return this.pattern(i)}string(...t){const n=t[t.length-1],r=typeof n=="object"&&n!==null&&!Array.isArray(n)?n:{},s=typeof n=="object"&&n!==null&&!Array.isArray(n)?t.slice(0,-1):t,a={...this._stringDefaults,...this._defaults,...r},i=new Na(a,...s);return this.pattern(i)}functional(...t){const n=t[0],r=t.length>1&&typeof t[1]=="object"?t[1]:{},s={...this._functionalDefaults,...this._defaults,...r},a=new Ia(s,n);return this.pattern(a)}chain(t={}){const n={...this._chainDefaults,...this._defaults,...t},r=new Q(this,n);return r._defaults={...this._defaults},r._regexDefaults={...this._regexDefaults},r._stringDefaults={...this._stringDefaults},r._functionalDefaults={...this._functionalDefaults},r._chainDefaults={...this._chainDefaults},this.pattern(r),r}pattern(...t){if(!t.length)throw new Error("One pattern should be given to the chain");if(t.length>1)throw new Error("Only one pattern can be given to the chain");const n=new mi(this,t[0]);return this.parts.push(n),n}close(){let t=this._parent;for(;t instanceof Q;)t=t._parent;return t}get patterns(){return[this]}get matchOptions(){return{}}_processMatch(t,n,r=!1){if(super._processMatch(t,n,r))return!0;if(t.children.length>0){const a=t.children.get(t.children.length-1).pattern,i=t.children.toArray().filter(c=>c.pattern===a),o=Q._groupByMatchIndex(i);if(o.size>0){const c=new Fe(t.children.toArray()),l=t.end,d=[...o.keys()].sort((p,g)=>g-p);for(const p of d){const g=o.get(p);for(const v of g)t.children.remove(v);if(t.end=t.children.length>0?t.children.get(t.children.length-1).end:t.start,super._processMatch(t,n,r))return!0}t.children=c,t.end=l}}return!1}*_match(t,n,r){let s=0;for(;s<n.length;){let a=!1;const i=[];let o=!0,c=n.slice(s);for(const l of this.parts)try{const d=l.matches(c,r,!0),[p,g]=d;if(Q._fixMatchesOffset(p,n,s),Q._fixMatchesOffset(g,n,s),g.length>0){const f=Q._groupByMatchIndex(g),v=Q._groupByMatchIndex(p);for(const[h,m]of f)if(a=!0,s=m[m.length-1].rawEnd,c=n.slice(s),!l.isHidden){const D=v.get(h)??[];this._chainBreakerEval([...i,...D])&&i.push(...D)}}}catch(d){if(d instanceof Fa){o=!1,i.length>0?s=i[0].rawEnd:s++;break}throw d}if(!a)break;i.length>0&&o&&(yield this._buildChainMatch(i,n))}}_chainBreakerEval(t){return this._chainBreaker?!this._chainBreaker(new Fe(t)):!0}_buildChainMatch(t,n){let r=1/0,s=-1/0;for(const i of t)i.start<r&&(r=i.start),i.end>s&&(s=i.end);const a=new P(r,s,{...this._matchKwargs,pattern:this,inputString:n});for(const i of t){if(i.children.length>0)for(const o of i.children)a.children.append(o);a.children.includes(i)||(a.children.append(i),i.parent=a)}return a}static _fixMatchesOffset(t,n,r){for(const s of t){if(s.inputString!==n){s.inputString=n;const a=s.rawStart,i=s.rawEnd;s.start+=r,s.end+=r,s.rawStart=a+r,s.rawEnd=i+r}s.children.length>0&&Q._fixMatchesOffset(s.children.toArray(),n,r)}}static _groupByMatchIndex(t){const n=new Map;for(const r of t){const s=n.get(r.matchIndex)??[];s.push(r),n.set(r.matchIndex,s)}return n}}ii(Q);class $ extends li{constructor(t={}){super();_(this,"_patterns",[]);_(this,"_rules");_(this,"_rebulks",[]);_(this,"_disabled");_(this,"customizeProperties");const n=t.disabled;typeof n=="function"?this._disabled=n:typeof n=="boolean"?this._disabled=()=>n:this._disabled=()=>!1,this._rules=new ra,t.defaultRules!==!1&&this._rules.load(Ra,La)}pattern(...t){return this._patterns.push(...t),this}rules(...t){return this._rules.load(...t),this}rebulk(...t){return this._rebulks.push(...t),this}matches(t,n={}){const r=new Fe(void 0,t);return this._matchesPatterns(r,n),this._executeRules(r,n),r}effectiveRules(t){const n=new ra;n.extend(this._rules);for(const r of this._rebulks)r._disabled(t??{})||n.extend(r._rules);return n}effectivePatterns(t){const n=[...this._patterns];for(const r of this._rebulks)r._disabled(t??{})||Ja(n,r._patterns);return n}_executeRules(t,n){this._disabled(n)||this.effectiveRules(n).executeAllRules(t,n)}_matchesPatterns(t,n){if(this._disabled(n))return;const r=this.effectivePatterns(n);for(const s of r){if(s.disabled&&s.disabled(n))continue;const a=s.matches(t.inputString,n);for(const i of a)i.marker?t.markers.append(i):t.append(i)}}}function vi(u){const e=new $;e.defaults({name:"path",marker:!0});function t(n,r){if(r?.name_only)return[[0,n.length]];const s=[...Rt(n,"/"),...Rt(n,"\\"),-1,n.length];s.sort((i,o)=>i-o);const a=[];for(let i=0;i<s.length-1;i++)a.push([s[i]+1,s[i+1]]);return a}return e.functional(t),e}class xi extends Error{constructor(e){super(e),this.name="ConfigurationException"}}function _i(u){const e=new $;e.defaults({name:"group",marker:!0});const{starting:t,ending:n}=u;if(t.length!==n.length)throw new xi("Starting and ending groups must have the same length");function r(s){const a=Array.from({length:t.length},()=>[]),i=[];for(let o=0;o<s.length;o++){const c=s[o],l=t.indexOf(c);l>-1&&a[l].push(o);const d=n.indexOf(c);if(d>-1){const p=a[d];if(p.length>0){const g=p.pop();i.push([g,o+1])}}}return i}return e.functional(r),e}function I(u,e,t=!1){if(!u||u.length===0)return"(?:)";const n=[];for(const r of u)n.length===0?(n.push("(?"),e?n.push(`<${e}>`):n.push(":")):n.push("|"),n.push(t?`(?:${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`:`(?:${r})`);return n.push(")"),n.join("")}const yi=[["M",1e3],["CM",900],["D",500],["CD",400],["C",100],["XC",90],["L",50],["XL",40],["X",10],["IX",9],["V",5],["IV",4],["I",1]],bi={zero:0,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,zéro:0,un:1,deux:2,trois:3,quatre:4,cinq:5,sept:7,huit:8,neuf:9,dix:10,onze:11,douze:12,treize:13,quatorze:14,quinze:15,seize:16,"dix-sept":17,"dix-huit":18,"dix-neuf":19,vingt:20};function wi(u){const e=u.toUpperCase();let t=0,n=0;for(const[r,s]of yi)for(;e.startsWith(r,n);)t+=s,n+=r.length;return n===e.length&&t>0?t:void 0}function Si(u){return bi[u.toLowerCase()]}function se(u){const e=parseInt(u,10);if(!isNaN(e))return e;const t=wi(u);return t!==void 0?t:Si(u)}const C=" [](){}+*|=-_~#/\\.,;:",ke=C.replace(/[\[\](){}]/g,""),$a=C.replace(/[/\\]/g,""),Ft="-+/\\|";function $e(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}const B=$e(C);$e(ke);const K=["-","["+$e($a)+"]"],Ai=["@","["+$e($a)+"]"];function z(u){return"(?:"+u+")?"}const ie=u=>Ca(C,u),oe=u=>Ma(C,u),R=u=>ei(C,u);function ye(u){const e=Number(u.trim());return Number.isInteger(e)}function ge(...u){return e=>u.every(t=>t(e))}function Ha(...u){return e=>u.some(t=>t(e))}const ki={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ç:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ç:"c",è:"e",é:"e",ê:"e",ë:"e",ì:"i",í:"i",î:"i",ï:"i",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ù:"u",ú:"u",û:"u",ü:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",Ď:"D",ď:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",ĝ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",Ť:"T",ť:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ǟ:"A",ǟ:"a",Ǡ:"A",ǡ:"a",Ǣ:"Æ",ǣ:"æ",Ǧ:"G",ǧ:"g",Ǩ:"K",ǩ:"k",Ǫ:"O",ǫ:"o",Ǭ:"O",ǭ:"o",Ǯ:"Ʒ",ǯ:"ʒ",ǰ:"j",Ǵ:"G",ǵ:"g",Ǹ:"N",ǹ:"n",Ǻ:"A",ǻ:"a",Ǽ:"Æ",ǽ:"æ",Ǿ:"Ø",ǿ:"ø",Ȁ:"A",ȁ:"a",Ȃ:"A",ȃ:"a",Ȅ:"E",ȅ:"e",Ȇ:"E",ȇ:"e",Ȉ:"I",ȉ:"i",Ȋ:"I",ȋ:"i",Ȍ:"O",ȍ:"o",Ȏ:"O",ȏ:"o",Ȑ:"R",ȑ:"r",Ȓ:"R",ȓ:"r",Ȕ:"U",ȕ:"u",Ȗ:"U",ȗ:"u",Ș:"S",ș:"s",Ț:"T",ț:"t",Ȟ:"H",ȟ:"h",Ȧ:"A",ȧ:"a",Ȩ:"E",ȩ:"e",Ȫ:"O",ȫ:"o",Ȭ:"O",ȭ:"o",Ȯ:"O",ȯ:"o",Ȱ:"O",ȱ:"o",Ȳ:"Y",ȳ:"y","΅":"¨",Ά:"Α",Έ:"Ε",Ή:"Η",Ί:"Ι",Ό:"Ο",Ύ:"Υ",Ώ:"Ω",ΐ:"ι",Ϊ:"Ι",Ϋ:"Υ",ά:"α",έ:"ε",ή:"η",ί:"ι",ΰ:"υ",ϊ:"ι",ϋ:"υ",ό:"ο",ύ:"υ",ώ:"ω",ϓ:"ϒ",ϔ:"ϒ",Ѐ:"Е",Ё:"Е",Ѓ:"Г",Ї:"І",Ќ:"К",Ѝ:"И",Ў:"У",Й:"И",й:"и",ѐ:"е",ё:"е",ѓ:"г",ї:"і",ќ:"к",ѝ:"и",ў:"у",Ѷ:"Ѵ",ѷ:"ѵ",Ӂ:"Ж",ӂ:"ж",Ӑ:"А",ӑ:"а",Ӓ:"А",ӓ:"а",Ӗ:"Е",ӗ:"е",Ӛ:"Ә",ӛ:"ә",Ӝ:"Ж",ӝ:"ж",Ӟ:"З",ӟ:"з",Ӣ:"И",ӣ:"и",Ӥ:"И",ӥ:"и",Ӧ:"О",ӧ:"о",Ӫ:"Ө",ӫ:"ө",Ӭ:"Э",ӭ:"э",Ӯ:"У",ӯ:"у",Ӱ:"У",ӱ:"у",Ӳ:"У",ӳ:"у",Ӵ:"Ч",ӵ:"ч",Ӹ:"Ы",ӹ:"ы",Ḁ:"A",ḁ:"a",Ḃ:"B",ḃ:"b",Ḅ:"B",ḅ:"b",Ḇ:"B",ḇ:"b",Ḉ:"C",ḉ:"c",Ḋ:"D",ḋ:"d",Ḍ:"D",ḍ:"d",Ḏ:"D",ḏ:"d",Ḑ:"D",ḑ:"d",Ḓ:"D",ḓ:"d",Ḕ:"E",ḕ:"e",Ḗ:"E",ḗ:"e",Ḙ:"E",ḙ:"e",Ḛ:"E",ḛ:"e",Ḝ:"E",ḝ:"e",Ḟ:"F",ḟ:"f",Ḡ:"G",ḡ:"g",Ḣ:"H",ḣ:"h",Ḥ:"H",ḥ:"h",Ḧ:"H",ḧ:"h",Ḩ:"H",ḩ:"h",Ḫ:"H",ḫ:"h",Ḭ:"I",ḭ:"i",Ḯ:"I",ḯ:"i",Ḱ:"K",ḱ:"k",Ḳ:"K",ḳ:"k",Ḵ:"K",ḵ:"k",Ḷ:"L",ḷ:"l",Ḹ:"L",ḹ:"l",Ḻ:"L",ḻ:"l",Ḽ:"L",ḽ:"l",Ḿ:"M",ḿ:"m",Ṁ:"M",ṁ:"m",Ṃ:"M",ṃ:"m",Ṅ:"N",ṅ:"n",Ṇ:"N",ṇ:"n",Ṉ:"N",ṉ:"n",Ṋ:"N",ṋ:"n",Ṍ:"O",ṍ:"o",Ṏ:"O",ṏ:"o",Ṑ:"O",ṑ:"o",Ṓ:"O",ṓ:"o",Ṕ:"P",ṕ:"p",Ṗ:"P",ṗ:"p",Ṙ:"R",ṙ:"r",Ṛ:"R",ṛ:"r",Ṝ:"R",ṝ:"r",Ṟ:"R",ṟ:"r",Ṡ:"S",ṡ:"s",Ṣ:"S",ṣ:"s",Ṥ:"S",ṥ:"s",Ṧ:"S",ṧ:"s",Ṩ:"S",ṩ:"s",Ṫ:"T",ṫ:"t",Ṭ:"T",ṭ:"t",Ṯ:"T",ṯ:"t",Ṱ:"T",ṱ:"t",Ṳ:"U",ṳ:"u",Ṵ:"U",ṵ:"u",Ṷ:"U",ṷ:"u",Ṹ:"U",ṹ:"u",Ṻ:"U",ṻ:"u",Ṽ:"V",ṽ:"v",Ṿ:"V",ṿ:"v",Ẁ:"W",ẁ:"w",Ẃ:"W",ẃ:"w",Ẅ:"W",ẅ:"w",Ẇ:"W",ẇ:"w",Ẉ:"W",ẉ:"w",Ẋ:"X",ẋ:"x",Ẍ:"X",ẍ:"x",Ẏ:"Y",ẏ:"y",Ẑ:"Z",ẑ:"z",Ẓ:"Z",ẓ:"z",Ẕ:"Z",ẕ:"z",ẖ:"h",ẗ:"t",ẘ:"w",ẙ:"y",ẛ:"ſ",Ạ:"A",ạ:"a",Ả:"A",ả:"a",Ấ:"A",ấ:"a",Ầ:"A",ầ:"a",Ẩ:"A",ẩ:"a",Ẫ:"A",ẫ:"a",Ậ:"A",ậ:"a",Ắ:"A",ắ:"a",Ằ:"A",ằ:"a",Ẳ:"A",ẳ:"a",Ẵ:"A",ẵ:"a",Ặ:"A",ặ:"a",Ẹ:"E",ẹ:"e",Ẻ:"E",ẻ:"e",Ẽ:"E",ẽ:"e",Ế:"E",ế:"e",Ề:"E",ề:"e",Ể:"E",ể:"e",Ễ:"E",ễ:"e",Ệ:"E",ệ:"e",Ỉ:"I",ỉ:"i",Ị:"I",ị:"i",Ọ:"O",ọ:"o",Ỏ:"O",ỏ:"o",Ố:"O",ố:"o",Ồ:"O",ồ:"o",Ổ:"O",ổ:"o",Ỗ:"O",ỗ:"o",Ộ:"O",ộ:"o",Ớ:"O",ớ:"o",Ờ:"O",ờ:"o",Ở:"O",ở:"o",Ỡ:"O",ỡ:"o",Ợ:"O",ợ:"o",Ụ:"U",ụ:"u",Ủ:"U",ủ:"u",Ứ:"U",ứ:"u",Ừ:"U",ừ:"u",Ử:"U",ử:"u",Ữ:"U",ữ:"u",Ự:"U",ự:"u",Ỳ:"Y",ỳ:"y",Ỵ:"Y",ỵ:"y",Ỷ:"Y",ỷ:"y",Ỹ:"Y",ỹ:"y",ἀ:"α",ἁ:"α",ἂ:"α",ἃ:"α",ἄ:"α",ἅ:"α",ἆ:"α",ἇ:"α",Ἀ:"Α",Ἁ:"Α",Ἂ:"Α",Ἃ:"Α",Ἄ:"Α",Ἅ:"Α",Ἆ:"Α",Ἇ:"Α",ἐ:"ε",ἑ:"ε",ἒ:"ε",ἓ:"ε",ἔ:"ε",ἕ:"ε",Ἐ:"Ε",Ἑ:"Ε",Ἒ:"Ε",Ἓ:"Ε",Ἔ:"Ε",Ἕ:"Ε",ἠ:"η",ἡ:"η",ἢ:"η",ἣ:"η",ἤ:"η",ἥ:"η",ἦ:"η",ἧ:"η",Ἠ:"Η",Ἡ:"Η",Ἢ:"Η",Ἣ:"Η",Ἤ:"Η",Ἥ:"Η",Ἦ:"Η",Ἧ:"Η",ἰ:"ι",ἱ:"ι",ἲ:"ι",ἳ:"ι",ἴ:"ι",ἵ:"ι",ἶ:"ι",ἷ:"ι",Ἰ:"Ι",Ἱ:"Ι",Ἲ:"Ι",Ἳ:"Ι",Ἴ:"Ι",Ἵ:"Ι",Ἶ:"Ι",Ἷ:"Ι",ὀ:"ο",ὁ:"ο",ὂ:"ο",ὃ:"ο",ὄ:"ο",ὅ:"ο",Ὀ:"Ο",Ὁ:"Ο",Ὂ:"Ο",Ὃ:"Ο",Ὄ:"Ο",Ὅ:"Ο",ὐ:"υ",ὑ:"υ",ὒ:"υ",ὓ:"υ",ὔ:"υ",ὕ:"υ",ὖ:"υ",ὗ:"υ",Ὑ:"Υ",Ὓ:"Υ",Ὕ:"Υ",Ὗ:"Υ",ὠ:"ω",ὡ:"ω",ὢ:"ω",ὣ:"ω",ὤ:"ω",ὥ:"ω",ὦ:"ω",ὧ:"ω",Ὠ:"Ω",Ὡ:"Ω",Ὢ:"Ω",Ὣ:"Ω",Ὤ:"Ω",Ὥ:"Ω",Ὦ:"Ω",Ὧ:"Ω",ὰ:"α",ά:"α",ὲ:"ε",έ:"ε",ὴ:"η",ή:"η",ὶ:"ι",ί:"ι",ὸ:"ο",ό:"ο",ὺ:"υ",ύ:"υ",ὼ:"ω",ώ:"ω",ᾀ:"α",ᾁ:"α",ᾂ:"α",ᾃ:"α",ᾄ:"α",ᾅ:"α",ᾆ:"α",ᾇ:"α",ᾈ:"Α",ᾉ:"Α",ᾊ:"Α",ᾋ:"Α",ᾌ:"Α",ᾍ:"Α",ᾎ:"Α",ᾏ:"Α",ᾐ:"η",ᾑ:"η",ᾒ:"η",ᾓ:"η",ᾔ:"η",ᾕ:"η",ᾖ:"η",ᾗ:"η",ᾘ:"Η",ᾙ:"Η",ᾚ:"Η",ᾛ:"Η",ᾜ:"Η",ᾝ:"Η",ᾞ:"Η",ᾟ:"Η",ᾠ:"ω",ᾡ:"ω",ᾢ:"ω",ᾣ:"ω",ᾤ:"ω",ᾥ:"ω",ᾦ:"ω",ᾧ:"ω",ᾨ:"Ω",ᾩ:"Ω",ᾪ:"Ω",ᾫ:"Ω",ᾬ:"Ω",ᾭ:"Ω",ᾮ:"Ω",ᾯ:"Ω",ᾰ:"α",ᾱ:"α",ᾲ:"α",ᾳ:"α",ᾴ:"α",ᾶ:"α",ᾷ:"α",Ᾰ:"Α",Ᾱ:"Α",Ὰ:"Α",Ά:"Α",ᾼ:"Α","῁":"¨",ῂ:"η",ῃ:"η",ῄ:"η",ῆ:"η",ῇ:"η",Ὲ:"Ε",Έ:"Ε",Ὴ:"Η",Ή:"Η",ῌ:"Η","῍":"᾿","῎":"᾿","῏":"᾿",ῐ:"ι",ῑ:"ι",ῒ:"ι",ΐ:"ι",ῖ:"ι",ῗ:"ι",Ῐ:"Ι",Ῑ:"Ι",Ὶ:"Ι",Ί:"Ι","῝":"῾","῞":"῾","῟":"῾",ῠ:"υ",ῡ:"υ",ῢ:"υ",ΰ:"υ",ῤ:"ρ",ῥ:"ρ",ῦ:"υ",ῧ:"υ",Ῠ:"Υ",Ῡ:"Υ",Ὺ:"Υ",Ύ:"Υ",Ῥ:"Ρ","῭":"¨","΅":"¨",ῲ:"ω",ῳ:"ω",ῴ:"ω",ῶ:"ω",ῷ:"ω",Ὸ:"Ο",Ό:"Ο",Ὼ:"Ω",Ώ:"Ω",ῼ:"Ω",Å:"A","↚":"←","↛":"→","↮":"↔","⇍":"⇐","⇎":"⇔","⇏":"⇒","∄":"∃","∉":"∈","∌":"∋","∤":"∣","∦":"∥","≁":"∼","≄":"≃","≇":"≅","≉":"≈","≠":"=","≢":"≡","≭":"≍","≮":"<","≯":">","≰":"≤","≱":"≥","≴":"≲","≵":"≳","≸":"≶","≹":"≷","⊀":"≺","⊁":"≻","⊄":"⊂","⊅":"⊃","⊈":"⊆","⊉":"⊇","⊬":"⊢","⊭":"⊨","⊮":"⊩","⊯":"⊫","⋠":"≼","⋡":"≽","⋢":"⊑","⋣":"⊒","⋪":"⊲","⋫":"⊳","⋬":"⊴","⋭":"⊵","⫝̸":"⫝"};function sa(u){let e="";for(const t of u)e+=ki[t]??t;return e.replace(/[̀-ͯ]/g,"")}const Di=new Set([",",":",";","-","/","\\"]),Ci=C.split("").filter(u=>!Di.has(u)).join("");function Mi(u,e){return u-1>=0&&C.includes(e[u])&&(u-2<0||C.includes(e[u-2]))&&!C.includes(e[u-1])}function Ei(u,e){return u+2>=e.length||e[u+2]===e[u]&&!C.includes(e[u+1])}function H(u){if(!u)return u;let e=u;for(const s of Ci)e=e.split(s).join(" ");const t=[];for(let s=0;s<e.length;s++)C.includes(e[s])&&t.push(s);const n=new Set;if(t.length>0){const s=e.split(""),a=[];for(const o of t)Mi(o,u)&&Ei(o,u)&&a.push(o);const i=[];for(const o of a)(a.includes(o-2)||a.includes(o+2))&&i.push(o);if(i.length>0){for(const o of i)n.add(u[o]),s[o]=u[o];e=s.join("")}}const r=C.split("").filter(s=>!n.has(s)).join("");return e=me(e,r),e=e.replace(/ +/g," "),e}function me(u,e=C){let t=0,n=u.length;for(;t<n&&e.includes(u[t]);)t++;for(;n>t&&e.includes(u[n-1]);)n--;return u.slice(t,n)}function Ba(u){return Le(H,me)(u.toLowerCase())}function qe(u,e=["the"],t=[", ",","]){const n=u.toLowerCase();for(const r of e)for(const s of t){const a=s+r;if(n.endsWith(a))return u.slice(u.length-a.length+s.length)+" "+u.slice(0,u.length-a.length)}return u}function S(u,e){if(!u)return!1;const t=u.excludes,n=u.includes;return!!(t&&t.includes(e)||n&&n.length>0&&!n.includes(e))}const It={零:0,一:1,二:2,两:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},aa="(?:\\d{1,4}|[一二两三四五六七八九]?十[一二两三四五六七八九]?|[零一二两三四五六七八九])";function ia(u){if(/^\d+$/.test(u))return parseInt(u,10);if(u.includes("十")){const[e,t]=u.split("十"),n=e?It[e]:1,r=t?It[t]:0;return n*10+r}return It[u]}function oa(u){const e=[],t=[];for(const n of u)typeof n=="object"?(n.numfirst&&t.push(n.value),e.push(n.value)):e.push(n);return{words:e,numfirst:t}}function la(u,e){const t=u.named("episode")||[];if(t.length>1&&Math.abs(t[t.length-1].value-t[t.length-2].value)>e.episode_max_range)return!0;const n=u.named("season")||[];if(n.length>1){const r=n[n.length-1].value,s=n[n.length-2].value;if(Math.abs(r-s)>e.season_max_range||r<s)return!0}return!1}function Se(u,e){const t=a=>!!(a?.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(a?.initiator?.name)||["weak_episode","weak_duplicate"].includes(a?.name));if(t(u)&&t(e))return null;const n=a=>a?.name?null:[...a?.children??[]].find(o=>o.name==="season"||o.name==="episode")??null,r=n(u),s=n(e);if(r&&s){const a=!!r.tags?.includes("numfirst"),i=!!s.tags?.includes("numfirst");if(a!==i)return null}if(u.name!==e.name){if(u.name==="episode"&&e.name==="year")return u;if(["season","episode"].includes(u.name)){if(["video_codec","audio_codec","container","date"].includes(e.name)){if(e.name==="video_codec"&&/^[hx][\W_]\d/i.test(String(e.raw??""))){const a=(e.inputString??"")[e.start-1]??"";if(/[a-z]/i.test(a))return e}return u}if(e.name==="audio_channels"&&!e.tags?.includes("weak-audio_channels")&&!u.initiator?.children?.named(u.name+"Marker")?.length||e.name==="screen_size"&&!ye(e.raw))return u}}if(["season","episode"].includes(u.name)&&["season","episode"].includes(e.name)&&u.initiator!==e.initiator){const a=v=>!!(v.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(v.initiator?.name)),i=!!u.tags?.includes("numfirst"),o=!!e.tags?.includes("numfirst");if(i!==o&&!a(u)&&!a(e)&&u.start<e.end&&e.start<u.end){const v=i?u:e,h=i?e:u,m=u.inputString??"",D=(T,O)=>{let y=T;for(;y>=0&&y<m.length&&C.includes(m[y]);)y+=O;let q="";for(;y>=0&&y<m.length&&/\d/.test(m[y]);)q=q+m[y],y+=O;return q},b=T=>T.length===4&&+T>=1900&&+T<=2100,A=v.initiator??v,k=h.initiator??h,E=(()=>{const T=D(A.end,1);return T.length>=1&&T.length<=4&&!b(T)})();return(()=>{const T=m.slice(Math.max(0,k.start-12),k.start),O=/(\d{1,3})(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?[\s.,_\-–]*$/iu.exec(T);return!!(O&&!b(O[1]))})()&&!E?h:v}const c=!!(u.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(u.initiator?.name)),l=!!(e.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(e.initiator?.name));if(c&&l)return null;if(c)return u;if(l)return e;const d=!!u.tags?.includes("SxxExx"),p=!!e.tags?.includes("SxxExx");if(d&&!p)return e;if(p&&!d)return u;const g=u.initiator?.raw?.toLowerCase().includes("x")&&!d,f=e.initiator?.raw?.toLowerCase().includes("x")&&!p;if(g&&!f)return u;if(f&&!g)return e}return"__default__"}function Ae(u){const e=u.children?.toDict?.()??u.children?.to_dict?.(),t=e instanceof Map?Object.fromEntries(e):e||{};if(t.season&&Array.isArray(t.season)){const n=[...t.season].sort((r,s)=>r-s);if(JSON.stringify(n)!==JSON.stringify(t.season))return!1}if(t.episode&&Array.isArray(t.episode)){const n=[...t.episode].sort((r,s)=>r-s);if(JSON.stringify(n)!==JSON.stringify(t.episode))return!1}return!0}function Ue(u){return ye(u.raw)?!0:R(u)}function ca(u){const e=String(u.raw??"");if(/^\d{4}$/.test(e)){const t=parseInt(e,10);if(t>=1900&&t<=2100)return!1}return Ue(u)}function Pi(u){u.range_separators;const e=u.discrete_separators,t=C.split("").filter(y=>!u.range_separators.includes(y)&&y!=="/"&&y!=="\\"),n=[...u.range_separators,...e,...t],r=Ae,s=y=>{if(!r(y))return!1;const q=V=>{let J=null,ce=!0;const pe=y.children,ne=pe?.named?.(V)??[];for(const F of Array.isArray(ne)?ne:[ne]){if(J){const Z=pe.previous?.(F,j=>j.name===V+"Separator",0);if(Z){const j=String(Z.raw??"");if(!u.range_separators.includes(j)&&t.includes(j)){const re=Number(F.value)-Number(J.value);re>0&&re<=u.max_range_gap+1||(ce=!1)}if(e.includes(j)){ce=!0;break}}}J=F}return ce};return q("episode")&&q("season")},o=`(?:\\d+|[ivxlcdm]+|${["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","un","deux","trois","quatre","cinq","sept","huit","neuf","dix","onze","douze","treize","quatorze","quinze","seize","vingt"].join("|")})`,c="(?:\\d+|[ivxlcdm]+)";function l(y){return S(y,"episode")||S(y,"season")}const d=new $().regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}).defaults({privateNames:["episodeSeparator","seasonSeparator","episodeMarker","seasonMarker"],formatter:{season:y=>parseInt(y,10),episode:y=>parseInt(y,10),version:y=>parseInt(y,10),count:y=>parseInt(y,10)},children:!0,privateParent:!0,conflictSolver:Se,abbreviations:[Ai]});d.regex(`第(?<episode>${aa})[話话集]`,{tags:["SxxExx"],formatter:{episode:ia}}),d.regex(`第(?<season>${aa})季`,{tags:["SxxExx"],formatter:{season:ia}}),d.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})(?!\\d)",{tags:["SxxExx"]}),d.regex("(?<!\\d)(?<season>\\d{1,2})期",{});const p=I(u.season_markers,"seasonMarker"),g=I([...u.episode_markers,...u.disc_markers],"episodeMarker"),f=I([...u.episode_markers,...u.disc_markers,...n],"episodeSeparator",!0);d.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ge(R,s)},chainBreaker:y=>la(y,u),disabled:l}).defaults({tags:["SxxExx"]}).regex(p+"(?<season>\\d+)@?"+g+"@?(?<episode>\\d+)(?:[a-d](?![a-z0-9]))?(?:v(?<version>\\d+))?").repeater("+").regex(f+"@?(?<episode>\\d+)").repeater("*");const v=I(u.season_ep_markers,"episodeMarker"),h="(?!@"+I(u.season_ep_markers)+"\\d)";d.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ge(R,Ae)},disabled:l}).defaults({tags:["SxxExx"]}).regex("(?!0x[0-9a-fA-F])(?<season>\\d+)"+h+"@?"+v+"@?(?<episode>\\d+)").repeater("+"),d.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ge(R,Ae)},disabled:l}).defaults({tags:["SxxExx"]}).regex("(?!0x[0-9a-fA-F])(?<season>\\d+)"+h+"@?"+v+"@?(?<episode>\\d+)").regex(I([...u.season_ep_markers,...e,...u.range_separators],"episodeSeparator",!0)+"(?<episode>\\d+)").repeater("*"),d.regex("t(?<season>\\d{1,2})@?"+I(u.episode_markers,"episodeMarker")+"@?(?<episode>\\d{1,4})",{tags:["SxxExx"],disabled:l}),d.regex("(?<![^\\W_])(?:SP|EX|OVA|OAV)-?(?<episode>\\d{1,3})(?![^\\W_])",{tags:["SxxExx","special-episode"],disabled:y=>S(y,"episode")}),d.regex("(?<season>\\d{1,2})(?:st|nd|rd|th)@?(?:season)(?![^\\W_])",{tags:["SxxExx","numfirst"],disabled:l}),d.regex("(?<!\\d)(?<season>\\d{1,2})(?<episodeMarker>x)(?<episode>\\d{2})(?!\\d)",{tags:["SxxExx"],disabled:l});const m=I([...u.season_markers,...e,...u.range_separators],"seasonSeparator",!0);d.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ge(R,Ae)},disabled:l}).defaults({tags:["SxxExx"]}).regex(p+"(?<season>\\d+)").regex("(?<other>Extras)",{name:"other",value:"Extras",tags:["no-release-group-prefix"]}).repeater("?").regex(m+"(?<season>\\d+)").repeater("*");for(const y of["Special","Pilot","Unaired","Final"])d.string(y,{name:"episode_details",value:y,children:!1,privateParent:!1,disabled:q=>S(q,"episode_details")});const{words:D,numfirst:b}=oa(u.season_words),{words:A,numfirst:k}=oa(u.episode_words),E=I(D,"seasonMarker"),M=I(u.of_words);d.chain({validateAll:!0,conflictSolver:Se,formatter:{season:se,season_count:se},validator:{__parent__:ge(R,Ae),season:ca,season_count:Ue},chainBreaker:y=>la(y,u),disabled:y=>y?.type==="movie"||S(y,"season")}).defaults({formatter:{season:se,season_count:se},validator:{season:ca,season_count:Ue},conflictSolver:Se}).regex(E+`@?(?P<season>${o})`).regex(M+`@?(?P<season_count>${c})`).repeater("?").regex("(?:,@?)?@?"+I([...u.range_separators,...e,"@"],"seasonSeparator",!0)+"@?(?P<season>\\d+)").repeater("*");const T="(?:@?"+M+"@?(?<count>\\d+))?";b.length>0&&d.regex("(?<season>\\d{1,2})"+u.ordinal_suffix+"@?@?"+I(b,"seasonMarker")+"(?![^\\W\\d_])"+T,{tags:["SxxExx","numfirst"],formatter:{season:se,count:y=>parseInt(y,10)},disabled:l}),k.length>0&&d.regex("(?<episode>\\d{1,3})"+u.ordinal_suffix+"@?@?"+I(k,"episodeMarker")+"(?![^\\W\\d_])"+T,{tags:["SxxExx","numfirst"],formatter:{episode:se,count:y=>parseInt(y,10)},disabled:y=>S(y,"episode")});const O=I(A,"episodeMarker");return d.regex(I(A,"episodeMarker")+"@?(?<season>\\d{1,2})\\.(?<episode>\\d{2,3})(?!\\d)",{tags:["SxxExx"],disabled:l}),d.regex("(?<=[\\s([_-][\\s._-]?)(?<season>\\d{1,2})\\.(?<episode>\\d{2,3})(?=[\\s)\\]._-]|$)(?!\\.\\d)",{tags:["SxxExx","decimal-episode"],validator:{__parent__:y=>{const V=(y.inputString??"").slice(Math.max(0,y.start-3),y.start);return/[-([]\s?$|^\s*$|\s-\s$/.test(V)||/[([]/.test(V)}},disabled:l}),d.regex("(?<![a-zA-Z\\d])"+O+"@?(?<episode>\\d+)(?:v(?<version>\\d+))?(?:@?"+M+"@?(?<count>\\d+))?",{disabled:y=>y?.type==="episode"||S(y,"episode")}),d.regex("(?<![a-zA-Z\\d])"+O+`@?(?<episode>${c})(?:v(?<version>\\d+))?(?:@?`+M+"@?(?<count>\\d+))?",{validator:{episode:Ue},formatter:{episode:se},disabled:y=>y?.type!=="episode"||S(y,"episode")}),d.regex("S?(?<season>\\d+)-?(?:xE|Ex|E|x)-?(?<other>"+I(u.all_words)+")",{tags:["SxxExx"],formatter:{other:()=>"Complete"},disabled:y=>S(y,"season")}),d.chain({tags:["weak-episode"],disabled:y=>y?.type==="movie"||S(y,"episode")}).defaults({validator:null,tags:["weak-episode"]}).regex("(?<![^\\W_])(?<episode>\\d{2})(?!(?:st|nd|rd|th)\\b)(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>[x-])(?<episode>\\d{2})",{abbreviations:null}).repeater("*"),d.chain({tags:["weak-episode"],disabled:y=>y?.type==="movie"||S(y,"episode")}).defaults({validator:null,tags:["weak-episode"]}).regex("(?<![^\\W_])0(?<episode>\\d{1,2})(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>[x-])0(?<episode>\\d{1,2})",{abbreviations:null}).repeater("*"),d.chain({tags:["weak-episode"],name:"weak_episode",disabled:y=>y?.type==="movie"||S(y,"episode")}).defaults({validator:null,tags:["weak-episode"],name:"weak_episode"}).regex("(?<![^\\W_])(?<episode>\\d{3,4})(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>[x-])(?<episode>\\d{3,4})",{abbreviations:null}).repeater("*"),d.chain({tags:["weak-episode"],disabled:y=>y?.type!=="episode"||S(y,"episode")}).defaults({validator:null,tags:["weak-episode"]}).regex("(?<![^\\W_])(?<episode>\\d)(?!-[a-z])(?!%)(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>[x-])(?<episode>\\d{1,2})",{abbreviations:null}).repeater("*"),d.chain({validateAll:!0,validator:{__parent__:R},disabled:y=>S(y,"episode")}).defaults({validator:null}).regex("(?<season>\\d{1,2})?(?<episodeMarker>e)(?<episode>\\d{1,4})").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>e|x|-)(?<episode>\\d{1,4})",{abbreviations:null}).repeater("*"),d.chain({disabled:y=>S(y,"episode")}).defaults({validator:null}).regex("(?<![a-zA-Z\\d])ep-?(?<episode>\\d{1,4})").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>ep|e|x|-)(?<episode>\\d{1,4})",{abbreviations:null}).repeater("*"),d.chain({tags:["see-pattern"],disabled:l}).defaults({validator:null,tags:["see-pattern"]}).regex("(?<seasonMarker>cap)@?(?<season>\\d{1,2})(?<episode>\\d{2})(?!\\d)").regex("(?<episodeSeparator>[_-])(?<season>\\d{1,2})(?<episode>\\d{2})(?!\\d)").repeater("?"),d.chain({tags:["weak-episode","weak-duplicate"],name:"weak_duplicate",conflictSolver:Se,disabled:y=>y?.episode_prefer_number===!0||y?.type==="movie"||l(y)}).defaults({tags:["weak-episode","weak-duplicate"],name:"weak_duplicate",validator:null,conflictSolver:Se}).regex("(?<![^\\W_])(?<season>\\d{1,2})(?<episode>\\d{2})(?!%)(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>x|-)(?<episode>\\d{2})",{abbreviations:null}).repeater("*"),d.regex("v(?<version>\\d+)",{formatter:{version:y=>parseInt(y,10)},disabled:y=>S(y,"version")}),d.regex("(?<![^\\W_])(?<episode>\\d+)@?"+M+"@?(?<count>\\d+)@?"+O+"?",{formatter:{episode:y=>parseInt(y,10),count:y=>parseInt(y,10)},preMatchProcessor:y=>(y.value=H(y.value),y),disabled:y=>S(y,"episode")}),d.regex("Minisodes?",{children:!1,privateParent:!1,name:"episode_format",value:"Minisode",disabled:y=>S(y,"episode_format")}),d.rules(Ht,Bt,$t,Vt,zt,Ut,Wt,qt,new jt(u),Ni,new Oi(u),Yt,Xt,Jt,Zt,Gt,Kt,Ii),d}const Br=class Br extends x{constructor(){super(...arguments),this.priority=72,this.consequence=w}when(e,t){const n=e.inputString??"",r=[],s=new Set(["audio_codec","audio_channels","video_codec","audio_profile","other"]);for(const a of e.named("season")??[]){const i=a.initiator??a;if(!/^s\d{1,3}$/i.test(String(i.raw??""))||[...i.children??[]].some(d=>d.name==="episode")||n[i.start-1]!=="-")continue;const c=e.range(Math.max(0,i.start-12),i.start-1,d=>!d.private&&s.has(d.name??""),-1)??e.range(Math.max(0,i.start-12),i.start-1,d=>!d.private&&s.has(d.name??""),0),l=e.markers.atMatch(i,d=>d.name==="group",0);if(!(!c&&!l)){r.push(a);for(const d of i.children??[])r.includes(d)||r.push(d)}}return r.length?r:!1}};Br.priority=72;let $t=Br;const Vr=class Vr extends x{constructor(){super(...arguments),this.priority=60,this.consequence=w}when(e,t){const n=e.inputString??"",r=[],s=a=>!!(a.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(a.initiator?.name));for(const a of e.markers.named("path")??[]){const i=e.range(a.start,a.end,c=>c.name==="episode"&&!c.private&&s(c))??[];if(!i.length)continue;const o=e.range(a.start,a.end,c=>!c.private&&(c.name==="season"||c.name==="year"||c.name==="date"||c.name==="episode"&&c.tags?.includes("SxxExx")),0);for(const c of i){const l=c.initiator??c,d=n.slice(l.end,l.end+5);if(/^[\s._-]?PPV/i.test(d)){for(const p of[l,...l.children??[]])r.includes(p)||r.push(p);continue}if(!o&&l.start===a.start&&/^[1-9]\d$/.test(String(l.raw??""))&&(n.slice(l.end,a.end).match(/[A-Za-z][a-z]+/g)??[]).length>=2)for(const f of[l,...l.children??[]])r.includes(f)||r.push(f)}}return r.length?r:!1}};Vr.priority=60;let Ht=Vr;const zr=class zr extends x{constructor(){super(...arguments),this.priority=60,this.consequence=w}when(e,t){const n=[];for(const r of e.named("episode")??[]){const s=r.initiator??r,a=[...s.children??[]].find(d=>d.name==="episodeMarker");if(!a||String(a.raw??"").length<3)continue;const i=e.markers.atMatch(r,d=>d.name==="path",0);if(!i)continue;const o=e.range(r.end,i.end,d=>!d.private&&d.name==="year",0);if(!o||e.range(i.start,i.end,d=>!d.private&&(d.name==="season"||d.name==="episode"&&d.tags?.includes("SxxExx")),0))continue;const l=String(e.inputString??"").slice(r.end,o.start);if(/[a-zA-Z]{2,}/.test(l)){n.push(r),n.includes(s)||n.push(s);for(const d of s.children??[])n.includes(d)||n.push(d)}}return n.length?n:!1}};zr.priority=60;let Bt=zr;const Ur=class Ur extends x{constructor(){super(...arguments),this.priority=-64,this.consequence=[w,L]}when(e,t){const n=e.inputString??"",r=[],s=[];if((e.named("episode")??[]).length)return!1;for(const i of e.markers.named("path")??[]){const o=e.range(i.start,i.end,h=>h.name==="crc32",0),c=e.range(i.start,i.end,h=>h.name==="release_group"&&h.tags?.includes("anime"),0),l=(e.markers.range(i.start,i.end,h=>h.name==="group")??[]).length;if(!o&&!c&&l<3)continue;let d=!1;for(const h of e.markers.range(i.start,i.end,m=>m.name==="group")??[]){const m=n.slice(h.start+1,h.end-1).trim();if(!/^\d{1,3}$/.test(m))continue;const D=e.range(h.start,h.end,b=>!b.private)??[];if(!D.some(b=>!["alternative_title","episode_title"].includes(b.name??"")&&!b.tags?.includes("weak-episode"))){r.push(...D),s.push(new P(h.start+1,h.end-1,{name:"episode",value:parseInt(m,10),inputString:n,tags:["anime"]})),d=!0;break}}if(d)continue;const p=e.range(i.start,i.end,h=>h.name==="title",0);if(!p)continue;const g=/^(.*[^\W\d_])[\s._-]+(\d{1,3})$/.exec(n.slice(p.start,p.end));if(!g)continue;const f=p.start+g[1].length+(g[0].length-g[1].length-g[2].length);r.push(p);const v=new P(p.start,p.start+g[1].length,{name:"title",value:H(g[1]),inputString:n});s.push(v),s.push(new P(f,p.end,{name:"episode",value:parseInt(g[2],10),inputString:n,tags:["anime"]}))}return r.length||s.length?[r,s]:!1}};Ur.priority=-64;let Vt=Ur;const Wr=class Wr extends x{constructor(){super(...arguments),this.priority=40,this.consequence=w}when(e,t){const n=e.inputString??"",r=[],s=i=>i.name==="episode"&&!i.private&&(i.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(i.initiator?.name)),a=i=>{for(const o of[...i.children??[],i])r.includes(o)||r.push(o);!i.children?.length&&!r.includes(i)&&r.push(i)};for(const i of e.markers.named("path")??[]){const o=e.range(i.start,i.end,s)??[];if(!o.length)continue;const c=e.range(i.start,i.end,h=>h.name==="episode"&&!h.private&&!s(h)&&!!h.initiator?.children?.named?.("episodeMarker")?.length,0),l=new Map;for(const h of o){const m=h.initiator??h;l.set(m,[...l.get(m)??[],h])}if(c){for(const h of l.keys())a(h);continue}if(l.size<2)continue;const d=h=>{let m=0;const D=String(h.raw??"");/^0\d/.test(D)&&(m+=4);let b=h.start-1;for(;b>=0&&(n[b]===" "||n[b]==="."||n[b]==="_");)b--;return n[b]==="-"&&(m+=1),e.markers.atMatch(h,A=>A.name==="group",0)&&(m-=2),m},p=[...l.keys()].map(h=>[h,d(h)]),g=Math.max(...p.map(([,h])=>h)),f=p.filter(([,h])=>h===g);if(f.length===p.length)continue;const v=new Set(f.flatMap(([h])=>(l.get(h)??[]).map(m=>Number(m.value))));for(const[h,m]of p){if(m>=g)continue;const D=l.get(h)??[];D.length>1||D.some(b=>v.has(Number(b.value)))||a(h)}}return r.length?r:!1}};Wr.priority=40;let zt=Wr;const qr=class qr extends x{constructor(){super(...arguments),this.priority=32,this.consequence=[w,L]}when(e,t){const n=e.inputString??"",r=[],s=[],a=e.named("season")??[],i=new Set;for(const o of a){const c=o.initiator??o;if(i.has(c))continue;i.add(c);const l=[...c.children??[]],d=l.find(b=>b.name==="seasonMarker");if(!d)continue;const p=String(d.raw??""),g=/^[a-zà-ÿа-я]{3,}$/i.test(p),f=!!e.markers.atMatch(o,b=>b.name==="group",0);if(!g&&!(p.toLowerCase()==="s"&&f)||g&&/s$/i.test(p))continue;const v=l.filter(b=>b.name==="season");if(v.length!==2)continue;const h=l.find(b=>b.name==="seasonSeparator");if(!h||String(h.raw??"").trim()!=="-"||g&&(n[h.start-1]!==" "||n[h.end]!==" "))continue;const m=e.markers.atMatch(o,b=>b.name==="path",0);if(m&&e.range(m.start,m.end,A=>A.name==="other"&&A.value==="Complete",0))continue;const D=new P(v[1].start,v[1].end,{name:"episode",value:v[1].value,inputString:n});r.push(v[1]),s.push(D)}return r.length||s.length?[r,s]:!1}};qr.priority=32;let Ut=qr;const jr=class jr extends x{constructor(){super(...arguments),this.priority=70,this.consequence=[w,L]}when(e,t){const n=[],r=[],s=c=>!!(c.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(c.initiator?.name)),a=c=>{const l=c.initiator??c;n.includes(c)||n.push(c);for(const d of l.children??[])n.includes(d)||n.push(d)},i=[...e],o=i.filter(c=>(c.name==="season"||c.name==="episode")&&c.tags?.includes("numfirst"));for(const c of o){const l=c.initiator??c,d=i.find(f=>{if(f.name!=="season"&&f.name!=="episode"||f.tags?.includes("numfirst")||s(f))return!1;const v=f.initiator??f;return v===l?!1:v.start<l.end&&l.start<v.end});if(!d)continue;const p=i.some(f=>!f.private&&(f.name==="screen_size"||f.name==="year")&&f.start<d.end&&d.start<f.end),g=/^(?:st|nd|rd|th|ª|º|°)/i.test(String(e.inputString??"").slice(c.end,c.end+2));p||g?(a(d),p||r.push(new P(d.start,d.end,{name:"episode",value:d.value,inputString:e.inputString}))):a(c)}return n.length||r.length?[n,r]:!1}};jr.priority=70;let Wt=jr;const Xe=class Xe extends x{constructor(){super(...arguments),this.priority=64,this.consequence=[w,new he("episode_count"),new he("season_count")]}when(e,t){const n=[],r=[],s=[];for(const a of e.named("count")??[]){const i=e.range(a.initiator.start,a.start,c=>c.name==="episode"||c.name==="season"),o=i.length?i[i.length-1]:void 0;o?o.name==="episode"?r.push(a):s.push(a):n.push(a)}return n.length||r.length||s.length?[n,r,s]:!1}};Xe.priority=64,Xe.consequence=[w,new he("episode_count"),new he("season_count")];let qt=Xe;const Gr=class Gr extends x{constructor(e){super(),this.priority=128,this.config=e}when(e,t){const n=new Set((this.config.disc_markers||[]).map(a=>a.toLowerCase()));if(n.size===0)return!1;const r=[],s=e.named("episode",a=>!a.private)||[];for(const a of s){const i=a.initiator;if(!i)continue;const o=i.children;if(!o)continue;const c=(typeof o.named=="function"?o.named("episodeMarker"):[])||[];for(const l of c){const d=(l.rawString||l.raw||l.value||"").toString().toLowerCase();if(n.has(d)){r.push(a);break}}}return r.length>0?r:!1}then(e,t,n){const r=S(n,"disc");for(const s of t)if(r){const a=s.initiator;if(e.remove(s),a){const i=a.children?typeof a.children[Symbol.iterator]=="function"?[...a.children]:[]:[];for(const o of i)e.includes(o)&&e.remove(o);e.includes(a)&&e.remove(a)}}else e.remove(s),s.name="disc",e.append(s)}};Gr.priority=128;let jt=Gr;class Ni extends x{when(e,t){const n=[],r=e.markers?.named("group")||[],s=Array.isArray(r)?r:r?[r]:[];for(const a of e){if(a.name!=="episode"&&a.name!=="season"||typeof a.value!="number"||!s.some(g=>a.end===g.end))continue;const o=e.inputString||"";let c=a.end-1,l=c;for(;l>a.start&&/\d/.test(o[l-1]);)l--;if(l>=c)continue;const d=o.slice(l,c),p=parseInt(d,10);isNaN(p)||p===a.value||n.push({match:a,correctValue:p})}return n.length>0?n:!1}then(e,t,n){for(const{match:r,correctValue:s}of t){r.value=s,e.inputString;let a=r.end-1;r.rawEnd<a&&(r.rawEnd=a)}}}class Oi extends x{constructor(e){super(),this.consequence=L,this.config=e}when(e,t){const n=[],r=new Set(this.config.range_separators||["-","~","to","a"]),s=e.markers?.named("path")||[],a=Array.isArray(s)?s:s?[s]:[],i=o=>{for(const c of a)if(o.start>=c.start&&o.end<=c.end)return c;return null};for(const o of["season","episode","absolute_episode","disc"]){const c=o==="season"?this.config.season_max_range:this.config.episode_max_range,l=e.named(o,p=>!p.private)||[];if(l.length<2)continue;const d=[...l].sort((p,g)=>p.start-g.start);for(let p=0;p<d.length-1;p++){const g=d[p],f=d[p+1],v=i(g),h=i(f);if(v!==h||!v)continue;const m=typeof g.value=="number"?g.value:parseInt(g.value,10),D=typeof f.value=="number"?f.value:parseInt(f.value,10);if(isNaN(m)||isNaN(D)||D<=m)continue;const b=D-m;if(b<=1||b>c)continue;const A=e.inputString?.slice(g.end,f.start)||"",k=A.replace(/[\s.]/g,"").toLowerCase(),E=k.replace(/[sexp]/gi,"");if(/[-~_]/.test(A)||o==="season"&&k===":"||r.has(k)||r.has(E))for(let y=m+1;y<D;y++){const q=new P(g.start,f.end,{name:o,value:y,inputString:e.inputString,tags:g.tags?[...g.tags]:[]});n.push(q)}}}return n.length>0?n:!1}}const Kr=class Kr extends x{constructor(){super(...arguments),this.consequence=w,this.priority=64}when(e,t){const n=[];for(const r of e.markers?.named("path")||[]){const s=e.range?.(r.start,r.end,a=>a.name==="season"&&!a.private&&a.tags?.includes("SxxExx"))?.[0];if(s?.initiator?.children?.named("episode"))for(const a of e.range?.(s.end,r.end,i=>i.name==="season"&&!i.private)||[])(!a.tags?.includes("SxxExx")||!a.initiator?.children?.named("episode"))&&(a.initiator?(n.push(a.initiator),n.push(...a.initiator.children||[])):n.push(a))}return n.length>0?n:!1}};Kr.priority=64;let Gt=Kr;const Xr=class Xr extends x{constructor(){super(...arguments),this.consequence=w,this.priority=64}when(e,t){const n=[];for(const r of e.markers?.named("path")||[]){const s=e.range?.(r.start,r.end,a=>a.name==="episode"&&!a.private&&a.tags?.includes("SxxExx"))?.[0];if(s){const a=this.getEpisodePrefix(e,s);for(const i of e.range?.(s.end,r.end,o=>o.name==="episode"&&!o.private)||[]){if(i.tags?.includes("SxxExx"))continue;const o=this.getEpisodePrefix(e,i),c=i.initiator?.children?.named?.("episodeMarker")||[],d=(Array.isArray(c)?c:[c]).some(g=>{const f=(g.rawString||g.raw||g.value||"").toString().toLowerCase();return f==="e"||f==="ep"});(a&&o?a.value?.toLowerCase?.()!==o.value?.toLowerCase?.():!i.tags?.includes("SxxExx")&&!d)&&(i.initiator?(n.push(i.initiator),n.push(...i.initiator.children||[])):(o&&n.push(o),n.push(i)))}}}return n.length>0?n:!1}getEpisodePrefix(e,t){return e.previous?.(t,n=>!n.private&&["episodeMarker","episodeSeparator"].includes(n.name))?.[0]}};Xr.priority=64;let Kt=Xr;const Yr=class Yr extends x{constructor(){super(...arguments),this.consequence=w,this.priority=64}when(e,t){const n=[],r=e.markers?.named("path")||[],s=Array.isArray(r)?r:r?[r]:[];for(const a of s){const i=(e.range?.(a.start,a.end,c=>c.tags?.includes("weak-duplicate"))||[]).slice().reverse(),o={};for(const c of i){const l=c.name??"",d=c.initiator?.pattern??c.pattern??null;d&&(o[l]||(o[l]=new Set),o[l].has(d)?n.push(c):o[l].add(d))}}return n.length>0?n:!1}};Yr.priority=64;let Xt=Yr;var xe;let Ii=(xe=class extends x{constructor(){super(...arguments),this.consequence=w,this.priority=32}when(e,t){return!1}},xe.priority=32,xe);const Zr=class Zr extends x{constructor(){super(...arguments),this.consequence=w,this.priority=128}enabled(e){return e?.type!=="movie"}isAnime(e){if(e.named("version")?.length>0||e.named("crc32")?.length>0)return!0;const t=e.markers?.named("group")||[],n=Array.isArray(t)?t:t?[t]:[];for(const r of n){const s=e.range?.(r.start,r.end,l=>l.name==="screen_size");if(Array.isArray(s)?s.length>0:!!s)return!0;const i=e.range?.(r.start,r.end,l=>!l.private&&!l.tags?.includes("weak-language"))||[];if((Array.isArray(i)?i:i?[i]:[]).filter(l=>l.name!=="release_group").length===0){const l=(e.inputString??"").slice(r.start+1,r.end-1).trim();if(l&&!/^\d+$/.test(l))return!0}}return!1}when(e,t){const n=[],r=this.isAnime(e),s=e.markers?.named("path")||[],a=Array.isArray(s)?s:s?[s]:[];for(const i of a){const o=e.range?.(i.start,i.end,l=>l.initiator?.name==="weak_episode")||[],c=e.range?.(i.start,i.end,l=>l.initiator?.name==="weak_duplicate")||[];if(r)o.length>0&&n.push(...c);else if(c.length>0){const l=e.range?.(i.start,i.end,p=>{if(p.name!=="episode"||p.initiator?.name!=="weak_episode")return!1;const g=p.initiator?.children;return g?Array.isArray(g)?g.some(f=>f.name==="episodeSeparator"):typeof g.named=="function"?(g.named("episodeSeparator")||[]).length>0:!1:!1})||[],d=(e.range?.(i.start,i.end,p=>p.tags?.includes("SxxExx")&&!p.private)||[]).length>0;l.length===0&&!d?n.push(...o):l.length>0&&n.push(...c)}}return n.length>0?n:!1}};Zr.priority=128;let Yt=Zr;const Jr=class Jr extends x{constructor(){super(...arguments),this.priority=-1}when(e,t){const n=[],r=e.markers?.named("path")||[],s=Array.isArray(r)?r:[r];for(const a of s){const i=e.range?.(a.start,a.end,f=>f.name==="episode"&&!f.private)||[];if(i.length<2)continue;const o=e.markers?.named?.("group")||[],l=(Array.isArray(o)?o:o?[o]:[]).filter(f=>f.start>=a.start&&f.end<=a.end),d=f=>l.some(v=>f.start>=v.start&&f.end<=v.end),p=i.filter(d),g=i.filter(f=>!d(f));p.length>0&&g.length>0&&n.push(...p)}return n.length===0?!1:(this._toRename=n,!0)}then(e,t,n){const r=this._toRename||[];for(const s of r)e.remove(s),s.name="absolute_episode",e.append(s)}};Jr.priority=-1;let Zt=Jr;const Qr=class Qr extends x{constructor(){super(...arguments),this.consequence=w,this.priority=64}when(e,t){const n=[],r=[],s=e.markers?.named("path")||[],a=Array.isArray(s)?s:[s];for(const i of a){const o=e.range?.(i.start,i.end,l=>!l.private&&l.tags?.includes("SxxExx"))||[];if(Array.isArray(o)?o.length>0:!!o){const l=e.range?.(i.start,i.end,p=>p.tags?.includes("weak-episode"))||[],d=new Map;for(const p of l){const g=p.initiator;d.has(g)||d.set(g,[]),d.get(g).push(p)}for(const p of l){const g=p.initiator,f=p.name==="episode"&&g?.name==="weak_episode",h=(d.get(g)||[]).filter(M=>M.name==="episode").length>1,m=e.inputString||"",D=g?.start??p.start,b=g?.end??p.end,A=D>0?m[D-1]:"",k=b<m.length?m[b]:"",E=(!A||C.includes(A))&&(!k||C.includes(k));f&&E&&h?r.push(p):n.push(p)}}}return this._toRename=r,n.length>0||r.length>0?n:!1}then(e,t,n){if(t&&Array.isArray(t))for(const s of t)e.remove(s);const r=this._toRename||[];for(const s of r)e.remove(s),s.name="absolute_episode",e.append(s)}};Qr.priority=64;let Jt=Qr;function Ti(u){const e=new $({disabled:l=>S(l,"container")});e.regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}),e.defaults({name:"container",formatter:l=>l.replace(new RegExp(`[${$e(C)}]`,"g"),""),tags:["extension"],conflictSolver:(l,d)=>d.name==="source"||d.name==="video_codec"||d.name==="container"&&!d.tags.includes("extension")?d:"__default__"});const t=u.subtitles||[],n=u.info||[],r=u.videos||[],s=u.torrent||[],a=u.nzb||[],i=u.archives||[],o=u.images||[];i.length&&e.regex("\\."+I(i,void 0,!0)+"$",{exts:i,tags:["extension","archive"]}),e.regex("\\.r\\d{2}$",{tags:["extension","archive"]}),o.length&&e.regex("\\."+I(o,void 0,!0)+"$",{exts:o,tags:["extension","image"]}),t.length&&e.regex("\\."+I(t,void 0,!0)+"$",{exts:t,tags:["extension","subtitle"]}),n.length&&e.regex("\\."+I(n,void 0,!0)+"$",{exts:n,tags:["extension","info"]}),r.length&&e.regex("\\."+I(r,void 0,!0)+"$",{exts:r,tags:["extension","video"]}),s.length&&e.regex("\\."+I(s,void 0,!0)+"$",{exts:s,tags:["extension","torrent"]}),a.length&&e.regex("\\."+I(a,void 0,!0)+"$",{exts:a,tags:["extension","nzb"]}),e.defaults({clear:!0,name:"container",validator:R,formatter:l=>l.toLowerCase(),conflictSolver:(l,d)=>d.name==="source"||d.name==="video_codec"||d.name==="container"&&d.tags.includes("extension")?l:"__default__"});const c=t.filter(l=>!["sub","ass"].includes(l));return e.string(...c,{tags:["subtitle"]}),e.string(...r,{tags:["video"]}),e.string(...s,{tags:["torrent"]}),e.string(...a,{tags:["nzb"]}),e}function Ri(u){const e=u.rip_prefix??"(?P<other>Rip)-?",t=u.rip_suffix??"-?(?P<other>Rip)";function n(a,i="",o=""){return a.map(c=>`${i}(${c})${o}`)}function r(a,i){return["other","release_group"].includes(i.name??"")?i:"__default__"}const s=new $({disabled:a=>S(a,"source")});return s.regexDefaults({flags:"i",abbreviations:[K],privateParent:!0,children:!0}),s.defaults({name:"source",tags:["video-codec-prefix","streaming_service.suffix"],validateAll:!0,validator:{__parent__:Ha(ie,oe)}}),s.regex(...n(["VHS"],"",z(t)),{value:{source:"VHS",other:"Rip"}}),s.regex(...n(["CAM"],"",z(t)),{value:{source:"Camera",other:"Rip"}}),s.regex(...n(["HD-?CAM"],"",z(t)),{value:{source:"HD Camera",other:"Rip"}}),s.regex(...n(["HQ-?CAM"],"",z(t)),{value:{source:"Camera",other:"Rip"}}),s.regex(...n(["S-?Print"],"",z(t)),{value:{source:"Camera"}}),s.regex(...n(["TELESYNC","TS"],"",z(t)),{value:{source:"Telesync",other:"Rip"},tags:["video-codec-prefix"],overrides:["tags"]}),s.regex(...n(["HD-?TELESYNC","HD-?TS"],"",z(t)),{value:{source:"HD Telesync",other:"Rip"}}),s.regex(...n(["WORKPRINT","WP"]),{value:"Workprint"}),s.regex(...n(["TELECINE","TC"],"",z(t)),{value:{source:"Telecine",other:"Rip"}}),s.regex(...n(["HD-?TELECINE","HD-?TC"],"",z(t)),{value:{source:"HD Telecine",other:"Rip"}}),s.regex(...n(["PPV"],"",z(t)),{value:{source:"Pay-per-view",other:"Rip"}}),s.regex(...n(["SD-?TV"],"",z(t)),{value:{source:"TV",other:"Rip"}}),s.regex(...n(["TV"],"",t),{value:{source:"TV",other:"Rip"}}),s.regex(...n(["TV","SD-?TV"],e),{value:{source:"TV",other:"Rip"}}),s.regex(...n(["TV-?(?=Dub)"]),{value:"TV"}),s.regex(...n(["DVB","PD-?TV"],"",z(t)),{value:{source:"Digital TV",other:"Rip"}}),s.regex(...n(["DVD"],"",z(t)),{value:{source:"DVD",other:"Rip"}}),s.regex(...n(["DVD-?R[59]"],"",""),{value:{source:"DVD"}}),s.regex(...n(["LD"],"",t),{value:{source:"Laserdisc",other:"Rip"}}),s.regex(...n(["LASERDISC"],"",z(t)),{value:{source:"Laserdisc",other:"Rip"}}),s.regex(...n(["DM"],"",z(t)),{value:{source:"Digital Master",other:"Rip"}}),s.regex(...n(["VIDEO-?TS","DVD-?R(?:$|(?!E))","DVD-?9","DVD-?5"]),{value:"DVD"}),s.regex(...n(["HD-?TV"],"",z(t)),{conflictSolver:r,value:{source:"HDTV",other:"Rip"}}),s.regex(...n(["TV-?HD"],"",t),{conflictSolver:r,value:{source:"HDTV",other:"Rip"}}),s.regex(...n(["TV"],"","-?(?P<other>Rip-?HD)"),{conflictSolver:r,value:{source:"HDTV",other:"Rip"}}),s.regex(...n(["VOD"],"",z(t)),{value:{source:"Video on Demand",other:"Rip"}}),s.regex(...n(["WEB","WEB-?DL"],"",t),{value:{source:"Web",other:"Rip"}}),s.regex(...n(["WEB-?(?P<another>Cap)"],"",z(t)),{value:{source:"Web",other:"Rip",another:"Rip"}}),s.regex(...n(["WEB-?DL","WEB-?U?HD","DL-?WEB","DL(?=-?Mux)"]),{value:{source:"Web"}}),s.regex("(WEB)",{value:"Web",tags:"weak.source"}),s.regex(...n(["HD-?DVD"],"",z(t)),{value:{source:"HD-DVD",other:"Rip"}}),s.regex(...n(["Blu-?ray","BD","BD[59]","BD25","BD50"],"",z(t)),{value:{source:"Blu-ray",other:"Rip"}}),s.regex(...n(["(?P<another>BR)-?(?=Scr(?:eener)?)","(?P<another>BR)-?(?=Mux)"]),{value:{source:"Blu-ray",another:"Reencoded"}}),s.regex(...n(["(?P<another>BR)"],"",t),{value:{source:"Blu-ray",other:"Rip",another:"Reencoded"}}),s.regex(...n(["Ultra-?Blu-?ray","Blu-?ray-?Ultra"]),{value:"Ultra HD Blu-ray"}),s.regex(...n(["AHDTV"]),{value:"Analog HDTV"}),s.regex(...n(["UHD-?TV"],"",z(t)),{conflictSolver:r,value:{source:"Ultra HDTV",other:"Rip"}}),s.regex(...n(["UHD"],"",t),{conflictSolver:r,value:{source:"Ultra HDTV",other:"Rip"}}),s.regex(...n(["DSR","DTH"],"",z(t)),{value:{source:"Satellite",other:"Rip"}}),s.regex(...n(["DSR?","SAT"],"",t),{value:{source:"Satellite",other:"Rip"}}),s.rules(Qt,en,Li),s}const es=class es extends x{constructor(){super(...arguments),this.consequence=w}enabled(e){return!S(e,"source")}when(e,t){const n=[];for(const r of e.markers.named("path")?[e.markers.named("path")].flat():[]){const s=r,a=e.range(s.start,s.end,i=>i.name==="source");for(const i of Array.isArray(a)?a:a?[a]:[]){const o=i.initiator??i,c=ie(o),l=e.range(o.start-1,o.start,g=>g.tags?.includes("source-prefix"));if(!c&&!(Array.isArray(l)?l.length>0:l)){o.children?.length>0&&n.push(...o.children.toArray()),n.push(o);continue}const d=oe(o),p=e.range(o.end,o.end+1,g=>g.tags?.includes("source-suffix"));!d&&!(Array.isArray(p)?p.length>0:p)&&(o.children?.length>0&&n.push(...o.children.toArray()),n.push(o))}}return n}};es.priority=64;let Qt=es;const ts=class ts extends x{constructor(){super(...arguments),this.consequence=w}enabled(e){return!S(e,"source")}when(e,t){const n=[];for(const r of[e.markers.named("path")].flat().filter(Boolean)){const s=e.range(r.start,r.end,a=>a.name==="source");for(const a of Array.isArray(s)?s:s?[s]:[]){if(!a.tags?.includes("weak.source"))continue;const i=e.range(a.end,r.end,d=>d.name==="source"),o=Array.isArray(i)?i.length>0:!!i,c=e.holes(r.start,a.start,{predicate:d=>!!(d.value&&String(d.value).replace(new RegExp(`[${B}]`,"g"),""))}),l=Array.isArray(c)?c.length>0:!!c;o&&l&&(a.children?.length>0&&n.push(...a.children.toArray()),n.push(a))}}return n}};ts.priority=64;let en=ts;class Li extends x{constructor(){super(...arguments),this.consequence=[w,L]}enabled(e){return!S(e,"source")}when(e,t){const n=[],r=[];for(const s of[e.markers.named("path")].flat().filter(Boolean)){const a=e.range(s.start,s.end,i=>!i.private&&i.name==="source"&&i.value==="Blu-ray");for(const i of Array.isArray(a)?a:a?[a]:[]){const o=(d,p)=>e.range(d,p,g=>!g.private&&g.name==="other"&&g.value==="Ultra HD")?.[0];let c=o(s.start,i.start);if(c){const d=e.holes(c.end,i.start,{predicate:g=>!!(g.value&&String(g.value).replace(new RegExp(`[${B}]`,"g"),""))}),p=e.range(c.end,i.start,g=>!g.private&&!["screen_size","color_depth"].includes(g.name??"")&&!(g.name==="other"&&g.tags?.includes("uhdbluray-neighbor")));((Array.isArray(d)?d.length:d?1:0)>0||(Array.isArray(p)?p.length:p?1:0)>0)&&(c=void 0)}if(!c&&(c=o(i.end,s.end),c)){const d=e.holes(i.end,c.start,{predicate:g=>!!(g.value&&String(g.value).replace(new RegExp(`[${B}]`,"g"),""))}),p=e.range(i.end,c.start,g=>!g.private&&!["screen_size","color_depth"].includes(g.name??"")&&!(g.name==="other"&&g.tags?.includes("uhdbluray-neighbor")));((Array.isArray(d)?d.length:d?1:0)>0||(Array.isArray(p)?p.length:p?1:0)>0)&&(c=void 0)}if(!c){const d=e.range(s.start,s.end,p=>p.name==="screen_size"&&p.value==="2160p");if(!(Array.isArray(d)?d.length:d))continue}c&&(c.private=!0);const l=new P(i.start,i.end,{name:i.name,inputString:e.inputString,tags:[...i.tags??[]],private:i.private,value:"Ultra HD Blu-ray"});n.push(i),r.push(l)}}return n.length||r.length?[n,r]:!1}}function Fi(u){const e=new $;return e.regexDefaults({flags:"i",abbreviations:[K]}),e.stringDefaults({ignoreCase:!0}),e.defaults({name:"video_codec",tags:["source-suffix","streaming_service.suffix"],disabled:t=>S(t,"video_codec")}),e.regex("Rv\\d{2}",{value:"RealVideo"}),e.regex("Mpe?g-?2","[hx]-?262",{value:"MPEG-2"}),e.string("DVDivX","DivX",{value:"DivX"}),e.string("XviD",{value:"Xvid"}),e.regex("VC-?1",{value:"VC-1"}),e.string("VP7",{value:"VP7"}),e.string("VP8","VP80",{value:"VP8"}),e.string("VP9",{value:"VP9"}),e.regex("[hx]-?263",{value:"H.263"}),e.regex("[hx]-?264","(?:MPEG-?4)?AVC(?:HD)?",{value:"H.264"}),e.regex("[hx]-?265","HEVC",{value:"H.265"}),e.regex("(?<video_codec>hevc)(?<color_depth>10)",{value:{video_codec:"H.265",color_depth:"10-bit"},tags:["video-codec-suffix"],children:!0}),e.defaults({clear:!0,name:"video_profile",validator:R,disabled:t=>S(t,"video_profile")}),e.string("BP",{value:"Baseline",tags:"video_profile.rule"}),e.string("XP","EP",{value:"Extended",tags:"video_profile.rule"}),e.string("MP",{value:"Main",tags:"video_profile.rule"}),e.string("HP","HiP",{value:"High",tags:"video_profile.rule"}),e.string("SC","SVC",{value:"Scalable Video Coding",tags:"video_profile.rule"}),e.regex("AVC(?:HD)?",{value:"Advanced Video Codec High Definition",tags:"video_profile.rule"}),e.string("HEVC",{value:"High Efficiency Video Coding",tags:"video_profile.rule"}),e.regex("Hi422P",{value:"High 4:2:2"}),e.regex("Hi444PP",{value:"High 4:4:4 Predictive"}),e.regex("Hi10P?",{value:"High 10"}),e.string("DXVA",{value:"DXVA",name:"video_api",disabled:t=>S(t,"video_api")}),e.defaults({clear:!0,name:"color_depth",validator:R,disabled:t=>S(t,"color_depth")}),e.regex("12.?bits?",{value:"12-bit"}),e.regex("10.?bits?","YUV420P10","Hi10P?",{value:"10-bit"}),e.regex("8.?bits?",{value:"8-bit"}),e.rules(tn,nn),e}const Ye=class Ye extends x{enabled(e){return!S(e,"video_codec")}when(e,t){const n=[],r=e.named("video_codec"),s=i=>Array.isArray(i)?i.length>0:!!i,a=e.inputString??"";for(const i of r){const o=a[i.start]==="["||a[i.start-1]==="[",c=a[i.end-1]==="]"||a[i.end]==="]";if(!o&&!ie(i)&&!s(e.atIndex(i.start-1,l=>l.tags?.includes("video-codec-prefix")))){n.push(i);continue}if(!c&&!oe(i)&&!s(e.atIndex(i.end+1,l=>l.tags?.includes("video-codec-suffix")))){n.push(i);continue}}return n}};Ye.priority=64,Ye.consequence=w;let tn=Ye;const ns=class ns extends x{enabled(e){return!S(e,"video_profile")}when(e,t){const n=e.named("video_profile",s=>s.tags?.includes("video_profile.rule"))??[],r=[];for(const s of n){let a=e.atSpan(s.span,i=>i.name==="video_codec",0);a||(a=e.previous(s,i=>i.name==="video_codec",0)),a||(a=e.next(s,i=>i.name==="video_codec",0)),a||r.push(s)}return r}};ns.consequence=w;let nn=ns;const Ve="re:",ua="import:",da="eval:",pa=["regex","string"],Tt=new Map,He=new Map;function $i(u,e){He.set(u,e)}He.set("seps_after",oe);He.set("seps_before",ie);He.set("seps_surround",R);const Hi={"lambda match, other: other if other.name == 'audio_codec' else '__default__'":(u,e)=>e.name==="audio_codec"?e:"__default__","lambda match, other: match if other.name == 'audio_channels' and 'weak-audio_channels' not in other.tags else other":(u,e)=>e.name==="audio_channels"&&!(e.tags??[]).includes("weak-audio_channels")?u:e,"lambda match, conflicting: match if conflicting.name in ('video_codec', 'episode') and 'weak-episode' not in conflicting.tags else '__default__'":(u,e)=>["video_codec","episode"].includes(e.name)&&!(e.tags??[]).includes("weak-episode")?u:e.name==="episode"&&(e.tags??[]).includes("weak-episode")?e:"__default__","lambda match, other: other if other.name == 'episode_details' and other.value == 'Special' else '__default__'":(u,e)=>e.name==="episode_details"&&e.value==="Special"?e:"__default__"},Bi={"lambda match: 0 < match.value < 100":u=>typeof u.value=="number"&&u.value>0&&u.value<100};function Vi(u,e){if(u.startsWith(ua)){const t=u.slice(ua.length);if(Tt.has(t))return Tt.get(t);const n=He.get(t);return n!==void 0?(Tt.set(t,n),n):void 0}if(u.startsWith(da)){const t=u.slice(da.length).trim();return t==="int"?n=>parseInt(String(n),10):t==="float"?n=>parseFloat(String(n)):t==="bool"?n=>!!n:t}if(u.startsWith("lambda ")||u.startsWith("lambda:")){const t=Hi[u];if(t)return t;const n=Bi[u];return n||void 0}return u}const zi={conflict_solver:"conflictSolver",private_parent:"privateParent",private_children:"privateChildren",private_names:"privateNames",ignore_names:"ignoreNames",format_all:"formatAll",validate_all:"validateAll",pre_match_processor:"preMatchProcessor",post_match_processor:"postMatchProcessor",post_processor:"postProcessor",log_level:"logLevel",ignore_case:"ignoreCase"};function Ui(u){for(const[e,t]of Object.entries(zi))e in u&&!(t in u)&&(u[t]=u[e],delete u[e]);return u}function Va(u,e){if(u==="validator"||u==="conflict_solver"||u==="formatter"){if(e&&typeof e=="object"&&!Array.isArray(e)){const t={};for(const[n,r]of Object.entries(e))t[n]=Va(u,r);return t}if(e!=null&&typeof e=="string")return Vi(e)}return e}function Wi(u,e,t){const r={...e[Symbol.for("default")]||e.__default__||{}};if(t.startsWith("_")||(r.value=t),typeof u=="string"?u.startsWith(Ve)?r.regex=[u.slice(Ve.length)]:r.string=[u]:u&&typeof u=="object"&&Object.assign(r,u),"pattern"in r){const s=r.pattern;delete r.pattern,s.startsWith(Ve)?r.regex=[s.slice(Ve.length)]:r.string=[s]}return r}function qi(u,e,t,n={}){const s={...n[Symbol.for("default")]||n.__default__||{}},a=n[e];a&&Object.assign(s,a);const i={};for(const[o,c]of Object.entries(s))i[o]=Va(o,c);for(const o of Object.keys(i))i[o]===void 0&&delete i[o];Ui(i),e==="regex"?u.regex(...t,i):u.string(...t,i)}function te(u,e,t={}){if(e)for(const[n,r]of Object.entries(e)){const s=Array.isArray(r)?r:[r];for(const a of s){const i=Wi(a,t,n);for(const o of pa){let c=i[o];if(!c)continue;Array.isArray(c)||(c=[c]);const l={...i};for(const p of pa)delete l[p];const d={...t};d[Symbol.for("default")]=l,d.__default__=l,qi(u,o,c,d)}}}}function ji(u){const e=new $;e.regexDefaults({flags:"i",abbreviations:[K]}),e.stringDefaults({ignoreCase:!0}),e.defaults({name:"audio_codec",tags:["source-suffix","streaming_service.suffix"],disabled:n=>S(n,"audio_codec")}),te(e,u.audio_codec),e.defaults({clear:!0,name:"audio_profile",validator:R,disabled:n=>S(n,"audio_profile")}),te(e,u.audio_profile),e.defaults({clear:!0,name:"audio_channels",disabled:n=>S(n,"audio_channels")}),te(e,u.audio_channels);function t(n){const r=[],s=[{regex:/DTS-?ES/gi,codec:"DTS",profile:"Extended Surround"},{regex:/DTS-?MA/gi,codec:"DTS-HD",profile:"Master Audio"},{regex:/HE-?AAC/gi,codec:"AAC",profile:"High Efficiency"},{regex:/DD-?EX/gi,codec:"Dolby Digital",profile:"EX"}];for(const a of s){let i;for(;(i=a.regex.exec(n))!==null;)r.push([i.index,i.index+i[0].length,{value:a.codec,tags:["compound-audio"]}])}return r}return e.functional(t,{name:"audio_codec",disabled:n=>S(n,"audio_codec")}),e.rules(rn,Ki,Xi,Yi,Zi,sn,an,on),e}const Gi={DTS:"Extended Surround","DTS-HD":"Master Audio",AAC:"High Efficiency","Dolby Digital":"EX"},Ze=class Ze extends x{constructor(){super(...arguments),this.priority=128}enabled(e){return!S(e,"audio_profile")}when(e){const t=e.named("audio_codec");for(const n of t){if(n.tags?.includes("compound-audio")){const r=Gi[String(n.value)];if(r)return new P(n.start,n.end,{name:"audio_profile",value:r,inputString:n.inputString})}if(String(n.value)==="DTS-HD"){const r=(n.raw??n.inputString?.slice(n.start,n.end)??"").toUpperCase();if(/MA/.test(r))return new P(n.start,n.end,{name:"audio_profile",value:"Master Audio",inputString:n.inputString});const a=(n.inputString??"").slice(n.end,n.end+4).toUpperCase();if(/^[.\-_\s]?MA(?!\w*[b-ln-z])/i.test(a)){const i=n.end+(a.match(/^[.\-_\s]/)?1:0);return new P(i,i+2,{name:"audio_profile",value:"Master Audio",inputString:n.inputString})}}}}};Ze.priority=128,Ze.consequence=L;let rn=Ze;const rs=class rs extends x{enabled(e){return!S(e,"audio_profile")}when(e,t){const n=[],r=e.named("audio_profile"),s=a=>a&&(!Array.isArray(a)||a.length>0);for(const a of r){if(!a.tags.includes(this.codecName))continue;let i=e.atSpan(a.span,o=>o.name==="audio_codec"&&o.value===this.codecName);if(!s(i)){const o=e.previous(a,c=>!c.private,0);o&&o.name==="audio_codec"&&o.value===this.codecName&&(i=o)}if(!s(i)){const o=e.next(a,c=>!c.private,0);o&&o.name==="audio_codec"&&o.value===this.codecName&&(i=o)}s(i)||n.push(a)}return n.length>0?n:!1}};rs.consequence=w;let be=rs;class Ki extends be{constructor(){super(...arguments),this.codecName="DTS-HD"}}class Xi extends be{constructor(){super(...arguments),this.codecName="DTS"}}class Yi extends be{constructor(){super(...arguments),this.codecName="AAC"}}class Zi extends be{constructor(){super(...arguments),this.codecName="Dolby Digital"}}const ss=class ss extends x{enabled(e){return!S(e,"audio_profile")}when(e,t){const n=[],r=e.named("other"),s=e.named("audio_profile",a=>a.value==="High Quality")??[];for(const a of s)for(const i of r)i.span[0]===a.span[0]&&i.span[1]===a.span[1]&&n.push(i);return n}};ss.consequence=w;let sn=ss;const Je=class Je extends x{enabled(e){return!S(e,"audio_codec")&&!S(e,"audio_profile")}when(e,t){const n=[],r=["audio_codec","audio_profile","audio_channels"],s=r.flatMap(a=>[...e.named(a)]);for(const a of s){if(!ie(a)){const i=e.range(a.start-1,a.start,o=>r.includes(o.name??""));if(!(Array.isArray(i)?i.length:i)){n.push(a);continue}}if(!oe(a)){const i=e.range(a.end,a.end+1,o=>r.includes(o.name??""));if(!(Array.isArray(i)?i.length:i)){n.push(a);continue}}}return n}};Je.priority=64,Je.consequence=w;let an=Je;const Qe=class Qe extends x{enabled(e){return!S(e,"audio_channels")}when(e,t){const n=[],r=e.named("audio_channels",s=>s.tags.includes("weak-audio_channels"))??[];for(const s of r)e.previous(s,i=>i.name==="audio_codec")||n.push(s);return n}};Qe.priority=128,Qe.consequence=w;let on=Qe;const Ji=/^(?<magnitude>\d+(?:[.]\d+)?)(?<units>[^\d]+)?/;class le{constructor(e,t){this.magnitude=e,this.units=t}static parseUnits(e){throw new Error("parseUnits must be implemented by subclass")}static fromstring(e){const t=Ji.exec(e);if(!t?.groups)throw new Error(`Cannot parse quantity: ${e}`);const n=t.groups.magnitude,r=n.includes(".")?parseFloat(n):parseInt(n,10),s=t.groups.units??"",a=this.parseUnits(s);return new this(r,a)}toString(){return`${this.magnitude}${this.units}`}equals(e){return typeof e=="string"?this.toString()===e:e instanceof le?this.magnitude===e.magnitude&&this.units===e.units:!1}}class Rr extends le{static parseUnits(e){let t=e;for(const n of C)t=t.split(n).join("");return t.toUpperCase()}static fromstring(e){return le.fromstring.call(Rr,e)}}class Lr extends le{static parseUnits(e){let t=e;for(const n of C)t=t.split(n).join("");t=t.charAt(0).toUpperCase()+t.slice(1);for(const n of["bits","bit"])t=t.replace(n,"bps");return t}static fromstring(e){return le.fromstring.call(Lr,e)}}class Et extends le{static parseUnits(e){return"fps"}static fromstring(e){return le.fromstring.call(Et,e)}}function Qi(u){const e=new Set(u.interlaced),t=new Set(u.progressive),n=t,r=u.frame_rates,s=u.min_ar,a=u.max_ar,i=new $;i.stringDefaults({ignoreCase:!0}),i.regexDefaults({flags:"i"}),i.defaults({name:"screen_size",validator:R,abbreviations:[K],disabled:g=>S(g,"screen_size")});const o=I(r,"frame_rate"),c=I([...e],"height"),l=I([...t],"height"),d="(?:x|\\*|×)",p=`(?:(?<width>\\d{3,4})${d})?`;return i.regex(p+c+"(?<scan_type>i)"+o+"?"),i.regex(p+l+"(?<scan_type>p)"+o+"?"),i.regex(p+l+"(?<scan_type>p)?(?:hd)"),i.regex(p+l+"(?<scan_type>p)?x?"),i.string("4k",{value:"2160p",conflictSolver:(g,f)=>f.name==="screen_size"?"__default__":g}),i.regex(`(?<width>\\d{3,4})(?:${d}|-${d}-)(?<height>\\d{3,4})(?:up)?`,{conflictSolver:(g,f)=>f.name==="screen_size"?"__default__":f}),i.regex(o+"-?(?:p|fps)",{name:"frame_rate",formatter:g=>Et.fromstring(g).toString(),disabled:g=>S(g,"frame_rate")}),i.rules(new ln(n,s,a),cn,un),i}const as=class as extends x{constructor(e,t,n){super(),this.standardHeights=e,this.minAr=t,this.maxAr=n}when(e,t){const n=[];for(const r of e.named("screen_size")){if(!S(t,"frame_rate"))for(const l of r.children.named("frame_rate"))l.formatter=d=>Et.fromstring(d).toString(),n.push(l);let s=r.children.toDict();if(!("height"in s)){const l=String(r.raw??""),p=/^(\d{3,4})\s*[xX*×]\s*(\d{3,4})(?:up)?$/i.exec(l);if(p)s={width:p[1],height:p[2],scan_type:void 0};else{const f=/^(\d{3,4})([ip])?/i.exec(l);if(f&&f[1])s={height:f[1],scan_type:f[2]};else continue}}const a=(s.scan_type||"p").toLowerCase(),i=String(s.height??"");if(!("width"in s)||s.width===void 0){r.value=`${i}${a}`;continue}const o=String(s.width??""),c=parseFloat(o)/parseFloat(i);if(this.standardHeights.has(i)&&this.minAr<c&&c<this.maxAr?r.value=`${i}${a}`:r.value=`${o}x${i}`,!S(t,"aspect_ratio")&&o&&this.minAr<c&&c<this.maxAr){const l=new P(r.start,r.end,{name:"aspect_ratio",value:Math.round(c*1e3)/1e3,inputString:r.inputString});n.push(l)}}return n}};as.consequence=L;let ln=as;const is=class is extends x{when(e,t){const n=[];for(const r of e.markers.named("path")){const s=e.range(r.start,r.end,i=>i.name==="screen_size").reverse(),a=new Set(s.map(i=>i.value));s.length>1&&a.size>1&&n.push(...s.slice(1))}return n}};is.consequence=w;let cn=is;const os=class os extends x{when(e,t){const n=[];for(const r of e.markers.named("path")){const s=e.range(r.start,r.end,p=>p.name==="screen_size",0);if(!s)continue;const a=e.conflicting(s,p=>["season","episode"].includes(p.name??""))??[];if(a.length===0)continue;let i=!1;const o=e.range(r.start,r.end,p=>p.name==="screen_size")??[],c=p=>e.markers.atMatch(p,g=>g.name==="group",0),l=e.range(s.end,r.end,p=>p.name==="video_profile"||p.name==="video_codec",0);l&&e.holes(s.end,l.start,{predicate:p=>!!(p.value&&String(p.value).replace(new RegExp(`[${B}]`,"g"),""))}).length===0&&(l.name==="video_profile"||o.length===1&&c(s)===c(l))&&(n.push(...a),i=!0);const d=e.previous(s,p=>["date","source","other","streaming_service"].includes(p.name??""),0);d&&e.holes(d.end,s.start,{predicate:p=>!!(p.value&&String(p.value).replace(new RegExp(`[${B}]`,"g"),""))}).length===0&&(n.push(...a),i=!0),i||n.push(s)}return n}};os.consequence=w;let un=os;const eo=["aarp","abb","abbott","abbvie","abc","able","abogado","abudhabi","ac","academy","accenture","accountant","accountants","aco","actor","ad","ads","adult","ae","aeg","aero","aetna","af","afl","africa","ag","agakhan","agency","ai","aig","airbus","airforce","airtel","akdn","al","alibaba","alipay","allfinanz","allstate","ally","alsace","alstom","am","amazon","americanexpress","americanfamily","amex","amfam","amica","amsterdam","analytics","android","anquan","anz","ao","aol","apartments","app","apple","aq","aquarelle","ar","arab","aramco","archi","army","arpa","art","arte","as","asda","asia","associates","at","athleta","attorney","au","auction","audi","audible","audio","auspost","author","auto","autos","aw","aws","ax","axa","az","azure","ba","baby","baidu","banamex","band","bank","bar","barcelona","barclaycard","barclays","barefoot","bargains","baseball","basketball","bauhaus","bayern","bb","bbc","bbt","bbva","bcg","bcn","bd","be","beats","beauty","beer","berlin","best","bestbuy","bet","bf","bg","bh","bharti","bi","bible","bid","bike","bing","bingo","bio","biz","bj","black","blackfriday","blockbuster","blog","bloomberg","blue","bm","bms","bmw","bn","bnpparibas","bo","boats","boehringer","bofa","bom","bond","boo","book","booking","bosch","bostik","boston","bot","boutique","box","br","bradesco","bridgestone","broadway","broker","brother","brussels","bs","bt","build","builders","business","buy","buzz","bv","bw","by","bz","bzh","ca","cab","cafe","cal","call","calvinklein","cam","camera","camp","canon","capetown","capital","capitalone","car","caravan","cards","care","career","careers","cars","casa","case","cash","casino","cat","catering","catholic","cba","cbn","cbre","cc","cd","center","ceo","cern","cf","cfa","cfd","cg","ch","chanel","channel","charity","chase","chat","cheap","chintai","christmas","chrome","church","ci","cipriani","circle","cisco","citadel","citi","citic","city","ck","cl","claims","cleaning","click","clinic","clinique","clothing","cloud","club","clubmed","cm","cn","co","coach","codes","coffee","college","cologne","com","commbank","community","company","compare","computer","comsec","condos","construction","consulting","contact","contractors","cooking","cool","coop","corsica","country","coupon","coupons","courses","cpa","cr","credit","creditcard","creditunion","cricket","crown","crs","cruise","cruises","cu","cuisinella","cv","cw","cx","cy","cymru","cyou","cz","dad","dance","data","date","dating","datsun","day","dclk","dds","de","deal","dealer","deals","degree","delivery","dell","deloitte","delta","democrat","dental","dentist","desi","design","dev","dhl","diamonds","diet","digital","direct","directory","discount","discover","dish","diy","dj","dk","dm","dnp","do","docs","doctor","dog","domains","dot","download","drive","dtv","dubai","dupont","durban","dvag","dvr","dz","earth","eat","ec","eco","edeka","edu","education","ee","eg","email","emerck","energy","engineer","engineering","enterprises","epson","equipment","er","ericsson","erni","es","esq","estate","et","eu","eurovision","eus","events","exchange","expert","exposed","express","extraspace","fage","fail","fairwinds","faith","family","fan","fans","farm","farmers","fashion","fast","fedex","feedback","ferrari","ferrero","fi","fidelity","fido","film","final","finance","financial","fire","firestone","firmdale","fish","fishing","fit","fitness","fj","fk","flickr","flights","flir","florist","flowers","fly","fm","fo","foo","food","football","ford","forex","forsale","forum","foundation","fox","fr","free","fresenius","frl","frogans","frontier","ftr","fujitsu","fun","fund","furniture","futbol","fyi","ga","gal","gallery","gallo","gallup","game","games","gap","garden","gay","gb","gbiz","gd","gdn","ge","gea","gent","genting","george","gf","gg","ggee","gh","gi","gift","gifts","gives","giving","gl","glass","gle","global","globo","gm","gmail","gmbh","gmo","gmx","gn","godaddy","gold","goldpoint","golf","goodyear","goog","google","gop","got","gov","gp","gq","gr","grainger","graphics","gratis","green","gripe","grocery","group","gs","gt","gu","gucci","guge","guide","guitars","guru","gw","gy","hair","hamburg","hangout","haus","hbo","hdfc","hdfcbank","health","healthcare","help","helsinki","here","hermes","hiphop","hisamitsu","hitachi","hiv","hk","hkt","hm","hn","hockey","holdings","holiday","homedepot","homegoods","homes","homesense","honda","horse","hospital","host","hosting","hot","hotels","hotmail","house","how","hr","hsbc","ht","hu","hughes","hyatt","hyundai","ibm","icbc","ice","icu","id","ie","ieee","ifm","ikano","il","im","imamat","imdb","immo","immobilien","in","inc","industries","infiniti","info","ing","ink","institute","insurance","insure","int","international","intuit","investments","io","ipiranga","iq","ir","irish","is","ismaili","ist","istanbul","it","itau","itv","jaguar","java","jcb","je","jeep","jetzt","jewelry","jio","jll","jm","jmp","jnj","jo","jobs","joburg","jot","joy","jp","jpmorgan","jprs","juegos","juniper","kaufen","kddi","ke","kerryhotels","kerryproperties","kfh","kg","kh","ki","kia","kids","kim","kindle","kitchen","kiwi","km","kn","koeln","komatsu","kosher","kp","kpmg","kpn","kr","krd","kred","kuokgroup","kw","ky","kyoto","kz","la","lacaixa","lamborghini","lamer","land","landrover","lanxess","lasalle","lat","latino","latrobe","law","lawyer","lb","lc","lds","lease","leclerc","lefrak","legal","lego","lexus","lgbt","li","lidl","life","lifeinsurance","lifestyle","lighting","like","lilly","limited","limo","lincoln","link","live","living","lk","llc","llp","loan","loans","locker","locus","lol","london","lotte","lotto","love","lpl","lplfinancial","lr","ls","lt","ltd","ltda","lu","lundbeck","luxe","luxury","lv","ly","ma","madrid","maif","maison","makeup","man","management","mango","map","market","marketing","markets","marriott","marshalls","mattel","mba","mc","mckinsey","md","me","med","media","meet","melbourne","meme","memorial","men","menu","merck","merckmsd","mg","mh","miami","microsoft","mil","mini","mint","mit","mitsubishi","mk","ml","mlb","mls","mm","mma","mn","mo","mobi","mobile","moda","moe","moi","mom","monash","money","monster","mormon","mortgage","moscow","moto","motorcycles","mov","movie","mp","mq","mr","ms","msd","mt","mtn","mtr","mu","museum","music","mv","mw","mx","my","mz","na","nab","nagoya","name","navy","nba","nc","ne","nec","net","netbank","netflix","network","neustar","new","news","next","nextdirect","nexus","nf","nfl","ng","ngo","nhk","ni","nico","nike","nikon","ninja","nissan","nissay","nl","no","nokia","norton","now","nowruz","nowtv","np","nr","nra","nrw","ntt","nu","nyc","nz","obi","observer","office","okinawa","olayan","olayangroup","ollo","om","omega","one","ong","onl","online","ooo","open","oracle","orange","org","organic","origins","osaka","otsuka","ott","ovh","pa","page","panasonic","paris","pars","partners","parts","party","pay","pccw","pe","pet","pf","pfizer","pg","ph","pharmacy","phd","philips","phone","photo","photography","photos","physio","pics","pictet","pictures","pid","pin","ping","pink","pioneer","pizza","pk","pl","place","play","playstation","plumbing","plus","pm","pn","pnc","pohl","poker","politie","porn","post","pr","praxi","press","prime","pro","prod","productions","prof","progressive","promo","properties","property","protection","pru","prudential","ps","pt","pub","pw","pwc","py","qa","qpon","quebec","quest","racing","radio","re","read","realestate","realtor","realty","recipes","red","redumbrella","rehab","reise","reisen","reit","reliance","ren","rent","rentals","repair","report","republican","rest","restaurant","review","reviews","rexroth","rich","richardli","ricoh","ril","rio","rip","ro","rocks","rodeo","rogers","room","rs","rsvp","ru","rugby","ruhr","run","rw","rwe","ryukyu","sa","saarland","safe","safety","sakura","sale","salon","samsclub","samsung","sandvik","sandvikcoromant","sanofi","sap","sarl","sas","save","saxo","sb","sbi","sbs","sc","scb","schaeffler","schmidt","scholarships","school","schule","schwarz","science","scot","sd","se","search","seat","secure","security","seek","select","sener","services","seven","sew","sex","sexy","sfr","sg","sh","shangrila","sharp","shell","shia","shiksha","shoes","shop","shopping","shouji","show","si","silk","sina","singles","site","sj","sk","ski","skin","sky","skype","sl","sling","sm","smart","smile","sn","sncf","so","soccer","social","softbank","software","sohu","solar","solutions","song","sony","soy","spa","space","sport","spot","sr","srl","ss","st","stada","staples","star","statebank","statefarm","stc","stcgroup","stockholm","storage","store","stream","studio","study","style","su","sucks","supplies","supply","support","surf","surgery","suzuki","sv","swatch","swiss","sx","sy","sydney","systems","sz","tab","taipei","talk","taobao","target","tatamotors","tatar","tattoo","tax","taxi","tc","tci","td","tdk","team","tech","technology","tel","temasek","tennis","teva","tf","tg","th","thd","theater","theatre","tiaa","tickets","tienda","tips","tires","tirol","tj","tjmaxx","tjx","tk","tkmaxx","tl","tm","tmall","tn","to","today","tokyo","tools","top","toray","toshiba","total","tours","town","toyota","toys","tr","trade","trading","training","travel","travelers","travelersinsurance","trust","trv","tt","tube","tui","tunes","tushu","tv","tvs","tw","tz","ua","ubank","ubs","ug","uk","unicom","university","uno","uol","ups","us","uy","uz","va","vacations","vana","vanguard","vc","ve","vegas","ventures","verisign","versicherung","vet","vg","vi","viajes","video","vig","viking","villas","vin","vip","virgin","visa","vision","viva","vivo","vlaanderen","vn","vodka","volvo","vote","voting","voto","voyage","vu","wales","walmart","walter","wang","wanggou","watch","watches","weather","weatherchannel","webcam","weber","website","wed","wedding","weibo","weir","wf","whoswho","wien","wiki","williamhill","win","windows","wine","winners","wme","woodside","work","works","world","wow","ws","wtc","wtf","xbox","xerox","xihuan","xin","xxx","xyz","yachts","yahoo","yamaxun","yandex","ye","yodobashi","yoga","yokohama","you","youtube","yt","yun","za","zappos","zara","zero","zip","zm","zone","zuerich","zw"];function to(u){const e=new $({disabled:o=>S(o,"website")});e.regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}),e.defaults({name:"website"});const t=u.tlds||eo,n=u.safe_tlds||["com","org","net"],r=u.safe_subdomains||["www"],s=u.safe_prefixes||[],a=u.prefixes||[];e.regex(`(?:[^a-z0-9]|^)((?:${I(r)}\\.)+(?:[a-z-0-9-]+\\.)+(?:${I(t)}))(?:[^a-z0-9]|$)`,{children:!0}),e.regex(`(?:[^a-z0-9]|^)((?:${I(r)}\\.)*[a-z0-9-]+\\.(?:${I(n)}))(?:[^a-z0-9]|$)`,{children:!0}),e.regex(`(?:[^a-z0-9]|^)((?:${I(r)}\\.)*[a-z0-9-]+\\.(?:${I(s)}\\.)+(?:${I(t)}))(?:[^a-z0-9]|$)`,{children:!0}),e.string(...a,{validator:R,private:!0,tags:["website.prefix"]});class i extends x{constructor(c,l){super(),this.consequence=w,this.safeSubdomains=c,this.safePrefix=l}validFollowers(c){return["season","episode","year"].includes(c.name??"")}when(c){const l=[];for(const d of c.named("website")){let p=!1;for(const g of[...this.safeSubdomains,...this.safePrefix])if(String(d.value??"").toLowerCase().startsWith(g)){p=!0;break}if(!p){const f=c.markers.atMatch(d,D=>D.name==="path",0)?.end??c.inputString?.length??d.end+50,v=c.range(d.end,f,D=>!D.private&&this.validFollowers(D)),h=Array.isArray(v)?v:v?[v]:[];(h.length>0?h[0]:void 0)&&(c.markers.atMatch(d,b=>b.name==="group",0)||l.push(d))}}return l}}return e.rules(new i(r,s),dn),e}const et=class et extends x{when(e){const t=[];for(const n of e.tagged("website.prefix")){const r=e.range(n.end,n.end+100,i=>!i.private&&i.name==="website"),s=Array.isArray(r)?r:r?[r]:[],a=s.length>0?s[0]:void 0;(!a||e.holes(n.end,a.start,H,C,i=>i.value))&&t.push(n)}return t}};et.priority=64,et.consequence=w;let dn=et;const G="[-/ .]",fa="[-/ .x]",no=[new RegExp(`${G}((\\d{8}))${G}`,"i"),new RegExp(`${G}((\\d{6}))${G}`,"i"),new RegExp(`(?:^|[^\\d])((\\d{2})${G}(\\d{1,2})${G}(\\d{1,2}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{1,2})${G}(\\d{1,2})${G}(\\d{2}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{4})${fa}(\\d{1,2})${G}(\\d{1,2}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{1,2})${G}(\\d{1,2})${fa}(\\d{4}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{1,2}(?:st|nd|rd|th)?${G}(?:[a-z]{3,10})${G}\\d{4}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^a-z\\d])(([a-z]{3,10})${G}\\d{1,2}(?:st|nd|rd|th)?${G}\\d{4})(?:$|[^\\d])`,"i")],ga={jan:1,january:1,feb:2,february:2,mar:3,march:3,apr:4,april:4,may:5,jun:6,june:6,jul:7,july:7,aug:8,august:8,sep:9,sept:9,september:9,oct:10,october:10,nov:11,november:11,dec:12,december:12};function ee(u){return u>=1900&&u<2035}function ro(u){return u>=1&&u<53}function ze(u){return!isNaN(parseInt(u,10))&&String(parseInt(u,10))===u.replace(/^0+/,"")||u==="0"}function so(u){const e=u[0],t=u[u.length-1];if(ze(e)&&ee(parseInt(e.slice(0,4),10)))return!1;if(ze(t)&&ee(parseInt(t.slice(-4),10)))return!0;if(ze(e)&&parseInt(e.slice(0,2),10)>31)return!1;if(ze(t)&&parseInt(t.slice(-2),10)>31)return!0}function ao(u,e,t,n){const s=u.replace(/[-/ .x]/g,"-").split("-").filter(Boolean),a=t!==void 0?[t]:[!1,!0],i=n!==void 0?[n]:[!0,!1];for(const o of a)for(const c of i){let l,d,p;const g=s.findIndex(f=>ga[f.toLowerCase()]!==void 0);if(s.length===3&&g>=0){d=ga[s[g].toLowerCase()];const f=s.filter((h,m)=>m!==g).map(h=>parseInt(h.replace(/(st|nd|rd|th)$/i,""),10)),v=f.findIndex(h=>h>=1e3);if(v>=0?(l=f[v],p=f[1-v]):(l=f[1],p=f[0]),d>=1&&d<=12&&p>=1&&p<=31&&ee(l)){const h=Date.UTC(l,d-1,p),m=new Date(h);if(m.getUTCFullYear()===l&&m.getUTCMonth()===d-1&&m.getUTCDate()===p)return m}continue}if(s.length===1){const f=s[0];if(f.length===8)l=parseInt(f.slice(0,4),10),d=parseInt(f.slice(4,6),10),p=parseInt(f.slice(6,8),10);else if(f.length===6){const v=parseInt(f.slice(0,2),10);l=v>50?1900+v:2e3+v,d=parseInt(f.slice(2,4),10),p=parseInt(f.slice(4,6),10)}else continue}else if(s.length===3){const f=s.map(Number);if(o)[l,d,p]=c?[f[0],f[2],f[1]]:[f[0],f[1],f[2]],!ee(l)&&l<100&&(l=l>50?1900+l:2e3+l);else{const v=f.findIndex((h,m)=>s[m].length===4&&ee(h));v===0?[l,d,p]=c?[f[0],f[2],f[1]]:[f[0],f[1],f[2]]:v===2?[l,d,p]=c?[f[2],f[1],f[0]]:[f[2],f[0],f[1]]:(c?[p,d,l]=o?[f[2],f[1],f[0]]:[f[0],f[1],f[2]]:[d,p,l]=o?[f[2],f[0],f[1]]:[f[0],f[1],f[2]],l=l>100?l:l>50?1900+l:2e3+l)}}else continue;if(!(d<1||d>12)&&!(p<1||p>31)&&ee(l))try{const f=Date.UTC(l,d-1,p),v=new Date(f);if(v.getUTCFullYear()===l&&v.getUTCMonth()===d-1&&v.getUTCDate()===p)return v}catch{}}}function io(u,e,t){for(const n of no){const r=new RegExp(n.source,n.flags.includes("g")?n.flags:n.flags+"g");let s;for(r.lastIndex=0;(s=r.exec(u))!==null;){if(!s[1])continue;const a=s.index+s[0].indexOf(s[1]),i=a+s[1].length,o=s.slice(2).filter(Boolean),c=s[1];let l=t;e&&l===void 0&&(l=!1);const d=l!==void 0;!d&&o.length>0&&(l=so(o));const p=l!==void 0?d?[l]:[l,!l]:[void 0];let g;for(const f of p)if(g=ao(c,o,e,f),g&&ee(g.getUTCFullYear()))break;if(g&&ee(g.getUTCFullYear()))return[a,i,g]}}}const ls=class ls extends x{constructor(){super(...arguments),this.consequence=w}enabled(e){return!S(e,"year")}when(e,t){const n=[],r=e.named("year");if((Array.isArray(r)?r:r?[r]:[]).length<=1)return n;const a=e.markers.named("path"),i=Array.isArray(a)?a:a?[a]:[];for(const o of i){const c=e.range(o.start,o.end,g=>g.name==="year"),l=Array.isArray(c)?c:c?[c]:[];if(l.length<=1)continue;const d=[],p=[];for(const g of l)e.markers.atMatch(g,v=>v.name==="group",0)?d.push(g):p.push(g);if(d.length>0&&p.length>0){const g=d[0].start;n.push(...p.filter(f=>f.start<g)),n.push(...d.slice(1))}else d.length===0&&(n.push(p[0]),p.length>2&&n.push(...p.slice(2)))}return n}};ls.priority=64;let pn=ls;const cs=class cs extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=[];if(!e.named("episode").some(s=>s.tags?.includes("SxxExx")))return n;for(const s of e.named("year")){const a=e.markers.atMatch(s,c=>c.name==="group",0);if(!a)continue;const i=a.end-a.start,o=s.end-s.start;i-o>4&&n.push(s)}return n}};cs.priority=64;let fn=cs;function oo(u){const e=new $().defaults({validator:R});e.regex("\\d{4}",{name:"year",formatter:r=>parseInt(r,10),disabled:r=>S(r,"year"),conflictSolver:(r,s)=>(s.name==="episode"||s.name==="season")&&s.raw&&r.raw&&s.raw.length<r.raw.length?s:"__default__",validator:r=>R(r)&&ee(r.value)});const t=u.week_words;if(t&&t.length>0){const r=I(t)+"-?(\\d{1,2})";e.regex(r,{name:"week",formatter:s=>parseInt(s.replace(/\D/g,""),10),children:!0,flags:"i",abbreviations:[K],conflictSolver:(s,a)=>(a.name==="episode"||a.name==="season")&&a.raw&&s.raw&&a.raw.length<s.raw.length?a:"__default__",validator:s=>R(s)&&ro(s.value)})}const n=(r,s)=>{const a=io(r,s?.date_year_first,s?.date_day_first);return a?[[a[0],a[1],{value:a[2]}]]:[]};return e.functional(n,{name:"date",properties:{date:[null]},disabled:r=>S(r,"date"),conflictSolver:(r,s)=>s.name==="episode"||s.name==="season"||s.name==="crc32"?s:"__default__"}),e.rules(pn,fn,new lo(u.weekday_words??[])),e}class lo extends x{constructor(e){super(),this.consequence=w;const t="["+C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"]";this.weekdayRe=new RegExp("(?:^|"+t+")("+I(e.length?e:["\\bnever\\b"])+")"+t+"*$","i")}enabled(e){return!S(e,"date")}when(e,t){const n=e.inputString??"",r=[];for(const s of e.named("date")??[]){const a=e.markers.atMatch(s,p=>p.name==="path",0),i=a?a.start:0,o=n.slice(i,s.start),c=this.weekdayRe.exec(o);if(!c)continue;const l=i+c.index+c[0].indexOf(c[1]),d=e.range(l,s.start,p=>!p.private);(Array.isArray(d)?d.length:d?1:0)>0||r.push([s,l])}return r.length?r:!1}then(e,t,n){for(const[r,s]of t)e.remove(r),r.start=s,e.append(r)}}function co(u){return!u.private&&u.name!=="proper_count"&&u.name!=="title"&&!(u.name==="container"&&u.tags?.includes("extension"))&&!(u.name==="other"&&u.value==="Rip")}function ha(u,e,t){const n=u.range(e.start,e.end,t),r=Array.isArray(n)?n:n?[n]:[];return new Set(r.map(a=>a.name)).size}function we(u,e,t=co){const n=[...u],r=new Map(n.map((s,a)=>[s,a]));return n.sort((s,a)=>{const i=ha(e,a,t)-ha(e,s,t);return i!==0?i:(r.get(a)??0)-(r.get(s)??0)})}function za(u){return function(t,n){let r=n?.[u];if(!r||Array.isArray(r)&&r.length===0)return[];typeof r=="string"&&(r=[r]);const s="[\\s._-]",a=[];for(const i of r){let o;if(i.startsWith("re:")){const l=i.slice(3);try{o=new RegExp(l,"gi")}catch{continue}}else{const l=i.split(/[\s._-]+/).map(p=>p.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"));if(l.length===0)continue;const d="(?<![a-zA-Z0-9])"+l.join(`${s}?`)+"(?![a-zA-Z0-9])";try{o=new RegExp(d,"gi")}catch{const p=i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");try{o=new RegExp(p,"gi")}catch{continue}}}let c;for(;(c=o.exec(t))!==null&&(a.push([c.index,c.index+c[0].length,{}]),c[0].length!==0););}return a}}const gn=new Set(["the","a","an","and","or","of","to","in","on","at","for","from","by","with","into","onto","no","le","la","les","de","du","des","el"]);function uo(u){return u==null?!1:Array.isArray(u)?u.length>0:!0}const tt=class tt extends x{constructor(e,t,n){super(),this.consequence=[L,w],this.matchName=e,this.propertyName=t[0]??"title",this.alternativePropertyName=n}holeFilter(e){return!0}filepartFilter(e){return!0}holesProcess(e,t,n){const r=t.markers.named("group"),i=(Array.isArray(r)?r:r?[r]:[]).filter(c=>c.start>=n.start&&c.end<=n.end).filter(c=>!(c.start===n.start&&c.end===n.end)),o=[];for(const c of e){const l=c.crop(i);l&&(Array.isArray(l)?o.push(...l):o.push(l))}return o}isIgnored(e){if(!(e.name==="language"||e.name==="country"||e.name==="episode_details"))return!1;const t=e.raw??"";return!(e.end-e.start>3&&t!==""&&t===t.toUpperCase()&&t!==t.toLowerCase())}shouldKeep(e,t,n){return n?t[0].end<e.end||t.length>1:t[t.length-1].start>e.start&&t.length>1}languageDuplicatedAfterHole(e,t,n){if(e.name!=="language"&&e.name!=="country")return!1;const r=n.markers.atMatch(e,i=>i.name==="path");if(!r)return!1;const s=String(e.value??"").toLowerCase(),a=n.range(t,r.end,i=>i.name===e.name&&String(i.value??"").toLowerCase()===s);return Array.isArray(a)?a.length>0:!!a}shouldRemove(e){return!1}splitTitleAlternative(e,t){const n=t.slice(e.start,e.end),r=[];for(let c=0;c<n.length;c++){const l=n[c];if(!Ft.includes(l))continue;const d=c===0||C.includes(n[c-1]),p=c===n.length-1||C.includes(n[c+1]);(d&&p||l==="/")&&r.push(c)}if(r.length===0)return null;const s=(c,l)=>{let d=c,p=l;for(;d<p&&C.includes(t[d]);)d++;for(;p>d&&C.includes(t[p-1]);)p--;if(d>=p)return null;const g=t.slice(d,p),f=e.formatter?e.formatter(g):g;return new P(d,p,{inputString:t,formatter:e.formatter,value:f})},a=[];let i=e.start;for(const c of r){const l=e.start+c,d=s(i,l);d&&a.push(d),i=l+1}const o=s(i,e.end);return o&&a.push(o),a.length<2||/^\d+$/.test(String(a[0].value??"").trim())?null:{title:a[0],alternatives:a.slice(1)}}checkTitlesInFilepart(e,t,n){const r=[],s=[],a=t.range(e.start,e.end,f=>f.name==="year",0),i=!!a,o=!!t.range(e.start,e.end,f=>f.name==="date",0),c=!!t.range(e.start,e.end,f=>f.tags?.includes("SxxExx")&&!f.private,0),l=t.holes(e.start,e.end,{formatter:Le(H,qe),ignore:f=>{if(this.isIgnored(f)||f.private&&f.tags?.includes("weak-episode"))return!0;if(f.tags?.includes("weak-episode")||f.tags?.includes("weak-duplicate")){const v=f.initiator;if((f.start===e.start||v.start===e.start)&&(i||o||c)||i&&f.start>=e.start&&f.start<e.start+4&&f.end<=e.start+4||a&&f.end<=a.start)return!0;if(f.tags?.includes("weak-duplicate")){const m=f.initiator||f;if((t.range(m.end,e.end,A=>A.tags?.includes("weak-duplicate")&&!A.private)||[]).some(A=>(A.initiator||A)!==m))return!0}}return!1},predicate:f=>!!f.value}),d=Array.isArray(l)?l:l?[l]:[];let p=this.holesProcess(d,t,e);for(const f of p){if(!this.holeFilter(f))continue;if(process.env.DEBUG_TITLE_TRIM){const b=t.inputString??"";console.log(`[trim] hole="${b.slice(f.start,f.end)}" [${f.start},${f.end})`)}const v=t.range(f.start,f.end,b=>this.isIgnored(b)),h=Array.isArray(v)?v:v?[v]:[];if(h.length>0&&h.every(b=>b.name==="language"||b.name==="country")){let A=(t.inputString??"").slice(f.start,f.end);for(const E of h){const M=E.start-f.start;A=A.slice(0,M)+" ".repeat(E.end-E.start)+A.slice(E.end-f.start)}if(![...A].some(E=>!C.includes(E)&&E!==" "))continue}let m=f;const D=t.inputString??"";for(;m.start<m.end&&C.includes(D[m.start]);)m.start++;for(;m.end>m.start&&C.includes(D[m.end-1]);){const b=m.end-1;if(D[b]==="."&&b>=2&&/[a-zA-Z0-9]/.test(D[b-1])&&D[b-2]===".")break;m.end--}if(process.env.DEBUG_TITLE_TRIM){const b=h.map(A=>`${A.name}="${D.slice(A.start,A.end)}"@[${A.start},${A.end})`).join(", ");console.log(` after pre-strip hole=[${m.start},${m.end}) ignoredArray=[${b}]`)}for(;h.length>0;){const b=h[0];if(b.start===m.start){const A=b.name==="country"?!1:this.shouldKeep(m,h,!0);if(process.env.DEBUG_TITLE_TRIM&&console.log(` leading trim: shouldKeep=${A} for "${D.slice(b.start,b.end)}"`),A){let k=!1;for(let E=b.end;E<m.end;E++){const M=D[E];if(Ft.includes(M)){k=!0;break}if(!C.includes(M))break}if(!k)break}for(m.start=b.end;m.start<m.end&&C.includes(D[m.start]);)m.start++;h.shift()}else break}for(;h.length>0;){const b=h[h.length-1];if(b.end===m.end){if(b.name==="language"||b.name==="country"){const A=D.slice(m.start,b.start).toLowerCase().split(/[^a-z0-9]+/i).filter(Boolean),k=A[A.length-1];if(k&&gn.has(k)){s.push(b),h.pop();break}}if(b.name==="episode_details"&&b.value==="Special"){const A=t.range(b.end,b.end+10,k=>k.name==="year"&&!k.private,0);if(A&&[...D.slice(b.end,A.start)].every(E=>C.includes(E)))break}if(this.languageDuplicatedAfterHole(b,m.end,t)){s.push(b),h.pop();break}if(this.shouldKeep(m,h,!1)){let A=!0,k=m.end;for(let E=h.length-1;E>=0;E--){const M=h[E];if(![...D.slice(M.end,k)].every(O=>C.includes(O))){A=!1;break}k=M.start}if(!A)break}for(m.end=b.start;m.end>m.start&&C.includes(D[m.end-1]);)m.end--;h.pop()}else break}if(process.env.DEBUG_TITLE_TRIM&&console.log(` result: hole=[${m.start},${m.end}) length=${m.length} value="${m.value}"`),m.length>0&&!this.shouldRemove(m)&&m.value){t.inputString;const b=t.markers.range(e.start,e.end,k=>k.name==="group"&&k.start===e.start,0)!==void 0||t.range(e.start,e.end,k=>k.name==="crc32",0)!==void 0;let A=this.alternativePropertyName&&!S(n,this.alternativePropertyName)?this.splitTitleAlternative(m,D):null;if(A&&b&&A.alternatives.every(k=>{const E=String(k.value??"").trim();return E.length>=4||/\s/.test(E)})&&(A=null),A){A.title.name=this.matchName,r.push(A.title);for(const k of A.alternatives)k.name=this.alternativePropertyName,r.push(k)}else m.name=this.matchName,r.push(m)}}const g=r.find(f=>f.name===this.matchName);if(g){const f=t.range(g.start,g.end,h=>h.name==="episode_details"||h.name==="country"||h.name==="language"),v=Array.isArray(f)?f:f?[f]:[];for(const h of v)s.includes(h)||s.push(h)}return{toAppend:r,toRemove:s}}_serieNameFilepart(e,t){for(let n=0;n<t.length-1;n++){if(n===0)continue;const r=t[n],s=e.range(r.start,r.end).filter(a=>!a.private);if(process.env.DEBUG_TITLE){const a=e.inputString??"";if(console.log(`[_serieNameFilepart] index=${n} fp="${a.slice(r.start,r.end)}" fpMatches=${s.map(i=>`${i.name}="${i.value}"@[${i.start},${i.end})`).join(",")}`),s[0]){const i=s[0].parent;console.log(` season span=[${s[0].start},${s[0].end}), filepart=[${r.start},${r.end}), parent span=${i?`[${i.start},${i.end})`:"null"}`)}}if(s.length===1&&s[0].name==="season"&&(s[0].start===r.start&&s[0].end===r.end||s[0].parent&&s[0].parent.start===r.start&&s[0].parent.end===r.end))return t[n+1]??null}return null}_serieNameFilepartMatch(e,t,n,r){const s=e.range(t.start,t.end,p=>p.name==="title",0);if(s){if(process.env.DEBUG_TITLE){const p=e.inputString??"";console.log(`[_serieNameFilepartMatch] fp="${p.slice(t.start,t.end)}" found existing title="${s.value}"`)}return s}const a=p=>p.tags?p.tags.some(g=>g==="weak"||g.startsWith("weak-")):!1,i=this.isIgnored.bind(this),o=p=>i(p)||a(p),c=e.holes(t.start,t.end,{formatter:Le(H,qe),ignore:o,predicate:p=>!!p.value}),l=Array.isArray(c)?c:c?[c]:[],d=this.holesProcess(l,e,t);if(process.env.DEBUG_TITLE){const p=e.inputString??"";console.log(`[_serieNameFilepartMatch] fp="${p.slice(t.start,t.end)}" holeArray=${l.length} processedHoles=${d.length}`),d.forEach((g,f)=>console.log(` hole[${f}]="${p.slice(g.start,g.end)}" value="${g.value}"`))}if(d.length===1&&d[0].value){const p=d[0];return p.name=this.matchName,n.push(p),p}return null}when(e,t){if((e.tagged("expected")?.filter(p=>p.name==="title")??[]).length>0)return null;const r=[],s=[],a=e.markers.named("path"),i=Array.isArray(a)?a:a?[a]:[],o=we(i,e),c=this._serieNameFilepart(e,o);let l=null;if(c&&(l=this._serieNameFilepartMatch(e,c,r,s)),process.env.DEBUG_TITLE){const p=e.inputString??"";console.log(`[when] sortedFileparts: ${o.map(g=>`"${p.slice(g.start,g.end)}"`).join(", ")}`),console.log(`[when] serieNameFilepart: ${c?`"${p.slice(c.start,c.end)}"`:"null"}`),console.log(`[when] serieNameMatch: ${l?`"${l.value}"`:"null"}`)}const d=new Set(o.filter(p=>uo(e.range(p.start,p.end,g=>g.name==="year",0))));for(const p of o){if(d.delete(p),!this.filepartFilter(p))continue;const g=this.checkTitlesInFilepart(p,e,t);if(g.toAppend.length>0||g.toRemove.length>0){if(l){const f=v=>sa(v).replace(/[''`]/g,"").replace(/\.+$/,"").toLowerCase().trim();for(const v of g.toAppend)f(String(v.value))!==f(String(l.value))&&(v.name="episode_title")}r.push(...g.toAppend),s.push(...g.toRemove);break}}for(const p of d){if(!this.filepartFilter(p))continue;const g=this.checkTitlesInFilepart(p,e,t),f=[];for(const v of g.toAppend){if(v.name!==this.matchName){f.push(v);continue}const h=String(v.value??""),m=A=>sa(A).replace(/[''`]/g,"").toLowerCase(),D=r.findIndex(A=>{const k=String(A.value??"");return m(k)===m(h)&&k!==h});if(D!==-1){const A=r[D];if(A.name===this.matchName)A.value=h;else if(A.name===this.alternativePropertyName){A.value=h;const k=r.find(E=>E.name===this.matchName);k&&(k.name=this.alternativePropertyName||"alternative_title",A.name=this.matchName)}continue}r.some(A=>{if(A.name!==this.matchName)return!1;const k=m(String(A.value??"")),E=m(h);return E.startsWith(k+" ")||E.endsWith(" "+k)})||f.push(v)}r.push(...f),s.push(...g.toRemove)}return r.length===0&&s.length===0?null:{toAppend:r,toRemove:s}}then(e,t,n){if(!t||typeof t!="object")return;const r=t;new w().then(e,r.toRemove,n),new L().then(e,r.toAppend,n)}};tt.priority=0,tt.properties={};let hn=tt;const Ce=class Ce extends hn{constructor(){super("title",["title"],"alternative_title")}};Ce.priority=0,Ce.dependency=["DashSeparatedReleaseGroup","SubtitlePrefixLanguageRule","SubtitleSuffixLanguageRule","SubtitleExtensionRule"],Ce.properties={title:[null],alternative_title:[null]};let je=Ce;const nt=class nt extends x{constructor(){super(...arguments),this.consequence=[w,na]}when(e,t){const n=[],r=e.named("title"),s=Array.isArray(r)?r:r?[r]:[];e.named("year");for(const a of s){if(a.tags?.includes("expected"))continue;const i=e.markers.atMatch(a,l=>l.name==="path",0);if(!i)continue;const o=e.range(i.start,i.end,l=>l.name==="year");(Array.isArray(o)?o:o?[o]:[]).length===0&&n.push(a)}return n}then(e,t,n){if(!t||!Array.isArray(t))return;new w().then(e,t,n),new na(["equivalent-ignore"]).then(e,t,n)}};nt.priority=32,nt.dependency=[je];let mn=nt;const po=new Set(["the","a","an","le","la","les","l'","el","los","las","il","lo","un","una","der","die","das","de","het","o","os"]),us=class us extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.inputString||"",r=[],s=e.named("title"),a=e.named("episode_title"),i=[...Array.isArray(s)?s:s?[s]:[],...Array.isArray(a)?a:a?[a]:[]];for(const o of i){if(!po.has(String(o.value??"").trim().toLowerCase()))continue;const c=e.markers.atMatch(o,p=>p.name==="path",0);if(!c)continue;const l=e.range(o.end,c.end,p=>!p.private&&["edition","language","country","other","source"].includes(p.name??""),0);if(!l||![...n.slice(o.end,l.start)].every(p=>C.includes(p)))continue;const d=e.range(l.end,c.end,p=>!p.private&&["year","season","episode","date"].includes(p.name??""),0);d&&n.slice(l.end,d.start).replace(/[sexd]/gi,"").split("").some(p=>!C.includes(p))||r.push({title:o,prop:l})}return r.length?r:!1}then(e,t,n){for(const{title:r,prop:s}of t){const a=e.inputString||"";e.remove(r),e.remove(s),r.end=s.end,r.value=H(a.slice(r.start,r.end)),e.append(r)}}};us.priority=-32;let vn=us;const ds=class ds extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.inputString||"",r=[],s=e.range(0,n.length,i=>!i.private&&["country","other","edition"].includes(i.name??"")),a=Array.isArray(s)?s:s?[s]:[];for(const i of a){if(!/^[A-Z][a-z]+$/.test(i.raw??""))continue;const o=e.markers.atMatch(i,l=>l.name==="path",0);if(!o||![...n.slice(o.start,i.start)].every(l=>C.includes(l))||["release-group-prefix","streaming_service.prefix","streaming_service.suffix"].some(l=>i.tags?.includes(l))||e.markers.atMatch(i,l=>l.name==="group",0))continue;const c=e.range(i.end,o.end,l=>!l.private&&["year","season","episode","date"].includes(l.name??""),0);c&&(![...n.slice(i.end,c.start)].every(l=>C.includes(l))&&e.range(i.end,c.start,l=>!l.private&&l.value!=null,0)||r.push(i))}return r.length?r:!1}};ds.priority=64;let xn=ds;const ps=class ps extends x{constructor(){super(...arguments),this.priority=64,this.consequence=w}when(e,t){const n=[],r=e.tagged("title-word")??[];for(const s of Array.isArray(r)?r:[r]){if(!s||s.private)continue;const a=e.markers.atMatch(s,o=>o.name==="path",0);if(!a)continue;const i=e.range(a.start,a.end,o=>!o.private&&["year","season","episode","date"].includes(o.name??""),0);!i||s.start>=i.start||n.push(s)}return n.length?n:!1}};ps.priority=64;let _n=ps;const fo=/[\u0370-\u03FF\u0400-\u04FF\u0590-\u05FF\u0600-\u06FF\u0E00-\u0E7F\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF]/,fs=class fs extends x{constructor(){super(...arguments),this.priority=N,this.consequence=[w,L]}when(e,t){if(S(t,"alternative_title"))return!1;const n=e.inputString??"",r=[],s=[];for(const a of e.named("title")){if(a.tags?.includes("expected"))continue;const i=n.slice(a.start,a.end),o=new RegExp("(?:^|["+B+"])([A-Za-z])").exec(i);if(!o)continue;const c=o.index+o[0].indexOf(o[1]),l=i.slice(0,c);if(!fo.test(l))continue;let d=l;for(;d.length&&C.includes(d[d.length-1]);)d=d.slice(0,-1);const p=a.start+d.length,g=a.start+c;p<=a.start||(r.push(a),s.push(new P(a.start,p,{name:"alternative_title",value:H(n.slice(a.start,p)),inputString:n})),s.push(new P(g,a.end,{name:"title",tags:["title"],value:H(n.slice(g,a.end)),inputString:n})))}return r.length||s.length?[r,s]:!1}};fs.priority=N;let yn=fs;const gs=class gs extends x{constructor(){super(...arguments),this.priority=N,this.consequence=[w,L]}when(e,t){if(S(t,"title"))return!1;const n=e.inputString??"",r=[],s=[];for(const a of e.named("title")??[]){const i=/^(.*\S)[\s._-]+(seasons?|saison)$/i.exec(String(a.value??""));if(!i)continue;const o=e.range(a.end,n.length,l=>!l.private&&!!l.value,0);if(!o||o.name!=="season")continue;r.push(a),n.slice(a.start,a.end).slice(0,i[1].length+(String(a.value).length===a.end-a.start,0));let c=a.end;for(;c>a.start&&H(n.slice(a.start,c)).toLowerCase()!==i[1].toLowerCase();)c--;c<=a.start||s.push(new P(a.start,c,{name:"title",value:H(n.slice(a.start,c)),inputString:n}))}return r.length||s.length?[r,s]:!1}};gs.priority=N;let bn=gs;const hs=class hs extends x{constructor(){super(...arguments),this.priority=N,this.consequence=w}when(e,t){if(S(t,"title"))return!1;const n=e.inputString??"",r=[];for(const s of e.markers.named("path")){const a=(e.range(s.start,s.end,l=>l.name==="title")??[]).sort((l,d)=>l.start-d.start);if(a.length<2)continue;const i=a[0];if(i.start!==s.start||/[\s._-]/.test(String(i.value??"").trim()))continue;const o=e.markers.range(i.end,s.end,l=>l.name==="group",0);!o||o.start>=a[1].start||![...n.slice(i.end,o.start)].every(l=>C.includes(l))||!e.range(o.start,o.end,l=>l.name==="release_group"&&!!l.tags?.includes("anime"),0)||r.push(i)}return r.length?r:!1}};hs.priority=N;let wn=hs;const ms=class ms extends x{constructor(){super(...arguments),this.priority=N,this.consequence=[w,L]}when(e,t){if(S(t,"title"))return!1;const n=e.inputString??"",r=[],s=[];for(const a of e.markers.named("path")){const i=e.range(a.start,a.end,p=>p.name==="title")??[];if(i.find(p=>/[\p{L}\p{N}]/u.test(String(p.value??""))))continue;r.push(...i);const c=e.markers.range(a.start,a.end,p=>p.name==="group")??[];if(!c.length)continue;const l=e.range(a.start,a.end,p=>p.name==="release_group",0);let d;for(const p of c){if(l&&p.start<=l.start&&p.end>=l.end)continue;const g=n.slice(p.start+1,p.end-1);if(!/[a-zA-Z]{2,}/.test(g))continue;const f=e.range(p.start,p.end,m=>!m.private&&["episode_title","alternative_title"].includes(m.name??""))??[],v=e.range(p.start,p.end,m=>!m.private&&!["episode_title","alternative_title"].includes(m.name??""))??[];if(f.length&&!v.length){r.push(...f),d=new P(p.start+1,p.end-1,{name:"title",value:H(n.slice(p.start+1,p.end-1)),inputString:n});break}const h=e.holes(p.start+1,p.end-1,{formatter:H,predicate:m=>!!m.value,index:0});if(!(!h||!/[a-zA-Z]{3,}/.test(String(h.value??"")))){d=h;break}}if(d){d.name="title",s.push(d);continue}if(l&&l.tags?.includes("anime")){const p=n.slice(a.start,a.end).replace(n.slice(l.start-1>=a.start?l.start-1:l.start,Math.min(l.end+1,a.end)),""),g=e.range(a.start,a.end,v=>!v.private&&v.name!=="release_group"&&v.start>=a.start)??[];/[a-zA-Z]{2,}/.test(p.replace(/\b(mkv|avi|mp4)\b/gi,""))&&g.some(v=>["title","episode_title","alternative_title"].includes(v.name??""))||(r.push(l),s.push(new P(l.start,l.end,{name:"title",value:H(n.slice(l.start,l.end)),inputString:n})))}}return r.length||s.length?[r,s]:!1}};ms.priority=N;let Sn=ms;const vs=class vs extends x{constructor(){super(...arguments),this.priority=64,this.consequence=w}when(e,t){if(S(t,"part"))return!1;const n=[];for(const r of e.named("part")??[]){const s=r.initiator??r;if(/\d/.test(String(s.raw??"")))continue;const a=e.markers.atMatch(r,o=>o.name==="path",0);if(!(!a||!e.range(r.end,a.end,o=>!o.private&&["year","season","episode","date"].includes(o.name??""),0))){n.push(r);for(const o of[...s.children??[]])n.includes(o)||n.push(o);s!==r&&!n.includes(s)&&n.push(s)}}return n.length?n:!1}};vs.priority=64;let An=vs;const xs=class xs extends x{constructor(){super(...arguments),this.priority=64,this.consequence=w}when(e,t){if(S(t,"bonus"))return!1;const n=[];for(const r of e.named("bonus")??[]){const s=e.markers.atMatch(r,c=>c.name==="path",0);if(!s||!(e.range(s.start,s.end,c=>c.name==="crc32",0)||e.markers.range(s.start,s.end,c=>c.name==="group"&&c.start===s.start,0)))continue;const i=e.range(r.end,s.end,c=>!c.private&&["episode","season","year","date"].includes(c.name??""),0),o=e.named("bonus_title")??[];!i&&!o.length||(n.push(r),n.push(...o.filter(c=>c.start>=s.start&&c.end<=s.end)))}return n.length?n:!1}};xs.priority=64;let kn=xs;const _s=class _s extends x{constructor(){super(...arguments),this.priority=64,this.consequence=w}when(e,t){if(S(t,"language"))return!1;const n=[];for(const r of e.named("language")??[]){const s=String(r.raw??"");if(s.length>3||!/^[A-Z][a-z]{0,2}$/.test(s))continue;const a=e.markers.atMatch(r,c=>c.name==="path",0);!a||!e.markers.range(a.start,a.end,c=>c.name==="group"&&c.start===a.start,0)||!e.range(r.end,a.end,c=>!c.private&&["episode","season","year","date"].includes(c.name??""),0)||n.push(r)}return n.length?n:!1}};_s.priority=64;let Dn=_s;const ys=class ys extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.inputString||"",r=[];for(const s of e.markers.named("path")){const a=e.range(s.start,s.end,l=>!l.private&&!!l.value,0);if(!a)continue;const i=e.range(a.end,s.end,l=>!l.private&&["year","season","episode","date"].includes(l.name??""),0);if(!i){const l=e.range(s.start,s.end,d=>d.name==="title",0);if(a.name==="year"&&a.start===s.start&&!l){a.name="title",a.value=String(e.inputString??"").slice(a.start,a.end),r.push(a);continue}continue}const o=a.name==="year"&&["season","episode"].includes(i.name??"")&&!i.tags?.includes("weak-episode")&&!i.tags?.includes("weak-duplicate");if(!o&&!["other","country","edition"].includes(a.name??""))continue;const c=e.range(s.start,s.end,l=>l.name==="title")??[];c.some(l=>l.start<i.end)||c.length&&!o||(r.push(...c),!(a.name!=="year"&&(a.raw??"")===String(a.value??""))&&[...n.slice(s.start,a.start)].every(l=>C.includes(l))&&r.push(a))}return r.length?r:!1}then(e,t,n){const r=e.inputString||"";for(const s of t){e.remove(s);const a=new P(s.start,s.end,{name:"title",value:H(r.slice(s.start,s.end)),inputString:r});e.append(a)}}};ys.priority=-48;let Cn=ys;const bs=class bs extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.named("alternative_title"),r=Array.isArray(n)?n:n?[n]:[];if(!r.length)return!1;const s=[];for(const a of r){const i=String(a.raw??a.value??"");if(!/^[\d\s.~_-]+$/.test(i)||!/\d/.test(i))continue;const o=e.markers.atMatch(a,l=>l.name==="path",0);if(!o)continue;e.range(o.start,o.end,l=>l.name==="episode"||l.name==="absolute_episode",0)&&s.push(a)}return s.length?s:!1}};bs.priority=-64;let Mn=bs;const rt=class rt extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.named("alternative_title"),r=Array.isArray(n)?n:n?[n]:[];if(!r.length)return!1;const s=new Set(["year","title","alternative_title","episode_title","type"]),a=[];for(const i of r){const o=e.markers.atMatch(i,g=>g.name==="path",0);if(!o)continue;const c=e.range(o.start,o.end,g=>g.name==="year"),l=Array.isArray(c)?c:c?[c]:[];if(!l.length)continue;const d=Math.max(...l.map(g=>g.end));if(i.start<d)continue;e.range(d,i.start,g=>!g.private&&!!g.value&&!s.has(g.name??""),0)&&a.push(i)}return a.length?a:!1}};rt.priority=N,rt.dependency=["RenameEpisodeTitleWhenMovieType"];let En=rt;const st=class st extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=new Set(["year","title","alternative_title","episode_title","type"]),r=[];for(const s of e.markers.named("path")){const a=e.range(s.start,s.end,l=>l.name==="title"),i=(Array.isArray(a)?a:a?[a]:[]).slice().sort((l,d)=>l.start-d.start);if(i.length<2)continue;const o=i[0],c=String(o.value??"").trim().toLowerCase();if(c){if(gn.has(c)){i.slice(1).some(l=>!gn.has(String(l.value??"").trim().toLowerCase()))&&r.push(o);continue}for(const l of i.slice(1))e.range(o.end,l.start,p=>!p.private&&!!p.value&&!n.has(p.name??""),0)&&r.push(l)}}return r.length?r:!1}};st.priority=N,st.dependency=["RenameEpisodeTitleWhenMovieType"];let Pn=st;function go(u){const e=new $({disabled:n=>S(n,"title")});e.rules(xn,_n,An,kn,Dn,yn,je,mn,vn,Cn,Mn,En,Pn,Sn,wn,bn);const t=za("expected_title");return e.functional(t,{name:"title",tags:["expected","title"],validator:R,formatter:Le(H,qe),conflictSolver:(n,r)=>r,disabled:n=>!n?.expected_title}),e}function ae(u){return u==null?!1:Array.isArray(u)?u.length>0:!0}const ho=/^(the|a|an|le|la|les|l'|el|los|las|der|die|das)\s+/i;function ma(u){return u.toLowerCase().replace(ho,"").trim()}const ws=class ws extends x{constructor(){super(...arguments),this.priority=N,this.consequence=[w,L]}when(e,t){const n=e.inputString??"",r=[],s=[],a=e.named("episode_title")??[];for(const i of a){if(!/^\d{1,2}$/.test(String(i.value??"")))continue;const o=(e.named("episode")??[]).filter(g=>g.end<=i.start&&!g.private).sort((g,f)=>g.start-f.start);if(o.length<3)continue;const c=o.slice(1),l=c[0].start,d=n.slice(l,i.end);if(!/^\d{1,3}(-\d{1,3})+$/.test(d))continue;const p=n.slice(o[0].end,l);/^[\s._]+$/.test(p)&&(r.push(...c,i),s.push(new P(l,i.end,{name:"episode_title",value:d,inputString:n})))}return r.length||s.length?[r,s]:!1}};ws.priority=N;let Nn=ws;function mo(u){const e=new $({disabled:t=>S(t,"episode_title")});return e.rules(Bn,Vn,zn,Un,Wn,qn,_o,yo,Hn,$n,On,Tn,Rn,Ln,In,Fn,Nn,jn),e}const vo=new Set(["ep","eps","episode","episodes","episodio","episodios","cap","capitulo","capitulos","folge","e"]),Ss=class Ss extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.named("episode_title"),r=Array.isArray(n)?n:n?[n]:[];if(!r.length)return!1;const s=[];for(const a of r){if(!vo.has(String(a.value??"").trim().toLowerCase()))continue;const i=e.range(a.end,e.inputString?.length??a.end+100,o=>!o.private&&!!o.value,0);i&&i.name==="episode"&&s.push(a)}return s.length?s:!1}};Ss.priority=N;let On=Ss;const at=class at extends x{constructor(){super(...arguments),this.consequence=w}static isHash(e){return/[\s._\-]/.test(e)?!1:/^[0-9a-f]{16,}$/i.test(e)?!0:e.length>=24&&/[a-z]/.test(e)&&/[A-Z]/.test(e)&&/\d/.test(e)}when(e,t){const n=e.inputString??"",r=new Set(["episode_title","version","episode_details","alternative_title"]),s=[];for(const a of e.markers.named("path")){let i=n.slice(a.start,a.end);const o=e.range(a.start,a.end,c=>c.name==="container",0);if(o&&(i=n.slice(a.start,o.start)),!!at.isHash(i.replace(/[.\s]+$/,"")))for(const c of e.range(a.start,a.end,l=>r.has(l.name??"")))s.push(c)}return s.length?s:!1}};at.priority=N;let In=at;const As=class As extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.named("episode_title"),r=Array.isArray(n)?n:n?[n]:[],s=[];for(const a of r){if(!e.markers.atMatch(a,o=>o.name==="group",0))continue;e.range(a.start,a.end,o=>o.name==="episode_details"&&o.start<=a.start&&o.end>=a.end,0)&&s.push(a)}return s.length?s:!1}};As.priority=N;let Tn=As;const ks=class ks extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.named("episode_title"),s=(Array.isArray(n)?n:n?[n]:[]).filter(a=>/\bfansub/i.test(String(a.value??"")));return s.length?s:!1}};ks.priority=N;let Rn=ks;const Ds=class Ds extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.inputString??"",r=e.named("episode_title"),s=Array.isArray(r)?r:r?[r]:[],a=[];for(const i of s){if(/[\s.]/.test(String(i.value??"").trim()))continue;const o=n.slice(i.end).replace(/^[\s._-]+/,"");/^subtitl(e|es)\b|^subs?\b/i.test(o)&&a.push(i)}return a.length?a:!1}};Ds.priority=N;let Ln=Ds;const xo=new Set(["the","a","an","and","or","of","to","in","on","at","for","from","by","with","le","la","les","de","du","des","el"]),Me=class Me extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=[];for(const r of e.markers.named("path")){const s=e.range(r.start,r.end,c=>c.name==="episode_title"),a=(Array.isArray(s)?s:s?[s]:[]).slice().sort((c,l)=>c.start-l.start);if(a.length<2)continue;const i=a[0],o=String(i.value??"").trim().toLowerCase();if(!(!o||xo.has(o)))for(const c of a.slice(1))e.range(i.end,c.start,d=>!d.private&&!!d.value&&!Me.TITLEISH.has(d.name??""),0)&&n.push(c)}return n.length?n:!1}};Me.priority=N,Me.TITLEISH=new Set(["year","title","alternative_title","episode_title","type","episode","season"]);let Fn=Me;const Ee=class Ee extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=e.named("episode_title"),r=Array.isArray(n)?n:n?[n]:[];if(!r.length)return!1;const s=[],a=e.inputString??"",i=(c,l)=>!!e.range(c,l,d=>Ee.RELEASE_PROPS.has(d.name??""),0),o=(c,l)=>l<=c||[...a.slice(c,l)].every(d=>"[](){} .-_".includes(d));for(const c of r){const l=e.markers.atMatch(c,p=>p.name==="group",0);if(!l)continue;let d=i(l.start,l.end);if(!d)for(const p of e.markers.named("group")){if(p.span?.[0]===l.span?.[0])continue;if((p.start>=l.end&&o(l.end,p.start)||p.end<=l.start&&o(p.end,l.start))&&i(p.start,p.end)){d=!0;break}}d&&s.push(c)}return s.length?s:!1}};Ee.priority=N,Ee.RELEASE_PROPS=new Set(["screen_size","video_codec","audio_codec","audio_channels","source","color_depth","video_profile","audio_profile","streaming_service","video_bit_rate","audio_bit_rate","container"]);let $n=Ee;const Cs=class Cs extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=[];for(const r of e.markers.named("path")){if(e.range(r.start,r.end,a=>a.name==="episode"&&!a.private,0)||!e.range(r.start,r.end,a=>a.name==="season"&&!a.private,0))continue;const s=e.range(r.start,r.end,a=>a.name==="episode_title");for(const a of Array.isArray(s)?s:s?[s]:[])/^\d{1,3}$/.test(String(a.value??"").trim())&&n.push(a)}return n.length?n:!1}then(e,t,n){for(const r of t)e.remove(r),r.name="episode",r.value=parseInt(String(r.value).trim(),10),e.append(r)}};Cs.priority=N;let Hn=Cs;const Ms=class Ms extends x{constructor(){super(...arguments),this.consequence=w,this.previousNames=["episode","episode_count","season","season_count","date","title","year"],this.nextNames=["streaming_service","screen_size","source","video_codec","audio_codec","other","container"],this.affectedIfHolesAfter=["part"],this.affectedNames=["part","year"]}when(e,t){const n=[],r=e.markers.named("path");for(const s of r){const a=e.range(s.start,s.end,i=>this.affectedNames.includes(i.name??""));for(const i of a){const o=e.range(s.start,i.start,h=>!h.private,-1);if(!o||!this.previousNames.includes(o.name??"")||o.tags?.includes("weak-episode")||o.tags?.includes("weak-duplicate")||i.name==="year"&&e.markers.atMatch(i,m=>m.name==="group",0))continue;const c=e.range(i.end,s.end,h=>!h.private,0);if(!c||!this.nextNames.includes(c.name??""))continue;const l=e.markers.atMatch(i,h=>h.name==="group",0),d=h=>!!(h.value&&String(h.value).replace(new RegExp(`[${B}]`,"g"),""))&&l===e.markers.atMatch(h,m=>m.name==="group",0),p=e.holes(o.end,i.start,{predicate:d}),g=e.holes(i.end,c.start,{predicate:d}),f=ae(p),v=ae(g);!f&&!v||this.affectedIfHolesAfter.includes(i.name??"")&&!v||(n.push(i),i.parent&&n.push(i.parent))}}return n}};Ms.priority=64;let Bn=Ms;const Es=class Es extends x{when(e,t){const n=e.named("title"),r={};for(const c of n){const l=String(c.value);r[l]=r[l]||[],r[l].push(c)}const s=[];if(Object.keys(r).length<2)return s;const a=new Set(["episode","season","date","year"]),i=c=>{const l=e.markers.atMatch(c,g=>g.name==="path",0);if(!l)return;const d=e.range(l.start,c.start,g=>!g.private&&a.has(g.name??"")),p=Array.isArray(d)?d:d?[d]:[];return p.length>0?p[p.length-1]:void 0},o=new Set;for(const c of n)i(c)||o.add(ma(String(c.value)));for(const c of n)if(i(c)){const d=ma(String(c.value));o.has(d)||s.push(c)}return s}then(e,t,n){const r=t;for(const s of r)e.remove(s),s.name="episode_title",e.append(s)}};Es.dependency=["TitleFromPosition"];let Vn=Es;const Ps=class Ps extends x{when(e,t){const n=e.named("episode_title");if(!n||n.length===0)return;const r=[];for(const s of n){const a=e.inputString??"",i=e.range(s.end,s.end+20,o=>o.name==="episode_details");if(!(!i||i.length===0)){for(const o of i)if([...a.slice(s.end,o.start)].every(l=>C.includes(l))){r.push({et:s,detail:o});break}}}return r.length>0?r:void 0}then(e,t,n){const r=t;if(r)for(const{et:s,detail:a}of r)e.remove(s),s.end=a.end,s.value=void 0,s.value,e.append(s)}};Ps.dependency=["TitleToEpisodeTitle"];let zn=Ps;const Ns=class Ns extends x{constructor(){super(...arguments),this.previousNames=["episode","episode_count","season","season_count","date","title","year"]}isIgnored(e){if(!(e.name==="language"||e.name==="country"||e.name==="episode_details"))return!1;const t=e.raw??"";return!(e.end-e.start>3&&t!==""&&t===t.toUpperCase()&&t!==t.toLowerCase())}when(e,t){const n=[],r=e.markers.named("path");for(const s of r){if(ae(e.range(s.start,s.end,p=>p.name==="episode_title",0)))continue;const i=ae(e.range(s.start,s.end,p=>p.name==="title",0)),o=ae(e.range(s.start,s.end,p=>p.name==="episode"&&!p.private,0));if(!i&&!o)continue;const c=e.holes(s.start,s.end,{formatter:Le(H,qe),ignore:p=>this.isIgnored(p),predicate:p=>!!p.value}),l=Array.isArray(c)?c:c?[c]:[],d=e.inputString||"";for(const p of l){const g=e.markers?.atMatch?.(p,M=>M.name==="group",0);if(g&&e.range(g.start,g.end,T=>(T.name==="year"||T.name==="date")&&!T.private,0))continue;const f=M=>M.name==="language"||M.name==="country",v=e.range(s.start,s.end,M=>f(M)),h=Array.isArray(v)?v:v?[v]:[];let m=0;for(;m++<64;){let M=p.end;for(;M>p.start&&C.includes(d[M-1]);)M--;if(M<=p.start)break;const T=h.find(O=>O.start<=M-1&&O.end>=M);if(T&&T.start<p.end)p.end=Math.min(p.end,T.start);else break}for(m=0;m++<64;){let M=p.start;for(;M<p.end&&C.includes(d[M]);)M++;if(M>=p.end)break;const T=h.find(O=>O.start<=M&&O.end>=M+1);if(T&&T.end>p.start)p.start=Math.max(p.start,T.end);else break}for(;p.start<p.end&&C.includes(d[p.start]);)p.start++;for(;p.end>p.start&&C.includes(d[p.end-1]);)p.end--;if(p.end<=p.start||!p.value)continue;const D=M=>!M.private&&this.previousNames.includes(M.name??""),b=e.range(s.start,p.start,D),A=Array.isArray(b)?b:b?[b]:[],k=A.length>0?A[A.length-1]:void 0;let E;if(!k){const M=e.range(s.start,p.start,O=>!O.private&&O.name==="crc32"),T=Array.isArray(M)?M:M?[M]:[];E=T.length>0?T[T.length-1]:void 0}!k&&!E||(p.name="episode_title",n.push(p))}}return n}then(e,t,n){const r=t;for(const s of r)e.includes(s)||e.append(s)}};Ns.dependency=["ExtendEpisodeTitleWithDetails"];let Un=Ns;const Os=class Os extends x{constructor(){super(...arguments),this.previousNames=["episode","episode_count","season","season_count","date","title","year"]}when(e,t){if(ae(e.named("episode_title",null,0)))return;const n=e.range(0,void 0,r=>r.name==="alternative_title",0);if(n){const r=e.chainBefore(n.start,C,0,s=>s.name==="title",0);if(r){const s=e.markers.atMatch(r,v=>v.name==="path",0),a=s?.start??0,i=v=>!v.private&&this.previousNames.includes(v.name??""),o=e.range(a,r.start,i),c=Array.isArray(o)?o:o?[o]:[],l=c.length>0?c[c.length-1]:void 0,d=s?.end??e.inputString?.length??r.end+100,p=l?void 0:e.range(a,d,v=>!v.private&&v.name==="crc32"),g=Array.isArray(p)?p:p?[p]:[],f=g.length>0?g[0]:void 0;if(l||f)return n}}}then(e,t,n){const r=t;r&&(e.remove(r),r.name="episode_title",r.tags=r.tags||[],r.tags.push("alternative-replaced"),e.append(r))}};Os.dependency=["EpisodeTitleFromPosition"];let Wn=Os;const Is=class Is extends x{constructor(){super(...arguments),this.langNames=new Set(["language","country","subtitle_language"])}when(e,t){const n=e.named("episode_title");if(!n||n.length===0)return;const r=[];for(const s of n){let a=s.start,i=s.end;const o=e.range(s.start,s.end,l=>this.langNames.has(l.name??""));if(!o||o.length===0)continue;const c=[...o].sort((l,d)=>d.start-l.start);for(const l of c)if(l.start>=a&&l.start<i){const d=s.inputString??"",p=l.end>=i?"":d.slice(l.end,i);if(p===""||[...p].every(g=>C.includes(g))){let g=l.start;for(;g>a&&C.includes(d[g-1]);)g--;g<i&&(i=g)}}(a!==s.start||i!==s.end)&&i>a&&r.push({match:s,newStart:a,newEnd:i})}return r.length>0?r:void 0}then(e,t,n){const r=t;if(r)for(const{match:s,newStart:a,newEnd:i}of r){e.remove(s),s.start=a,s.end=i,s.value=void 0;const o=s.value;o&&String(o).trim()&&e.append(s)}}};Is.dependency=["EpisodeTitleFromPosition","AlternativeTitleReplace"];let qn=Is;function Ua(u,e,t){const n=u.holes(e,t,{ignore:Ha(i=>!!i.tags?.includes("weak-episode"),i=>i.name==="language"||i.name==="country"||i.name==="episode_details"),formatter:H,seps:Ft,predicate:i=>!!i.value}),r=Array.isArray(n)?n:n?[n]:[];if(r.length===0)return;const s=r[0],a=s.inputString??"";for(const i of r.slice(1)){const o=a.slice(s.end,i.start),c=s.raw,l=i.raw;if(o==="-"&&c&&!C.includes(c[c.length-1])&&l&&!C.includes(l[0]))s.end=i.end;else break}return s}class _o extends x{constructor(){super(...arguments),this.consequence=new L("title")}when(e,t){if(ae(e.tagged("filepart-title",null,0)))return;const n=e.markers.named("path");if(n.length<3)return;const r=n[n.length-1],s=n[n.length-2],a=n[n.length-3];if(e.range(r.start,r.end,o=>o.name==="episode",0)&&e.range(s.start,s.end,c=>c.name==="season",0)){const c=Ua(e,a.start,a.end);if(c)return c}}}class yo extends x{constructor(){super(...arguments),this.consequence=new L("title")}when(e,t){if(ae(e.tagged("filepart-title",null,0)))return;const n=e.markers.named("path");if(n.length<2)return;const r=n[n.length-1],s=n[n.length-2];if(e.range(r.start,r.end,i=>i.name==="episode",0)){const i=e.range(s.start,s.end,l=>l.name==="season",0)||e.range(r.start,r.end,l=>l.name==="season",0),o=e.named("season"),c=Array.isArray(o)?o.length>0:!!o;if(i||!c){const l=Ua(e,s.start,s.end);if(l){const d=e.markers.named("group"),g=(Array.isArray(d)?d:d?[d]:[]).filter(f=>f.start>=s.start&&f.end<=s.end&&!(f.start===s.start&&f.end===s.end));if(g.length>0){const f=l.crop(g),h=(Array.isArray(f)?f:f?[f]:[]).find(m=>m.value);if(h)return h.tags=h.tags||[],h.tags.push("filepart-title"),h}else return l.tags=l.tags||[],l.tags.push("filepart-title"),l}}}}}const it=class it extends x{when(e,t){const n=e.named("episode_title",s=>!s.tags?.includes("alternative-replaced"))||[],r=e.named("type",s=>s.value==="episode",0);if(n.length>0&&!r)return n}then(e,t,n){const r=t;if(r)for(const s of r)e.remove(s),s.name="alternative_title",e.append(s)}};it.priority=N,it.dependency=["TypeProcessor"];let jn=it;const ue=[{alpha3:"eng",alpha2:"en",name:"English",opensubtitles:"eng"},{alpha3:"fra",alpha2:"fr",name:"French",opensubtitles:"fre"},{alpha3:"deu",alpha2:"de",name:"German",opensubtitles:"ger"},{alpha3:"spa",alpha2:"es",name:"Spanish",opensubtitles:"spa"},{alpha3:"ita",alpha2:"it",name:"Italian",opensubtitles:"ita"},{alpha3:"por",alpha2:"pt",name:"Portuguese",opensubtitles:"por"},{alpha3:"rus",alpha2:"ru",name:"Russian",opensubtitles:"rus"},{alpha3:"jpn",alpha2:"ja",name:"Japanese",opensubtitles:"jpn"},{alpha3:"zho",alpha2:"zh",name:"Chinese",opensubtitles:"chi"},{alpha3:"kor",alpha2:"ko",name:"Korean",opensubtitles:"kor"},{alpha3:"ara",alpha2:"ar",name:"Arabic",opensubtitles:"ara"},{alpha3:"hin",alpha2:"hi",name:"Hindi",opensubtitles:"hin"},{alpha3:"tur",alpha2:"tr",name:"Turkish",opensubtitles:"tur"},{alpha3:"pol",alpha2:"pl",name:"Polish",opensubtitles:"pol"},{alpha3:"nld",alpha2:"nl",name:"Dutch",opensubtitles:"dut"},{alpha3:"swe",alpha2:"sv",name:"Swedish",opensubtitles:"swe"},{alpha3:"dan",alpha2:"da",name:"Danish",opensubtitles:"dan"},{alpha3:"nor",alpha2:"no",name:"Norwegian",opensubtitles:"nor"},{alpha3:"fin",alpha2:"fi",name:"Finnish",opensubtitles:"fin"},{alpha3:"hun",alpha2:"hu",name:"Hungarian",opensubtitles:"hun"},{alpha3:"ces",alpha2:"cs",name:"Czech",opensubtitles:"cze"},{alpha3:"ron",alpha2:"ro",name:"Romanian",opensubtitles:"rum"},{alpha3:"ukr",alpha2:"uk",name:"Ukrainian",opensubtitles:"ukr"},{alpha3:"heb",alpha2:"he",name:"Hebrew",opensubtitles:"heb"},{alpha3:"cat",alpha2:"ca",name:"Catalan",opensubtitles:"cat"},{alpha3:"vie",alpha2:"vi",name:"Vietnamese",opensubtitles:"vie"},{alpha3:"tha",alpha2:"th",name:"Thai",opensubtitles:"tha"},{alpha3:"ind",alpha2:"id",name:"Indonesian",opensubtitles:"ind"},{alpha3:"mal",alpha2:"ml",name:"Malayalam",opensubtitles:"mal"},{alpha3:"tel",alpha2:"te",name:"Telugu",opensubtitles:"tel"},{alpha3:"tam",alpha2:"ta",name:"Tamil",opensubtitles:"tam"},{alpha3:"bul",alpha2:"bg",name:"Bulgarian",opensubtitles:"bul"},{alpha3:"hrv",alpha2:"hr",name:"Croatian",opensubtitles:"hrv"},{alpha3:"srp",alpha2:"sr",name:"Serbian",opensubtitles:"srp"},{alpha3:"slk",alpha2:"sk",name:"Slovak",opensubtitles:"slo"},{alpha3:"slv",alpha2:"sl",name:"Slovenian",opensubtitles:"slv"},{alpha3:"ell",alpha2:"el",name:"Greek",opensubtitles:"ell"},{alpha3:"lit",alpha2:"lt",name:"Lithuanian",opensubtitles:"lit"},{alpha3:"lav",alpha2:"lv",name:"Latvian",opensubtitles:"lav"},{alpha3:"est",alpha2:"et",name:"Estonian",opensubtitles:"est"},{alpha3:"glg",alpha2:"gl",name:"Galician",opensubtitles:"glg"},{alpha3:"eus",alpha2:"eu",name:"Basque",opensubtitles:"baq"},{alpha3:"ben",alpha2:"bn",name:"Bengali",opensubtitles:"ben"},{alpha3:"isl",alpha2:"is",name:"Icelandic",opensubtitles:"ice"},{alpha3:"mkd",alpha2:"mk",name:"Macedonian",opensubtitles:"mac"},{alpha3:"bos",alpha2:"bs",name:"Bosnian",opensubtitles:"bos"},{alpha3:"alb",alpha2:"sq",name:"Albanian",opensubtitles:"alb"},{alpha3:"per",alpha2:"fa",name:"Persian",opensubtitles:"per"},{alpha3:"msa",alpha2:"ms",name:"Malay",opensubtitles:"may"},{alpha3:"mon",alpha2:"mn",name:"Mongolian",opensubtitles:"mon"},{alpha3:"tha",alpha2:"th",name:"Thai",opensubtitles:"tha"},{alpha3:"urd",alpha2:"ur",name:"Urdu",opensubtitles:"urd"},{alpha3:"pan",alpha2:"pa",name:"Punjabi",opensubtitles:"pun"},{alpha3:"guj",alpha2:"gu",name:"Gujarati",opensubtitles:"guj"},{alpha3:"kan",alpha2:"kn",name:"Kannada",opensubtitles:"kan"},{alpha3:"mar",alpha2:"mr",name:"Marathi",opensubtitles:"mar"},{alpha3:"asm",alpha2:"as",name:"Assamese",opensubtitles:"asm"},{alpha3:"mya",alpha2:"my",name:"Burmese",opensubtitles:"mya"},{alpha3:"khm",alpha2:"km",name:"Khmer",opensubtitles:"khm"},{alpha3:"lao",alpha2:"lo",name:"Lao",opensubtitles:"lao"},{alpha3:"por",alpha2:"pt",name:"Brazilian Portuguese",country:"BR",opensubtitles:"pob"},{alpha3:"zho",alpha2:"zh",name:"Simplified Chinese",country:"CN",opensubtitles:"chi"},{alpha3:"zho",alpha2:"zh",name:"Traditional Chinese",country:"TW",opensubtitles:"zht"},{alpha3:"zho",alpha2:"zh",name:"Hong Kong Chinese",country:"HK",opensubtitles:"zht"},{alpha3:"deu",alpha2:"de",name:"Swiss German",country:"CH",opensubtitles:"ger"},{alpha3:"fra",alpha2:"fr",name:"Swiss French",country:"CH",opensubtitles:"fre"},{alpha3:"ita",alpha2:"it",name:"Swiss Italian",country:"CH",opensubtitles:"ita"},{alpha3:"nld",alpha2:"nl",name:"Flemish",country:"BE",opensubtitles:"dut"},{alpha3:"und",name:"Undetermined",opensubtitles:"und"},{alpha3:"mul",name:"Multiple Languages",opensubtitles:"mul"}];function Pt(u){const e=new Map;for(const t of ue){const n=t[u];if(n){const r=String(n).toLowerCase();(!e.has(r)||!t.country&&e.get(r).country)&&e.set(r,t)}}return e}const bo=Pt("alpha3"),wo=Pt("alpha2"),So=Pt("name"),Ao=Pt("opensubtitles"),ko={ell:["gr","greek"],spa:["esp","español","espanol"],fra:["français","vf","vff","vfi","vfq"],swe:["se"],por_BR:["po","pb","pob","ptbr","br","brazilian"],deu_CH:["swissgerman","swiss german"],nld_BE:["flemish"],cat:["català","castellano","espanol castellano","español castellano"],ces:["cz"],ukr:["ua"],zho:["cn"],jpn:["jp"],hrv:["scr"],mul:["multi","multiple","dl"]};class X{constructor(e,t,n){this.alpha3=e,this.country=t,this.script=n}toString(){return this.country?`${this.alpha3}-${this.country}`:this.alpha3}getName(){this.country?`${this.alpha3}${this.country}`:this.alpha3;for(const e of ue)if(e.alpha3===this.alpha3&&e.country===this.country)return e.name;for(const e of ue)if(e.alpha3===this.alpha3&&!e.country)return e.name;return this.alpha3}getAlpha2(){for(const e of ue)if(e.alpha3===this.alpha3&&e.country===this.country)return e.alpha2;for(const e of ue)if(e.alpha3===this.alpha3&&!e.country)return e.alpha2}getOpenSubtitles(){for(const e of ue)if(e.alpha3===this.alpha3&&e.country===this.country)return e.opensubtitles;for(const e of ue)if(e.alpha3===this.alpha3&&!e.country)return e.opensubtitles}static fromString(e){if(!e)return;const t=e.toLowerCase().trim(),n=this.fromSynonym(t);if(n)return n;if(t.length===3)return this.fromAlpha3(t);if(t.length===2)return this.fromAlpha2(t);const r=this.fromName(t);if(r)return r;const s=this.fromOpenSubtitles(t);if(s)return s;const a=this.fromIetf(t);if(a)return a}static fromAlpha3(e){if(!e)return;const t=e.toLowerCase().trim(),n=bo.get(t);if(n)return new X(n.alpha3,n.country,n.script)}static fromAlpha2(e){if(!e)return;const t=e.toLowerCase().trim(),n=wo.get(t);if(n)return new X(n.alpha3,n.country,n.script)}static fromName(e){if(!e)return;const t=e.toLowerCase().trim(),n=So.get(t);if(n)return new X(n.alpha3,n.country,n.script)}static fromOpenSubtitles(e){if(!e)return;const t=e.toLowerCase().trim(),n=Ao.get(t);if(n)return new X(n.alpha3,n.country,n.script)}static fromIetf(e){if(!e)return;const t=e.toLowerCase().trim().split("-");if(t.length!==0&&t.length>=1){const n=this.fromAlpha2(t[0]);if(n&&t.length>=2)if(t[1].length===2)n.country=t[1].toUpperCase();else return;return n}}static fromSynonym(e){if(!e)return;const t=e.toLowerCase().trim();for(const[n,r]of Object.entries(ko))for(const s of r)if(s.toLowerCase()===t){const[a,i]=n.split("_");return new X(a,i)}}equals(e){return this.alpha3===e.alpha3&&this.country===e.country&&this.script===e.script}}const va=new X("und"),Do=new X("mul");function*Fr(u){let e=null;for(let t=0;t<=u.length;t++){const n=t<u.length?u[t]:null;n!==null&&!C.includes(n)?e===null&&(e=t):e!==null&&(yield{span:[e,t],value:u.slice(e,t)},e=null)}}class De{constructor(e,t,n,r,s){this.start=e,this.end=t,this.value=n,this.inputString=r,this.nextWord=s}get extendedWord(){if(!this.nextWord)return;const e=this.inputString.slice(this.end,this.nextWord.start),t=this.inputString.slice(this.nextWord.end,this.nextWord.end+1);if(e==="-"&&e!==t||e===" "||e==="."){const n=this.inputString.slice(this.start,this.nextWord.end).replace(/\./g," ");return new De(this.start,this.nextWord.end,n,this.inputString,this.nextWord.nextWord)}}}class Co{constructor(e,t,n,r,s,a,i){const o=e?.allowed_languages||[];this.allowedLanguages=new Set(o.map(c=>c.toLowerCase())),this.weakAffixes=new Set(a),this.commonWords=i??new Set,this.prefixesMap=new Map,this.suffixesMap=new Map,S(e,"subtitle_language")||(this.prefixesMap.set("subtitle_language",t),this.suffixesMap.set("subtitle_language",n)),this.prefixesMap.set("language",r),this.suffixesMap.set("language",s)}*find(e){const t=new Map,n=new Map,r=new Map;for(const i of this.iterLanguageMatches(e)){const o=i.propertyName;i.lang.equals(va)?(n.has(o)||n.set(o,new Set),n.get(o).add(i)):i.lang.equals(Do)?(r.has(o)||r.set(o,new Set),r.get(o).add(i)):(t.has(o)||t.set(o,new Set),t.get(o).add(i))}const s=new Set,a=i=>{const o=`${i.propertyName}:${i.word.start}-${i.word.end}:${i.lang.alpha3}`;if(!s.has(o))return s.add(o),this.toRebulkMatch(i)};for(const[i,o]of r)if(t.has(i)||!n.has(i))for(const c of o){const l=a(c);l&&(yield l)}for(const[i,o]of n)if(!t.has(i))for(const c of o){const l=a(c);l&&(yield l)}for(const i of t.values())for(const o of i){const c=a(o);c&&(yield c)}}toRebulkMatch(e){const t=e.word,n=t.start,r=t.end,s=e.propertyName;if(e.lang.equals(va))return[n,r,{name:s,value:t.value.toLowerCase(),formatter:i=>new X("und"),tags:["weak-language"]}];const a=[];return this.commonWords.has(t.value.toLowerCase())&&a.push("common"),[n,r,{name:s,value:e.lang,...a.length>0?{tags:a}:{}}]}*iterLanguageMatches(e){const t=[];let n=null;for(const r of Fr(e)){const s=new De(r.span[0],r.span[1],r.value,e);n&&(n.nextWord=s,t.push(n)),n=s}n&&t.push(n);for(const r of t)yield*this.iterMatchesForCandidate(r)}*iterMatchesForCandidate(e){if(e.nextWord){const r=this.findMatchForWord(e.nextWord,e,this.prefixesMap,(s,a)=>s.startsWith(a),(s,a)=>s.slice(a.length));r&&(yield r)}const t=this.findMatchForWord(e,e.nextWord??void 0,this.suffixesMap,(r,s)=>r.endsWith(s),(r,s)=>r.slice(0,-s.length));t&&(yield t);const n=this.findLanguageMatchForWord(e);n&&(yield n)}findMatchForWord(e,t,n,r,s){if(e)for(const a of[e.extendedWord,e]){if(!a)continue;const i=a.value.toLowerCase();for(const[o,c]of n)for(const l of c){if(!r(i,l))continue;let d;const p=s(i,l);if(!p)t&&(Math.abs(t.start-a.end)<=1||Math.abs(a.start-t.end)<=1)&&(d=this.findLanguageMatchForWord(t,o)),!d&&!this.weakAffixes.has(l)&&(d=this.createLanguageMatch(o,new De(a.start,a.end,"und",a.inputString)));else{let g=a.start,f=a.end;if(a!==e){const v=p.trim();v&&e&&e.value.toLowerCase()===v?(g=e.start,f=e.end):v&&e&&e.nextWord&&e.nextWord.value.toLowerCase()===v?(g=e.nextWord.start,f=e.nextWord.end):v&&t&&(g=t.start,f=t.end)}d=this.createLanguageMatch(o,new De(g,f,p,a.inputString))}if(d)return d}}}findLanguageMatchForWord(e,t="language"){if(e){for(const n of[e.extendedWord,e])if(n){const r=this.createLanguageMatch(t,n);if(r)return r}}}createLanguageMatch(e,t){const n=this.parseLanguage(t.value.toLowerCase());if(n)return{propertyName:e,word:t,lang:n}}parseLanguage(e){const t=X.fromString(e);if(!t)return;if(this.allowedLanguages.size===0)return t;const n=t.getName().toLowerCase(),r=t.getAlpha2(),s=t.alpha3.toLowerCase();if(this.allowedLanguages.has(n)||r&&this.allowedLanguages.has(r.toLowerCase())||this.allowedLanguages.has(s))return t}}class $r extends x{constructor(){super(...arguments),this.consequence=w,this.properties={subtitle_language:[null]}}enabled(e){return!S(e,"subtitle_language")}when(e,t){const n=[],r=e.named("subtitle_language.prefix")||[];for(const s of e.named("language")||[]){let a=e.previous(s,i=>i.name==="subtitle_language.prefix",0);if(!a){const i=e.markers?.at(s,o=>o.name==="group",0);i&&(a=e.previous(i,o=>o.name==="subtitle_language.prefix",0),a||(a=e.range?.(i.start,s.start,o=>o.name==="subtitle_language.prefix",0)))}if(!a){const i=e.markers?.atMatch?.(s,o=>o.name==="group",0);if(i){const o=n.find(([c,l])=>l.start>=i.start&&l.end<=i.end);o&&(a=o[0])}}if(a){n.push([a,s]);const i=e.conflicting?.(s)||[];r.push(...i),r.includes(a)&&r.splice(r.indexOf(a),1)}}return n.length>0||r.length>0?{toRename:n,toRemove:r}:!1}then(e,t,n){const{toRename:r,toRemove:s}=t;for(const a of s)e.remove(a);for(const[a,i]of r){const o={...a,name:"subtitle_language.suffix"};e.includes?.(o)&&e.remove(o),e.remove(i),i.name="subtitle_language",e.append(i)}}}class Hr extends x{constructor(){super(...arguments),this.dependency=$r,this.consequence=w,this.properties={subtitle_language:[null]}}enabled(e){return!S(e,"subtitle_language")}when(e,t){const n=[],r=e.named("subtitle_language.suffix")||[];for(const s of e.named("language")||[]){const a=e.next(s,i=>i.name==="subtitle_language.suffix",0);if(a){if(e.next(a,c=>c.name==="language"||c.name==="subtitle_language",0)||e.range?.(a.start,a.end+10,c=>(c.name==="language"||c.name==="subtitle_language")&&c.start>=a.start&&c.end>a.end,0))continue;n.push(s),r.includes(a)&&r.splice(r.indexOf(a),1)}}return n.length>0||r.length>0?{toAppend:n,toRemove:r}:!1}then(e,t,n){const{toAppend:r,toRemove:s}=t;for(const a of s)e.remove(a);for(const a of r)e.remove(a),a.name="subtitle_language",e.append(a)}}const ot=class ot extends x{constructor(){super(...arguments),this.dependency=Hr}when(e,t){const n=e.named("container")||[],s=(Array.isArray(n)?n:n?[n]:[]).find(p=>ot.SUBTITLE_EXTENSIONS.has(String(p.value).toLowerCase()));if(!s)return!1;const a=e.markers?.named("path")||[],o=(Array.isArray(a)?a:a?[a]:[]).find(p=>s.start>=p.start&&s.end<=p.end),c=e.named("language")||[],l=Array.isArray(c)?c:c?[c]:[];let d;return o?d=l.filter(p=>p.start>=o.start&&p.end<=o.end):d=l,d.length>0?d:!1}then(e,t,n){if(!(!t||!Array.isArray(t)))for(const r of t)e.remove(r),r.name="subtitle_language",e.append(r)}};ot.SUBTITLE_EXTENSIONS=new Set(["srt","sub","smi","ssa","ass","vtt","idx","sup"]);let Ge=ot;const Ts=class Ts extends x{constructor(){super(...arguments),this.consequence=w,this.priority=32}when(e,t){const n=[],r=e.range?.(0,e.inputString?.length??0,a=>a.name==="language"||a.name==="subtitle_language")||[],s=Array.isArray(r)?r:r?[r]:[];for(const a of s){if(!a.tags?.includes("common"))continue;const i=e.markers?.atMatch?.(a,o=>o.name==="group",0);if(i){const o=e.range?.(i.start,i.end,p=>p.name!=="language"&&p.name!=="subtitle_language"),c=Array.isArray(o)?o.length>0:!!o,l=e.holes?.(i.start,i.end,{predicate:p=>p.value&&[...String(p.value)].some(g=>!C.includes(g))}),d=Array.isArray(l)?l.length>0:!!l;if(!c&&!d)continue}n.push(a)}return n.length>0?n:!1}};Ts.priority=32;let Gn=Ts;class Mo extends x{constructor(){super(...arguments),this.consequence=w}enabled(e){return S(e,"language")}when(e,t){return e.named("language")||!1}}const Rs=class Rs extends x{constructor(){super(...arguments),this.consequence=w,this.priority=32}when(e,t){const n=[];for(const r of e.range?.(0,e.inputString?.length)||[])if(["language","subtitle_language"].includes(r.name)&&(r.value==="und"||r.value instanceof X&&r.value.alpha3==="und")){const s=e.previous?.(r,void 0,0),a=e.next?.(r,void 0,0),i=new Set(["language","subtitle_language"]);(s&&i.has(s.name)||a&&i.has(a.name))&&n.push(r)}return n.length>0?n:!1}};Rs.priority=32;let Kn=Rs;class Eo extends x{constructor(){super(...arguments),this.consequence=w,this.dependency=[$r,Hr,Ge]}identity(e){const t=e.value;if(t instanceof X){const n=t.country;return`${t.alpha3}:${n?String(n):""}`}return String(t)}when(e){const t=[];for(const n of["language","subtitle_language"]){const r=[...e.named(n)||[]].sort((a,i)=>a.start-i.start||a.end-i.end),s=new Set;for(const a of r){const i=`${a.start}-${a.end}:${this.identity(a)}`;s.has(i)?t.push(a):s.add(i)}}return t.length>0?t:!1}}function Po(u,e){const t=u.subtitle_affixes,n=[...t,...u.subtitle_prefixes].sort((l,d)=>d.length-l.length),r=[...t,...u.subtitle_suffixes].sort((l,d)=>d.length-l.length),s=u.language_affixes,a=[...s,...u.language_prefixes].sort((l,d)=>d.length-l.length),i=[...s,...u.language_suffixes].sort((l,d)=>d.length-l.length),o=new Set(u.weak_affixes),c=new $().stringDefaults({ignoreCase:!0}).defaults({validator:R});for(const l of n)c.string(l,{name:"subtitle_language.prefix",ignoreCase:!0,private:!0,validator:R,tags:["release-group-prefix"],disabled:d=>S(d,"subtitle_language")});for(const l of r)c.string(l,{name:"subtitle_language.suffix",ignoreCase:!0,private:!0,validator:R,disabled:d=>S(d,"subtitle_language")});for(const l of i)c.string(l,{name:"language.suffix",ignoreCase:!0,private:!0,validator:R,tags:["source-suffix"],disabled:d=>S(d,"language")});return c.functional((l,d)=>{const p=new Co(d,n,r,a,i,Array.from(o),e);return Array.from(p.find(l))},{properties:{language:[null]},disabled:l=>S(l,"language")&&S(l,"subtitle_language")}),c.rules($r,Hr,Ge,Gn,Mo,Kn,Eo,Xn),c}const Ls=class Ls extends x{constructor(){super(...arguments),this.consequence=w}when(e){const t=new Set(["title","episode_title","alternative_title"]),n=e.range(0,(e.inputString??"").length,s=>t.has(s.name??""));if(!n.length)return!1;const r=[];for(const s of["language","subtitle_language"])for(const a of e.named(s))String(a.raw??"").trim().length>3||n.some(o=>o.start<=a.start&&o.end>=a.end)&&r.push(a);return r.length?r:!1}};Ls.priority=N;let Xn=Ls;const No={us:"US",usa:"US","united states":"US",gb:"GB",uk:"GB","united kingdom":"GB",ca:"CA",canada:"CA",de:"DE",germany:"DE",fr:"FR",france:"FR",it:"IT",italy:"IT",es:"ES",spain:"ES",nl:"NL",netherlands:"NL",be:"BE",belgium:"BE",ch:"CH",switzerland:"CH",se:"SE",sweden:"SE",no:"NO",norway:"NO",dk:"DK",denmark:"DK",fi:"FI",finland:"FI",pl:"PL",poland:"PL",ru:"RU",russia:"RU",cn:"CN",china:"CN",jp:"JP",japan:"JP",au:"AU",australia:"AU",nz:"NZ","new zealand":"NZ",in:"IN",india:"IN",br:"BR",brazil:"BR",mx:"MX",mexico:"MX",za:"ZA","south africa":"ZA",kr:"KR","south korea":"KR",tw:"TW",taiwan:"TW",hk:"HK","hong kong":"HK"};function Oo(u,e){const t=new $({disabled:r=>S(r,"country")});t.defaults({name:"country"});function n(r,s){const a=s?.allowed_countries;return new Io(a,e).find(r)}return t.functional(n,{conflictSolver:(r,s)=>s.name!=="language"||!["US","GB"].includes(String(r.value))?r:s,properties:{country:[null]},disabled:r=>!r?.allowed_countries}),t}class Io{constructor(e,t){this.allowedCountries=new Set(e?.map(n=>n.toLowerCase())||[]),this.commonWords=t}find(e){const t=[];for(const n of Fr(e.trim().toLowerCase())){const r=n.value;if(this.commonWords.has(r.toLowerCase()))continue;const s=No[r.toLowerCase()];s&&(this.allowedCountries.has(s.toLowerCase())||this.allowedCountries.has(r.toLowerCase()))&&t.push([n.span[0],n.span[1],{value:s}])}return t}}function To(u){const e=u.forbidden_names,t=u.ignored_seps,n=C.split("").filter(i=>!t.includes(i)).join("");function r(i){let o=me(i,n);const c=t.split("").some(p=>o.includes(p)),l=t.split("").some(p=>o.startsWith(p)),d=t.split("").some(p=>o.endsWith(p));!(l&&d)&&!c&&(o=me(o,t));for(const p of e)o.toLowerCase().startsWith(p)&&o.length>p.length&&C.includes(o[p.length])&&(o=me(o.slice(p.length),n)),o.toLowerCase().endsWith(p)&&o.length>p.length&&C.includes(o[o.length-p.length-1])&&(o=me(o.slice(0,o.length-p.length),n));return o=o.replace(/\s*[)\]]\s*$/,p=>{const f=p.trim()===")"?"(":"[";return o.includes(f)?p:""}).trim(),o.replace(/(.+)\)\s*\[(.+)\]/,"$1 $2").trim()}const s=new $({disabled:i=>S(i,"release_group")}),a=za("expected_group");return s.functional(a,{name:"release_group",tags:["expected"],validator:R,conflictSolver:()=>null,disabled:i=>!i?.expected_group}),s.rules(new Ro(r),new Zn(r),Jn,new er(r),Qn,Yn)}const Fs=class Fs extends x{constructor(){super(...arguments),this.consequence=w}when(e){const t=e.named("release_group"),n=(Array.isArray(t)?t:t?[t]:[]).filter(r=>/(^|[\s._\-\[(])seasons?[\s._-]*\d/i.test(String(r.value??"")));return n.length?n:!1}};Fs.priority=N;let Yn=Fs;class Ro extends x{constructor(e){super(),this.consequence=[w,L],this.valueFormatter=e}isValid(e,t,n,r,s){if(!s){if(String(t.value).length<=1||e.markers.atMatch(t,g=>g.name==="group",0)||e.range(t.start,t.end,g=>g.name==="episode",0))return!1;const c=e.holes(t.end,r,{predicate:g=>g.start===t.end,index:0});if(!c)return!1;const d=String(c.raw??"").replace(new RegExp("^["+B+"]+|["+B+"]+$","g"),"");if(t.start===n&&!d.includes(".")&&!d.includes(" ")&&e.range(t.end,r,g=>["season","episode","date"].includes(g.name??"")&&!g.private,0))return!1;const p=c.raw;return p[0]==="-"&&!p.slice(1).includes("-")&&p.includes(".")&&!p.includes(" ")}const a=e.markers.atMatch(t,c=>c.name==="group",0);if(a&&e.atMatch(a,c=>!c.private&&c.span!==t.span))return!1;let i=0,o=t;for(;o;){const c=e.range(n,o.start,p=>!p.private&&!p.tags.includes("expected"),-1);if(!c)break;let d=(e.inputString??"").slice(c.end,o.start);if(!d&&(o.raw??"")[0]==="-"&&(d="-"),o=c,i===0){if(d!=="-")break;i++;continue}if(d===".")return!0}return!1}detect(e,t,n,r){let s=null;if(r){const a=e.ending(n,i=>i.name==="container",0);a&&(n=a.start),s=e.ending(n,i=>!i.private&&!(i.name==="other"&&i.tags.includes("not-a-release-group"))&&!(i.raw??"").includes("-")&&(i.raw??"").trim()===i.raw,0)}if(!s){const a=i=>!!(i.tags?.includes("weak-episode")||i.tags?.includes("weak-duplicate"));r?s=e.holes(t,n,{seps:C,index:-1,ignore:a,predicate:i=>i.end===n&&!!(i.raw??"").trim()&&(i.raw??"")[0]==="-"}):s=e.holes(t,n,{seps:C,index:0,ignore:a,predicate:i=>i.start===t&&!!(i.raw??"").trim()})}return s&&this.isValid(e,s,t,n,r)?s:null}when(e){if(e.named("release_group").length>0)return;const t=[],n=[];for(const r of e.markers.named("path")){let s=this.detect(e,r.start,r.end,!0);if(s?t.push(...e.atMatch(s)):s=this.detect(e,r.start,r.end,!1),s){const a=new P(s.start,s.end,{name:"release_group",inputString:e.inputString});if(a.formatter=this.valueFormatter,a.value&&n.push(a),t.length||n.length)return[t,n]}}}}const Pe=class Pe extends x{constructor(e){super(),this.valueFormatter=e}isPreviousMatch(e){const t=["video_codec","source","video_api","audio_codec","audio_profile","video_profile","audio_channels","screen_size","other","container","language","subtitle_language","subtitle_language.suffix","subtitle_language.prefix","language.suffix"],n=["release-group-prefix"],r=["no-release-group-prefix"];return t.includes(e.name??"")?!e.tags.some(s=>r.includes(s)):e.tags.some(s=>n.includes(s))}when(e){const t=[];for(const n of we(e.markers.named("path"),e)){const{start:r,end:s}=n;if(e.named("release_group",c=>c.start>=r&&c.end<=s).length>0)continue;const a=e.named("title",c=>c.start>=r&&c.end<=s),i=c=>a.slice(1).includes(c)||c.name==="episode_title"||!!(c.tags?.includes("weak-episode")||c.tags?.includes("weak-duplicate")),o=e.holes(r,s+1,{formatter:c=>H(c),ignore:i,predicate:c=>!!H(String(c.value??"")),index:-1});if(o){const c=e.markers.atMatch(o,f=>f.name==="group",0);if(c&&String(c.raw??"").startsWith("(")&&(e.range(r,s,v=>v.name==="episode"||v.name==="season")??[]).length>0){const v=e.markers.range(r,s,h=>h.name==="group"&&h.start===r,0);if(v){const h=e.range(v.start,v.end,b=>!b.tags.includes("weak-language"))??[],m=String(v.value??"").replace(new RegExp(`[${B}]`,"g"),"");if((h.length===0||h.every(b=>b.name==="container"&&b.tags?.includes("subtitle")))&&m&&!ye(m))continue}}const l=f=>f.start<n.start?!1:!f.private||this.isPreviousMatch(f),d=e.previous(o,l,0),p=e.inputString??"",g=String(o.value??"");if(d&&this.isPreviousMatch(d)&&!p.slice(d.end,o.start).replace(new RegExp(`[${B}]`,"g"),"")&&!ye(g.replace(new RegExp(`[${B}]`,"g"),""))){o.name="release_group",o.tags=["scene"],o.formatter=this.valueFormatter;const f=e.markers.atMatch(o,h=>h.name==="group",0);f&&(f.formatter=this.valueFormatter,f.value===o.value&&(o.start=f.start+1,o.end=f.end-1,o.tags=["anime"]));const v=e.range(o.start,o.end,i);for(const h of v)e.remove(h);t.push(o)}}}return t}};Pe.dependency=["TitleFromPosition"],Pe.consequence=L,Pe.properties={release_group:[null]};let Zn=Pe;const Ne=class Ne extends x{when(e){const t=[],n=[];if(e.named("release_group").length>0||!e.named("episode").length&&!e.named("season").length&&e.named("release_group").length>0)return!1;for(const r of we(e.markers.named("path"),e)){const s=i=>{const o=e.range(i.start,i.end,c=>!c.tags.includes("weak-language"));return!!(o.length===0||i.start===r.start&&o.every(c=>c.name==="container"&&c.tags?.includes("subtitle")))},a=e.markers.range(r.start,r.end,i=>i.name==="group"&&s(i)&&String(i.value).replace(new RegExp(`[${B}]`,"g"),"")&&!ye(String(i.value).replace(new RegExp(`[${B}]`,"g"),"")),0);if(a){const i=new P(a.start+1,a.end-1,{name:"release_group",inputString:e.inputString,tags:["anime"]});n.push(i),t.push(...e.range(a.start,a.end,o=>o.tags.includes("weak-language")||o.name==="other"||o.name==="container"&&o.tags?.includes("subtitle")))}}return t.length||n.length?[t,n]:!1}};Ne.dependency=["SceneReleaseGroup","TitleFromPosition"],Ne.consequence=[w,L],Ne.properties={release_group:[null]};let Jn=Ne;const $s=class $s extends x{constructor(){super(...arguments),this.priority=-32,this.consequence=[w,L]}when(e,t){const n=e.inputString??"",r=[],s=[];for(const a of e.named("release_group")??[]){const i=/^(\d{1,3})\s*\[([^\]]+)\]$/.exec(String(a.value??""));if(!i)continue;const o=n.slice(a.start,a.end),c=i[1].length;r.push(a),s.push(new P(a.start,a.start+c,{name:"episode",value:parseInt(i[1],10),inputString:n}));const l=o.indexOf("[");s.push(new P(a.start+l+1,a.end-1,{name:"release_group",value:i[2],inputString:n}))}return r.length||s.length?[r,s]:!1}};$s.priority=-32;let Qn=$s;const Hs=class Hs extends x{constructor(e){super(),this.consequence=[w,L],this.valueFormatter=e}when(e){if(e.named("release_group").length>0)return!1;const t=e.inputString??"",n=[],r=[];for(const s of e.markers.named("path")){const a=e.range(s.start,s.end,d=>!d.private&&d.name==="episode_title"&&d.value,-1);if(!a||e.range(a.end,s.end,d=>!d.private&&d.span[0]!==d.span[1],0))continue;const o=String(a.raw??a.value);if(/[\s.]/.test(o.trim())||t[a.start-1]!=="-")continue;const c=e.range(s.start,a.start,d=>!d.private,-1);if(!c||!["episode","absolute_episode"].includes(c.name??""))continue;const l=new P(a.start,a.end,{name:"release_group",inputString:t});l.formatter=this.valueFormatter,l.value&&(n.push(a),r.push(l))}return n.length||r.length?[n,r]:!1}};Hs.dependency=["AnimeReleaseGroup"];let er=Hs;function Lo(u){const e=new $({disabled:t=>S(t,"streaming_service")});return e.stringDefaults({ignoreCase:!0}).regexDefaults({flags:"i",abbreviations:[K]}),e.defaults({name:"streaming_service",tags:["source-prefix"]}),te(e,u),e.rules(tr),e}const lt=class lt extends x{when(e){const t=[],n=e.named("streaming_service");process.env.DEBUG_SS&&console.log(`[VS.when] allServices count=${n.length}`);const r=e.inputString||"";for(const s of n){if((s.raw??"").length<=3){const h=r[s.end],m=r[s.start-1];if(h&&/[a-z0-9]/i.test(h)||m&&/[a-z0-9]/i.test(m)){t.push(s);continue}}const i=h=>!h.private&&h.tags?.includes("streaming_service.suffix"),o=h=>!h.private&&h.tags?.includes("streaming_service.prefix"),c=e.range(s.end,s.end+30,i),l=Array.isArray(c)?c:c?[c]:[],d=l.length>0?l.reduce((h,m)=>h.start<m.start?h:m):void 0,p=e.range(Math.max(0,s.start-30),s.start,o),g=Array.isArray(p)?p:p?[p]:[],f=g.length>0?g.reduce((h,m)=>h.end>m.end?h:m):void 0,v=s.initiator&&s.initiator.children.named("other").length>0;if(process.env.DEBUG_SS&&console.log(`[SS] service=${s.value} [${s.start},${s.end}) nextMatch=${d?.name}@${d?.start} prevMatch=${f?.name} sepsBefore=${ie(s)} sepsAfter=${oe(s)}`),!v){const h=d?e.holes(s.end,d.start,{predicate:O=>!!String(O.value).replace(new RegExp(`[${B}]`,"g"),"")}):null,m=f?e.holes(f.end,s.start,{predicate:O=>!!String(O.value).replace(new RegExp(`[${B}]`,"g"),"")}):null,D=20,b=d&&d.start-s.end>D,A=f&&s.start-f.end>D,k=d?e.range(s.end,d.start,O=>O.name!=="streaming_service"&&!O.private&&O.name!=="other"):null,E=f?e.range(f.end,s.start,O=>O.name!=="streaming_service"&&!O.private&&O.name!=="other"):null,M=k&&k.length>0,T=E&&E.length>0;if((!d||b||M||h!==null&&h.length>0||!ie(s))&&(!f||A||T||m!==null&&m.length>0||!oe(s))){process.env.DEBUG_SS&&console.log(` [VS.when] pushing to toRemove: ${s.value}`),t.push(s);continue}}s.value==="Comedy Central"&&t.push(...e.named("edition",h=>h.value==="Criterion"))}return process.env.DEBUG_SS&&console.log(`[VS.when] returning toRemove.length=${t.length}`),t}};lt.priority=128,lt.consequence=w;let tr=lt;function Fo(u){const e=new $({disabled:t=>S(t,"other")});return e.regexDefaults({flags:"i",abbreviations:[K]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"other",validator:R}),te(e,u.other),Uo(e),e.rules(rr,sr,ar,lr,cr,dr,ur,pr,fr,gr,hr,mr,xr,vr,nr,ir,or),e}const $o={poster:"Poster",fanart:"Fanart",banner:"Banner",thumb:"Thumbnail",thumbnail:"Thumbnail",landscape:"Landscape",cover:"Cover",clearart:"Clear Art",clearlogo:"Clear Logo",logo:"Logo",discart:"Disc Art"},Bs=class Bs extends x{constructor(){super(...arguments),this.consequence=[w,L]}when(e){const t=[],n=[];for(const r of e.markers.named("path")){if(!e.range(r.start,r.end,i=>i.name==="container"&&i.tags?.includes("image"),0))continue;const a=e.range(r.start,r.end,i=>["title","alternative_title","episode_title"].includes(i.name??""));for(const i of a){const o=String(i.value??"").trim().toLowerCase().replace(/[\s._-]+/g,""),c=$o[o];c&&(t.push(i),n.push(new P(i.start,i.end,{name:"other",value:c,inputString:e.inputString})))}}return t.length?[t,n]:!1}};Bs.priority=N;let nr=Bs;const Ho="(?P<credits_number>\\d+(?:(?![vV]\\d)[^\\W\\d_])?)?",Bo="(?:-?[vV](?P<version>\\d+))?",Vo=Ho+Bo;function zo(u){const e=/^(\d+)(\w?)$/.exec(u);return e?String(parseInt(e[1],10))+e[2].toLowerCase():u}function Uo(u){const e=(t,n,r)=>{u.regex("(?P<other>"+t+")"+Vo,{flags:r?"i":"",name:"other",children:!0,privateParent:!0,validateAll:!0,validator:{__parent__:R},formatter:{other:()=>n,credits_number:zo,version:s=>parseInt(s,10)},disabled:s=>S(s,"other")})};e("NC-?OP|creditless-?op(?:ening)?","Opening Credits",!0),e("NC-?ED|creditless-?(?:ed|ending)","Ending Credits",!0),e("OPED|OP","Opening Credits",!1),e("ED","Ending Credits",!1)}const ct=class ct extends x{constructor(){super(...arguments),this.priority=N,this.consequence=L}when(e,t){const n=[];for(const r of e.named("other",s=>s.value==="Opening Credits"||s.value==="Ending Credits")??[]){const s=(r.raw??"").toLowerCase().replace(/[\s._-]+/g,"");(s.startsWith("nc")||s.includes("creditless"))&&n.push(new P(r.start,r.end,{name:"other",value:"Creditless",inputString:e.inputString}))}return n.length?n:!1}};ct.priority=N,ct.properties={other:["Creditless"]};let rr=ct;const ut=class ut extends x{constructor(){super(...arguments),this.priority=N,this.consequence=L}when(e,t){const n=[];for(const r of e.named("other",s=>s.value==="Opening Credits")??[])(r.raw??"").toLowerCase().replace(/[\s._-]+/g,"")==="oped"&&n.push(new P(r.start,r.end,{name:"other",value:"Ending Credits",inputString:e.inputString}));return n.length?n:!1}};ut.priority=N,ut.properties={other:["Ending Credits"]};let sr=ut;const Wo="stereo-vr-context",qo=new Set(["Virtual Reality","3D"]),Vs=class Vs extends x{constructor(){super(...arguments),this.priority=64,this.consequence=w}when(e,t){const n=[],r=e.markers.named("path");for(const s of Array.isArray(r)?r:r?[r]:[]){const a=e.range(s.start,s.end,o=>o.name==="other"&&o.tags.includes(Wo));if(!a?.length)continue;if(e.range(s.start,s.end,o=>o.name==="other"&&qo.has(String(o.value)))?.length>0)for(const o of a)n.push(...e.range(o.start,o.end,c=>c.name==="streaming_service")??[]);else n.push(...a)}return n.length?n:!1}};Vs.priority=64;let ar=Vs;const xa="(?<![^\\W_])";function jo(u,e){const t=I(e.completeMarkerWords),n=I(e.seasonWords),r=I(e.completeArticleWords),s="(?:-+(?:\\d+|"+I(e.seasonNumberSeparators,void 0,!0)+"))+-+";function a(i){const o=i.children;return!(!o.named("completeWordsBefore")&&!o.named("completeWordsAfter"))}u.regex(xa+`(?P<completeArticle>${r}-)?(?P<completeWordsBefore>${n}-)?`+t+`(?P<completeWordsAfter>-${n})?`,{privateNames:["completeArticle","completeWordsBefore","completeWordsAfter"],value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:i=>R(i)&&a(i)}}),u.regex(n+s+"(?P<other>"+t+")",{children:!0,privateParent:!0,validateAll:!0,value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:R}}),u.regex(xa+"(?P<completePrefix>"+I(e.completePrefixWords)+"-?)"+t,{privateNames:["completePrefix"],value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:R}})}const Oe=class Oe extends x{when(e,t){const n=e.named("other",c=>c.value==="Proper");if(!n||n.length===0)return;const r={};for(const c of n)r[Ba(c.raw)]=c;let s=0,a=null,i=null;for(const c of Object.values(r)){(!a||a>c.start)&&(a=c.start),(!i||i<c.end)&&(i=c.end);const l=c.children.named("proper_count",null,0);l?s+=parseInt(String(l.value),10):c.tags.includes("real")?s+=2:s+=1}const o=new P(a,i,{name:"proper_count"});return o.value=s,[o]}};Oe.priority=N,Oe.consequence=L,Oe.properties={proper_count:[null]};let ir=Oe;const Ie=class Ie extends x{when(e){const t=e.named("other",i=>i.value==="Fix").filter(i=>{const o=Ba(i.raw??"").toLowerCase();return o==="fix"||o==="fixed"});if(!t||t.length===0)return;const n=e.named("proper_count");if(n&&(!Array.isArray(n)||n.length>0))return;let r=null,s=null;for(const i of t)(r===null||i.start<r)&&(r=i.start),(s===null||i.end>s)&&(s=i.end);const a=new P(r,s,{name:"proper_count"});return a.value=-1,[a]}};Ie.priority=N,Ie.consequence=L,Ie.properties={proper_count:[null]};let or=Ie;const dt=class dt extends x{when(e){return e.named("another")}};dt.priority=32,dt.consequence=new he("other");let lr=dt;const pt=class pt extends x{when(e){const t=[];for(const n of e.range(0,void 0,r=>r.tags.includes("has-neighbor"))){let r=e.previous(n,o=>!0,0),s=e.markers.previous(n,o=>o.name==="group",0);if(s&&(!r||s.end>r.end)&&(r=s),r&&!e.inputString.slice(r.end,n.start).replace(new RegExp(`[${B}]`,"g"),""))continue;let a=e.next(n,o=>!0,0),i=e.markers.next(n,o=>o.name==="group",0);i&&(!a||i.start<a.start)&&(a=i),!(a&&!e.inputString.slice(n.end,a.start).replace(new RegExp(`[${B}]`,"g"),""))&&t.push(n)}return t}};pt.consequence=w,pt.priority=64;let cr=pt;const ft=class ft extends x{when(e){const t=[];for(const n of e.range(0,void 0,r=>r.tags.includes("has-neighbor-before"))){let r=e.previous(n,a=>!0,0),s=e.markers.previous(n,a=>a.name==="group",0);s&&(!r||s.end>r.end)&&(r=s),!(r&&!e.inputString.slice(r.end,n.start).replace(new RegExp(`[${B}]`,"g"),""))&&t.push(n)}return t}};ft.consequence=w,ft.priority=64;let ur=ft;const gt=class gt extends x{when(e){const t=[];for(const n of e.range(0,void 0,r=>r.tags.includes("has-neighbor-after"))){let r=e.next(n,a=>!0,0),s=e.markers.next(n,a=>a.name==="group",0);s&&(!r||s.start<r.start)&&(r=s),!(r&&!e.inputString.slice(n.end,r.start).replace(new RegExp(`[${B}]`,"g"),""))&&t.push(n)}return t}};gt.consequence=w,gt.priority=64;let dr=gt;const ht=class ht extends x{when(e){const t=[];for(const n of e.named("other",r=>r.tags.includes("other.validate.screener"))){const r=e.previous(n,s=>s.initiator?.name==="source",0);(!r||e.inputString.slice(r.end,n.start).replace(new RegExp(`[${B}]`,"g"),""))&&t.push(n)}return t}};ht.consequence=w,ht.priority=64;let pr=ht;const mt=class mt extends x{when(e){const t=[];for(const n of e.named("other",r=>r.tags.includes("other.validate.mux")))e.previous(n,s=>s.initiator?.name==="source",0)||t.push(n);return t}};mt.consequence=w,mt.priority=64;let fr=mt;const vt=class vt extends x{when(e){return[]}};vt.priority=32,vt.consequence=w;let gr=vt;const xt=class xt extends x{when(e){const t=[];for(const n of e.named("other",r=>r.initiator?.name!=="source"&&(r.tags.includes("streaming_service.prefix")||r.tags.includes("streaming_service.suffix")))){let r=n.initiator;if(oe(r)){if(!ie(r)){if(r.tags.includes("streaming_service.suffix")){const s=e.previous(r,a=>a.name==="streaming_service",0);if(s&&!e.holes(s.end,r.start,a=>String(a.value).replace(new RegExp(`[${B}]`,"g"),"")).length)continue}r.children&&t.push(...r.children),t.push(r)}}else{if(r.tags.includes("streaming_service.prefix")){const s=e.next(r,a=>a.name==="streaming_service",0);if(s&&!e.holes(r.end,s.start,a=>String(a.value).replace(new RegExp(`[${B}]`,"g"),"")).length)continue}r.children&&t.push(...r.children),t.push(r)}}return t}};xt.priority=32,xt.consequence=w;let hr=xt;const _t=class _t extends x{when(e){const t=[];for(const n of e.markers.named("path"))for(const r of e.range(n.start,n.end,s=>s.name==="other"&&s.tags.includes("at-end")))(e.holes(r.end,n.end,s=>String(s.value).replace(new RegExp(`[${B}]`,"g"),"")).length||e.range(r.end,n.end,s=>!["other","container"].includes(s.name??"")).length)&&t.push(r);return t}};_t.priority=32,_t.consequence=w;let mr=_t;const yt=class yt extends x{when(e){const t=new Set(["Real","Cam","Convert"]),n=new Set(["screen_size","video_codec","audio_codec","video_profile","release_group"]),r=[];for(const s of e.range(0,e.inputString?.length??0)){if(s.name!=="other"&&s.name!=="source"||!t.has(s.raw??""))continue;const i=e.markers.atMatch(s,c=>c.name==="path",0)?.end??e.inputString?.length??s.end;(e.range(s.end,i,c=>!c.private&&n.has(c.name??""))??[]).length>0||r.push(s)}return r.length?r:!1}};yt.consequence=w,yt.priority=64;let vr=yt;const bt=class bt extends x{when(e){const t=[];for(const n of e.markers.named("path"))for(const r of e.range(n.start,n.end,s=>s.name==="other"&&s.tags.includes("real"))){const s=e.range(n.start,r.start);(!s||s.length===0)&&t.push(r)}return t}};bt.consequence=w,bt.priority=64;let xr=bt;function Go(u){const e=new $({disabled:t=>S(t,"size")});return e.regexDefaults({flags:"i",abbreviations:[K]}),e.defaults({name:"size",validator:R}),e.regex("\\d+-?[mgt]b","\\d+\\.\\d+-?[mgt]b",{formatter:t=>Rr.fromstring(t).toString(),tags:["release-group-prefix"]}),e}$i("guessit.rules.common.quantity:BitRate.fromstring",u=>Lr.fromstring(u).toString());function Ko(u){const e=new $({disabled:t=>S(t,"audio_bit_rate")&&S(t,"video_bit_rate")});return e.regexDefaults({flags:"i",abbreviations:[K]}),e.defaults({name:"audio_bit_rate",validator:R}),te(e,u.bit_rate),e.rules(_r),e}const zs=class zs extends x{when(e,t){const n=[],r=[];if(S(t,"audio_bit_rate"))r.push(...e.named("audio_bit_rate"));else{const s=S(t,"video_bit_rate");for(const a of e.named("audio_bit_rate")){const i=e.previous(a,d=>["source","screen_size","video_codec"].includes(d.name??""),0),o=e.inputString??"",c=(d,p)=>o.slice(d,p).replace(new RegExp(`[${B}]`,"g"),"")==="",l=i?c(i.end,a.start):!1;if(i&&l){const p=String(a.value).toLowerCase(),g=/kbps$|kbits?$/.test(p),f=e.next(a,v=>v.name==="audio_codec",0);if(f&&c(a.end,f.start)){g||(s?r.push(a):n.push(a));continue}g||(s?r.push(a):n.push(a))}}}return n.length||r.length?[n,r]:!1}};zs.consequence=[new he("video_bit_rate"),w];let _r=zs;function Xo(u){const e=new $({disabled:t=>S(t,"edition")});return e.regexDefaults({flags:"i",abbreviations:[K]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"edition",validator:R}),te(e,u.edition),e}function Yo(u){const e=new $({disabled:t=>S(t,"cd")});return e.regexDefaults({flags:"i",abbreviations:[K]}),te(e,u),e}function Zo(u){const e=new $({disabled:t=>S(t,"bonus")});return e.regexDefaults({name:"bonus",flags:"i"}),te(e,u.bonus),e.rules(yr,br,wr),e}const Us=class Us extends x{when(e){const t=e.inputString||"",n=e.named("bonus")?.filter(s=>!s.private)??[],r=[];for(const s of n){const a=e.markers.atMatch(s,l=>l.name==="path",0);if(!a)continue;const i=s.parent,o=i?i.start:s.start-1;[...t.slice(a.start,o)].every(l=>C.includes(l))&&(r.push(s),i&&r.push(i))}return r}then(e,t){for(const n of t)e.remove(n)}};Us.priority=128;let yr=Us;const Ws=class Ws extends x{when(e){const t=e.named("bonus")?.filter(r=>!r.private)??[],n=[];for(const r of t){const s=e.markers.atMatch(r,o=>o.name==="path",0);if(!s)continue;const a=!!e.range(s.start,s.end,o=>o.name==="season"&&!o.private,0),i=!!e.range(s.start,s.end,o=>o.name==="episode"&&!o.private,0);a&&!i&&n.push(r)}return n}then(e,t){const n=t;for(const r of n)e.remove(r),r.name="episode",e.append(r)}};Ws.priority=64;let br=Ws;const Jo=new Set(["source","video_codec","audio_codec","screen_size","container","release_group","language","country","other","streaming_service","edition","audio_channels","season","date"]),wt=class wt extends x{when(e){const t=e.named("bonus",m=>!m.private,0);if(!t)return;const n=e.markers.atMatch(t,m=>m.name==="path",0);if(!n)return;const r=e.range(t.end,n.end+1,m=>(m.name==="title"||m.name==="alternative_title"||m.name==="episode_title")&&!m.private,0);if(r&&r.value){const m=e.inputString||"",D=e.range(t.end,n.end+1,V=>V.name==="container"&&!V.private,0),b=D?D.start:n.end;let A=t.end;for(;A<r.start&&/[\s._\-]/.test(m[A]);)A++;let k=r.end;const E=e.range(r.end,b,V=>!V.private&&V.name==="year",0);if(E){const V=m.slice(r.end,E.start),J=m.slice(E.end,b),ce=[...V].every(ne=>/[\s._\-]/.test(ne)),pe=[...J].every(ne=>/[\s._\-]/.test(ne));ce&&pe&&(k=E.end)}const M=m.slice(A,k),T=H(M),O=[r],y=e.range(A,k,V=>!V.private&&V.name!=="bonus"&&V.name!=="container")||[];for(const V of y)O.includes(V)||O.push(V);const q=new P(A,k,{name:"bonus_title",value:T||H(String(r.value)),inputString:m});return{toRemove:O,toAppend:[q]}}const s=e.inputString||"",a=e.range(t.end,n.end+1,m=>m.name==="container"&&!m.private,0),i=a?a.start:n.end,o=e.range(t.end,i,m=>!m.private&&Jo.has(m.name??""))||[];o.sort((m,D)=>m.start-D.start);let c=i;o.length>0&&(c=o[0].start);let l=t.end;for(;l<c&&/[\s._\-]/.test(s[l]);)l++;let d=c;for(;d>l&&/[\s._\-]/.test(s[d-1]);)d--;if(l>=d)return;const p=s.slice(l,d),g=H(p);if(!g)return;const f=[],v=e.range(l,d,m=>!m.private&&m.name!=="bonus"&&m.name!=="container")||[];for(const m of v)f.push(m);const h=new P(l,d,{name:"bonus_title",value:g,inputString:s});return{toRemove:f,toAppend:[h]}}then(e,t){if(!t)return;if(t instanceof P){e.append(t);return}const{toRemove:n,toAppend:r}=t;for(const s of n)e.remove(s);for(const s of r)e.append(s)}};wt.dependency=["TitleFromPosition"],wt.properties={bonus_title:[null]};let wr=wt;function Qo(u){const e=new $({disabled:t=>S(t,"film")});return e.regexDefaults({flags:"i",abbreviations:[K]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"film",validator:R}),te(e,u.film),e.rules(Sr,Ar),e}const qs=class qs extends x{constructor(){super(...arguments),this.consequence=w}when(e,t){const n=[],r=e.named("film",s=>!s.private)??[];for(const s of Array.isArray(r)?r:[r]){const a=e.markers.atMatch(s,o=>o.name==="path",0);if(!a)continue;const i=e.holes(a.start,s.start+1,{formatter:H,index:0});i&&i.value||(n.push(s),s.parent&&n.push(s.parent))}return n.length?n:!1}};qs.consequence=w;let Sr=qs;const St=class St extends x{enabled(e){return!S(e,"film_title")}when(e){const t=e.named("film",n=>!n.private,0);if(t){const n=e.markers.atMatch(t,s=>s.name==="path",0);if(!n)return;const r=e.holes(n.start,t.start+1,{formatter:H,predicate:s=>!!s.value,index:0});if(r&&r.value)return r.name="film_title",r}}};St.consequence=L,St.properties={film_title:[null]};let Ar=St;function el(u){const e=new $({disabled:a=>S(a,"part")});e.regexDefaults({flags:"i",abbreviations:[K],validator:{__parent__:R}});const t=u.prefixes,r=`(?:\\d+|[ivxlcdm]+|${["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"].join("|")})`;function s(a){return ye(a.raw)?!0:R(a)}return e.regex(`${I(t)}-?(?P<part>${r})`,{prefixes:t,validateAll:!0,privateParent:!0,children:!0,formatter:se,validator:{part:ge(s,a=>0<a.value&&a.value<100)}}),e}const tl=0,_a=1,nl=2,rl="[a-zA-Z0-9-]{20,}";function sl(u){const e=[],t=new RegExp(rl,"g");let n;for(;(n=t.exec(u))!==null;){const r=n[0];let s=0,a=0,i=0,o=null,c=_a;for(const p of r){let g;"0123456789".includes(p)?g=tl:/[a-zA-Z]/.test(p)?(g=_a,p!==o&&a++,o=p,i++):g=nl,g!==c&&s++,c=g}const l=s/r.length,d=i>0?a/i:1;if(l>.4&&d>.4){if(/^[sS]\d+[eE]\d+/i.test(r))continue;e.push([n.index,n.index+r.length])}}return e}function al(u){const e=new $({disabled:t=>S(t,"crc32")});return e.regexDefaults({flags:"i"}),e.defaults({validator:R}),e.regex("(?:[a-fA-F]|[0-9]){8}",{name:"crc32",conflictSolver:(t,n)=>["episode","season"].includes(n.name??"")?n:"__default__"}),e.regex("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",{name:"uuid",validator:void 0,conflictSolver:(t,n)=>["episode","season","crc32"].includes(n.name??"")?n:"__default__"}),e.functional(sl,{name:"uuid",conflictSolver:(t,n)=>["episode","season","crc32"].includes(n.name??"")?n:"__default__"}),e}function il(u){const e=new $({disabled:t=>S(t,"imdb_id")});return e.regexDefaults({flags:"i"}),e.defaults({validator:R}),e.regex("tt\\d{7,8}",{name:"imdb_id",formatter:t=>t.toLowerCase()}),e.regex("tmdb(?:id)?[-=]?(?<tmdb_id>\\d{1,9})",{name:"tmdb_id",private_parent:!0,children:!0,formatter:t=>parseInt(t,10)}),e.regex("tvdb(?:id)?[-=]?(?<tvdb_id>\\d{1,9})",{name:"tvdb_id",private_parent:!0,children:!0,formatter:t=>parseInt(t,10)}),e}function ol(u){const e=new $({disabled:t=>S(t,"volume")});return e.regexDefaults({flags:"i"}),e.regex("vol(?:\\d{1,3}|(?:ume)?[-. ]{1,2}\\d{1,3})(?:v\\d)?(?:[&+]\\d{1,3})?",{name:"volume",validator:R,formatter:t=>parseInt(String(t).replace(/^vol(?:ume)?[-. ]*/i,"").replace(/[v&+].*$/i,""),10),conflictSolver:(t,n)=>n.name==="episode"||n.name==="season"?n:"__default__"}),e}const ll={mkv:"video/x-matroska",mp4:"video/mp4",avi:"video/x-msvideo",mov:"video/quicktime",flv:"video/x-flv",wmv:"video/x-ms-wmv",webm:"video/webm",mp3:"audio/mpeg",flac:"audio/flac",aac:"audio/aac",ogg:"audio/ogg",wma:"audio/x-ms-wma",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",svg:"image/svg+xml",zip:"application/zip",rar:"application/x-rar-compressed",pdf:"application/pdf",srt:"text/plain",ts:"video/mp2t",iso:"application/x-iso9660-image",torrent:"application/x-bittorrent"};function cl(u){const e=new $({disabled:t=>S(t,"mimetype")});return e.rules(kr),e}const Te=class Te extends x{when(e,t){const r=(e.inputString??"").split(".").pop()?.toLowerCase()||"";return ll[r]||null}then(e,t,n){if(t&&typeof t=="string"){const r=e.inputString?.length??0,s=new P(r,r,{name:"mimetype",value:t,inputString:e.inputString});e.append(s)}}};Te.priority=N,Te.dependency=["Processors"],Te.properties={mimetype:[null]};let kr=Te;function ul(u,e){u.append(new P(u.inputString?.length??0,u.inputString?.length??0,{name:"type",value:e}))}const Re=class Re extends x{constructor(){super(...arguments),this.priority=N,this.consequence=L}when(e,t){const n=t?.type;if(n)return n;const r=e.named("episode"),s=e.named("season"),a=e.named("absolute_episode"),i=e.named("episode_details"),o=e.named("year"),c=Array.isArray(r)?r:r?[r]:[],l=Array.isArray(s)?s:s?[s]:[],d=!!(o&&(!Array.isArray(o)||o.length>0)),p=!!(a&&(!Array.isArray(a)||a.length>0)),g=!!(i&&(!Array.isArray(i)||i.length>0));if(c.length>0||l.length>0||g||p){c.length>0&&c.every(F=>F.tags.includes("weak-episode")||F.tags.includes("weak-duplicate"));const k=Array.isArray(o)?o:o?[o]:[],E=k.length>0?k[0].start:1/0,M=l.every(F=>(F.tags.includes("weak-duplicate")||F.tags.includes("weak-episode"))&&F.start<E);l.length;let T=!1;const O=c.filter(F=>F.tags.includes("weak-episode")||F.tags.includes("weak-duplicate"));if(O.length>=3)T=!0;else if(O.length===2){const F=[...O].sort((re,fe)=>re.start-fe.start),j=(e.inputString??"").slice(F[0].end,F[1].start).replace(/[\s._]/g,"");(j==="-"||j==="~"||j.toLowerCase()==="to")&&(T=!0)}const y=c.length>0&&!T&&c.every(F=>F.tags.includes("weak-episode")||F.tags.includes("weak-duplicate")),q=l.every(F=>{if(!(F.tags.includes("weak-duplicate")||F.tags.includes("weak-episode")))return!1;if(F.start<E)return!0;const Z=e.inputString??"",j=F.initiator;if(j){const re=j.start??F.start,fe=j.end??F.end,Ys=re>0?Z[re-1]:"",Zs=fe<Z.length?Z[fe]:"";if(Ys&&/[a-zA-Z]/.test(Ys)||Zs&&/[a-zA-Z]/.test(Zs))return!0}return!1}),V=(l.length===0||q)&&!p&&!g,J=e.named("release_group"),ce=Array.isArray(J)?J:J?[J]:[],pe=e.inputString??"",ne=ce.some(F=>(F.start>0?pe[F.start-1]:"")==="[");if(y&&V&&d&&!ne)return{type:"movie",removeWeak:!0};if(c.length===0&&l.length===0&&!p&&g&&d){const F=Array.isArray(i)?i:i?[i]:[],Z=Array.isArray(o)?o:o?[o]:[],j=Z.length>0?Z[0].start:1/0;if(F.some(fe=>fe.start>j))return"episode"}else return"episode"}const f=e.named("other",k=>k.value==="Complete"&&!!(k.children?.named?.("completeWordsBefore")?.length||k.children?.named?.("completeWordsAfter")?.length));if(f&&(!Array.isArray(f)||f.length>0))return"episode";const v=e.named("film");if(v&&(!Array.isArray(v)||v.length>0))return"movie";const h=e.named("date");if(h&&(!Array.isArray(h)||h.length>0)&&(!o||Array.isArray(o)&&o.length===0))return"episode";const m=e.named("bonus");if(m&&(!Array.isArray(m)||m.length>0)&&(!o||Array.isArray(o)&&o.length===0))return"episode";const D=e.named("crc32"),b=e.named("release_group",k=>k.tags.includes("anime"));if(D&&(!Array.isArray(D)||D.length>0)&&b&&(!Array.isArray(b)||b.length>0))return"episode";const A=e.named("other",k=>k.value==="Complete");return A&&(!Array.isArray(A)||A.length>0)&&(!o||Array.isArray(o)&&o.length===0)?"episode":"movie"}then(e,t,n){if(!t)return;let r,s=!1;if(typeof t=="string")r=t;else if(typeof t=="object"&&t!==null&&"type"in t){const a=t;r=a.type,s=!!a.removeWeak}else return;if(s){const a=[];for(const i of["episode","season"]){const o=e.named(i),c=Array.isArray(o)?o:o?[o]:[];for(const l of c)(l.tags.includes("weak-episode")||l.tags.includes("weak-duplicate"))&&a.push(l)}for(const i of a)e.remove(i)}ul(e,r)}};Re.priority=N,Re.dependency=void 0,Re.properties={type:["episode","movie"]};let Dr=Re;function dl(u){const e=new $({disabled:t=>S(t,"type")});return e.rules(Dr),e}const Wa=new Set(["language","subtitle_language"]);function ya(u){if(!Wa.has(u.name??""))return!1;const e=u.value;return e==="und"?!0:e&&typeof e=="object"&&"alpha3"in e?e.alpha3==="und":!1}const js=class js extends Y{when(e,t){const n=[],r=[];for(const s of e.markers.named("group")){for(const a of e.starting(s.start+1))n.push(a);for(const a of e.ending(s.end-1))r.push(a)}return n.length>0||r.length>0?[n,r]:!1}then(e,t,n){const[r,s]=t;for(const a of r)e.remove(a),a.start-=1,a.rawStart+=1,e.append(a);for(const a of s)e.remove(a),a.end+=1,a.rawEnd-=1,e.append(a)}};js.priority=Lt;let Cr=js;function pl(u,e){return u===e||ba(u)&&!ba(e)||!u.toUpperCase().startsWith(u)&&e===e.toUpperCase()||!u.toUpperCase().startsWith(u)&&u[0]===u[0].toUpperCase()&&e[0]!==e[0].toUpperCase()||wa(u)>wa(e)?u:e}function ba(u){return u.split(" ").every(e=>e.length===0||e[0]===e[0].toUpperCase())}function wa(u){let e=0;for(const t of Fr(u))t.value[0]===t.value[0].toUpperCase()&&t.value[0]!==t.value[0].toLowerCase()&&e++;return e}const At=class At extends x{when(e,t){const n=[];for(const r of we(e.markers.named("path"),e)){const s=e.holes(r.start,r.end,{formatter:H});for(const a of e.names){const i=[...s];for(const o of[...i])for(const c of e.named(a))if(typeof c.value=="string"&&o.value&&typeof o.value=="string"&&o.value.toLowerCase()===c.value.toLowerCase()){if(c.tags.includes("equivalent-ignore"))continue;const l=pl(o.value,c.value);o.value!==l&&(o.value=l),c.value!==l&&(c.value=l),o.name=a,o.tags=["equivalent"],n.push(o);const d=i.indexOf(o);d>-1&&i.splice(d,1)}}}return n}};At.priority=N,At.consequence=L;let Mr=At;const kt=class kt extends x{constructor(e,t){super(),this.sortFunction=e??we,this.predicate=t??null}when(e,t){const n=this.sortFunction(e.markers.named("path"),e),r=new Set,s=new Map,a=[];for(const i of n){const o=this.predicate?e.range(i.start,i.end,this.predicate):e.range(i.start,i.end),c=new Set;for(const l of o){const d=l.name??"";if(c.add(d),r.has(d)){const p=s.get(d)??[];if(!p.includes(l.value)){if(d==="episode_title"&&e.range(i.start,i.end,f=>!f.private&&(f.tags?.includes("SxxExx")??!1),0)){const f=e.named(d).filter(v=>v.start<i.start||v.end>i.end);a.push(...f),p.length=0,p.push(l.value),s.set(d,p);continue}if(!ya(l)&&Wa.has(d)&&p.every(f=>f==="und"||f&&typeof f=="object"&&"alpha3"in f&&f.alpha3==="und")){const f=a.length>0?[]:e.named(d).filter(v=>ya(v));a.push(...f),p.length=0,p.push(l.value),s.set(d,p);continue}a.push(l)}}else{const p=s.get(d)??[];p.includes(l.value)||(p.push(l.value),s.set(d,p))}}for(const l of c)r.add(l)}return a}};kt.priority=N,kt.consequence=w;let Ke=kt;const Sa=u=>(u.name==="season"||u.name==="episode")&&u.tags.includes("SxxExx");class qa extends Ke{constructor(e){super((t,n)=>we(t,n,Sa),t=>t.name===e)}when(e,t){const n=e.markers.named("path"),r=Array.isArray(n)?n:n?[n]:[];if(r.length>1){const s=r.map(i=>{const o=e.range(i.start,i.end,Sa);return new Set((Array.isArray(o)?o:[]).map(c=>c.name)).size}),a=Math.max(...s);if(s.filter(i=>i===a).length>1)return[]}return super.when(e,t)}}class fl extends qa{constructor(){super("season")}}class gl extends qa{constructor(){super("episode")}}const Dt=class Dt extends x{when(e,t){const n=[];if(e.named("year").length===0){for(const r of e.named("season"))if(typeof r.value=="number"&&ee(r.value)){const s=r.clone();s.name="year",n.push(s)}}return n}};Dt.priority=N,Dt.consequence=L;let Er=Dt;const Ct=class Ct extends x{when(e,t){const n=[],r=e.named("episode").filter(s=>!s.tags.includes("weak-episode")&&!s.tags.includes("weak-duplicate"));if(e.named("season").length===0&&r.length>0)for(const s of e.named("year")){const a=s.clone();a.name="season",n.push(a)}return n}};Ct.priority=N,Ct.consequence=L;let Pr=Ct;const Gs=class Gs extends x{when(e,t){return!1}};Gs.priority=N;let Nr=Gs;const Ks=class Ks extends Y{when(e,t){return e}then(e,t,n){for(const r of e){const s=r.span;for(let a=0;a<s[1]-s[0];a++){const i=r.raw;if(i&&ke.includes(i[0])&&(i.length<3||!ke.includes(i[2])))r.rawStart=r.rawStart+1;else break}for(let a=s[1]-s[0]-1;a>=0;a--){const i=r.raw;if(i&&ke.includes(i[i.length-1])&&(i.length<3||!ke.includes(i[i.length-3])))r.rawEnd=r.rawEnd-1;else break}}}};Ks.priority=N;let Or=Ks;const Xs=class Xs extends Y{when(e){const t=[];for(const n of e)(n.value===null||n.value===void 0||typeof n.value=="number"&&isNaN(n.value)||n.value==="")&&t.push(n);return t}then(e,t){const n=t;for(const r of n)e.remove(r)}};Xs.priority=N;let Ir=Xs;function hl(u){return new $().rules(Cr,Mr,fl,gl,Ke,Er,Pr,Nr,Or,Ir)}function ja(u){function e(s){return u[s]??{}}const t=new $,n=new Set(u.common_words??[]);t.rebulk(vi(e("path"))),t.rebulk(_i(e("groups")??{starting:"([{",ending:")]}"})),t.rebulk(Pi(e("episodes"))),t.rebulk(Ti(e("container"))),t.rebulk(Ri(e("source"))),t.rebulk(Fi(e("video_codec"))),t.rebulk(ji(e("audio_codec"))),t.rebulk(Qi(e("screen_size"))),t.rebulk(to(e("website"))),t.rebulk(oo(e("date"))),t.rebulk(go(e("title"))),t.rebulk(mo(e("episode_title"))),t.rebulk(Po(e("language"),n)),t.rebulk(Oo(e("country"),n)),t.rebulk(To(e("release_group"))),t.rebulk(Lo(e("streaming_service")));const r=Fo(e("other"));return e("episodes"),jo(r,{completeMarkerWords:["Complete","Int[ée]grale"],seasonWords:["seasons?","mini-?series?","series?"],completeArticleWords:["The"],completePrefixWords:["L['’]?","Coffret"],seasonNumberSeparators:["&","and"]}),t.rebulk(r),t.rebulk(Go(e("size"))),t.rebulk(Ko(e("bit_rate"))),t.rebulk(Xo(e("edition"))),t.rebulk(Yo(e("cd"))),t.rebulk(Zo(e("bonus"))),t.rebulk(Qo(e("film"))),t.rebulk(el(e("part"))),t.rebulk(al(e("crc"))),t.rebulk(il(e("imdb"))),t.rebulk(ol(e("volume"))),t.rebulk(hl(e("processors"))),t.rebulk(cl(e("mimetype"))),t.rebulk(dl(e("type"))),t.customizeProperties=function(a){const i=a.count;return delete a.count,a.season_count=i,a.episode_count=i,a},t}const ml=["OSS 117","This is Us"],vl=["au","gb","us"],xl=["ca","cs","de","en","es","fr","he","hi","hu","it","ja","ko","mul","nl","no","pl","pt","ro","ru","sv","te","uk","und"],_l={common_words:["ca","cat","de","he","it","no","por","rum","se","st","sub"],groups:{starting:"([{【「(",ending:")]}】」)"},audio_codec:{audio_codec:{MP3:{string:["MP3","LAME"],regex:["LAME(?:\\d)+-?(?:\\d)+"]},MP2:"MP2","Dolby Digital":{string:["Dolby","DolbyDigital"],regex:["Dolby-Digital","DD","AC-?3D?","DolbyD"]},"Dolby Atmos":{string:["Atmos"],regex:["Dolby-?Atmos"]},AAC:"AAC","Dolby Digital Plus":{string:["DDP","DD+"],regex:["E-?AC-?3"]},FLAC:"Flac",DTS:"DTS","DTS-HD":{regex:["DTS-?HD","DTS(?=-?MA)","DTS-?MA"],conflict_solver:"lambda match, other: other if other.name == 'audio_codec' else '__default__'"},"DTS:X":{string:["DTS:X","DTS-X","DTSX"]},"Dolby TrueHD":{regex:["True-?HD"]},Opus:{string:"Opus",tags:"title-word"},Vorbis:"Vorbis",PCM:"PCM",LPCM:"LPCM"},audio_channels:{"1.0":["1ch","mono","re:(1[\\W_]0(?:ch)?)(?=[^\\d]|$)"],"2.0":["2ch","stereo",{regex:"(2[\\W_]0(?:ch)?)(?=[^\\d]|$)",children:!0},{string:"20",validator:"import:seps_after",tags:"weak-audio_channels"}],"5.1":["5ch","6ch",{regex:"(5[\\W_][01](?:ch)?)(?=[^\\d]|$)",children:!0},{regex:"(6[\\W_]0(?:ch)?)(?=[^\\d]|$)",children:!0},{regex:"5[01]",validator:"import:seps_after",tags:"weak-audio_channels"}],"7.1":["7ch","8ch",{regex:"(7[\\W_][01](?:ch)?)(?=[^\\d]|$)",children:!0},{regex:"7[01]",validator:"import:seps_after",tags:"weak-audio_channels"}]},audio_profile:{"Master Audio":{string:"MA",tags:["audio_profile.rule","DTS-HD"]},"High Resolution Audio":{string:["HR","HRA"],tags:["audio_profile.rule","DTS-HD"]},"Extended Surround":{string:"ES",tags:["audio_profile.rule","DTS"]},"High Efficiency":{string:"HE",tags:["audio_profile.rule","AAC"]},"Low Complexity":{string:"LC",tags:["audio_profile.rule","AAC"]},"High Quality":{string:"HQ",tags:["audio_profile.rule","Dolby Digital"]},EX:{string:"EX",tags:["audio_profile.rule","Dolby Digital"]}}},bit_rate:{bit_rate:{_:{regex:["\\d+-?[kmg]b(ps|its?)","\\d+\\.\\d+-?[kmg]b(ps|its?)"],conflict_solver:"lambda match, other: match if other.name == 'audio_channels' and 'weak-audio_channels' not in other.tags else other",formatter:"import:guessit.rules.common.quantity:BitRate.fromstring",tags:["release-group-prefix"]}}},bonus:{bonus:{_:{regex:"x(\\d+)",private_parent:!0,children:!0,formatter:"eval:int",validator:{__parent__:"import:seps_surround"},validate_all:!0,conflict_solver:"lambda match, conflicting: match if conflicting.name in ('video_codec', 'episode') and 'weak-episode' not in conflicting.tags else '__default__'"}}},cd:{_cd_of_cd_count:{regex:"(?<!\\d)(?<![^\\W\\d_])cd-?(?P<cd>\\d+)(?:-?of-?(?P<cd_count>\\d+))?",validator:{cd:"lambda match: 0 < match.value < 100",cd_count:"lambda match: 0 < match.value < 100"},formatter:{cd:"eval:int",cd_count:"eval:int"},children:!0,private_parent:!0,properties:{cd:[null],cd_count:[null]}},_cd_count:{regex:"(?P<cd_count>\\d+)-?cds?",validator:{cd:"lambda match: 0 < match.value < 100",cd_count:"lambda match: 0 < match.value < 100"},formatter:{cd_count:"eval:int"},children:!0,private_parent:!0,properties:{cd:[null],cd_count:[null]}}},container:{subtitles:["srt","idx","sub","ssa","ass"],info:["nfo"],videos:["3g2","3gp","3gp2","asf","avi","divx","flv","iso","m4v","mk2","mk3d","mka","mkv","mov","mp4","mp4a","mpeg","mpg","ogg","ogm","ogv","qt","ra","ram","rm","ts","m2ts","vob","wav","webm","wma","wmv"],torrent:["torrent"],nzb:["nzb"],archives:["rar","zip","7z","tar","gz","bz2","tgz","ace","arj","cbr","cbz","cb7"],images:["jpg","jpeg","png","gif","bmp","tbn","webp"]},country:{synonyms:{ES:["españa"],GB:["UK"],BR:["brazilian","bra"],CA:["québec","quebec","qc"],MX:["Latinoamérica","latin america"]}},edition:{edition:{Collector:{string:["collector"],regex:["collector'?s?-edition","edition-collector"]},Special:[{regex:["special-edition","edition-special"],conflict_solver:"lambda match, other: other if other.name == 'episode_details' and other.value == 'Special' else '__default__'"},{string:"se",tags:"has-neighbor"}],"Director's Definitive Cut":"ddc",Criterion:{string:["CC","Criterion"],regex:["criterion-edition","edition-criterion"]},Deluxe:{string:["deluxe"],regex:["deluxe-edition","edition-deluxe"]},Limited:{string:["limited"],regex:["limited-edition"],tags:["has-neighbor","release-group-prefix"]},Theatrical:{string:["theatrical"],regex:["theatrical-cut","theatrical-edition"]},"Director's Cut":{string:["DC"],regex:["director'?s?-cut","director'?s?-cut-edition","edition-director'?s?-cut"]},Extended:{string:["extended"],regex:["extended-?cut","extended-?version"],tags:["has-neighbor","release-group-prefix"]},"Alternative Cut":{regex:["alternat(e|ive)(?:-?Cut)?"],tags:["has-neighbor","release-group-prefix"]},Remastered:[{regex:"(?:4k.)?remaster(?:ed)?",tags:["release-group-prefix"]}],Restored:[{regex:"(?:4k.)?restore(?:d)?",tags:["release-group-prefix"]}],Uncensored:{string:"Uncensored",tags:["has-neighbor","release-group-prefix"]},Uncut:{string:"Uncut",tags:["has-neighbor","release-group-prefix"]},Unrated:{string:"Unrated",tags:["has-neighbor","release-group-prefix"]},Festival:{string:"Festival",tags:["has-neighbor-before","has-neighbor-after"]},IMAX:{string:["imax"],regex:["imax-edition"]},Fan:{regex:["fan-edit(?:ion)?","fan-collection"]},Ultimate:{regex:["ultimate-edition"]},_Ultimate_Collector:{regex:["ultimate-collector'?s?-edition"],value:["Ultimate","Collector"]},_Ultimate_Fan:{regex:["ultimate-fan-edit(?:ion)?","ultimate-fan-collection"],value:["Ultimate","Fan"]}}},episodes:{season_max_range:100,episode_max_range:100,max_range_gap:1,season_markers:["s","sn"],season_ep_markers:["x","×"],disc_markers:["d"],episode_markers:["xe","ex","ep","e","x","×"],range_separators:["-","~","to","a"],discrete_separators:["+","&","and","et"],season_words:["season","saison","seizoen","seasons","saisons","tem","temp",{value:"temporada",numfirst:!0},{value:"temporadas",numfirst:!0},"stagione",{value:"сезон",numfirst:!0},{value:"sezon",numfirst:!0},{value:"staffel",numfirst:!0},"sezonul","säsong","sesong","sæson",{value:"évad",numfirst:!0}],episode_words:["episode","episodes","épisode","épisodes","eps","ep","episodio","episodios","capitulo","capitulos",{value:"серия",numfirst:!0},{value:"серии",numfirst:!0},{value:"эпизод",numfirst:!0},{value:"seria",numfirst:!0},{value:"serii",numfirst:!0},{value:"serija",numfirst:!0},{value:"bölüm",numfirst:!0},{value:"bolum",numfirst:!0},"aflevering","afl","folge","odcinek","episodul","avsnitt",{value:"rész",numfirst:!0}],of_words:["of","sur","de","di","von","van","din","из"],all_words:["All"],ordinal_suffix:"(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?"},film:{film:{_f:{regex:"f(\\d{1,2})",name:"film",validate_all:!0,validator:{__parent__:"import:seps_surround"},private_parent:!0,children:!0,formatter:"eval:int"}}},language:{synonyms:{ell:["gr","greek"],spa:["esp","español","espanol"],fra:["français","vf","vff","vfi","vfq"],swe:["se"],por_BR:["po","pb","pob","ptbr","br","brazilian"],deu_CH:["swissgerman","swiss german"],nld_BE:["flemish"],cat:["català","castellano","espanol castellano","español castellano"],ces:["cz"],ukr:["ua"],zho:["cn"],jpn:["jp"],hrv:["scr"],mul:["multi","multiple","dl"]},subtitle_affixes:["sub","subs","subtitle","subtitles","esub","esubs","subbed","custom subbed","custom subs","custom sub","customsubbed","customsubs","customsub","soft subtitles","soft subs"],subtitle_prefixes:["st","vost","subforced","fansub","hardsub","legenda","legendas","legendado","subtitulado","soft"],subtitle_suffixes:["subforced","fansub","hardsub"],language_affixes:["dublado","dubbed","dub"],language_prefixes:["true"],language_suffixes:["audio"],weak_affixes:["v","audio","true","st"]},other:{other:{"Audio Fixed":{regex:["Audio-?Fix","Audio-?Fixed"]},"Sync Fixed":{regex:["Sync-?Fix","Sync-?Fixed"]},"Dual Audio":{string:["Dual"],regex:["Dual-?Audio"]},Widescreen:{string:["ws"],regex:["wide-?screen"]},Reencoded:{regex:["Re-?Enc(?:oded)?"]},_repack_with_count:{regex:["Repack(?P<proper_count>\\d*)","Rerip(?P<proper_count>\\d*)"],value:{other:"Proper"},tags:["streaming_service.prefix","streaming_service.suffix"]},Proper:[{string:"Proper",tags:["has-neighbor","streaming_service.prefix","streaming_service.suffix"]},{regex:["Real-Proper","Real-Repack","Real-Rerip"],tags:["streaming_service.prefix","streaming_service.suffix","real"]},{string:"Real",tags:["has-neighbor","streaming_service.prefix","streaming_service.suffix","real"]}],Fix:[{string:["Fix","Fixed"],tags:["has-neighbor-before","has-neighbor-after","streaming_service.prefix","streaming_service.suffix"]},{string:["Dirfix","Nfofix","Prooffix"],tags:["streaming_service.prefix","streaming_service.suffix"]},{regex:["(?:Proof-?)?Sample-?Fix"],tags:["streaming_service.prefix","streaming_service.suffix"]}],"Fan Subtitled":{string:"Fansub",tags:"has-neighbor"},"Fast Subtitled":{string:"Fastsub",tags:"has-neighbor"},"Region 5":"R5","Region C":"RC",Preair:{regex:"Pre-?Air"},"PS Vita":[{regex:"(?:PS-?)Vita"},{string:"Vita",tags:"has-neighbor"}],_HdRip:{value:{other:"HD",another:"Rip"},regex:["(HD)(?P<another>Rip)"],private_parent:!0,children:!0,validator:{__parent__:"import:seps_surround"},validate_all:!0},Screener:["Screener",{regex:"Scr(?:eener)?",validator:null,tags:["other.validate.screener","source-prefix","source-suffix"]}],Remux:"Remux",Hybrid:"Hybrid",PAL:"PAL",SECAM:"SECAM",NTSC:"NTSC",XXX:"XXX","2in1":"2in1","3D":{string:"3D",tags:"has-neighbor"},"Virtual Reality":{string:["VR","EAC360"],regex:["VR180","VR360","VR-180","VR-360"],tags:"has-neighbor"},"High Quality":{string:"HQ",tags:"uhdbluray-neighbor"},"High Resolution":"HR","Line Dubbed":"LD","Mic Dubbed":{string:"MD",tags:"title-word"},"Micro HD":{string:["mHD","HDLight"],regex:["micro-?hd","hd-?lite"]},"Low Definition":"LDTV","High Frame Rate":"HFR","Variable Frame Rate":"VFR",HD:{string:"HD",validator:null,tags:["streaming_service.prefix","streaming_service.suffix"]},"Full HD":{string:["FHD"],regex:["Full-?HD"],validator:null,tags:["streaming_service.prefix","streaming_service.suffix"]},"Ultra HD":{string:["UHD"],regex:["Ultra-?(?:HD)?"],validator:null,tags:["streaming_service.prefix","streaming_service.suffix"]},Upscaled:{regex:"Upscaled?"},Complete:{string:["Complet","Complete"],tags:["has-neighbor","release-group-prefix"]},Classic:{string:"Classic",tags:["has-neighbor","release-group-prefix"]},Bonus:{string:"Bonus",tags:["has-neighbor","release-group-prefix"]},Trailer:{string:"Trailer",tags:["has-neighbor","release-group-prefix"]},Retail:{string:"Retail",tags:["has-neighbor","release-group-prefix"]},Colorized:{string:"Colorized",tags:["has-neighbor","release-group-prefix"]},Internal:{string:"Internal",tags:["has-neighbor","release-group-prefix"]},"Line Audio":{string:"LiNE",tags:["has-neighbor-before","has-neighbor-after","release-group-prefix"]},"Read NFO":{regex:"Read-?NFO"},Converted:{string:"CONVERT",tags:"has-neighbor"},Documentary:{string:["DOCU","DOKU"],tags:"has-neighbor"},"Open Matte":{regex:"(?:OM|Open-?Matte)",tags:"has-neighbor"},"Straight to Video":{string:"STV",tags:"has-neighbor"},"Original Aspect Ratio":{string:"OAR",tags:"has-neighbor"},"East Coast Feed":{regex:"(?:Live-)?(?:Episode-)?East-?(?:Coast-)?Feed"},"West Coast Feed":{regex:"(?:Live-)?(?:Episode-)?West-?(?:Coast-)?Feed"},"Original Video":{string:["VO","OV"],tags:"has-neighbor"},"Original Animated Video":{string:["Ova","Oav"],tags:"title-word"},"Original Net Animation":"Ona","Original Animation DVD":"Oad",Mux:{string:"Mux",validator:"import:seps_after",tags:["other.validate.mux","video-codec-prefix","source-suffix"]},"Hardcoded Subtitles":["HC","vost"],"Standard Dynamic Range":{string:"SDR",tags:"uhdbluray-neighbor"},HDR10:{regex:"HDR(?:10)?",tags:"uhdbluray-neighbor"},"Dolby Vision":{regex:"(?:Dolby-?Vision|DoVi|DV)",tags:"uhdbluray-neighbor"},"BT.2020":{regex:"BT-?2020",tags:"uhdbluray-neighbor"},Sample:{string:"Sample",tags:["at-end","not-a-release-group"]},Extras:[{string:"Extras",tags:"has-neighbor"},{regex:"Digital-?Extras?"}],Proof:{string:"Proof",tags:["at-end","not-a-release-group"]},Obfuscated:{string:["Obfuscated","Scrambled"],tags:["at-end","not-a-release-group"]},Repost:{string:["xpost","postbot","asrequested"],tags:"not-a-release-group"},_complete_words:{callable:"import:guessit.rules.properties.other:complete_words",season_words:["seasons?","series?"],complete_article_words:["The"]},"Side By Side":{string:["SBS","LR"],tags:["has-neighbor","stereo-vr-context"]},"Over Under":{string:["TB","OU"],tags:["has-neighbor","stereo-vr-context"]},"Half Side By Side":{string:["HSBS"],regex:["h-?sbs","half-?sbs"],tags:"has-neighbor"},"Half Over Under":{string:["HOU","HTAB"],regex:["h-?ou","half-?ou","half-?tab"],tags:"has-neighbor"}}},part:{prefixes:["pt","part"]},release_group:{forbidden_names:["bonus","by","for","par","pour","rip"],ignored_seps:"[]{}()"},screen_size:{frame_rates:["23\\.976","24(?:\\.0{1,3})?","25(?:\\.0{1,3})?","29\\.970","30(?:\\.0{1,3})?","48(?:\\.0{1,3})?","50(?:\\.0{1,3})?","60(?:\\.0{1,3})?","120(?:\\.0{1,3})?"],min_ar:1.333,max_ar:1.898,interlaced:["360","480","540","576","900","1080"],progressive:["360","480","540","576","900","1080","368","720","1440","2160","4320"]},source:{rip_prefix:"(?P<other>Rip)-?",rip_suffix:"-?(?P<other>Rip)"},website:{safe_tlds:["com","net","org"],safe_subdomains:["www"],safe_prefixes:["co","com","net","org"],prefixes:["from"]},streaming_service:{"9Now":"9NOW","A&E":["AE","A&E"],ABC:"AMBC","ABC Australia":"AUBC","Al Jazeera English":"AJAZ",AMC:"AMC","Amazon Prime":["AMZN","AMZN-CBR","Amazon","re:Amazon-?Prime"],"Adult Swim":["AS","re:Adult-?Swim"],"America's Test Kitchen":"ATK","Animal Planet":"ANPL",AnimeLab:"ANLB",AOL:"AOL",AppleTV:["ATVP","ATV+","APTV"],ARD:"ARD","BBC iPlayer":["iP","re:BBC-?iPlayer"],Binge:"BNGE",Blackpills:"BKPL",BluTV:"BLU",Boomerang:"BOOM","Disney+":"DSNP",BravoTV:"BRAV","Canal+":"CNLP","Cartoon Network":"CN",CBC:"CBC",CBS:"CBS",CNBC:"CNBC","Comedy Central":["CC","re:Comedy-?Central"],"Channel 4":["ALL4","4OD"],CHRGD:"CHGD",Cinemax:"CMAX","Country Music Television":"CMT","Comedians in Cars Getting Coffee":"CCGC",Crave:"CRAV","Crunchy Roll":["CR","re:Crunchy-?Roll"],Crackle:"CRKL",CSpan:"CSPN",CTV:"CTV",CuriosityStream:"CUR",CWSeed:"CWS",Daisuki:"DSKI","DC Universe":"DCU","Deadhouse Films":"DHF",DramaFever:["DF","DramaFever"],"Digiturk Diledigin Yerde":"DDY",Discovery:["DISC","Discovery"],"Discovery Plus":"DSCP",Disney:["DSNY","Disney"],"DIY Network":"DIY","Doc Club":"DOCC",DPlay:"DPLY","E!":"ETV",ePix:"EPIX","El Trece":"ETTV",ESPN:"ESPN",Esquire:"ESQ","Facebook Watch":"FBWatch",Family:"FAM","Family Jr":"FJR",Fandor:"FANDOR","Food Network":"FOOD",Fox:"FOX","Fox Premium":"FOXP",Foxtel:"FXTL",Freeform:"FREE","FYI Network":"FYI",GagaOOLala:"Gaga",Global:"GLBL","GloboSat Play":"GLOB",Hallmark:"HLMK","HBO Go":["HBO","re:HBO-?Go"],"HBO Max":"HMAX",HGTV:"HGTV",History:["HIST","History"],Hulu:"HULU","Investigation Discovery":"ID",IFC:"IFC",hoichoi:"HoiChoi",iflix:"IFX",iQIYI:"iQIYI",iTunes:["iTunes",{pattern:"iT",ignore_case:!1}],ITV:"ITV","Knowledge Network":"KNOW",Lifetime:"LIFE","Motor Trend OnDemand":"MTOD",MBC:["MBC","MBCVOD"],MSNBC:"MNBC",MTV:"MTV",MUBI:"MUBI","National Audiovisual Institute":"INA","National Film Board":"NFB","National Geographic":["NATG","re:National-?Geographic"],"NBA TV":["NBA","re:NBA-?TV"],NBC:"NBC",Netflix:["NF","Netflix"],NFL:"NFL","NFL Now":"NFLN","NHL GameCenter":"GC",Nickelodeon:["NICK","Nickelodeon","NICKAPP"],"Norsk Rikskringkasting":"NRK",OnDemandKorea:["ODK","OnDemandKorea"],Opto:"OPTO","Oprah Winfrey Network":"OWN","Paramount+":["PMTP","PMNP","PMT+","Paramount+","ParamountPlus"],PBS:"PBS","PBS Kids":"PBSK",Peacock:["PCOK","Peacock"],"Playstation Network":"PSN",Pluzz:"PLUZ",PokerGO:"POGO","Rakuten TV":"RKTN","The Roku Channel":"ROKU","RTE One":"RTE",RUUTU:"RUUTU",SBS:"SBS","Science Channel":"SCI",SeeSo:["SESO","SeeSo"],Shomi:"SHMI",Showtime:"SHO",Sony:"SONY",Spike:"SPIK","Spike TV":["SPKE","re:Spike-?TV"],Sportsnet:"SNET",Sprout:"SPRT",Stan:"STAN",Starz:"STZ","Sveriges Television":"SVT",SwearNet:"SWER",Syfy:"SYFY",TBS:"TBS",TFou:"TFOU","The CW":["CW","re:The-?CW"],TLC:"TLC",TubiTV:"TUBI","TV3 Ireland":"TV3","TV4 Sweeden":"TV4",TVING:"TVING","TV Land":["TVL","re:TV-?Land"],TVNZ:"TVNZ",UFC:"UFC","UFC Fight Pass":"FP",UKTV:"UKTV",Univision:"UNIV","USA Network":"USAN",Velocity:"VLCT",VH1:"VH1",Viceland:"VICE",Viki:"VIKI",Vimeo:"VMEO",VRV:"VRV","W Network":"WNET",WatchMe:"WME","WWE Network":"WWEN","Xbox Video":"XBOX",Yahoo:"YHOO","YouTube Red":"RED",ZDF:"ZDF"},date:{week_words:["week"],weekday_words:["monday","tuesday","wednesday","thursday","friday","saturday","sunday","mon","tue","tues","wed","weds","thu","thur","thurs","fri","sat","sun"]}},Aa={expected_title:ml,allowed_countries:vl,allowed_languages:xl,advanced_config:_l};function We(u,e=!1){return u?typeof u=="object"&&!Array.isArray(u)?u:{}:{}}function Ga(u={}){const e=[];u.noDefaultConfig||e.push(Aa);const t=e.length>0?ve(...e):{};return"advanced_config"in t||(t.advanced_config=Aa.advanced_config),t}function ve(...u){let e={};if(u.length===0)return e;u[0]&&(e=bl(u[0]));for(const t of u.slice(1)){if(!t)continue;const n=t.pristine;if(n===!0)e={};else if(Array.isArray(n))for(const r of n)delete e[r];for(const[r,s]of Object.entries(t))yl(r,s,e)}return e}function yl(u,e,t){if(e!=null&&u!=="pristine"){const n=t[u];if(Array.isArray(n)&&Array.isArray(e))for(const r of e)!n.includes(r)&&r!==null&&n.push(r);else n!==null&&typeof n=="object"&&!Array.isArray(n)&&e!==null&&typeof e=="object"&&!Array.isArray(e)?t[u]=ve(n,e):Array.isArray(e)?t[u]=[...e]:t[u]=e}}function bl(u){return JSON.parse(JSON.stringify(u))}const Ka={absolute_episode:{type:["number"],array:!0,scalar:!0},alternative_title:{type:["string"],array:!0,scalar:!0},another:{type:["string"],array:!1,scalar:!1},aspect_ratio:{type:["number"],array:!1,scalar:!0},audio_bit_rate:{type:["string"],array:!1,scalar:!0},audio_channels:{type:["string"],array:!0,scalar:!0,enum:["1.0","1ch","2.0","20","2ch","5.1","5ch","6ch","7.1","7ch","8ch","mono","stereo"]},audio_codec:{type:["string"],array:!0,scalar:!0,enum:["AAC","Atmos","DD+","DDP","Dolby","Dolby Atmos","Dolby Digital","Dolby Digital Plus","Dolby TrueHD","DolbyDigital","DTS","DTS-HD","DTS-X","DTS:X","DTSX","Flac","FLAC","LAME","LPCM","MP2","MP3","Opus","PCM","Vorbis"]},audio_profile:{type:["string"],array:!0,scalar:!0,enum:["ES","EX","Extended Surround","HE","High Efficiency","High Quality","High Resolution Audio","HQ","HR","HRA","LC","Low Complexity","MA","Master Audio"]},bonus:{type:["number"],array:!1,scalar:!0},bonus_title:{type:["string"],array:!1,scalar:!0},cd:{type:["number"],array:!1,scalar:!0},cd_count:{type:["number"],array:!1,scalar:!0},color_depth:{type:["string"],array:!1,scalar:!0,enum:["10-bit","12-bit","8-bit"]},container:{type:["string"],array:!0,scalar:!0,enum:["3g2","3gp","3gp2","7z","ace","arj","asf","avi","bmp","bz2","cb7","cbr","cbz","divx","flv","gif","gz","idx","iso","jpeg","jpg","m2ts","m4v","mk2","mk3d","mka","mkv","MKV","mov","mp4","mp4a","mpeg","mpg","nfo","nzb","ogg","ogm","ogv","png","qt","r00","ra","ram","rar","rm","srt","ssa","tar","tbn","tgz","torrent","ts","vob","wav","webm","webp","wma","wmv","zip"]},country:{type:["Language"],array:!1,scalar:!0},crc32:{type:["string"],array:!1,scalar:!0},date:{type:["object"],array:!1,scalar:!0},disc:{type:["number"],array:!0,scalar:!0},edition:{type:["string"],array:!0,scalar:!0,enum:["Alternative Cut","CC","collector","Collector","Criterion","DC","ddc","deluxe","Deluxe","Director's Cut","Director's Definitive Cut","extended","Extended","Fan","Festival","imax","IMAX","limited","Limited","Remastered","Restored","se","Special","theatrical","Theatrical","Ultimate","Uncensored","Uncut","Unrated"]},episode:{type:["number"],array:!0,scalar:!0},episode_count:{type:["number"],array:!1,scalar:!0},episode_details:{type:["string"],array:!0,scalar:!0},episode_format:{type:["string"],array:!1,scalar:!0,enum:["Minisode"]},episode_title:{type:["string"],array:!1,scalar:!0},film:{type:["number"],array:!1,scalar:!0},film_title:{type:["string"],array:!1,scalar:!0},frame_rate:{type:["string"],array:!1,scalar:!0},language:{type:["Language"],array:!0,scalar:!0},mimetype:{type:["string"],array:!1,scalar:!0,enum:["application/x-bittorrent","application/x-iso9660-image","application/x-rar-compressed","application/zip","image/gif","image/jpeg","image/png","text/plain","video/mp2t","video/mp4","video/webm","video/x-matroska","video/x-msvideo"]},other:{type:["string"],array:!0,scalar:!0,enum:["2in1","3D","asrequested","Audio Fixed","Banner","Bonus","BT.2020","Classic","Clear Art","Clear Logo","Colorized","Complet","Complete","CONVERT","Converted","Cover","Dirfix","Disc Art","DOCU","Documentary","DOKU","Dolby Vision","Dual","Dual Audio","East Coast Feed","Extras","Fan Subtitled","Fanart","Fansub","Fast Subtitled","Fastsub","FHD","Fix","Fixed","Full HD","Half Over Under","Half Side By Side","Hardcoded Subtitles","HC","HD","HDLight","HDR10","HFR","High Frame Rate","High Quality","High Resolution","HQ","HR","Hybrid","Internal","Landscape","LD","LDTV","LiNE","Line Audio","Line Dubbed","Logo","Low Definition","MD","mHD","Mic Dubbed","Micro HD","Mux","Nfofix","NTSC","Oad","OAR","Oav","Obfuscated","Ona","Open Matte","Original Animated Video","Original Animation DVD","Original Aspect Ratio","Original Net Animation","Original Video","OV","Ova","Over Under","PAL","postbot","Poster","Preair","Proof","Prooffix","Proper","PS Vita","R5","RC","Read NFO","Real","Reencoded","Region 5","Region C","Remux","Repost","Retail","Rip","Sample","Scrambled","Screener","SDR","SECAM","Side By Side","Standard Dynamic Range","Straight to Video","STV","Sync Fixed","Thumbnail","Trailer","UHD","Ultra HD","Upscaled","Variable Frame Rate","VFR","Virtual Reality","Vita","VO","vost","West Coast Feed","Widescreen","ws","xpost","XXX"]},part:{type:["number"],array:!0,scalar:!0},proper_count:{type:["number"],array:!1,scalar:!0},release_group:{type:["string"],array:!1,scalar:!0},screen_size:{type:["string"],array:!1,scalar:!0,enum:["1080i","1080p","1440p","1444x866","2160p","360p","368p","480p","4k","540p","576p","720p","720x432","960x544"]},season:{type:["number"],array:!0,scalar:!0},season_count:{type:["number"],array:!1,scalar:!0},size:{type:["string"],array:!1,scalar:!0},source:{type:["string"],array:!1,scalar:!0,enum:["Analog HDTV","Blu-ray","Camera","Digital Master","Digital TV","DVD","HD Camera","HD Telecine","HD Telesync","HD-DVD","HDTV","Laserdisc","Pay-per-view","Satellite","Telecine","Telesync","TV","Ultra HD Blu-ray","Ultra HDTV","VHS","Video on Demand","Web","Workprint"]},streaming_service:{type:["string"],array:!1,scalar:!0,enum:["4OD","9Now","9NOW","A&E","ABC","ABC Australia","Adult Swim","AE","AJAZ","Al Jazeera English","ALL4","Amazon","Amazon Prime","AMBC","AMC","America's Test Kitchen","AMZN","AMZN-CBR","Animal Planet","AnimeLab","ANLB","ANPL","AOL","AppleTV","APTV","ARD","AS","ATK","ATV+","ATVP","AUBC","BBC iPlayer","Binge","BKPL","Blackpills","BLU","BluTV","BNGE","BOOM","Boomerang","BRAV","BravoTV","Canal+","Cartoon Network","CBC","CBS","CC","CCGC","Channel 4","CHGD","CHRGD","Cinemax","CMAX","CMT","CN","CNBC","CNLP","Comedians in Cars Getting Coffee","Comedy Central","Country Music Television","CR","Crackle","CRAV","Crave","CRKL","Crunchy Roll","CSpan","CSPN","CTV","CUR","CuriosityStream","CW","CWS","CWSeed","Daisuki","DC Universe","DCU","DDY","Deadhouse Films","DF","DHF","Digiturk Diledigin Yerde","DISC","Discovery","Discovery Plus","Disney","Disney+","DIY","DIY Network","Doc Club","DOCC","DPlay","DPLY","DramaFever","DSCP","DSKI","DSNP","DSNY","E!","El Trece","ePix","EPIX","ESPN","ESQ","Esquire","ETTV","ETV","Facebook Watch","FAM","Family","Family Jr","Fandor","FANDOR","FBWatch","FJR","FOOD","Food Network","Fox","FOX","Fox Premium","FOXP","Foxtel","FP","FREE","Freeform","FXTL","FYI","FYI Network","Gaga","GagaOOLala","GC","GLBL","GLOB","Global","GloboSat Play","Hallmark","HBO","HBO Go","HBO Max","HGTV","HIST","History","HLMK","HMAX","hoichoi","HoiChoi","Hulu","HULU","ID","IFC","iflix","IFX","INA","Investigation Discovery","iP","iQIYI","iT","iTunes","ITV","KNOW","Knowledge Network","LIFE","Lifetime","MBC","MBCVOD","MNBC","Motor Trend OnDemand","MSNBC","MTOD","MTV","MUBI","NATG","National Audiovisual Institute","National Film Board","National Geographic","NBA","NBA TV","NBC","Netflix","NF","NFB","NFL","NFL Now","NFLN","NHL GameCenter","NICK","NICKAPP","Nickelodeon","Norsk Rikskringkasting","NRK","ODK","OnDemandKorea","Oprah Winfrey Network","Opto","OPTO","OWN","Paramount+","ParamountPlus","PBS","PBS Kids","PBSK","PCOK","Peacock","Playstation Network","PLUZ","Pluzz","PMNP","PMT+","PMTP","POGO","PokerGO","PSN","Rakuten TV","RED","RKTN","ROKU","RTE","RTE One","RUUTU","SBS","SCI","Science Channel","SeeSo","SESO","SHMI","SHO","Shomi","Showtime","SNET","Sony","SONY","SPIK","Spike","Spike TV","SPKE","Sportsnet","Sprout","SPRT","Stan","STAN","Starz","STZ","Sveriges Television","SVT","SwearNet","SWER","Syfy","SYFY","TBS","TFou","TFOU","The CW","The Roku Channel","TLC","TUBI","TubiTV","TV Land","TV3","TV3 Ireland","TV4","TV4 Sweeden","TVING","TVL","TVNZ","UFC","UFC Fight Pass","UKTV","UNIV","Univision","USA Network","USAN","Velocity","VH1","VICE","Viceland","Viki","VIKI","Vimeo","VLCT","VMEO","VRV","W Network","WatchMe","WME","WNET","WWE Network","WWEN","XBOX","Xbox Video","Yahoo","YHOO","YouTube Red","ZDF"]},subtitle_language:{type:["Language"],array:!0,scalar:!0},title:{type:["string"],array:!1,scalar:!0},type:{type:["string"],array:!1,scalar:!0,enum:["episode","movie"]},uuid:{type:["string"],array:!1,scalar:!0},version:{type:["number"],array:!1,scalar:!0},video_api:{type:["string"],array:!1,scalar:!0,enum:["DXVA"]},video_bit_rate:{type:["string"],array:!1,scalar:!0},video_codec:{type:["string"],array:!1,scalar:!0,enum:["DivX","DVDivX","H.263","H.264","H.265","MPEG-2","RealVideo","VC-1","VP7","VP8","VP80","VP9","Xvid","XviD"]},video_profile:{type:["string"],array:!0,scalar:!0,enum:["Advanced Video Codec High Definition","Baseline","BP","EP","Extended","HEVC","High","High 10","High 4:2:2","High 4:4:4 Predictive","High Efficiency Video Coding","HiP","HP","Main","MP","SC","Scalable Video Coding","SVC","XP"]},website:{type:["string"],array:!1,scalar:!0},year:{type:["number"],array:!1,scalar:!0}};class Tr extends Error{constructor(e,t,n){const r=n instanceof Error?n.message:String(n);super(`An internal error has occurred in guessit.
1
+ "use strict";var mo=Object.defineProperty;var oc=(d,e,t)=>e in d?mo(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var p=(d,e)=>mo(d,"name",{value:e,configurable:!0});var _=(d,e,t)=>oc(d,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function vo(d){return d}p(vo,"defaultFormatter");function At(...d){return e=>{let t=e;for(const n of d)t=n(t);return t}}p(At,"formatters");function Wo(d){return d?Array.isArray(d)?d:[d]:[]}p(Wo,"ensureList");function Dr(d,e,t=null){return d||(d=e),typeof d!="object"||d===null||Array.isArray(d)?(d&&(e=d),[{[t??void 0]:d},e]):[d,e]}p(Dr,"ensureDict");function W(d,e,t){typeof e=="number"&&(t=e,e=null);let n=e?d.filter(e):[...d];return t!=null?t<0?n[n.length+t]:n[t]:n}p(W,"filterIndex");function q(d,e,t=!1){if("clear"in d&&d.clear){for(const n of Object.keys(e))delete e[n];delete d.clear}for(const[n,s]of Object.entries(d)){if(n in e){if(Array.isArray(s)&&Array.isArray(e[n])){e[n]=[...s,...e[n]];continue}if(s&&typeof s=="object"&&!Array.isArray(s)&&e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])){q(s,e[n]);continue}}(!(n in e)||t)&&(e[n]=s)}}p(q,"setDefaults");function qo(d){return d==null||typeof d=="string"?!1:typeof d[Symbol.iterator]=="function"}p(qo,"isIterable");function*Nr(d,e,t=0,n,s=!1){let r=d,a=e;s&&(r=r.toLowerCase(),a=a.toLowerCase());const i=n!==void 0?n:r.length;let o=t;for(;;){const c=r.indexOf(a,o);if(c===-1||c>=i)return;yield c,o=c+a.length}}p(Nr,"findAll");function Cr(d,e,t=void 0){for(const n of e)if(n!=null&&n in d)return d[n];return t}p(Cr,"getFirstDefined");function cc(d,e){for(const t of e)d.includes(t)||d.push(t)}p(cc,"extendSafe");const bi=class bi{constructor(e){_(this,"_map",new Map);if(e)for(const t of e)this.add(t)}add(e){return this._map.set(e,!0),this}delete(e){return this._map.delete(e)}has(e){return this._map.has(e)}get size(){return this._map.size}[Symbol.iterator](){return this._map.keys()}};p(bi,"IdentitySet");let Pr=bi;function xo(d){return!0}p(xo,"alwaysTrue");function lc(d,e){if(!e.inputString)return!0;const t=e.start-1;return t<0?!0:d.includes(e.inputString[t])}p(lc,"charsBefore");function uc(d,e){if(!e.inputString)return!0;const t=e.end;return t>=e.inputString.length?!0:d.includes(e.inputString[t])}p(uc,"charsAfter");const Zt=class Zt{constructor(e,t,n={}){_(this,"start");_(this,"end");_(this,"name");_(this,"tags");_(this,"marker");_(this,"private");_(this,"inputString");_(this,"formatter");_(this,"pattern");_(this,"parent");_(this,"conflictSolver");_(this,"defined_at");_(this,"matchIndex",0);_(this,"_value");_(this,"_children");_(this,"_rawStart");_(this,"_rawEnd");this.start=e,this.end=t,this.name=n.name,this.tags=Wo(n.tags),this.marker=n.marker??!1,this.private=n.private??!1,this.inputString=n.inputString,this.formatter=n.formatter,this._value=n.value,this.conflictSolver=n.conflictSolver,this.pattern=n.pattern,this.parent=n.parent,this.defined_at=n.pattern?n.pattern.defined_at:void 0}get span(){return[this.start,this.end]}get rawStart(){return this._rawStart!==void 0?this._rawStart:this.start}set rawStart(e){this._rawStart=e}get rawEnd(){return this._rawEnd!==void 0?this._rawEnd:this.end}set rawEnd(e){this._rawEnd=e}get raw(){if(this.inputString!==void 0)return this.inputString.slice(this.rawStart,this.rawEnd)}get value(){return this._value?this._value:this.formatter&&typeof this.formatter=="function"?this.formatter(this.raw??""):this.raw}set value(e){this._value=e}get children(){return this._children||(this._children=new ve(void 0,this.inputString)),this._children}set children(e){this._children=e}get names(){if(!this._children||this._children.length===0)return this.name?new Set([this.name]):new Set;const e=new Set;for(const t of this._children)for(const n of t.names)e.add(n);return e}get initiator(){let e=this;for(;e.parent;)e=e.parent;return e}get length(){return this.end-this.start}tagged(...e){return e.some(t=>this.tags.includes(t))}named(...e){return e.some(t=>this.names.has(t))}crop(e,t,n){const s=Array.isArray(e)&&e.length===2&&typeof e[0]=="number"?[e]:Array.isArray(e)?e:[e];let a=[this._clone()];for(const i of s){const[o,c]="span"in i?i.span:i;for(const l of[...a])if(o<=l.start&&c>=l.end)a.splice(a.indexOf(l),1);else if(o>=l.start&&c<=l.end){const u=l._clone();l.end=o,l.length===0&&a.splice(a.indexOf(l),1),u.start=c,u.length>0&&a.push(u)}else l.end>=c&&c>l.start?l.start=c:l.start<=o&&o<l.end&&(l.end=o)}return W(a,t??null,n??null)}split(e,t,n){const s=[];let r=null;for(let a=0;a<(this.raw?.length??0);a++){const i=this.raw[a];if(e.includes(i)){if(r!==null){const o=this._clone();o.start=this.start+r,o.end=this.start+a,s.push(o),r=null}}else r===null&&(r=a)}if(r!==null){const a=this._clone();a.start=this.start+r,s.push(a)}return W(s,t??null,n??null)}clone(){return this._clone()}_clone(){const e=new Zt(this.start,this.end,{name:this.name,tags:[...this.tags],marker:this.marker,private:this.private,inputString:this.inputString,formatter:this.formatter,value:this._value,conflictSolver:this.conflictSolver,pattern:this.pattern,parent:this.parent});return e.matchIndex=this.matchIndex,e._rawStart=this._rawStart,e._rawEnd=this._rawEnd,e}equals(e){return this.start===e.start&&this.end===e.end&&this.value===e.value&&this.name===e.name&&this.parent===e.parent}toString(){let e="";const t=this.initiator.value;t!==this.value&&(e+=`+initiator=${String(t)}`),this.private&&(e+="+private");const n=this.name?`+name=${this.name}`:"",s=this.tags.length?`+tags=${JSON.stringify(this.tags)}`:"",r=this.defined_at?`@${this.defined_at.filename.split("/").pop()}#L${this.defined_at.lineno}`:"";return`<${String(this.value)}:(${this.start}, ${this.end})${e}${n}${s}${r}>`}};p(Zt,"Match");let N=Zt;const wi=class wi extends Map{constructor(){super(...arguments);_(this,"matches",new Map);_(this,"valuesList",new Map)}};p(wi,"MatchesDict");let Or=wi;const Si=class Si{constructor(e,t){_(this,"inputString");_(this,"_delegate",[]);_(this,"_maxEnd",0);_(this,"_nameDict",null);_(this,"_tagDict",null);_(this,"_startDict",null);_(this,"_endDict",null);_(this,"_indexDict",null);this.inputString=t,e&&this.extend(e)}get length(){return this._delegate.length}[Symbol.iterator](){return this._delegate[Symbol.iterator]()}toArray(){return[...this._delegate]}get matches(){return[...this._delegate]}get nameDict(){if(!this._nameDict){this._nameDict=new Map;for(const e of this._delegate)if(e.name){const t=this._nameDict.get(e.name)??[];t.push(e),this._nameDict.set(e.name,t)}}return this._nameDict}get startDict(){if(!this._startDict){this._startDict=new Map;for(const e of this._delegate){const t=this._startDict.get(e.start)??[];t.push(e),this._startDict.set(e.start,t)}}return this._startDict}get endDict(){if(!this._endDict){this._endDict=new Map;for(const e of this._delegate){const t=this._endDict.get(e.end)??[];t.push(e),this._endDict.set(e.end,t)}}return this._endDict}get tagDict(){if(!this._tagDict){this._tagDict=new Map;for(const e of this._delegate)for(const t of e.tags){const n=this._tagDict.get(t)??[];n.push(e),this._tagDict.set(t,n)}}return this._tagDict}get indexDict(){if(!this._indexDict){this._indexDict=new Map;for(const e of this._delegate)for(let t=e.start;t<e.end;t++){const n=this._indexDict.get(t)??[];n.push(e),this._indexDict.set(t,n)}}return this._indexDict}get maxEnd(){return this.inputString?Math.max(this.inputString.length,this._maxEnd):this._maxEnd}_addMatch(e){if(this._nameDict&&e.name){const t=this._nameDict.get(e.name)??[];t.push(e),this._nameDict.set(e.name,t)}if(this._tagDict)for(const t of e.tags){const n=this._tagDict.get(t)??[];n.push(e),this._tagDict.set(t,n)}if(this._startDict){const t=this._startDict.get(e.start)??[];t.push(e),this._startDict.set(e.start,t)}if(this._endDict){const t=this._endDict.get(e.end)??[];t.push(e),this._endDict.set(e.end,t)}if(this._indexDict)for(let t=e.start;t<e.end;t++){const n=this._indexDict.get(t)??[];n.push(e),this._indexDict.set(t,n)}e.end>this._maxEnd&&(this._maxEnd=e.end)}_removeMatch(e){if(this._nameDict&&e.name){const t=this._nameDict.get(e.name);if(t){const n=t.findIndex(s=>s===e);n!==-1&&t.splice(n,1)}}if(this._tagDict)for(const t of e.tags){const n=this._tagDict.get(t);if(n){const s=n.findIndex(r=>r===e);s!==-1&&n.splice(s,1)}}if(this._startDict){const t=this._startDict.get(e.start);if(t){const n=t.findIndex(s=>s===e);n!==-1&&t.splice(n,1)}}if(this._endDict){const t=this._endDict.get(e.end);if(t){const n=t.findIndex(s=>s===e);n!==-1&&t.splice(n,1)}}if(this._indexDict)for(let t=e.start;t<e.end;t++){const n=this._indexDict.get(t);if(n){const s=n.findIndex(r=>r===e);s!==-1&&n.splice(s,1)}}if(e.end>=this._maxEnd){this._maxEnd=0;for(const t of this._delegate)t.end>this._maxEnd&&(this._maxEnd=t.end)}}append(e){this._delegate.push(e),this._addMatch(e)}extend(e){for(const t of e)this.append(t)}remove(e){const t=this._delegate.findIndex(n=>n===e);t!==-1&&(this._delegate.splice(t,1),this._removeMatch(e))}includes(e){return this._delegate.some(t=>t===e||t.equals(e))}at(e){return this._delegate[e]}get(e){return this._delegate[e]}clear(){this._delegate.length=0,this._nameDict=null,this._tagDict=null,this._startDict=null,this._endDict=null,this._indexDict=null,this._maxEnd=0}slice(e,t){return new ve(this._delegate.slice(e,t),this.inputString)}deleteSlice(e,t){const n=this._delegate.splice(e,t-e);for(const s of n)this._removeMatch(s)}setSlice(e,t,...n){const s=this._delegate.splice(e,t-e,...n);for(const r of s)this._removeMatch(r);for(const r of n)this._addMatch(r)}setAt(e,t){const n=this._delegate[e];n&&this._removeMatch(n),this._delegate[e]=t,this._addMatch(t)}insert(e,t){this._delegate.splice(e,0,t),this._addMatch(t)}sort(){return[...this._delegate].sort((e,t)=>e.start!==t.start?e.start-t.start:e.end-t.end)}named(e,t,n){const s=this.nameDict.get(e)??[];return W(s,t,n)}tagged(e,t,n){const s=this.tagDict.get(e)??[];return W(s,t,n)}starting(e,t,n){const s=this.startDict.get(e)??[];return W(s,t,n)}ending(e,t,n){const s=this.endDict.get(e)??[];return W(s,t,n)}atIndex(e,t,n){const s=this.indexDict.get(e)??[];return W(s,t,n)}atSpan(e,t,n){const s=this.indexDict.get(e[0])??[],r=this.indexDict.get(e[1]-1)??[],a=[...s];for(const i of r)a.includes(i)||a.push(i);return W(a,t,n)}atMatch(e,t,n){return this.atSpan(e.span,t,n)}range(e=0,t,n,s){const r=t!==void 0?Math.min(this.maxEnd,t):this.maxEnd,a=[];for(const i of this.sort())i.start<r&&i.end>e&&(!n||n(i))&&a.push(i);return W(a,null,s)}previous(e,t,n){let s=e.start;for(;s>-1;){const r=this.ending(s);if(r.length>0)return W(r,t,n);s--}return W([],t,n)}next(e,t,n){let s=e.start+1;for(;s<=this.maxEnd;){const r=this.starting(s);if(r.length>0)return W(r,t,n);s++}return W([],t,n)}conflicting(e,t,n){const s=[],r=new Set;for(let a=e.start;a<e.end;a++)for(const i of this.indexDict.get(a)??[])i!==e&&!r.has(i)&&(r.add(i),s.push(i));return W(s,t,n)}chainBefore(e,t,n=0,s,r){const a=typeof e=="number"?e:e.start,i=[];for(let o=Math.min(this.maxEnd,a)-1;o>=n;o--){const c=this.indexDict.get(o)??[],l=s?c.filter(s):[...c];if(l.length>0)for(const u of l)i.includes(u)||i.push(u);else if(!this.inputString||!t.includes(this.inputString[o]))break}return W(i,null,r)}chainAfter(e,t,n,s,r){const a=typeof e=="number"?e:e.end,i=n!==void 0?Math.min(this.maxEnd,n):this.maxEnd,o=[];for(let c=a;c<i;c++){const l=this.indexDict.get(c)??[],u=s?l.filter(s):[...l];if(u.length>0)for(const f of u)o.includes(f)||o.push(f);else if(!this.inputString||!t.includes(this.inputString[c]))break}return W(o,null,r)}holes(e=0,t,n={}){const{formatter:s,ignore:r,seps:a,predicate:i,index:o}=n,c=t!==void 0?Math.min(this.maxEnd,t):this.maxEnd,l=[];let u=!1,f=0;for(let h=e-1;h>=0;h--){const x=this.starting(h);let m=!1;for(const v of x)if(!r||!r(v)){f=h,m=!0;break}if(m)break}for(let h=f;h<c;h++){const x=this.indexDict.get(h)??[],m=r?x.filter(v=>!r(v)):[...x];a&&u&&this.inputString&&a.includes(this.inputString[h])?(u=!1,l[l.length-1].end=h):m.length===0&&!u?(u=!0,l.push(new N(Math.max(h,e),0,{inputString:this.inputString,formatter:s}))):m.length>0&&u&&(u=!1,l[l.length-1].end=h)}if(l.length>0&&u){let h=this.maxEnd;const x=c>f?c-1:f;for(let m=x;m<this.maxEnd;m++){const v=this.starting(m);let C=!1;for(const w of v)if(!r||!r(w)){h=m,C=!0;break}if(C)break}l[l.length-1].end=Math.min(h,c)}const g=l.filter(h=>h.end>h.start);return W(g,i??null,o??null)}get names(){return new Set(this.nameDict.keys())}get allTags(){return new Set(this.tagDict.keys())}toDict(e=!1,t=!1,n=!1){const s=new Or;for(const r of this.sort()){const a=e?r:r.value,i=s.matches.get(r.name??"")??[];i.push(r),s.matches.set(r.name??"",i);const o=p((l,u)=>e&&l instanceof N&&u instanceof N?l.equals(u):l===u,"valEquals");if(!n){const l=s.valuesList.get(r.name??"")??[];l.some(u=>o(u,a))||l.push(a),s.valuesList.set(r.name??"",l)}const c=s.get(r.name??"");c!==void 0?t||(Array.isArray(c)?c.some(l=>o(l,a))||c.push(a):o(c,a)||s.set(r.name,[c,a])):s.set(r.name,n&&!Array.isArray(a)?[a]:a)}return s}toString(){return`[${this._delegate.map(String).join(", ")}]`}};p(Si,"_BaseMatches");let $t=Si;const Ai=class Ai extends $t{constructor(t,n){super(void 0,n);_(this,"markers");this.markers=new Ir(void 0,n),t&&this.extend(t)}_addMatch(t){if(t.marker)throw new Error("A marker match should not be added to Matches");super._addMatch(t)}};p(Ai,"Matches");let ve=Ai;const ki=class ki extends $t{constructor(e,t){super(void 0,t),e&&this.extend(e)}_addMatch(e){if(!e.marker)throw new Error("A non-marker match should not be added to Markers");super._addMatch(e)}};p(ki,"Markers");let Ir=ki;function Ie(d,e=!1){const t={...d};return delete t.pattern,delete t.start,delete t.end,delete t.parent,delete t.formatter,delete t.value,e&&delete t.name,t}p(Ie,"filterMatchKwargs");function dc(d){return d.replace(/\(\?P</g,"(?<")}p(dc,"convertPythonNamedGroups");function pc(d,e){let t=d;for(const[n,s]of e)t=t.split(n).join(s);return t}p(pc,"applyAbbreviations");function fc(d,e){let t=dc(d);e.abbreviations&&(t=pc(t,e.abbreviations));let n=e.flags??"";return e.ignoreCase&&!n.includes("i")&&(n+="i"),n.includes("g")||(n+="g"),n.includes("d")||(n+="d"),new RegExp(t,n)}p(fc,"compileRegex");function yo(d){const e=[];let t=0;for(;t<d.length;){if(d[t]==="\\"){t+=2;continue}if(d[t]==="["){for(t++;t<d.length&&d[t]!=="]";)d[t]==="\\"&&t++,t++;t++;continue}if(d[t]==="("){if(d[t+1]!=="?")e.push(void 0);else if(d[t+2]==="<"){const r=d[t+3];if(r!=="="&&r!=="!"){const a=d.indexOf(">",t+3);e.push(a!==-1?d.slice(t+3,a):void 0)}}}t++}return e}p(yo,"buildGroupNames");const Di=class Di{};p(Di,"BasePattern");let Ht=Di;const Ve=class Ve extends Ht{constructor(t={}){super();_(this,"name");_(this,"tags");_(this,"formatters");_(this,"defaultFormatterFn");_(this,"values");_(this,"defaultValue");_(this,"validators");_(this,"defaultValidator");_(this,"children");_(this,"every");_(this,"private_");_(this,"privateNames");_(this,"ignoreNames");_(this,"privateParent");_(this,"privateChildren");_(this,"marker");_(this,"formatAll");_(this,"validateAll");_(this,"disabled");_(this,"logLevel");_(this,"properties_");_(this,"postProcessor");_(this,"preMatchProcessor");_(this,"postMatchProcessor");_(this,"defined_at");_(this,"_opts");this._opts=t,this.name=t.name,this.tags=Wo(t.tags);const[n,s]=Dr(t.formatter,vo);this.formatters=n,this.defaultFormatterFn=s??vo;const[r,a]=Dr(t.value,void 0);this.values=r,this.defaultValue=a;const[i,o]=Dr(t.validator,xo);this.validators=i,this.defaultValidator=o??xo,this.every=t.every??!1,this.children=t.children??!1,this.private_=t.private??!1,this.privateNames=t.privateNames??[],this.ignoreNames=t.ignoreNames??[],this.privateParent=t.privateParent??!1,this.privateChildren=t.privateChildren??!1,this.marker=t.marker??!1,this.formatAll=t.formatAll??!1,this.validateAll=t.validateAll??!1;const c=t.disabled;typeof c=="function"?this.disabled=c:typeof c=="boolean"?this.disabled=()=>c:this.disabled=()=>!1,this.logLevel=t.logLevel??0,this.properties_=t.properties,this.postProcessor=typeof t.postProcessor=="function"?t.postProcessor:void 0,this.preMatchProcessor=typeof t.preMatchProcessor=="function"?t.preMatchProcessor:void 0,this.postMatchProcessor=typeof t.postMatchProcessor=="function"?t.postMatchProcessor:void 0,this.defined_at=void 0}get shouldIncludeChildren(){return this.children||this.every}get shouldIncludeParent(){return!this.children||this.every}_matchConfigPropertyKeys(t,n=!1){const s=[];return t.name&&s.push(t.name),s.push(n?"__children__":"__parent__"),s.push(null),s}_processMatchPrivate(t,n=!1){(t.name&&this.privateNames.includes(t.name)||!n&&this.privateParent||n&&this.privateChildren)&&(t.private=!0)}_processMatchValue(t,n=!1){const s=this._matchConfigPropertyKeys(t,n),r=Cr(this.values,s,this.defaultValue);r!=null&&(t.value=r)}_processMatchFormatter(t,n=!1){if((n?this.shouldIncludeChildren:this.shouldIncludeParent)||this.formatAll){const r=this._matchConfigPropertyKeys(t,n);t.formatter=Cr(this.formatters,r,this.defaultFormatterFn)}}_processMatchValidator(t,n=!1){if((n?this.shouldIncludeChildren:this.shouldIncludeParent)||this.validateAll){const r=this._matchConfigPropertyKeys(t,n),a=Cr(this.validators,r,this.defaultValidator);if(a&&!a(t))return!1}return!0}_processMatch(t,n,s=!1){return t.matchIndex=n,this._processMatchPrivate(t,s),this._processMatchValue(t,s),this._processMatchFormatter(t,s),this._processMatchValidator(t,s)}static _applyProcessor(t,n){if(!n||!t)return t;const s=n(t);return s!==void 0?s:t}*_processMatches(t,n){const s=Ve._applyProcessor(t,this.preMatchProcessor);if(!s||!this._processMatch(s,n))return;for(const a of s.children)if(!this._processMatch(a,n,!0))return;const r=Ve._applyProcessor(s,this.postMatchProcessor);if(r&&((this.shouldIncludeParent||this.privateParent)&&!this.ignoreNames.includes(r.name??"")&&(yield r),this.shouldIncludeChildren||this.privateChildren))for(const a of r.children)this.ignoreNames.includes(a.name??"")||(yield a)}_postProcessMatches(t){return this.postProcessor?this.postProcessor(t,this):t}matches(t,n,s=!1){const r=[],a=[];for(const o of this.patterns){let c=0;for(const l of this._match(o,t,n)){a.push(l);for(const u of this._processMatches(l,c))r.push(u);c++}}const i=this._postProcessMatches(r);return s?[i,a]:i}get properties(){return this.properties_??{}}};p(Ve,"Pattern");let Le=Ve;const Ci=class Ci extends Le{constructor(t,...n){var e=(...Mu)=>(super(...Mu),_(this,"_patterns"),_(this,"_matchKwargs"),this);typeof t=="string"?(e({}),this._patterns=[t,...n],this._matchKwargs=Ie({})):(e(t),this._patterns=n,this._matchKwargs=Ie(t))}get patterns(){return this._patterns}get matchOptions(){return this._matchKwargs}*_match(t,n,s){const r=(this._opts.ignoreCase??!1)||(this._opts.flags?.includes("i")??!1),a=this._opts.start??0,i=this._opts.end??void 0;for(const o of Nr(n,t,a,i,r)){const c=new N(o,o+t.length,{...this._matchKwargs,pattern:this,inputString:n});c.length>0&&(yield c)}}toString(){return`<StringPattern:(${this._patterns.map(t=>`'${t}'`).join(", ")})>`}};p(Ci,"StringPattern");let Tt=Ci;const Mi=class Mi extends Le{constructor(t,...n){super(t);_(this,"_regexes");_(this,"_matchKwargs");_(this,"_childrenMatchKwargs");_(this,"_groupNamesList");this._matchKwargs=Ie(t),this._childrenMatchKwargs=Ie(t,!0),this._regexes=[],this._groupNamesList=[];for(const s of n)if(s instanceof RegExp)this._regexes.push(s),this._groupNamesList.push(yo(s.source));else{const r=fc(s,{flags:t.flags,ignoreCase:t.ignoreCase,abbreviations:t.abbreviations});this._regexes.push(r),this._groupNamesList.push(yo(r.source))}}get patterns(){return this._regexes}get matchOptions(){return this._matchKwargs}*_match(t,n,s){const r=this._groupNamesList[this._regexes.indexOf(t)]??[];t.lastIndex=0;let a;for(;(a=t.exec(n))!==null;){const i=a.index,o=a.index+a[0].length,c=new N(i,o,{...this._matchKwargs,pattern:this,inputString:n});if(r.length>0){const l=a.indices;for(let u=0;u<r.length;u++){const f=u+1,g=r[u]??this.name,h=l?.[f];if(h&&h[0]!==-1){const[x,m]=h,v=new N(x,m,{...this._childrenMatchKwargs,name:g,parent:c,pattern:this,inputString:n});v.length>0&&c.children.append(v)}}}(c.length>0||a[0].length===0)&&c.length>0&&(yield c),a[0].length===0&&t.lastIndex++}}toString(){return`<RePattern:(${this._regexes.map(t=>t.source).join(", ")})>`}};p(Mi,"RePattern");let Ft=Mi;const Ei=class Ei extends Le{constructor(t,...n){super(t);_(this,"_fns");_(this,"_matchKwargs");this._fns=n,this._matchKwargs=Ie(t)}get patterns(){return this._fns}get matchOptions(){return this._matchKwargs}*_match(t,n,s){const r=t(n,s);if(!r)return;const i=p(o=>!Array.isArray(o)||o.length>=2&&typeof o[0]=="number"&&typeof o[1]=="number","isSingleResult")(r)?[r]:r;for(const o of i)if(o){if(typeof o=="object"&&!Array.isArray(o)){const{start:c,end:l,...u}=o,f={...this._matchKwargs,...u},g=new N(c??0,l??0,{...f,pattern:this,inputString:n});g.length>0&&(yield g)}else if(Array.isArray(o)){let c=this._matchKwargs,l,u;o.length>=3&&typeof o[2]=="object"&&!Array.isArray(o[2])?(c={...this._matchKwargs,...o[2]},[l,u]=o):[l,u]=o;const f=new N(l,u,{...c,pattern:this,inputString:n});f.length>0&&(yield f)}}}toString(){return`<FunctionalPattern:(${this._fns.map(t=>t.name||"anonymous").join(", ")})>`}};p(Ei,"FunctionalPattern");let Ut=Ei,jo=null;function gc(d){jo=d}p(gc,"registerChain");function hc(){return jo}p(hc,"getChainClass");function _o(d){if(d.length===0)return[[],{}];const e=d[0],t=d[d.length-1];return typeof e=="object"&&e!==null?[d.slice(1),e]:d.length>1&&typeof t=="object"&&t!==null?[d.slice(0,-1),t]:[d,{}]}p(_o,"splitPatternsOpts");const Ni=class Ni{constructor(){_(this,"_defaults",{});_(this,"_regexDefaults",{});_(this,"_stringDefaults",{});_(this,"_functionalDefaults",{});_(this,"_chainDefaults",{})}reset(){return this._defaults={},this._regexDefaults={},this._stringDefaults={},this._functionalDefaults={},this._chainDefaults={},this}defaults(e){return q(e,this._defaults,!0),this}regexDefaults(e){return q(e,this._regexDefaults,!0),this}stringDefaults(e){return q(e,this._stringDefaults,!0),this}functionalDefaults(e){return q(e,this._functionalDefaults,!0),this}chainDefaults(e){return q(e,this._chainDefaults,!0),this}_applyOverrides(e){const t=e.overrides??[];delete e.overrides;const n={};for(const s of t)n[s]=e[s];return[e,n]}buildRe(e,...t){const n={...e},[,s]=this._applyOverrides(n);return q(this._regexDefaults,n),q(this._defaults,n),Object.assign(n,s),new Ft(n,...t)}buildString(e,...t){const n={...e},[,s]=this._applyOverrides(n);return q(this._stringDefaults,n),q(this._defaults,n),Object.assign(n,s),new Tt(n,...t)}buildFunctional(e,...t){const n={...e},[,s]=this._applyOverrides(n);return q(this._functionalDefaults,n),q(this._defaults,n),Object.assign(n,s),new Ut(n,...t)}regex(...e){const[t,n]=_o(e),s=this.buildRe(n,...t);return this.pattern(s)}string(...e){const[t,n]=_o(e),s=this.buildString(n,...t);return this.pattern(s)}functional(e,...t){let n;if(typeof e=="function"){const s=t[t.length-1];if(t.length>0&&typeof s=="object"&&s!==null&&!Array.isArray(s)){const r=s,a=t.slice(0,-1);n=this.buildFunctional(r,e,...a)}else n=this.buildFunctional({},e,...t)}else n=this.buildFunctional(e,...t);return this.pattern(n)}chain(e={}){const t=hc();if(!t)throw new Error("Chain class not registered. Import chain.ts before calling chain().");const n={...e};q(this._chainDefaults,n),q(this._defaults,n);const s=new t(this,n);return s._defaults={...this._defaults},s._regexDefaults={...this._regexDefaults},s._stringDefaults={...this._stringDefaults},s._functionalDefaults={...this._functionalDefaults},s._chainDefaults={...this._chainDefaults},this.pattern(s),s}};p(Ni,"Builder");let Lr=Ni;const Pi=class Pi extends Error{constructor(t){const n=[...t.entries()].map(([s,r])=>`${String(s)} -> ${[...r].map(String).join(", ")}`);super(`Cyclic dependencies exist among these items: ${n.join("; ")}`);_(this,"cyclic");this.cyclic=t,this.name="CyclicDependency"}};p(Pi,"CyclicDependency");let $r=Pi;function*mc(d){if(d.size===0)return;const e=new Map;for(const[n,s]of d){const r=new Set(s);r.delete(n),e.set(n,r)}const t=new Set;for(const n of e.values())for(const s of n)t.add(s);for(const n of t)e.has(n)||e.set(n,new Set);for(;e.size>0;){const n=new Set;for(const[s,r]of e)r.size===0&&n.add(s);if(n.size===0)throw new $r(e);yield n;for(const s of n)e.delete(s);for(const s of e.values())for(const r of n)s.delete(r)}}p(mc,"toposort");const Oi=class Oi{};p(Oi,"Consequence");let $e=Oi;const Ii=class Ii{};p(Ii,"Condition");let Hr=Ii;const he=class he extends Hr{constructor(){super();_(this,"priority",this.constructor.priority);_(this,"name_",this.constructor.name);_(this,"dependency_",this.constructor.dependency);_(this,"logLevel",0);_(this,"defined_at");this.defined_at=void 0}enabled(t){return!0}toString(){const t=this.defined_at?`@${this.defined_at.filename.split("/").pop()}#L${this.defined_at.lineno}`:"";return`<${this.name_??this.constructor.name}${t}>`}equals(t){return this===t?!0:this.constructor!==t.constructor?!1:vc(this,t)}};p(he,"CustomRule"),_(he,"priority",0),_(he,"ruleName"),_(he,"dependency",null),_(he,"properties",{});let ee=he;const bo=new Set(["defined_at"]);function vc(d,e){const t=Object.keys(d).filter(a=>!bo.has(a)),n=Object.keys(e).filter(a=>!bo.has(a));if(t.length!==n.length)return!1;const s=d,r=e;for(const a of t){if(!Object.prototype.hasOwnProperty.call(e,a))return!1;const i=s[a],o=r[a];if(i!==o&&!(Number.isNaN(i)&&Number.isNaN(o)))return!1}return!0}p(vc,"sameParameters");const Li=class Li extends ee{constructor(){super(...arguments);_(this,"consequence",null)}then(t,n,s){const r=this.consequence??this.constructor.consequence;if(Array.isArray(r)){const i=(Array.isArray(n)?n:[n])[Symbol.iterator]();for(const o of r)(typeof o=="function"?new o:o).then(t,i.next().value,s)}else{const a=typeof r=="function"?new r:r;a&&a.then(t,n,s)}}};p(Li,"Rule");let y=Li;const $i=class $i extends $e{then(e,t,n){if(!t)return;if(qo(t)&&!(t instanceof String)){const r=[];for(const a of t)e.includes(a)&&(e.remove(a),r.push(a));return r}const s=t;if(e.includes(s))return e.remove(s),s}};p($i,"RemoveMatch");let b=$i;const Hi=class Hi extends $e{constructor(t){super();_(this,"matchName");this.matchName=t}then(t,n,s){if(!n)return;if(qo(n)&&!(n instanceof String)){const a=[];for(const i of n)t.includes(i)||(this.matchName&&(i.name=this.matchName),t.append(i),a.push(i));return a}const r=n;if(this.matchName&&(r.name=this.matchName),!t.includes(r))return t.append(r),r}};p(Hi,"AppendMatch");let $=Hi;const Ti=class Ti extends $e{constructor(t){super();_(this,"matchName");_(this,"_remove",new b);_(this,"_append",new $);this.matchName=t}then(t,n,s){const r=this._remove.then(t,n,s);if(r)if(Array.isArray(r)){for(const a of r)a.name=this.matchName;this._append.then(t,r,s)}else r.name=this.matchName,this._append.then(t,r,s)}};p(Ti,"RenameMatch");let le=Ti;const Fi=class Fi extends $e{constructor(t){super();_(this,"tags");_(this,"_remove",new b);_(this,"_append",new $);this.tags=t}then(t,n,s){const r=this._remove.then(t,n,s);if(r){if(Array.isArray(r))for(const a of r)a.tags.push(...this.tags);else r.tags.push(...this.tags);this._append.then(t,r,s)}}};p(Fi,"AppendTags");let Bt=Fi;const Ui=class Ui{constructor(...e){_(this,"_list",[]);this.load(...e)}load(...e){for(const t of e)typeof t=="function"&&t.prototype instanceof ee?this._list.push(new t):typeof t=="object"&&t!==null&&!(t instanceof ee)?this.loadModule(t):t instanceof ee?this._list.push(t):typeof t=="function"&&this._list.push(new t)}loadModule(e){for(const t of Object.values(e))typeof t=="function"&&t.prototype instanceof ee&&this._list.push(new t)}extend(e){for(const t of e._list)this._list.some(n=>n.equals(t))||this._list.push(t)}indexOf(e){return this._list.indexOf(e)}[Symbol.iterator](){return this._list[Symbol.iterator]()}get length(){return this._list.length}executeAllRules(e,t){const n=[],s=new Map;for(const a of this._list){const i=a.priority,o=s.get(i)??[];o.push(a),s.set(i,o)}const r=[...s.keys()].sort((a,i)=>i-a);for(const a of r){const i=s.get(a),o=yc(i);for(const c of o){const l=[...c].sort((u,f)=>this.indexOf(u)-this.indexOf(f));for(const u of l){const f=xc(u,e,t);f!=null&&f!==!1&&n.push([u,f])}}}return n}};p(Ui,"Rules");let zt=Ui;function xc(d,e,t){if(!d.enabled(t))return null;const n=d.when(e,t);return n!=null&&n!==!1?(d.then(e,n,t),n):null}p(xc,"executeRule");function yc(d){const e=new Map,t=new Map;for(const n of d){const s=n.constructor;t.set(s,[...t.get(s)??[],n])}for(const n of d){const s=new Set,r=n.dependency_;if(r){const a=Array.isArray(r)?r:[r];for(const i of a){let o=[];if(typeof i=="string"){for(const[c,l]of t)if(c.name===i){o=l;break}}else o=t.get(i)??[];for(const c of o)c!==n&&s.add(c)}}e.set(n,s)}return[...mc(e)]}p(yc,"toposortRules");const _c="__default__",Tr=2048,O=-2048;function bc(d,e){return e.initiator.length<d.initiator.length?e:d.initiator.length<e.initiator.length?d:null}p(bc,"defaultConflictSolver");const Yt=class Yt extends y{constructor(){super(...arguments);_(this,"priority",Tr);_(this,"consequence",b)}get defaultConflictSolverFn(){return bc}when(t,n){const s=new Pr,r=t.toArray().filter(a=>!a.private).sort((a,i)=>a.length-i.length);for(const a of r){const i=t.conflicting(a)??[];if(!i.length)continue;const o=i.filter(c=>!c.private).sort((c,l)=>c.length-l.length);for(const c of o){const l=[[this.defaultConflictSolverFn,!1]];a.conflictSolver&&l.push([a.conflictSolver,!1]),c.conflictSolver&&l.push([c.conflictSolver,!0]);for(let u=l.length-1;u>=0;u--){const[f,g]=l[u],h=g?f(c,a):f(a,c);if(h!==_c){if(h&&!s.has(h)){const x=h===a?c:a;s.has(x)||s.add(h)}break}}}}return s}};p(Yt,"ConflictSolver"),_(Yt,"priority",Tr);let Fr=Yt;const Jt=class Jt extends y{constructor(){super(...arguments);_(this,"priority",O);_(this,"consequence",b)}when(t,n){return t.toArray().filter(s=>s.private)}};p(Jt,"PrivateRemover"),_(Jt,"priority",O);let Ur=Jt;const Bi=class Bi extends Error{constructor(){super("Invalid chain")}};p(Bi,"InvalidChainException");let Vt=Bi;const zi=class zi extends Ht{constructor(t,n){super();_(this,"_chain");_(this,"pattern");_(this,"repeaterStart",1);_(this,"repeaterEnd",1);_(this,"_hidden",!1);this._chain=t,this.pattern=n}get isChainStart(){return this._chain.parts[0]===this}get isHidden(){return this._hidden}hidden(t=!0){return this._hidden=t,this}matches(t,n,s=!1){const r=this.pattern.matches(t,n,!0);let[a,i]=r;return a=this._truncateRepeater(a,t),i=this._truncateRepeater(i,t),this._validateRepeater(i),s?[a,i]:a}_truncateRepeater(t,n){if(!t.length)return t;if(!this.isChainStart&&n.slice(0,t[0].initiator.rawStart))return[];let s=1;for(let a=0;a<t.length-1&&!n.slice(t[a].initiator.rawEnd,t[a+1].initiator.rawStart);a++)s++;let r=t.slice(0,s);return this.repeaterEnd!==null&&(r=r.filter(a=>a.matchIndex<this.repeaterEnd)),r}_validateRepeater(t){if((t.length>0?Math.max(...t.map(s=>s.matchIndex)):-1)+1<this.repeaterStart)throw new Vt}repeater(t){if(typeof t=="number")return this.repeaterStart=t,this.repeaterEnd=t,this;const n=String(t);if(n==="+")this.repeaterStart=1,this.repeaterEnd=null;else if(n==="*")this.repeaterStart=0,this.repeaterEnd=null;else if(n==="?")this.repeaterStart=0,this.repeaterEnd=1;else{const s=/\{\s*(\d*)\s*,?\s*(\d*)\s*\}/.exec(n);s&&(this.repeaterStart=s[1]?parseInt(s[1]):0,this.repeaterEnd=s[2]?parseInt(s[2]):null)}return this}regex(t,...n){return this._chain.regex(t,...n)}string(t,...n){return this._chain.string(t,...n)}functional(t,...n){return this._chain.functional(t,...n)}chain(t){return this._chain.chain(t)}close(){return this._chain.close()}toString(){return`${this.pattern}({${this.repeaterStart},${this.repeaterEnd}})`}};p(zi,"ChainPart");let Br=zi;const wo=256,wc=256,Sc=128,Y=class Y extends Le{constructor(t,n={}){super(n);_(this,"parts",[]);_(this,"_defaults",{});_(this,"_regexDefaults",{});_(this,"_stringDefaults",{});_(this,"_functionalDefaults",{});_(this,"_chainDefaults",{});_(this,"_parent");_(this,"_chainBreaker");_(this,"_matchKwargs");this._parent=t,this._matchKwargs=Ie(n),this._chainBreaker=n.chainBreaker??null}defaults(t){return q(t,this._defaults,!0),"children"in t&&(this.children=t.children),"privateParent"in t&&(this.privateParent=t.privateParent),"privateChildren"in t&&(this.privateChildren=t.privateChildren),"conflictSolver"in t&&(this._matchKwargs.conflictSolver=t.conflictSolver),"privateNames"in t&&(this.privateNames=t.privateNames),this}regexDefaults(t){return q(t,this._regexDefaults,!0),this}regex(...t){const n=t[t.length-1],s=typeof n=="object"&&n!==null&&!Array.isArray(n)?n:{},r=typeof n=="object"&&n!==null&&!Array.isArray(n)?t.slice(0,-1):t,a={...this._regexDefaults,...this._defaults,...s},i=new Ft(a,...r);return this.pattern(i)}string(...t){const n=t[t.length-1],s=typeof n=="object"&&n!==null&&!Array.isArray(n)?n:{},r=typeof n=="object"&&n!==null&&!Array.isArray(n)?t.slice(0,-1):t,a={...this._stringDefaults,...this._defaults,...s},i=new Tt(a,...r);return this.pattern(i)}functional(...t){const n=t[0],s=t.length>1&&typeof t[1]=="object"?t[1]:{},r={...this._functionalDefaults,...this._defaults,...s},a=new Ut(r,n);return this.pattern(a)}chain(t={}){const n={...this._chainDefaults,...this._defaults,...t},s=new Y(this,n);return s._defaults={...this._defaults},s._regexDefaults={...this._regexDefaults},s._stringDefaults={...this._stringDefaults},s._functionalDefaults={...this._functionalDefaults},s._chainDefaults={...this._chainDefaults},this.pattern(s),s}pattern(...t){if(!t.length)throw new Error("One pattern should be given to the chain");if(t.length>1)throw new Error("Only one pattern can be given to the chain");const n=new Br(this,t[0]);return this.parts.push(n),n}close(){let t=this._parent;for(;t instanceof Y;)t=t._parent;return t}get patterns(){return[this]}get matchOptions(){return{}}_processMatch(t,n,s=!1){if(super._processMatch(t,n,s))return!0;if(t.children.length>0){const a=t.children.get(t.children.length-1).pattern,i=t.children.toArray().filter(c=>c.pattern===a),o=Y._groupByMatchIndex(i);if(o.size>0){const c=new ve(t.children.toArray()),l=t.end,u=[...o.keys()].sort((f,g)=>g-f);for(const f of u){const g=o.get(f);for(const x of g)t.children.remove(x);if(t.end=t.children.length>0?t.children.get(t.children.length-1).end:t.start,super._processMatch(t,n,s))return!0}t.children=c,t.end=l}}return!1}*_match(t,n,s){let r=0;for(;r<n.length;){let a=!1;const i=[];let o=!0,c=n.slice(r,r+wo);for(const l of this.parts)try{const u=l.matches(c,s,!0),[f,g]=u;if(Y._fixMatchesOffset(f,n,r),Y._fixMatchesOffset(g,n,r),g.length>0){const h=Y._groupByMatchIndex(g),x=Y._groupByMatchIndex(f);for(const[m,v]of h)if(a=!0,r=v[v.length-1].rawEnd,c=n.slice(r,r+wc),!l.isHidden){const C=x.get(m)??[];this._chainBreakerEval([...i,...C])&&i.push(...C)}}}catch(u){if(u instanceof Vt){o=!1,i.length>0?r=i[0].rawEnd:r++;break}throw u}if(!a){const l=r+wo-Sc;if(l<=r||l>=n.length)break;r=l;continue}i.length>0&&o&&(yield this._buildChainMatch(i,n))}}_chainBreakerEval(t){return this._chainBreaker?!this._chainBreaker(new ve(t)):!0}_buildChainMatch(t,n){let s=1/0,r=-1/0;for(const i of t)i.start<s&&(s=i.start),i.end>r&&(r=i.end);const a=new N(s,r,{...this._matchKwargs,pattern:this,inputString:n});for(const i of t){if(i.children.length>0)for(const o of i.children)a.children.append(o);a.children.includes(i)||(a.children.append(i),i.parent=a)}return a}static _fixMatchesOffset(t,n,s){for(const r of t){if(r.inputString!==n){r.inputString=n;const a=r.rawStart,i=r.rawEnd;r.start+=s,r.end+=s,r.rawStart=a+s,r.rawEnd=i+s}r.children.length>0&&Y._fixMatchesOffset(r.children.toArray(),n,s)}}static _groupByMatchIndex(t){const n=new Map;for(const s of t){const r=n.get(s.matchIndex)??[];r.push(s),n.set(s.matchIndex,r)}return n}};p(Y,"Chain");let zr=Y;gc(zr);const Vi=class Vi extends Lr{constructor(t={}){super();_(this,"_patterns",[]);_(this,"_rules");_(this,"_rebulks",[]);_(this,"_disabled");_(this,"customizeProperties");const n=t.disabled;typeof n=="function"?this._disabled=n:typeof n=="boolean"?this._disabled=()=>n:this._disabled=()=>!1,this._rules=new zt,t.defaultRules!==!1&&this._rules.load(Fr,Ur)}pattern(...t){return this._patterns.push(...t),this}rules(...t){return this._rules.load(...t),this}rebulk(...t){return this._rebulks.push(...t),this}matches(t,n={}){const s=new ve(void 0,t);return this._matchesPatterns(s,n),this._executeRules(s,n),s}_effectiveChildren(t){const n=[];for(const s of this._rebulks)s._disabled(t)||n.push(s,...s._effectiveChildren(t));return n}effectiveRules(t){const n=new zt;n.extend(this._rules);for(const s of this._effectiveChildren(t??{}))n.extend(s._rules);return n}effectivePatterns(t){const n=[...this._patterns];for(const s of this._effectiveChildren(t??{}))cc(n,s._patterns);return n}_executeRules(t,n){this._disabled(n)||this.effectiveRules(n).executeAllRules(t,n)}_matchesPatterns(t,n){if(this._disabled(n))return;const s=this.effectivePatterns(n);for(const r of s){if(r.disabled&&r.disabled(n))continue;const a=r.matches(t.inputString,n);for(const i of a)i.marker?t.markers.append(i):t.append(i)}}};p(Vi,"Rebulk");let F=Vi;function Ac(d){const e=new F;e.defaults({name:"path",marker:!0});function t(n,s){if(s?.name_only)return[[0,n.length]];const r=[...Nr(n,"/"),...Nr(n,"\\"),-1,n.length];r.sort((i,o)=>i-o);const a=[];for(let i=0;i<r.length-1;i++)a.push([r[i]+1,r[i+1]]);return a}return p(t,"markPath"),e.functional(t),e}p(Ac,"path");const Ri=class Ri extends Error{constructor(e){super(e),this.name="ConfigurationException"}};p(Ri,"ConfigurationException");let Vr=Ri;function kc(d){const e=new F;e.defaults({name:"group",marker:!0});const{starting:t,ending:n}=d;if(t.length!==n.length)throw new Vr("Starting and ending groups must have the same length");function s(r){const a=Array.from({length:t.length},()=>[]),i=[];for(let o=0;o<r.length;o++){const c=r[o],l=t.indexOf(c);l>-1&&a[l].push(o);const u=n.indexOf(c);if(u>-1){const f=a[u];if(f.length>0){const g=f.pop();i.push([g,o+1])}}}return i}return p(s,"markGroups"),e.functional(s),e}p(kc,"groups");function I(d,e,t=!1){if(!d||d.length===0)return"(?:)";const n=[];for(const s of d)n.length===0?(n.push("(?"),e?n.push(`<${e}>`):n.push(":")):n.push("|"),n.push(t?`(?:${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`:`(?:${s})`);return n.push(")"),n.join("")}p(I,"buildOrPattern");const Dc=[["M",1e3],["CM",900],["D",500],["CD",400],["C",100],["XC",90],["L",50],["XL",40],["X",10],["IX",9],["V",5],["IV",4],["I",1]],Ko={zero:0,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20,zéro:0,un:1,deux:2,trois:3,quatre:4,cinq:5,sept:7,huit:8,neuf:9,dix:10,onze:11,douze:12,treize:13,quatorze:14,quinze:15,seize:16,"dix-sept":17,"dix-huit":18,"dix-neuf":19,vingt:20},Cc=Object.keys(Ko).sort((d,e)=>e.length-d.length).map(d=>d.replace(/[-]/g,"\\-")).join("|");function Mc(d){const e=d.toUpperCase();let t=0,n=0;for(const[s,r]of Dc)for(;e.startsWith(s,n);)t+=r,n+=s.length;return n===e.length&&t>0?t:void 0}p(Mc,"parseRoman");function Ec(d){return Ko[d.toLowerCase()]}p(Ec,"parseWord");function oe(d){const e=parseInt(d,10);if(!isNaN(e))return e;const t=Mc(d);return t!==void 0?t:Ec(d)}p(oe,"parseNumber");const M=" [](){}+*|=-_~#/\\.,;:",Be=M.replace(/[\[\](){}]/g,""),Go=M.replace(/[/\\]/g,""),Rr="-+/\\|";function Mt(d){return d.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}p(Mt,"reEscape");const z=Mt(M);Mt(Be);const X=["-","["+Mt(Go)+"]"],Nc=["@","["+Mt(Go)+"]"];function R(d){return"(?:"+d+")?"}p(R,"optional");const Pc=p(d=>d.rawStart!==void 0&&d.rawStart>d.start,"enlargedStart"),Oc=p(d=>d.rawEnd!==void 0&&d.rawEnd<d.end,"enlargedEnd"),se=p(d=>Pc(d)||lc(M,d),"sepsBefore"),ae=p(d=>Oc(d)||uc(M,d),"sepsAfter"),T=p(d=>se(d)&&ae(d),"sepsSurround");function xe(d){return/^[+-]?\d+(?:_\d+)*$/.test(d.trim())}p(xe,"intCoercable");function ge(...d){return e=>d.every(t=>t(e))}p(ge,"and_");function Xo(...d){return e=>d.some(t=>t(e))}p(Xo,"or_");const Ic={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ç:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ç:"c",è:"e",é:"e",ê:"e",ë:"e",ì:"i",í:"i",î:"i",ï:"i",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ù:"u",ú:"u",û:"u",ü:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",Ď:"D",ď:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",ĝ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",Ť:"T",ť:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ǟ:"A",ǟ:"a",Ǡ:"A",ǡ:"a",Ǣ:"Æ",ǣ:"æ",Ǧ:"G",ǧ:"g",Ǩ:"K",ǩ:"k",Ǫ:"O",ǫ:"o",Ǭ:"O",ǭ:"o",Ǯ:"Ʒ",ǯ:"ʒ",ǰ:"j",Ǵ:"G",ǵ:"g",Ǹ:"N",ǹ:"n",Ǻ:"A",ǻ:"a",Ǽ:"Æ",ǽ:"æ",Ǿ:"Ø",ǿ:"ø",Ȁ:"A",ȁ:"a",Ȃ:"A",ȃ:"a",Ȅ:"E",ȅ:"e",Ȇ:"E",ȇ:"e",Ȉ:"I",ȉ:"i",Ȋ:"I",ȋ:"i",Ȍ:"O",ȍ:"o",Ȏ:"O",ȏ:"o",Ȑ:"R",ȑ:"r",Ȓ:"R",ȓ:"r",Ȕ:"U",ȕ:"u",Ȗ:"U",ȗ:"u",Ș:"S",ș:"s",Ț:"T",ț:"t",Ȟ:"H",ȟ:"h",Ȧ:"A",ȧ:"a",Ȩ:"E",ȩ:"e",Ȫ:"O",ȫ:"o",Ȭ:"O",ȭ:"o",Ȯ:"O",ȯ:"o",Ȱ:"O",ȱ:"o",Ȳ:"Y",ȳ:"y","΅":"¨",Ά:"Α",Έ:"Ε",Ή:"Η",Ί:"Ι",Ό:"Ο",Ύ:"Υ",Ώ:"Ω",ΐ:"ι",Ϊ:"Ι",Ϋ:"Υ",ά:"α",έ:"ε",ή:"η",ί:"ι",ΰ:"υ",ϊ:"ι",ϋ:"υ",ό:"ο",ύ:"υ",ώ:"ω",ϓ:"ϒ",ϔ:"ϒ",Ѐ:"Е",Ё:"Е",Ѓ:"Г",Ї:"І",Ќ:"К",Ѝ:"И",Ў:"У",Й:"И",й:"и",ѐ:"е",ё:"е",ѓ:"г",ї:"і",ќ:"к",ѝ:"и",ў:"у",Ѷ:"Ѵ",ѷ:"ѵ",Ӂ:"Ж",ӂ:"ж",Ӑ:"А",ӑ:"а",Ӓ:"А",ӓ:"а",Ӗ:"Е",ӗ:"е",Ӛ:"Ә",ӛ:"ә",Ӝ:"Ж",ӝ:"ж",Ӟ:"З",ӟ:"з",Ӣ:"И",ӣ:"и",Ӥ:"И",ӥ:"и",Ӧ:"О",ӧ:"о",Ӫ:"Ө",ӫ:"ө",Ӭ:"Э",ӭ:"э",Ӯ:"У",ӯ:"у",Ӱ:"У",ӱ:"у",Ӳ:"У",ӳ:"у",Ӵ:"Ч",ӵ:"ч",Ӹ:"Ы",ӹ:"ы",Ḁ:"A",ḁ:"a",Ḃ:"B",ḃ:"b",Ḅ:"B",ḅ:"b",Ḇ:"B",ḇ:"b",Ḉ:"C",ḉ:"c",Ḋ:"D",ḋ:"d",Ḍ:"D",ḍ:"d",Ḏ:"D",ḏ:"d",Ḑ:"D",ḑ:"d",Ḓ:"D",ḓ:"d",Ḕ:"E",ḕ:"e",Ḗ:"E",ḗ:"e",Ḙ:"E",ḙ:"e",Ḛ:"E",ḛ:"e",Ḝ:"E",ḝ:"e",Ḟ:"F",ḟ:"f",Ḡ:"G",ḡ:"g",Ḣ:"H",ḣ:"h",Ḥ:"H",ḥ:"h",Ḧ:"H",ḧ:"h",Ḩ:"H",ḩ:"h",Ḫ:"H",ḫ:"h",Ḭ:"I",ḭ:"i",Ḯ:"I",ḯ:"i",Ḱ:"K",ḱ:"k",Ḳ:"K",ḳ:"k",Ḵ:"K",ḵ:"k",Ḷ:"L",ḷ:"l",Ḹ:"L",ḹ:"l",Ḻ:"L",ḻ:"l",Ḽ:"L",ḽ:"l",Ḿ:"M",ḿ:"m",Ṁ:"M",ṁ:"m",Ṃ:"M",ṃ:"m",Ṅ:"N",ṅ:"n",Ṇ:"N",ṇ:"n",Ṉ:"N",ṉ:"n",Ṋ:"N",ṋ:"n",Ṍ:"O",ṍ:"o",Ṏ:"O",ṏ:"o",Ṑ:"O",ṑ:"o",Ṓ:"O",ṓ:"o",Ṕ:"P",ṕ:"p",Ṗ:"P",ṗ:"p",Ṙ:"R",ṙ:"r",Ṛ:"R",ṛ:"r",Ṝ:"R",ṝ:"r",Ṟ:"R",ṟ:"r",Ṡ:"S",ṡ:"s",Ṣ:"S",ṣ:"s",Ṥ:"S",ṥ:"s",Ṧ:"S",ṧ:"s",Ṩ:"S",ṩ:"s",Ṫ:"T",ṫ:"t",Ṭ:"T",ṭ:"t",Ṯ:"T",ṯ:"t",Ṱ:"T",ṱ:"t",Ṳ:"U",ṳ:"u",Ṵ:"U",ṵ:"u",Ṷ:"U",ṷ:"u",Ṹ:"U",ṹ:"u",Ṻ:"U",ṻ:"u",Ṽ:"V",ṽ:"v",Ṿ:"V",ṿ:"v",Ẁ:"W",ẁ:"w",Ẃ:"W",ẃ:"w",Ẅ:"W",ẅ:"w",Ẇ:"W",ẇ:"w",Ẉ:"W",ẉ:"w",Ẋ:"X",ẋ:"x",Ẍ:"X",ẍ:"x",Ẏ:"Y",ẏ:"y",Ẑ:"Z",ẑ:"z",Ẓ:"Z",ẓ:"z",Ẕ:"Z",ẕ:"z",ẖ:"h",ẗ:"t",ẘ:"w",ẙ:"y",ẛ:"ſ",Ạ:"A",ạ:"a",Ả:"A",ả:"a",Ấ:"A",ấ:"a",Ầ:"A",ầ:"a",Ẩ:"A",ẩ:"a",Ẫ:"A",ẫ:"a",Ậ:"A",ậ:"a",Ắ:"A",ắ:"a",Ằ:"A",ằ:"a",Ẳ:"A",ẳ:"a",Ẵ:"A",ẵ:"a",Ặ:"A",ặ:"a",Ẹ:"E",ẹ:"e",Ẻ:"E",ẻ:"e",Ẽ:"E",ẽ:"e",Ế:"E",ế:"e",Ề:"E",ề:"e",Ể:"E",ể:"e",Ễ:"E",ễ:"e",Ệ:"E",ệ:"e",Ỉ:"I",ỉ:"i",Ị:"I",ị:"i",Ọ:"O",ọ:"o",Ỏ:"O",ỏ:"o",Ố:"O",ố:"o",Ồ:"O",ồ:"o",Ổ:"O",ổ:"o",Ỗ:"O",ỗ:"o",Ộ:"O",ộ:"o",Ớ:"O",ớ:"o",Ờ:"O",ờ:"o",Ở:"O",ở:"o",Ỡ:"O",ỡ:"o",Ợ:"O",ợ:"o",Ụ:"U",ụ:"u",Ủ:"U",ủ:"u",Ứ:"U",ứ:"u",Ừ:"U",ừ:"u",Ử:"U",ử:"u",Ữ:"U",ữ:"u",Ự:"U",ự:"u",Ỳ:"Y",ỳ:"y",Ỵ:"Y",ỵ:"y",Ỷ:"Y",ỷ:"y",Ỹ:"Y",ỹ:"y",ἀ:"α",ἁ:"α",ἂ:"α",ἃ:"α",ἄ:"α",ἅ:"α",ἆ:"α",ἇ:"α",Ἀ:"Α",Ἁ:"Α",Ἂ:"Α",Ἃ:"Α",Ἄ:"Α",Ἅ:"Α",Ἆ:"Α",Ἇ:"Α",ἐ:"ε",ἑ:"ε",ἒ:"ε",ἓ:"ε",ἔ:"ε",ἕ:"ε",Ἐ:"Ε",Ἑ:"Ε",Ἒ:"Ε",Ἓ:"Ε",Ἔ:"Ε",Ἕ:"Ε",ἠ:"η",ἡ:"η",ἢ:"η",ἣ:"η",ἤ:"η",ἥ:"η",ἦ:"η",ἧ:"η",Ἠ:"Η",Ἡ:"Η",Ἢ:"Η",Ἣ:"Η",Ἤ:"Η",Ἥ:"Η",Ἦ:"Η",Ἧ:"Η",ἰ:"ι",ἱ:"ι",ἲ:"ι",ἳ:"ι",ἴ:"ι",ἵ:"ι",ἶ:"ι",ἷ:"ι",Ἰ:"Ι",Ἱ:"Ι",Ἲ:"Ι",Ἳ:"Ι",Ἴ:"Ι",Ἵ:"Ι",Ἶ:"Ι",Ἷ:"Ι",ὀ:"ο",ὁ:"ο",ὂ:"ο",ὃ:"ο",ὄ:"ο",ὅ:"ο",Ὀ:"Ο",Ὁ:"Ο",Ὂ:"Ο",Ὃ:"Ο",Ὄ:"Ο",Ὅ:"Ο",ὐ:"υ",ὑ:"υ",ὒ:"υ",ὓ:"υ",ὔ:"υ",ὕ:"υ",ὖ:"υ",ὗ:"υ",Ὑ:"Υ",Ὓ:"Υ",Ὕ:"Υ",Ὗ:"Υ",ὠ:"ω",ὡ:"ω",ὢ:"ω",ὣ:"ω",ὤ:"ω",ὥ:"ω",ὦ:"ω",ὧ:"ω",Ὠ:"Ω",Ὡ:"Ω",Ὢ:"Ω",Ὣ:"Ω",Ὤ:"Ω",Ὥ:"Ω",Ὦ:"Ω",Ὧ:"Ω",ὰ:"α",ά:"α",ὲ:"ε",έ:"ε",ὴ:"η",ή:"η",ὶ:"ι",ί:"ι",ὸ:"ο",ό:"ο",ὺ:"υ",ύ:"υ",ὼ:"ω",ώ:"ω",ᾀ:"α",ᾁ:"α",ᾂ:"α",ᾃ:"α",ᾄ:"α",ᾅ:"α",ᾆ:"α",ᾇ:"α",ᾈ:"Α",ᾉ:"Α",ᾊ:"Α",ᾋ:"Α",ᾌ:"Α",ᾍ:"Α",ᾎ:"Α",ᾏ:"Α",ᾐ:"η",ᾑ:"η",ᾒ:"η",ᾓ:"η",ᾔ:"η",ᾕ:"η",ᾖ:"η",ᾗ:"η",ᾘ:"Η",ᾙ:"Η",ᾚ:"Η",ᾛ:"Η",ᾜ:"Η",ᾝ:"Η",ᾞ:"Η",ᾟ:"Η",ᾠ:"ω",ᾡ:"ω",ᾢ:"ω",ᾣ:"ω",ᾤ:"ω",ᾥ:"ω",ᾦ:"ω",ᾧ:"ω",ᾨ:"Ω",ᾩ:"Ω",ᾪ:"Ω",ᾫ:"Ω",ᾬ:"Ω",ᾭ:"Ω",ᾮ:"Ω",ᾯ:"Ω",ᾰ:"α",ᾱ:"α",ᾲ:"α",ᾳ:"α",ᾴ:"α",ᾶ:"α",ᾷ:"α",Ᾰ:"Α",Ᾱ:"Α",Ὰ:"Α",Ά:"Α",ᾼ:"Α","῁":"¨",ῂ:"η",ῃ:"η",ῄ:"η",ῆ:"η",ῇ:"η",Ὲ:"Ε",Έ:"Ε",Ὴ:"Η",Ή:"Η",ῌ:"Η","῍":"᾿","῎":"᾿","῏":"᾿",ῐ:"ι",ῑ:"ι",ῒ:"ι",ΐ:"ι",ῖ:"ι",ῗ:"ι",Ῐ:"Ι",Ῑ:"Ι",Ὶ:"Ι",Ί:"Ι","῝":"῾","῞":"῾","῟":"῾",ῠ:"υ",ῡ:"υ",ῢ:"υ",ΰ:"υ",ῤ:"ρ",ῥ:"ρ",ῦ:"υ",ῧ:"υ",Ῠ:"Υ",Ῡ:"Υ",Ὺ:"Υ",Ύ:"Υ",Ῥ:"Ρ","῭":"¨","΅":"¨",ῲ:"ω",ῳ:"ω",ῴ:"ω",ῶ:"ω",ῷ:"ω",Ὸ:"Ο",Ό:"Ο",Ὼ:"Ω",Ώ:"Ω",ῼ:"Ω",Å:"A","↚":"←","↛":"→","↮":"↔","⇍":"⇐","⇎":"⇔","⇏":"⇒","∄":"∃","∉":"∈","∌":"∋","∤":"∣","∦":"∥","≁":"∼","≄":"≃","≇":"≅","≉":"≈","≠":"=","≢":"≡","≭":"≍","≮":"<","≯":">","≰":"≤","≱":"≥","≴":"≲","≵":"≳","≸":"≶","≹":"≷","⊀":"≺","⊁":"≻","⊄":"⊂","⊅":"⊃","⊈":"⊆","⊉":"⊇","⊬":"⊢","⊭":"⊨","⊮":"⊩","⊯":"⊫","⋠":"≼","⋡":"≽","⋢":"⊑","⋣":"⊒","⋪":"⊲","⋫":"⊳","⋬":"⊴","⋭":"⊵","⫝̸":"⫝"};function So(d){let e="";for(const t of d)e+=Ic[t]??t;return e.replace(/[̀-ͯ]/g,"")}p(So,"foldDiacritics");const Lc=new Set([",",":",";","-","/","\\"]),$c=M.split("").filter(d=>!Lc.has(d)).join("");function Hc(d,e){return d-1>=0&&M.includes(e[d])&&(d-2<0||M.includes(e[d-2]))&&!M.includes(e[d-1])}p(Hc,"potentialBefore");function Tc(d,e){return d+2>=e.length||e[d+2]===e[d]&&!M.includes(e[d+1])}p(Tc,"potentialAfter");function B(d){if(!d)return d;let e=d;for(const u of $c)e=e.split(u).join(" ");const t=[];for(let u=0;u<e.length;u++)M.includes(e[u])&&t.push(u);const n=new Set;if(t.length>0){const u=e.split(""),f=[];for(const h of t)Hc(h,d)&&Tc(h,d)&&f.push(h);const g=[];for(const h of f)/\d/.test(d[h-1]??"")&&!me(d.slice(h+1),M)||(f.includes(h-2)||f.includes(h+2))&&g.push(h);if(g.length>0){for(const h of g)n.add(d[h]),u[h]=d[h];e=u.join("")}}const s=[],r=/(?<![\d.])\d+(?:\.\d+)+(?![\d.])/g;let a;for(;(a=r.exec(d))!==null;)for(let u=a.index;u<a.index+a[0].length;u++)d[u]==="."&&s.push(u);if(s.length>0){const u=e.split("");for(const f of s)u[f]=".";n.add("."),e=u.join("")}const i=[],o=/\d+(?:\.\d+){2,}/g;let c;for(;(c=o.exec(d))!==null;)if(/[^\s._-]/.test(d.slice(0,c.index)))for(let u=c.index;u<c.index+c[0].length;u++)d[u]==="."&&i.push(u);if(i.length>0){const u=e.split("");for(const f of i)u[f]=".";n.add("."),e=u.join("")}const l=M.split("").filter(u=>!n.has(u)).join("");return e=me(e,l),/(?:^|[ ])\d+\.\d+\.$/.test(e)&&(e=e.slice(0,-1)),e=e.replace(/ +/g," "),e}p(B,"cleanup");function me(d,e=M){let t=0,n=d.length;for(;t<n&&e.includes(d[t]);)t++;for(;n>t&&e.includes(d[n-1]);)n--;return d.slice(t,n)}p(me,"strip");function Zo(d){return At(B,me)(d.toLowerCase())}p(Zo,"rawCleanup");function Rt(d,e=["the"],t=[", ",","]){const n=d.toLowerCase();for(const s of e)for(const r of t){const a=r+s;if(n.endsWith(a))return d.slice(d.length-a.length+r.length)+" "+d.slice(0,d.length-a.length)}return d}p(Rt,"reorderTitle");function A(d,e){if(!d)return!1;const t=d.excludes,n=d.includes;return!!(t&&t.includes(e)||n&&n.length>0&&!n.includes(e))}p(A,"isDisabled");const Mr={零:0,一:1,二:2,两:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Ao="(?:\\d{1,4}|[一二两三四五六七八九]?十[一二两三四五六七八九]?|[零一二两三四五六七八九])";function ko(d){if(/^\d+$/.test(d))return parseInt(d,10);if(d.includes("十")){const[e,t]=d.split("十"),n=e?Mr[e]:1,s=t?Mr[t]:0;return n*10+s}return Mr[d]}p(ko,"parseCjkNumber");function Do(d){const e=[],t=[];for(const n of d)typeof n=="object"?(n.numfirst&&t.push(n.value),e.push(n.value)):e.push(n);return{words:e,numfirst:t}}p(Do,"splitWords");function Co(d,e){const t=d.named("episode")||[];if(t.length>1&&Math.abs(t[t.length-1].value-t[t.length-2].value)>e.episode_max_range)return!0;const n=d.named("season")||[];if(n.length>1){const s=n[n.length-1].value,r=n[n.length-2].value;if(Math.abs(s-r)>e.season_max_range||s<r)return!0}return!1}p(Co,"episodesSeasonChainBreaker");function Fe(d,e){const t=p(a=>!!(a?.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(a?.initiator?.name)||["weak_episode","weak_duplicate"].includes(a?.name)),"weakFamily");if(t(d)&&t(e))return null;const n=p(a=>a?.name?null:[...a?.children??[]].find(o=>o.name==="season"||o.name==="episode")??null,"famChild"),s=n(d),r=n(e);if(s&&r){const a=!!s.tags?.includes("numfirst"),i=!!r.tags?.includes("numfirst");if(a!==i)return null}if(d.name!==e.name){if(d.name==="episode"&&e.name==="year")return d;if(["season","episode"].includes(d.name)){if(["video_codec","audio_codec","container","date"].includes(e.name)){if(e.name==="video_codec"&&/^[hx][\W_]\d/i.test(String(e.raw??""))){const a=(e.inputString??"")[e.start-1]??"";if(/[a-z]/i.test(a))return e}return d}if(e.name==="audio_channels"&&!e.tags?.includes("weak-audio_channels")&&!d.initiator?.children?.named(d.name+"Marker")?.length||e.name==="screen_size"&&!xe(e.raw))return d}}if(["season","episode"].includes(d.name)&&["season","episode"].includes(e.name)&&d.initiator!==e.initiator){const a=p(x=>!!(x.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(x.initiator?.name)),"isWeak"),i=!!d.tags?.includes("numfirst"),o=!!e.tags?.includes("numfirst");if(i!==o&&!a(d)&&!a(e)&&d.start<e.end&&e.start<d.end){const x=i?d:e,m=i?e:d,v=d.inputString??"",C=p((H,L)=>{let S=H;for(;S>=0&&S<v.length&&M.includes(v[S]);)S+=L;let j="";for(;S>=0&&S<v.length&&/\d/.test(v[S]);)j=j+v[S],S+=L;return j},"digitToken"),w=p(H=>H.length===4&&+H>=1900&&+H<=2100,"isYearLike"),k=x.initiator??x,D=m.initiator??m,P=(()=>{const H=C(k.end,1);return H.length>=1&&H.length<=4&&!w(H)})();return(()=>{const H=v.slice(Math.max(0,D.start-12),D.start),L=/(\d{1,3})(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?[\s.,_\-–]*$/iu.exec(H);return!!(L&&!w(L[1]))})()&&!P?m:x}const c=!!(d.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(d.initiator?.name)),l=!!(e.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(e.initiator?.name));if(c&&l)return null;if(c)return d;if(l)return e;const u=!!d.tags?.includes("SxxExx"),f=!!e.tags?.includes("SxxExx");if(u&&!f)return e;if(f&&!u)return d;const g=d.initiator?.raw?.toLowerCase().includes("x")&&!u,h=e.initiator?.raw?.toLowerCase().includes("x")&&!f;if(g&&!h)return d;if(h&&!g)return e}return"__default__"}p(Fe,"seasonEpisodeConflictSolver");function Ue(d){const e=d.children?.toDict?.()??d.children?.to_dict?.(),t=e instanceof Map?Object.fromEntries(e):e||{};if(t.season&&Array.isArray(t.season)){const n=[...t.season].sort((s,r)=>s-r);if(JSON.stringify(n)!==JSON.stringify(t.season))return!1}if(t.episode&&Array.isArray(t.episode)){const n=[...t.episode].sort((s,r)=>s-r);if(JSON.stringify(n)!==JSON.stringify(t.episode))return!1}return!0}p(Ue,"orderingValidator");function It(d){return xe(d.raw)?!0:T(d)}p(It,"validateRoman");function Mo(d){const e=String(d.raw??"");if(/^\d{4}$/.test(e)){const t=parseInt(e,10);if(t>=1900&&t<=2100)return!1}return It(d)}p(Mo,"seasonWordNotYear");function Fc(d){d.range_separators;const e=d.discrete_separators,t=M.split("").filter(S=>!d.range_separators.includes(S)&&S!=="/"&&S!=="\\"),n=[...d.range_separators,...e,...t],s=Ue,r=p(S=>{if(!s(S))return!1;const j=p(V=>{let Q=null,pe=!0;const ye=S.children,re=ye?.named?.(V)??[];for(const U of Array.isArray(re)?re:[re]){if(Q){const Z=ye.previous?.(U,K=>K.name===V+"Separator",0);if(Z){const K=String(Z.raw??"");if(!d.range_separators.includes(K)&&t.includes(K)){const ie=Number(U.value)-Number(Q.value);ie>0&&ie<=d.max_range_gap+1||(pe=!1)}if(e.includes(K)){pe=!0;break}}}Q=U}return pe},"isConsecutive");return j("episode")&&j("season")},"localOrderingValidator"),o=`(?:\\d+|[ivxlcdm]+|${["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty","un","deux","trois","quatre","cinq","sept","huit","neuf","dix","onze","douze","treize","quatorze","quinze","seize","vingt"].join("|")})`,c="(?:\\d+|[ivxlcdm]+)";function l(S){return A(S,"episode")||A(S,"season")}p(l,"isSeasonEpisodeDisabled");const u=new F().regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}).defaults({privateNames:["episodeSeparator","seasonSeparator","episodeMarker","seasonMarker"],formatter:{season:p(S=>parseInt(S,10),"season"),episode:p(S=>parseInt(S,10),"episode"),version:p(S=>parseInt(S,10),"version"),count:p(S=>parseInt(S,10),"count")},children:!0,privateParent:!0,conflictSolver:Fe,abbreviations:[Nc]});u.regex(`第(?<episode>${Ao})[話话集]`,{tags:["SxxExx"],formatter:{episode:ko}}),u.regex(`第(?<season>${Ao})季`,{tags:["SxxExx"],formatter:{season:ko}}),u.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})(?!\\d)",{tags:["SxxExx"]}),u.regex("(?<!\\d)(?<season>\\d{1,2})期",{});const f=I(d.season_markers,"seasonMarker"),g=I([...d.episode_markers,...d.disc_markers],"episodeMarker"),h=I([...d.episode_markers,...d.disc_markers,...n],"episodeSeparator",!0);u.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ge(T,r)},chainBreaker:p(S=>Co(S,d),"chainBreaker"),disabled:l}).defaults({tags:["SxxExx"]}).regex(f+"(?<season>\\d+)@?"+g+"@?(?<episode>\\d+)(?:[a-d](?![a-z0-9]))?(?:v(?<version>\\d+))?").repeater("+").regex(h+"@?(?<episode>\\d+)").repeater("*");const x=I(d.season_ep_markers,"episodeMarker"),m="(?!@"+I(d.season_ep_markers)+"\\d)";u.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ge(T,Ue)},disabled:l}).defaults({tags:["SxxExx"]}).regex("(?!0x[0-9a-fA-F])(?<season>\\d+)"+m+"@?"+x+"@?(?<episode>\\d+)").repeater("+"),u.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ge(T,Ue)},disabled:l}).defaults({tags:["SxxExx"]}).regex("(?!0x[0-9a-fA-F])(?<season>\\d+)"+m+"@?"+x+"@?(?<episode>\\d+)").regex(I([...d.season_ep_markers,...e,...d.range_separators],"episodeSeparator",!0)+"(?<episode>\\d+)").repeater("*"),u.regex("t(?<season>\\d{1,2})@?"+I(d.episode_markers,"episodeMarker")+"@?(?<episode>\\d{1,4})",{tags:["SxxExx"],disabled:l}),u.regex("(?<![^\\W_])(?:SP|EX|OVA|OAV)-?(?<episode>\\d{1,3})(?![^\\W_])",{tags:["SxxExx","special-episode"],disabled:p(S=>A(S,"episode"),"disabled")}),u.regex("(?<season>\\d{1,2})(?:st|nd|rd|th)@?(?:season)(?![^\\W_])",{tags:["SxxExx","numfirst"],disabled:l}),u.regex("(?<!\\d)(?<season>\\d{1,2})(?<episodeMarker>x)(?<episode>\\d{2})(?!\\d)",{tags:["SxxExx"],disabled:l});const v=I([...d.season_markers,...e,...d.range_separators],"seasonSeparator",!0);u.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ge(T,Ue)},disabled:l}).defaults({tags:["SxxExx"]}).regex(f+"(?<season>\\d+)").regex("(?<other>Extras)",{name:"other",value:"Extras",tags:["no-release-group-prefix"]}).repeater("?").regex(v+"(?<season>\\d+)").repeater("*");for(const S of["Special","Pilot","Unaired","Final"])u.string(S,{name:"episode_details",value:S,children:!1,privateParent:!1,disabled:p(j=>A(j,"episode_details"),"disabled")});const{words:C,numfirst:w}=Do(d.season_words),{words:k,numfirst:D}=Do(d.episode_words),P=I(C,"seasonMarker"),E=I(d.of_words);u.chain({validateAll:!0,conflictSolver:Fe,formatter:{season:oe,season_count:oe},validator:{__parent__:ge(T,Ue),season:Mo,season_count:It},chainBreaker:p(S=>Co(S,d),"chainBreaker"),disabled:p(S=>S?.type==="movie"||A(S,"season"),"disabled")}).defaults({formatter:{season:oe,season_count:oe},validator:{season:Mo,season_count:It},conflictSolver:Fe}).regex(P+`@?(?P<season>${o})`).regex(E+`@?(?P<season_count>${c})`).repeater("?").regex("(?:,@?)?@?"+I([...d.range_separators,...e,"@"],"seasonSeparator",!0)+"@?(?P<season>\\d+)").repeater("*");const H="(?:@?"+E+"@?(?<count>\\d+))?";w.length>0&&u.regex("(?<season>\\d{1,2})"+d.ordinal_suffix+"@?@?"+I(w,"seasonMarker")+"(?![^\\W\\d_])"+H,{tags:["SxxExx","numfirst"],formatter:{season:oe,count:p(S=>parseInt(S,10),"count")},disabled:l}),D.length>0&&u.regex("(?<episode>\\d{1,3})"+d.ordinal_suffix+"@?@?"+I(D,"episodeMarker")+"(?![^\\W\\d_])"+H,{tags:["SxxExx","numfirst"],formatter:{episode:oe,count:p(S=>parseInt(S,10),"count")},disabled:p(S=>A(S,"episode"),"disabled")});const L=I(k,"episodeMarker");return u.regex(I(k,"episodeMarker")+"@?(?<season>\\d{1,2})\\.(?<episode>\\d{2,3})(?!\\d)",{tags:["SxxExx"],disabled:l}),u.regex("(?<=[\\s([_-][\\s._-]?)(?<!\\d[-x])(?<season>\\d{1,2})\\.(?<episode>\\d{2,3})(?=[\\s)\\]._-]|$)(?!\\.\\d)",{tags:["SxxExx","decimal-episode"],validator:{__parent__:p(S=>{const V=(S.inputString??"").slice(Math.max(0,S.start-3),S.start);return/[-([]\s?$|^\s*$|\s-\s$/.test(V)||/[([]/.test(V)},"__parent__")},disabled:l}),u.regex("(?<![a-zA-Z\\d])"+L+"@?(?<episode>\\d+)(?:v(?<version>\\d+))?(?:@?"+E+"@?(?<count>\\d+))?",{disabled:p(S=>S?.type==="episode"||A(S,"episode"),"disabled")}),u.regex("(?<![a-zA-Z\\d])"+L+`@?(?<episode>${c})(?:v(?<version>\\d+))?(?:@?`+E+"@?(?<count>\\d+))?",{validator:{episode:It},formatter:{episode:oe},disabled:p(S=>S?.type!=="episode"||A(S,"episode"),"disabled")}),u.regex("S?(?<season>\\d+)-?(?:xE|Ex|E|x)-?(?<other>"+I(d.all_words)+")",{tags:["SxxExx"],formatter:{other:p(()=>"Complete","other")},disabled:p(S=>A(S,"season"),"disabled")}),u.chain({tags:["weak-episode"],disabled:p(S=>S?.type==="movie"||A(S,"episode"),"disabled")}).defaults({validator:null,tags:["weak-episode"]}).regex("(?<![^\\W_])(?<episode>\\d{2})(?!(?:st|nd|rd|th)\\b)(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>[x-])(?<episode>\\d{2})",{abbreviations:null}).repeater("*"),u.chain({tags:["weak-episode"],disabled:p(S=>S?.type==="movie"||A(S,"episode"),"disabled")}).defaults({validator:null,tags:["weak-episode"]}).regex("(?<![^\\W_])0(?<episode>\\d{1,2})(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>[x-])0(?<episode>\\d{1,2})",{abbreviations:null}).repeater("*"),u.chain({tags:["weak-episode"],name:"weak_episode",disabled:p(S=>S?.type==="movie"||A(S,"episode"),"disabled")}).defaults({validator:null,tags:["weak-episode"],name:"weak_episode"}).regex("(?<![^\\W_])(?<episode>\\d{3,4})(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>[x-])(?<episode>\\d{3,4})",{abbreviations:null}).repeater("*"),u.chain({tags:["weak-episode"],disabled:p(S=>S?.type!=="episode"||A(S,"episode"),"disabled")}).defaults({validator:null,tags:["weak-episode"]}).regex("(?<![^\\W_])(?<episode>\\d)(?!-[a-z])(?!%)(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>[x-])(?<episode>\\d{1,2})",{abbreviations:null}).repeater("*"),u.chain({validateAll:!0,validator:{__parent__:T},disabled:p(S=>A(S,"episode"),"disabled")}).defaults({validator:null}).regex("(?<season>\\d{1,2})?(?<episodeMarker>e)(?<episode>\\d{1,4})").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>e|x|-)(?<episode>\\d{1,4})",{abbreviations:null}).repeater("*"),u.chain({disabled:p(S=>A(S,"episode"),"disabled")}).defaults({validator:null}).regex("(?<![a-zA-Z\\d])ep-?(?<episode>\\d{1,4})").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>ep|e|x|-)(?<episode>\\d{1,4})",{abbreviations:null}).repeater("*"),u.chain({tags:["see-pattern"],disabled:l}).defaults({validator:null,tags:["see-pattern"]}).regex("(?<seasonMarker>cap)@?(?<season>\\d{1,2})(?<episode>\\d{2})(?!\\d)").regex("(?<episodeSeparator>[_-])(?<season>\\d{1,2})(?<episode>\\d{2})(?!\\d)").repeater("?"),u.chain({tags:["weak-episode","weak-duplicate"],name:"weak_duplicate",conflictSolver:Fe,disabled:p(S=>S?.episode_prefer_number===!0||S?.type==="movie"||l(S),"disabled")}).defaults({tags:["weak-episode","weak-duplicate"],name:"weak_duplicate",validator:null,conflictSolver:Fe}).regex("(?<![^\\W_])(?<season>0[1-9]|[1-9]\\d(?=[0-3]\\d)|\\d)(?<episode>\\d{2})(?!%)(?!(?![vV]\\d)[^\\W_])").regex("v(?<version>\\d+)").repeater("?").regex("(?<episodeSeparator>x|-)(?<episode>\\d{2})",{abbreviations:null}).repeater("*"),u.regex("v(?<version>\\d+)",{formatter:{version:p(S=>parseInt(S,10),"version")},disabled:p(S=>A(S,"version"),"disabled")}),u.regex("(?<![^\\W_])(?<episode>\\d+)@?"+E+"@?(?<count>\\d+)@?"+L+"?",{formatter:{episode:p(S=>parseInt(S,10),"episode"),count:p(S=>parseInt(S,10),"count")},preMatchProcessor:p(S=>(S.value=B(S.value),S),"preMatchProcessor"),disabled:p(S=>A(S,"episode"),"disabled")}),u.regex("Minisodes?",{children:!1,privateParent:!1,name:"episode_format",value:"Minisode",disabled:p(S=>A(S,"episode_format"),"disabled")}),u.rules(qr,jr,Kr,Gr,Wr,Xr,Zr,Yr,Jr,Qr,new es(d),ts,new ns(d),is,as,ls,cs,os,rs,ss),u}p(Fc,"episodes");const Qt=class Qt extends y{constructor(){super(...arguments),this.priority=72,this.consequence=b}when(e,t){const n=e.inputString??"",s=[],r=new Set(["audio_codec","audio_channels","video_codec","audio_profile","other"]);for(const a of e.named("season")??[]){const i=a.initiator??a;if(!/^s\d{1,3}$/i.test(String(i.raw??""))||[...i.children??[]].some(u=>u.name==="episode")||n[i.start-1]!=="-")continue;const c=e.range(Math.max(0,i.start-12),i.start-1,u=>!u.private&&r.has(u.name??""),-1)??e.range(Math.max(0,i.start-12),i.start-1,u=>!u.private&&r.has(u.name??""),0),l=e.markers.atMatch(i,u=>u.name==="group",0);if(!(!c&&!l)){s.push(a);for(const u of i.children??[])s.includes(u)||s.push(u)}}return s.length?s:!1}};p(Qt,"RemoveGroupSuffixSeason"),Qt.priority=72;let Wr=Qt;const en=class en extends y{constructor(){super(...arguments),this.priority=60,this.consequence=b}when(e,t){const n=e.inputString??"",s=[],r=p(a=>!!(a.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(a.initiator?.name)),"isWeak");for(const a of e.markers.named("path")??[]){const i=e.range(a.start,a.end,c=>c.name==="episode"&&!c.private&&r(c))??[];if(!i.length)continue;const o=e.range(a.start,a.end,c=>!c.private&&(c.name==="season"||c.name==="year"||c.name==="date"||c.name==="episode"&&c.tags?.includes("SxxExx")),0);for(const c of i){const l=c.initiator??c,u=n.slice(l.end,l.end+5);if(/^[\s._-]?PPV/i.test(u)){for(const f of[l,...l.children??[]])s.includes(f)||s.push(f);continue}if(!o&&l.start===a.start&&/^[1-9]\d$/.test(String(l.raw??""))&&(n.slice(l.end,a.end).match(/[A-Za-z][a-z]+/g)??[]).length>=2)for(const h of[l,...l.children??[]])s.includes(h)||s.push(h)}}return s.length?s:!1}};p(en,"EventNumberAsTitleRule"),en.priority=60;let qr=en;const Uc=/^(?:ufc|bellator|pfl|rizin|ksw|glory|invicta[\W_]?fc|cage[\W_]?warriors|one[\W_]?(?:championship|fc))(?:[\W_]|$)/i,tn=class tn extends y{constructor(){super(...arguments),this.priority=60,this.consequence=[b,$]}when(e,t){const n=e.inputString??"",s=[],r=[];for(const a of e.markers.named("path")??[]){if(!Uc.test(n.slice(a.start,a.end))||e.range(a.start,a.end,l=>!l.private&&(l.name==="date"||l.tags?.includes("SxxExx")),0))continue;const o=p(l=>l.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(l.initiator?.name),"isWeak"),c=e.range(a.start,a.end,l=>!l.private&&l.name==="season"&&o(l))??[];for(const l of c){const u=l.initiator??l,f=String(u.raw??"").trim();if(/^\d{3,4}$/.test(f)){for(const g of[l,u,...u.children??[]])s.includes(g)||s.push(g);r.push(new N(u.start,u.end,{name:"episode",value:parseInt(f,10),inputString:n}))}}}return s.length||r.length?[s,r]:!1}};p(tn,"SportsEventNumberIsOneNumber"),tn.priority=60;let jr=tn;const Bc=/^(?:formula[\W_]?(?:1|e|one)|f1|motogp|moto2|moto3|nascar|indycar|wrc|wec|dtm|supercars|superbike|wsbk)(?:[\W_]|$)/i,nn=class nn extends y{constructor(){super(...arguments),this.priority=60,this.consequence=[b,$]}when(e,t){const n=e.inputString??"",s=[],r=[];for(const a of e.markers.named("path")??[]){const i=n.slice(a.start,a.end);if(!Bc.test(i)||e.range(a.start,a.end,u=>!u.private&&(u.name==="date"||u.tags?.includes("SxxExx")),0))continue;const c=/(?:^|[\W_])round[\W_]?(\d{1,2})(?=[\W_]|$)/i.exec(i),l=p(u=>u.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(u.initiator?.name),"isWeak");for(const u of e.range(a.start,a.end,f=>!f.private&&(f.name==="season"||f.name==="episode")&&l(f))??[]){const f=u.initiator??u;for(const g of[u,f,...f.children??[]])s.includes(g)||s.push(g)}if(c){const u=a.start+c.index+c[0].search(/round/i),f=a.start+c.index+c[0].length;r.push(new N(u,f,{name:"episode",value:parseInt(c[1],10),inputString:n}))}}return s.length||r.length?[s,r]:!1}};p(nn,"MotorsportRoundIsEpisode"),nn.priority=60;let Kr=nn;const rn=class rn extends y{constructor(){super(...arguments),this.priority=60,this.consequence=b}when(e,t){const n=[];for(const s of e.named("episode")??[]){const r=s.initiator??s,a=[...r.children??[]].find(u=>u.name==="episodeMarker");if(!a||String(a.raw??"").length<3)continue;const i=e.markers.atMatch(s,u=>u.name==="path",0);if(!i)continue;const o=e.range(s.end,i.end,u=>!u.private&&u.name==="year",0);if(!o||e.range(i.start,i.end,u=>!u.private&&(u.name==="season"||u.name==="episode"&&u.tags?.includes("SxxExx")),0))continue;const l=String(e.inputString??"").slice(s.end,o.start);if(/[a-zA-Z]{2,}/.test(l)){n.push(s),n.includes(r)||n.push(r);for(const u of r.children??[])n.includes(u)||n.push(u)}}return n.length?n:!1}};p(rn,"EpisodeWordBeforeYearAsTitle"),rn.priority=60;let Gr=rn;const sn=class sn extends y{constructor(){super(...arguments),this.priority=-64,this.consequence=[b,$]}when(e,t){const n=e.inputString??"",s=[],r=[];if((e.named("episode")??[]).length)return!1;for(const i of e.markers.named("path")??[]){const o=e.range(i.start,i.end,m=>m.name==="crc32",0),c=e.range(i.start,i.end,m=>m.name==="release_group"&&m.tags?.includes("anime"),0),l=(e.markers.range(i.start,i.end,m=>m.name==="group")??[]).length;if(!o&&!c&&l<3)continue;let u=!1;for(const m of e.markers.range(i.start,i.end,v=>v.name==="group")??[]){const v=n.slice(m.start+1,m.end-1).trim();if(!/^\d{1,3}$/.test(v))continue;const C=e.range(m.start,m.end,w=>!w.private)??[];if(!C.some(w=>!["alternative_title","episode_title"].includes(w.name??"")&&!w.tags?.includes("weak-episode"))){s.push(...C),r.push(new N(m.start+1,m.end-1,{name:"episode",value:parseInt(v,10),inputString:n,tags:["anime"]})),u=!0;break}}if(u)continue;const f=e.range(i.start,i.end,m=>m.name==="title",0);if(!f)continue;const g=/^(.*[^\W\d_])[\s._-]+(\d{1,3})$/.exec(n.slice(f.start,f.end));if(!g)continue;const h=f.start+g[1].length+(g[0].length-g[1].length-g[2].length);s.push(f);const x=new N(f.start,f.start+g[1].length,{name:"title",value:B(g[1]),inputString:n});r.push(x),r.push(new N(h,f.end,{name:"episode",value:parseInt(g[2],10),inputString:n,tags:["anime"]}))}return s.length||r.length?[s,r]:!1}};p(sn,"AnimeTrailingEpisodeRule"),sn.priority=-64;let Xr=sn;const an=class an extends y{constructor(){super(...arguments),this.priority=40,this.consequence=b}when(e,t){const n=e.inputString??"",s=[],r=p(i=>i.name==="episode"&&!i.private&&(i.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(i.initiator?.name)),"isWeakEp"),a=p(i=>{for(const o of[...i.children??[],i])s.includes(o)||s.push(o);!i.children?.length&&!s.includes(i)&&s.push(i)},"removeGroup");for(const i of e.markers.named("path")??[]){const o=e.range(i.start,i.end,r)??[];if(!o.length)continue;const c=e.range(i.start,i.end,m=>m.name==="episode"&&!m.private&&!r(m)&&!!m.initiator?.children?.named?.("episodeMarker")?.length,0),l=new Map;for(const m of o){const v=m.initiator??m;l.set(v,[...l.get(v)??[],m])}if(c){for(const m of l.keys())a(m);continue}if(l.size<2)continue;const u=p(m=>{let v=0;const C=String(m.raw??"");/^0\d{1,2}$/.test(C)&&(v+=4);let w=m.start-1;for(;w>=0&&(n[w]===" "||n[w]==="."||n[w]==="_");)w--;return n[w]==="-"&&(v+=1),e.markers.atMatch(m,k=>k.name==="group",0)&&(v-=2),v},"score"),f=[...l.keys()].map(m=>[m,u(m)]),g=Math.max(...f.map(([,m])=>m)),h=f.filter(([,m])=>m===g);if(h.length===f.length)continue;const x=new Set(h.flatMap(([m])=>(l.get(m)??[]).map(v=>Number(v.value))));for(const[m,v]of f){if(v>=g)continue;const C=l.get(m)??[];C.length>1||C.some(w=>x.has(Number(w.value)))||a(m)}}return s.length?s:!1}};p(an,"PreferAnchoredWeakEpisodeRule"),an.priority=40;let Zr=an;function Yo(d){if(d.named("version")?.length>0||d.named("crc32")?.length>0)return!0;const e=d.markers?.named("group")||[],t=Array.isArray(e)?e:e?[e]:[];for(const n of t){const s=d.range?.(n.start,n.end,c=>c.name==="screen_size");if(Array.isArray(s)?s.length>0:!!s)return!0;const a=d.range?.(n.start,n.end,c=>!c.private&&!c.tags?.includes("weak-language"))||[];if((Array.isArray(a)?a:a?[a]:[]).filter(c=>c.name!=="release_group").length===0){const c=(d.inputString??"").slice(n.start+1,n.end-1).trim();if(c&&!/^\d+$/.test(c))return!0}}return!1}p(Yo,"isAnime");function zc(d,e){const t=d.markers.atMatch(e,s=>s.name==="group",0);if(!t||t.start!==e.start||t.end!==e.end)return!1;const n=String(t.raw??"");return!n.startsWith("(")||!n.endsWith(")")?!1:/(?:^|[\s._-])\d{1,4}[\s._]*$/.test((d.inputString??"").slice(0,t.start))}p(zc,"isAbsoluteNumberAnnotation");const on=class on extends y{constructor(){super(...arguments),this.priority=32,this.consequence=[b,$]}when(e,t){const n=e.inputString??"",s=[],r=[],a=e.named("season")??[],i=new Set;for(const o of a){const c=o.initiator??o;if(i.has(c))continue;i.add(c);const l=[...c.children??[]],u=l.find(w=>w.name==="seasonMarker");if(!u)continue;const f=String(u.raw??""),g=/^[a-zà-ÿа-я]{3,}$/i.test(f),h=f.toLowerCase()==="s"&&zc(e,c);if(!g&&!h||g&&/s$/i.test(f))continue;const x=l.filter(w=>w.name==="season");if(x.length!==2)continue;const m=l.find(w=>w.name==="seasonSeparator");if(!m||String(m.raw??"").trim()!=="-"||g&&(n[m.start-1]!==" "||n[m.end]!==" ")||g&&!Yo(e))continue;const v=e.markers.atMatch(o,w=>w.name==="path",0);if(v&&e.range(v.start,v.end,k=>k.name==="other"&&k.value==="Complete",0))continue;const C=new N(x[1].start,x[1].end,{name:"episode",value:x[1].value,inputString:n});s.push(x[1]),r.push(C)}return s.length||r.length?[s,r]:!1}};p(on,"SeasonWordDashedEpisodeRule"),on.priority=32;let Yr=on;const cn=class cn extends y{constructor(){super(...arguments),this.priority=70,this.consequence=[b,$]}when(e,t){const n=[],s=[],r=p(c=>!!(c.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(c.initiator?.name)),"isWeak"),a=p(c=>{const l=c.initiator??c;n.includes(c)||n.push(c);for(const u of l.children??[])n.includes(u)||n.push(u)},"removeWithParent"),i=[...e],o=i.filter(c=>(c.name==="season"||c.name==="episode")&&c.tags?.includes("numfirst"));for(const c of o){const l=c.initiator??c,u=i.find(h=>{if(h.name!=="season"&&h.name!=="episode"||h.tags?.includes("numfirst")||r(h))return!1;const x=h.initiator??h;return x===l?!1:x.start<l.end&&l.start<x.end});if(!u)continue;const f=i.some(h=>!h.private&&(h.name==="screen_size"||h.name==="year")&&h.start<u.end&&u.start<h.end),g=/^(?:st|nd|rd|th|ª|º|°)/i.test(String(e.inputString??"").slice(c.end,c.end+2));f||g?(a(u),f||s.push(new N(u.start,u.end,{name:"episode",value:u.value,inputString:e.inputString}))):a(c)}return n.length||s.length?[n,s]:!1}};p(cn,"RemoveNumfirstMarkerCollision"),cn.priority=70;let Jr=cn;const Re=class Re extends y{constructor(){super(...arguments),this.priority=64,this.consequence=[b,new le("episode_count"),new le("season_count")]}when(e,t){const n=[],s=[],r=[];for(const a of e.named("count")??[]){const i=e.range(a.initiator.start,a.start,c=>c.name==="episode"||c.name==="season"),o=i.length?i[i.length-1]:void 0;o?o.name==="episode"?s.push(a):r.push(a):n.push(a)}return n.length||s.length||r.length?[n,s,r]:!1}};p(Re,"CountValidator"),Re.priority=64,Re.consequence=[b,new le("episode_count"),new le("season_count")];let Qr=Re;const ln=class ln extends y{constructor(e){super(),this.priority=128,this.config=e}when(e,t){const n=new Set((this.config.disc_markers||[]).map(a=>a.toLowerCase()));if(n.size===0)return!1;const s=[],r=e.named("episode",a=>!a.private)||[];for(const a of r){const i=a.initiator;if(!i)continue;const o=i.children;if(!o)continue;const c=(typeof o.named=="function"?o.named("episodeMarker"):[])||[];for(const l of c){const u=(l.rawString||l.raw||l.value||"").toString().toLowerCase();if(n.has(u)){s.push(a);break}}}return s.length>0?s:!1}then(e,t,n){const s=A(n,"disc");for(const r of t)if(s){const a=r.initiator;if(e.remove(r),a){const i=a.children?typeof a.children[Symbol.iterator]=="function"?[...a.children]:[]:[];for(const o of i)e.includes(o)&&e.remove(o);e.includes(a)&&e.remove(a)}}else e.remove(r),r.name="disc",e.append(r)}};p(ln,"DiscMarkerRule"),ln.priority=128;let es=ln;const Wi=class Wi extends y{when(e,t){const n=[],s=e.markers?.named("group")||[],r=Array.isArray(s)?s:s?[s]:[];for(const a of e){if(a.name!=="episode"&&a.name!=="season"||typeof a.value!="number"||!r.some(g=>a.end===g.end))continue;const o=e.inputString||"";let c=a.end-1,l=c;for(;l>a.start&&/\d/.test(o[l-1]);)l--;if(l>=c)continue;const u=o.slice(l,c),f=parseInt(u,10);isNaN(f)||f===a.value||n.push({match:a,correctValue:f})}return n.length>0?n:!1}then(e,t,n){for(const{match:s,correctValue:r}of t){s.value=r,e.inputString;let a=s.end-1;s.rawEnd<a&&(s.rawEnd=a)}}};p(Wi,"FixCorruptedGroupBoundaryValues");let ts=Wi;const qi=class qi extends y{constructor(e){super(),this.consequence=$,this.config=e}when(e,t){const n=[],s=new Set(this.config.range_separators||["-","~","to","a"]),r=e.markers?.named("path")||[],a=Array.isArray(r)?r:r?[r]:[],i=p(o=>{for(const c of a)if(o.start>=c.start&&o.end<=c.end)return c;return null},"getFilepart");for(const o of["season","episode","absolute_episode","disc"]){const c=o==="season"?this.config.season_max_range:this.config.episode_max_range,l=e.named(o,f=>!f.private)||[];if(l.length<2)continue;const u=[...l].sort((f,g)=>f.start-g.start);for(let f=0;f<u.length-1;f++){const g=u[f],h=u[f+1],x=i(g),m=i(h);if(x!==m||!x)continue;const v=typeof g.value=="number"?g.value:parseInt(g.value,10),C=typeof h.value=="number"?h.value:parseInt(h.value,10);if(isNaN(v)||isNaN(C)||C<=v)continue;const w=C-v;if(w<=1||w>c)continue;const k=e.inputString?.slice(g.end,h.start)||"",D=k.replace(/[\s.]/g,"").toLowerCase(),P=D.replace(/[sexp]/gi,"");if(/[-~_]/.test(k)||o==="season"&&D===":"||s.has(D)||s.has(P))for(let S=v+1;S<C;S++){const j=new N(g.start,h.end,{name:o,value:S,inputString:e.inputString,tags:g.tags?[...g.tags]:[]});n.push(j)}}}return n.length>0?n:!1}};p(qi,"RangeExpansionRule");let ns=qi;const un=class un extends y{constructor(){super(...arguments),this.consequence=b,this.priority=64}when(e,t){const n=[];for(const s of e.markers?.named("path")||[]){const r=e.range?.(s.start,s.end,a=>a.name==="season"&&!a.private&&a.tags?.includes("SxxExx"))?.[0];if(r?.initiator?.children?.named("episode"))for(const a of e.range?.(r.end,s.end,i=>i.name==="season"&&!i.private)||[])(!a.tags?.includes("SxxExx")||!a.initiator?.children?.named("episode"))&&(a.initiator?(n.push(a.initiator),n.push(...a.initiator.children||[])):n.push(a))}return n.length>0?n:!1}};p(un,"RemoveInvalidSeasonRule"),un.priority=64;let rs=un;const dn=class dn extends y{constructor(){super(...arguments),this.consequence=b,this.priority=64}when(e,t){const n=[];for(const s of e.markers?.named("path")||[]){const r=e.range?.(s.start,s.end,a=>a.name==="episode"&&!a.private&&a.tags?.includes("SxxExx"))?.[0];if(r){const a=this.getEpisodePrefix(e,r);for(const i of e.range?.(r.end,s.end,o=>o.name==="episode"&&!o.private)||[]){if(i.tags?.includes("SxxExx"))continue;const o=this.getEpisodePrefix(e,i),c=i.initiator?.children?.named?.("episodeMarker")||[],u=(Array.isArray(c)?c:[c]).some(g=>{const h=(g.rawString||g.raw||g.value||"").toString().toLowerCase();return h==="e"||h==="ep"});(a&&o?a.value?.toLowerCase?.()!==o.value?.toLowerCase?.():!i.tags?.includes("SxxExx")&&!u)&&(i.initiator?(n.push(i.initiator),n.push(...i.initiator.children||[])):(o&&n.push(o),n.push(i)))}}}return n.length>0?n:!1}getEpisodePrefix(e,t){return e.previous?.(t,n=>!n.private&&["episodeMarker","episodeSeparator"].includes(n.name))?.[0]}};p(dn,"RemoveInvalidEpisodeRule"),dn.priority=64;let ss=dn;const pn=class pn extends y{constructor(){super(...arguments),this.consequence=b,this.priority=64}when(e,t){const n=[],s=e.markers?.named("path")||[],r=Array.isArray(s)?s:s?[s]:[];for(const a of r){const i=(e.range?.(a.start,a.end,c=>c.tags?.includes("weak-duplicate"))||[]).slice().reverse(),o={};for(const c of i){const l=c.name??"",u=c.initiator?.pattern??c.pattern??null;u&&(o[l]||(o[l]=new Set),o[l].has(u)?n.push(c):o[l].add(u))}}return n.length>0?n:!1}};p(pn,"RemoveWeakDuplicateRule"),pn.priority=64;let as=pn;const fn=class fn extends y{constructor(){super(...arguments),this.consequence=b,this.priority=128}enabled(e){return e?.type!=="movie"}when(e,t){const n=[],s=Yo(e),r=e.markers?.named("path")||[],a=Array.isArray(r)?r:r?[r]:[];for(const i of a){const o=e.range?.(i.start,i.end,u=>u.initiator?.name==="weak_episode")||[],l=(e.range?.(i.start,i.end,u=>u.initiator?.name==="weak_duplicate")||[]).filter(u=>{const f=e.range?.(u.start,u.end,g=>!g.private&&!!g.name&&g.name!=="season"&&g.name!=="episode"&&!g.tags?.includes("weak-episode")&&g.start<=u.start&&g.end>=u.end&&(g.start<u.start||g.end>u.end))||[];return!(Array.isArray(f)?f.length>0:f)});if(s)o.length>0&&n.push(...l);else if(l.length>0){const u=e.range?.(i.start,i.end,g=>{if(g.name!=="episode"||g.initiator?.name!=="weak_episode")return!1;const h=g.initiator?.children;return h?Array.isArray(h)?h.some(x=>x.name==="episodeSeparator"):typeof h.named=="function"?(h.named("episodeSeparator")||[]).length>0:!1:!1})||[],f=(e.range?.(i.start,i.end,g=>g.tags?.includes("SxxExx")&&!g.private)||[]).length>0;u.length===0&&!f?n.push(...o):u.length>0&&n.push(...l)}}return n.length>0?n:!1}};p(fn,"WeakConflictSolverRule"),fn.priority=128;let is=fn;const gn=class gn extends y{constructor(){super(...arguments),this.priority=-1}when(e,t){const n=[],s=e.markers?.named("path")||[],r=Array.isArray(s)?s:[s];for(const a of r){const i=e.range?.(a.start,a.end,h=>h.name==="episode"&&!h.private)||[];if(i.length<2)continue;const o=e.markers?.named?.("group")||[],l=(Array.isArray(o)?o:o?[o]:[]).filter(h=>h.start>=a.start&&h.end<=a.end),u=p(h=>l.some(x=>h.start>=x.start&&h.end<=x.end),"isInGroup"),f=i.filter(u),g=i.filter(h=>!u(h));f.length>0&&g.length>0&&n.push(...f)}return n.length===0?!1:(this._toRename=n,!0)}then(e,t,n){const s=this._toRename||[];for(const r of s)e.remove(r),r.name="absolute_episode",e.append(r)}};p(gn,"AbsoluteEpisodeInGroupRule"),gn.priority=-1;let os=gn;const hn=class hn extends y{constructor(){super(...arguments),this.priority=-2048,this.consequence=b}when(e,t){const n=(e.named("title")??[]).filter(a=>!a.private);if(!n.length)return!1;const s=p(a=>!!(a.tags?.includes("weak-episode")||a.tags?.includes("weak-duplicate")||["weak_episode","weak_duplicate"].includes(a.initiator?.name)),"isWeak"),r=[];for(const a of["episode","season"])for(const i of e.named(a)??[])if(!(i.private||!s(i)||i.tags?.includes("SxxExx"))&&n.some(o=>i.start>=o.start&&i.end<=o.end))for(const o of[i,...i.initiator===i?i.children??[]:[]])r.includes(o)||r.push(o);return r.length?r:!1}};p(hn,"RemoveWeakInsideTitleRule"),hn.priority=-2048;let cs=hn;const mn=class mn extends y{constructor(){super(...arguments),this.consequence=b,this.priority=64}when(e,t){const n=[],s=[],r=e.markers?.named("path")||[],a=Array.isArray(r)?r:[r];for(const i of a){const o=e.range?.(i.start,i.end,l=>!l.private&&l.tags?.includes("SxxExx"))||[];if(Array.isArray(o)?o.length>0:!!o){const l=e.range?.(i.start,i.end,f=>f.tags?.includes("weak-episode"))||[],u=new Map;for(const f of l){const g=f.initiator;u.has(g)||u.set(g,[]),u.get(g).push(f)}for(const f of l){const g=f.initiator,h=f.name==="episode"&&g?.name==="weak_episode",m=(u.get(g)||[]).filter(E=>E.name==="episode").length>1,v=e.inputString||"",C=g?.start??f.start,w=g?.end??f.end,k=C>0?v[C-1]:"",D=w<v.length?v[w]:"",P=(!k||M.includes(k))&&(!D||M.includes(D));h&&P&&m?s.push(f):n.push(f)}}}return this._toRename=s,n.length>0||s.length>0?n:!1}then(e,t,n){if(t&&Array.isArray(t))for(const r of t)e.remove(r);const s=this._toRename||[];for(const r of s)e.remove(r),r.name="absolute_episode",e.append(r)}};p(mn,"RemoveWeakIfSxxExxRule"),mn.priority=64;let ls=mn;function Vc(d){const e=new F({disabled:p(l=>A(l,"container"),"disabled")});e.regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}),e.defaults({name:"container",formatter:p(l=>l.replace(new RegExp(`[${Mt(M)}]`,"g"),""),"formatter"),tags:["extension"],conflictSolver:p((l,u)=>u.name==="source"||u.name==="video_codec"||u.name==="container"&&!u.tags.includes("extension")?u:"__default__","conflictSolver")});const t=d.subtitles||[],n=d.info||[],s=d.videos||[],r=d.torrent||[],a=d.nzb||[],i=d.archives||[],o=d.images||[];i.length&&e.regex("\\."+I(i,void 0,!0)+"$",{exts:i,tags:["extension","archive"]}),e.regex("\\.r\\d{2}$",{tags:["extension","archive"]}),o.length&&e.regex("\\."+I(o,void 0,!0)+"$",{exts:o,tags:["extension","image"]}),t.length&&e.regex("\\."+I(t,void 0,!0)+"$",{exts:t,tags:["extension","subtitle"]}),n.length&&e.regex("\\."+I(n,void 0,!0)+"$",{exts:n,tags:["extension","info"]}),s.length&&e.regex("\\."+I(s,void 0,!0)+"$",{exts:s,tags:["extension","video"]}),r.length&&e.regex("\\."+I(r,void 0,!0)+"$",{exts:r,tags:["extension","torrent"]}),a.length&&e.regex("\\."+I(a,void 0,!0)+"$",{exts:a,tags:["extension","nzb"]}),e.defaults({clear:!0,name:"container",validator:T,formatter:p(l=>l.toLowerCase(),"formatter"),conflictSolver:p((l,u)=>u.name==="source"||u.name==="video_codec"||u.name==="container"&&u.tags.includes("extension")?l:"__default__","conflictSolver")});const c=t.filter(l=>!["sub","ass"].includes(l));return e.string(...c,{tags:["subtitle"]}),e.string(...s,{tags:["video"]}),e.string(...r,{tags:["torrent"]}),e.string(...a,{tags:["nzb"]}),e.rules(us)}p(Vc,"container");const vn=class vn extends y{constructor(){super(...arguments),this.consequence=[b,$]}when(e,t){const n=e.named("container"),s=[],r=[];for(const a of Array.isArray(n)?n:n?[n]:[]){if(String(a.value??"").toLowerCase()!=="ogg"||a.tags?.includes("extension"))continue;const i=e.markers.atMatch(a,c=>c.name==="group",0);!i||!e.range(i.start,i.end,c=>c.name==="video_codec",0)||(s.push(a),r.push(new N(a.start,a.end,{name:"audio_codec",value:"Vorbis",inputString:e.inputString})))}return s.length?[s,r]:!1}};p(vn,"OggCodecTagToVorbis"),vn.priority=O;let us=vn;function Rc(d){const e=d.rip_prefix??"(?P<other>Rip)-?",t=d.rip_suffix??"-?(?P<other>Rip)";function n(a,i="",o=""){return a.map(c=>`${i}(${c})${o}`)}p(n,"buildSourcePattern");function s(a,i){return["other","release_group"].includes(i.name??"")?i:"__default__"}p(s,"demoteOther");const r=new F({disabled:p(a=>A(a,"source"),"disabled")});return r.regexDefaults({flags:"i",abbreviations:[X],privateParent:!0,children:!0}),r.defaults({name:"source",tags:["video-codec-prefix","streaming_service.suffix"],validateAll:!0,validator:{__parent__:Xo(se,ae)}}),r.regex(...n(["VHS"],"",R(t)),{value:{source:"VHS",other:"Rip"}}),r.regex(...n(["CAM"],"",R(t)),{value:{source:"Camera",other:"Rip"}}),r.regex(...n(["HD-?CAM","CAM-?HD"],"",R(t)),{value:{source:"HD Camera",other:"Rip"}}),r.regex(...n(["HQ-?CAM"],"",R(t)),{value:{source:"Camera",other:"Rip"}}),r.regex(...n(["S-?Print"],"",R(t)),{value:{source:"Camera"}}),r.regex(...n(["TELESYNC","TS"],"",R(t)),{value:{source:"Telesync",other:"Rip"},tags:["video-codec-prefix"],overrides:["tags"]}),r.regex(...n(["HD-?TELESYNC","HD-?TS"],"",R(t)),{value:{source:"HD Telesync",other:"Rip"}}),r.regex(...n(["WORKPRINT","WP"]),{value:"Workprint"}),r.regex(...n(["TELECINE","TC"],"",R(t)),{value:{source:"Telecine",other:"Rip"}}),r.regex(...n(["HD-?TELECINE","HD-?TC"],"",R(t)),{value:{source:"HD Telecine",other:"Rip"}}),r.regex(...n(["PPV"],"",R(t)),{value:{source:"Pay-per-view",other:"Rip"}}),r.regex(...n(["SD-?TV"],"",R(t)),{value:{source:"TV",other:"Rip"}}),r.regex(...n(["TV"],"",t),{value:{source:"TV",other:"Rip"}}),r.regex(...n(["TV","SD-?TV"],e),{value:{source:"TV",other:"Rip"}}),r.regex(...n(["TV-?(?=Dub)"]),{value:"TV"}),r.regex(...n(["DVB","PD-?TV"],"",R(t)),{value:{source:"Digital TV",other:"Rip"}}),r.regex(...n(["DVD"],"",R(t)),{value:{source:"DVD",other:"Rip"}}),r.regex(...n(["DVD-?R[59]"],"",""),{value:{source:"DVD"}}),r.regex(...n(["LD"],"",t),{value:{source:"Laserdisc",other:"Rip"}}),r.regex(...n(["LASERDISC"],"",R(t)),{value:{source:"Laserdisc",other:"Rip"}}),r.regex(...n(["DM"],"",R(t)),{value:{source:"Digital Master",other:"Rip"}}),r.regex(...n(["VIDEO-?TS","DVD-?R(?:$|(?!E))","DVD-?9","DVD-?5"]),{value:"DVD"}),r.regex(...n(["HD-?TV"],"",R(t)),{conflictSolver:s,value:{source:"HDTV",other:"Rip"}}),r.regex(...n(["TV-?HD"],"",t),{conflictSolver:s,value:{source:"HDTV",other:"Rip"}}),r.regex(...n(["TV"],"","-?(?P<other>Rip-?HD)"),{conflictSolver:s,value:{source:"HDTV",other:"Rip"}}),r.regex(...n(["VOD"],"",R(t)),{value:{source:"Video on Demand",other:"Rip"}}),r.regex(...n(["WEB","WEB-?DL"],"",t),{value:{source:"Web",other:"Rip"}}),r.regex(...n(["WEB-?(?P<another>Cap)"],"",R(t)),{value:{source:"Web",other:"Rip",another:"Rip"}}),r.regex(...n(["WEB-?DL","WEB-?U?HD","DL-?WEB","DL(?=-?Mux)"]),{value:{source:"Web"}}),r.regex("(WEB)",{value:"Web",tags:"weak.source"}),r.regex(...n(["HD-?DVD"],"",R(t)),{value:{source:"HD-DVD",other:"Rip"}}),r.regex(...n(["Blu-?ray","BD","BD[59]","BD25","BD50"],"",R(t)),{value:{source:"Blu-ray",other:"Rip"}}),r.regex(...n(["(?P<another>BR)-?(?=Scr(?:eener)?)","(?P<another>BR)-?(?=Mux)"]),{value:{source:"Blu-ray",another:"Reencoded"}}),r.regex(...n(["(?P<another>BR)"],"",t),{value:{source:"Blu-ray",other:"Rip",another:"Reencoded"}}),r.regex(...n(["Ultra-?Blu-?ray","Blu-?ray-?Ultra"]),{value:"Ultra HD Blu-ray"}),r.regex(...n(["AHDTV"]),{value:"Analog HDTV"}),r.regex(...n(["UHD-?TV"],"",R(t)),{conflictSolver:s,value:{source:"Ultra HDTV",other:"Rip"}}),r.regex(...n(["UHD"],"",t),{conflictSolver:s,value:{source:"Ultra HDTV",other:"Rip"}}),r.regex(...n(["DSR","DTH"],"",R(t)),{value:{source:"Satellite",other:"Rip"}}),r.regex(...n(["DSR?","SAT"],"",t),{value:{source:"Satellite",other:"Rip"}}),r.rules(ds,ps,fs),r}p(Rc,"source");const xn=class xn extends y{constructor(){super(...arguments),this.consequence=b}enabled(e){return!A(e,"source")}when(e,t){const n=[];for(const s of e.markers.named("path")?[e.markers.named("path")].flat():[]){const r=s,a=e.range(r.start,r.end,i=>i.name==="source");for(const i of Array.isArray(a)?a:a?[a]:[]){const o=i.initiator??i,c=se(o),l=e.range(o.start-1,o.start,g=>g.tags?.includes("source-prefix"));if(!c&&!(Array.isArray(l)?l.length>0:l)){o.children?.length>0&&n.push(...o.children.toArray()),n.push(o);continue}const u=ae(o),f=e.range(o.end,o.end+1,g=>g.tags?.includes("source-suffix"));!u&&!(Array.isArray(f)?f.length>0:f)&&(o.children?.length>0&&n.push(...o.children.toArray()),n.push(o))}}return n}};p(xn,"ValidateSourcePrefixSuffix"),xn.priority=64;let ds=xn;const yn=class yn extends y{constructor(){super(...arguments),this.consequence=b}enabled(e){return!A(e,"source")}when(e,t){const n=[],s=p(r=>Array.isArray(r)?r:r?[r]:[],"toArray");for(const r of[e.markers.named("path")].flat().filter(Boolean)){const a=e.range(r.start,r.end,u=>u.name==="source"),i=p(u=>Array.isArray(u)?u.length>0:!!u,"hasText"),o=p((u,f)=>e.holes(u,f,{predicate:p(g=>!!(g.value&&String(g.value).replace(new RegExp(`[${z}]`,"g"),"")),"predicate")}),"textHoles"),c=s(e.range(r.start,r.end,u=>u.name==="container")),l=p(u=>c.some(f=>f.start<=u.start&&f.end>=u.end),"isExtension");for(const u of s(a)){const f=!!u.tags?.includes("weak.source"),g=s(e.range(u.end,r.end,h=>h.name==="source"));if(g.length!==0&&i(o(r.start,u.start))){if(!f){const h=g.filter(m=>!l(m));if(h.length===0||!i(o(u.end,h[0].start))||s(e.range(u.end,h[0].start,m=>!!m.name&&m.name!=="source")).length===0)continue}u.children?.length>0&&n.push(...u.children.toArray()),n.push(u)}}}return n}};p(yn,"ValidateWeakSource"),yn.priority=64;let ps=yn;const ji=class ji extends y{constructor(){super(...arguments),this.consequence=[b,$]}enabled(e){return!A(e,"source")}when(e,t){const n=[],s=[];for(const r of[e.markers.named("path")].flat().filter(Boolean)){const a=e.range(r.start,r.end,i=>!i.private&&i.name==="source"&&i.value==="Blu-ray");for(const i of Array.isArray(a)?a:a?[a]:[]){const o=p((u,f)=>e.range(u,f,g=>!g.private&&g.name==="other"&&g.value==="Ultra HD")?.[0],"findUltraHd");let c=o(r.start,i.start);if(c){const u=e.holes(c.end,i.start,{predicate:p(g=>!!(g.value&&String(g.value).replace(new RegExp(`[${z}]`,"g"),"")),"predicate")}),f=e.range(c.end,i.start,g=>!g.private&&!["screen_size","color_depth"].includes(g.name??"")&&!(g.name==="other"&&g.tags?.includes("uhdbluray-neighbor")));((Array.isArray(u)?u.length:u?1:0)>0||(Array.isArray(f)?f.length:f?1:0)>0)&&(c=void 0)}if(!c&&(c=o(i.end,r.end),c)){const u=e.holes(i.end,c.start,{predicate:p(g=>!!(g.value&&String(g.value).replace(new RegExp(`[${z}]`,"g"),"")),"predicate")}),f=e.range(i.end,c.start,g=>!g.private&&!["screen_size","color_depth"].includes(g.name??"")&&!(g.name==="other"&&g.tags?.includes("uhdbluray-neighbor")));((Array.isArray(u)?u.length:u?1:0)>0||(Array.isArray(f)?f.length:f?1:0)>0)&&(c=void 0)}if(!c){const u=e.range(r.start,r.end,f=>f.name==="screen_size"&&f.value==="2160p");if(!(Array.isArray(u)?u.length:u))continue}c&&(c.private=!0);const l=new N(i.start,i.end,{name:i.name,inputString:e.inputString,tags:[...i.tags??[]],private:i.private,value:"Ultra HD Blu-ray"});n.push(i),s.push(l)}}return n.length||s.length?[n,s]:!1}};p(ji,"UltraHdBlurayRule");let fs=ji;function Wc(d){const e=new F;return e.regexDefaults({flags:"i",abbreviations:[X]}),e.stringDefaults({ignoreCase:!0}),e.defaults({name:"video_codec",tags:["source-suffix","streaming_service.suffix"],disabled:p(t=>A(t,"video_codec"),"disabled")}),e.regex("Rv\\d{2}",{value:"RealVideo"}),e.regex("Mpe?g-?2","[hx]-?262",{value:"MPEG-2"}),e.string("DVDivX","DivX",{value:"DivX"}),e.string("XviD",{value:"Xvid"}),e.regex("VC-?1",{value:"VC-1"}),e.string("VP7",{value:"VP7"}),e.string("VP8","VP80",{value:"VP8"}),e.string("VP9",{value:"VP9"}),e.regex("[hx]-?263",{value:"H.263"}),e.regex("[hx]-?264","(?:MPEG-?4)?AVC(?:HD)?",{value:"H.264"}),e.regex("[hx]-?265","HEVC",{value:"H.265"}),e.regex("AV-?1",{value:"AV1"}),e.regex("AV-?2",{value:"AV2"}),e.regex("(?<video_codec>hevc)(?<color_depth>10)",{value:{video_codec:"H.265",color_depth:"10-bit"},tags:["video-codec-suffix"],children:!0}),e.defaults({clear:!0,name:"video_profile",validator:T,disabled:p(t=>A(t,"video_profile"),"disabled")}),e.string("BP",{value:"Baseline",tags:"video_profile.rule"}),e.string("XP","EP",{value:"Extended",tags:"video_profile.rule"}),e.string("MP",{value:"Main",tags:"video_profile.rule"}),e.string("HP","HiP",{value:"High",tags:"video_profile.rule"}),e.string("SC","SVC",{value:"Scalable Video Coding",tags:"video_profile.rule"}),e.regex("AVC(?:HD)?",{value:"Advanced Video Codec High Definition",tags:"video_profile.rule"}),e.string("HEVC",{value:"High Efficiency Video Coding",tags:"video_profile.rule"}),e.regex("Hi422P",{value:"High 4:2:2"}),e.regex("Hi444PP",{value:"High 4:4:4 Predictive"}),e.regex("Hi10P?",{value:"High 10"}),e.string("DXVA",{value:"DXVA",name:"video_api",disabled:p(t=>A(t,"video_api"),"disabled")}),e.defaults({clear:!0,name:"color_depth",validator:T,disabled:p(t=>A(t,"color_depth"),"disabled")}),e.regex("12.?bits?",{value:"12-bit"}),e.regex("10.?bits?","YUV420P10","Hi10P?",{value:"10-bit"}),e.regex("8.?bits?",{value:"8-bit"}),e.rules(gs,hs),e}p(Wc,"videoCodec");const We=class We extends y{enabled(e){return!A(e,"video_codec")}when(e,t){const n=[],s=e.named("video_codec"),r=p(i=>Array.isArray(i)?i.length>0:!!i,"hasAny"),a=e.inputString??"";for(const i of s){const o=a[i.start]==="["||a[i.start-1]==="[",c=a[i.end-1]==="]"||a[i.end]==="]";if(!o&&!se(i)&&!r(e.atIndex(i.start-1,l=>l.tags?.includes("video-codec-prefix")))){n.push(i);continue}if(!c&&!ae(i)&&!r(e.atIndex(i.end+1,l=>l.tags?.includes("video-codec-suffix")))){n.push(i);continue}}return n}};p(We,"ValidateVideoCodec"),We.priority=64,We.consequence=b;let gs=We;const _n=class _n extends y{enabled(e){return!A(e,"video_profile")}when(e,t){const n=e.named("video_profile",r=>r.tags?.includes("video_profile.rule"))??[],s=[];for(const r of n){let a=e.atSpan(r.span,i=>i.name==="video_codec",0);a||(a=e.previous(r,i=>i.name==="video_codec",0)),a||(a=e.next(r,i=>i.name==="video_codec",0)),a||s.push(r)}return s}};p(_n,"VideoProfileRule"),_n.consequence=b;let hs=_n;const Pt="re:",Eo="import:",No="eval:",Po=["regex","string"],Er=new Map,Et=new Map;function qc(d,e){Et.set(d,e)}p(qc,"registerFunction");Et.set("seps_after",ae);Et.set("seps_before",se);Et.set("seps_surround",T);const jc={"lambda match, other: other if other.name == 'audio_codec' else '__default__'":p((d,e)=>e.name==="audio_codec"?e:"__default__","lambda match, other: other if other.name == 'audio_codec' else '__default__'"),"lambda match, other: match if other.name == 'audio_channels' and 'weak-audio_channels' not in other.tags else other":p((d,e)=>e.name==="audio_channels"&&!(e.tags??[]).includes("weak-audio_channels")?d:e,"lambda match, other: match if other.name == 'audio_channels' and 'weak-audio_channels' not in other.tags else other"),"lambda match, conflicting: match if conflicting.name in ('video_codec', 'episode') and 'weak-episode' not in conflicting.tags else '__default__'":p((d,e)=>["video_codec","episode"].includes(e.name)&&!(e.tags??[]).includes("weak-episode")?d:e.name==="episode"&&(e.tags??[]).includes("weak-episode")?e:"__default__","lambda match, conflicting: match if conflicting.name in ('video_codec', 'episode') and 'weak-episode' not in conflicting.tags else '__default__'"),"lambda match, other: other if other.name == 'episode_details' and other.value == 'Special' else '__default__'":p((d,e)=>e.name==="episode_details"&&e.value==="Special"?e:"__default__","lambda match, other: other if other.name == 'episode_details' and other.value == 'Special' else '__default__'")},Kc={"lambda match: 0 < match.value < 100":p(d=>typeof d.value=="number"&&d.value>0&&d.value<100,"lambda match: 0 < match.value < 100")};function Gc(d,e){if(d.startsWith(Eo)){const t=d.slice(Eo.length);if(Er.has(t))return Er.get(t);const n=Et.get(t);return n!==void 0?(Er.set(t,n),n):void 0}if(d.startsWith(No)){const t=d.slice(No.length).trim();return t==="int"?n=>parseInt(String(n),10):t==="float"?n=>parseFloat(String(n)):t==="bool"?n=>!!n:t}if(d.startsWith("lambda ")||d.startsWith("lambda:")){const t=jc[d];if(t)return t;const n=Kc[d];return n||void 0}return d}p(Gc,"processExecutable");const Xc={conflict_solver:"conflictSolver",private_parent:"privateParent",private_children:"privateChildren",private_names:"privateNames",ignore_names:"ignoreNames",format_all:"formatAll",validate_all:"validateAll",pre_match_processor:"preMatchProcessor",post_match_processor:"postMatchProcessor",post_processor:"postProcessor",log_level:"logLevel",ignore_case:"ignoreCase"};function Zc(d){for(const[e,t]of Object.entries(Xc))e in d&&!(t in d)&&(d[t]=d[e],delete d[e]);return d}p(Zc,"normalizeCamelCase");function Jo(d,e){if(d==="validator"||d==="conflict_solver"||d==="formatter"){if(e&&typeof e=="object"&&!Array.isArray(e)){const t={};for(const[n,s]of Object.entries(e))t[n]=Jo(d,s);return t}if(e!=null&&typeof e=="string")return Gc(e)}return e}p(Jo,"processOption");function Yc(d,e,t){const s={...e[Symbol.for("default")]||e.__default__||{}};if(t.startsWith("_")||(s.value=t),typeof d=="string"?d.startsWith(Pt)?s.regex=[d.slice(Pt.length)]:s.string=[d]:d&&typeof d=="object"&&Object.assign(s,d),"pattern"in s){const r=s.pattern;delete s.pattern,r.startsWith(Pt)?s.regex=[r.slice(Pt.length)]:s.string=[r]}return s}p(Yc,"buildEntryDecl");function Jc(d,e,t,n={}){const r={...n[Symbol.for("default")]||n.__default__||{}},a=n[e];a&&Object.assign(r,a);const i={};for(const[o,c]of Object.entries(r))i[o]=Jo(o,c);for(const o of Object.keys(i))i[o]===void 0&&delete i[o];Zc(i),e==="regex"?d.regex(...t,i):d.string(...t,i)}p(Jc,"loadPatterns");function te(d,e,t={}){if(e)for(const[n,s]of Object.entries(e)){const r=Array.isArray(s)?s:[s];for(const a of r){const i=Yc(a,t,n);for(const o of Po){let c=i[o];if(!c)continue;Array.isArray(c)||(c=[c]);const l={...i};for(const f of Po)delete l[f];const u={...t};u[Symbol.for("default")]=l,u.__default__=l,Jc(d,o,c,u)}}}}p(te,"loadConfigPatterns");function Qc(d){const e=new F;e.regexDefaults({flags:"i",abbreviations:[X]}),e.stringDefaults({ignoreCase:!0}),e.defaults({name:"audio_codec",tags:["source-suffix","streaming_service.suffix"],disabled:p(n=>A(n,"audio_codec"),"disabled")}),te(e,d.audio_codec),e.defaults({clear:!0,name:"audio_profile",validator:T,disabled:p(n=>A(n,"audio_profile"),"disabled")}),te(e,d.audio_profile),e.defaults({clear:!0,name:"audio_channels",disabled:p(n=>A(n,"audio_channels"),"disabled")}),te(e,d.audio_channels);function t(n){const s=[],r=[{regex:/DTS-?ES/gi,codec:"DTS",profile:"Extended Surround"},{regex:/DTS-?MA/gi,codec:"DTS-HD",profile:"Master Audio"},{regex:/HE-?AAC/gi,codec:"AAC",profile:"High Efficiency"},{regex:/DD-?EX/gi,codec:"Dolby Digital",profile:"EX"}];for(const a of r){let i;for(;(i=a.regex.exec(n))!==null;)s.push([i.index,i.index+i[0].length,{value:a.codec,tags:["compound-audio"]}])}return s}return p(t,"findCompoundAudio"),e.functional(t,{name:"audio_codec",disabled:p(n=>A(n,"audio_codec"),"disabled")}),e.rules(ms,vs,xs,ys,_s,bs,ws,As,Ss),e}p(Qc,"audioCodec");const el={DTS:"Extended Surround","DTS-HD":"Master Audio",AAC:"High Efficiency","Dolby Digital":"EX"},qe=class qe extends y{constructor(){super(...arguments),this.priority=128}enabled(e){return!A(e,"audio_profile")}when(e){const t=e.named("audio_codec");for(const n of t){if(n.tags?.includes("compound-audio")){const s=el[String(n.value)];if(s)return new N(n.start,n.end,{name:"audio_profile",value:s,inputString:n.inputString})}if(String(n.value)==="DTS-HD"){const s=(n.raw??n.inputString?.slice(n.start,n.end)??"").toUpperCase();if(/MA/.test(s))return new N(n.start,n.end,{name:"audio_profile",value:"Master Audio",inputString:n.inputString});const a=(n.inputString??"").slice(n.end,n.end+4).toUpperCase();if(/^[.\-_\s]?MA(?!\w*[b-ln-z])/i.test(a)){const i=n.end+(a.match(/^[.\-_\s]/)?1:0);return new N(i,i+2,{name:"audio_profile",value:"Master Audio",inputString:n.inputString})}}}}};p(qe,"CompoundAudioProfileRule"),qe.priority=128,qe.consequence=$;let ms=qe;const bn=class bn extends y{enabled(e){return!A(e,"audio_profile")}when(e,t){const n=[],s=e.named("audio_profile"),r=p(a=>a&&(!Array.isArray(a)||a.length>0),"hasResult");for(const a of s){if(!a.tags.includes(this.codecName))continue;let i=e.atSpan(a.span,o=>o.name==="audio_codec"&&o.value===this.codecName);if(!r(i)){const o=e.previous(a,c=>!c.private,0);o&&o.name==="audio_codec"&&o.value===this.codecName&&(i=o)}if(!r(i)){const o=e.next(a,c=>!c.private,0);o&&o.name==="audio_codec"&&o.value===this.codecName&&(i=o)}r(i)||n.push(a)}return n.length>0?n:!1}};p(bn,"AudioProfileRule"),bn.consequence=b;let He=bn;const Ki=class Ki extends He{constructor(){super(...arguments),this.codecName="DTS-HD"}};p(Ki,"DtsHDRule");let vs=Ki;const Gi=class Gi extends He{constructor(){super(...arguments),this.codecName="DTS"}};p(Gi,"DtsRule");let xs=Gi;const Xi=class Xi extends He{constructor(){super(...arguments),this.codecName="AAC"}};p(Xi,"AacRule");let ys=Xi;const Zi=class Zi extends He{constructor(){super(...arguments),this.codecName="Dolby Digital"}};p(Zi,"DolbyDigitalRule");let _s=Zi;const wn=class wn extends y{enabled(e){return!A(e,"audio_profile")}when(e,t){const n=[],s=e.named("other"),r=e.named("audio_profile",a=>a.value==="High Quality")??[];for(const a of r)for(const i of s)i.span[0]===a.span[0]&&i.span[1]===a.span[1]&&n.push(i);return n}};p(wn,"HqConflictRule"),wn.consequence=b;let bs=wn;const je=class je extends y{enabled(e){return!A(e,"audio_codec")&&!A(e,"audio_profile")}when(e,t){const n=[],s=["audio_codec","audio_profile","audio_channels"],r=s.flatMap(a=>[...e.named(a)]);for(const a of r){if(!se(a)){const i=e.range(a.start-1,a.start,o=>s.includes(o.name??""));if(!(Array.isArray(i)?i.length:i)){n.push(a);continue}}if(!ae(a)){const i=e.range(a.end,a.end+1,o=>s.includes(o.name??""));if(!(Array.isArray(i)?i.length:i)){n.push(a);continue}}}return n}};p(je,"AudioValidatorRule"),je.priority=64,je.consequence=b;let ws=je;const Ke=class Ke extends y{enabled(e){return!A(e,"audio_channels")}when(e,t){const n=e.inputString??"",s=[];for(const r of e.named("audio_channels")){const a=r.initiator??r;if(!/^\d[\W_]\d$/.test(n.slice(a.start,a.end)))continue;const i=e.range(a.start-1,a.start,c=>!c.private);if(Array.isArray(i)?i.length:i||!1)continue;const o=e.range(a.end,a.end+2,c=>c.name==="year");(Array.isArray(o)?o.length:o)&&(r.children?.length>0&&s.push(...r.children.toArray()),s.push(r),a!==r&&s.push(a))}return s}};p(Ke,"RemoveDecimalTitleChannels"),Ke.priority=128,Ke.consequence=b;let Ss=Ke;const Ge=class Ge extends y{enabled(e){return!A(e,"audio_channels")}when(e,t){const n=[],s=e.named("audio_channels",r=>r.tags.includes("weak-audio_channels"))??[];for(const r of s)e.previous(r,i=>i.name==="audio_codec")||n.push(r);return n}};p(Ge,"AudioChannelsValidatorRule"),Ge.priority=128,Ge.consequence=b;let As=Ge;const tl=/^(?<magnitude>\d+(?:[.]\d+)?)(?<units>[^\d]+)?/,Sn=class Sn{constructor(e,t){this.magnitude=e,this.units=t}static parseUnits(e){throw new Error("parseUnits must be implemented by subclass")}static fromstring(e){const t=tl.exec(e);if(!t?.groups)throw new Error(`Cannot parse quantity: ${e}`);const n=t.groups.magnitude,s=n.includes(".")?parseFloat(n):parseInt(n,10),r=t.groups.units??"",a=this.parseUnits(r);return new this(s,a)}toString(){return`${this.magnitude}${this.units}`}equals(e){return typeof e=="string"?this.toString()===e:e instanceof Sn?this.magnitude===e.magnitude&&this.units===e.units:!1}};p(Sn,"Quantity");let de=Sn;const An=class An extends de{static parseUnits(e){let t=e;for(const n of M)t=t.split(n).join("");return t.toUpperCase()}static fromstring(e){return de.fromstring.call(An,e)}};p(An,"Size");let ks=An;const kn=class kn extends de{static parseUnits(e){let t=e;for(const n of M)t=t.split(n).join("");t=t.charAt(0).toUpperCase()+t.slice(1);for(const n of["bits","bit"])t=t.replace(n,"bps");return t}static fromstring(e){return de.fromstring.call(kn,e)}};p(kn,"BitRate");let Ds=kn;const Dn=class Dn extends de{static parseUnits(e){return"fps"}static fromstring(e){return de.fromstring.call(Dn,e)}};p(Dn,"FrameRate");let Wt=Dn;function nl(d){const e=new Set(d.interlaced),t=new Set(d.progressive),n=t,s=d.frame_rates,r=d.min_ar,a=d.max_ar,i=new F;i.stringDefaults({ignoreCase:!0}),i.regexDefaults({flags:"i"}),i.defaults({name:"screen_size",validator:T,abbreviations:[X],disabled:p(g=>A(g,"screen_size"),"disabled")});const o=I(s,"frame_rate"),c=I([...e],"height"),l=I([...t],"height"),u="(?:x|\\*|×)",f=`(?:(?<width>\\d{3,4})${u})?`;return i.regex(f+c+"(?<scan_type>i)"+o+"?"),i.regex(f+l+"(?<scan_type>p)"+o+"?"),i.regex(f+l+"(?<scan_type>p)?(?:hd)"),i.regex(f+l+"(?<scan_type>p)?x?"),i.string("4k",{value:"2160p",conflictSolver:p((g,h)=>h.name==="screen_size"?"__default__":g,"conflictSolver")}),i.regex(`(?<width>\\d{3,4})(?:${u}|-${u}-)(?<height>\\d{3,4})(?:up)?`,{conflictSolver:p((g,h)=>h.name==="screen_size"?"__default__":h,"conflictSolver")}),i.regex(o+"-?(?:p|fps)",{name:"frame_rate",formatter:p(g=>Wt.fromstring(g).toString(),"formatter"),disabled:p(g=>A(g,"frame_rate"),"disabled")}),i.rules(new Cs(n,r,a),Ms,Es),i}p(nl,"screenSize");const Cn=class Cn extends y{constructor(e,t,n){super(),this.standardHeights=e,this.minAr=t,this.maxAr=n}when(e,t){const n=[];for(const s of e.named("screen_size")){if(!A(t,"frame_rate"))for(const l of s.children.named("frame_rate"))l.formatter=u=>Wt.fromstring(u).toString(),n.push(l);let r=s.children.toDict();if(!("height"in r)){const l=String(s.raw??""),f=/^(\d{3,4})\s*[xX*×]\s*(\d{3,4})\s*([ip])?(?:up)?$/i.exec(l);if(f)r={width:f[1],height:f[2],scan_type:f[3]};else{const h=/^(\d{3,4})([ip])?/i.exec(l);if(h&&h[1])r={height:h[1],scan_type:h[2]};else continue}}const a=(r.scan_type||"p").toLowerCase(),i=String(r.height??"");if(!("width"in r)||r.width===void 0){s.value=`${i}${a}`;continue}const o=String(r.width??""),c=parseFloat(o)/parseFloat(i);if(this.standardHeights.has(i)&&this.minAr<c&&c<this.maxAr?s.value=`${i}${a}`:s.value=`${o}x${i}`,!A(t,"aspect_ratio")&&o){const l=new N(s.start,s.end,{name:"aspect_ratio",value:Math.round(c*1e3)/1e3,inputString:s.inputString});n.push(l)}}return n}};p(Cn,"PostProcessScreenSize"),Cn.consequence=$;let Cs=Cn;const Mn=class Mn extends y{when(e,t){const n=[];for(const s of e.markers.named("path")){const r=e.range(s.start,s.end,i=>i.name==="screen_size").reverse(),a=new Set(r.map(i=>i.value));r.length>1&&a.size>1&&n.push(...r.slice(1))}return n}};p(Mn,"ScreenSizeOnlyOne"),Mn.consequence=b;let Ms=Mn;const En=class En extends y{when(e,t){const n=[];for(const s of e.markers.named("path")){const r=e.range(s.start,s.end,f=>f.name==="screen_size",0);if(!r)continue;const a=e.conflicting(r,f=>["season","episode"].includes(f.name??""))??[];if(a.length===0)continue;let i=!1;const o=e.range(s.start,s.end,f=>f.name==="screen_size")??[],c=p(f=>e.markers.atMatch(f,g=>g.name==="group",0),"groupOf"),l=e.range(r.end,s.end,f=>f.name==="video_profile"||f.name==="video_codec",0);l&&e.holes(r.end,l.start,{predicate:p(f=>!!(f.value&&String(f.value).replace(new RegExp(`[${z}]`,"g"),"")),"predicate")}).length===0&&(l.name==="video_profile"||o.length===1&&c(r)===c(l))&&(n.push(...a),i=!0);const u=e.previous(r,f=>["date","source","other","streaming_service"].includes(f.name??""),0);u&&e.holes(u.end,r.start,{predicate:p(f=>!!(f.value&&String(f.value).replace(new RegExp(`[${z}]`,"g"),"")),"predicate")}).length===0&&(n.push(...a),i=!0),i||n.push(r)}return n}};p(En,"ResolveScreenSizeConflicts"),En.consequence=b;let Es=En;const rl=["aarp","abb","abbott","abbvie","abc","able","abogado","abudhabi","ac","academy","accenture","accountant","accountants","aco","actor","ad","ads","adult","ae","aeg","aero","aetna","af","afl","africa","ag","agakhan","agency","ai","aig","airbus","airforce","airtel","akdn","al","alibaba","alipay","allfinanz","allstate","ally","alsace","alstom","am","amazon","americanexpress","americanfamily","amex","amfam","amica","amsterdam","analytics","android","anquan","anz","ao","aol","apartments","app","apple","aq","aquarelle","ar","arab","aramco","archi","army","arpa","art","arte","as","asda","asia","associates","at","athleta","attorney","au","auction","audi","audible","audio","auspost","author","auto","autos","aw","aws","ax","axa","az","azure","ba","baby","baidu","banamex","band","bank","bar","barcelona","barclaycard","barclays","barefoot","bargains","baseball","basketball","bauhaus","bayern","bb","bbc","bbt","bbva","bcg","bcn","bd","be","beats","beauty","beer","berlin","best","bestbuy","bet","bf","bg","bh","bharti","bi","bible","bid","bike","bing","bingo","bio","biz","bj","black","blackfriday","blockbuster","blog","bloomberg","blue","bm","bms","bmw","bn","bnpparibas","bo","boats","boehringer","bofa","bom","bond","boo","book","booking","bosch","bostik","boston","bot","boutique","box","br","bradesco","bridgestone","broadway","broker","brother","brussels","bs","bt","build","builders","business","buy","buzz","bv","bw","by","bz","bzh","ca","cab","cafe","cal","call","calvinklein","cam","camera","camp","canon","capetown","capital","capitalone","car","caravan","cards","care","career","careers","cars","casa","case","cash","casino","cat","catering","catholic","cba","cbn","cbre","cc","cd","center","ceo","cern","cf","cfa","cfd","cg","ch","chanel","channel","charity","chase","chat","cheap","chintai","christmas","chrome","church","ci","cipriani","circle","cisco","citadel","citi","citic","city","ck","cl","claims","cleaning","click","clinic","clinique","clothing","cloud","club","clubmed","cm","cn","co","coach","codes","coffee","college","cologne","com","commbank","community","company","compare","computer","comsec","condos","construction","consulting","contact","contractors","cooking","cool","coop","corsica","country","coupon","coupons","courses","cpa","cr","credit","creditcard","creditunion","cricket","crown","crs","cruise","cruises","cu","cuisinella","cv","cw","cx","cy","cymru","cyou","cz","dad","dance","data","date","dating","datsun","day","dclk","dds","de","deal","dealer","deals","degree","delivery","dell","deloitte","delta","democrat","dental","dentist","desi","design","dev","dhl","diamonds","diet","digital","direct","directory","discount","discover","dish","diy","dj","dk","dm","dnp","do","docs","doctor","dog","domains","dot","download","drive","dtv","dubai","dupont","durban","dvag","dvr","dz","earth","eat","ec","eco","edeka","edu","education","ee","eg","email","emerck","energy","engineer","engineering","enterprises","epson","equipment","er","ericsson","erni","es","esq","estate","et","eu","eurovision","eus","events","exchange","expert","exposed","express","extraspace","fage","fail","fairwinds","faith","family","fan","fans","farm","farmers","fashion","fast","fedex","feedback","ferrari","ferrero","fi","fidelity","fido","film","final","finance","financial","fire","firestone","firmdale","fish","fishing","fit","fitness","fj","fk","flickr","flights","flir","florist","flowers","fly","fm","fo","foo","food","football","ford","forex","forsale","forum","foundation","fox","fr","free","fresenius","frl","frogans","frontier","ftr","fujitsu","fun","fund","furniture","futbol","fyi","ga","gal","gallery","gallo","gallup","game","games","gap","garden","gay","gb","gbiz","gd","gdn","ge","gea","gent","genting","george","gf","gg","ggee","gh","gi","gift","gifts","gives","giving","gl","glass","gle","global","globo","gm","gmail","gmbh","gmo","gmx","gn","godaddy","gold","goldpoint","golf","goodyear","goog","google","gop","got","gov","gp","gq","gr","grainger","graphics","gratis","green","gripe","grocery","group","gs","gt","gu","gucci","guge","guide","guitars","guru","gw","gy","hair","hamburg","hangout","haus","hbo","hdfc","hdfcbank","health","healthcare","help","helsinki","here","hermes","hiphop","hisamitsu","hitachi","hiv","hk","hkt","hm","hn","hockey","holdings","holiday","homedepot","homegoods","homes","homesense","honda","horse","hospital","host","hosting","hot","hotels","hotmail","house","how","hr","hsbc","ht","hu","hughes","hyatt","hyundai","ibm","icbc","ice","icu","id","ie","ieee","ifm","ikano","il","im","imamat","imdb","immo","immobilien","in","inc","industries","infiniti","info","ing","ink","institute","insurance","insure","int","international","intuit","investments","io","ipiranga","iq","ir","irish","is","ismaili","ist","istanbul","it","itau","itv","jaguar","java","jcb","je","jeep","jetzt","jewelry","jio","jll","jm","jmp","jnj","jo","jobs","joburg","jot","joy","jp","jpmorgan","jprs","juegos","juniper","kaufen","kddi","ke","kerryhotels","kerryproperties","kfh","kg","kh","ki","kia","kids","kim","kindle","kitchen","kiwi","km","kn","koeln","komatsu","kosher","kp","kpmg","kpn","kr","krd","kred","kuokgroup","kw","ky","kyoto","kz","la","lacaixa","lamborghini","lamer","land","landrover","lanxess","lasalle","lat","latino","latrobe","law","lawyer","lb","lc","lds","lease","leclerc","lefrak","legal","lego","lexus","lgbt","li","lidl","life","lifeinsurance","lifestyle","lighting","like","lilly","limited","limo","lincoln","link","live","living","lk","llc","llp","loan","loans","locker","locus","lol","london","lotte","lotto","love","lpl","lplfinancial","lr","ls","lt","ltd","ltda","lu","lundbeck","luxe","luxury","lv","ly","ma","madrid","maif","maison","makeup","man","management","mango","map","market","marketing","markets","marriott","marshalls","mattel","mba","mc","mckinsey","md","me","med","media","meet","melbourne","meme","memorial","men","menu","merck","merckmsd","mg","mh","miami","microsoft","mil","mini","mint","mit","mitsubishi","mk","ml","mlb","mls","mm","mma","mn","mo","mobi","mobile","moda","moe","moi","mom","monash","money","monster","mormon","mortgage","moscow","moto","motorcycles","mov","movie","mp","mq","mr","ms","msd","mt","mtn","mtr","mu","museum","music","mv","mw","mx","my","mz","na","nab","nagoya","name","navy","nba","nc","ne","nec","net","netbank","netflix","network","neustar","new","news","next","nextdirect","nexus","nf","nfl","ng","ngo","nhk","ni","nico","nike","nikon","ninja","nissan","nissay","nl","no","nokia","norton","now","nowruz","nowtv","np","nr","nra","nrw","ntt","nu","nyc","nz","obi","observer","office","okinawa","olayan","olayangroup","ollo","om","omega","one","ong","onl","online","ooo","open","oracle","orange","org","organic","origins","osaka","otsuka","ott","ovh","pa","page","panasonic","paris","pars","partners","parts","party","pay","pccw","pe","pet","pf","pfizer","pg","ph","pharmacy","phd","philips","phone","photo","photography","photos","physio","pics","pictet","pictures","pid","pin","ping","pink","pioneer","pizza","pk","pl","place","play","playstation","plumbing","plus","pm","pn","pnc","pohl","poker","politie","porn","post","pr","praxi","press","prime","pro","prod","productions","prof","progressive","promo","properties","property","protection","pru","prudential","ps","pt","pub","pw","pwc","py","qa","qpon","quebec","quest","racing","radio","re","read","realestate","realtor","realty","recipes","red","redumbrella","rehab","reise","reisen","reit","reliance","ren","rent","rentals","repair","report","republican","rest","restaurant","review","reviews","rexroth","rich","richardli","ricoh","ril","rio","rip","ro","rocks","rodeo","rogers","room","rs","rsvp","ru","rugby","ruhr","run","rw","rwe","ryukyu","sa","saarland","safe","safety","sakura","sale","salon","samsclub","samsung","sandvik","sandvikcoromant","sanofi","sap","sarl","sas","save","saxo","sb","sbi","sbs","sc","scb","schaeffler","schmidt","scholarships","school","schule","schwarz","science","scot","sd","se","search","seat","secure","security","seek","select","sener","services","seven","sew","sex","sexy","sfr","sg","sh","shangrila","sharp","shell","shia","shiksha","shoes","shop","shopping","shouji","show","si","silk","sina","singles","site","sj","sk","ski","skin","sky","skype","sl","sling","sm","smart","smile","sn","sncf","so","soccer","social","softbank","software","sohu","solar","solutions","song","sony","soy","spa","space","sport","spot","sr","srl","ss","st","stada","staples","star","statebank","statefarm","stc","stcgroup","stockholm","storage","store","stream","studio","study","style","su","sucks","supplies","supply","support","surf","surgery","suzuki","sv","swatch","swiss","sx","sy","sydney","systems","sz","tab","taipei","talk","taobao","target","tatamotors","tatar","tattoo","tax","taxi","tc","tci","td","tdk","team","tech","technology","tel","temasek","tennis","teva","tf","tg","th","thd","theater","theatre","tiaa","tickets","tienda","tips","tires","tirol","tj","tjmaxx","tjx","tk","tkmaxx","tl","tm","tmall","tn","to","today","tokyo","tools","top","toray","toshiba","total","tours","town","toyota","toys","tr","trade","trading","training","travel","travelers","travelersinsurance","trust","trv","tt","tube","tui","tunes","tushu","tv","tvs","tw","tz","ua","ubank","ubs","ug","uk","unicom","university","uno","uol","ups","us","uy","uz","va","vacations","vana","vanguard","vc","ve","vegas","ventures","verisign","versicherung","vet","vg","vi","viajes","video","vig","viking","villas","vin","vip","virgin","visa","vision","viva","vivo","vlaanderen","vn","vodka","volvo","vote","voting","voto","voyage","vu","wales","walmart","walter","wang","wanggou","watch","watches","weather","weatherchannel","webcam","weber","website","wed","wedding","weibo","weir","wf","whoswho","wien","wiki","williamhill","win","windows","wine","winners","wme","woodside","work","works","world","wow","ws","wtc","wtf","xbox","xerox","xihuan","xin","xxx","xyz","yachts","yahoo","yamaxun","yandex","ye","yodobashi","yoga","yokohama","you","youtube","yt","yun","za","zappos","zara","zero","zip","zm","zone","zuerich","zw"];function sl(d){const e=new F({disabled:p(c=>A(c,"website"),"disabled")});e.regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}),e.defaults({name:"website"});const t=d.tlds||rl,n=d.safe_tlds||["com","org","net"],s=d.safe_subdomains||["www"],r=d.safe_prefixes||[],a=d.prefixes||[];e.regex(`(?:[^a-z0-9]|^)((?:${I(s)}\\.)+(?:[a-z-0-9-]+\\.)+(?:${I(t)}))(?:[^a-z0-9]|$)`,{children:!0}),e.regex(`(?:[^a-z0-9]|^)((?:${I(s)}\\.)*[a-z0-9-]+\\.(?:${I(n)}))(?:[^a-z0-9]|$)`,{children:!0}),e.regex(`(?:[^a-z0-9]|^)((?:${I(s)}\\.)*[a-z0-9-]+\\.(?:${I(r)}\\.)+(?:${I(t)}))(?:[^a-z0-9]|$)`,{children:!0}),e.string(...a,{validator:T,private:!0,tags:["website.prefix"]});const o=class o extends y{constructor(l,u){super(),this.consequence=b,this.safeSubdomains=l,this.safePrefix=u}validFollowers(l){return["season","episode","year"].includes(l.name??"")}when(l){const u=[];for(const f of l.named("website")){let g=!1;for(const h of[...this.safeSubdomains,...this.safePrefix])if(String(f.value??"").toLowerCase().startsWith(h)){g=!0;break}if(!g){const x=l.markers.atMatch(f,w=>w.name==="path",0)?.end??l.inputString?.length??f.end+50,m=l.range(f.end,x,w=>!w.private&&this.validFollowers(w)),v=Array.isArray(m)?m:m?[m]:[];(v.length>0?v[0]:void 0)&&(l.markers.atMatch(f,k=>k.name==="group",0)||u.push(f))}}return u}};p(o,"PreferTitleOverWebsiteWithConfig");let i=o;return e.rules(new i(s,r),Ns),e}p(sl,"website");const Xe=class Xe extends y{when(e){const t=[];for(const n of e.tagged("website.prefix")){const s=e.range(n.end,n.end+100,i=>!i.private&&i.name==="website"),r=Array.isArray(s)?s:s?[s]:[],a=r.length>0?r[0]:void 0;(!a||e.holes(n.end,a.start,B,M,i=>i.value))&&t.push(n)}return t}};p(Xe,"ValidateWebsitePrefix"),Xe.priority=64,Xe.consequence=b;let Ns=Xe;const G="[-/ ._]",Oo="[-/ ._x]",al=[new RegExp(`${G}((\\d{8}))${G}`,"i"),new RegExp(`${G}((\\d{6}))${G}`,"i"),new RegExp(`(?:^|[^\\d])((\\d{4})${Oo}(\\d{1,2})${G}(\\d{1,2}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{1,2})${G}(\\d{1,2})${Oo}(\\d{4}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{2})${G}(\\d{1,2})${G}(\\d{1,2}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{1,2})${G}(\\d{1,2})${G}(\\d{2}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{1,2}(?:st|nd|rd|th)?${G}(?:[a-z]{3,10})${G}\\d{4}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^a-z\\d])(([a-z]{3,10})${G}\\d{1,2}(?:st|nd|rd|th)?${G}\\d{4})(?:$|[^\\d])`,"i")],Io={jan:1,january:1,feb:2,february:2,mar:3,march:3,apr:4,april:4,may:5,jun:6,june:6,jul:7,july:7,aug:8,august:8,sep:9,sept:9,september:9,oct:10,october:10,nov:11,november:11,dec:12,december:12};function J(d){return d>=1900&&d<2035}p(J,"validYear");function il(d){return d>=1&&d<53}p(il,"validWeek");function Ot(d){return!isNaN(parseInt(d,10))&&String(parseInt(d,10))===d.replace(/^0+/,"")||d==="0"}p(Ot,"isInt");function ol(d){const e=d[0],t=d[d.length-1];if(Ot(e)&&J(parseInt(e.slice(0,4),10)))return!1;if(Ot(t)&&J(parseInt(t.slice(-4),10)))return!0;if(Ot(e)&&parseInt(e.slice(0,2),10)>31)return!1;if(Ot(t)&&parseInt(t.slice(-2),10)>31)return!0}p(ol,"guessDayFirst");function cl(d,e,t,n){const r=d.replace(/[-/ ._x]/g,"-").split("-").filter(Boolean),a=t!==void 0?[t]:[!1,!0],i=n!==void 0?[n]:[!0,!1];for(const o of a)for(const c of i){let l,u,f;const g=r.findIndex(h=>Io[h.toLowerCase()]!==void 0);if(r.length===3&&g>=0){u=Io[r[g].toLowerCase()];const h=r.filter((m,v)=>v!==g).map(m=>parseInt(m.replace(/(st|nd|rd|th)$/i,""),10)),x=h.findIndex(m=>m>=1e3);if(x>=0?(l=h[x],f=h[1-x]):(l=h[1],f=h[0]),u>=1&&u<=12&&f>=1&&f<=31&&J(l)){const m=Date.UTC(l,u-1,f),v=new Date(m);if(v.getUTCFullYear()===l&&v.getUTCMonth()===u-1&&v.getUTCDate()===f)return v}continue}if(r.length===1){const h=r[0];if(h.length===8)l=parseInt(h.slice(0,4),10),u=parseInt(h.slice(4,6),10),f=parseInt(h.slice(6,8),10);else if(h.length===6){const x=parseInt(h.slice(0,2),10);l=x>50?1900+x:2e3+x,u=parseInt(h.slice(2,4),10),f=parseInt(h.slice(4,6),10)}else continue}else if(r.length===3){const h=r.map(Number);if(o)[l,u,f]=c?[h[0],h[2],h[1]]:[h[0],h[1],h[2]],!J(l)&&l<100&&(l=l>50?1900+l:2e3+l);else{const x=h.findIndex((m,v)=>r[v].length===4&&J(m));x===0?[l,u,f]=c?[h[0],h[2],h[1]]:[h[0],h[1],h[2]]:x===2?[l,u,f]=c?[h[2],h[1],h[0]]:[h[2],h[0],h[1]]:(c?[f,u,l]=o?[h[2],h[1],h[0]]:[h[0],h[1],h[2]]:[u,f,l]=o?[h[2],h[0],h[1]]:[h[0],h[1],h[2]],l=l>100?l:l>50?1900+l:2e3+l)}}else continue;if(!(u<1||u>12)&&!(f<1||f>31)&&J(l))try{const h=Date.UTC(l,u-1,f),x=new Date(h);if(x.getUTCFullYear()===l&&x.getUTCMonth()===u-1&&x.getUTCDate()===f)return x}catch{}}}p(cl,"tryParseDate");function ll(d,e,t){for(const n of al){const s=new RegExp(n.source,n.flags.includes("g")?n.flags:n.flags+"g");let r;for(s.lastIndex=0;(r=s.exec(d))!==null;){if(!r[1])continue;const a=r.index+r[0].indexOf(r[1]),i=a+r[1].length,o=r.slice(2).filter(Boolean),c=r[1];if(/^\d\.\d\.\d{4}$/.test(c))continue;let l=t;e&&l===void 0&&(l=!1);const u=l!==void 0;!u&&o.length>0&&(l=ol(o));const f=l!==void 0?u?[l]:[l,!l]:[void 0];let g;for(const h of f)if(g=cl(c,o,e,h),g&&J(g.getUTCFullYear()))break;if(g&&J(g.getUTCFullYear()))return[a,i,g]}}}p(ll,"searchDate");function ul(d){const e="[ ._]",t=d.filter(r=>/^[a-z]+$/i.test(r)),n=d.filter(r=>!/^[a-z]+$/i.test(r)),s=[];return n.length&&s.push(`${e}*${I(n,void 0,!0)}${e}*`),t.length&&s.push(`${e}+${I(t,void 0,!0)}${e}+`),`(?:${s.join("|")})`}p(ul,"yearRangeSeparatorPattern");function dl(d){const t=(d.children?[...d.children]:[]).filter(n=>n.name==="year").map(n=>Number(n.value));return t.length===2&&t[0]<t[1]}p(dl,"isAscendingYearRange");function pl(d){const e=[],t=new Map;for(const n of d){const s=n.tags.includes("year-range")?Qo(n):void 0;if(!s){e.push([n]);continue}const r=t.get(s);if(r)r.push(n);else{const a=[n];t.set(s,a),e.push(a)}}return e}p(pl,"yearUnits");function Qo(d){let e=d.parent;for(;e?.parent;)e=e.parent;return e}p(Qo,"rootParent");const Nn=class Nn extends y{constructor(){super(...arguments),this.consequence=b}enabled(e){return!A(e,"year")}when(e,t){const n=[],s=e.named("year");if((Array.isArray(s)?s:s?[s]:[]).length<=1)return n;const a=e.markers.named("path"),i=Array.isArray(a)?a:a?[a]:[];for(const o of i){const c=e.range(o.start,o.end,x=>x.name==="year"),l=Array.isArray(c)?c:c?[c]:[];if(l.length<=1)continue;const u=pl(l);if(u.length<=1)continue;const f=[],g=[];for(const x of u)(x.some(v=>e.markers.atMatch(v,C=>C.name==="group",0))?f:g).push(x);let h=[];if(f.length>0&&g.length>0){const x=f[0][0].start;h=[...g.filter(m=>m[0].start<x),...f.slice(1)]}else f.length===0&&g[0].length>1?h=g.slice(1):f.length===0&&(h=[g[0],...g.slice(2)]);for(const x of h)n.push(...x)}return n}};p(Nn,"KeepMarkedYearInFilepart"),Nn.priority=64;let Ps=Nn;const Pn=class Pn extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=[];if(!e.named("episode").some(r=>r.tags?.includes("SxxExx")))return n;for(const r of e.named("year")){const a=e.markers.atMatch(r,l=>l.name==="group",0);if(!a)continue;const i=r.tags.includes("year-range")?Qo(r):void 0,o=a.end-a.start,c=i?i.end-i.start:r.end-r.start;o-c>4&&n.push(r)}return n}};p(Pn,"RemoveGroupedYearWithSxxExx"),Pn.priority=64;let Os=Pn;const On=class On extends y{constructor(){super(...arguments),this.consequence=b}enabled(e){return!A(e,"date")}when(e,t){const n=e.inputString??"",s=[];for(const r of e.named("date")){if(!/^\d+(?:\.\d+)+$/.test(n.slice(r.start,r.end)))continue;const a=n[r.start-1],i=n[r.start-2];if(a==="."&&i&&/\d/.test(i)){const o=e.range(r.start-2,r.start-1,c=>!c.private);(Array.isArray(o)?o.length:o)||s.push(r)}}return s}};p(On,"RemoveDecimalVersionDate"),On.priority=128;let Is=On;const In=class In extends y{constructor(){super(...arguments),this.consequence=b}enabled(e){return!A(e,"date")}when(e,t){const n=e.inputString??"",s=[];for(const r of e.named("date")){const a=/^\d{4}([-/ ._])\d{1,2}\1\d{1,2}$/.exec(n.slice(r.start,r.end));if(!a)continue;const i=a[1].replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`^((?:${i}\\d{2}){2,3})(?!\\d)`).exec(n.slice(r.end));if(!o)continue;const c=o[1].split(a[1]).filter(Boolean).map(g=>parseInt(g,10)),l=[23,59,59];if(c.some((g,h)=>g>l[h]))continue;const u=r.end+o[1].length,f=e.range(r.end,u,g=>!g.private)??[];s.push([r,u,Array.isArray(f)?f:[f]])}return s.length?s:!1}then(e,t,n){for(const[s,r,a]of t){for(const i of a){const o=i.initiator??i;for(const c of o.children?.toArray?.()??[])e.remove(c);e.remove(o),e.remove(i)}e.remove(s),s.end=r,e.append(s)}}};p(In,"AbsorbBroadcastClockSuffix"),In.priority=128;let Ls=In;function fl(d){const e=new F().defaults({validator:T});e.regex("\\d{4}",{name:"year",formatter:p(r=>parseInt(r,10),"formatter"),disabled:p(r=>A(r,"year"),"disabled"),conflictSolver:p((r,a)=>(a.name==="episode"||a.name==="season")&&a.raw&&r.raw&&a.raw.length<r.raw.length?a:"__default__","conflictSolver"),validator:p(r=>T(r)&&J(r.value),"validator")});const t=d.year_range_separators??["-","~","to","–"];e.chain({tags:["year-range"],flags:"i",children:!0,privateParent:!0,validateAll:!0,validator:{__parent__:ge(T,dl),year:p(r=>J(Number(r.value)),"year")},formatter:{year:p(r=>parseInt(r,10),"year")},conflictSolver:p((r,a)=>(a.name==="episode"||a.name==="season")&&a.raw!==void 0&&r.raw!==void 0&&a.raw.length<=r.raw.length?a:"__default__","conflictSolver"),disabled:p(r=>A(r,"year"),"disabled")}).defaults({tags:["year-range"],validator:null,privateParent:!0}).regex("(?<year>\\d{4})").regex(ul(t)+"(?<year>\\d{4})");const n=d.week_words;if(n&&n.length>0){const r=I(n)+"-?(\\d{1,2})";e.regex(r,{name:"week",formatter:p(a=>parseInt(a.replace(/\D/g,""),10),"formatter"),children:!0,flags:"i",abbreviations:[X],conflictSolver:p((a,i)=>(i.name==="episode"||i.name==="season")&&i.raw&&a.raw&&i.raw.length<a.raw.length?i:"__default__","conflictSolver"),validator:p(a=>T(a)&&il(a.value),"validator")})}const s=p((r,a)=>{const i=ll(r,a?.date_year_first,a?.date_day_first);return i?[[i[0],i[1],{value:i[2]}]]:[]},"dateFunctional");return e.functional(s,{name:"date",properties:{date:[null]},disabled:p(r=>A(r,"date"),"disabled"),conflictSolver:p((r,a)=>a.name==="episode"||a.name==="season"||a.name==="crc32"?a:"__default__","conflictSolver")}),e.rules(Is,Ls,Ps,Os,new $s(d.weekday_words??[])),e}p(fl,"date");const Yi=class Yi extends y{constructor(e){super(),this.consequence=b;const t="["+M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"]";this.weekdayRe=new RegExp("(?:^|"+t+")("+I(e.length?e:["\\bnever\\b"])+")"+t+"*$","i")}enabled(e){return!A(e,"date")}when(e,t){const n=e.inputString??"",s=[];for(const r of e.named("date")??[]){const a=e.markers.atMatch(r,f=>f.name==="path",0),i=a?a.start:0,o=n.slice(i,r.start),c=this.weekdayRe.exec(o);if(!c)continue;const l=i+c.index+c[0].indexOf(c[1]),u=e.range(l,r.start,f=>!f.private);(Array.isArray(u)?u.length:u?1:0)>0||s.push([r,l])}return s.length?s:!1}then(e,t,n){for(const[s,r]of t)e.remove(s),s.start=r,e.append(s)}};p(Yi,"AbsorbWeekdayPrefix");let $s=Yi;function gl(d){return!d.private&&d.name!=="proper_count"&&d.name!=="title"&&!(d.name==="container"&&d.tags?.includes("extension"))&&!(d.name==="other"&&d.value==="Rip")}p(gl,"markerComparatorPredicate");function Lo(d,e,t){const n=d.range(e.start,e.end,t),s=Array.isArray(n)?n:n?[n]:[];return new Set(s.map(a=>a.name)).size}p(Lo,"markerWeight");function Nt(d,e,t=gl){const n=[...d],s=new Map(n.map((r,a)=>[r,a]));return n.sort((r,a)=>{const i=Lo(e,a,t)-Lo(e,r,t);return i!==0?i:(s.get(a)??0)-(s.get(r)??0)})}p(Nt,"markerSorted");function ec(d){return p(function(t,n){let s=n?.[d];if(!s||Array.isArray(s)&&s.length===0)return[];typeof s=="string"&&(s=[s]);const r="[\\s._-]",a=[];for(const i of s){let o;if(i.startsWith("re:")){const u=i.slice(3).replace(/ /g,"-").replace(/-/g,"[\\W_]?");try{o=new RegExp(u,"gi")}catch{continue}}else{const u=i.split(/[\s._-]+/).map(g=>g.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"));if(u.length===0)continue;const f="(?<![a-zA-Z0-9])"+u.join(`${r}?`)+"(?![a-zA-Z0-9])";try{o=new RegExp(f,"gi")}catch{const g=i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");try{o=new RegExp(g,"gi")}catch{continue}}}const c=p(u=>[...u].map(f=>M.includes(f)?" ":f).join(""),"normalise");let l;for(;(l=o.exec(t))!==null;){const u=i.startsWith("re:")?{}:{value:c(l[0])};if(a.push([l.index,l.index+l[0].length,u]),l[0].length===0)break}}return a},"findExpected")}p(ec,"buildExpectedFunction");const Hs=new Set(["the","a","an","and","or","of","to","in","on","at","for","from","by","with","into","onto","no","le","la","les","de","du","des","el"]);function $o(d){return d==null?!1:Array.isArray(d)?d.length>0:!0}p($o,"hasmatch$1");const Ze=class Ze extends y{constructor(e,t,n){super(),this.consequence=[$,b],this.matchName=e,this.propertyName=t[0]??"title",this.alternativePropertyName=n}holeFilter(e){return!0}filepartFilter(e){return!0}holesProcess(e,t,n){const s=t.markers.named("group"),i=(Array.isArray(s)?s:s?[s]:[]).filter(c=>c.start>=n.start&&c.end<=n.end).filter(c=>!(c.start===n.start&&c.end===n.end)),o=[];for(const c of e){const l=c.crop(i);l&&(Array.isArray(l)?o.push(...l):o.push(l))}return o}isIgnored(e){if(!(e.name==="language"||e.name==="country"||e.name==="episode_details"))return!1;const t=e.raw??"";return!(e.end-e.start>3&&t!==""&&t===t.toUpperCase()&&t!==t.toLowerCase())}shouldKeep(e,t,n){return n?t[0].end<e.end||t.length>1:t[t.length-1].start>e.start&&t.length>1}languageDuplicatedAfterHole(e,t,n){if(e.name!=="language"&&e.name!=="country")return!1;const s=n.markers.atMatch(e,i=>i.name==="path");if(!s)return!1;const r=String(e.value??"").toLowerCase(),a=n.range(t,s.end,i=>i.name===e.name&&String(i.value??"").toLowerCase()===r);return Array.isArray(a)?a.length>0:!!a}shouldRemove(e){return!1}splitTitleAlternative(e,t){const n=t.slice(e.start,e.end),s=[];for(let c=0;c<n.length;c++){const l=n[c];if(!Rr.includes(l))continue;const u=c===0||M.includes(n[c-1]),f=c===n.length-1||M.includes(n[c+1]);(u&&f||l==="/")&&s.push(c)}if(s.length===0)return null;const r=p((c,l)=>{let u=c,f=l;for(;u<f&&M.includes(t[u]);)u++;for(;f>u&&M.includes(t[f-1]);)f--;if(u>=f)return null;const g=t.slice(u,f),h=e.formatter?e.formatter(g):g;return new N(u,f,{inputString:t,formatter:e.formatter,value:h})},"createMatch"),a=[];let i=e.start;for(const c of s){const l=e.start+c,u=r(i,l);u&&a.push(u),i=l+1}const o=r(i,e.end);return o&&a.push(o),a.length<2||/^\d+$/.test(String(a[0].value??"").trim())?null:{title:a[0],alternatives:a.slice(1)}}checkTitlesInFilepart(e,t,n){const s=[],r=[],a=t.range(e.start,e.end,h=>h.name==="year",0),i=!!a,o=!!t.range(e.start,e.end,h=>h.name==="date",0),c=!!t.range(e.start,e.end,h=>h.tags?.includes("SxxExx")&&!h.private,0),l=t.holes(e.start,e.end,{formatter:At(B,Rt),ignore:p(h=>{if(this.isIgnored(h)||h.private&&h.tags?.includes("weak-episode"))return!0;if(h.tags?.includes("weak-episode")||h.tags?.includes("weak-duplicate")){const x=h.initiator;if((h.start===e.start||x.start===e.start)&&(i||o||c)||i&&h.start>=e.start&&h.start<e.start+4&&h.end<=e.start+4||a&&h.end<=a.start)return!0;if(h.tags?.includes("weak-duplicate")){const v=h.initiator||h;if((t.range(v.end,e.end,k=>k.tags?.includes("weak-duplicate")&&!k.private)||[]).some(k=>(k.initiator||k)!==v))return!0}}return!1},"ignore"),predicate:p(h=>!!h.value,"predicate")}),u=Array.isArray(l)?l:l?[l]:[];let f=this.holesProcess(u,t,e);for(const h of f){if(!this.holeFilter(h))continue;if(process.env.DEBUG_TITLE_TRIM){const w=t.inputString??"";console.log(`[trim] hole="${w.slice(h.start,h.end)}" [${h.start},${h.end})`)}const x=t.range(h.start,h.end,w=>this.isIgnored(w)),m=Array.isArray(x)?x:x?[x]:[];if(m.length>0&&m.every(w=>w.name==="language"||w.name==="country")){let k=(t.inputString??"").slice(h.start,h.end);for(const P of m){const E=P.start-h.start;k=k.slice(0,E)+" ".repeat(P.end-P.start)+k.slice(P.end-h.start)}if(![...k].some(P=>!M.includes(P)&&P!==" "))continue}let v=h;const C=t.inputString??"";for(;v.start<v.end&&M.includes(C[v.start]);)v.start++;for(;v.end>v.start&&M.includes(C[v.end-1]);){const w=v.end-1;if(C[w]==="."&&w>=2&&/[a-zA-Z0-9]/.test(C[w-1])&&C[w-2]===".")break;v.end--}if(process.env.DEBUG_TITLE_TRIM){const w=m.map(k=>`${k.name}="${C.slice(k.start,k.end)}"@[${k.start},${k.end})`).join(", ");console.log(` after pre-strip hole=[${v.start},${v.end}) ignoredArray=[${w}]`)}for(;m.length>0;){const w=m[0];if(w.start===v.start){const k=w.name==="country"?!1:this.shouldKeep(v,m,!0);if(process.env.DEBUG_TITLE_TRIM&&console.log(` leading trim: shouldKeep=${k} for "${C.slice(w.start,w.end)}"`),k){let D=!1;for(let P=w.end;P<v.end;P++){const E=C[P];if(Rr.includes(E)){D=!0;break}if(!M.includes(E))break}if(!D)break}for(v.start=w.end;v.start<v.end&&M.includes(C[v.start]);)v.start++;m.shift()}else break}for(;m.length>0;){const w=m[m.length-1];if(w.end===v.end){if(w.name==="language"||w.name==="country"){const k=C.slice(v.start,w.start).toLowerCase().split(/[^a-z0-9]+/i).filter(Boolean),D=k[k.length-1];if(D&&Hs.has(D)){r.push(w),m.pop();break}}if(w.name==="episode_details"&&w.value==="Special"){const k=t.range(w.end,w.end+10,D=>D.name==="year"&&!D.private,0);if(k&&[...C.slice(w.end,k.start)].every(P=>M.includes(P)))break}if(this.languageDuplicatedAfterHole(w,v.end,t)){r.push(w),m.pop();break}if(this.shouldKeep(v,m,!1)){let k=!0,D=v.end;for(let P=m.length-1;P>=0;P--){const E=m[P];if(![...C.slice(E.end,D)].every(L=>M.includes(L))){k=!1;break}D=E.start}if(!k)break}for(v.end=w.start;v.end>v.start&&M.includes(C[v.end-1]);)v.end--;m.pop()}else break}if(process.env.DEBUG_TITLE_TRIM&&console.log(` result: hole=[${v.start},${v.end}) length=${v.length} value="${v.value}"`),v.length>0&&!this.shouldRemove(v)&&v.value){t.inputString;const w=t.markers.range(e.start,e.end,D=>D.name==="group"&&D.start===e.start,0)!==void 0||t.range(e.start,e.end,D=>D.name==="crc32",0)!==void 0;let k=this.alternativePropertyName&&!A(n,this.alternativePropertyName)?this.splitTitleAlternative(v,C):null;if(k&&w&&k.alternatives.every(D=>{const P=String(D.value??"").trim();return P.length>=4||/\s/.test(P)})&&(k=null),k){k.title.name=this.matchName,s.push(k.title);for(const D of k.alternatives)D.name=this.alternativePropertyName,s.push(D)}else v.name=this.matchName,s.push(v)}}const g=s.find(h=>h.name===this.matchName);if(g){const h=t.range(g.start,g.end,m=>m.name==="episode_details"||m.name==="country"||m.name==="language"),x=Array.isArray(h)?h:h?[h]:[];for(const m of x)r.includes(m)||r.push(m)}return{toAppend:s,toRemove:r}}_serieNameFilepart(e,t){for(let n=0;n<t.length-1;n++){if(n===0)continue;const s=t[n],r=e.range(s.start,s.end).filter(a=>!a.private);if(process.env.DEBUG_TITLE){const a=e.inputString??"";if(console.log(`[_serieNameFilepart] index=${n} fp="${a.slice(s.start,s.end)}" fpMatches=${r.map(i=>`${i.name}="${i.value}"@[${i.start},${i.end})`).join(",")}`),r[0]){const i=r[0].parent;console.log(` season span=[${r[0].start},${r[0].end}), filepart=[${s.start},${s.end}), parent span=${i?`[${i.start},${i.end})`:"null"}`)}}if(r.length===1&&r[0].name==="season"&&(r[0].start===s.start&&r[0].end===s.end||r[0].parent&&r[0].parent.start===s.start&&r[0].parent.end===s.end)){const a=[...t].sort((o,c)=>o.start-c.start),i=a.indexOf(s);return i>0?a[i-1]:null}}return null}_serieNameFilepartMatch(e,t,n,s){const r=e.range(t.start,t.end,f=>f.name==="title",0);if(r){if(process.env.DEBUG_TITLE){const f=e.inputString??"";console.log(`[_serieNameFilepartMatch] fp="${f.slice(t.start,t.end)}" found existing title="${r.value}"`)}return r}const a=p(f=>f.tags?f.tags.some(g=>g==="weak"||g.startsWith("weak-")):!1,"weakIgnored"),i=this.isIgnored.bind(this),o=p(f=>i(f)||a(f),"combinedIgnore"),c=e.holes(t.start,t.end,{formatter:At(B,Rt),ignore:o,predicate:p(f=>!!f.value,"predicate")}),l=Array.isArray(c)?c:c?[c]:[],u=this.holesProcess(l,e,t);if(process.env.DEBUG_TITLE){const f=e.inputString??"";console.log(`[_serieNameFilepartMatch] fp="${f.slice(t.start,t.end)}" holeArray=${l.length} processedHoles=${u.length}`),u.forEach((g,h)=>console.log(` hole[${h}]="${f.slice(g.start,g.end)}" value="${g.value}"`))}if(u.length===1&&u[0].value){const f=u[0];return f.name=this.matchName,n.push(f),f}return null}when(e,t){if((e.tagged("expected")?.filter(g=>g.name==="title")??[]).length>0)return null;const s=[],r=[],a=e.markers.named("path"),i=Array.isArray(a)?a:a?[a]:[],o=Nt(i,e),c=this._serieNameFilepart(e,o);let l=null;if(c&&(l=this._serieNameFilepartMatch(e,c,s,r)),process.env.DEBUG_TITLE){const g=e.inputString??"";console.log(`[when] sortedFileparts: ${o.map(h=>`"${g.slice(h.start,h.end)}"`).join(", ")}`),console.log(`[when] serieNameFilepart: ${c?`"${g.slice(c.start,c.end)}"`:"null"}`),console.log(`[when] serieNameMatch: ${l?`"${l.value}"`:"null"}`)}const u=new Set(o.filter(g=>$o(e.range(g.start,g.end,h=>h.name==="year",0)))),f=[...o].sort((g,h)=>g.start-h.start).pop();for(const g of o){if(u.delete(g),!this.filepartFilter(g)||l&&g!==c&&g!==f&&!$o(e.range(g.start,g.end,x=>!x.private,0)))continue;const h=this.checkTitlesInFilepart(g,e,t);if(h.toAppend.length>0||h.toRemove.length>0){if(l){const x=p(m=>So(m).replace(/[''`]/g,"").replace(/\.+$/,"").toLowerCase().trim(),"normTitle");for(const m of h.toAppend)x(String(m.value))!==x(String(l.value))&&(m.name="episode_title")}s.push(...h.toAppend),r.push(...h.toRemove);break}}for(const g of u){if(!this.filepartFilter(g))continue;const h=this.checkTitlesInFilepart(g,e,t),x=[];for(const m of h.toAppend){if(m.name!==this.matchName){x.push(m);continue}const v=String(m.value??""),C=p(D=>So(D).replace(/[''`]/g,"").toLowerCase(),"norm"),w=s.findIndex(D=>{const P=String(D.value??"");return C(P)===C(v)&&P!==v});if(w!==-1){const D=s[w];if(D.name===this.matchName)D.value=v;else if(D.name===this.alternativePropertyName){D.value=v;const P=s.find(E=>E.name===this.matchName);P&&(P.name=this.alternativePropertyName||"alternative_title",D.name=this.matchName)}continue}s.some(D=>{if(D.name!==this.matchName)return!1;const P=C(String(D.value??"")),E=C(v);return E.startsWith(P+" ")||E.endsWith(" "+P)})||x.push(m)}s.push(...x),r.push(...h.toRemove)}return s.length===0&&r.length===0?null:{toAppend:s,toRemove:r}}then(e,t,n){if(!t||typeof t!="object")return;const s=t;new b().then(e,s.toRemove,n),new $().then(e,s.toAppend,n)}};p(Ze,"TitleBaseRule"),Ze.priority=0,Ze.properties={};let Ts=Ze;const be=class be extends Ts{constructor(){super("title",["title"],"alternative_title")}};p(be,"TitleFromPosition"),be.priority=0,be.dependency=["DashSeparatedReleaseGroup","SubtitlePrefixLanguageRule","SubtitleSuffixLanguageRule","SubtitleExtensionRule"],be.properties={title:[null],alternative_title:[null]};let qt=be;const Ye=class Ye extends y{constructor(){super(...arguments),this.consequence=[b,Bt]}when(e,t){const n=[],s=e.named("title"),r=Array.isArray(s)?s:s?[s]:[];e.named("year");for(const a of r){if(a.tags?.includes("expected"))continue;const i=e.markers.atMatch(a,l=>l.name==="path",0);if(!i)continue;const o=e.range(i.start,i.end,l=>l.name==="year");(Array.isArray(o)?o:o?[o]:[]).length===0&&n.push(a)}return n}then(e,t,n){if(!t||!Array.isArray(t))return;new b().then(e,t,n),new Bt(["equivalent-ignore"]).then(e,t,n)}};p(Ye,"PreferTitleWithYear"),Ye.priority=32,Ye.dependency=[qt];let Fs=Ye;const hl=new Set(["the","a","an","le","la","les","l'","el","los","las","il","lo","un","una","der","die","das","de","het","o","os"]),Ln=class Ln extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.inputString||"",s=[],r=e.named("title"),a=e.named("episode_title"),i=[...Array.isArray(r)?r:r?[r]:[],...Array.isArray(a)?a:a?[a]:[]];for(const o of i){if(!hl.has(String(o.value??"").trim().toLowerCase()))continue;const c=e.markers.atMatch(o,f=>f.name==="path",0);if(!c)continue;const l=e.range(o.end,c.end,f=>!f.private&&["edition","language","country","other","source"].includes(f.name??""),0);if(!l||![...n.slice(o.end,l.start)].every(f=>M.includes(f)))continue;const u=e.range(l.end,c.end,f=>!f.private&&["year","season","episode","date"].includes(f.name??""),0);u&&n.slice(l.end,u.start).replace(/[sexd]/gi,"").split("").some(f=>!M.includes(f))||s.push({title:o,prop:l})}return s.length?s:!1}then(e,t,n){for(const{title:s,prop:r}of t){const a=e.inputString||"";e.remove(s),e.remove(r),s.end=r.end,s.value=B(a.slice(s.start,s.end)),e.append(s)}}};p(Ln,"ExtendLoneArticleTitle"),Ln.priority=-32;let Us=Ln;const $n=class $n extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.inputString||"",s=[],r=e.range(0,n.length,i=>!i.private&&["country","other","edition"].includes(i.name??"")),a=Array.isArray(r)?r:r?[r]:[];for(const i of a){if(!/^[A-Z][a-z]+$/.test(i.raw??""))continue;const o=e.markers.atMatch(i,l=>l.name==="path",0);if(!o||![...n.slice(o.start,i.start)].every(l=>M.includes(l))||["release-group-prefix","streaming_service.prefix","streaming_service.suffix"].some(l=>i.tags?.includes(l))||e.markers.atMatch(i,l=>l.name==="group",0))continue;const c=e.range(i.end,o.end,l=>!l.private&&["year","season","episode","date"].includes(l.name??""),0);c&&(![...n.slice(i.end,c.start)].every(l=>M.includes(l))&&e.range(i.end,c.start,l=>!l.private&&l.value!=null,0)||s.push(i))}return s.length?s:!1}};p($n,"CountryAtTitlePosition"),$n.priority=64;let Bs=$n;const Hn=class Hn extends y{constructor(){super(...arguments),this.priority=64,this.consequence=b}when(e,t){const n=[],s=e.inputString??"",r=e.tagged("title-word")??[];for(const a of Array.isArray(r)?r:[r]){if(!a||a.private)continue;const i=e.markers.atMatch(a,l=>l.name==="path",0);if(!i)continue;const o=e.range(i.start,i.end,l=>!l.private&&["year","season","episode","date"].includes(l.name??""),0);if(!o||a.start>=o.start)continue;const c=(e.range(i.start,a.start,l=>!l.private&&!(l.tags??[]).includes("title-word"))??[]).sort((l,u)=>l.end-u.end).pop();c&&[...s.slice(c.end,a.start)].every(l=>M.includes(l))||n.push(a)}return n.length?n:!1}};p(Hn,"TitleWordAtTitlePosition"),Hn.priority=64;let zs=Hn;const ml=/[\u0370-\u03FF\u0400-\u04FF\u0590-\u05FF\u0600-\u06FF\u0E00-\u0E7F\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF]/,Tn=class Tn extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[b,$]}when(e,t){if(A(t,"alternative_title"))return!1;const n=e.inputString??"",s=[],r=[];for(const a of e.named("title")){if(a.tags?.includes("expected"))continue;const i=n.slice(a.start,a.end),o=new RegExp("(?:^|["+z+"])([A-Za-z])").exec(i);if(!o)continue;const c=o.index+o[0].indexOf(o[1]),l=i.slice(0,c);if(!ml.test(l))continue;let u=l;for(;u.length&&M.includes(u[u.length-1]);)u=u.slice(0,-1);const f=a.start+u.length,g=a.start+c;f<=a.start||(s.push(a),r.push(new N(a.start,f,{name:"alternative_title",value:B(n.slice(a.start,f)),inputString:n})),r.push(new N(g,a.end,{name:"title",tags:["title"],value:B(n.slice(g,a.end)),inputString:n})))}return s.length||r.length?[s,r]:!1}};p(Tn,"SplitOriginalScriptTitle"),Tn.priority=O;let Vs=Tn;const Fn=class Fn extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[b,$]}when(e,t){if(A(t,"title"))return!1;const n=e.inputString??"",s=[],r=[];for(const a of e.named("title")??[]){const i=/^(.*\S)[\s._-]+(seasons?|saison)$/i.exec(String(a.value??""));if(!i)continue;const o=e.range(a.end,n.length,l=>!l.private&&!!l.value,0);if(!o||o.name!=="season")continue;s.push(a),n.slice(a.start,a.end).slice(0,i[1].length+(String(a.value).length===a.end-a.start,0));let c=a.end;for(;c>a.start&&B(n.slice(a.start,c)).toLowerCase()!==i[1].toLowerCase();)c--;c<=a.start||r.push(new N(a.start,c,{name:"title",value:B(n.slice(a.start,c)),inputString:n}))}return s.length||r.length?[s,r]:!1}};p(Fn,"TrimSeasonWordFromTitle"),Fn.priority=O;let Rs=Fn;const Un=class Un extends y{constructor(){super(...arguments),this.priority=O,this.consequence=b}when(e,t){if(A(t,"title"))return!1;const n=e.inputString??"",s=[];for(const r of e.markers.named("path")){const a=(e.range(r.start,r.end,l=>l.name==="title")??[]).sort((l,u)=>l.start-u.start);if(a.length<2)continue;const i=a[0];if(i.start!==r.start||/[\s._-]/.test(String(i.value??"").trim()))continue;const o=e.markers.range(i.end,r.end,l=>l.name==="group",0);!o||o.start>=a[1].start||![...n.slice(i.end,o.start)].every(l=>M.includes(l))||!e.range(o.start,o.end,l=>l.name==="release_group"&&!!l.tags?.includes("anime"),0)||s.push(i)}return s.length?s:!1}};p(Un,"PreBracketJunkTitle"),Un.priority=O;let Ws=Un;const Bn=class Bn extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[b,$]}when(e,t){if(A(t,"title"))return!1;const n=e.inputString??"",s=[],r=[];for(const a of e.markers.named("path")){const i=e.range(a.start,a.end,g=>g.name==="title")??[];if(i.length!==1)continue;const o=e.markers.atMatch(i[0],g=>g.name==="group"&&n[g.start]==="(",0);if(!o||!((e.range(a.start,a.end,g=>g.name==="episode"||g.name==="season")??[]).length>0))continue;const l=e.range(a.start,o.start,g=>g.name==="release_group",0);if(!l||!e.markers.atMatch(l,g=>g.name==="group"&&n[g.start]==="["&&g.start===a.start,0))continue;const f=B(n.slice(l.start,l.end));/[\p{L}]/u.test(f)&&(s.push(l,i[0]),r.push(new N(l.start,l.end,{name:"title",value:f,inputString:n})),r.push(new N(i[0].start,i[0].end,{name:"alternative_title",value:i[0].value,inputString:n})))}return s.length||r.length?[s,r]:!1}};p(Bn,"ParentheticalTitleYieldsToLeadBracket"),Bn.priority=O;let qs=Bn;const zn=class zn extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[b,$]}when(e,t){if(A(t,"title"))return!1;const n=e.inputString??"",s=[],r=[];for(const a of e.markers.named("path")){const i=e.range(a.start,a.end,f=>f.name==="title")??[];if(i.find(f=>/[\p{L}\p{N}]/u.test(String(f.value??""))))continue;s.push(...i);const c=e.markers.range(a.start,a.end,f=>f.name==="group")??[];if(!c.length)continue;const l=e.range(a.start,a.end,f=>f.name==="release_group",0);let u;for(const f of c){if(l&&f.start<=l.start&&f.end>=l.end)continue;const g=n.slice(f.start+1,f.end-1);if(!/[a-zA-Z]{2,}/.test(g))continue;const h=e.range(f.start,f.end,v=>!v.private&&["episode_title","alternative_title"].includes(v.name??""))??[],x=e.range(f.start,f.end,v=>!v.private&&!["episode_title","alternative_title"].includes(v.name??""))??[];if(h.length&&!x.length){s.push(...h),u=new N(f.start+1,f.end-1,{name:"title",value:B(n.slice(f.start+1,f.end-1)),inputString:n});break}const m=e.holes(f.start+1,f.end-1,{formatter:B,predicate:p(v=>!!v.value,"predicate"),index:0});if(!(!m||!/[a-zA-Z]{3,}/.test(String(m.value??"")))){u=m;break}}if(u){u.name="title",r.push(u);continue}if(l&&l.tags?.includes("anime")){const f=n.slice(a.start,a.end).replace(n.slice(l.start-1>=a.start?l.start-1:l.start,Math.min(l.end+1,a.end)),""),g=e.range(a.start,a.end,x=>!x.private&&x.name!=="release_group"&&x.start>=a.start)??[];/[a-zA-Z]{2,}/.test(f.replace(/\b(mkv|avi|mp4)\b/gi,""))&&g.some(x=>["title","episode_title","alternative_title"].includes(x.name??""))||(s.push(l),r.push(new N(l.start,l.end,{name:"title",value:B(n.slice(l.start,l.end)),inputString:n})))}}return s.length||r.length?[s,r]:!1}};p(zn,"BracketedTitleFallback"),zn.priority=O;let js=zn;const Vn=class Vn extends y{constructor(){super(...arguments),this.priority=64,this.consequence=b}when(e,t){if(A(t,"part"))return!1;const n=[];for(const s of e.named("part")??[]){const r=s.initiator??s;if(/\d/.test(String(r.raw??"")))continue;const a=e.markers.atMatch(s,o=>o.name==="path",0);if(!(!a||!e.range(s.end,a.end,o=>!o.private&&["year","season","episode","date"].includes(o.name??""),0))){n.push(s);for(const o of[...r.children??[]])n.includes(o)||n.push(o);r!==s&&!n.includes(r)&&n.push(r)}}return n.length?n:!1}};p(Vn,"WordNumeralPartAtTitlePosition"),Vn.priority=64;let Ks=Vn;const Rn=class Rn extends y{constructor(){super(...arguments),this.priority=64,this.consequence=b}when(e,t){if(A(t,"bonus"))return!1;const n=[];for(const s of e.named("bonus")??[]){const r=e.markers.atMatch(s,c=>c.name==="path",0);if(!r||!(e.range(r.start,r.end,c=>c.name==="crc32",0)||e.markers.range(r.start,r.end,c=>c.name==="group"&&c.start===r.start,0)))continue;const i=e.range(s.end,r.end,c=>!c.private&&["episode","season","year","date"].includes(c.name??""),0),o=e.named("bonus_title")??[];!i&&!o.length||(n.push(s),n.push(...o.filter(c=>c.start>=r.start&&c.end<=r.end)))}return n.length?n:!1}};p(Rn,"BonusAtTitlePositionRule"),Rn.priority=64;let Gs=Rn;const Wn=class Wn extends y{constructor(){super(...arguments),this.priority=64,this.consequence=b}when(e,t){if(A(t,"language"))return!1;const n=[];for(const s of e.named("language")??[]){const r=String(s.raw??"");if(r.length>3||!/^[A-Z][a-z]{0,2}$/.test(r))continue;const a=e.markers.atMatch(s,c=>c.name==="path",0);!a||!e.markers.range(a.start,a.end,c=>c.name==="group"&&c.start===a.start,0)||!e.range(s.end,a.end,c=>!c.private&&["episode","season","year","date"].includes(c.name??""),0)||n.push(s)}return n.length?n:!1}};p(Wn,"LanguageWordInAnimeTitle"),Wn.priority=64;let Xs=Wn;const qn=class qn extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.inputString||"",s=[];for(const r of e.markers.named("path")){const a=e.range(r.start,r.end,l=>!l.private&&!!l.value,0);if(!a)continue;const i=e.range(a.end,r.end,l=>!l.private&&["year","season","episode","date"].includes(l.name??""),0);if(!i){const l=e.range(r.start,r.end,u=>u.name==="title",0);if(a.name==="year"&&a.start===r.start&&!l){a.name="title",a.value=String(e.inputString??"").slice(a.start,a.end),s.push(a);continue}continue}const o=a.name==="year"&&["season","episode"].includes(i.name??"")&&!i.tags?.includes("weak-episode")&&!i.tags?.includes("weak-duplicate");if(!o&&!["other","country","edition"].includes(a.name??""))continue;const c=e.range(r.start,r.end,l=>l.name==="title")??[];c.some(l=>l.start<i.end)||c.length&&!o||(s.push(...c),!(a.name!=="year"&&(a.raw??"")===String(a.value??""))&&[...n.slice(r.start,a.start)].every(l=>M.includes(l))&&s.push(a))}return s.length?s:!1}then(e,t,n){const s=e.inputString||"";for(const r of t){e.remove(r);const a=new N(r.start,r.end,{name:"title",value:B(s.slice(r.start,r.end)),inputString:s});e.append(a)}}};p(qn,"PropertyAtTitlePositionAsTitle"),qn.priority=-48;let Zs=qn;const jn=class jn extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.named("alternative_title"),s=Array.isArray(n)?n:n?[n]:[];if(!s.length)return!1;const r=[];for(const a of s){const i=String(a.raw??a.value??"");if(!/^[\d\s.~_-]+$/.test(i)||!/\d/.test(i))continue;const o=e.markers.atMatch(a,l=>l.name==="path",0);if(!o)continue;e.range(o.start,o.end,l=>l.name==="episode"||l.name==="absolute_episode",0)&&r.push(a)}return r.length?r:!1}};p(jn,"RemoveNumericAlternativeTitle"),jn.priority=-64;let Ys=jn;const Je=class Je extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.named("alternative_title"),s=Array.isArray(n)?n:n?[n]:[];if(!s.length)return!1;const r=new Set(["year","title","alternative_title","episode_title","type"]),a=[];for(const i of s){const o=e.markers.atMatch(i,g=>g.name==="path",0);if(!o)continue;const c=e.range(o.start,o.end,g=>g.name==="year"),l=Array.isArray(c)?c:c?[c]:[];if(!l.length)continue;const u=Math.max(...l.map(g=>g.end));if(i.start<u)continue;e.range(u,i.start,g=>!g.private&&!!g.value&&!r.has(g.name??""),0)&&a.push(i)}return a.length?a:!1}};p(Je,"RemoveTailAlternativeTitle"),Je.priority=O,Je.dependency=["RenameEpisodeTitleWhenMovieType"];let Js=Je;const Qe=class Qe extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=new Set(["year","title","alternative_title","episode_title","type"]),s=[],r=[];for(const a of e.markers.named("path")){const i=e.range(a.start,a.end,u=>u.name==="title"),o=(Array.isArray(i)?i:i?[i]:[]).slice().sort((u,f)=>u.start-f.start);if(o.length<2)continue;const c=o[0],l=String(c.value??"").trim().toLowerCase();if(l){if(Hs.has(l)){o.slice(1).some(u=>!Hs.has(String(u.value??"").trim().toLowerCase()))&&s.push(c);continue}for(const u of o.slice(1))e.range(c.end,u.start,g=>!g.private&&!!g.value&&!n.has(g.name??""),0)&&(this.isSubtitle(e,a,u)?r.push(u):s.push(u))}}return this._toRename=r,s.length||r.length?s:!1}isSubtitle(e,t,n){const s=e.range(t.start,t.end,i=>i.name==="year");if(Array.isArray(s)?s.length>0:s)return!1;const r=String(n.value??"").trim();if(!/\p{Ll}/u.test(r))return!1;const a=r.split(/\s+/).filter(Boolean);return a.length<2?!1:a.every(i=>/^[\p{L}][\p{L}\p{N}'’.&-]*$/u.test(i))}then(e,t,n){if(Array.isArray(t))for(const s of t)e.remove(s);for(const s of this._toRename??[])e.remove(s),s.name="alternative_title",e.append(s)}};p(Qe,"RemoveTailTitle"),Qe.priority=O,Qe.dependency=["RenameEpisodeTitleWhenMovieType"];let Qs=Qe;function vl(d){const e=new F({disabled:p(n=>A(n,"title"),"disabled")});e.rules(Bs,zs,Ks,Gs,Xs,Vs,qt,Fs,Us,Zs,Ys,Js,Qs,js,Ws,qs,Rs);const t=ec("expected_title");return e.functional(t,{name:"title",tags:["expected","title"],validator:T,formatter:At(B,Rt),conflictSolver:p((n,s)=>s,"conflictSolver"),disabled:p(n=>!n?.expected_title,"disabled")}),e}p(vl,"title");function ue(d){return d==null?!1:Array.isArray(d)?d.length>0:!0}p(ue,"hasmatch");const xl=/^(the|a|an|le|la|les|l'|el|los|las|der|die|das)\s+/i;function Ho(d){return d.toLowerCase().replace(xl,"").trim()}p(Ho,"normalizeTitle");const Kn=class Kn extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[b,$]}when(e,t){const n=e.inputString??"",s=[],r=[],a=e.named("episode_title")??[];for(const i of a){if(!/^\d{1,2}$/.test(String(i.value??"")))continue;const o=(e.named("episode")??[]).filter(g=>g.end<=i.start&&!g.private).sort((g,h)=>g.start-h.start);if(o.length<3)continue;const c=o.slice(1),l=c[0].start,u=n.slice(l,i.end);if(!/^\d{1,3}(-\d{1,3})+$/.test(u))continue;const f=n.slice(o[0].end,l);/^[\s._]+$/.test(f)&&(s.push(...c,i),r.push(new N(l,i.end,{name:"episode_title",value:u,inputString:n})))}return s.length||r.length?[s,r]:!1}};p(Kn,"FormationRunEpisodeTitle"),Kn.priority=O;let ea=Kn;function yl(d){const e=new F({disabled:p(t=>A(t,"episode_title"),"disabled")});return e.rules(ua,da,pa,fa,ga,ha,ma,va,la,ca,ta,ra,sa,aa,ia,na,oa,ea,xa),e}p(yl,"episodeTitle");const _l=new Set(["ep","eps","episode","episodes","episodio","episodios","cap","capitulo","capitulos","folge","e"]),Gn=class Gn extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.named("episode_title"),s=Array.isArray(n)?n:n?[n]:[];if(!s.length)return!1;const r=[];for(const a of s){if(!_l.has(String(a.value??"").trim().toLowerCase()))continue;const i=e.range(a.end,e.inputString?.length??a.end+100,o=>!o.private&&!!o.value,0);i&&i.name==="episode"&&r.push(a)}return r.length?r:!1}};p(Gn,"RemoveEpisodeMarkerWordTitle"),Gn.priority=O;let ta=Gn;const et=class et extends y{constructor(){super(...arguments),this.consequence=b}static isHash(e){return/[\s._\-]/.test(e)?!1:/^[0-9a-f]{16,}$/i.test(e)?!0:e.length>=24&&/[a-z]/.test(e)&&/[A-Z]/.test(e)&&/\d/.test(e)}when(e,t){const n=e.inputString??"",s=new Set(["episode_title","version","episode_details","alternative_title"]),r=[];for(const a of e.markers.named("path")){let i=n.slice(a.start,a.end);const o=e.range(a.start,a.end,c=>c.name==="container",0);if(o&&(i=n.slice(a.start,o.start)),!!et.isHash(i.replace(/[.\s]+$/,"")))for(const c of e.range(a.start,a.end,l=>s.has(l.name??"")))r.push(c)}return r.length?r:!1}};p(et,"RemoveHashFilepartJunk"),et.priority=O;let na=et;const Xn=class Xn extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.named("episode_title"),s=Array.isArray(n)?n:n?[n]:[],r=[];for(const a of s){if(!e.markers.atMatch(a,o=>o.name==="group",0))continue;e.range(a.start,a.end,o=>o.name==="episode_details"&&o.start<=a.start&&o.end>=a.end,0)&&r.push(a)}return r.length?r:!1}};p(Xn,"RemoveEpisodeTitleCoveredByDetailsInGroup"),Xn.priority=O;let ra=Xn;const bl=/^[\s([(【「]*(?:end|fin|完结|完|全)[\s)\])】」]*$/i,Zn=class Zn extends y{constructor(){super(...arguments),this.consequence=[b,$]}when(e,t){const n=e.named("episode_title"),s=Array.isArray(n)?n:n?[n]:[],r=[],a=[];for(const i of s){if(!e.markers.atMatch(i,l=>l.name==="group",0)||!bl.test(String(i.raw??i.value??"")))continue;r.push(i);const o=e.named("other",l=>l.value==="Complete");(Array.isArray(o)?o.length:o?1:0)===0&&a.push(new N(i.start,i.end,{name:"other",value:"Complete",inputString:e.inputString}))}return r.length?[r,a]:!1}};p(Zn,"EndMarkerEpisodeTitleToComplete"),Zn.priority=O;let sa=Zn;const Yn=class Yn extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.named("episode_title"),r=(Array.isArray(n)?n:n?[n]:[]).filter(a=>/\bfansub/i.test(String(a.value??"")));return r.length?r:!1}};p(Yn,"RemoveFansubCreditEpisodeTitle"),Yn.priority=O;let aa=Yn;const Jn=class Jn extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.inputString??"",s=e.named("episode_title"),r=Array.isArray(s)?s:s?[s]:[],a=[];for(const i of r){if(/[\s.]/.test(String(i.value??"").trim()))continue;const o=n.slice(i.end).replace(/^[\s._-]+/,"");/^subtitl(e|es)\b|^subs?\b/i.test(o)&&a.push(i)}return a.length?a:!1}};p(Jn,"RemoveSubtitleDescriptorEpisodeTitle"),Jn.priority=O;let ia=Jn;const wl=new Set(["the","a","an","and","or","of","to","in","on","at","for","from","by","with","le","la","les","de","du","des","el"]),we=class we extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=[];for(const s of e.markers.named("path")){const r=e.range(s.start,s.end,c=>c.name==="episode_title"),a=(Array.isArray(r)?r:r?[r]:[]).slice().sort((c,l)=>c.start-l.start);if(a.length<2)continue;const i=a[0],o=String(i.value??"").trim().toLowerCase();if(!(!o||wl.has(o)))for(const c of a.slice(1))e.range(i.end,c.start,u=>!u.private&&!!u.value&&!we.TITLEISH.has(u.name??""),0)&&n.push(c)}return n.length?n:!1}};p(we,"RemoveTailEpisodeTitle"),we.priority=O,we.TITLEISH=new Set(["year","title","alternative_title","episode_title","type","episode","season"]);let oa=we;const Se=class Se extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=e.named("episode_title"),s=Array.isArray(n)?n:n?[n]:[];if(!s.length)return!1;const r=[],a=e.inputString??"",i=p((c,l)=>!!e.range(c,l,u=>Se.RELEASE_PROPS.has(u.name??""),0),"hasReleaseIn"),o=p((c,l)=>l<=c||[...a.slice(c,l)].every(u=>"[](){} .-_".includes(u)),"onlySeps");for(const c of s){const l=e.markers.atMatch(c,f=>f.name==="group",0);if(!l)continue;let u=i(l.start,l.end);if(!u)for(const f of e.markers.named("group")){if(f.span?.[0]===l.span?.[0])continue;if((f.start>=l.end&&o(l.end,f.start)||f.end<=l.start&&o(f.end,l.start))&&i(f.start,f.end)){u=!0;break}}u&&r.push(c)}return r.length?r:!1}};p(Se,"RemoveEpisodeTitleInReleaseGroup"),Se.priority=O,Se.RELEASE_PROPS=new Set(["screen_size","video_codec","audio_codec","audio_channels","source","color_depth","video_profile","audio_profile","streaming_service","video_bit_rate","audio_bit_rate","container"]);let ca=Se;const Qn=class Qn extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=[];for(const s of e.markers.named("path")){if(e.range(s.start,s.end,a=>a.name==="episode"&&!a.private,0)||!e.range(s.start,s.end,a=>a.name==="season"&&!a.private,0))continue;const r=e.range(s.start,s.end,a=>a.name==="episode_title");for(const a of Array.isArray(r)?r:r?[r]:[])/^\d{1,3}$/.test(String(a.value??"").trim())&&n.push(a)}return n.length?n:!1}then(e,t,n){for(const s of t)e.remove(s),s.name="episode",s.value=parseInt(String(s.value).trim(),10),e.append(s)}};p(Qn,"NumericEpisodeTitleToEpisode"),Qn.priority=O;let la=Qn;const er=class er extends y{constructor(){super(...arguments),this.consequence=b,this.previousNames=["episode","episode_count","season","season_count","date","title","year"],this.nextNames=["streaming_service","screen_size","source","video_codec","audio_codec","other","container"],this.affectedIfHolesAfter=["part"],this.affectedNames=["part","year"]}when(e,t){const n=[],s=e.markers.named("path");for(const r of s){const a=e.range(r.start,r.end,i=>this.affectedNames.includes(i.name??""));for(const i of a){const o=e.range(r.start,i.start,m=>!m.private,-1);if(!o||!this.previousNames.includes(o.name??"")||o.tags?.includes("weak-episode")||o.tags?.includes("weak-duplicate")||i.name==="year"&&e.markers.atMatch(i,v=>v.name==="group",0))continue;const c=e.range(i.end,r.end,m=>!m.private,0);if(!c||!this.nextNames.includes(c.name??""))continue;const l=e.markers.atMatch(i,m=>m.name==="group",0),u=p(m=>!!(m.value&&String(m.value).replace(new RegExp(`[${z}]`,"g"),""))&&l===e.markers.atMatch(m,v=>v.name==="group",0),"hasValueInSameGroup"),f=e.holes(o.end,i.start,{predicate:u}),g=e.holes(i.end,c.start,{predicate:u}),h=ue(f),x=ue(g);!h&&!x||this.affectedIfHolesAfter.includes(i.name??"")&&!x||(n.push(i),i.parent&&n.push(i.parent))}}return n}};p(er,"RemoveConflictsWithEpisodeTitle"),er.priority=64;let ua=er;const tr=class tr extends y{when(e,t){const n=e.named("title"),s={};for(const c of n){const l=String(c.value);s[l]=s[l]||[],s[l].push(c)}const r=[];if(Object.keys(s).length<2)return r;const a=new Set(["episode","season","date","year"]),i=p(c=>{const l=e.markers.atMatch(c,g=>g.name==="path",0);if(!l)return;const u=e.range(l.start,c.start,g=>!g.private&&a.has(g.name??"")),f=Array.isArray(u)?u:u?[u]:[];return f.length>0?f[f.length-1]:void 0},"findPrevEpisode"),o=new Set;for(const c of n)i(c)||o.add(Ho(String(c.value)));for(const c of n)if(i(c)){const u=Ho(String(c.value));o.has(u)||r.push(c)}return r}then(e,t,n){const s=t;for(const r of s)e.remove(r),r.name="episode_title",e.append(r)}};p(tr,"TitleToEpisodeTitle"),tr.dependency=["TitleFromPosition"];let da=tr;const nr=class nr extends y{when(e,t){const n=e.named("episode_title");if(!n||n.length===0)return;const s=[];for(const r of n){const a=e.inputString??"",i=e.range(r.end,r.end+20,o=>o.name==="episode_details");if(!(!i||i.length===0)){for(const o of i)if([...a.slice(r.end,o.start)].every(l=>M.includes(l))){s.push({et:r,detail:o});break}}}return s.length>0?s:void 0}then(e,t,n){const s=t;if(s)for(const{et:r,detail:a}of s)e.remove(r),r.end=a.end,r.value=void 0,r.value,e.append(r)}};p(nr,"ExtendEpisodeTitleWithDetails"),nr.dependency=["TitleToEpisodeTitle"];let pa=nr;const rr=class rr extends y{constructor(){super(...arguments),this.previousNames=["episode","episode_count","season","season_count","date","title","year"]}isIgnored(e){if(!(e.name==="language"||e.name==="country"||e.name==="episode_details"))return!1;const t=e.raw??"";return!(e.end-e.start>3&&t!==""&&t===t.toUpperCase()&&t!==t.toLowerCase())}when(e,t){const n=[],s=e.markers.named("path");for(const r of s){if(ue(e.range(r.start,r.end,f=>f.name==="episode_title",0)))continue;const i=ue(e.range(r.start,r.end,f=>f.name==="title",0)),o=ue(e.range(r.start,r.end,f=>f.name==="episode"&&!f.private,0));if(!i&&!o)continue;const c=e.holes(r.start,r.end,{formatter:At(B,Rt),ignore:p(f=>this.isIgnored(f),"ignore"),predicate:p(f=>!!f.value,"predicate")}),l=Array.isArray(c)?c:c?[c]:[],u=e.inputString||"";for(const f of l){const g=e.markers?.atMatch?.(f,E=>E.name==="group",0);if(g&&e.range(g.start,g.end,H=>(H.name==="year"||H.name==="date")&&!H.private,0))continue;const h=p(E=>E.name==="language"||E.name==="country","cropName"),x=e.range(r.start,r.end,E=>h(E)),m=Array.isArray(x)?x:x?[x]:[];let v=0;for(;v++<64;){let E=f.end;for(;E>f.start&&M.includes(u[E-1]);)E--;if(E<=f.start)break;const H=m.find(L=>L.start<=E-1&&L.end>=E);if(H&&H.start<f.end)f.end=Math.min(f.end,H.start);else break}for(v=0;v++<64;){let E=f.start;for(;E<f.end&&M.includes(u[E]);)E++;if(E>=f.end)break;const H=m.find(L=>L.start<=E&&L.end>=E+1);if(H&&H.end>f.start)f.start=Math.max(f.start,H.end);else break}for(;f.start<f.end&&M.includes(u[f.start]);)f.start++;for(;f.end>f.start&&M.includes(u[f.end-1]);)f.end--;if(f.end<=f.start||!f.value)continue;const C=p(E=>!E.private&&this.previousNames.includes(E.name??""),"prevPred"),w=e.range(r.start,f.start,C),k=Array.isArray(w)?w:w?[w]:[],D=k.length>0?k[k.length-1]:void 0;let P;if(!D){const E=e.range(r.start,f.start,L=>!L.private&&L.name==="crc32"),H=Array.isArray(E)?E:E?[E]:[];P=H.length>0?H[H.length-1]:void 0}!D&&!P||(f.name="episode_title",n.push(f))}}return n}then(e,t,n){const s=t;for(const r of s)e.includes(r)||e.append(r)}};p(rr,"EpisodeTitleFromPosition"),rr.dependency=["ExtendEpisodeTitleWithDetails"];let fa=rr;const sr=class sr extends y{constructor(){super(...arguments),this.previousNames=["episode","episode_count","season","season_count","date","title","year"]}when(e,t){if(ue(e.named("episode_title",null,0)))return;const n=e.range(0,void 0,s=>s.name==="alternative_title",0);if(n){const s=e.chainBefore(n.start,M,0,r=>r.name==="title",0);if(s){const r=e.markers.atMatch(s,x=>x.name==="path",0),a=r?.start??0,i=p(x=>!x.private&&this.previousNames.includes(x.name??""),"prevPred"),o=e.range(a,s.start,i),c=Array.isArray(o)?o:o?[o]:[],l=c.length>0?c[c.length-1]:void 0,u=r?.end??e.inputString?.length??s.end+100,f=l?void 0:e.range(a,u,x=>!x.private&&x.name==="crc32"),g=Array.isArray(f)?f:f?[f]:[],h=g.length>0?g[0]:void 0;if(l||h)return n}}}then(e,t,n){const s=t;s&&(e.remove(s),s.name="episode_title",s.tags=s.tags||[],s.tags.push("alternative-replaced"),e.append(s))}};p(sr,"AlternativeTitleReplace"),sr.dependency=["EpisodeTitleFromPosition"];let ga=sr;const ar=class ar extends y{constructor(){super(...arguments),this.langNames=new Set(["language","country","subtitle_language"])}when(e,t){const n=e.named("episode_title");if(!n||n.length===0)return;const s=[];for(const r of n){let a=r.start,i=r.end;const o=e.range(r.start,r.end,l=>this.langNames.has(l.name??""));if(!o||o.length===0)continue;const c=[...o].sort((l,u)=>u.start-l.start);for(const l of c)if(l.start>=a&&l.start<i){const u=r.inputString??"",f=l.end>=i?"":u.slice(l.end,i);if(f===""||[...f].every(g=>M.includes(g))){let g=l.start;for(;g>a&&M.includes(u[g-1]);)g--;g<i&&(i=g)}}(a!==r.start||i!==r.end)&&i>a&&s.push({match:r,newStart:a,newEnd:i})}return s.length>0?s:void 0}then(e,t,n){const s=t;if(s)for(const{match:r,newStart:a,newEnd:i}of s){e.remove(r),r.start=a,r.end=i,r.value=void 0;const o=r.value;o&&String(o).trim()&&e.append(r)}}};p(ar,"TrimLanguageFromEpisodeTitle"),ar.dependency=["EpisodeTitleFromPosition","AlternativeTitleReplace"];let ha=ar;function tc(d,e,t){const n=d.holes(e,t,{ignore:Xo(i=>!!i.tags?.includes("weak-episode"),i=>i.name==="language"||i.name==="country"||i.name==="episode_details"),formatter:B,seps:Rr,predicate:p(i=>!!i.value,"predicate")}),s=Array.isArray(n)?n:n?[n]:[];if(s.length===0)return;const r=s[0],a=r.inputString??"";for(const i of s.slice(1)){const o=a.slice(r.end,i.start),c=r.raw,l=i.raw;if(o==="-"&&c&&!M.includes(c[c.length-1])&&l&&!M.includes(l[0]))r.end=i.end;else break}return r}p(tc,"parentTitleHole");const Ji=class Ji extends y{constructor(){super(...arguments),this.consequence=new $("title")}when(e,t){if(ue(e.tagged("filepart-title",null,0)))return;const n=e.markers.named("path");if(n.length<3)return;const s=n[n.length-1],r=n[n.length-2],a=n[n.length-3];if(e.range(s.start,s.end,o=>o.name==="episode",0)&&e.range(r.start,r.end,c=>c.name==="season",0)){const c=tc(e,a.start,a.end);if(c)return c}}};p(Ji,"Filepart3EpisodeTitle");let ma=Ji;const Qi=class Qi extends y{constructor(){super(...arguments),this.consequence=new $("title")}when(e,t){if(ue(e.tagged("filepart-title",null,0)))return;const n=e.markers.named("path");if(n.length<2)return;const s=n[n.length-1],r=n[n.length-2];if(e.range(s.start,s.end,i=>i.name==="episode",0)){const i=e.range(r.start,r.end,l=>l.name==="season",0)||e.range(s.start,s.end,l=>l.name==="season",0),o=e.named("season"),c=Array.isArray(o)?o.length>0:!!o;if(i||!c){const l=tc(e,r.start,r.end);if(l){const u=e.markers.named("group"),g=(Array.isArray(u)?u:u?[u]:[]).filter(h=>h.start>=r.start&&h.end<=r.end&&!(h.start===r.start&&h.end===r.end));if(g.length>0){const h=l.crop(g),m=(Array.isArray(h)?h:h?[h]:[]).find(v=>v.value);if(m)return m.tags=m.tags||[],m.tags.push("filepart-title"),m}else return l.tags=l.tags||[],l.tags.push("filepart-title"),l}}}}};p(Qi,"Filepart2EpisodeTitle");let va=Qi;const tt=class tt extends y{when(e,t){const n=e.named("episode_title",r=>!r.tags?.includes("alternative-replaced"))||[],s=e.named("type",r=>r.value==="episode",0);if(n.length>0&&!s)return n}then(e,t,n){const s=t;if(s)for(const r of s)e.remove(r),r.name="alternative_title",e.append(r)}};p(tt,"RenameEpisodeTitleWhenMovieType"),tt.priority=O,tt.dependency=["TypeProcessor"];let xa=tt;const fe=[{alpha3:"eng",alpha2:"en",name:"English",opensubtitles:"eng"},{alpha3:"fra",alpha2:"fr",name:"French",opensubtitles:"fre"},{alpha3:"deu",alpha2:"de",name:"German",opensubtitles:"ger"},{alpha3:"spa",alpha2:"es",name:"Spanish",opensubtitles:"spa"},{alpha3:"ita",alpha2:"it",name:"Italian",opensubtitles:"ita"},{alpha3:"por",alpha2:"pt",name:"Portuguese",opensubtitles:"por"},{alpha3:"rus",alpha2:"ru",name:"Russian",opensubtitles:"rus"},{alpha3:"jpn",alpha2:"ja",name:"Japanese",opensubtitles:"jpn"},{alpha3:"zho",alpha2:"zh",name:"Chinese",opensubtitles:"chi"},{alpha3:"kor",alpha2:"ko",name:"Korean",opensubtitles:"kor"},{alpha3:"ara",alpha2:"ar",name:"Arabic",opensubtitles:"ara"},{alpha3:"hin",alpha2:"hi",name:"Hindi",opensubtitles:"hin"},{alpha3:"tur",alpha2:"tr",name:"Turkish",opensubtitles:"tur"},{alpha3:"pol",alpha2:"pl",name:"Polish",opensubtitles:"pol"},{alpha3:"nld",alpha2:"nl",name:"Dutch",opensubtitles:"dut"},{alpha3:"swe",alpha2:"sv",name:"Swedish",opensubtitles:"swe"},{alpha3:"dan",alpha2:"da",name:"Danish",opensubtitles:"dan"},{alpha3:"nor",alpha2:"no",name:"Norwegian",opensubtitles:"nor"},{alpha3:"fin",alpha2:"fi",name:"Finnish",opensubtitles:"fin"},{alpha3:"hun",alpha2:"hu",name:"Hungarian",opensubtitles:"hun"},{alpha3:"ces",alpha2:"cs",name:"Czech",opensubtitles:"cze"},{alpha3:"ron",alpha2:"ro",name:"Romanian",opensubtitles:"rum"},{alpha3:"ukr",alpha2:"uk",name:"Ukrainian",opensubtitles:"ukr"},{alpha3:"heb",alpha2:"he",name:"Hebrew",opensubtitles:"heb"},{alpha3:"cat",alpha2:"ca",name:"Catalan",opensubtitles:"cat"},{alpha3:"vie",alpha2:"vi",name:"Vietnamese",opensubtitles:"vie"},{alpha3:"tha",alpha2:"th",name:"Thai",opensubtitles:"tha"},{alpha3:"ind",alpha2:"id",name:"Indonesian",opensubtitles:"ind"},{alpha3:"mal",alpha2:"ml",name:"Malayalam",opensubtitles:"mal"},{alpha3:"tel",alpha2:"te",name:"Telugu",opensubtitles:"tel"},{alpha3:"tam",alpha2:"ta",name:"Tamil",opensubtitles:"tam"},{alpha3:"bul",alpha2:"bg",name:"Bulgarian",opensubtitles:"bul"},{alpha3:"hrv",alpha2:"hr",name:"Croatian",opensubtitles:"hrv"},{alpha3:"srp",alpha2:"sr",name:"Serbian",opensubtitles:"srp"},{alpha3:"slk",alpha2:"sk",name:"Slovak",opensubtitles:"slo"},{alpha3:"slv",alpha2:"sl",name:"Slovenian",opensubtitles:"slv"},{alpha3:"ell",alpha2:"el",name:"Greek",opensubtitles:"ell"},{alpha3:"lit",alpha2:"lt",name:"Lithuanian",opensubtitles:"lit"},{alpha3:"lav",alpha2:"lv",name:"Latvian",opensubtitles:"lav"},{alpha3:"est",alpha2:"et",name:"Estonian",opensubtitles:"est"},{alpha3:"glg",alpha2:"gl",name:"Galician",opensubtitles:"glg"},{alpha3:"eus",alpha2:"eu",name:"Basque",opensubtitles:"baq"},{alpha3:"ben",alpha2:"bn",name:"Bengali",opensubtitles:"ben"},{alpha3:"isl",alpha2:"is",name:"Icelandic",opensubtitles:"ice"},{alpha3:"mkd",alpha2:"mk",name:"Macedonian",opensubtitles:"mac"},{alpha3:"bos",alpha2:"bs",name:"Bosnian",opensubtitles:"bos"},{alpha3:"alb",alpha2:"sq",name:"Albanian",opensubtitles:"alb"},{alpha3:"per",alpha2:"fa",name:"Persian",opensubtitles:"per"},{alpha3:"msa",alpha2:"ms",name:"Malay",opensubtitles:"may"},{alpha3:"mon",alpha2:"mn",name:"Mongolian",opensubtitles:"mon"},{alpha3:"tha",alpha2:"th",name:"Thai",opensubtitles:"tha"},{alpha3:"urd",alpha2:"ur",name:"Urdu",opensubtitles:"urd"},{alpha3:"pan",alpha2:"pa",name:"Punjabi",opensubtitles:"pun"},{alpha3:"guj",alpha2:"gu",name:"Gujarati",opensubtitles:"guj"},{alpha3:"kan",alpha2:"kn",name:"Kannada",opensubtitles:"kan"},{alpha3:"mar",alpha2:"mr",name:"Marathi",opensubtitles:"mar"},{alpha3:"asm",alpha2:"as",name:"Assamese",opensubtitles:"asm"},{alpha3:"mya",alpha2:"my",name:"Burmese",opensubtitles:"mya"},{alpha3:"khm",alpha2:"km",name:"Khmer",opensubtitles:"khm"},{alpha3:"lao",alpha2:"lo",name:"Lao",opensubtitles:"lao"},{alpha3:"por",alpha2:"pt",name:"Brazilian Portuguese",country:"BR",opensubtitles:"pob"},{alpha3:"zho",alpha2:"zh",name:"Simplified Chinese",country:"CN",opensubtitles:"chi"},{alpha3:"zho",alpha2:"zh",name:"Traditional Chinese",country:"TW",opensubtitles:"zht"},{alpha3:"zho",alpha2:"zh",name:"Hong Kong Chinese",country:"HK",opensubtitles:"zht"},{alpha3:"deu",alpha2:"de",name:"Swiss German",country:"CH",opensubtitles:"ger"},{alpha3:"fra",alpha2:"fr",name:"Swiss French",country:"CH",opensubtitles:"fre"},{alpha3:"ita",alpha2:"it",name:"Swiss Italian",country:"CH",opensubtitles:"ita"},{alpha3:"nld",alpha2:"nl",name:"Flemish",country:"BE",opensubtitles:"dut"},{alpha3:"und",name:"Undetermined",opensubtitles:"und"},{alpha3:"mul",name:"Multiple Languages",opensubtitles:"mul"}];function kr(d){const e=new Map;for(const t of fe){const n=t[d];if(n){const s=String(n).toLowerCase();(!e.has(s)||!t.country&&e.get(s).country)&&e.set(s,t)}}return e}p(kr,"buildLookupMap");const Sl=kr("alpha3"),Al=kr("alpha2"),kl=kr("name"),Dl=kr("opensubtitles"),Cl={ell:["gr","gre","greek"],spa:["esp","español","espanol"],fra:["français","vf","vff","vfi","vfq"],swe:["se"],por_BR:["po","pb","pob","ptbr","br","brazilian"],deu_CH:["swissgerman","swiss german"],nld_BE:["flemish"],cat:["català","castellano","espanol castellano","español castellano"],ces:["cz"],ukr:["ua"],zho:[],jpn:["jp"],hrv:["scr"],mul:["multi","multiple","dl"]},Ml=new Set("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" ")),ce=class ce{constructor(e,t,n){this.alpha3=e,this.country=t,this.script=n}toString(){return this.script?`${this.alpha3}-${this.script}`:this.country?`${this.alpha3}-${this.country}`:this.alpha3}getName(){this.country?`${this.alpha3}${this.country}`:this.alpha3;for(const e of fe)if(e.alpha3===this.alpha3&&e.country===this.country)return e.name;for(const e of fe)if(e.alpha3===this.alpha3&&!e.country)return e.name;return this.alpha3}getAlpha2(){for(const e of fe)if(e.alpha3===this.alpha3&&e.country===this.country)return e.alpha2;for(const e of fe)if(e.alpha3===this.alpha3&&!e.country)return e.alpha2}getOpenSubtitles(){for(const e of fe)if(e.alpha3===this.alpha3&&e.country===this.country)return e.opensubtitles;for(const e of fe)if(e.alpha3===this.alpha3&&!e.country)return e.opensubtitles}static fromString(e){if(!e)return;const t=e.toLowerCase().trim(),n=this.fromSynonym(t);if(n)return n;if(t.length===3){const i=this.fromAlpha3(t);if(i)return i}if(t.length===2){const i=this.fromAlpha2(t);if(i)return i}const s=this.fromName(t);if(s)return s;const r=this.fromOpenSubtitles(t);if(r)return r;const a=this.fromIetf(t);if(a)return a}static fromAlpha3(e){if(!e)return;const t=e.toLowerCase().trim(),n=Sl.get(t);if(n)return new ce(n.alpha3,n.country,n.script)}static fromAlpha2(e){if(!e)return;const t=e.toLowerCase().trim(),n=Al.get(t);if(n)return new ce(n.alpha3,n.country,n.script)}static fromName(e){if(!e)return;const t=e.toLowerCase().trim(),n=kl.get(t);if(n)return new ce(n.alpha3,n.country,n.script)}static fromOpenSubtitles(e){if(!e)return;const t=e.toLowerCase().trim(),n=Dl.get(t);if(n)return new ce(n.alpha3,n.country,n.script)}static fromIetf(e){if(!e)return;const t=e.toLowerCase().trim().split("-");if(t.length!==0&&t.length>=1){const n=this.fromAlpha2(t[0]);if(n&&t.length>=2)if(t[1].length===2&&Ml.has(t[1].toUpperCase()))n.country=t[1].toUpperCase();else if(t[1].length===4&&/^[a-z]{4}$/.test(t[1]))n.script=t[1].charAt(0).toUpperCase()+t[1].slice(1);else return;return n}}static fromSynonym(e){if(!e)return;const t=e.toLowerCase().trim();for(const[n,s]of Object.entries(Cl))for(const r of s)if(r.toLowerCase()===t){const[a,i]=n.split("_");return new ce(a,i)}}equals(e){return this.alpha3===e.alpha3&&this.country===e.country&&this.script===e.script}};p(ce,"Language");let ne=ce;const To=new ne("und"),El=new ne("mul");function*_i(d){let e=null;for(let t=0;t<=d.length;t++){const n=t<d.length?d[t]:null;n!==null&&!M.includes(n)?e===null&&(e=t):e!==null&&(yield{span:[e,t],value:d.slice(e,t)},e=null)}}p(_i,"iterWords");const ir=class ir{constructor(e,t,n,s,r){this.start=e,this.end=t,this.value=n,this.inputString=s,this.nextWord=r}get extendedWord(){if(!this.nextWord)return;const e=this.inputString.slice(this.end,this.nextWord.start),t=this.inputString.slice(this.nextWord.end,this.nextWord.end+1);if(e==="-"&&e!==t||e===" "||e==="."){const n=this.inputString.slice(this.start,this.nextWord.end).replace(/\./g," ");return new ir(this.start,this.nextWord.end,n,this.inputString,this.nextWord.nextWord)}}};p(ir,"LanguageWord");let ze=ir;const eo=class eo{constructor(e,t,n,s,r,a,i){const o=e?.allowed_languages||[];this.allowedLanguages=new Set(o.map(c=>c.toLowerCase())),this.weakAffixes=new Set(a),this.commonWords=i??new Set,this.prefixesMap=new Map,this.suffixesMap=new Map,A(e,"subtitle_language")||(this.prefixesMap.set("subtitle_language",t),this.suffixesMap.set("subtitle_language",n)),this.prefixesMap.set("language",s),this.suffixesMap.set("language",r)}*find(e){const t=new Map,n=new Map,s=new Map;for(const i of this.iterLanguageMatches(e)){const o=i.propertyName;i.lang.equals(To)?(n.has(o)||n.set(o,new Set),n.get(o).add(i)):i.lang.equals(El)?(s.has(o)||s.set(o,new Set),s.get(o).add(i)):(t.has(o)||t.set(o,new Set),t.get(o).add(i))}const r=new Set,a=p(i=>{const o=`${i.propertyName}:${i.word.start}-${i.word.end}:${i.lang.alpha3}`;if(!r.has(o))return r.add(o),this.toRebulkMatch(i)},"emit");for(const[i,o]of s)if(t.has(i)||!n.has(i))for(const c of o){const l=a(c);l&&(yield l)}for(const[i,o]of n)if(!t.has(i))for(const c of o){const l=a(c);l&&(yield l)}for(const i of t.values())for(const o of i){const c=a(o);c&&(yield c)}}toRebulkMatch(e){const t=e.word,n=t.start,s=t.end,r=e.propertyName;if(e.lang.equals(To)){const i=["weak-language"],o=(t.inputString??"").slice(n,s).toLowerCase();return(this.commonWords.has(o)||this.commonWords.has(t.value.toLowerCase()))&&i.push("common"),[n,s,{name:r,value:t.value.toLowerCase(),formatter:p(c=>new ne("und"),"formatter"),tags:i}]}const a=[];return this.commonWords.has(t.value.toLowerCase())&&a.push("common"),[n,s,{name:r,value:e.lang,...a.length>0?{tags:a}:{}}]}*iterLanguageMatches(e){const t=[];let n=null;for(const s of _i(e)){const r=new ze(s.span[0],s.span[1],s.value,e);n&&(n.nextWord=r,t.push(n)),n=r}n&&t.push(n);for(const s of t)yield*this.iterMatchesForCandidate(s)}*iterMatchesForCandidate(e){if(e.nextWord){const s=this.findMatchForWord(e.nextWord,e,this.prefixesMap,(r,a)=>r.startsWith(a),(r,a)=>r.slice(a.length));s&&(yield s)}const t=this.findMatchForWord(e,e.nextWord??void 0,this.suffixesMap,(s,r)=>s.endsWith(r),(s,r)=>s.slice(0,-r.length));t&&(yield t);const n=this.findLanguageMatchForWord(e);n&&(yield n)}findMatchForWord(e,t,n,s,r){if(e)for(const a of[e.extendedWord,e]){if(!a)continue;const i=a.value.toLowerCase();for(const[o,c]of n)for(const l of c){if(!s(i,l))continue;let u;const f=r(i,l);if(!f)t&&(Math.abs(t.start-a.end)<=1||Math.abs(a.start-t.end)<=1)&&(u=this.findLanguageMatchForWord(t,o)),!u&&!this.weakAffixes.has(l)&&(u=this.createLanguageMatch(o,new ze(a.start,a.end,"und",a.inputString)));else{let g=a.start,h=a.end;if(a!==e){const x=f.trim();x&&e&&e.value.toLowerCase()===x?(g=e.start,h=e.end):x&&e&&e.nextWord&&e.nextWord.value.toLowerCase()===x?(g=e.nextWord.start,h=e.nextWord.end):x&&t&&(g=t.start,h=t.end)}u=this.createLanguageMatch(o,new ze(g,h,f,a.inputString))}if(u)return u}}}findLanguageMatchForWord(e,t="language"){if(e){for(const n of[e.extendedWord,e])if(n){const s=this.createLanguageMatch(t,n);if(s)return s}}}createLanguageMatch(e,t){const n=this.parseLanguage(t.value.toLowerCase());if(n)return{propertyName:e,word:t,lang:n}}parseLanguage(e){const t=ne.fromString(e);if(!t)return;if(this.allowedLanguages.size===0)return t;const n=t.getName().toLowerCase(),s=t.getAlpha2(),r=t.alpha3.toLowerCase();if(this.allowedLanguages.has(n)||s&&this.allowedLanguages.has(s.toLowerCase())||this.allowedLanguages.has(r))return t}};p(eo,"LanguageFinder");let ya=eo;const to=class to extends y{constructor(){super(...arguments),this.consequence=b,this.properties={subtitle_language:[null]}}enabled(e){return!A(e,"subtitle_language")}when(e,t){const n=[],s=e.named("subtitle_language.prefix")||[];for(const r of e.named("language")||[]){let a=e.previous(r,i=>i.name==="subtitle_language.prefix",0);if(!a){const i=e.markers?.at(r,o=>o.name==="group",0);i&&(a=e.previous(i,o=>o.name==="subtitle_language.prefix",0),a||(a=e.range?.(i.start,r.start,o=>o.name==="subtitle_language.prefix",0)))}if(!a){const i=e.markers?.atMatch?.(r,o=>o.name==="group",0);if(i){const o=n.find(([c,l])=>l.start>=i.start&&l.end<=i.end);o&&(a=o[0])}}if(a){n.push([a,r]);const i=e.conflicting?.(r)||[];s.push(...i),s.includes(a)&&s.splice(s.indexOf(a),1)}}return n.length>0||s.length>0?{toRename:n,toRemove:s}:!1}then(e,t,n){const{toRename:s,toRemove:r}=t;for(const a of r)e.remove(a);for(const[a,i]of s){const o={...a,name:"subtitle_language.suffix"};e.includes?.(o)&&e.remove(o),e.remove(i),i.name="subtitle_language",e.append(i)}}};p(to,"SubtitlePrefixLanguageRule");let kt=to;const no=class no extends y{constructor(){super(...arguments),this.dependency=kt,this.consequence=b,this.properties={subtitle_language:[null]}}enabled(e){return!A(e,"subtitle_language")}when(e,t){const n=[],s=e.named("subtitle_language.suffix")||[];for(const r of e.named("language")||[]){const a=e.next(r,i=>i.name==="subtitle_language.suffix",0);if(a){if(e.next(a,c=>c.name==="language"||c.name==="subtitle_language",0)||e.range?.(a.start,a.end+10,c=>(c.name==="language"||c.name==="subtitle_language")&&c.start>=a.start&&c.end>a.end,0))continue;n.push(r),s.includes(a)&&s.splice(s.indexOf(a),1)}}return n.length>0||s.length>0?{toAppend:n,toRemove:s}:!1}then(e,t,n){const{toAppend:s,toRemove:r}=t;for(const a of r)e.remove(a);for(const a of s)e.remove(a),a.name="subtitle_language",e.append(a)}};p(no,"SubtitleSuffixLanguageRule");let Dt=no;const nt=class nt extends y{constructor(){super(...arguments),this.dependency=Dt}when(e,t){const n=e.named("container")||[],r=(Array.isArray(n)?n:n?[n]:[]).find(f=>nt.SUBTITLE_EXTENSIONS.has(String(f.value).toLowerCase()));if(!r)return!1;const a=e.markers?.named("path")||[],o=(Array.isArray(a)?a:a?[a]:[]).find(f=>r.start>=f.start&&r.end<=f.end),c=e.named("language")||[],l=Array.isArray(c)?c:c?[c]:[];let u;return o?u=l.filter(f=>f.start>=o.start&&f.end<=o.end):u=l,u.length>0?u:!1}then(e,t,n){if(!(!t||!Array.isArray(t)))for(const s of t)e.remove(s),s.name="subtitle_language",e.append(s)}};p(nt,"SubtitleExtensionRule"),nt.SUBTITLE_EXTENSIONS=new Set(["srt","sub","smi","ssa","ass","vtt","idx","sup"]);let jt=nt;const or=class or extends y{constructor(){super(...arguments),this.consequence=b,this.priority=32}when(e,t){const n=[],s=e.range?.(0,e.inputString?.length??0,a=>a.name==="language"||a.name==="subtitle_language")||[],r=Array.isArray(s)?s:s?[s]:[];for(const a of r){if(!a.tags?.includes("common"))continue;const i=e.markers?.atMatch?.(a,o=>o.name==="group",0);if(i){const o=e.range?.(i.start,i.end,f=>f.name!=="language"&&f.name!=="subtitle_language"),c=Array.isArray(o)?o.length>0:!!o,l=e.holes?.(i.start,i.end,{predicate:p(f=>f.value&&[...String(f.value)].some(g=>!M.includes(g)),"predicate")}),u=Array.isArray(l)?l.length>0:!!l;if(!c&&!u)continue}n.push(a)}return n.length>0?n:!1}};p(or,"RemoveCommonWordsLanguageRule"),or.priority=32;let _a=or;const ro=class ro extends y{constructor(){super(...arguments),this.consequence=b}enabled(e){return A(e,"language")}when(e,t){return e.named("language")||!1}};p(ro,"RemoveLanguageRule");let ba=ro;const cr=class cr extends y{constructor(){super(...arguments),this.consequence=b,this.priority=32}when(e,t){const n=[];for(const s of e.range?.(0,e.inputString?.length)||[])if(["language","subtitle_language"].includes(s.name)&&(s.value==="und"||s.value instanceof ne&&s.value.alpha3==="und")){const r=e.previous?.(s,void 0,0),a=e.next?.(s,void 0,0),i=new Set(["language","subtitle_language"]);(r&&i.has(r.name)||a&&i.has(a.name))&&n.push(s)}return n.length>0?n:!1}};p(cr,"RemoveUndeterminedLanguagesRule"),cr.priority=32;let wa=cr;const so=class so extends y{constructor(){super(...arguments),this.consequence=b,this.dependency=[kt,Dt,jt]}identity(e){const t=e.value;if(t instanceof ne){const n=t.country;return`${t.alpha3}:${n?String(n):""}`}return String(t)}when(e){const t=[];for(const n of["language","subtitle_language"]){const s=[...e.named(n)||[]].sort((a,i)=>a.start-i.start||a.end-i.end),r=new Set;for(const a of s){const i=`${a.start}-${a.end}:${this.identity(a)}`;r.has(i)?t.push(a):r.add(i)}}return t.length>0?t:!1}};p(so,"DedupLanguageRule");let Sa=so;function Nl(d,e){const t=d.subtitle_affixes,n=[...t,...d.subtitle_prefixes].sort((l,u)=>u.length-l.length),s=[...t,...d.subtitle_suffixes].sort((l,u)=>u.length-l.length),r=d.language_affixes,a=[...r,...d.language_prefixes].sort((l,u)=>u.length-l.length),i=[...r,...d.language_suffixes].sort((l,u)=>u.length-l.length),o=new Set(d.weak_affixes),c=new F().stringDefaults({ignoreCase:!0}).defaults({validator:T});for(const l of n)c.string(l,{name:"subtitle_language.prefix",ignoreCase:!0,private:!0,validator:T,tags:["release-group-prefix"],disabled:p(u=>A(u,"subtitle_language"),"disabled")});for(const l of s)c.string(l,{name:"subtitle_language.suffix",ignoreCase:!0,private:!0,validator:T,disabled:p(u=>A(u,"subtitle_language"),"disabled")});for(const l of i)c.string(l,{name:"language.suffix",ignoreCase:!0,private:!0,validator:T,tags:["source-suffix"],disabled:p(u=>A(u,"language"),"disabled")});return c.functional((l,u)=>{const f=new ya(u,n,s,a,i,Array.from(o),e);return Array.from(f.find(l))},{properties:{language:[null]},disabled:p(l=>A(l,"language")&&A(l,"subtitle_language"),"disabled")}),c.rules(kt,Dt,jt,_a,ba,wa,Sa,ka,Aa),c}p(Nl,"language");const Ae=class Ae extends y{constructor(){super(...arguments),this.priority=32,this.consequence=b}static isBibliographicOnly(e){const t=e.trim().toLowerCase();return t.length!==3?!1:!ne.fromAlpha3(t)&&!!ne.fromOpenSubtitles(t)}when(e,t){const n=e.inputString??"",s=[];for(const r of e.named("language")??[])Ae.isBibliographicOnly(String(r.raw??""))&&n[r.start-1]==="-"&&s.push(r);for(const r of e.named("subtitle_language")??[])Ae.isBibliographicOnly(String(r.raw??""))&&n[r.start-1]==="-"&&s.push(r);return s.length?s:!1}};p(Ae,"RemoveDashGluedBibliographicCode"),Ae.priority=32;let Aa=Ae;const lr=class lr extends y{constructor(){super(...arguments),this.consequence=b}when(e){const t=new Set(["title","episode_title","alternative_title"]),n=e.range(0,(e.inputString??"").length,r=>t.has(r.name??""));if(!n.length)return!1;const s=[];for(const r of["language","subtitle_language"])for(const a of e.named(r))String(a.raw??"").trim().length>3||n.some(o=>o.start<=a.start&&o.end>=a.end)&&s.push(a);return s.length?s:!1}};p(lr,"RemoveLanguageInsideTitle"),lr.priority=O;let ka=lr;const Pl={us:"US",usa:"US","united states":"US",gb:"GB",uk:"GB","united kingdom":"GB",ca:"CA",canada:"CA",de:"DE",germany:"DE",fr:"FR",france:"FR",it:"IT",italy:"IT",es:"ES",spain:"ES",nl:"NL",netherlands:"NL",be:"BE",belgium:"BE",ch:"CH",switzerland:"CH",se:"SE",sweden:"SE",no:"NO",norway:"NO",dk:"DK",denmark:"DK",fi:"FI",finland:"FI",pl:"PL",poland:"PL",ru:"RU",russia:"RU",cn:"CN",china:"CN",jp:"JP",japan:"JP",au:"AU",australia:"AU",nz:"NZ","new zealand":"NZ",in:"IN",india:"IN",br:"BR",brazil:"BR",mx:"MX",mexico:"MX",za:"ZA","south africa":"ZA",kr:"KR","south korea":"KR",tw:"TW",taiwan:"TW",hk:"HK","hong kong":"HK"};function Ol(d,e){const t=new F({disabled:p(s=>A(s,"country"),"disabled")});t.defaults({name:"country"});function n(s,r){const a=r?.allowed_countries;return new Ca(a,e).find(s)}return p(n,"findCountries"),t.functional(n,{conflictSolver:p((s,r)=>r.name!=="language"||!["US","GB"].includes(String(s.value))?s:r,"conflictSolver"),properties:{country:[null]},disabled:p(s=>!s?.allowed_countries,"disabled")}),t.rules(Da)}p(Ol,"country");const ao=class ao extends y{constructor(){super(...arguments),this.consequence=b}then(e,t,n){if(Array.isArray(t))for(const s of t)e.remove(s),s.private=!0,e.append(s)}when(e,t){const n=e.named("country"),s=[];for(const r of Array.isArray(n)?n:n?[n]:[]){if(String(r.value)!=="GB")continue;const a=e.markers.atMatch(r,o=>o.name==="group",0);if(!a)continue;const i=(e.inputString??"").slice(a.start+1,a.end-1).trim();/^gbk?$/i.test(i)&&s.push(r)}return s.length?s:!1}};p(ao,"RemoveEncodingTagCountry");let Da=ao;const io=class io{constructor(e,t){this.allowedCountries=new Set(e?.map(n=>n.toLowerCase())||[]),this.commonWords=t}find(e){const t=[];for(const n of _i(e.trim().toLowerCase())){const s=n.value;if(this.commonWords.has(s.toLowerCase()))continue;const r=Pl[s.toLowerCase()];r&&(this.allowedCountries.has(r.toLowerCase())||this.allowedCountries.has(s.toLowerCase()))&&t.push([n.span[0],n.span[1],{value:r}])}return t}};p(io,"CountryFinder");let Ca=io;function Il(d){const e=d.forbidden_names,t=d.ignored_seps,n=M.split("").filter(o=>!t.includes(o)).join("");function s(o){let c=me(o,n);const l=t.split("").some(g=>c.includes(g)),u=t.split("").some(g=>c.startsWith(g)),f=t.split("").some(g=>c.endsWith(g));!(u&&f)&&!l&&(c=me(c,t));for(const g of e)c.toLowerCase().startsWith(g)&&c.length>g.length&&M.includes(c[g.length])&&(c=me(c.slice(g.length),n)),c.toLowerCase().endsWith(g)&&c.length>g.length&&M.includes(c[c.length-g.length-1])&&(c=me(c.slice(0,c.length-g.length),n));return c=c.replace(/\s*[)\]]\s*$/,g=>{const x=g.trim()===")"?"(":"[";return c.includes(x)?g:""}).trim(),c.replace(/(.+)\)\s*\[(.+)\]/,"$1 $2").trim()}p(s,"cleanGroupname");const r=new F({disabled:p(o=>A(o,"release_group"),"disabled")}),a=ec("expected_group");r.functional(a,{name:"release_group",tags:["expected"],validator:T,conflictSolver:p(()=>null,"conflictSolver"),disabled:p(o=>!o?.expected_group,"disabled")});const i=new Na(s);return r.rules(new Ea(s),i,Pa,new La(s),Oa,Ma,new Ia(s,o=>i.isPreviousMatch(o)))}p(Il,"releaseGroup");const ur=class ur extends y{constructor(){super(...arguments),this.consequence=b}when(e){const t=e.named("release_group"),n=(Array.isArray(t)?t:t?[t]:[]).filter(s=>/(^|[\s._\-\[(])seasons?[\s._-]*\d/i.test(String(s.value??"")));return n.length?n:!1}};p(ur,"RemoveSeasonPackReleaseGroup"),ur.priority=O;let Ma=ur;const oo=class oo extends y{constructor(e){super(),this.consequence=[b,$],this.valueFormatter=e}isValid(e,t,n,s,r){if(!r){if(String(t.value).length<=1||e.markers.atMatch(t,g=>g.name==="group",0)||e.range(t.start,t.end,g=>g.name==="episode",0))return!1;const c=e.holes(t.end,s,{predicate:p(g=>g.start===t.end,"predicate"),index:0});if(!c)return!1;const u=String(c.raw??"").replace(new RegExp("^["+z+"]+|["+z+"]+$","g"),"");if(t.start===n&&!u.includes(".")&&!u.includes(" ")&&e.range(t.end,s,g=>["season","episode","date","year"].includes(g.name??"")&&!g.private,0))return!1;const f=c.raw;return f[0]==="-"&&!f.slice(1).includes("-")&&f.includes(".")&&!f.includes(" ")}const a=e.markers.atMatch(t,c=>c.name==="group",0);if(a&&e.atMatch(a,c=>!c.private&&c.span!==t.span))return!1;let i=0,o=t;for(;o;){const c=e.range(n,o.start,f=>!f.private&&!f.tags.includes("expected"),-1);if(!c)break;let u=(e.inputString??"").slice(c.end,o.start);if(!u&&(o.raw??"")[0]==="-"&&(u="-"),o=c,i===0){if(u!=="-")break;i++;continue}if(u===".")return!0}return!1}detect(e,t,n,s){let r=null;if(s){const a=e.ending(n,i=>i.name==="container",0);a&&(n=a.start),r=e.ending(n,i=>!i.private&&!(i.name==="other"&&i.tags.includes("not-a-release-group"))&&!(i.raw??"").includes("-")&&(i.raw??"").trim()===i.raw,0)}if(!r){const a=p(i=>!!(i.tags?.includes("weak-episode")||i.tags?.includes("weak-duplicate")),"ignoreWeak");s?r=e.holes(t,n,{seps:M,index:-1,ignore:a,predicate:p(i=>i.end===n&&!!(i.raw??"").trim()&&(i.raw??"")[0]==="-","predicate")}):r=e.holes(t,n,{seps:M,index:0,ignore:a,predicate:p(i=>i.start===t&&!!(i.raw??"").trim(),"predicate")})}return r&&this.isValid(e,r,t,n,s)?r:null}when(e){if(e.named("release_group").length>0)return;const t=[],n=[];for(const s of e.markers.named("path")){let r=this.detect(e,s.start,s.end,!0);if(r?t.push(...e.atMatch(r)):r=this.detect(e,s.start,s.end,!1),r){const a=new N(r.start,r.end,{name:"release_group",inputString:e.inputString});if(a.formatter=this.valueFormatter,a.value&&n.push(a),t.length||n.length)return[t,n]}}}};p(oo,"DashSeparatedReleaseGroup");let Ea=oo;const ke=class ke extends y{constructor(e){super(),this.valueFormatter=e}isPreviousMatch(e){const t=["video_codec","source","video_api","audio_codec","audio_profile","video_profile","audio_channels","screen_size","other","container","language","subtitle_language","subtitle_language.suffix","subtitle_language.prefix","language.suffix"],n=["release-group-prefix"],s=["no-release-group-prefix"];return t.includes(e.name??"")?!e.tags.some(r=>s.includes(r)):e.tags.some(r=>n.includes(r))}when(e){const t=[];for(const n of Nt(e.markers.named("path"),e)){const{start:s,end:r}=n;if(e.named("release_group",c=>c.start>=s&&c.end<=r).length>0)continue;const a=e.named("title",c=>c.start>=s&&c.end<=r),i=p(c=>a.slice(1).includes(c)||c.name==="episode_title"||!!(c.tags?.includes("weak-episode")||c.tags?.includes("weak-duplicate")),"keepOnlyFirstTitle"),o=e.holes(s,r+1,{formatter:p(c=>B(c),"formatter"),ignore:i,predicate:p(c=>!!B(String(c.value??"")),"predicate"),index:-1});if(o){const c=e.markers.atMatch(o,h=>h.name==="group",0);if(c&&String(c.raw??"").startsWith("(")&&(e.range(s,r,x=>x.name==="episode"||x.name==="season")??[]).length>0){const x=e.markers.range(s,r,m=>m.name==="group"&&m.start===s,0);if(x){const m=e.range(x.start,x.end,w=>!w.tags.includes("weak-language"))??[],v=String(x.value??"").replace(new RegExp(`[${z}]`,"g"),"");if((m.length===0||m.every(w=>w.name==="container"&&w.tags?.includes("subtitle")))&&v&&!xe(v))continue}}const l=p(h=>h.start<n.start?!1:!h.private||this.isPreviousMatch(h),"previousMatchFilter"),u=e.previous(o,l,0),f=e.inputString??"",g=String(o.value??"");if(u&&this.isPreviousMatch(u)&&!f.slice(u.end,o.start).replace(new RegExp(`[${z}]`,"g"),"")&&!xe(g.replace(new RegExp(`[${z}]`,"g"),""))){o.name="release_group",o.tags=["scene"],o.formatter=this.valueFormatter;const h=e.markers.atMatch(o,m=>m.name==="group",0);h&&(h.formatter=this.valueFormatter,h.value===o.value&&(o.start=h.start+1,o.end=h.end-1,o.tags=["anime"]));const x=e.range(o.start,o.end,i);for(const m of x)e.remove(m);t.push(o)}}}return t}};p(ke,"SceneReleaseGroup"),ke.dependency=["TitleFromPosition"],ke.consequence=$,ke.properties={release_group:[null]};let Na=ke;const De=class De extends y{when(e){const t=[],n=[];if(e.named("release_group").length>0||!e.named("episode").length&&!e.named("season").length&&e.named("release_group").length>0)return!1;for(const s of Nt(e.markers.named("path"),e)){const r=p(i=>{const o=e.range(i.start,i.end,c=>!c.tags.includes("weak-language"));return!!(o.length===0||i.start===s.start&&o.every(c=>c.name==="container"&&c.tags?.includes("subtitle")))},"isGroupEmpty"),a=e.markers.range(s.start,s.end,i=>i.name==="group"&&r(i)&&String(i.value).replace(new RegExp(`[${z}]`,"g"),"")&&!xe(String(i.value).replace(new RegExp(`[${z}]`,"g"),"")),0);if(a){const i=new N(a.start+1,a.end-1,{name:"release_group",inputString:e.inputString,tags:["anime"]});n.push(i),t.push(...e.range(a.start,a.end,o=>o.tags.includes("weak-language")||o.name==="other"||o.name==="container"&&o.tags?.includes("subtitle")))}}return t.length||n.length?[t,n]:!1}};p(De,"AnimeReleaseGroup"),De.dependency=["SceneReleaseGroup","TitleFromPosition"],De.consequence=[b,$],De.properties={release_group:[null]};let Pa=De;const dr=class dr extends y{constructor(){super(...arguments),this.priority=-32,this.consequence=[b,$]}when(e,t){const n=e.inputString??"",s=[],r=[];for(const a of e.named("release_group")??[]){const i=/^(\d{1,3})\s*\[([^\]]+)\]$/.exec(String(a.value??""));if(!i)continue;const o=n.slice(a.start,a.end),c=i[1].length;s.push(a),r.push(new N(a.start,a.start+c,{name:"episode",value:parseInt(i[1],10),inputString:n}));const l=o.indexOf("[");r.push(new N(a.start+l+1,a.end-1,{name:"release_group",value:i[2],inputString:n}))}return s.length||r.length?[s,r]:!1}};p(dr,"NumericPrefixedGroupRule"),dr.priority=-32;let Oa=dr;const Ce=class Ce extends y{constructor(e,t){super(),this.priority=O+1,this.valueFormatter=e,this.isPreviousMatch=t}when(e){const t=[],n=[],s=e.inputString??"",r=new RegExp(`[${z}]`,"g");for(const a of e.markers.named("path")){const{start:i,end:o}=a,c=p(g=>e.named(g,h=>h.start>=i&&h.end<=o)??[],"inPart");if(c("release_group").length)continue;const l=c("title").sort((g,h)=>g.start-h.start);if(l.length<2)continue;const u=l[l.length-1];if(xe(String(u.value??"").replace(r,"")))continue;const f=e.previous(u,g=>g.start>=i&&(!g.private||this.isPreviousMatch(g)),0);!f||!this.isPreviousMatch(f)||s.slice(f.end,u.start).replace(r,"")||(t.push(u),n.push(new N(u.start,u.end,{name:"release_group",value:this.valueFormatter(String(u.value??"")),inputString:s,tags:["scene"]})))}return t.length||n.length?[t,n]:!1}};p(Ce,"ReclaimTrailingSceneGroup"),Ce.priority=O+1,Ce.consequence=[b,$],Ce.properties={release_group:[null]};let Ia=Ce;const pr=class pr extends y{constructor(e){super(),this.consequence=[b,$],this.valueFormatter=e}when(e){if(e.named("release_group").length>0)return!1;const t=e.inputString??"",n=[],s=[];for(const r of e.markers.named("path")){const a=e.range(r.start,r.end,u=>!u.private&&u.name==="episode_title"&&u.value,-1);if(!a||e.range(a.end,r.end,u=>!u.private&&u.span[0]!==u.span[1],0))continue;const o=String(a.raw??a.value);if(/[\s.]/.test(o.trim())||t[a.start-1]!=="-")continue;const c=e.range(r.start,a.start,u=>!u.private,-1);if(!c||!["episode","absolute_episode"].includes(c.name??""))continue;const l=new N(a.start,a.end,{name:"release_group",inputString:t});l.formatter=this.valueFormatter,l.value&&(n.push(a),s.push(l))}return n.length||s.length?[n,s]:!1}};p(pr,"TrailingTokenAfterEpisodeAsReleaseGroup"),pr.dependency=["AnimeReleaseGroup"];let La=pr;function Ll(d){const e=new F;return e.stringDefaults({ignoreCase:!0}).regexDefaults({flags:"i",abbreviations:[X]}),e.defaults({name:"streaming_service",tags:["source-prefix"]}),te(e,d),e.rules(Ha,$a),e}p(Ll,"streamingService");const rt=class rt extends y{when(e,t){if(!A(t,"streaming_service"))return!1;const n=e.named("streaming_service")??[];for(const s of n)s.private=!0;return!1}};p(rt,"PrivatiseExcludedStreamingService"),rt.priority=127,rt.consequence=[];let $a=rt;const st=class st extends y{when(e){const t=[],n=e.named("streaming_service");process.env.DEBUG_SS&&console.log(`[VS.when] allServices count=${n.length}`);const s=e.inputString||"";for(const r of n){if((r.raw??"").length<=3){const m=s[r.end],v=s[r.start-1];if(m&&/[a-z0-9]/i.test(m)||v&&/[a-z0-9]/i.test(v)){t.push(r);continue}}const i=p(m=>!m.private&&m.tags?.includes("streaming_service.suffix"),"suffixPred"),o=p(m=>!m.private&&m.tags?.includes("streaming_service.prefix"),"prefixPred"),c=e.range(r.end,r.end+30,i),l=Array.isArray(c)?c:c?[c]:[],u=l.length>0?l.reduce((m,v)=>m.start<v.start?m:v):void 0,f=e.range(Math.max(0,r.start-30),r.start,o),g=Array.isArray(f)?f:f?[f]:[],h=g.length>0?g.reduce((m,v)=>m.end>v.end?m:v):void 0,x=r.initiator&&r.initiator.children.named("other").length>0;if(process.env.DEBUG_SS&&console.log(`[SS] service=${r.value} [${r.start},${r.end}) nextMatch=${u?.name}@${u?.start} prevMatch=${h?.name} sepsBefore=${se(r)} sepsAfter=${ae(r)}`),!x){const m=u?e.holes(r.end,u.start,{predicate:p(L=>!!String(L.value).replace(new RegExp(`[${z}]`,"g"),""),"predicate")}):null,v=h?e.holes(h.end,r.start,{predicate:p(L=>!!String(L.value).replace(new RegExp(`[${z}]`,"g"),""),"predicate")}):null,C=20,w=u&&u.start-r.end>C,k=h&&r.start-h.end>C,D=u?e.range(r.end,u.start,L=>L.name!=="streaming_service"&&!L.private&&L.name!=="other"):null,P=h?e.range(h.end,r.start,L=>L.name!=="streaming_service"&&!L.private&&L.name!=="other"):null,E=D&&D.length>0,H=P&&P.length>0;if((!u||w||E||m!==null&&m.length>0||!se(r))&&(!h||k||H||v!==null&&v.length>0||!ae(r))){process.env.DEBUG_SS&&console.log(` [VS.when] pushing to toRemove: ${r.value}`),t.push(r);continue}}r.value==="Comedy Central"&&t.push(...e.named("edition",m=>m.value==="Criterion"))}return process.env.DEBUG_SS&&console.log(`[VS.when] returning toRemove.length=${t.length}`),t}};p(st,"ValidateStreamingService"),st.priority=128,st.consequence=b;let Ha=st;function $l(d){const e=new F({disabled:p(t=>A(t,"other"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"other",validator:T}),te(e,d.other),zl(e),e.rules(Fa,Ua,Ba,qa,ja,Ga,Ka,Xa,Za,Ya,Ja,Qa,Ra,Wa,ti,ei,Ta,za,Va),e}p($l,"other");const Hl={poster:"Poster",fanart:"Fanart",banner:"Banner",thumb:"Thumbnail",thumbnail:"Thumbnail",landscape:"Landscape",cover:"Cover",clearart:"Clear Art",clearlogo:"Clear Logo",logo:"Logo",discart:"Disc Art"},fr=class fr extends y{constructor(){super(...arguments),this.consequence=[b,$]}when(e){const t=[],n=[];for(const s of e.markers.named("path")){if(!e.range(s.start,s.end,i=>i.name==="container"&&i.tags?.includes("image"),0))continue;const a=e.range(s.start,s.end,i=>["title","alternative_title","episode_title"].includes(i.name??""));for(const i of a){const o=String(i.value??"").trim().toLowerCase().replace(/[\s._-]+/g,""),c=Hl[o];c&&(t.push(i),n.push(new N(i.start,i.end,{name:"other",value:c,inputString:e.inputString})))}}return t.length?[t,n]:!1}};p(fr,"ImageArtKeywordToOther"),fr.priority=O;let Ta=fr;const Tl="(?P<credits_number>\\d+(?:(?![vV]\\d)[^\\W\\d_])?)?",Fl="(?:-?[vV](?P<version>\\d+))?",Ul=Tl+Fl;function Bl(d){const e=/^(\d+)(\w?)$/.exec(d);return e?String(parseInt(e[1],10))+e[2].toLowerCase():d}p(Bl,"formatCreditsNumber");function zl(d){const e=p((t,n,s)=>{d.regex("(?P<other>"+t+")"+Ul,{flags:s?"i":"",name:"other",children:!0,privateParent:!0,validateAll:!0,validator:{__parent__:T},formatter:{other:p(()=>n,"other"),credits_number:Bl,version:p(r=>parseInt(r,10),"version")},disabled:p(r=>A(r,"other"),"disabled")})},"add");e("NC-?OP|creditless-?op(?:ening)?","Opening Credits",!0),e("NC-?ED|creditless-?(?:ed|ending)","Ending Credits",!0),e("OPED|OP","Opening Credits",!1),e("ED","Ending Credits",!1)}p(zl,"openingEndingCredits");const at=class at extends y{constructor(){super(...arguments),this.priority=O,this.consequence=$}when(e,t){const n=[];for(const s of e.named("other",r=>r.value==="Opening Credits"||r.value==="Ending Credits")??[]){const r=(s.raw??"").toLowerCase().replace(/[\s._-]+/g,"");(r.startsWith("nc")||r.includes("creditless"))&&n.push(new N(s.start,s.end,{name:"other",value:"Creditless",inputString:e.inputString}))}return n.length?n:!1}};p(at,"AppendCreditless"),at.priority=O,at.properties={other:["Creditless"]};let Fa=at;const it=class it extends y{constructor(){super(...arguments),this.priority=O,this.consequence=$}when(e,t){const n=[];for(const s of e.named("other",r=>r.value==="Opening Credits")??[])(s.raw??"").toLowerCase().replace(/[\s._-]+/g,"")==="oped"&&n.push(new N(s.start,s.end,{name:"other",value:"Ending Credits",inputString:e.inputString}));return n.length?n:!1}};p(it,"AppendOpedEndingCredits"),it.priority=O,it.properties={other:["Ending Credits"]};let Ua=it;const Vl="stereo-vr-context",Rl=new Set(["Virtual Reality","3D"]),gr=class gr extends y{constructor(){super(...arguments),this.priority=64,this.consequence=b}when(e,t){const n=[],s=e.markers.named("path");for(const r of Array.isArray(s)?s:s?[s]:[]){const a=e.range(r.start,r.end,o=>o.name==="other"&&o.tags.includes(Vl));if(!a?.length)continue;if(e.range(r.start,r.end,o=>o.name==="other"&&Rl.has(String(o.value)))?.length>0)for(const o of a)n.push(...e.range(o.start,o.end,c=>c.name==="streaming_service")??[]);else n.push(...a)}return n.length?n:!1}};p(gr,"ValidateStereoVRContext"),gr.priority=64;let Ba=gr;const Fo="(?<![^\\W_])";function Wl(d,e){const t=I(e.completeMarkerWords),n=I(e.seasonWords),s=I(e.completeArticleWords),r="(?:-+(?:\\d+|"+I(e.seasonNumberSeparators,void 0,!0)+"))+-+";function a(i){const o=i.children;return!(!o.named("completeWordsBefore")&&!o.named("completeWordsAfter"))}p(a,"validateComplete"),d.regex(Fo+`(?P<completeArticle>${s}-)?(?P<completeWordsBefore>${n}-)?`+t+`(?P<completeWordsAfter>-${n})?`,{privateNames:["completeArticle","completeWordsBefore","completeWordsAfter"],value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:p(i=>T(i)&&a(i),"__parent__")}}),d.regex(n+r+"(?P<other>"+t+")",{children:!0,privateParent:!0,validateAll:!0,value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:T}}),d.regex(Fo+"(?P<completePrefix>"+I(e.completePrefixWords)+"-?)"+t,{privateNames:["completePrefix"],value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:T}})}p(Wl,"completeWords");const Me=class Me extends y{when(e,t){const n=e.named("other",c=>c.value==="Proper");if(!n||n.length===0)return;const s={};for(const c of n)s[Zo(c.raw)]=c;let r=0,a=null,i=null;for(const c of Object.values(s)){(!a||a>c.start)&&(a=c.start),(!i||i<c.end)&&(i=c.end);const l=c.children.named("proper_count",null,0);l?r+=parseInt(String(l.value),10):c.tags.includes("real")?r+=2:r+=1}const o=new N(a,i,{name:"proper_count"});return o.value=r,[o]}};p(Me,"ProperCountRule"),Me.priority=O,Me.consequence=$,Me.properties={proper_count:[null]};let za=Me;const Ee=class Ee extends y{when(e){const t=e.named("other",i=>i.value==="Fix").filter(i=>{const o=Zo(i.raw??"").toLowerCase();return o==="fix"||o==="fixed"});if(!t||t.length===0)return;const n=e.named("proper_count");if(n&&(!Array.isArray(n)||n.length>0))return;let s=null,r=null;for(const i of t)(s===null||i.start<s)&&(s=i.start),(r===null||i.end>r)&&(r=i.end);const a=new N(s,r,{name:"proper_count"});return a.value=-1,[a]}};p(Ee,"FixCountRule"),Ee.priority=O,Ee.consequence=$,Ee.properties={proper_count:[null]};let Va=Ee;const hr=class hr extends y{constructor(){super(...arguments),this.priority=64,this.consequence=b}when(e,t){const n=e.named("other",r=>r.tags?.includes("subtitle-flag"));if(!n?.length)return!1;const s=[];for(const r of n){const a=e.markers.atMatch(r,o=>o.name==="path",0);if(!a){s.push(r);continue}e.range(a.start,a.end,o=>o.name==="container"&&o.tags?.includes("subtitle"),0)||s.push(r)}return s.length?s:!1}};p(hr,"ValidateSubtitleFlag"),hr.priority=64;let Ra=hr;const mr=class mr extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[b,$]}when(e,t){const n=[],s=[];for(const r of e.markers.named("path")??[]){if(!e.range(r.start,r.end,c=>c.name==="container"&&c.tags?.includes("subtitle"),0))continue;const i=(e.range(r.start,r.end,c=>c.name==="subtitle_language"&&!c.private)??[]).slice().sort((c,l)=>c.start-l.start);if(i.length<2)continue;const o=i[i.length-1];String(o.raw??"").trim().toLowerCase()==="hi"&&(n.push(o),s.push(new N(o.start,o.end,{name:"other",value:"SDH",inputString:e.inputString})))}return n.length?[n,s]:!1}};p(mr,"HearingImpairedLanguageToSDH"),mr.priority=O;let Wa=mr;const ot=class ot extends y{when(e){return e.named("another")}};p(ot,"RenameAnotherToOther"),ot.priority=32,ot.consequence=new le("other");let qa=ot;const ct=class ct extends y{when(e){const t=[];for(const n of e.range(0,void 0,s=>s.tags.includes("has-neighbor"))){let s=e.previous(n,o=>!0,0),r=e.markers.previous(n,o=>o.name==="group",0);if(r&&(!s||r.end>s.end)&&(s=r),s&&!e.inputString.slice(s.end,n.start).replace(new RegExp(`[${z}]`,"g"),""))continue;let a=e.next(n,o=>!0,0),i=e.markers.next(n,o=>o.name==="group",0);i&&(!a||i.start<a.start)&&(a=i),!(a&&!e.inputString.slice(n.end,a.start).replace(new RegExp(`[${z}]`,"g"),""))&&t.push(n)}return t}};p(ct,"ValidateHasNeighbor"),ct.consequence=b,ct.priority=64;let ja=ct;const lt=class lt extends y{when(e){const t=[];for(const n of e.range(0,void 0,s=>s.tags.includes("has-neighbor-before"))){let s=e.previous(n,a=>!0,0),r=e.markers.previous(n,a=>a.name==="group",0);r&&(!s||r.end>s.end)&&(s=r),!(s&&!e.inputString.slice(s.end,n.start).replace(new RegExp(`[${z}]`,"g"),""))&&t.push(n)}return t}};p(lt,"ValidateHasNeighborBefore"),lt.consequence=b,lt.priority=64;let Ka=lt;const ut=class ut extends y{when(e){const t=[];for(const n of e.range(0,void 0,s=>s.tags.includes("has-neighbor-after"))){let s=e.next(n,a=>!0,0),r=e.markers.next(n,a=>a.name==="group",0);r&&(!s||r.start<s.start)&&(s=r),!(s&&!e.inputString.slice(n.end,s.start).replace(new RegExp(`[${z}]`,"g"),""))&&t.push(n)}return t}};p(ut,"ValidateHasNeighborAfter"),ut.consequence=b,ut.priority=64;let Ga=ut;const dt=class dt extends y{when(e){const t=[];for(const n of e.named("other",s=>s.tags.includes("other.validate.screener"))){const s=e.previous(n,r=>r.initiator?.name==="source",0);(!s||e.inputString.slice(s.end,n.start).replace(new RegExp(`[${z}]`,"g"),""))&&t.push(n)}return t}};p(dt,"ValidateScreenerRule"),dt.consequence=b,dt.priority=64;let Xa=dt;const pt=class pt extends y{when(e){const t=[];for(const n of e.named("other",s=>s.tags.includes("other.validate.mux")))e.previous(n,r=>r.initiator?.name==="source",0)||t.push(n);return t}};p(pt,"ValidateMuxRule"),pt.consequence=b,pt.priority=64;let Za=pt;const ft=class ft extends y{when(e){return[]}};p(ft,"ValidateHardcodedSubs"),ft.priority=32,ft.consequence=b;let Ya=ft;const gt=class gt extends y{when(e){const t=[];for(const n of e.named("other",s=>s.initiator?.name!=="source"&&(s.tags.includes("streaming_service.prefix")||s.tags.includes("streaming_service.suffix")))){let s=n.initiator;if(ae(s)){if(!se(s)){if(s.tags.includes("streaming_service.suffix")){const r=e.previous(s,a=>a.name==="streaming_service",0);if(r&&!e.holes(r.end,s.start,a=>String(a.value).replace(new RegExp(`[${z}]`,"g"),"")).length)continue}s.children&&t.push(...s.children),t.push(s)}}else{if(s.tags.includes("streaming_service.prefix")){const r=e.next(s,a=>a.name==="streaming_service",0);if(r&&!e.holes(s.end,r.start,a=>String(a.value).replace(new RegExp(`[${z}]`,"g"),"")).length)continue}s.children&&t.push(...s.children),t.push(s)}}return t}};p(gt,"ValidateStreamingServiceNeighbor"),gt.priority=32,gt.consequence=b;let Ja=gt;const ht=class ht extends y{when(e){const t=[];for(const n of e.markers.named("path"))for(const s of e.range(n.start,n.end,r=>r.name==="other"&&r.tags.includes("at-end")))(e.holes(s.end,n.end,r=>String(r.value).replace(new RegExp(`[${z}]`,"g"),"")).length||e.range(s.end,n.end,r=>!["other","container"].includes(r.name??"")).length)&&t.push(s);return t}};p(ht,"ValidateAtEnd"),ht.priority=32,ht.consequence=b;let Qa=ht;const mt=class mt extends y{when(e){const t=new Set(["Real","Cam","Convert"]),n=new Set(["screen_size","video_codec","audio_codec","video_profile","release_group"]),s=[];for(const r of e.range(0,e.inputString?.length??0)){if(r.name!=="other"&&r.name!=="source"||!t.has(r.raw??""))continue;const i=e.markers.atMatch(r,c=>c.name==="path",0)?.end??e.inputString?.length??r.end;(e.range(r.end,i,c=>!c.private&&n.has(c.name??""))??[]).length>0||s.push(r)}return s.length?s:!1}};p(mt,"RemoveTitleCaseAmbiguous"),mt.consequence=b,mt.priority=64;let ei=mt;const vt=class vt extends y{when(e){const t=[];for(const n of e.markers.named("path"))for(const s of e.range(n.start,n.end,r=>r.name==="other"&&r.tags.includes("real"))){const r=e.range(n.start,s.start);(!r||r.length===0)&&t.push(s)}return t}};p(vt,"ValidateReal"),vt.consequence=b,vt.priority=64;let ti=vt;function ql(d){const e=new F({disabled:p(t=>A(t,"size"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}),e.defaults({name:"size",validator:T}),e.regex("\\d+-?[mgt]b","\\d+\\.\\d+-?[mgt]b",{formatter:p(t=>ks.fromstring(t).toString(),"formatter"),tags:["release-group-prefix"]}),e}p(ql,"size");qc("guessit.rules.common.quantity:BitRate.fromstring",d=>Ds.fromstring(d).toString());function jl(d){const e=new F({disabled:p(t=>A(t,"audio_bit_rate")&&A(t,"video_bit_rate"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}),e.defaults({name:"audio_bit_rate",validator:T}),te(e,d.bit_rate),e.rules(ni),e}p(jl,"bitRate");const vr=class vr extends y{when(e,t){const n=[],s=[];if(A(t,"audio_bit_rate"))for(const r of e.named("audio_bit_rate"))r.private=!0;else{const r=A(t,"video_bit_rate");for(const a of e.named("audio_bit_rate")){const i=e.previous(a,u=>["source","screen_size","video_codec"].includes(u.name??""),0),o=e.inputString??"",c=p((u,f)=>o.slice(u,f).replace(new RegExp(`[${z}]`,"g"),"")==="","onlySepsBetween"),l=i?c(i.end,a.start):!1;if(i&&l){const f=String(a.value).toLowerCase(),g=/kbps$|kbits?$/.test(f),h=e.next(a,x=>x.name==="audio_codec",0);if(h&&c(a.end,h.start)){g||(r?s.push(a):n.push(a));continue}g||(r?s.push(a):n.push(a))}}}return n.length||s.length?[n,s]:!1}};p(vr,"BitRateTypeRule"),vr.consequence=[new le("video_bit_rate"),b];let ni=vr;function Kl(d){const e=new F({disabled:p(t=>A(t,"edition"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"edition",validator:T}),te(e,d.edition),e}p(Kl,"edition");function Gl(d){const e=new F({disabled:p(t=>A(t,"cd"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}),te(e,d),e}p(Gl,"cd");function Xl(d){const e=new F({disabled:p(t=>A(t,"bonus"),"disabled")});return e.regexDefaults({name:"bonus",flags:"i"}),te(e,d.bonus),e.rules(ri,si,ai),e}p(Xl,"bonus");const xr=class xr extends y{when(e){const t=e.inputString||"",n=e.named("bonus")?.filter(r=>!r.private)??[],s=[];for(const r of n){const a=e.markers.atMatch(r,l=>l.name==="path",0);if(!a)continue;const i=r.parent,o=i?i.start:r.start-1;[...t.slice(a.start,o)].every(l=>M.includes(l))&&(s.push(r),i&&s.push(i))}return s}then(e,t){for(const n of t)e.remove(n)}};p(xr,"BonusAtFilepartStartRule"),xr.priority=128;let ri=xr;const yr=class yr extends y{when(e){const t=e.named("bonus")?.filter(s=>!s.private)??[],n=[];for(const s of t){const r=e.markers.atMatch(s,o=>o.name==="path",0);if(!r)continue;const a=!!e.range(r.start,r.end,o=>o.name==="season"&&!o.private,0),i=!!e.range(r.start,r.end,o=>o.name==="episode"&&!o.private,0);a&&!i&&n.push(s)}return n}then(e,t){const n=t;for(const s of n)e.remove(s),s.name="episode",e.append(s)}};p(yr,"BonusToEpisodeRule"),yr.priority=64;let si=yr;const Zl=new Set(["source","video_codec","audio_codec","screen_size","container","release_group","language","country","other","streaming_service","edition","audio_channels","season","date"]),xt=class xt extends y{when(e){const t=e.named("bonus",v=>!v.private,0);if(!t)return;const n=e.markers.atMatch(t,v=>v.name==="path",0);if(!n)return;const s=e.range(t.end,n.end+1,v=>(v.name==="title"||v.name==="alternative_title"||v.name==="episode_title")&&!v.private,0);if(s&&s.value){const v=e.inputString||"",C=e.range(t.end,n.end+1,V=>V.name==="container"&&!V.private,0),w=C?C.start:n.end;let k=t.end;for(;k<s.start&&/[\s._\-]/.test(v[k]);)k++;let D=s.end;const P=e.range(s.end,w,V=>!V.private&&V.name==="year",0);if(P){const V=v.slice(s.end,P.start),Q=v.slice(P.end,w),pe=[...V].every(re=>/[\s._\-]/.test(re)),ye=[...Q].every(re=>/[\s._\-]/.test(re));pe&&ye&&(D=P.end)}const E=v.slice(k,D),H=B(E),L=[s],S=e.range(k,D,V=>!V.private&&V.name!=="bonus"&&V.name!=="container")||[];for(const V of S)L.includes(V)||L.push(V);const j=new N(k,D,{name:"bonus_title",value:H||B(String(s.value)),inputString:v});return{toRemove:L,toAppend:[j]}}const r=e.inputString||"",a=e.range(t.end,n.end+1,v=>v.name==="container"&&!v.private,0),i=a?a.start:n.end,o=e.range(t.end,i,v=>!v.private&&Zl.has(v.name??""))||[];o.sort((v,C)=>v.start-C.start);let c=i;o.length>0&&(c=o[0].start);let l=t.end;for(;l<c&&/[\s._\-]/.test(r[l]);)l++;let u=c;for(;u>l&&/[\s._\-]/.test(r[u-1]);)u--;if(l>=u)return;const f=r.slice(l,u),g=B(f);if(!g)return;const h=[],x=e.range(l,u,v=>!v.private&&v.name!=="bonus"&&v.name!=="container")||[];for(const v of x)h.push(v);const m=new N(l,u,{name:"bonus_title",value:g,inputString:r});return{toRemove:h,toAppend:[m]}}then(e,t){if(!t)return;if(t instanceof N){e.append(t);return}const{toRemove:n,toAppend:s}=t;for(const r of n)e.remove(r);for(const r of s)e.append(r)}};p(xt,"BonusTitleRule"),xt.dependency=["TitleFromPosition"],xt.properties={bonus_title:[null]};let ai=xt;function Yl(d){const e=new F({disabled:p(t=>A(t,"film"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"film",validator:T}),te(e,d.film),e.rules(ii,oi),e}p(Yl,"film");const _r=class _r extends y{constructor(){super(...arguments),this.consequence=b}when(e,t){const n=[],s=e.named("film",r=>!r.private)??[];for(const r of Array.isArray(s)?s:[s]){const a=e.markers.atMatch(r,o=>o.name==="path",0);if(!a)continue;const i=e.holes(a.start,r.start+1,{formatter:B,index:0});i&&i.value||(n.push(r),r.parent&&n.push(r.parent))}return n.length?n:!1}};p(_r,"LeadingFilmNumberRule"),_r.consequence=b;let ii=_r;const yt=class yt extends y{enabled(e){return!A(e,"film_title")}when(e){const t=e.named("film",n=>!n.private,0);if(t){const n=e.markers.atMatch(t,r=>r.name==="path",0);if(!n)return;const s=e.holes(n.start,t.start+1,{formatter:B,predicate:p(r=>!!r.value,"predicate"),index:0});if(s&&s.value)return s.name="film_title",s}}};p(yt,"FilmTitleRule"),yt.consequence=$,yt.properties={film_title:[null]};let oi=yt;function Jl(d){const e=new F({disabled:p(r=>A(r,"part"),"disabled")});e.regexDefaults({flags:"i",abbreviations:[X],validator:{__parent__:T}});const t=d.prefixes,n=`(?:\\d+|[ivxlcdm]+|${Cc})`;function s(r){return xe(r.raw)?!0:T(r)}return p(s,"validateRoman"),e.regex(`${I(t)}-?(?P<part>${n})`,{prefixes:t,validateAll:!0,privateParent:!0,children:!0,formatter:oe,validator:{part:ge(s,r=>0<r.value&&r.value<100)}}),e}p(Jl,"part");const Ql=0,Uo=1,eu=2,tu="[a-zA-Z0-9-]{20,}";function nu(d){const e=[],t=new RegExp(tu,"g");let n;for(;(n=t.exec(d))!==null;){const s=n[0];let r=0,a=0,i=0,o=null,c=Uo;for(const f of s){let g;"0123456789".includes(f)?g=Ql:/[a-zA-Z]/.test(f)?(g=Uo,f!==o&&a++,o=f,i++):g=eu,g!==c&&r++,c=g}const l=r/s.length,u=i>0?a/i:1;if(l>.4&&u>.4){if(/^[sS]\d+[eE]\d+/i.test(s))continue;e.push([n.index,n.index+s.length])}}return e}p(nu,"guessIdnumber");function ru(d){const e=new F({disabled:p(t=>A(t,"crc32"),"disabled")});return e.regexDefaults({flags:"i"}),e.defaults({validator:T}),e.regex("(?:[a-fA-F]|[0-9]){8}",{name:"crc32",conflictSolver:p((t,n)=>["episode","season"].includes(n.name??"")?n:"__default__","conflictSolver")}),e.regex("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",{name:"uuid",validator:void 0,conflictSolver:p((t,n)=>["episode","season","crc32"].includes(n.name??"")?n:"__default__","conflictSolver")}),e.functional(nu,{name:"uuid",conflictSolver:p((t,n)=>["episode","season","crc32"].includes(n.name??"")?n:"__default__","conflictSolver")}),e}p(ru,"crc");function su(d){const e=new F({disabled:p(t=>A(t,"imdb_id"),"disabled")});return e.regexDefaults({flags:"i"}),e.defaults({validator:T}),e.regex("(?:imdb(?:id)?[-=]?)?(?<imdb_id>tt\\d{7,8})",{name:"imdb_id",privateParent:!0,children:!0,formatter:p(t=>t.toLowerCase(),"formatter")}),e.regex("tmdb(?:id)?[-=]?(?<tmdb_id>\\d{1,9})",{name:"tmdb_id",privateParent:!0,children:!0,formatter:p(t=>parseInt(t,10),"formatter")}),e.regex("tvdb(?:id)?[-=]?(?<tvdb_id>\\d{1,9})",{name:"tvdb_id",privateParent:!0,children:!0,formatter:p(t=>parseInt(t,10),"formatter")}),e}p(su,"imdb");function au(d){const e=new F({disabled:p(t=>A(t,"volume"),"disabled")});return e.regexDefaults({flags:"i"}),e.regex("vol(?:\\d{1,3}|(?:ume)?[-. ]{1,2}\\d{1,3})(?:v\\d)?(?:[&+]\\d{1,3})?",{name:"volume",validator:T,formatter:p(t=>parseInt(String(t).replace(/^vol(?:ume)?[-. ]*/i,"").replace(/[v&+].*$/i,""),10),"formatter"),conflictSolver:p((t,n)=>n.name==="episode"||n.name==="season"?n:"__default__","conflictSolver")}),e}p(au,"volume");const iu={mkv:"video/x-matroska",mp4:"video/mp4",avi:"video/x-msvideo",mov:"video/quicktime",flv:"video/x-flv",wmv:"video/x-ms-wmv",webm:"video/webm",mp3:"audio/mpeg",flac:"audio/flac",aac:"audio/aac",ogg:"audio/ogg",wma:"audio/x-ms-wma",jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",svg:"image/svg+xml",zip:"application/zip",rar:"application/x-rar-compressed",pdf:"application/pdf",srt:"application/x-subrip",vtt:"text/vtt",nfo:"text/x-nfo",ts:"video/mp2t",mk3d:"video/x-matroska",iso:"application/x-iso9660-image",torrent:"application/x-bittorrent",nzb:"application/x-nzb","7z":"application/x-7z-compressed",ace:"application/x-ace-compressed",tar:"application/x-tar",tgz:"application/x-tar",cbr:"application/x-cbr",cbz:"application/x-cbr",cb7:"application/x-cbr",bmp:"image/bmp",webp:"image/webp"};function ou(d){const e=new F({disabled:p(t=>A(t,"mimetype"),"disabled")});return e.rules(ci),e}p(ou,"mimetype");const Ne=class Ne extends y{when(e,t){const s=(e.inputString??"").split(".").pop()?.toLowerCase()||"";return iu[s]||null}then(e,t,n){if(t&&typeof t=="string"){const s=e.inputString?.length??0,r=new N(s,s,{name:"mimetype",value:t,inputString:e.inputString});e.append(r)}}};p(Ne,"Mimetype"),Ne.priority=O,Ne.dependency=void 0,Ne.properties={mimetype:[null]};let ci=Ne;function cu(d,e){d.append(new N(d.inputString?.length??0,d.inputString?.length??0,{name:"type",value:e}))}p(cu,"addType");const Pe=class Pe extends y{constructor(){super(...arguments),this.priority=O,this.consequence=$}when(e,t){const n=t?.type;if(n)return n;const s=e.named("episode"),r=e.named("season"),a=e.named("absolute_episode"),i=e.named("episode_details"),o=e.named("year"),c=Array.isArray(s)?s:s?[s]:[],l=Array.isArray(r)?r:r?[r]:[],u=!!(o&&(!Array.isArray(o)||o.length>0)),f=!!(a&&(!Array.isArray(a)||a.length>0)),g=!!(i&&(!Array.isArray(i)||i.length>0));if(c.length>0||l.length>0||g||f){c.length>0&&c.every(U=>U.tags.includes("weak-episode")||U.tags.includes("weak-duplicate"));const D=Array.isArray(o)?o:o?[o]:[],P=D.length>0?D[0].start:1/0,E=l.every(U=>(U.tags.includes("weak-duplicate")||U.tags.includes("weak-episode"))&&U.start<P);l.length;let H=!1;const L=c.filter(U=>U.tags.includes("weak-episode")||U.tags.includes("weak-duplicate"));if(L.length>=3)H=!0;else if(L.length===2){const U=[...L].sort((ie,_e)=>ie.start-_e.start),K=(e.inputString??"").slice(U[0].end,U[1].start).replace(/[\s._]/g,"");(K==="-"||K==="~"||K.toLowerCase()==="to")&&(H=!0)}const S=c.length>0&&!H&&c.every(U=>U.tags.includes("weak-episode")||U.tags.includes("weak-duplicate")),j=l.every(U=>{if(!(U.tags.includes("weak-duplicate")||U.tags.includes("weak-episode")))return!1;if(U.start<P)return!0;const Z=e.inputString??"",K=U.initiator;if(K){const ie=K.start??U.start,_e=K.end??U.end,go=ie>0?Z[ie-1]:"",ho=_e<Z.length?Z[_e]:"";if(go&&/[a-zA-Z]/.test(go)||ho&&/[a-zA-Z]/.test(ho))return!0}return!1}),V=(l.length===0||j)&&!f&&!g,Q=e.named("release_group"),pe=Array.isArray(Q)?Q:Q?[Q]:[],ye=e.inputString??"",re=pe.some(U=>(U.start>0?ye[U.start-1]:"")==="[");if(S&&V&&u&&!re)return{type:"movie",removeWeak:!0};if(c.length===0&&l.length===0&&!f&&g&&u){const U=Array.isArray(i)?i:i?[i]:[],Z=Array.isArray(o)?o:o?[o]:[],K=Z.length>0?Z[0].start:1/0;if(U.some(_e=>_e.start>K))return"episode"}else return"episode"}const h=e.named("other",D=>D.value==="Complete"&&!!(D.children?.named?.("completeWordsBefore")?.length||D.children?.named?.("completeWordsAfter")?.length));if(h&&(!Array.isArray(h)||h.length>0))return"episode";const x=e.named("film");if(x&&(!Array.isArray(x)||x.length>0))return"movie";const m=e.named("date");if(m&&(!Array.isArray(m)||m.length>0)&&(!o||Array.isArray(o)&&o.length===0))return"episode";const v=e.named("bonus");if(v&&(!Array.isArray(v)||v.length>0)&&(!o||Array.isArray(o)&&o.length===0))return"episode";const C=e.named("crc32"),w=e.named("release_group",D=>D.tags.includes("anime"));if(C&&(!Array.isArray(C)||C.length>0)&&w&&(!Array.isArray(w)||w.length>0))return"episode";const k=e.named("other",D=>D.value==="Complete");return k&&(!Array.isArray(k)||k.length>0)&&(!o||Array.isArray(o)&&o.length===0)?"episode":"movie"}then(e,t,n){if(!t)return;let s,r=!1;if(typeof t=="string")s=t;else if(typeof t=="object"&&t!==null&&"type"in t){const a=t;s=a.type,r=!!a.removeWeak}else return;if(r){const a=[];for(const i of["episode","season"]){const o=e.named(i),c=Array.isArray(o)?o:o?[o]:[];for(const l of c)(l.tags.includes("weak-episode")||l.tags.includes("weak-duplicate"))&&a.push(l)}for(const i of a)e.remove(i)}cu(e,s)}};p(Pe,"TypeProcessor"),Pe.priority=O,Pe.dependency=void 0,Pe.properties={type:["episode","movie"]};let li=Pe;function lu(d){const e=new F({disabled:p(t=>A(t,"type"),"disabled")});return e.rules(li),e}p(lu,"type_");const nc=new Set(["language","subtitle_language"]);function Bo(d){if(!nc.has(d.name??""))return!1;const e=d.value;return e==="und"?!0:e&&typeof e=="object"&&"alpha3"in e?e.alpha3==="und":!1}p(Bo,"isUndeterminedLang");const br=class br extends ee{when(e,t){const n=[],s=[];for(const r of e.markers.named("group")){for(const a of e.starting(r.start+1))n.push(a);for(const a of e.ending(r.end-1))s.push(a)}return n.length>0||s.length>0?[n,s]:!1}then(e,t,n){const[s,r]=t;for(const a of s){const i=a.rawStart;e.remove(a),a.start-=1,a.rawStart=i,e.append(a)}for(const a of r){const i=a.rawEnd;e.remove(a),a.end+=1,a.rawEnd=i,e.append(a)}}};p(br,"EnlargeGroupMatches"),br.priority=Tr;let ui=br;function uu(d,e){return d===e||zo(d)&&!zo(e)||!d.toUpperCase().startsWith(d)&&e===e.toUpperCase()||!d.toUpperCase().startsWith(d)&&d[0]===d[0].toUpperCase()&&e[0]!==e[0].toUpperCase()||Vo(d)>Vo(e)?d:e}p(uu,"preferredString");function zo(d){return d.split(" ").every(e=>e.length===0||e[0]===e[0].toUpperCase())}p(zo,"isTitleCase");function Vo(d){let e=0;for(const t of _i(d))t.value[0]===t.value[0].toUpperCase()&&t.value[0]!==t.value[0].toLowerCase()&&e++;return e}p(Vo,"countTitleWords");const _t=class _t extends y{when(e,t){const n=[];for(const s of Nt(e.markers.named("path"),e)){const r=e.holes(s.start,s.end,{formatter:B});for(const a of e.names){const i=[...r];for(const o of[...i])for(const c of e.named(a))if(typeof c.value=="string"&&o.value&&typeof o.value=="string"&&o.value.toLowerCase()===c.value.toLowerCase()){if(c.tags.includes("equivalent-ignore"))continue;const l=uu(o.value,c.value);o.value!==l&&(o.value=l),c.value!==l&&(c.value=l),o.name=a,o.tags=["equivalent"],n.push(o);const u=i.indexOf(o);u>-1&&i.splice(u,1)}}}return n}};p(_t,"EquivalentHoles"),_t.priority=O,_t.consequence=$;let di=_t;const bt=class bt extends y{constructor(e,t){super(),this.sortFunction=e??Nt,this.predicate=t??null}when(e,t){const n=this.sortFunction(e.markers.named("path"),e),s=new Set,r=new Map,a=[];for(const i of n){const o=this.predicate?e.range(i.start,i.end,this.predicate):e.range(i.start,i.end),c=new Set;for(const l of o){const u=l.name??"";if(c.add(u),s.has(u)){const f=r.get(u)??[];if(!f.includes(l.value)){if(u==="episode_title"&&e.range(i.start,i.end,h=>!h.private&&(h.tags?.includes("SxxExx")??!1),0)){const h=e.named(u).filter(x=>x.start<i.start||x.end>i.end);a.push(...h),f.length=0,f.push(l.value),r.set(u,f);continue}if(!Bo(l)&&nc.has(u)&&f.every(h=>h==="und"||h&&typeof h=="object"&&"alpha3"in h&&h.alpha3==="und")){const h=a.length>0?[]:e.named(u).filter(x=>Bo(x));a.push(...h),f.length=0,f.push(l.value),r.set(u,f);continue}a.push(l)}}else{const f=r.get(u)??[];f.includes(l.value)||(f.push(l.value),r.set(u,f))}}for(const l of c)s.add(l)}return a}};p(bt,"RemoveAmbiguous"),bt.priority=O,bt.consequence=b;let Kt=bt;const rc=p(d=>(d.name==="season"||d.name==="episode")&&d.tags.includes("SxxExx"),"sxxExxWeightPredicate"),pi=p(d=>Array.isArray(d)?d:d?[d]:[],"asArray"),du=p((d,e)=>new Set(pi(d.range(e.start,e.end,rc)).map(t=>t.name)).size,"sxxExxWeight");function pu(d,e){const t=[...d],n=new Map;let s=0,r=!1;return t.forEach((a,i)=>{const o=du(e,a),c=r&&pi(e.range(s,a.end,l=>l.tags.includes("companion-file"))).length>0;n.set(a,[-o,c?1:0,-i]),o&&(s=a.end,r=new Set(pi(e.range(a.start,a.end,u=>u.name==="episode")).map(u=>u.value)).size<=1)}),t.sort((a,i)=>{const o=n.get(a),c=n.get(i);return o[0]-c[0]||o[1]-c[1]||o[2]-c[2]})}p(pu,"seasonEpisodeFilepartsSorted");const co=class co extends Kt{constructor(e){super((t,n)=>pu(t,n),t=>t.name===e)}when(e,t){return e.toArray().some(rc)?super.when(e,t):[]}};p(co,"RemoveLessSpecificSeasonEpisode");let Gt=co;const lo=class lo extends Gt{constructor(){super("season")}};p(lo,"RemoveLessSpecificSeason");let fi=lo;const uo=class uo extends Gt{constructor(){super("episode")}};p(uo,"RemoveLessSpecificEpisode");let gi=uo;const wt=class wt extends y{when(e,t){const n=[];if(e.named("year").length===0){for(const s of e.named("season"))if(typeof s.value=="number"&&J(s.value)){const r=s.clone();r.name="year",n.push(r)}}return n}};p(wt,"SeasonYear"),wt.priority=O,wt.consequence=$;let hi=wt;const St=class St extends y{when(e,t){const n=[],s=e.named("episode").filter(r=>!r.tags.includes("weak-episode")&&!r.tags.includes("weak-duplicate"));if(e.named("season").length===0&&s.length>0)for(const r of e.named("year")){const a=r.clone();a.name="season",n.push(a)}return n}};p(St,"YearSeason"),St.priority=O,St.consequence=$;let mi=St;const wr=class wr extends y{when(e,t){return!1}};p(wr,"Processors"),wr.priority=O;let vi=wr;const Sr=class Sr extends ee{when(e,t){return e}then(e,t,n){for(const s of e){const r=s.span;for(let a=0;a<r[1]-r[0];a++){const i=s.raw;if(i&&Be.includes(i[0])&&(i.length<3||!Be.includes(i[2])))s.rawStart=s.rawStart+1;else break}for(let a=r[1]-r[0]-1;a>=0;a--){const i=s.raw;if(i&&Be.includes(i[i.length-1])&&(i.length<3||!Be.includes(i[i.length-3])))s.rawEnd=s.rawEnd-1;else break}}}};p(Sr,"StripSeparators"),Sr.priority=O;let xi=Sr;const Ar=class Ar extends ee{when(e){const t=[];for(const n of e)(n.value===null||n.value===void 0||typeof n.value=="number"&&isNaN(n.value)||n.value==="")&&t.push(n);return t}then(e,t){const n=t;for(const s of n)e.remove(s)}};p(Ar,"RemoveInvalidMatches"),Ar.priority=O;let yi=Ar;function fu(d){return new F().rules(ui,di,fi,gi,Kt,hi,mi,vi,xi,yi)}p(fu,"processors");function sc(d){function e(r){return d[r]??{}}p(e,"cfg");const t=new F,n=new Set(d.common_words??[]);t.rebulk(Ac(e("path"))),t.rebulk(kc(e("groups")??{starting:"([{",ending:")]}"})),t.rebulk(Fc(e("episodes"))),t.rebulk(Vc(e("container"))),t.rebulk(Rc(e("source"))),t.rebulk(Wc(e("video_codec"))),t.rebulk(Qc(e("audio_codec"))),t.rebulk(nl(e("screen_size"))),t.rebulk(sl(e("website"))),t.rebulk(fl(e("date"))),t.rebulk(vl(e("title"))),t.rebulk(yl(e("episode_title"))),t.rebulk(Nl(e("language"),n)),t.rebulk(Ol(e("country"),n)),t.rebulk(Il(e("release_group"))),t.rebulk(Ll(e("streaming_service")));const s=$l(e("other"));return e("episodes"),Wl(s,{completeMarkerWords:["Complete","Int[ée]grale"],seasonWords:["seasons?","mini-?series?","series?"],completeArticleWords:["The"],completePrefixWords:["L['’]?","Coffret"],seasonNumberSeparators:["&","and"]}),t.rebulk(s),t.rebulk(ql(e("size"))),t.rebulk(jl(e("bit_rate"))),t.rebulk(Kl(e("edition"))),t.rebulk(Gl(e("cd"))),t.rebulk(Xl(e("bonus"))),t.rebulk(Yl(e("film"))),t.rebulk(Jl(e("part"))),t.rebulk(ru(e("crc"))),t.rebulk(su(e("imdb"))),t.rebulk(au(e("volume"))),t.rebulk(fu(e("processors"))),t.rebulk(ou(e("mimetype"))),t.rebulk(lu(e("type"))),t.customizeProperties=p(function(a){const i=a.count;return delete a.count,a.season_count=i,a.episode_count=i,a},"customizeProperties"),t}p(sc,"rebulkBuilder");const gu=["OSS 117","This is Us"],hu=["au","gb","us"],mu=["ar","as","bg","bn","bs","ca","cs","da","de","el","en","es","et","eu","fa","fi","fr","gl","gu","he","hi","hr","hu","id","is","it","ja","km","kn","ko","lo","lt","lv","ml","mn","mr","ms","mul","my","nl","no","pa","pl","pt","ro","ru","sk","sl","sq","sr","sv","ta","te","th","tr","uk","und","ur","vi","zh"],vu={common_words:["ar","as","bs","ca","cat","da","de","el","et","fa","he","hr","id","ind","is","it","kan","kn","lo","lt","mr","ms","my","no","por","rum","scr","se","st","sub","vi"],groups:{starting:"([{【「(",ending:")]}】」)"},audio_codec:{audio_codec:{MP3:{string:["MP3","LAME"],regex:["LAME(?:\\d)+-?(?:\\d)+"]},MP2:"MP2","Dolby Digital":{string:["Dolby","DolbyDigital"],regex:["Dolby-Digital","DD","AC-?3D?","DolbyD"]},"Dolby Atmos":{string:["Atmos"],regex:["Dolby-?Atmos"]},AAC:"AAC","Dolby Digital Plus":{string:["DDP","DD+"],regex:["E-?AC-?3"]},FLAC:"Flac",DTS:"DTS","DTS-HD":{regex:["DTS-?HD","DTS(?=-?MA)","DTS-?MA"],conflict_solver:"lambda match, other: other if other.name == 'audio_codec' else '__default__'"},"DTS:X":{string:["DTS:X","DTS-X","DTSX"]},"Dolby TrueHD":{regex:["True-?HD"]},Opus:{string:"Opus",tags:"title-word"},Vorbis:"Vorbis",PCM:"PCM",LPCM:"LPCM"},audio_channels:{"1.0":["1ch","mono",{regex:"(1[\\W_]0(?:ch)?)(?=[^\\d]|$)",tags:"title-word"}],"2.0":["2ch","stereo",{regex:"(2[\\W_]0(?:ch)?)(?=[^\\d]|$)",children:!0,tags:"title-word"},{string:"20",validator:"import:seps_after",tags:"weak-audio_channels"}],"5.1":["5ch","6ch",{regex:"(5[\\W_][01](?:ch)?)(?=[^\\d]|$)",children:!0},{regex:"(6[\\W_]0(?:ch)?)(?=[^\\d]|$)",children:!0},{regex:"5[01]",validator:"import:seps_after",tags:"weak-audio_channels"}],"7.1":["7ch","8ch",{regex:"(7[\\W_][01](?:ch)?)(?=[^\\d]|$)",children:!0},{regex:"7[01]",validator:"import:seps_after",tags:"weak-audio_channels"}]},audio_profile:{"Master Audio":{string:"MA",tags:["audio_profile.rule","DTS-HD"]},"High Resolution Audio":{string:["HR","HRA"],tags:["audio_profile.rule","DTS-HD"]},"Extended Surround":{string:"ES",tags:["audio_profile.rule","DTS"]},"High Efficiency":{string:"HE",tags:["audio_profile.rule","AAC"]},"Low Complexity":{string:"LC",tags:["audio_profile.rule","AAC"]},"High Quality":{string:"HQ",tags:["audio_profile.rule","Dolby Digital"]},EX:{string:"EX",tags:["audio_profile.rule","Dolby Digital"]}}},bit_rate:{bit_rate:{_:{regex:["\\d+-?[kmg]b(ps|its?)","\\d+\\.\\d+-?[kmg]b(ps|its?)"],conflict_solver:"lambda match, other: match if other.name == 'audio_channels' and 'weak-audio_channels' not in other.tags else other",formatter:"import:guessit.rules.common.quantity:BitRate.fromstring",tags:["release-group-prefix"]}}},bonus:{bonus:{_:{regex:"x(\\d+)",private_parent:!0,children:!0,formatter:"eval:int",validator:{__parent__:"import:seps_surround"},validate_all:!0,conflict_solver:"lambda match, conflicting: match if conflicting.name in ('video_codec', 'episode') and 'weak-episode' not in conflicting.tags else '__default__'"}}},cd:{_cd_of_cd_count:{regex:"(?<!\\d)(?<![^\\W\\d_])cd-?(?P<cd>\\d+)(?:-?of-?(?P<cd_count>\\d+))?",validator:{cd:"lambda match: 0 < match.value < 100",cd_count:"lambda match: 0 < match.value < 100"},formatter:{cd:"eval:int",cd_count:"eval:int"},children:!0,private_parent:!0,properties:{cd:[null],cd_count:[null]}},_cd_count:{regex:"(?P<cd_count>\\d+)-?cds?",validator:{cd:"lambda match: 0 < match.value < 100",cd_count:"lambda match: 0 < match.value < 100"},formatter:{cd_count:"eval:int"},children:!0,private_parent:!0,properties:{cd:[null],cd_count:[null]}}},container:{subtitles:["srt","idx","sub","ssa","ass","vtt"],info:["nfo","strm","txt","url"],videos:["3g2","3gp","3gp2","asf","avi","divx","flv","iso","m4v","mk2","mk3d","mka","mkv","mov","mp4","mp4a","mpeg","mpg","ogg","ogm","ogv","qt","ra","ram","rm","ts","m2ts","vob","wav","webm","wma","wmv"],torrent:["torrent"],nzb:["nzb"],archives:["rar","zip","7z","tar","gz","bz2","tgz","ace","arj","cbr","cbz","cb7"],images:["jpg","jpeg","png","gif","bmp","tbn","webp"]},country:{synonyms:{ES:["españa"],GB:["UK"],BR:["brazilian","bra"],CA:["québec","quebec","qc"],MX:["Latinoamérica","latin america"]}},edition:{edition:{Collector:{string:["collector"],regex:["collector'?s?-edition","edition-collector"]},Special:[{regex:["special-edition","edition-special"],conflict_solver:"lambda match, other: other if other.name == 'episode_details' and other.value == 'Special' else '__default__'"},{string:"se",tags:"has-neighbor"}],"Director's Definitive Cut":"ddc",Criterion:{string:["CC","Criterion"],regex:["criterion-edition","edition-criterion"]},Deluxe:{string:["deluxe"],regex:["deluxe-edition","edition-deluxe"]},Limited:{string:["limited"],regex:["limited-edition"],tags:["has-neighbor","release-group-prefix"]},Theatrical:{string:["theatrical"],regex:["theatrical-cut","theatrical-edition"]},"Director's Cut":{string:["DC"],regex:["director'?s?-cut","director'?s?-cut-edition","edition-director'?s?-cut"]},"Final Cut":{regex:["final-cut","final-cut-edition","edition-final-cut"]},"Ultimate Cut":{regex:["ultimate-cut"]},"Assembly Cut":{regex:["assembly-cut"]},"International Cut":{regex:["international-cut"]},Redux:{string:["Redux"],tags:["has-neighbor","release-group-prefix"]},Anniversary:{regex:["(?:\\d{1,3}(?:st|nd|rd|th)-)?anniversary-edition"]},Extended:{string:["extended"],regex:["extended-?cut","extended-?version"],tags:["has-neighbor","release-group-prefix"]},"Alternative Cut":{regex:["alternat(e|ive)(?:-?Cut)?"],tags:["has-neighbor","release-group-prefix"]},Remastered:[{regex:"(?:4k.)?remaster(?:ed)?",tags:["release-group-prefix"]}],Restored:[{regex:"(?:4k.)?restore(?:d)?",tags:["release-group-prefix"]}],Uncensored:{string:"Uncensored",tags:["has-neighbor","release-group-prefix"]},Uncut:{string:"Uncut",tags:["has-neighbor","release-group-prefix"]},Unrated:{string:"Unrated",tags:["has-neighbor","release-group-prefix"]},Festival:{string:"Festival",tags:["has-neighbor-before","has-neighbor-after"]},IMAX:{string:["imax"],regex:["imax-edition"]},Fan:{regex:["fan-edit(?:ion)?","fan-collection"]},Ultimate:{regex:["ultimate-edition"]},_Ultimate_Collector:{regex:["ultimate-collector'?s?-edition"],value:["Ultimate","Collector"]},_Ultimate_Fan:{regex:["ultimate-fan-edit(?:ion)?","ultimate-fan-collection"],value:["Ultimate","Fan"]}}},episodes:{season_max_range:100,episode_max_range:100,max_range_gap:1,season_markers:["s","sn"],season_ep_markers:["x","×"],disc_markers:["d"],episode_markers:["xe","ex","ep","e","x","×"],range_separators:["-","~","to","a"],discrete_separators:["+","&","and","et"],season_words:["season","saison","seizoen","seasons","saisons","tem","temp",{value:"temporada",numfirst:!0},{value:"temporadas",numfirst:!0},"stagione",{value:"сезон",numfirst:!0},{value:"sezon",numfirst:!0},{value:"staffel",numfirst:!0},"sezonul","säsong","sesong","sæson",{value:"évad",numfirst:!0}],episode_words:["episode","episodes","épisode","épisodes","eps","ep","episodio","episodios","capitulo","capitulos",{value:"серия",numfirst:!0},{value:"серии",numfirst:!0},{value:"эпизод",numfirst:!0},{value:"seria",numfirst:!0},{value:"serii",numfirst:!0},{value:"serija",numfirst:!0},{value:"bölüm",numfirst:!0},{value:"bolum",numfirst:!0},"aflevering","afl","folge","odcinek","episodul","avsnitt",{value:"rész",numfirst:!0}],of_words:["of","sur","de","di","von","van","din","из"],all_words:["All"],ordinal_suffix:"(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?"},film:{film:{_f:{regex:"f(\\d{1,2})",name:"film",validate_all:!0,validator:{__parent__:"import:seps_surround"},private_parent:!0,children:!0,formatter:"eval:int"}}},language:{synonyms:{ell:["gr","greek"],spa:["esp","español","espanol"],fra:["français","vf","vff","vfi","vfq"],swe:["se"],por_BR:["po","pb","pob","ptbr","br","brazilian"],deu_CH:["swissgerman","swiss german"],nld_BE:["flemish"],cat:["català","castellano","espanol castellano","español castellano"],ces:["cz"],ukr:["ua"],zho:["cn"],jpn:["jp"],hrv:["scr"],mul:["multi","multiple","dl"]},subtitle_affixes:["sub","subs","subtitle","subtitles","esub","esubs","subbed","custom subbed","custom subs","custom sub","customsubbed","customsubs","customsub","soft subtitles","soft subs"],subtitle_prefixes:["st","vost","subforced","fansub","hardsub","legenda","legendas","legendado","subtitulado","soft"],subtitle_suffixes:["subforced","fansub","hardsub"],language_affixes:["dublado","dubbed","dub"],language_prefixes:["true"],language_suffixes:["audio"],weak_affixes:["v","audio","true","st"]},other:{other:{"Audio Fixed":{regex:["Audio-?Fix","Audio-?Fixed"]},"Sync Fixed":{regex:["Sync-?Fix","Sync-?Fixed"]},"Dual Audio":{string:["Dual"],regex:["Dual-?Audio"]},Widescreen:{string:["ws"],regex:["wide-?screen"]},Reencoded:{regex:["Re-?Enc(?:oded)?"]},_repack_with_count:{regex:["Repack(?P<proper_count>\\d*)","Rerip(?P<proper_count>\\d*)"],value:{other:"Proper"},tags:["streaming_service.prefix","streaming_service.suffix"]},Proper:[{string:"Proper",tags:["has-neighbor","streaming_service.prefix","streaming_service.suffix"]},{regex:["Real-Proper","Real-Repack","Real-Rerip"],tags:["streaming_service.prefix","streaming_service.suffix","real"]},{string:"Real",tags:["has-neighbor","streaming_service.prefix","streaming_service.suffix","real"]}],Fix:[{string:["Fix","Fixed"],tags:["has-neighbor-before","has-neighbor-after","streaming_service.prefix","streaming_service.suffix"]},{string:["Dirfix","Nfofix","Prooffix"],tags:["streaming_service.prefix","streaming_service.suffix"]},{regex:["(?:Proof-?)?Sample-?Fix"],tags:["streaming_service.prefix","streaming_service.suffix"]}],"Fan Subtitled":{string:"Fansub",tags:"has-neighbor"},"Fast Subtitled":{string:"Fastsub",tags:"has-neighbor"},"Region 5":"R5","Region C":"RC",Preair:{regex:"Pre-?Air"},"PS Vita":[{regex:"(?:PS-?)Vita"},{string:"Vita",tags:"has-neighbor"}],_HdRip:{value:{other:"HD",another:"Rip"},regex:["(HD)(?P<another>Rip)"],private_parent:!0,children:!0,validator:{__parent__:"import:seps_surround"},validate_all:!0},Screener:["Screener",{regex:"Scr(?:eener)?",validator:null,tags:["other.validate.screener","source-prefix","source-suffix"]}],Remux:"Remux",Hybrid:"Hybrid",PAL:"PAL",SECAM:"SECAM",NTSC:"NTSC",XXX:"XXX","2in1":"2in1","3D":{string:"3D",tags:"has-neighbor"},"Virtual Reality":{string:["VR","EAC360"],regex:["VR180","VR360","VR-180","VR-360"],tags:"has-neighbor"},"High Quality":{string:"HQ",tags:"uhdbluray-neighbor"},"High Resolution":"HR","Line Dubbed":"LD","Mic Dubbed":{string:"MD",tags:"title-word"},"Micro HD":{string:["mHD","HDLight"],regex:["micro-?hd","hd-?lite"]},"Low Definition":"LDTV","High Frame Rate":"HFR","Variable Frame Rate":"VFR",HD:{string:"HD",validator:null,tags:["streaming_service.prefix","streaming_service.suffix"]},"Full HD":{string:["FHD"],regex:["Full-?HD"],validator:null,tags:["streaming_service.prefix","streaming_service.suffix"]},"Ultra HD":{string:["UHD"],regex:["Ultra-?(?:HD)?"],validator:null,tags:["streaming_service.prefix","streaming_service.suffix"]},Upscaled:{regex:"Upscaled?"},Complete:{string:["Complet","Complete"],tags:["has-neighbor","release-group-prefix"]},Classic:{string:"Classic",tags:["has-neighbor","release-group-prefix"]},Bonus:{string:"Bonus",tags:["has-neighbor","release-group-prefix"]},Trailer:{string:"Trailer",tags:["has-neighbor","release-group-prefix"]},Retail:{string:"Retail",tags:["has-neighbor","release-group-prefix"]},Colorized:{string:"Colorized",tags:["has-neighbor","release-group-prefix"]},Internal:{string:"Internal",tags:["has-neighbor","release-group-prefix"]},"Line Audio":{string:"LiNE",tags:["has-neighbor-before","has-neighbor-after","release-group-prefix"]},"Read NFO":{regex:"Read-?NFO"},Converted:{string:"CONVERT",tags:"has-neighbor"},Documentary:{string:["DOCU","DOKU"],tags:"has-neighbor"},"Open Matte":{regex:"(?:OM|Open-?Matte)",tags:"has-neighbor"},"Straight to Video":{string:"STV",tags:"has-neighbor"},"Original Aspect Ratio":{string:"OAR",tags:"has-neighbor"},"East Coast Feed":{regex:"(?:Live-)?(?:Episode-)?East-?(?:Coast-)?Feed"},"West Coast Feed":{regex:"(?:Live-)?(?:Episode-)?West-?(?:Coast-)?Feed"},"Original Video":{string:["VO","OV"],tags:"has-neighbor"},"Original Animated Video":{string:["Ova","Oav"],tags:"title-word"},"Original Net Animation":"Ona","Original Animation DVD":"Oad",Mux:{string:"Mux",validator:"import:seps_after",tags:["other.validate.mux","video-codec-prefix","source-suffix"]},"Hardcoded Subtitles":["HC","vost"],"Standard Dynamic Range":{string:"SDR",tags:"uhdbluray-neighbor"},"HDR10+":{regex:"HDR-?10-?(?:\\+|Plus|P)",tags:"uhdbluray-neighbor"},HDR10:{regex:"HDR(?:10)?",tags:"uhdbluray-neighbor"},HLG:{regex:"HLG",tags:"uhdbluray-neighbor"},SDH:{string:"SDH",tags:["at-end","not-a-release-group","subtitle-flag"]},Forced:{string:"forced",tags:["at-end","not-a-release-group","subtitle-flag"]},"Closed Caption":{regex:"CC",tags:["at-end","not-a-release-group","subtitle-flag"]},"Dolby Vision":{regex:"(?:Dolby-?Vision|DoVi|DV)",tags:"uhdbluray-neighbor"},"BT.2020":{regex:"BT-?2020",tags:"uhdbluray-neighbor"},Sample:{string:"Sample",tags:["at-end","not-a-release-group","companion-file"]},Extras:[{string:"Extras",tags:"has-neighbor"},{regex:"Digital-?Extras?"}],Proof:{string:"Proof",tags:["at-end","not-a-release-group","companion-file"]},Obfuscated:{string:["Obfuscated","Scrambled"],tags:["at-end","not-a-release-group"]},Repost:{string:["xpost","postbot","asrequested"],tags:"not-a-release-group"},_complete_words:{callable:"import:guessit.rules.properties.other:complete_words",season_words:["seasons?","series?"],complete_article_words:["The"]},"Side By Side":{string:["SBS","LR"],tags:["has-neighbor","stereo-vr-context"]},"Over Under":{string:["TB","OU"],tags:["has-neighbor","stereo-vr-context"]},"Half Side By Side":{string:["HSBS"],regex:["h-?sbs","half-?sbs"],tags:"has-neighbor"},"Half Over Under":{string:["HOU","HTAB"],regex:["h-?ou","half-?ou","half-?tab"],tags:"has-neighbor"}}},part:{prefixes:["pt","part"]},release_group:{forbidden_names:["bonus","by","for","par","pour","rip"],ignored_seps:"[]{}()"},screen_size:{frame_rates:["23\\.976","24(?:\\.0{1,3})?","25(?:\\.0{1,3})?","29\\.970","30(?:\\.0{1,3})?","48(?:\\.0{1,3})?","50(?:\\.0{1,3})?","60(?:\\.0{1,3})?","120(?:\\.0{1,3})?"],min_ar:1.333,max_ar:1.898,interlaced:["360","480","540","576","900","1080"],progressive:["360","480","540","576","900","1080","368","720","1440","2160","4320"]},source:{rip_prefix:"(?P<other>Rip)-?",rip_suffix:"-?(?P<other>Rip)"},website:{safe_tlds:["com","net","org"],safe_subdomains:["www"],safe_prefixes:["co","com","net","org"],prefixes:["from"]},streaming_service:{"9Now":"9NOW","A&E":["AE","A&E"],ABC:"AMBC","ABC Australia":"AUBC","Al Jazeera English":"AJAZ",AMC:"AMC","Amazon Prime":["AMZN","AMZN-CBR","Amazon","re:Amazon-?Prime"],"Adult Swim":["AS","re:Adult-?Swim"],"America's Test Kitchen":"ATK","Animal Planet":"ANPL",AnimeLab:"ANLB","Anime Digital Network":"ADN",AOL:"AOL",AppleTV:["ATVP","ATV+","APTV"],ARD:"ARD","BBC iPlayer":["iP","re:BBC-?iPlayer"],Binge:"BNGE",Blackpills:"BKPL",BluTV:"BLU",Boomerang:"BOOM","Disney+":"DSNP",BravoTV:"BRAV","Canal+":"CNLP","Cartoon Network":"CN",CBC:"CBC",CBS:"CBS",CNBC:"CNBC","Comedy Central":["CC","re:Comedy-?Central"],"Channel 4":["ALL4","4OD"],"Channel 5":"MY5",CHRGD:"CHGD",Cinemax:"CMAX","Country Music Television":"CMT","Comedians in Cars Getting Coffee":"CCGC",Crave:"CRAV","Crunchy Roll":["CR","re:Crunchy-?Roll"],Crackle:"CRKL",CSpan:"CSPN",CTV:"CTV",CuriosityStream:"CUR",CWSeed:"CWS",Daisuki:"DSKI","DC Universe":"DCU","Deadhouse Films":"DHF",DramaFever:["DF","DramaFever"],"Digiturk Diledigin Yerde":"DDY",Discovery:["DISC","Discovery"],"Discovery Plus":"DSCP",Disney:["DSNY","Disney"],"DIY Network":"DIY","Doc Club":"DOCC",DPlay:"DPLY","E!":"ETV",ePix:"EPIX","El Trece":"ETTV",ESPN:"ESPN",Esquire:"ESQ","Facebook Watch":"FBWatch",Family:"FAM","Family Jr":"FJR",Fandor:"FANDOR","Food Network":"FOOD",Fox:"FOX","Fox Premium":"FOXP",Foxtel:"FXTL",Freeform:"FREE","FYI Network":"FYI",GagaOOLala:"Gaga",Global:"GLBL","GloboSat Play":"GLOB",Hallmark:"HLMK","HBO Go":["HBO","re:HBO-?Go"],"HBO Max":"HMAX",HGTV:"HGTV",History:["HIST","History"],Hulu:"HULU","Investigation Discovery":"ID",IFC:"IFC",hoichoi:"HoiChoi",iflix:"IFX",iQIYI:"iQIYI",iTunes:["iTunes",{pattern:"iT",ignore_case:!1}],ITV:"ITV","Knowledge Network":"KNOW",Lifetime:"LIFE",Max:{pattern:"MAX",ignore_case:!1},"Motor Trend OnDemand":"MTOD",MBC:["MBC","MBCVOD"],MSNBC:"MNBC",MTV:"MTV",MUBI:"MUBI","National Audiovisual Institute":"INA","National Film Board":"NFB","National Geographic":["NATG","re:National-?Geographic"],"NBA TV":["NBA","re:NBA-?TV"],NBC:"NBC",Netflix:["NF","Netflix"],NFL:"NFL","NFL Now":"NFLN","NHL GameCenter":"GC",NowTV:{pattern:"NOW",ignore_case:!1},Nickelodeon:["NICK","Nickelodeon","NICKAPP"],"Norsk Rikskringkasting":"NRK",OnDemandKorea:["ODK","OnDemandKorea"],Opto:"OPTO","Oprah Winfrey Network":"OWN","Paramount+":["PMTP","PMNP","PMT+","Paramount+","ParamountPlus"],PBS:"PBS","PBS Kids":"PBSK",Peacock:["PCOK","Peacock"],"Playstation Network":"PSN",Pluzz:"PLUZ",PokerGO:"POGO","Rakuten TV":"RKTN","The Roku Channel":"ROKU","RTE One":"RTE",RUUTU:"RUUTU",SBS:"SBS","Science Channel":"SCI",SeeSo:["SESO","SeeSo"],Shomi:"SHMI",Showtime:"SHO",Sony:"SONY",Spike:"SPIK","Spike TV":["SPKE","re:Spike-?TV"],Sportsnet:"SNET",Sprout:"SPRT",Stan:"STAN",Starz:"STZ","Sveriges Television":"SVT",SwearNet:"SWER",Syfy:"SYFY",TBS:"TBS",TFou:"TFOU","The CW":["CW","re:The-?CW"],TLC:"TLC",TubiTV:"TUBI","TV3 Ireland":"TV3","TV4 Sweeden":"TV4",TVING:"TVING","TV Land":["TVL","re:TV-?Land"],TVNZ:"TVNZ",UFC:"UFC","UFC Fight Pass":"FP",F1TV:"F1TV",DAZN:"DAZN",FITE:"FITE",MotorTrend:"MOTORTREND",UKTV:"UKTV",Univision:"UNIV","USA Network":"USAN",Velocity:"VLCT",VH1:"VH1",Viceland:"VICE",Viki:"VIKI",Vimeo:"VMEO",VRV:"VRV","W Network":"WNET",WatchMe:"WME","WWE Network":"WWEN","Xbox Video":"XBOX",Yahoo:"YHOO","YouTube Red":"RED",ZDF:"ZDF"},date:{year_range_separators:["-","~","to","–"],week_words:["week"],weekday_words:["monday","tuesday","wednesday","thursday","friday","saturday","sunday","mon","tue","tues","wed","weds","thu","thur","thurs","fri","sat","sun"]}},Ro={expected_title:gu,allowed_countries:hu,allowed_languages:mu,advanced_config:vu};function Lt(d,e=!1){return d?typeof d=="object"&&!Array.isArray(d)?d:{}:{}}p(Lt,"parseOptions");function ac(d={}){const e=[];d.noDefaultConfig||e.push(Ro);const t=e.length>0?Oe(...e):{};return"advanced_config"in t||(t.advanced_config=Ro.advanced_config),t}p(ac,"loadConfig");function Oe(...d){let e={};if(d.length===0)return e;d[0]&&(e=yu(d[0]));for(const t of d.slice(1)){if(!t)continue;const n=t.pristine;if(n===!0)e={};else if(Array.isArray(n))for(const s of n)delete e[s];for(const[s,r]of Object.entries(t))xu(s,r,e)}return e}p(Oe,"mergeOptions");function xu(d,e,t){if(e!=null&&d!=="pristine"){const n=t[d];if(Array.isArray(n)&&Array.isArray(e))for(const s of e)!n.includes(s)&&s!==null&&n.push(s);else n!==null&&typeof n=="object"&&!Array.isArray(n)&&e!==null&&typeof e=="object"&&!Array.isArray(e)?t[d]=Oe(n,e):Array.isArray(e)?t[d]=[...e]:t[d]=e}}p(xu,"mergeOptionValue");function yu(d){return JSON.parse(JSON.stringify(d))}p(yu,"deepCopy");const ic={absolute_episode:{type:["number"],array:!0,scalar:!0},alternative_title:{type:["string"],array:!0,scalar:!0},another:{type:["string"],array:!1,scalar:!1},aspect_ratio:{type:["number"],array:!1,scalar:!0},audio_bit_rate:{type:["string"],array:!1,scalar:!0},audio_channels:{type:["string"],array:!0,scalar:!0,enum:["1.0","1ch","2.0","20","2ch","5.1","5ch","6ch","7.1","7ch","8ch","mono","stereo"]},audio_codec:{type:["string"],array:!0,scalar:!0,enum:["AAC","Atmos","DD+","DDP","Dolby","Dolby Atmos","Dolby Digital","Dolby Digital Plus","Dolby TrueHD","DolbyDigital","DTS","DTS-HD","DTS-X","DTS:X","DTSX","Flac","FLAC","LAME","LPCM","MP2","MP3","Opus","PCM","Vorbis"]},audio_profile:{type:["string"],array:!0,scalar:!0,enum:["ES","EX","Extended Surround","HE","High Efficiency","High Quality","High Resolution Audio","HQ","HR","HRA","LC","Low Complexity","MA","Master Audio"]},bonus:{type:["number"],array:!1,scalar:!0},bonus_title:{type:["string"],array:!1,scalar:!0},cd:{type:["number"],array:!1,scalar:!0},cd_count:{type:["number"],array:!1,scalar:!0},color_depth:{type:["string"],array:!1,scalar:!0,enum:["10-bit","12-bit","8-bit"]},container:{type:["string"],array:!0,scalar:!0,enum:["3g2","3gp","3gp2","7z","ace","arj","asf","ass","avi","bmp","bz2","cb7","cbr","cbz","divx","flv","gif","gz","idx","iso","jpeg","jpg","m2ts","m4v","mk2","mk3d","mka","mkv","MKV","mov","mp4","mp4a","mpeg","mpg","nfo","nzb","ogg","ogm","ogv","png","qt","r00","ra","ram","rar","rm","srt","ssa","strm","sub","tar","tbn","tgz","torrent","ts","txt","url","vob","vtt","wav","webm","webp","wma","wmv","zip"]},country:{type:["Language"],array:!1,scalar:!0},crc32:{type:["string"],array:!1,scalar:!0},date:{type:["object"],array:!1,scalar:!0},disc:{type:["number"],array:!0,scalar:!0},edition:{type:["string"],array:!0,scalar:!0,enum:["Alternative Cut","Anniversary","Assembly Cut","CC","collector","Collector","Criterion","DC","ddc","deluxe","Deluxe","Director's Cut","Director's Definitive Cut","extended","Extended","Fan","Festival","Final Cut","imax","IMAX","International Cut","limited","Limited","Redux","Remastered","Restored","se","Special","theatrical","Theatrical","Ultimate","Ultimate Cut","Uncensored","Uncut","Unrated"]},episode:{type:["number"],array:!0,scalar:!0},episode_count:{type:["number"],array:!1,scalar:!0},episode_details:{type:["string"],array:!0,scalar:!0},episode_format:{type:["string"],array:!1,scalar:!0,enum:["Minisode"]},episode_title:{type:["string"],array:!1,scalar:!0},film:{type:["number"],array:!1,scalar:!0},film_title:{type:["string"],array:!1,scalar:!0},frame_rate:{type:["string"],array:!1,scalar:!0},language:{type:["Language"],array:!0,scalar:!0},mimetype:{type:["string"],array:!1,scalar:!0,enum:["application/x-7z-compressed","application/x-ace-compressed","application/x-bittorrent","application/x-cbr","application/x-iso9660-image","application/x-nzb","application/x-rar-compressed","application/x-subrip","application/x-tar","application/zip","image/bmp","image/gif","image/jpeg","image/png","image/webp","text/vtt","text/x-nfo","video/mp2t","video/mp4","video/webm","video/x-matroska","video/x-msvideo"]},other:{type:["string"],array:!0,scalar:!0,enum:["2in1","3D","asrequested","Audio Fixed","Banner","Bonus","BT.2020","Classic","Clear Art","Clear Logo","Closed Caption","Colorized","Complet","Complete","CONVERT","Converted","Cover","Dirfix","Disc Art","DOCU","Documentary","DOKU","Dolby Vision","Dual","Dual Audio","East Coast Feed","Extras","Fan Subtitled","Fanart","Fansub","Fast Subtitled","Fastsub","FHD","Fix","Fixed","Forced","Full HD","Half Over Under","Half Side By Side","Hardcoded Subtitles","HC","HD","HDLight","HDR10","HDR10+","HFR","High Frame Rate","High Quality","High Resolution","HLG","HQ","HR","Hybrid","Internal","Landscape","LD","LDTV","LiNE","Line Audio","Line Dubbed","Logo","Low Definition","MD","mHD","Mic Dubbed","Micro HD","Mux","Nfofix","NTSC","Oad","OAR","Oav","Obfuscated","Ona","Open Matte","Original Animated Video","Original Animation DVD","Original Aspect Ratio","Original Net Animation","Original Video","OV","Ova","Over Under","PAL","postbot","Poster","Preair","Proof","Prooffix","Proper","PS Vita","R5","RC","Read NFO","Real","Reencoded","Region 5","Region C","Remux","Repost","Retail","Rip","Sample","Scrambled","Screener","SDH","SDR","SECAM","Side By Side","Standard Dynamic Range","Straight to Video","STV","Sync Fixed","Thumbnail","Trailer","UHD","Ultra HD","Upscaled","Variable Frame Rate","VFR","Virtual Reality","Vita","VO","vost","West Coast Feed","Widescreen","ws","xpost","XXX"]},part:{type:["number"],array:!0,scalar:!0},proper_count:{type:["number"],array:!1,scalar:!0},release_group:{type:["string"],array:!1,scalar:!0},screen_size:{type:["string"],array:!1,scalar:!0,enum:["1080i","1080p","1440p","1444x866","2160p","360p","368p","480p","4k","540p","576p","720p","720x432","960x544"]},season:{type:["number"],array:!0,scalar:!0},season_count:{type:["number"],array:!1,scalar:!0},size:{type:["string"],array:!1,scalar:!0},source:{type:["string"],array:!1,scalar:!0,enum:["Analog HDTV","Blu-ray","Camera","Digital Master","Digital TV","DVD","HD Camera","HD Telecine","HD Telesync","HD-DVD","HDTV","Laserdisc","Pay-per-view","Satellite","Telecine","Telesync","TV","Ultra HD Blu-ray","Ultra HDTV","VHS","Video on Demand","Web","Workprint"]},streaming_service:{type:["string"],array:!1,scalar:!0,enum:["4OD","9Now","9NOW","A&E","ABC","ABC Australia","Adult Swim","AE","AJAZ","Al Jazeera English","ALL4","Amazon","Amazon Prime","AMBC","AMC","America's Test Kitchen","AMZN","AMZN-CBR","Animal Planet","Anime Digital Network","AnimeLab","ANLB","ANPL","AOL","AppleTV","APTV","ARD","AS","ATK","ATV+","ATVP","AUBC","BBC iPlayer","Binge","BKPL","Blackpills","BLU","BluTV","BNGE","BOOM","Boomerang","BRAV","BravoTV","Canal+","Cartoon Network","CBC","CBS","CC","CCGC","Channel 4","Channel 5","CHGD","CHRGD","Cinemax","CMAX","CMT","CN","CNBC","CNLP","Comedians in Cars Getting Coffee","Comedy Central","Country Music Television","CR","Crackle","CRAV","Crave","CRKL","Crunchy Roll","CSpan","CSPN","CTV","CUR","CuriosityStream","CW","CWS","CWSeed","Daisuki","DAZN","DC Universe","DCU","DDY","Deadhouse Films","DF","DHF","Digiturk Diledigin Yerde","DISC","Discovery","Discovery Plus","Disney","Disney+","DIY","DIY Network","Doc Club","DOCC","DPlay","DPLY","DramaFever","DSCP","DSKI","DSNP","DSNY","E!","El Trece","ePix","EPIX","ESPN","ESQ","Esquire","ETTV","ETV","F1TV","Facebook Watch","FAM","Family","Family Jr","Fandor","FANDOR","FBWatch","FITE","FJR","FOOD","Food Network","Fox","FOX","Fox Premium","FOXP","Foxtel","FP","FREE","Freeform","FXTL","FYI","FYI Network","Gaga","GagaOOLala","GC","GLBL","GLOB","Global","GloboSat Play","Hallmark","HBO","HBO Go","HBO Max","HGTV","HIST","History","HLMK","HMAX","hoichoi","HoiChoi","Hulu","HULU","ID","IFC","iflix","IFX","INA","Investigation Discovery","iP","iQIYI","iT","iTunes","ITV","KNOW","Knowledge Network","LIFE","Lifetime","Max","MBC","MBCVOD","MNBC","Motor Trend OnDemand","MotorTrend","MSNBC","MTOD","MTV","MUBI","NATG","National Audiovisual Institute","National Film Board","National Geographic","NBA","NBA TV","NBC","Netflix","NF","NFB","NFL","NFL Now","NFLN","NHL GameCenter","NICK","NICKAPP","Nickelodeon","Norsk Rikskringkasting","NowTV","NRK","ODK","OnDemandKorea","Oprah Winfrey Network","Opto","OPTO","OWN","Paramount+","ParamountPlus","PBS","PBS Kids","PBSK","PCOK","Peacock","Playstation Network","PLUZ","Pluzz","PMNP","PMT+","PMTP","POGO","PokerGO","PSN","Rakuten TV","RED","RKTN","ROKU","RTE","RTE One","RUUTU","SBS","SCI","Science Channel","SeeSo","SESO","SHMI","SHO","Shomi","Showtime","SNET","Sony","SONY","SPIK","Spike","Spike TV","SPKE","Sportsnet","Sprout","SPRT","Stan","STAN","Starz","STZ","Sveriges Television","SVT","SwearNet","SWER","Syfy","SYFY","TBS","TFou","TFOU","The CW","The Roku Channel","TLC","TUBI","TubiTV","TV Land","TV3","TV3 Ireland","TV4","TV4 Sweeden","TVING","TVL","TVNZ","UFC","UFC Fight Pass","UKTV","UNIV","Univision","USA Network","USAN","Velocity","VH1","VICE","Viceland","Viki","VIKI","Vimeo","VLCT","VMEO","VRV","W Network","WatchMe","WME","WNET","WWE Network","WWEN","XBOX","Xbox Video","Yahoo","YHOO","YouTube Red","ZDF"]},subtitle_language:{type:["Language"],array:!0,scalar:!0},title:{type:["string"],array:!1,scalar:!0},type:{type:["string"],array:!1,scalar:!0,enum:["episode","movie"]},uuid:{type:["string"],array:!1,scalar:!0},version:{type:["number"],array:!1,scalar:!0},video_api:{type:["string"],array:!1,scalar:!0,enum:["DXVA"]},video_bit_rate:{type:["string"],array:!1,scalar:!0},video_codec:{type:["string"],array:!1,scalar:!0,enum:["AV1","AV2","DivX","DVDivX","H.263","H.264","H.265","MPEG-2","RealVideo","VC-1","VP7","VP8","VP80","VP9","Xvid","XviD"]},video_profile:{type:["string"],array:!0,scalar:!0,enum:["Advanced Video Codec High Definition","Baseline","BP","EP","Extended","HEVC","High","High 10","High 4:2:2","High 4:4:4 Predictive","High Efficiency Video Coding","HiP","HP","Main","MP","SC","Scalable Video Coding","SVC","XP"]},website:{type:["string"],array:!1,scalar:!0},year:{type:["number"],array:!1,scalar:!0}},po=class po extends Error{constructor(e,t,n){const s=n instanceof Error?n.message:String(n);super(`An internal error has occurred in guessit.
2
2
  string=${e}
3
3
  options=${JSON.stringify(t)}
4
- `+r),this.name="GuessItException",this.string=e,this.options=t,n instanceof Error&&(this.cause=n)}}class Xa{constructor(){this._rebulk=null,this._config=null,this._loadConfigOptions=null,this._advancedConfig=null}reset(){this._rebulk=null,this._config=null,this._loadConfigOptions=null,this._advancedConfig=null}configure(e,t,n=!1,r=!0){const s=t??ja;let a=r?We(e,!0):e??{};const i=(d,p)=>d.config===p.config&&d.noUserConfig===p.noUserConfig&&d.noDefaultConfig===p.noDefaultConfig;let o;this._config===null||this._loadConfigOptions===null||n||!i(this._loadConfigOptions,a)?(o=Ga(a),this._loadConfigOptions=a):o=this._config;const c=ve(o.advanced_config??{},a.advancedConfig??{});return(n||!this._rebulk||!this._advancedConfig||JSON.stringify(this._advancedConfig)!==JSON.stringify(c))&&(this._advancedConfig=JSON.parse(JSON.stringify(c)),this._rebulk=s(c)),this._config=o,o}guessit(e,t){try{const n=We(t,!0),r=this.configure(n,void 0,!1,!1),s=ve(r,n);if(!this._rebulk)throw new Error("Rebulk not initialized");const a=this._rebulk.matches(e,s),i=a.toDict(!!s.advanced,!!s.singleValue||!!s.single_value,!!s.enforceList||!!s.enforce_list),o=Object.fromEntries(i);for(const c of["language","subtitle_language"]){const l=o[c];if(!Array.isArray(l))continue;const d=new Set,p=l.filter(g=>{const f=g&&typeof g=="object"&&"alpha3"in g?`${g.alpha3}:${g.country??""}`:String(g);return d.has(f)?!1:(d.add(f),!0)});o[c]=p.length===1?p[0]:p}return(s.outputInputString||s.output_input_string)&&(o.input_string=a.inputString),o}catch(n){throw n instanceof Tr?n:new Tr(e,typeof t=="object"&&t!==null?t:{},n)}}properties(e){const t=We(e,!0),n=this.configure(t,void 0,!1,!1);if(ve(n,t),!this._rebulk)return{};const r={};for(const i of this._rebulk.effectivePatterns())if(i.properties)for(const[o,c]of Object.entries(i.properties)){r[o]||(r[o]=new Set);for(const l of c)r[o].add(l)}let s={};for(const i of Object.keys(r).sort())s[i]=[...r[i]].sort((o,c)=>String(o).localeCompare(String(c)));const a=this._rebulk;a.customizeProperties&&(s=a.customizeProperties(s));for(const[i,o]of Object.entries(Ka)){const c=Array.isArray(s[i])?s[i]:[];if(o.enum){const l=new Set([...c,...o.enum]);s[i]=[...l].sort((d,p)=>String(d).localeCompare(String(p)))}else c.length===0&&(s[i]=[null])}return s}suggestedExpected(e,t){const n=[];for(const r of e){const s=this.guessit(r,t);(Object.keys(s).length!==2||!("title"in s))&&n.push(r)}return n}}const Be=new Xa;function wl(u,e){return Be.guessit(u,e)}function Sl(u){return Be.properties(u)}function Al(u,e,t=!1){Be.configure(u,e,t)}function kl(){Be.reset()}const Dl="4.7.1",Cl=Dl;exports.GUESSIT_SCHEMA=Ka;exports.GuessItApi=Xa;exports.GuessItException=Tr;exports.configure=Al;exports.defaultApi=Be;exports.guessit=wl;exports.loadConfig=Ga;exports.mergeOptions=ve;exports.parseOptions=We;exports.properties=Sl;exports.rebulkBuilder=ja;exports.reset=kl;exports.version=Cl;
4
+ `+s),this.name="GuessItException",this.string=e,this.options=t,n instanceof Error&&(this.cause=n)}};p(po,"GuessItException");let Ct=po;const fo=class fo{constructor(){this._rebulk=null,this._config=null,this._loadConfigOptions=null,this._advancedConfig=null}reset(){this._rebulk=null,this._config=null,this._loadConfigOptions=null,this._advancedConfig=null}configure(e,t,n=!1,s=!0){const r=t??sc;let a=s?Lt(e,!0):e??{};const i=p((u,f)=>u.config===f.config&&u.noUserConfig===f.noUserConfig&&u.noDefaultConfig===f.noDefaultConfig,"hasSameConfigProps");let o;this._config===null||this._loadConfigOptions===null||n||!i(this._loadConfigOptions,a)?(o=ac(a),this._loadConfigOptions=a):o=this._config;const c=Oe(o.advanced_config??{},a.advancedConfig??{});return(n||!this._rebulk||!this._advancedConfig||JSON.stringify(this._advancedConfig)!==JSON.stringify(c))&&(this._advancedConfig=JSON.parse(JSON.stringify(c)),this._rebulk=r(c)),this._config=o,o}guessit(e,t){try{return this._guess(e,this._prepare(t))}catch(n){throw n instanceof Ct?n:new Ct(e,typeof t=="object"&&t!==null?t:{},n)}}guessitMany(e,t){const n=this._prepare(t);return e.map(s=>{try{return{input_string:s,result:this._guess(s,n)}}catch(r){return{input_string:s,error:r instanceof Error?r.message:String(r)}}})}_prepare(e){const t=Lt(e,!0),n=this.configure(t,void 0,!1,!1);return Oe(n,t)}_guess(e,t){if(!this._rebulk)throw new Error("Rebulk not initialized");const n=this._rebulk.matches(e,t),s=n.toDict(!!t.advanced,!!t.singleValue||!!t.single_value,!!t.enforceList||!!t.enforce_list),r=Object.fromEntries(s);for(const a of["language","subtitle_language"]){const i=r[a];if(!Array.isArray(i))continue;const o=new Set,c=i.filter(l=>{const u=l&&typeof l=="object"&&"alpha3"in l?`${l.alpha3}:${l.country??""}`:String(l);return o.has(u)?!1:(o.add(u),!0)});r[a]=c.length===1?c[0]:c}return(t.outputInputString||t.output_input_string)&&(r.input_string=n.inputString),r}properties(e){const t=Lt(e,!0),n=this.configure(t,void 0,!1,!1);if(Oe(n,t),!this._rebulk)return{};const s={};for(const i of this._rebulk.effectivePatterns())if(i.properties)for(const[o,c]of Object.entries(i.properties)){s[o]||(s[o]=new Set);for(const l of c)s[o].add(l)}let r={};for(const i of Object.keys(s).sort())r[i]=[...s[i]].sort((o,c)=>String(o).localeCompare(String(c)));const a=this._rebulk;a.customizeProperties&&(r=a.customizeProperties(r));for(const[i,o]of Object.entries(ic)){const c=Array.isArray(r[i])?r[i]:[];if(o.enum){const l=new Set([...c,...o.enum]);r[i]=[...l].sort((u,f)=>String(u).localeCompare(String(f)))}else c.length===0&&(r[i]=[null])}return r}suggestedExpected(e,t){const n=[];for(const s of e){const r=this.guessit(s,t);(Object.keys(r).length!==2||!("title"in r))&&n.push(s)}return n}};p(fo,"GuessItApi");let Xt=fo;const Te=new Xt;function _u(d,e){return Te.guessit(d,e)}p(_u,"guessit");function bu(d,e){return Te.guessitMany(d,e)}p(bu,"guessitMany");function wu(d){return Te.properties(d)}p(wu,"properties");function Su(d,e,t=!1){Te.configure(d,e,t)}p(Su,"configure");function Au(){Te.reset()}p(Au,"reset");const ku="4.9.0",Du=ku;exports.GUESSIT_SCHEMA=ic;exports.GuessItApi=Xt;exports.GuessItException=Ct;exports.configure=Su;exports.defaultApi=Te;exports.guessit=_u;exports.guessitMany=bu;exports.loadConfig=ac;exports.mergeOptions=Oe;exports.parseOptions=Lt;exports.properties=wu;exports.rebulkBuilder=sc;exports.reset=Au;exports.version=Du;
5
5
  //# sourceMappingURL=guessit-js.cjs.map