guessit-js 4.7.1 → 4.8.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 qi=Object.defineProperty;var Po=(u,e,t)=>e in u?qi(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var d=(u,e)=>qi(u,"name",{value:e,configurable:!0});var _=(u,e,t)=>Po(u,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function Ri(u){return u}d(Ri,"defaultFormatter");function wt(...u){return e=>{let t=e;for(const n of u)t=n(t);return t}}d(wt,"formatters");function mo(u){return u?Array.isArray(u)?u:[u]:[]}d(mo,"ensureList");function hr(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]}d(hr,"ensureDict");function R(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}d(R,"filterIndex");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)}}d(W,"setDefaults");function vo(u){return u==null||typeof u=="string"?!1:typeof u[Symbol.iterator]=="function"}d(vo,"isIterable");function*yr(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 l=s.indexOf(a,o);if(l===-1||l>=i)return;yield l,o=l+a.length}}d(yr,"findAll");function mr(u,e,t=void 0){for(const n of e)if(n!=null&&n in u)return u[n];return t}d(mr,"getFirstDefined");function Oo(u,e){for(const t of e)u.includes(t)||u.push(t)}d(Oo,"extendSafe");const Ya=class Ya{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()}};d(Ya,"IdentitySet");let _r=Ya;function Wi(u){return!0}d(Wi,"alwaysTrue");function xo(u,e){if(!e.inputString)return!0;const t=e.start-1;return t<0?!0:u.includes(e.inputString[t])}d(xo,"charsBefore");function yo(u,e){if(!e.inputString)return!0;const t=e.end;return t>=e.inputString.length?!0:u.includes(e.inputString[t])}d(yo,"charsAfter");function Io(u,e){return xo(u,e)&&yo(u,e)}d(Io,"charsSurround");const Gt=class Gt{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=mo(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 me(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,l]="span"in i?i.span:i;for(const c of[...a])if(o<=c.start&&l>=c.end)a.splice(a.indexOf(c),1);else if(o>=c.start&&l<=c.end){const f=c._clone();c.end=o,c.length===0&&a.splice(a.indexOf(c),1),f.start=l,f.length>0&&a.push(f)}else c.end>=l&&l>c.start?c.start=l:c.start<=o&&o<c.end&&(c.end=o)}return R(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 R(r,t??null,n??null)}clone(){return this._clone()}_clone(){const e=new Gt(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}>`}};d(Gt,"Match");let P=Gt;const Za=class Za extends Map{constructor(){super(...arguments);_(this,"matches",new Map);_(this,"valuesList",new Map)}};d(Za,"MatchesDict");let br=Za;const Ja=class Ja{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 me(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 R(r,t,n)}tagged(e,t,n){const r=this.tagDict.get(e)??[];return R(r,t,n)}starting(e,t,n){const r=this.startDict.get(e)??[];return R(r,t,n)}ending(e,t,n){const r=this.endDict.get(e)??[];return R(r,t,n)}atIndex(e,t,n){const r=this.indexDict.get(e)??[];return R(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 R(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 R(a,null,r)}previous(e,t,n){let r=e.start;for(;r>-1;){const s=this.ending(r);if(s.length>0)return R(s,t,n);r--}return R([],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 R(s,t,n);r++}return R([],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 R(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 l=this.indexDict.get(o)??[],c=r?l.filter(r):[...l];if(c.length>0)for(const f of c)i.includes(f)||i.push(f);else if(!this.inputString||!t.includes(this.inputString[o]))break}return R(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 l=a;l<i;l++){const c=this.indexDict.get(l)??[],f=r?c.filter(r):[...c];if(f.length>0)for(const p of f)o.includes(p)||o.push(p);else if(!this.inputString||!t.includes(this.inputString[l]))break}return R(o,null,s)}holes(e=0,t,n={}){const{formatter:r,ignore:s,seps:a,predicate:i,index:o}=n,l=t!==void 0?Math.min(this.maxEnd,t):this.maxEnd,c=[];let f=!1,p=0;for(let g=e-1;g>=0;g--){const x=this.starting(g);let m=!1;for(const v of x)if(!s||!s(v)){p=g,m=!0;break}if(m)break}for(let g=p;g<l;g++){const x=this.indexDict.get(g)??[],m=s?x.filter(v=>!s(v)):[...x];a&&f&&this.inputString&&a.includes(this.inputString[g])?(f=!1,c[c.length-1].end=g):m.length===0&&!f?(f=!0,c.push(new P(Math.max(g,e),0,{inputString:this.inputString,formatter:r}))):m.length>0&&f&&(f=!1,c[c.length-1].end=g)}if(c.length>0&&f){let g=this.maxEnd;const x=l>p?l-1:p;for(let m=x;m<this.maxEnd;m++){const v=this.starting(m);let C=!1;for(const b of v)if(!s||!s(b)){g=m,C=!0;break}if(C)break}c[c.length-1].end=Math.min(g,l)}const h=c.filter(g=>g.end>g.start);return R(h,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 br;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=d((c,f)=>e&&c instanceof P&&f instanceof P?c.equals(f):c===f,"valEquals");if(!n){const c=r.valuesList.get(s.name??"")??[];c.some(f=>o(f,a))||c.push(a),r.valuesList.set(s.name??"",c)}const l=r.get(s.name??"");l!==void 0?t||(Array.isArray(l)?l.some(c=>o(c,a))||l.push(a):o(l,a)||r.set(s.name,[l,a])):r.set(s.name,n&&!Array.isArray(a)?[a]:a)}return r}toString(){return`[${this._delegate.map(String).join(", ")}]`}};d(Ja,"_BaseMatches");let It=Ja;const Qa=class Qa extends It{constructor(t,n){super(void 0,n);_(this,"markers");this.markers=new wr(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)}};d(Qa,"Matches");let me=Qa;const ei=class ei extends It{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)}};d(ei,"Markers");let wr=ei;function Pe(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}d(Pe,"filterMatchKwargs");function Lo(u){return u.replace(/\(\?P</g,"(?<")}d(Lo,"convertPythonNamedGroups");function $o(u,e){let t=u;for(const[n,r]of e)t=t.split(n).join(r);return t}d($o,"applyAbbreviations");function To(u,e){let t=Lo(u);e.abbreviations&&(t=$o(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)}d(To,"compileRegex");function ji(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}d(ji,"buildGroupNames");const ti=class ti{};d(ti,"BasePattern");let Lt=ti;const Ue=class Ue extends Lt{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=mo(t.tags);const[n,r]=hr(t.formatter,Ri);this.formatters=n,this.defaultFormatterFn=r??Ri;const[s,a]=hr(t.value,void 0);this.values=s,this.defaultValue=a;const[i,o]=hr(t.validator,Wi);this.validators=i,this.defaultValidator=o??Wi,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 l=t.disabled;typeof l=="function"?this.disabled=l:typeof l=="boolean"?this.disabled=()=>l: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=mr(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=mr(this.formatters,s,this.defaultFormatterFn)}}_processMatchValidator(t,n=!1){if((n?this.shouldIncludeChildren:this.shouldIncludeParent)||this.validateAll){const s=this._matchConfigPropertyKeys(t,n),a=mr(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=Ue._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=Ue._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 l=0;for(const c of this._match(o,t,n)){a.push(c);for(const f of this._processMatches(c,l))s.push(f);l++}}const i=this._postProcessMatches(s);return r?[i,a]:i}get properties(){return this.properties_??{}}};d(Ue,"Pattern");let Oe=Ue;const ni=class ni extends Oe{constructor(t,...n){var e=(...Hl)=>(super(...Hl),_(this,"_patterns"),_(this,"_matchKwargs"),this);typeof t=="string"?(e({}),this._patterns=[t,...n],this._matchKwargs=Pe({})):(e(t),this._patterns=n,this._matchKwargs=Pe(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 yr(n,t,a,i,s)){const l=new P(o,o+t.length,{...this._matchKwargs,pattern:this,inputString:n});l.length>0&&(yield l)}}toString(){return`<StringPattern:(${this._patterns.map(t=>`'${t}'`).join(", ")})>`}};d(ni,"StringPattern");let $t=ni;const ri=class ri extends Oe{constructor(t,...n){super(t);_(this,"_regexes");_(this,"_matchKwargs");_(this,"_childrenMatchKwargs");_(this,"_groupNamesList");this._matchKwargs=Pe(t),this._childrenMatchKwargs=Pe(t,!0),this._regexes=[],this._groupNamesList=[];for(const r of n)if(r instanceof RegExp)this._regexes.push(r),this._groupNamesList.push(ji(r.source));else{const s=To(r,{flags:t.flags,ignoreCase:t.ignoreCase,abbreviations:t.abbreviations});this._regexes.push(s),this._groupNamesList.push(ji(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,l=new P(i,o,{...this._matchKwargs,pattern:this,inputString:n});if(s.length>0){const c=a.indices;for(let f=0;f<s.length;f++){const p=f+1,h=s[f]??this.name,g=c?.[p];if(g&&g[0]!==-1){const[x,m]=g,v=new P(x,m,{...this._childrenMatchKwargs,name:h,parent:l,pattern:this,inputString:n});v.length>0&&l.children.append(v)}}}(l.length>0||a[0].length===0)&&l.length>0&&(yield l),a[0].length===0&&t.lastIndex++}}toString(){return`<RePattern:(${this._regexes.map(t=>t.source).join(", ")})>`}};d(ri,"RePattern");let Tt=ri;const si=class si extends Oe{constructor(t,...n){super(t);_(this,"_fns");_(this,"_matchKwargs");this._fns=n,this._matchKwargs=Pe(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=d(o=>!Array.isArray(o)||o.length>=2&&typeof o[0]=="number"&&typeof o[1]=="number","isSingleResult")(s)?[s]:s;for(const o of i)if(o){if(typeof o=="object"&&!Array.isArray(o)){const{start:l,end:c,...f}=o,p={...this._matchKwargs,...f},h=new P(l??0,c??0,{...p,pattern:this,inputString:n});h.length>0&&(yield h)}else if(Array.isArray(o)){let l=this._matchKwargs,c,f;o.length>=3&&typeof o[2]=="object"&&!Array.isArray(o[2])?(l={...this._matchKwargs,...o[2]},[c,f]=o):[c,f]=o;const p=new P(c,f,{...l,pattern:this,inputString:n});p.length>0&&(yield p)}}}toString(){return`<FunctionalPattern:(${this._fns.map(t=>t.name||"anonymous").join(", ")})>`}};d(si,"FunctionalPattern");let Ht=si,_o=null;function Ho(u){_o=u}d(Ho,"registerChain");function Fo(){return _o}d(Fo,"getChainClass");function Ki(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,{}]}d(Ki,"splitPatternsOpts");const ai=class ai{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 Tt(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 $t(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 Ht(n,...t)}regex(...e){const[t,n]=Ki(e),r=this.buildRe(n,...t);return this.pattern(r)}string(...e){const[t,n]=Ki(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=Fo();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}};d(ai,"Builder");let Sr=ai;const ii=class ii 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"}};d(ii,"CyclicDependency");let Ar=ii;function*zo(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 Ar(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)}}d(zo,"toposort");const oi=class oi{};d(oi,"Consequence");let Ie=oi;const ci=class ci{};d(ci,"Condition");let kr=ci;const ge=class ge extends kr{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}};d(ge,"CustomRule"),_(ge,"priority",0),_(ge,"ruleName"),_(ge,"dependency",null),_(ge,"properties",{});let Q=ge;const li=class li extends Q{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)}}};d(li,"Rule");let y=li;const ui=class ui extends Ie{then(e,t,n){if(!t)return;if(vo(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}};d(ui,"RemoveMatch");let S=ui;const di=class di extends Ie{constructor(t){super();_(this,"matchName");this.matchName=t}then(t,n,r){if(!n)return;if(vo(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}};d(di,"AppendMatch");let H=di;const fi=class fi extends Ie{constructor(t){super();_(this,"matchName");_(this,"_remove",new S);_(this,"_append",new H);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)}};d(fi,"RenameMatch");let ie=fi;const pi=class pi extends Ie{constructor(t){super();_(this,"tags");_(this,"_remove",new S);_(this,"_append",new H);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)}}};d(pi,"AppendTags");let Ft=pi;const gi=class gi{constructor(...e){_(this,"_list",[]);this.load(...e)}load(...e){for(const t of e)typeof t=="function"&&t.prototype instanceof Q?this._list.push(new t):typeof t=="object"&&t!==null&&!(t instanceof Q)?this.loadModule(t):t instanceof Q?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 Q&&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=Uo(i);for(const l of o){const c=[...l].sort((f,p)=>this.indexOf(f)-this.indexOf(p));for(const f of c){const p=Bo(f,e,t);p!=null&&p!==!1&&n.push([f,p])}}}return n}};d(gi,"Rules");let zt=gi;function Bo(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}d(Bo,"executeRule");function Uo(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[l,c]of t)if(l.name===i){o=c;break}}else o=t.get(i)??[];for(const l of o)l!==n&&r.add(l)}}e.set(n,r)}return[...zo(e)]}d(Uo,"toposortRules");const Vo="__default__",Dr=2048,O=-2048;function qo(u,e){return e.initiator.length<u.initiator.length?e:u.initiator.length<e.initiator.length?u:null}d(qo,"defaultConflictSolver");const Xt=class Xt extends y{constructor(){super(...arguments);_(this,"priority",Dr);_(this,"consequence",S)}get defaultConflictSolverFn(){return qo}when(t,n){const r=new _r,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(l=>!l.private).sort((l,c)=>l.length-c.length);for(const l of o){const c=[[this.defaultConflictSolverFn,!1]];a.conflictSolver&&c.push([a.conflictSolver,!1]),l.conflictSolver&&c.push([l.conflictSolver,!0]);for(let f=c.length-1;f>=0;f--){const[p,h]=c[f],g=h?p(l,a):p(a,l);if(g!==Vo){if(g&&!r.has(g)){const x=g===a?l:a;r.has(x)||r.add(g)}break}}}}return r}};d(Xt,"ConflictSolver"),_(Xt,"priority",Dr);let Cr=Xt;const Yt=class Yt extends y{constructor(){super(...arguments);_(this,"priority",O);_(this,"consequence",S)}when(t,n){return t.toArray().filter(r=>r.private)}};d(Yt,"PrivateRemover"),_(Yt,"priority",O);let Mr=Yt;const hi=class hi extends Error{constructor(){super("Invalid chain")}};d(hi,"InvalidChainException");let Bt=hi;const mi=class mi extends Lt{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 Bt}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}})`}};d(mi,"ChainPart");let Er=mi;const Z=class Z extends Oe{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=Pe(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 Tt(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 $t(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 Ht(s,n);return this.pattern(a)}chain(t={}){const n={...this._chainDefaults,...this._defaults,...t},r=new Z(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 Er(this,t[0]);return this.parts.push(n),n}close(){let t=this._parent;for(;t instanceof Z;)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(l=>l.pattern===a),o=Z._groupByMatchIndex(i);if(o.size>0){const l=new me(t.children.toArray()),c=t.end,f=[...o.keys()].sort((p,h)=>h-p);for(const p of f){const h=o.get(p);for(const x of h)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,r))return!0}t.children=l,t.end=c}}return!1}*_match(t,n,r){let s=0;for(;s<n.length;){let a=!1;const i=[];let o=!0,l=n.slice(s);for(const c of this.parts)try{const f=c.matches(l,r,!0),[p,h]=f;if(Z._fixMatchesOffset(p,n,s),Z._fixMatchesOffset(h,n,s),h.length>0){const g=Z._groupByMatchIndex(h),x=Z._groupByMatchIndex(p);for(const[m,v]of g)if(a=!0,s=v[v.length-1].rawEnd,l=n.slice(s),!c.isHidden){const C=x.get(m)??[];this._chainBreakerEval([...i,...C])&&i.push(...C)}}}catch(f){if(f instanceof Bt){o=!1,i.length>0?s=i[0].rawEnd:s++;break}throw f}if(!a)break;i.length>0&&o&&(yield this._buildChainMatch(i,n))}}_chainBreakerEval(t){return this._chainBreaker?!this._chainBreaker(new me(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&&Z._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}};d(Z,"Chain");let Nr=Z;Ho(Nr);const vi=class vi extends Sr{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(Cr,Mr)}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 me(void 0,t);return this._matchesPatterns(r,n),this._executeRules(r,n),r}effectiveRules(t){const n=new zt;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??{})||Oo(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)}}};d(vi,"Rebulk");let F=vi;function Ro(u){const e=new F;e.defaults({name:"path",marker:!0});function t(n,r){if(r?.name_only)return[[0,n.length]];const s=[...yr(n,"/"),...yr(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 d(t,"markPath"),e.functional(t),e}d(Ro,"path");const xi=class xi extends Error{constructor(e){super(e),this.name="ConfigurationException"}};d(xi,"ConfigurationException");let Pr=xi;function Wo(u){const e=new F;e.defaults({name:"group",marker:!0});const{starting:t,ending:n}=u;if(t.length!==n.length)throw new Pr("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 l=s[o],c=t.indexOf(l);c>-1&&a[c].push(o);const f=n.indexOf(l);if(f>-1){const p=a[f];if(p.length>0){const h=p.pop();i.push([h,o+1])}}}return i}return d(r,"markGroups"),e.functional(r),e}d(Wo,"groups");function L(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("")}d(L,"buildOrPattern");const jo=[["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};function Go(u){const e=u.toUpperCase();let t=0,n=0;for(const[r,s]of jo)for(;e.startsWith(r,n);)t+=s,n+=r.length;return n===e.length&&t>0?t:void 0}d(Go,"parseRoman");function Xo(u){return Ko[u.toLowerCase()]}d(Xo,"parseWord");function se(u){const e=parseInt(u,10);if(!isNaN(e))return e;const t=Go(u);return t!==void 0?t:Xo(u)}d(se,"parseNumber");const M=" [](){}+*|=-_~#/\\.,;:",ze=M.replace(/[\[\](){}]/g,""),bo=M.replace(/[/\\]/g,""),Or="-+/\\|";function Dt(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}d(Dt,"reEscape");const U=Dt(M);Dt(ze);const X=["-","["+Dt(bo)+"]"],Yo=["@","["+Dt(bo)+"]"];function q(u){return"(?:"+u+")?"}d(q,"optional");const ce=d(u=>xo(M,u),"sepsBefore"),le=d(u=>yo(M,u),"sepsAfter"),T=d(u=>Io(M,u),"sepsSurround");function Le(u){const e=Number(u.trim());return Number.isInteger(e)}d(Le,"intCoercable");function ye(...u){return e=>u.every(t=>t(e))}d(ye,"and_");function wo(...u){return e=>u.some(t=>t(e))}d(wo,"or_");const Zo={À:"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 Gi(u){let e="";for(const t of u)e+=Zo[t]??t;return e.replace(/[̀-ͯ]/g,"")}d(Gi,"foldDiacritics");const Jo=new Set([",",":",";","-","/","\\"]),Qo=M.split("").filter(u=>!Jo.has(u)).join("");function ec(u,e){return u-1>=0&&M.includes(e[u])&&(u-2<0||M.includes(e[u-2]))&&!M.includes(e[u-1])}d(ec,"potentialBefore");function tc(u,e){return u+2>=e.length||e[u+2]===e[u]&&!M.includes(e[u+1])}d(tc,"potentialAfter");function B(u){if(!u)return u;let e=u;for(const o of Qo)e=e.split(o).join(" ");const t=[];for(let o=0;o<e.length;o++)M.includes(e[o])&&t.push(o);const n=new Set;if(t.length>0){const o=e.split(""),l=[];for(const f of t)ec(f,u)&&tc(f,u)&&l.push(f);const c=[];for(const f of l)(l.includes(f-2)||l.includes(f+2))&&c.push(f);if(c.length>0){for(const f of c)n.add(u[f]),o[f]=u[f];e=o.join("")}}const r=[],s=/\d+(?:\.\d+){2,}/g;let a;for(;(a=s.exec(u))!==null;)if(/[^\s._-]/.test(u.slice(0,a.index)))for(let o=a.index;o<a.index+a[0].length;o++)u[o]==="."&&r.push(o);if(r.length>0){const o=e.split("");for(const l of r)o[l]=".";n.add("."),e=o.join("")}const i=M.split("").filter(o=>!n.has(o)).join("");return e=_e(e,i),/(?:^|[ ])\d+\.\d+\.$/.test(e)&&(e=e.slice(0,-1)),e=e.replace(/ +/g," "),e}d(B,"cleanup");function _e(u,e=M){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)}d(_e,"strip");function So(u){return wt(B,_e)(u.toLowerCase())}d(So,"rawCleanup");function Ut(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}d(Ut,"reorderTitle");function A(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))}d(A,"isDisabled");const vr={零:0,一:1,二:2,两:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Xi="(?:\\d{1,4}|[一二两三四五六七八九]?十[一二两三四五六七八九]?|[零一二两三四五六七八九])";function Yi(u){if(/^\d+$/.test(u))return parseInt(u,10);if(u.includes("十")){const[e,t]=u.split("十"),n=e?vr[e]:1,r=t?vr[t]:0;return n*10+r}return vr[u]}d(Yi,"parseCjkNumber");function Zi(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}}d(Zi,"splitWords");function Ji(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}d(Ji,"episodesSeasonChainBreaker");function He(u,e){const t=d(a=>!!(a?.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(a?.initiator?.name)||["weak_episode","weak_duplicate"].includes(a?.name)),"weakFamily");if(t(u)&&t(e))return null;const n=d(a=>a?.name?null:[...a?.children??[]].find(o=>o.name==="season"||o.name==="episode")??null,"famChild"),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"&&!Le(e.raw))return u}}if(["season","episode"].includes(u.name)&&["season","episode"].includes(e.name)&&u.initiator!==e.initiator){const a=d(x=>!!(x.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(x.initiator?.name)),"isWeak"),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 x=i?u:e,m=i?e:u,v=u.inputString??"",C=d(($,I)=>{let w=$;for(;w>=0&&w<v.length&&M.includes(v[w]);)w+=I;let j="";for(;w>=0&&w<v.length&&/\d/.test(v[w]);)j=j+v[w],w+=I;return j},"digitToken"),b=d($=>$.length===4&&+$>=1900&&+$<=2100,"isYearLike"),k=x.initiator??x,D=m.initiator??m,N=(()=>{const $=C(k.end,1);return $.length>=1&&$.length<=4&&!b($)})();return(()=>{const $=v.slice(Math.max(0,D.start-12),D.start),I=/(\d{1,3})(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?[\s.,_\-–]*$/iu.exec($);return!!(I&&!b(I[1]))})()&&!N?m:x}const l=!!(u.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(u.initiator?.name)),c=!!(e.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(e.initiator?.name));if(l&&c)return null;if(l)return u;if(c)return e;const f=!!u.tags?.includes("SxxExx"),p=!!e.tags?.includes("SxxExx");if(f&&!p)return e;if(p&&!f)return u;const h=u.initiator?.raw?.toLowerCase().includes("x")&&!f,g=e.initiator?.raw?.toLowerCase().includes("x")&&!p;if(h&&!g)return u;if(g&&!h)return e}return"__default__"}d(He,"seasonEpisodeConflictSolver");function Fe(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}d(Fe,"orderingValidator");function Pt(u){return Le(u.raw)?!0:T(u)}d(Pt,"validateRoman");function Qi(u){const e=String(u.raw??"");if(/^\d{4}$/.test(e)){const t=parseInt(e,10);if(t>=1900&&t<=2100)return!1}return Pt(u)}d(Qi,"seasonWordNotYear");function nc(u){u.range_separators;const e=u.discrete_separators,t=M.split("").filter(w=>!u.range_separators.includes(w)&&w!=="/"&&w!=="\\"),n=[...u.range_separators,...e,...t],r=Fe,s=d(w=>{if(!r(w))return!1;const j=d(V=>{let J=null,fe=!0;const ve=w.children,ne=ve?.named?.(V)??[];for(const z of Array.isArray(ne)?ne:[ne]){if(J){const Y=ve.previous?.(z,K=>K.name===V+"Separator",0);if(Y){const K=String(Y.raw??"");if(!u.range_separators.includes(K)&&t.includes(K)){const re=Number(z.value)-Number(J.value);re>0&&re<=u.max_range_gap+1||(fe=!1)}if(e.includes(K)){fe=!0;break}}}J=z}return fe},"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("|")})`,l="(?:\\d+|[ivxlcdm]+)";function c(w){return A(w,"episode")||A(w,"season")}d(c,"isSeasonEpisodeDisabled");const f=new F().regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}).defaults({privateNames:["episodeSeparator","seasonSeparator","episodeMarker","seasonMarker"],formatter:{season:d(w=>parseInt(w,10),"season"),episode:d(w=>parseInt(w,10),"episode"),version:d(w=>parseInt(w,10),"version"),count:d(w=>parseInt(w,10),"count")},children:!0,privateParent:!0,conflictSolver:He,abbreviations:[Yo]});f.regex(`第(?<episode>${Xi})[話话集]`,{tags:["SxxExx"],formatter:{episode:Yi}}),f.regex(`第(?<season>${Xi})季`,{tags:["SxxExx"],formatter:{season:Yi}}),f.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})(?!\\d)",{tags:["SxxExx"]}),f.regex("(?<!\\d)(?<season>\\d{1,2})期",{});const p=L(u.season_markers,"seasonMarker"),h=L([...u.episode_markers,...u.disc_markers],"episodeMarker"),g=L([...u.episode_markers,...u.disc_markers,...n],"episodeSeparator",!0);f.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ye(T,s)},chainBreaker:d(w=>Ji(w,u),"chainBreaker"),disabled:c}).defaults({tags:["SxxExx"]}).regex(p+"(?<season>\\d+)@?"+h+"@?(?<episode>\\d+)(?:[a-d](?![a-z0-9]))?(?:v(?<version>\\d+))?").repeater("+").regex(g+"@?(?<episode>\\d+)").repeater("*");const x=L(u.season_ep_markers,"episodeMarker"),m="(?!@"+L(u.season_ep_markers)+"\\d)";f.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ye(T,Fe)},disabled:c}).defaults({tags:["SxxExx"]}).regex("(?!0x[0-9a-fA-F])(?<season>\\d+)"+m+"@?"+x+"@?(?<episode>\\d+)").repeater("+"),f.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ye(T,Fe)},disabled:c}).defaults({tags:["SxxExx"]}).regex("(?!0x[0-9a-fA-F])(?<season>\\d+)"+m+"@?"+x+"@?(?<episode>\\d+)").regex(L([...u.season_ep_markers,...e,...u.range_separators],"episodeSeparator",!0)+"(?<episode>\\d+)").repeater("*"),f.regex("t(?<season>\\d{1,2})@?"+L(u.episode_markers,"episodeMarker")+"@?(?<episode>\\d{1,4})",{tags:["SxxExx"],disabled:c}),f.regex("(?<![^\\W_])(?:SP|EX|OVA|OAV)-?(?<episode>\\d{1,3})(?![^\\W_])",{tags:["SxxExx","special-episode"],disabled:d(w=>A(w,"episode"),"disabled")}),f.regex("(?<season>\\d{1,2})(?:st|nd|rd|th)@?(?:season)(?![^\\W_])",{tags:["SxxExx","numfirst"],disabled:c}),f.regex("(?<!\\d)(?<season>\\d{1,2})(?<episodeMarker>x)(?<episode>\\d{2})(?!\\d)",{tags:["SxxExx"],disabled:c});const v=L([...u.season_markers,...e,...u.range_separators],"seasonSeparator",!0);f.chain({tags:["SxxExx"],validateAll:!0,validator:{__parent__:ye(T,Fe)},disabled:c}).defaults({tags:["SxxExx"]}).regex(p+"(?<season>\\d+)").regex("(?<other>Extras)",{name:"other",value:"Extras",tags:["no-release-group-prefix"]}).repeater("?").regex(v+"(?<season>\\d+)").repeater("*");for(const w of["Special","Pilot","Unaired","Final"])f.string(w,{name:"episode_details",value:w,children:!1,privateParent:!1,disabled:d(j=>A(j,"episode_details"),"disabled")});const{words:C,numfirst:b}=Zi(u.season_words),{words:k,numfirst:D}=Zi(u.episode_words),N=L(C,"seasonMarker"),E=L(u.of_words);f.chain({validateAll:!0,conflictSolver:He,formatter:{season:se,season_count:se},validator:{__parent__:ye(T,Fe),season:Qi,season_count:Pt},chainBreaker:d(w=>Ji(w,u),"chainBreaker"),disabled:d(w=>w?.type==="movie"||A(w,"season"),"disabled")}).defaults({formatter:{season:se,season_count:se},validator:{season:Qi,season_count:Pt},conflictSolver:He}).regex(N+`@?(?P<season>${o})`).regex(E+`@?(?P<season_count>${l})`).repeater("?").regex("(?:,@?)?@?"+L([...u.range_separators,...e,"@"],"seasonSeparator",!0)+"@?(?P<season>\\d+)").repeater("*");const $="(?:@?"+E+"@?(?<count>\\d+))?";b.length>0&&f.regex("(?<season>\\d{1,2})"+u.ordinal_suffix+"@?@?"+L(b,"seasonMarker")+"(?![^\\W\\d_])"+$,{tags:["SxxExx","numfirst"],formatter:{season:se,count:d(w=>parseInt(w,10),"count")},disabled:c}),D.length>0&&f.regex("(?<episode>\\d{1,3})"+u.ordinal_suffix+"@?@?"+L(D,"episodeMarker")+"(?![^\\W\\d_])"+$,{tags:["SxxExx","numfirst"],formatter:{episode:se,count:d(w=>parseInt(w,10),"count")},disabled:d(w=>A(w,"episode"),"disabled")});const I=L(k,"episodeMarker");return f.regex(L(k,"episodeMarker")+"@?(?<season>\\d{1,2})\\.(?<episode>\\d{2,3})(?!\\d)",{tags:["SxxExx"],disabled:c}),f.regex("(?<=[\\s([_-][\\s._-]?)(?<!\\d[-x])(?<season>\\d{1,2})\\.(?<episode>\\d{2,3})(?=[\\s)\\]._-]|$)(?!\\.\\d)",{tags:["SxxExx","decimal-episode"],validator:{__parent__:d(w=>{const V=(w.inputString??"").slice(Math.max(0,w.start-3),w.start);return/[-([]\s?$|^\s*$|\s-\s$/.test(V)||/[([]/.test(V)},"__parent__")},disabled:c}),f.regex("(?<![a-zA-Z\\d])"+I+"@?(?<episode>\\d+)(?:v(?<version>\\d+))?(?:@?"+E+"@?(?<count>\\d+))?",{disabled:d(w=>w?.type==="episode"||A(w,"episode"),"disabled")}),f.regex("(?<![a-zA-Z\\d])"+I+`@?(?<episode>${l})(?:v(?<version>\\d+))?(?:@?`+E+"@?(?<count>\\d+))?",{validator:{episode:Pt},formatter:{episode:se},disabled:d(w=>w?.type!=="episode"||A(w,"episode"),"disabled")}),f.regex("S?(?<season>\\d+)-?(?:xE|Ex|E|x)-?(?<other>"+L(u.all_words)+")",{tags:["SxxExx"],formatter:{other:d(()=>"Complete","other")},disabled:d(w=>A(w,"season"),"disabled")}),f.chain({tags:["weak-episode"],disabled:d(w=>w?.type==="movie"||A(w,"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("*"),f.chain({tags:["weak-episode"],disabled:d(w=>w?.type==="movie"||A(w,"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("*"),f.chain({tags:["weak-episode"],name:"weak_episode",disabled:d(w=>w?.type==="movie"||A(w,"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("*"),f.chain({tags:["weak-episode"],disabled:d(w=>w?.type!=="episode"||A(w,"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("*"),f.chain({validateAll:!0,validator:{__parent__:T},disabled:d(w=>A(w,"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("*"),f.chain({disabled:d(w=>A(w,"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("*"),f.chain({tags:["see-pattern"],disabled:c}).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("?"),f.chain({tags:["weak-episode","weak-duplicate"],name:"weak_duplicate",conflictSolver:He,disabled:d(w=>w?.episode_prefer_number===!0||w?.type==="movie"||c(w),"disabled")}).defaults({tags:["weak-episode","weak-duplicate"],name:"weak_duplicate",validator:null,conflictSolver:He}).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("*"),f.regex("v(?<version>\\d+)",{formatter:{version:d(w=>parseInt(w,10),"version")},disabled:d(w=>A(w,"version"),"disabled")}),f.regex("(?<![^\\W_])(?<episode>\\d+)@?"+E+"@?(?<count>\\d+)@?"+I+"?",{formatter:{episode:d(w=>parseInt(w,10),"episode"),count:d(w=>parseInt(w,10),"count")},preMatchProcessor:d(w=>(w.value=B(w.value),w),"preMatchProcessor"),disabled:d(w=>A(w,"episode"),"disabled")}),f.regex("Minisodes?",{children:!1,privateParent:!1,name:"episode_format",value:"Minisode",disabled:d(w=>A(w,"episode_format"),"disabled")}),f.rules(Lr,$r,Ir,Tr,Hr,Fr,zr,Br,new Ur(u),Vr,new qr(u),Kr,jr,Xr,Gr,Rr,Wr,rc),f}d(nc,"episodes");const Zt=class Zt extends y{constructor(){super(...arguments),this.priority=72,this.consequence=S}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(f=>f.name==="episode")||n[i.start-1]!=="-")continue;const l=e.range(Math.max(0,i.start-12),i.start-1,f=>!f.private&&s.has(f.name??""),-1)??e.range(Math.max(0,i.start-12),i.start-1,f=>!f.private&&s.has(f.name??""),0),c=e.markers.atMatch(i,f=>f.name==="group",0);if(!(!l&&!c)){r.push(a);for(const f of i.children??[])r.includes(f)||r.push(f)}}return r.length?r:!1}};d(Zt,"RemoveGroupSuffixSeason"),Zt.priority=72;let Ir=Zt;const Jt=class Jt extends y{constructor(){super(...arguments),this.priority=60,this.consequence=S}when(e,t){const n=e.inputString??"",r=[],s=d(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,l=>l.name==="episode"&&!l.private&&s(l))??[];if(!i.length)continue;const o=e.range(a.start,a.end,l=>!l.private&&(l.name==="season"||l.name==="year"||l.name==="date"||l.name==="episode"&&l.tags?.includes("SxxExx")),0);for(const l of i){const c=l.initiator??l,f=n.slice(c.end,c.end+5);if(/^[\s._-]?PPV/i.test(f)){for(const p of[c,...c.children??[]])r.includes(p)||r.push(p);continue}if(!o&&c.start===a.start&&/^[1-9]\d$/.test(String(c.raw??""))&&(n.slice(c.end,a.end).match(/[A-Za-z][a-z]+/g)??[]).length>=2)for(const g of[c,...c.children??[]])r.includes(g)||r.push(g)}}return r.length?r:!1}};d(Jt,"EventNumberAsTitleRule"),Jt.priority=60;let Lr=Jt;const Qt=class Qt extends y{constructor(){super(...arguments),this.priority=60,this.consequence=S}when(e,t){const n=[];for(const r of e.named("episode")??[]){const s=r.initiator??r,a=[...s.children??[]].find(f=>f.name==="episodeMarker");if(!a||String(a.raw??"").length<3)continue;const i=e.markers.atMatch(r,f=>f.name==="path",0);if(!i)continue;const o=e.range(r.end,i.end,f=>!f.private&&f.name==="year",0);if(!o||e.range(i.start,i.end,f=>!f.private&&(f.name==="season"||f.name==="episode"&&f.tags?.includes("SxxExx")),0))continue;const c=String(e.inputString??"").slice(r.end,o.start);if(/[a-zA-Z]{2,}/.test(c)){n.push(r),n.includes(s)||n.push(s);for(const f of s.children??[])n.includes(f)||n.push(f)}}return n.length?n:!1}};d(Qt,"EpisodeWordBeforeYearAsTitle"),Qt.priority=60;let $r=Qt;const en=class en extends y{constructor(){super(...arguments),this.priority=-64,this.consequence=[S,H]}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,m=>m.name==="crc32",0),l=e.range(i.start,i.end,m=>m.name==="release_group"&&m.tags?.includes("anime"),0),c=(e.markers.range(i.start,i.end,m=>m.name==="group")??[]).length;if(!o&&!l&&c<3)continue;let f=!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,b=>!b.private)??[];if(!C.some(b=>!["alternative_title","episode_title"].includes(b.name??"")&&!b.tags?.includes("weak-episode"))){r.push(...C),s.push(new P(m.start+1,m.end-1,{name:"episode",value:parseInt(v,10),inputString:n,tags:["anime"]})),f=!0;break}}if(f)continue;const p=e.range(i.start,i.end,m=>m.name==="title",0);if(!p)continue;const h=/^(.*[^\W\d_])[\s._-]+(\d{1,3})$/.exec(n.slice(p.start,p.end));if(!h)continue;const g=p.start+h[1].length+(h[0].length-h[1].length-h[2].length);r.push(p);const x=new P(p.start,p.start+h[1].length,{name:"title",value:B(h[1]),inputString:n});s.push(x),s.push(new P(g,p.end,{name:"episode",value:parseInt(h[2],10),inputString:n,tags:["anime"]}))}return r.length||s.length?[r,s]:!1}};d(en,"AnimeTrailingEpisodeRule"),en.priority=-64;let Tr=en;const tn=class tn extends y{constructor(){super(...arguments),this.priority=40,this.consequence=S}when(e,t){const n=e.inputString??"",r=[],s=d(i=>i.name==="episode"&&!i.private&&(i.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(i.initiator?.name)),"isWeakEp"),a=d(i=>{for(const o of[...i.children??[],i])r.includes(o)||r.push(o);!i.children?.length&&!r.includes(i)&&r.push(i)},"removeGroup");for(const i of e.markers.named("path")??[]){const o=e.range(i.start,i.end,s)??[];if(!o.length)continue;const l=e.range(i.start,i.end,m=>m.name==="episode"&&!m.private&&!s(m)&&!!m.initiator?.children?.named?.("episodeMarker")?.length,0),c=new Map;for(const m of o){const v=m.initiator??m;c.set(v,[...c.get(v)??[],m])}if(l){for(const m of c.keys())a(m);continue}if(c.size<2)continue;const f=d(m=>{let v=0;const C=String(m.raw??"");/^0\d/.test(C)&&(v+=4);let b=m.start-1;for(;b>=0&&(n[b]===" "||n[b]==="."||n[b]==="_");)b--;return n[b]==="-"&&(v+=1),e.markers.atMatch(m,k=>k.name==="group",0)&&(v-=2),v},"score"),p=[...c.keys()].map(m=>[m,f(m)]),h=Math.max(...p.map(([,m])=>m)),g=p.filter(([,m])=>m===h);if(g.length===p.length)continue;const x=new Set(g.flatMap(([m])=>(c.get(m)??[]).map(v=>Number(v.value))));for(const[m,v]of p){if(v>=h)continue;const C=c.get(m)??[];C.length>1||C.some(b=>x.has(Number(b.value)))||a(m)}}return r.length?r:!1}};d(tn,"PreferAnchoredWeakEpisodeRule"),tn.priority=40;let Hr=tn;const nn=class nn extends y{constructor(){super(...arguments),this.priority=32,this.consequence=[S,H]}when(e,t){const n=e.inputString??"",r=[],s=[],a=e.named("season")??[],i=new Set;for(const o of a){const l=o.initiator??o;if(i.has(l))continue;i.add(l);const c=[...l.children??[]],f=c.find(b=>b.name==="seasonMarker");if(!f)continue;const p=String(f.raw??""),h=/^[a-zà-ÿа-я]{3,}$/i.test(p),g=!!e.markers.atMatch(o,b=>b.name==="group",0);if(!h&&!(p.toLowerCase()==="s"&&g)||h&&/s$/i.test(p))continue;const x=c.filter(b=>b.name==="season");if(x.length!==2)continue;const m=c.find(b=>b.name==="seasonSeparator");if(!m||String(m.raw??"").trim()!=="-"||h&&(n[m.start-1]!==" "||n[m.end]!==" "))continue;const v=e.markers.atMatch(o,b=>b.name==="path",0);if(v&&e.range(v.start,v.end,k=>k.name==="other"&&k.value==="Complete",0))continue;const C=new P(x[1].start,x[1].end,{name:"episode",value:x[1].value,inputString:n});r.push(x[1]),s.push(C)}return r.length||s.length?[r,s]:!1}};d(nn,"SeasonWordDashedEpisodeRule"),nn.priority=32;let Fr=nn;const rn=class rn extends y{constructor(){super(...arguments),this.priority=70,this.consequence=[S,H]}when(e,t){const n=[],r=[],s=d(l=>!!(l.tags?.includes("weak-episode")||["weak_episode","weak_duplicate"].includes(l.initiator?.name)),"isWeak"),a=d(l=>{const c=l.initiator??l;n.includes(l)||n.push(l);for(const f of c.children??[])n.includes(f)||n.push(f)},"removeWithParent"),i=[...e],o=i.filter(l=>(l.name==="season"||l.name==="episode")&&l.tags?.includes("numfirst"));for(const l of o){const c=l.initiator??l,f=i.find(g=>{if(g.name!=="season"&&g.name!=="episode"||g.tags?.includes("numfirst")||s(g))return!1;const x=g.initiator??g;return x===c?!1:x.start<c.end&&c.start<x.end});if(!f)continue;const p=i.some(g=>!g.private&&(g.name==="screen_size"||g.name==="year")&&g.start<f.end&&f.start<g.end),h=/^(?:st|nd|rd|th|ª|º|°)/i.test(String(e.inputString??"").slice(l.end,l.end+2));p||h?(a(f),p||r.push(new P(f.start,f.end,{name:"episode",value:f.value,inputString:e.inputString}))):a(l)}return n.length||r.length?[n,r]:!1}};d(rn,"RemoveNumfirstMarkerCollision"),rn.priority=70;let zr=rn;const Ve=class Ve extends y{constructor(){super(...arguments),this.priority=64,this.consequence=[S,new ie("episode_count"),new ie("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,l=>l.name==="episode"||l.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}};d(Ve,"CountValidator"),Ve.priority=64,Ve.consequence=[S,new ie("episode_count"),new ie("season_count")];let Br=Ve;const sn=class sn 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 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 l=(typeof o.named=="function"?o.named("episodeMarker"):[])||[];for(const c of l){const f=(c.rawString||c.raw||c.value||"").toString().toLowerCase();if(n.has(f)){r.push(a);break}}}return r.length>0?r:!1}then(e,t,n){const r=A(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)}};d(sn,"DiscMarkerRule"),sn.priority=128;let Ur=sn;const yi=class yi extends y{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(h=>a.end===h.end))continue;const o=e.inputString||"";let l=a.end-1,c=l;for(;c>a.start&&/\d/.test(o[c-1]);)c--;if(c>=l)continue;const f=o.slice(c,l),p=parseInt(f,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)}}};d(yi,"FixCorruptedGroupBoundaryValues");let Vr=yi;const _i=class _i extends y{constructor(e){super(),this.consequence=H,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=d(o=>{for(const l of a)if(o.start>=l.start&&o.end<=l.end)return l;return null},"getFilepart");for(const o of["season","episode","absolute_episode","disc"]){const l=o==="season"?this.config.season_max_range:this.config.episode_max_range,c=e.named(o,p=>!p.private)||[];if(c.length<2)continue;const f=[...c].sort((p,h)=>p.start-h.start);for(let p=0;p<f.length-1;p++){const h=f[p],g=f[p+1],x=i(h),m=i(g);if(x!==m||!x)continue;const v=typeof h.value=="number"?h.value:parseInt(h.value,10),C=typeof g.value=="number"?g.value:parseInt(g.value,10);if(isNaN(v)||isNaN(C)||C<=v)continue;const b=C-v;if(b<=1||b>l)continue;const k=e.inputString?.slice(h.end,g.start)||"",D=k.replace(/[\s.]/g,"").toLowerCase(),N=D.replace(/[sexp]/gi,"");if(/[-~_]/.test(k)||o==="season"&&D===":"||r.has(D)||r.has(N))for(let w=v+1;w<C;w++){const j=new P(h.start,g.end,{name:o,value:w,inputString:e.inputString,tags:h.tags?[...h.tags]:[]});n.push(j)}}}return n.length>0?n:!1}};d(_i,"RangeExpansionRule");let qr=_i;const an=class an extends y{constructor(){super(...arguments),this.consequence=S,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}};d(an,"RemoveInvalidSeasonRule"),an.priority=64;let Rr=an;const on=class on extends y{constructor(){super(...arguments),this.consequence=S,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),l=i.initiator?.children?.named?.("episodeMarker")||[],f=(Array.isArray(l)?l:[l]).some(h=>{const g=(h.rawString||h.raw||h.value||"").toString().toLowerCase();return g==="e"||g==="ep"});(a&&o?a.value?.toLowerCase?.()!==o.value?.toLowerCase?.():!i.tags?.includes("SxxExx")&&!f)&&(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]}};d(on,"RemoveInvalidEpisodeRule"),on.priority=64;let Wr=on;const cn=class cn extends y{constructor(){super(...arguments),this.consequence=S,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,l=>l.tags?.includes("weak-duplicate"))||[]).slice().reverse(),o={};for(const l of i){const c=l.name??"",f=l.initiator?.pattern??l.pattern??null;f&&(o[c]||(o[c]=new Set),o[c].has(f)?n.push(l):o[c].add(f))}}return n.length>0?n:!1}};d(cn,"RemoveWeakDuplicateRule"),cn.priority=64;let jr=cn;var he;let rc=(he=class extends y{constructor(){super(...arguments),this.consequence=S,this.priority=32}when(e,t){return!1}},d(he,"RemoveUndeterminedLanguagesRule"),he.priority=32,he);const ln=class ln extends y{constructor(){super(...arguments),this.consequence=S,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,c=>c.name==="screen_size");if(Array.isArray(s)?s.length>0:!!s)return!0;const i=e.range?.(r.start,r.end,c=>!c.private&&!c.tags?.includes("weak-language"))||[];if((Array.isArray(i)?i:i?[i]:[]).filter(c=>c.name!=="release_group").length===0){const c=(e.inputString??"").slice(r.start+1,r.end-1).trim();if(c&&!/^\d+$/.test(c))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,c=>c.initiator?.name==="weak_episode")||[],l=e.range?.(i.start,i.end,c=>c.initiator?.name==="weak_duplicate")||[];if(r)o.length>0&&n.push(...l);else if(l.length>0){const c=e.range?.(i.start,i.end,p=>{if(p.name!=="episode"||p.initiator?.name!=="weak_episode")return!1;const h=p.initiator?.children;return h?Array.isArray(h)?h.some(g=>g.name==="episodeSeparator"):typeof h.named=="function"?(h.named("episodeSeparator")||[]).length>0:!1:!1})||[],f=(e.range?.(i.start,i.end,p=>p.tags?.includes("SxxExx")&&!p.private)||[]).length>0;c.length===0&&!f?n.push(...o):c.length>0&&n.push(...l)}}return n.length>0?n:!1}};d(ln,"WeakConflictSolverRule"),ln.priority=128;let Kr=ln;const un=class un extends y{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,g=>g.name==="episode"&&!g.private)||[];if(i.length<2)continue;const o=e.markers?.named?.("group")||[],c=(Array.isArray(o)?o:o?[o]:[]).filter(g=>g.start>=a.start&&g.end<=a.end),f=d(g=>c.some(x=>g.start>=x.start&&g.end<=x.end),"isInGroup"),p=i.filter(f),h=i.filter(g=>!f(g));p.length>0&&h.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)}};d(un,"AbsoluteEpisodeInGroupRule"),un.priority=-1;let Gr=un;const dn=class dn extends y{constructor(){super(...arguments),this.consequence=S,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,c=>!c.private&&c.tags?.includes("SxxExx"))||[];if(Array.isArray(o)?o.length>0:!!o){const c=e.range?.(i.start,i.end,p=>p.tags?.includes("weak-episode"))||[],f=new Map;for(const p of c){const h=p.initiator;f.has(h)||f.set(h,[]),f.get(h).push(p)}for(const p of c){const h=p.initiator,g=p.name==="episode"&&h?.name==="weak_episode",m=(f.get(h)||[]).filter(E=>E.name==="episode").length>1,v=e.inputString||"",C=h?.start??p.start,b=h?.end??p.end,k=C>0?v[C-1]:"",D=b<v.length?v[b]:"",N=(!k||M.includes(k))&&(!D||M.includes(D));g&&N&&m?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)}};d(dn,"RemoveWeakIfSxxExxRule"),dn.priority=64;let Xr=dn;function sc(u){const e=new F({disabled:d(c=>A(c,"container"),"disabled")});e.regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}),e.defaults({name:"container",formatter:d(c=>c.replace(new RegExp(`[${Dt(M)}]`,"g"),""),"formatter"),tags:["extension"],conflictSolver:d((c,f)=>f.name==="source"||f.name==="video_codec"||f.name==="container"&&!f.tags.includes("extension")?f:"__default__","conflictSolver")});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("\\."+L(i,void 0,!0)+"$",{exts:i,tags:["extension","archive"]}),e.regex("\\.r\\d{2}$",{tags:["extension","archive"]}),o.length&&e.regex("\\."+L(o,void 0,!0)+"$",{exts:o,tags:["extension","image"]}),t.length&&e.regex("\\."+L(t,void 0,!0)+"$",{exts:t,tags:["extension","subtitle"]}),n.length&&e.regex("\\."+L(n,void 0,!0)+"$",{exts:n,tags:["extension","info"]}),r.length&&e.regex("\\."+L(r,void 0,!0)+"$",{exts:r,tags:["extension","video"]}),s.length&&e.regex("\\."+L(s,void 0,!0)+"$",{exts:s,tags:["extension","torrent"]}),a.length&&e.regex("\\."+L(a,void 0,!0)+"$",{exts:a,tags:["extension","nzb"]}),e.defaults({clear:!0,name:"container",validator:T,formatter:d(c=>c.toLowerCase(),"formatter"),conflictSolver:d((c,f)=>f.name==="source"||f.name==="video_codec"||f.name==="container"&&f.tags.includes("extension")?c:"__default__","conflictSolver")});const l=t.filter(c=>!["sub","ass"].includes(c));return e.string(...l,{tags:["subtitle"]}),e.string(...r,{tags:["video"]}),e.string(...s,{tags:["torrent"]}),e.string(...a,{tags:["nzb"]}),e}d(sc,"container");function ac(u){const e=u.rip_prefix??"(?P<other>Rip)-?",t=u.rip_suffix??"-?(?P<other>Rip)";function n(a,i="",o=""){return a.map(l=>`${i}(${l})${o}`)}d(n,"buildSourcePattern");function r(a,i){return["other","release_group"].includes(i.name??"")?i:"__default__"}d(r,"demoteOther");const s=new F({disabled:d(a=>A(a,"source"),"disabled")});return s.regexDefaults({flags:"i",abbreviations:[X],privateParent:!0,children:!0}),s.defaults({name:"source",tags:["video-codec-prefix","streaming_service.suffix"],validateAll:!0,validator:{__parent__:wo(ce,le)}}),s.regex(...n(["VHS"],"",q(t)),{value:{source:"VHS",other:"Rip"}}),s.regex(...n(["CAM"],"",q(t)),{value:{source:"Camera",other:"Rip"}}),s.regex(...n(["HD-?CAM"],"",q(t)),{value:{source:"HD Camera",other:"Rip"}}),s.regex(...n(["HQ-?CAM"],"",q(t)),{value:{source:"Camera",other:"Rip"}}),s.regex(...n(["S-?Print"],"",q(t)),{value:{source:"Camera"}}),s.regex(...n(["TELESYNC","TS"],"",q(t)),{value:{source:"Telesync",other:"Rip"},tags:["video-codec-prefix"],overrides:["tags"]}),s.regex(...n(["HD-?TELESYNC","HD-?TS"],"",q(t)),{value:{source:"HD Telesync",other:"Rip"}}),s.regex(...n(["WORKPRINT","WP"]),{value:"Workprint"}),s.regex(...n(["TELECINE","TC"],"",q(t)),{value:{source:"Telecine",other:"Rip"}}),s.regex(...n(["HD-?TELECINE","HD-?TC"],"",q(t)),{value:{source:"HD Telecine",other:"Rip"}}),s.regex(...n(["PPV"],"",q(t)),{value:{source:"Pay-per-view",other:"Rip"}}),s.regex(...n(["SD-?TV"],"",q(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"],"",q(t)),{value:{source:"Digital TV",other:"Rip"}}),s.regex(...n(["DVD"],"",q(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"],"",q(t)),{value:{source:"Laserdisc",other:"Rip"}}),s.regex(...n(["DM"],"",q(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"],"",q(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"],"",q(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)"],"",q(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"],"",q(t)),{value:{source:"HD-DVD",other:"Rip"}}),s.regex(...n(["Blu-?ray","BD","BD[59]","BD25","BD50"],"",q(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"],"",q(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"],"",q(t)),{value:{source:"Satellite",other:"Rip"}}),s.regex(...n(["DSR?","SAT"],"",t),{value:{source:"Satellite",other:"Rip"}}),s.rules(Yr,Zr,Jr),s}d(ac,"source");const fn=class fn extends y{constructor(){super(...arguments),this.consequence=S}enabled(e){return!A(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,l=ce(o),c=e.range(o.start-1,o.start,h=>h.tags?.includes("source-prefix"));if(!l&&!(Array.isArray(c)?c.length>0:c)){o.children?.length>0&&n.push(...o.children.toArray()),n.push(o);continue}const f=le(o),p=e.range(o.end,o.end+1,h=>h.tags?.includes("source-suffix"));!f&&!(Array.isArray(p)?p.length>0:p)&&(o.children?.length>0&&n.push(...o.children.toArray()),n.push(o))}}return n}};d(fn,"ValidateSourcePrefixSuffix"),fn.priority=64;let Yr=fn;const pn=class pn extends y{constructor(){super(...arguments),this.consequence=S}enabled(e){return!A(e,"source")}when(e,t){const n=[],r=d(s=>Array.isArray(s)?s:s?[s]:[],"toArray");for(const s of[e.markers.named("path")].flat().filter(Boolean)){const a=e.range(s.start,s.end,f=>f.name==="source"),i=d(f=>Array.isArray(f)?f.length>0:!!f,"hasText"),o=d((f,p)=>e.holes(f,p,{predicate:d(h=>!!(h.value&&String(h.value).replace(new RegExp(`[${U}]`,"g"),"")),"predicate")}),"textHoles"),l=r(e.range(s.start,s.end,f=>f.name==="container")),c=d(f=>l.some(p=>p.start<=f.start&&p.end>=f.end),"isExtension");for(const f of r(a)){const p=!!f.tags?.includes("weak.source"),h=r(e.range(f.end,s.end,g=>g.name==="source"));if(h.length!==0&&i(o(s.start,f.start))){if(!p){const g=h.filter(m=>!c(m));if(g.length===0||!i(o(f.end,g[0].start))||r(e.range(f.end,g[0].start,m=>!!m.name&&m.name!=="source")).length===0)continue}f.children?.length>0&&n.push(...f.children.toArray()),n.push(f)}}}return n}};d(pn,"ValidateWeakSource"),pn.priority=64;let Zr=pn;const bi=class bi extends y{constructor(){super(...arguments),this.consequence=[S,H]}enabled(e){return!A(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((f,p)=>e.range(f,p,h=>!h.private&&h.name==="other"&&h.value==="Ultra HD")?.[0],"findUltraHd");let l=o(s.start,i.start);if(l){const f=e.holes(l.end,i.start,{predicate:d(h=>!!(h.value&&String(h.value).replace(new RegExp(`[${U}]`,"g"),"")),"predicate")}),p=e.range(l.end,i.start,h=>!h.private&&!["screen_size","color_depth"].includes(h.name??"")&&!(h.name==="other"&&h.tags?.includes("uhdbluray-neighbor")));((Array.isArray(f)?f.length:f?1:0)>0||(Array.isArray(p)?p.length:p?1:0)>0)&&(l=void 0)}if(!l&&(l=o(i.end,s.end),l)){const f=e.holes(i.end,l.start,{predicate:d(h=>!!(h.value&&String(h.value).replace(new RegExp(`[${U}]`,"g"),"")),"predicate")}),p=e.range(i.end,l.start,h=>!h.private&&!["screen_size","color_depth"].includes(h.name??"")&&!(h.name==="other"&&h.tags?.includes("uhdbluray-neighbor")));((Array.isArray(f)?f.length:f?1:0)>0||(Array.isArray(p)?p.length:p?1:0)>0)&&(l=void 0)}if(!l){const f=e.range(s.start,s.end,p=>p.name==="screen_size"&&p.value==="2160p");if(!(Array.isArray(f)?f.length:f))continue}l&&(l.private=!0);const c=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(c)}}return n.length||r.length?[n,r]:!1}};d(bi,"UltraHdBlurayRule");let Jr=bi;function ic(u){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:d(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("(?<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:d(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:d(t=>A(t,"video_api"),"disabled")}),e.defaults({clear:!0,name:"color_depth",validator:T,disabled:d(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(Qr,es),e}d(ic,"videoCodec");const qe=class qe extends y{enabled(e){return!A(e,"video_codec")}when(e,t){const n=[],r=e.named("video_codec"),s=d(i=>Array.isArray(i)?i.length>0:!!i,"hasAny"),a=e.inputString??"";for(const i of r){const o=a[i.start]==="["||a[i.start-1]==="[",l=a[i.end-1]==="]"||a[i.end]==="]";if(!o&&!ce(i)&&!s(e.atIndex(i.start-1,c=>c.tags?.includes("video-codec-prefix")))){n.push(i);continue}if(!l&&!le(i)&&!s(e.atIndex(i.end+1,c=>c.tags?.includes("video-codec-suffix")))){n.push(i);continue}}return n}};d(qe,"ValidateVideoCodec"),qe.priority=64,qe.consequence=S;let Qr=qe;const gn=class gn extends y{enabled(e){return!A(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}};d(gn,"VideoProfileRule"),gn.consequence=S;let es=gn;const Et="re:",eo="import:",to="eval:",no=["regex","string"],xr=new Map,Ct=new Map;function oc(u,e){Ct.set(u,e)}d(oc,"registerFunction");Ct.set("seps_after",le);Ct.set("seps_before",ce);Ct.set("seps_surround",T);const cc={"lambda match, other: other if other.name == 'audio_codec' else '__default__'":d((u,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":d((u,e)=>e.name==="audio_channels"&&!(e.tags??[]).includes("weak-audio_channels")?u: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__'":d((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, 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__'":d((u,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__'")},lc={"lambda match: 0 < match.value < 100":d(u=>typeof u.value=="number"&&u.value>0&&u.value<100,"lambda match: 0 < match.value < 100")};function uc(u,e){if(u.startsWith(eo)){const t=u.slice(eo.length);if(xr.has(t))return xr.get(t);const n=Ct.get(t);return n!==void 0?(xr.set(t,n),n):void 0}if(u.startsWith(to)){const t=u.slice(to.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=cc[u];if(t)return t;const n=lc[u];return n||void 0}return u}d(uc,"processExecutable");const dc={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 fc(u){for(const[e,t]of Object.entries(dc))e in u&&!(t in u)&&(u[t]=u[e],delete u[e]);return u}d(fc,"normalizeCamelCase");function Ao(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]=Ao(u,r);return t}if(e!=null&&typeof e=="string")return uc(e)}return e}d(Ao,"processOption");function pc(u,e,t){const r={...e[Symbol.for("default")]||e.__default__||{}};if(t.startsWith("_")||(r.value=t),typeof u=="string"?u.startsWith(Et)?r.regex=[u.slice(Et.length)]:r.string=[u]:u&&typeof u=="object"&&Object.assign(r,u),"pattern"in r){const s=r.pattern;delete r.pattern,s.startsWith(Et)?r.regex=[s.slice(Et.length)]:r.string=[s]}return r}d(pc,"buildEntryDecl");function gc(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,l]of Object.entries(s))i[o]=Ao(o,l);for(const o of Object.keys(i))i[o]===void 0&&delete i[o];fc(i),e==="regex"?u.regex(...t,i):u.string(...t,i)}d(gc,"loadPatterns");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=pc(a,t,n);for(const o of no){let l=i[o];if(!l)continue;Array.isArray(l)||(l=[l]);const c={...i};for(const p of no)delete c[p];const f={...t};f[Symbol.for("default")]=c,f.__default__=c,gc(u,o,l,f)}}}}d(te,"loadConfigPatterns");function hc(u){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:d(n=>A(n,"audio_codec"),"disabled")}),te(e,u.audio_codec),e.defaults({clear:!0,name:"audio_profile",validator:T,disabled:d(n=>A(n,"audio_profile"),"disabled")}),te(e,u.audio_profile),e.defaults({clear:!0,name:"audio_channels",disabled:d(n=>A(n,"audio_channels"),"disabled")}),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 d(t,"findCompoundAudio"),e.functional(t,{name:"audio_codec",disabled:d(n=>A(n,"audio_codec"),"disabled")}),e.rules(ts,ns,rs,ss,as,is,os,ls,cs),e}d(hc,"audioCodec");const mc={DTS:"Extended Surround","DTS-HD":"Master Audio",AAC:"High Efficiency","Dolby Digital":"EX"},Re=class Re 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 r=mc[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})}}}}};d(Re,"CompoundAudioProfileRule"),Re.priority=128,Re.consequence=H;let ts=Re;const hn=class hn extends y{enabled(e){return!A(e,"audio_profile")}when(e,t){const n=[],r=e.named("audio_profile"),s=d(a=>a&&(!Array.isArray(a)||a.length>0),"hasResult");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,l=>!l.private,0);o&&o.name==="audio_codec"&&o.value===this.codecName&&(i=o)}if(!s(i)){const o=e.next(a,l=>!l.private,0);o&&o.name==="audio_codec"&&o.value===this.codecName&&(i=o)}s(i)||n.push(a)}return n.length>0?n:!1}};d(hn,"AudioProfileRule"),hn.consequence=S;let $e=hn;const wi=class wi extends $e{constructor(){super(...arguments),this.codecName="DTS-HD"}};d(wi,"DtsHDRule");let ns=wi;const Si=class Si extends $e{constructor(){super(...arguments),this.codecName="DTS"}};d(Si,"DtsRule");let rs=Si;const Ai=class Ai extends $e{constructor(){super(...arguments),this.codecName="AAC"}};d(Ai,"AacRule");let ss=Ai;const ki=class ki extends $e{constructor(){super(...arguments),this.codecName="Dolby Digital"}};d(ki,"DolbyDigitalRule");let as=ki;const mn=class mn extends y{enabled(e){return!A(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}};d(mn,"HqConflictRule"),mn.consequence=S;let is=mn;const We=class We extends y{enabled(e){return!A(e,"audio_codec")&&!A(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(!ce(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(!le(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}};d(We,"AudioValidatorRule"),We.priority=64,We.consequence=S;let os=We;const je=class je extends y{enabled(e){return!A(e,"audio_channels")}when(e,t){const n=e.inputString??"",r=[];for(const s of e.named("audio_channels")){const a=s.initiator??s;if(!/^\d[\W_]\d$/.test(n.slice(a.start,a.end)))continue;const i=e.range(a.start-1,a.start,l=>!l.private);if(Array.isArray(i)?i.length:i||!1)continue;const o=e.range(a.end,a.end+2,l=>l.name==="year");(Array.isArray(o)?o.length:o)&&(s.children?.length>0&&r.push(...s.children.toArray()),r.push(s),a!==s&&r.push(a))}return r}};d(je,"RemoveDecimalTitleChannels"),je.priority=128,je.consequence=S;let cs=je;const Ke=class Ke extends y{enabled(e){return!A(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}};d(Ke,"AudioChannelsValidatorRule"),Ke.priority=128,Ke.consequence=S;let ls=Ke;const vc=/^(?<magnitude>\d+(?:[.]\d+)?)(?<units>[^\d]+)?/,vn=class vn{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=vc.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 vn?this.magnitude===e.magnitude&&this.units===e.units:!1}};d(vn,"Quantity");let ue=vn;const xn=class xn extends ue{static parseUnits(e){let t=e;for(const n of M)t=t.split(n).join("");return t.toUpperCase()}static fromstring(e){return ue.fromstring.call(xn,e)}};d(xn,"Size");let us=xn;const yn=class yn extends ue{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 ue.fromstring.call(yn,e)}};d(yn,"BitRate");let ds=yn;const _n=class _n extends ue{static parseUnits(e){return"fps"}static fromstring(e){return ue.fromstring.call(_n,e)}};d(_n,"FrameRate");let Vt=_n;function xc(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 F;i.stringDefaults({ignoreCase:!0}),i.regexDefaults({flags:"i"}),i.defaults({name:"screen_size",validator:T,abbreviations:[X],disabled:d(h=>A(h,"screen_size"),"disabled")});const o=L(r,"frame_rate"),l=L([...e],"height"),c=L([...t],"height"),f="(?:x|\\*|×)",p=`(?:(?<width>\\d{3,4})${f})?`;return i.regex(p+l+"(?<scan_type>i)"+o+"?"),i.regex(p+c+"(?<scan_type>p)"+o+"?"),i.regex(p+c+"(?<scan_type>p)?(?:hd)"),i.regex(p+c+"(?<scan_type>p)?x?"),i.string("4k",{value:"2160p",conflictSolver:d((h,g)=>g.name==="screen_size"?"__default__":h,"conflictSolver")}),i.regex(`(?<width>\\d{3,4})(?:${f}|-${f}-)(?<height>\\d{3,4})(?:up)?`,{conflictSolver:d((h,g)=>g.name==="screen_size"?"__default__":g,"conflictSolver")}),i.regex(o+"-?(?:p|fps)",{name:"frame_rate",formatter:d(h=>Vt.fromstring(h).toString(),"formatter"),disabled:d(h=>A(h,"frame_rate"),"disabled")}),i.rules(new fs(n,s,a),ps,gs),i}d(xc,"screenSize");const bn=class bn extends y{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(!A(t,"frame_rate"))for(const c of r.children.named("frame_rate"))c.formatter=f=>Vt.fromstring(f).toString(),n.push(c);let s=r.children.toDict();if(!("height"in s)){const c=String(r.raw??""),p=/^(\d{3,4})\s*[xX*×]\s*(\d{3,4})(?:up)?$/i.exec(c);if(p)s={width:p[1],height:p[2],scan_type:void 0};else{const g=/^(\d{3,4})([ip])?/i.exec(c);if(g&&g[1])s={height:g[1],scan_type:g[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??""),l=parseFloat(o)/parseFloat(i);if(this.standardHeights.has(i)&&this.minAr<l&&l<this.maxAr?r.value=`${i}${a}`:r.value=`${o}x${i}`,!A(t,"aspect_ratio")&&o&&this.minAr<l&&l<this.maxAr){const c=new P(r.start,r.end,{name:"aspect_ratio",value:Math.round(l*1e3)/1e3,inputString:r.inputString});n.push(c)}}return n}};d(bn,"PostProcessScreenSize"),bn.consequence=H;let fs=bn;const wn=class wn extends y{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}};d(wn,"ScreenSizeOnlyOne"),wn.consequence=S;let ps=wn;const Sn=class Sn extends y{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")??[],l=d(p=>e.markers.atMatch(p,h=>h.name==="group",0),"groupOf"),c=e.range(s.end,r.end,p=>p.name==="video_profile"||p.name==="video_codec",0);c&&e.holes(s.end,c.start,{predicate:d(p=>!!(p.value&&String(p.value).replace(new RegExp(`[${U}]`,"g"),"")),"predicate")}).length===0&&(c.name==="video_profile"||o.length===1&&l(s)===l(c))&&(n.push(...a),i=!0);const f=e.previous(s,p=>["date","source","other","streaming_service"].includes(p.name??""),0);f&&e.holes(f.end,s.start,{predicate:d(p=>!!(p.value&&String(p.value).replace(new RegExp(`[${U}]`,"g"),"")),"predicate")}).length===0&&(n.push(...a),i=!0),i||n.push(s)}return n}};d(Sn,"ResolveScreenSizeConflicts"),Sn.consequence=S;let gs=Sn;const yc=["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 _c(u){const e=new F({disabled:d(l=>A(l,"website"),"disabled")});e.regexDefaults({flags:"i"}).stringDefaults({ignoreCase:!0}),e.defaults({name:"website"});const t=u.tlds||yc,n=u.safe_tlds||["com","org","net"],r=u.safe_subdomains||["www"],s=u.safe_prefixes||[],a=u.prefixes||[];e.regex(`(?:[^a-z0-9]|^)((?:${L(r)}\\.)+(?:[a-z-0-9-]+\\.)+(?:${L(t)}))(?:[^a-z0-9]|$)`,{children:!0}),e.regex(`(?:[^a-z0-9]|^)((?:${L(r)}\\.)*[a-z0-9-]+\\.(?:${L(n)}))(?:[^a-z0-9]|$)`,{children:!0}),e.regex(`(?:[^a-z0-9]|^)((?:${L(r)}\\.)*[a-z0-9-]+\\.(?:${L(s)}\\.)+(?:${L(t)}))(?:[^a-z0-9]|$)`,{children:!0}),e.string(...a,{validator:T,private:!0,tags:["website.prefix"]});const o=class o extends y{constructor(c,f){super(),this.consequence=S,this.safeSubdomains=c,this.safePrefix=f}validFollowers(c){return["season","episode","year"].includes(c.name??"")}when(c){const f=[];for(const p of c.named("website")){let h=!1;for(const g of[...this.safeSubdomains,...this.safePrefix])if(String(p.value??"").toLowerCase().startsWith(g)){h=!0;break}if(!h){const x=c.markers.atMatch(p,b=>b.name==="path",0)?.end??c.inputString?.length??p.end+50,m=c.range(p.end,x,b=>!b.private&&this.validFollowers(b)),v=Array.isArray(m)?m:m?[m]:[];(v.length>0?v[0]:void 0)&&(c.markers.atMatch(p,k=>k.name==="group",0)||f.push(p))}}return f}};d(o,"PreferTitleOverWebsiteWithConfig");let i=o;return e.rules(new i(r,s),hs),e}d(_c,"website");const Ge=class Ge extends y{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,B,M,i=>i.value))&&t.push(n)}return t}};d(Ge,"ValidateWebsitePrefix"),Ge.priority=64,Ge.consequence=S;let hs=Ge;const G="[-/ .]",ro="[-/ .x]",bc=[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})${ro}(\\d{1,2})${G}(\\d{1,2}))(?:$|[^\\d])`,"i"),new RegExp(`(?:^|[^\\d])((\\d{1,2})${G}(\\d{1,2})${ro}(\\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")],so={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}d(ee,"validYear");function wc(u){return u>=1&&u<53}d(wc,"validWeek");function Nt(u){return!isNaN(parseInt(u,10))&&String(parseInt(u,10))===u.replace(/^0+/,"")||u==="0"}d(Nt,"isInt");function Sc(u){const e=u[0],t=u[u.length-1];if(Nt(e)&&ee(parseInt(e.slice(0,4),10)))return!1;if(Nt(t)&&ee(parseInt(t.slice(-4),10)))return!0;if(Nt(e)&&parseInt(e.slice(0,2),10)>31)return!1;if(Nt(t)&&parseInt(t.slice(-2),10)>31)return!0}d(Sc,"guessDayFirst");function Ac(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 l of i){let c,f,p;const h=s.findIndex(g=>so[g.toLowerCase()]!==void 0);if(s.length===3&&h>=0){f=so[s[h].toLowerCase()];const g=s.filter((m,v)=>v!==h).map(m=>parseInt(m.replace(/(st|nd|rd|th)$/i,""),10)),x=g.findIndex(m=>m>=1e3);if(x>=0?(c=g[x],p=g[1-x]):(c=g[1],p=g[0]),f>=1&&f<=12&&p>=1&&p<=31&&ee(c)){const m=Date.UTC(c,f-1,p),v=new Date(m);if(v.getUTCFullYear()===c&&v.getUTCMonth()===f-1&&v.getUTCDate()===p)return v}continue}if(s.length===1){const g=s[0];if(g.length===8)c=parseInt(g.slice(0,4),10),f=parseInt(g.slice(4,6),10),p=parseInt(g.slice(6,8),10);else if(g.length===6){const x=parseInt(g.slice(0,2),10);c=x>50?1900+x:2e3+x,f=parseInt(g.slice(2,4),10),p=parseInt(g.slice(4,6),10)}else continue}else if(s.length===3){const g=s.map(Number);if(o)[c,f,p]=l?[g[0],g[2],g[1]]:[g[0],g[1],g[2]],!ee(c)&&c<100&&(c=c>50?1900+c:2e3+c);else{const x=g.findIndex((m,v)=>s[v].length===4&&ee(m));x===0?[c,f,p]=l?[g[0],g[2],g[1]]:[g[0],g[1],g[2]]:x===2?[c,f,p]=l?[g[2],g[1],g[0]]:[g[2],g[0],g[1]]:(l?[p,f,c]=o?[g[2],g[1],g[0]]:[g[0],g[1],g[2]]:[f,p,c]=o?[g[2],g[0],g[1]]:[g[0],g[1],g[2]],c=c>100?c:c>50?1900+c:2e3+c)}}else continue;if(!(f<1||f>12)&&!(p<1||p>31)&&ee(c))try{const g=Date.UTC(c,f-1,p),x=new Date(g);if(x.getUTCFullYear()===c&&x.getUTCMonth()===f-1&&x.getUTCDate()===p)return x}catch{}}}d(Ac,"tryParseDate");function kc(u,e,t){for(const n of bc){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),l=s[1];if(/^\d\.\d\.\d{4}$/.test(l))continue;let c=t;e&&c===void 0&&(c=!1);const f=c!==void 0;!f&&o.length>0&&(c=Sc(o));const p=c!==void 0?f?[c]:[c,!c]:[void 0];let h;for(const g of p)if(h=Ac(l,o,e,g),h&&ee(h.getUTCFullYear()))break;if(h&&ee(h.getUTCFullYear()))return[a,i,h]}}}d(kc,"searchDate");const An=class An extends y{constructor(){super(...arguments),this.consequence=S}enabled(e){return!A(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 l=e.range(o.start,o.end,h=>h.name==="year"),c=Array.isArray(l)?l:l?[l]:[];if(c.length<=1)continue;const f=[],p=[];for(const h of c)e.markers.atMatch(h,x=>x.name==="group",0)?f.push(h):p.push(h);if(f.length>0&&p.length>0){const h=f[0].start;n.push(...p.filter(g=>g.start<h)),n.push(...f.slice(1))}else f.length===0&&(n.push(p[0]),p.length>2&&n.push(...p.slice(2)))}return n}};d(An,"KeepMarkedYearInFilepart"),An.priority=64;let ms=An;const kn=class kn extends y{constructor(){super(...arguments),this.consequence=S}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,l=>l.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}};d(kn,"RemoveGroupedYearWithSxxExx"),kn.priority=64;let vs=kn;const Dn=class Dn extends y{constructor(){super(...arguments),this.consequence=S}enabled(e){return!A(e,"date")}when(e,t){const n=e.inputString??"",r=[];for(const s of e.named("date")){const a=n[s.start-1],i=n[s.start-2];if(a&&i&&/[.\-_/ ]/.test(a)&&/\d/.test(i)){const o=e.range(s.start-2,s.start-1,l=>!l.private);(Array.isArray(o)?o.length:o)||r.push(s)}}return r}};d(Dn,"RemoveDecimalVersionDate"),Dn.priority=128;let xs=Dn;function Dc(u){const e=new F().defaults({validator:T});e.regex("\\d{4}",{name:"year",formatter:d(r=>parseInt(r,10),"formatter"),disabled:d(r=>A(r,"year"),"disabled"),conflictSolver:d((r,s)=>(s.name==="episode"||s.name==="season")&&s.raw&&r.raw&&s.raw.length<r.raw.length?s:"__default__","conflictSolver"),validator:d(r=>T(r)&&ee(r.value),"validator")});const t=u.week_words;if(t&&t.length>0){const r=L(t)+"-?(\\d{1,2})";e.regex(r,{name:"week",formatter:d(s=>parseInt(s.replace(/\D/g,""),10),"formatter"),children:!0,flags:"i",abbreviations:[X],conflictSolver:d((s,a)=>(a.name==="episode"||a.name==="season")&&a.raw&&s.raw&&a.raw.length<s.raw.length?a:"__default__","conflictSolver"),validator:d(s=>T(s)&&wc(s.value),"validator")})}const n=d((r,s)=>{const a=kc(r,s?.date_year_first,s?.date_day_first);return a?[[a[0],a[1],{value:a[2]}]]:[]},"dateFunctional");return e.functional(n,{name:"date",properties:{date:[null]},disabled:d(r=>A(r,"date"),"disabled"),conflictSolver:d((r,s)=>s.name==="episode"||s.name==="season"||s.name==="crc32"?s:"__default__","conflictSolver")}),e.rules(xs,ms,vs,new ys(u.weekday_words??[])),e}d(Dc,"date");const Di=class Di extends y{constructor(e){super(),this.consequence=S;const t="["+M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"]";this.weekdayRe=new RegExp("(?:^|"+t+")("+L(e.length?e:["\\bnever\\b"])+")"+t+"*$","i")}enabled(e){return!A(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),l=this.weekdayRe.exec(o);if(!l)continue;const c=i+l.index+l[0].indexOf(l[1]),f=e.range(c,s.start,p=>!p.private);(Array.isArray(f)?f.length:f?1:0)>0||r.push([s,c])}return r.length?r:!1}then(e,t,n){for(const[r,s]of t)e.remove(r),r.start=s,e.append(r)}};d(Di,"AbsorbWeekdayPrefix");let ys=Di;function Cc(u){return!u.private&&u.name!=="proper_count"&&u.name!=="title"&&!(u.name==="container"&&u.tags?.includes("extension"))&&!(u.name==="other"&&u.value==="Rip")}d(Cc,"markerComparatorPredicate");function ao(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}d(ao,"markerWeight");function Te(u,e,t=Cc){const n=[...u],r=new Map(n.map((s,a)=>[s,a]));return n.sort((s,a)=>{const i=ao(e,a,t)-ao(e,s,t);return i!==0?i:(r.get(a)??0)-(r.get(s)??0)})}d(Te,"markerSorted");function ko(u){return d(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 c=i.slice(3).replace(/ /g,"-").replace(/-/g,"[\\W_]?");try{o=new RegExp(c,"gi")}catch{continue}}else{const c=i.split(/[\s._-]+/).map(p=>p.replace(/[-[\]{}()*+?.,\\^$|#]/g,"\\$&"));if(c.length===0)continue;const f="(?<![a-zA-Z0-9])"+c.join(`${s}?`)+"(?![a-zA-Z0-9])";try{o=new RegExp(f,"gi")}catch{const p=i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");try{o=new RegExp(p,"gi")}catch{continue}}}let l;for(;(l=o.exec(t))!==null&&(a.push([l.index,l.index+l[0].length,{}]),l[0].length!==0););}return a},"findExpected")}d(ko,"buildExpectedFunction");const _s=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 Mc(u){return u==null?!1:Array.isArray(u)?u.length>0:!0}d(Mc,"hasmatch$1");const Xe=class Xe extends y{constructor(e,t,n){super(),this.consequence=[H,S],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(l=>l.start>=n.start&&l.end<=n.end).filter(l=>!(l.start===n.start&&l.end===n.end)),o=[];for(const l of e){const c=l.crop(i);c&&(Array.isArray(c)?o.push(...c):o.push(c))}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 l=0;l<n.length;l++){const c=n[l];if(!Or.includes(c))continue;const f=l===0||M.includes(n[l-1]),p=l===n.length-1||M.includes(n[l+1]);(f&&p||c==="/")&&r.push(l)}if(r.length===0)return null;const s=d((l,c)=>{let f=l,p=c;for(;f<p&&M.includes(t[f]);)f++;for(;p>f&&M.includes(t[p-1]);)p--;if(f>=p)return null;const h=t.slice(f,p),g=e.formatter?e.formatter(h):h;return new P(f,p,{inputString:t,formatter:e.formatter,value:g})},"createMatch"),a=[];let i=e.start;for(const l of r){const c=e.start+l,f=s(i,c);f&&a.push(f),i=c+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,g=>g.name==="year",0),i=!!a,o=!!t.range(e.start,e.end,g=>g.name==="date",0),l=!!t.range(e.start,e.end,g=>g.tags?.includes("SxxExx")&&!g.private,0),c=t.holes(e.start,e.end,{formatter:wt(B,Ut),ignore:d(g=>{if(this.isIgnored(g)||g.private&&g.tags?.includes("weak-episode"))return!0;if(g.tags?.includes("weak-episode")||g.tags?.includes("weak-duplicate")){const x=g.initiator;if((g.start===e.start||x.start===e.start)&&(i||o||l)||i&&g.start>=e.start&&g.start<e.start+4&&g.end<=e.start+4||a&&g.end<=a.start)return!0;if(g.tags?.includes("weak-duplicate")){const v=g.initiator||g;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:d(g=>!!g.value,"predicate")}),f=Array.isArray(c)?c:c?[c]:[];let p=this.holesProcess(f,t,e);for(const g of p){if(!this.holeFilter(g))continue;if(process.env.DEBUG_TITLE_TRIM){const b=t.inputString??"";console.log(`[trim] hole="${b.slice(g.start,g.end)}" [${g.start},${g.end})`)}const x=t.range(g.start,g.end,b=>this.isIgnored(b)),m=Array.isArray(x)?x:x?[x]:[];if(m.length>0&&m.every(b=>b.name==="language"||b.name==="country")){let k=(t.inputString??"").slice(g.start,g.end);for(const N of m){const E=N.start-g.start;k=k.slice(0,E)+" ".repeat(N.end-N.start)+k.slice(N.end-g.start)}if(![...k].some(N=>!M.includes(N)&&N!==" "))continue}let v=g;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 b=v.end-1;if(C[b]==="."&&b>=2&&/[a-zA-Z0-9]/.test(C[b-1])&&C[b-2]===".")break;v.end--}if(process.env.DEBUG_TITLE_TRIM){const b=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=[${b}]`)}for(;m.length>0;){const b=m[0];if(b.start===v.start){const k=b.name==="country"?!1:this.shouldKeep(v,m,!0);if(process.env.DEBUG_TITLE_TRIM&&console.log(` leading trim: shouldKeep=${k} for "${C.slice(b.start,b.end)}"`),k){let D=!1;for(let N=b.end;N<v.end;N++){const E=C[N];if(Or.includes(E)){D=!0;break}if(!M.includes(E))break}if(!D)break}for(v.start=b.end;v.start<v.end&&M.includes(C[v.start]);)v.start++;m.shift()}else break}for(;m.length>0;){const b=m[m.length-1];if(b.end===v.end){if(b.name==="language"||b.name==="country"){const k=C.slice(v.start,b.start).toLowerCase().split(/[^a-z0-9]+/i).filter(Boolean),D=k[k.length-1];if(D&&_s.has(D)){s.push(b),m.pop();break}}if(b.name==="episode_details"&&b.value==="Special"){const k=t.range(b.end,b.end+10,D=>D.name==="year"&&!D.private,0);if(k&&[...C.slice(b.end,k.start)].every(N=>M.includes(N)))break}if(this.languageDuplicatedAfterHole(b,v.end,t)){s.push(b),m.pop();break}if(this.shouldKeep(v,m,!1)){let k=!0,D=v.end;for(let N=m.length-1;N>=0;N--){const E=m[N];if(![...C.slice(E.end,D)].every(I=>M.includes(I))){k=!1;break}D=E.start}if(!k)break}for(v.end=b.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 b=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&&b&&k.alternatives.every(D=>{const N=String(D.value??"").trim();return N.length>=4||/\s/.test(N)})&&(k=null),k){k.title.name=this.matchName,r.push(k.title);for(const D of k.alternatives)D.name=this.alternativePropertyName,r.push(D)}else v.name=this.matchName,r.push(v)}}const h=r.find(g=>g.name===this.matchName);if(h){const g=t.range(h.start,h.end,m=>m.name==="episode_details"||m.name==="country"||m.name==="language"),x=Array.isArray(g)?g:g?[g]:[];for(const m of x)s.includes(m)||s.push(m)}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=d(p=>p.tags?p.tags.some(h=>h==="weak"||h.startsWith("weak-")):!1,"weakIgnored"),i=this.isIgnored.bind(this),o=d(p=>i(p)||a(p),"combinedIgnore"),l=e.holes(t.start,t.end,{formatter:wt(B,Ut),ignore:o,predicate:d(p=>!!p.value,"predicate")}),c=Array.isArray(l)?l:l?[l]:[],f=this.holesProcess(c,e,t);if(process.env.DEBUG_TITLE){const p=e.inputString??"";console.log(`[_serieNameFilepartMatch] fp="${p.slice(t.start,t.end)}" holeArray=${c.length} processedHoles=${f.length}`),f.forEach((h,g)=>console.log(` hole[${g}]="${p.slice(h.start,h.end)}" value="${h.value}"`))}if(f.length===1&&f[0].value){const p=f[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=Te(i,e),l=this._serieNameFilepart(e,o);let c=null;if(l&&(c=this._serieNameFilepartMatch(e,l,r,s)),process.env.DEBUG_TITLE){const p=e.inputString??"";console.log(`[when] sortedFileparts: ${o.map(h=>`"${p.slice(h.start,h.end)}"`).join(", ")}`),console.log(`[when] serieNameFilepart: ${l?`"${p.slice(l.start,l.end)}"`:"null"}`),console.log(`[when] serieNameMatch: ${c?`"${c.value}"`:"null"}`)}const f=new Set(o.filter(p=>Mc(e.range(p.start,p.end,h=>h.name==="year",0))));for(const p of o){if(f.delete(p),!this.filepartFilter(p))continue;const h=this.checkTitlesInFilepart(p,e,t);if(h.toAppend.length>0||h.toRemove.length>0){if(c){const g=d(x=>Gi(x).replace(/[''`]/g,"").replace(/\.+$/,"").toLowerCase().trim(),"normTitle");for(const x of h.toAppend)g(String(x.value))!==g(String(c.value))&&(x.name="episode_title")}r.push(...h.toAppend),s.push(...h.toRemove);break}}for(const p of f){if(!this.filepartFilter(p))continue;const h=this.checkTitlesInFilepart(p,e,t),g=[];for(const x of h.toAppend){if(x.name!==this.matchName){g.push(x);continue}const m=String(x.value??""),v=d(k=>Gi(k).replace(/[''`]/g,"").toLowerCase(),"norm"),C=r.findIndex(k=>{const D=String(k.value??"");return v(D)===v(m)&&D!==m});if(C!==-1){const k=r[C];if(k.name===this.matchName)k.value=m;else if(k.name===this.alternativePropertyName){k.value=m;const D=r.find(N=>N.name===this.matchName);D&&(D.name=this.alternativePropertyName||"alternative_title",k.name=this.matchName)}continue}r.some(k=>{if(k.name!==this.matchName)return!1;const D=v(String(k.value??"")),N=v(m);return N.startsWith(D+" ")||N.endsWith(" "+D)})||g.push(x)}r.push(...g),s.push(...h.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 S().then(e,r.toRemove,n),new H().then(e,r.toAppend,n)}};d(Xe,"TitleBaseRule"),Xe.priority=0,Xe.properties={};let bs=Xe;const be=class be extends bs{constructor(){super("title",["title"],"alternative_title")}};d(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=[S,Ft]}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,c=>c.name==="path",0);if(!i)continue;const o=e.range(i.start,i.end,c=>c.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 S().then(e,t,n),new Ft(["equivalent-ignore"]).then(e,t,n)}};d(Ye,"PreferTitleWithYear"),Ye.priority=32,Ye.dependency=[qt];let ws=Ye;const Ec=new Set(["the","a","an","le","la","les","l'","el","los","las","il","lo","un","una","der","die","das","de","het","o","os"]),Cn=class Cn extends y{constructor(){super(...arguments),this.consequence=S}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(!Ec.has(String(o.value??"").trim().toLowerCase()))continue;const l=e.markers.atMatch(o,p=>p.name==="path",0);if(!l)continue;const c=e.range(o.end,l.end,p=>!p.private&&["edition","language","country","other","source"].includes(p.name??""),0);if(!c||![...n.slice(o.end,c.start)].every(p=>M.includes(p)))continue;const f=e.range(c.end,l.end,p=>!p.private&&["year","season","episode","date"].includes(p.name??""),0);f&&n.slice(c.end,f.start).replace(/[sexd]/gi,"").split("").some(p=>!M.includes(p))||r.push({title:o,prop:c})}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=B(a.slice(r.start,r.end)),e.append(r)}}};d(Cn,"ExtendLoneArticleTitle"),Cn.priority=-32;let Ss=Cn;const Mn=class Mn extends y{constructor(){super(...arguments),this.consequence=S}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,c=>c.name==="path",0);if(!o||![...n.slice(o.start,i.start)].every(c=>M.includes(c))||["release-group-prefix","streaming_service.prefix","streaming_service.suffix"].some(c=>i.tags?.includes(c))||e.markers.atMatch(i,c=>c.name==="group",0))continue;const l=e.range(i.end,o.end,c=>!c.private&&["year","season","episode","date"].includes(c.name??""),0);l&&(![...n.slice(i.end,l.start)].every(c=>M.includes(c))&&e.range(i.end,l.start,c=>!c.private&&c.value!=null,0)||r.push(i))}return r.length?r:!1}};d(Mn,"CountryAtTitlePosition"),Mn.priority=64;let As=Mn;const En=class En extends y{constructor(){super(...arguments),this.priority=64,this.consequence=S}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}};d(En,"TitleWordAtTitlePosition"),En.priority=64;let ks=En;const Nc=/[\u0370-\u03FF\u0400-\u04FF\u0590-\u05FF\u0600-\u06FF\u0E00-\u0E7F\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF]/,Nn=class Nn extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[S,H]}when(e,t){if(A(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("(?:^|["+U+"])([A-Za-z])").exec(i);if(!o)continue;const l=o.index+o[0].indexOf(o[1]),c=i.slice(0,l);if(!Nc.test(c))continue;let f=c;for(;f.length&&M.includes(f[f.length-1]);)f=f.slice(0,-1);const p=a.start+f.length,h=a.start+l;p<=a.start||(r.push(a),s.push(new P(a.start,p,{name:"alternative_title",value:B(n.slice(a.start,p)),inputString:n})),s.push(new P(h,a.end,{name:"title",tags:["title"],value:B(n.slice(h,a.end)),inputString:n})))}return r.length||s.length?[r,s]:!1}};d(Nn,"SplitOriginalScriptTitle"),Nn.priority=O;let Ds=Nn;const Pn=class Pn extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[S,H]}when(e,t){if(A(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,c=>!c.private&&!!c.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 l=a.end;for(;l>a.start&&B(n.slice(a.start,l)).toLowerCase()!==i[1].toLowerCase();)l--;l<=a.start||s.push(new P(a.start,l,{name:"title",value:B(n.slice(a.start,l)),inputString:n}))}return r.length||s.length?[r,s]:!1}};d(Pn,"TrimSeasonWordFromTitle"),Pn.priority=O;let Cs=Pn;const On=class On extends y{constructor(){super(...arguments),this.priority=O,this.consequence=S}when(e,t){if(A(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,c=>c.name==="title")??[]).sort((c,f)=>c.start-f.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,c=>c.name==="group",0);!o||o.start>=a[1].start||![...n.slice(i.end,o.start)].every(c=>M.includes(c))||!e.range(o.start,o.end,c=>c.name==="release_group"&&!!c.tags?.includes("anime"),0)||r.push(i)}return r.length?r:!1}};d(On,"PreBracketJunkTitle"),On.priority=O;let Ms=On;const In=class In extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[S,H]}when(e,t){if(A(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 l=e.markers.range(a.start,a.end,p=>p.name==="group")??[];if(!l.length)continue;const c=e.range(a.start,a.end,p=>p.name==="release_group",0);let f;for(const p of l){if(c&&p.start<=c.start&&p.end>=c.end)continue;const h=n.slice(p.start+1,p.end-1);if(!/[a-zA-Z]{2,}/.test(h))continue;const g=e.range(p.start,p.end,v=>!v.private&&["episode_title","alternative_title"].includes(v.name??""))??[],x=e.range(p.start,p.end,v=>!v.private&&!["episode_title","alternative_title"].includes(v.name??""))??[];if(g.length&&!x.length){r.push(...g),f=new P(p.start+1,p.end-1,{name:"title",value:B(n.slice(p.start+1,p.end-1)),inputString:n});break}const m=e.holes(p.start+1,p.end-1,{formatter:B,predicate:d(v=>!!v.value,"predicate"),index:0});if(!(!m||!/[a-zA-Z]{3,}/.test(String(m.value??"")))){f=m;break}}if(f){f.name="title",s.push(f);continue}if(c&&c.tags?.includes("anime")){const p=n.slice(a.start,a.end).replace(n.slice(c.start-1>=a.start?c.start-1:c.start,Math.min(c.end+1,a.end)),""),h=e.range(a.start,a.end,x=>!x.private&&x.name!=="release_group"&&x.start>=a.start)??[];/[a-zA-Z]{2,}/.test(p.replace(/\b(mkv|avi|mp4)\b/gi,""))&&h.some(x=>["title","episode_title","alternative_title"].includes(x.name??""))||(r.push(c),s.push(new P(c.start,c.end,{name:"title",value:B(n.slice(c.start,c.end)),inputString:n})))}}return r.length||s.length?[r,s]:!1}};d(In,"BracketedTitleFallback"),In.priority=O;let Es=In;const Ln=class Ln extends y{constructor(){super(...arguments),this.priority=64,this.consequence=S}when(e,t){if(A(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}};d(Ln,"WordNumeralPartAtTitlePosition"),Ln.priority=64;let Ns=Ln;const $n=class $n extends y{constructor(){super(...arguments),this.priority=64,this.consequence=S}when(e,t){if(A(t,"bonus"))return!1;const n=[];for(const r of e.named("bonus")??[]){const s=e.markers.atMatch(r,l=>l.name==="path",0);if(!s||!(e.range(s.start,s.end,l=>l.name==="crc32",0)||e.markers.range(s.start,s.end,l=>l.name==="group"&&l.start===s.start,0)))continue;const i=e.range(r.end,s.end,l=>!l.private&&["episode","season","year","date"].includes(l.name??""),0),o=e.named("bonus_title")??[];!i&&!o.length||(n.push(r),n.push(...o.filter(l=>l.start>=s.start&&l.end<=s.end)))}return n.length?n:!1}};d($n,"BonusAtTitlePositionRule"),$n.priority=64;let Ps=$n;const Tn=class Tn extends y{constructor(){super(...arguments),this.priority=64,this.consequence=S}when(e,t){if(A(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,l=>l.name==="path",0);!a||!e.markers.range(a.start,a.end,l=>l.name==="group"&&l.start===a.start,0)||!e.range(r.end,a.end,l=>!l.private&&["episode","season","year","date"].includes(l.name??""),0)||n.push(r)}return n.length?n:!1}};d(Tn,"LanguageWordInAnimeTitle"),Tn.priority=64;let Os=Tn;const Hn=class Hn extends y{constructor(){super(...arguments),this.consequence=S}when(e,t){const n=e.inputString||"",r=[];for(const s of e.markers.named("path")){const a=e.range(s.start,s.end,c=>!c.private&&!!c.value,0);if(!a)continue;const i=e.range(a.end,s.end,c=>!c.private&&["year","season","episode","date"].includes(c.name??""),0);if(!i){const c=e.range(s.start,s.end,f=>f.name==="title",0);if(a.name==="year"&&a.start===s.start&&!c){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 l=e.range(s.start,s.end,c=>c.name==="title")??[];l.some(c=>c.start<i.end)||l.length&&!o||(r.push(...l),!(a.name!=="year"&&(a.raw??"")===String(a.value??""))&&[...n.slice(s.start,a.start)].every(c=>M.includes(c))&&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:B(r.slice(s.start,s.end)),inputString:r});e.append(a)}}};d(Hn,"PropertyAtTitlePositionAsTitle"),Hn.priority=-48;let Is=Hn;const Fn=class Fn extends y{constructor(){super(...arguments),this.consequence=S}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,c=>c.name==="path",0);if(!o)continue;e.range(o.start,o.end,c=>c.name==="episode"||c.name==="absolute_episode",0)&&s.push(a)}return s.length?s:!1}};d(Fn,"RemoveNumericAlternativeTitle"),Fn.priority=-64;let Ls=Fn;const Ze=class Ze extends y{constructor(){super(...arguments),this.consequence=S}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,h=>h.name==="path",0);if(!o)continue;const l=e.range(o.start,o.end,h=>h.name==="year"),c=Array.isArray(l)?l:l?[l]:[];if(!c.length)continue;const f=Math.max(...c.map(h=>h.end));if(i.start<f)continue;e.range(f,i.start,h=>!h.private&&!!h.value&&!s.has(h.name??""),0)&&a.push(i)}return a.length?a:!1}};d(Ze,"RemoveTailAlternativeTitle"),Ze.priority=O,Ze.dependency=["RenameEpisodeTitleWhenMovieType"];let $s=Ze;const Je=class Je extends y{constructor(){super(...arguments),this.consequence=S}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,c=>c.name==="title"),i=(Array.isArray(a)?a:a?[a]:[]).slice().sort((c,f)=>c.start-f.start);if(i.length<2)continue;const o=i[0],l=String(o.value??"").trim().toLowerCase();if(l){if(_s.has(l)){i.slice(1).some(c=>!_s.has(String(c.value??"").trim().toLowerCase()))&&r.push(o);continue}for(const c of i.slice(1))e.range(o.end,c.start,p=>!p.private&&!!p.value&&!n.has(p.name??""),0)&&r.push(c)}}return r.length?r:!1}};d(Je,"RemoveTailTitle"),Je.priority=O,Je.dependency=["RenameEpisodeTitleWhenMovieType"];let Ts=Je;function Pc(u){const e=new F({disabled:d(n=>A(n,"title"),"disabled")});e.rules(As,ks,Ns,Ps,Os,Ds,qt,ws,Ss,Is,Ls,$s,Ts,Es,Ms,Cs);const t=ko("expected_title");return e.functional(t,{name:"title",tags:["expected","title"],validator:T,formatter:wt(B,Ut),conflictSolver:d((n,r)=>r,"conflictSolver"),disabled:d(n=>!n?.expected_title,"disabled")}),e}d(Pc,"title");function oe(u){return u==null?!1:Array.isArray(u)?u.length>0:!0}d(oe,"hasmatch");const Oc=/^(the|a|an|le|la|les|l'|el|los|las|der|die|das)\s+/i;function io(u){return u.toLowerCase().replace(Oc,"").trim()}d(io,"normalizeTitle");const zn=class zn extends y{constructor(){super(...arguments),this.priority=O,this.consequence=[S,H]}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(h=>h.end<=i.start&&!h.private).sort((h,g)=>h.start-g.start);if(o.length<3)continue;const l=o.slice(1),c=l[0].start,f=n.slice(c,i.end);if(!/^\d{1,3}(-\d{1,3})+$/.test(f))continue;const p=n.slice(o[0].end,c);/^[\s._]+$/.test(p)&&(r.push(...l,i),s.push(new P(c,i.end,{name:"episode_title",value:f,inputString:n})))}return r.length||s.length?[r,s]:!1}};d(zn,"FormationRunEpisodeTitle"),zn.priority=O;let Hs=zn;function Ic(u){const e=new F({disabled:d(t=>A(t,"episode_title"),"disabled")});return e.rules(js,Ks,Gs,Xs,Ys,Zs,Js,Qs,Ws,Rs,Fs,Bs,Us,Vs,zs,qs,Hs,ea),e}d(Ic,"episodeTitle");const Lc=new Set(["ep","eps","episode","episodes","episodio","episodios","cap","capitulo","capitulos","folge","e"]),Bn=class Bn extends y{constructor(){super(...arguments),this.consequence=S}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(!Lc.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}};d(Bn,"RemoveEpisodeMarkerWordTitle"),Bn.priority=O;let Fs=Bn;const Qe=class Qe extends y{constructor(){super(...arguments),this.consequence=S}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,l=>l.name==="container",0);if(o&&(i=n.slice(a.start,o.start)),!!Qe.isHash(i.replace(/[.\s]+$/,"")))for(const l of e.range(a.start,a.end,c=>r.has(c.name??"")))s.push(l)}return s.length?s:!1}};d(Qe,"RemoveHashFilepartJunk"),Qe.priority=O;let zs=Qe;const Un=class Un extends y{constructor(){super(...arguments),this.consequence=S}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}};d(Un,"RemoveEpisodeTitleCoveredByDetailsInGroup"),Un.priority=O;let Bs=Un;const Vn=class Vn extends y{constructor(){super(...arguments),this.consequence=S}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}};d(Vn,"RemoveFansubCreditEpisodeTitle"),Vn.priority=O;let Us=Vn;const qn=class qn extends y{constructor(){super(...arguments),this.consequence=S}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}};d(qn,"RemoveSubtitleDescriptorEpisodeTitle"),qn.priority=O;let Vs=qn;const $c=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=S}when(e,t){const n=[];for(const r of e.markers.named("path")){const s=e.range(r.start,r.end,l=>l.name==="episode_title"),a=(Array.isArray(s)?s:s?[s]:[]).slice().sort((l,c)=>l.start-c.start);if(a.length<2)continue;const i=a[0],o=String(i.value??"").trim().toLowerCase();if(!(!o||$c.has(o)))for(const l of a.slice(1))e.range(i.end,l.start,f=>!f.private&&!!f.value&&!we.TITLEISH.has(f.name??""),0)&&n.push(l)}return n.length?n:!1}};d(we,"RemoveTailEpisodeTitle"),we.priority=O,we.TITLEISH=new Set(["year","title","alternative_title","episode_title","type","episode","season"]);let qs=we;const Se=class Se extends y{constructor(){super(...arguments),this.consequence=S}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=d((l,c)=>!!e.range(l,c,f=>Se.RELEASE_PROPS.has(f.name??""),0),"hasReleaseIn"),o=d((l,c)=>c<=l||[...a.slice(l,c)].every(f=>"[](){} .-_".includes(f)),"onlySeps");for(const l of r){const c=e.markers.atMatch(l,p=>p.name==="group",0);if(!c)continue;let f=i(c.start,c.end);if(!f)for(const p of e.markers.named("group")){if(p.span?.[0]===c.span?.[0])continue;if((p.start>=c.end&&o(c.end,p.start)||p.end<=c.start&&o(p.end,c.start))&&i(p.start,p.end)){f=!0;break}}f&&s.push(l)}return s.length?s:!1}};d(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 Rs=Se;const Rn=class Rn extends y{constructor(){super(...arguments),this.consequence=S}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)}};d(Rn,"NumericEpisodeTitleToEpisode"),Rn.priority=O;let Ws=Rn;const Wn=class Wn extends y{constructor(){super(...arguments),this.consequence=S,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,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 l=e.range(i.end,s.end,m=>!m.private,0);if(!l||!this.nextNames.includes(l.name??""))continue;const c=e.markers.atMatch(i,m=>m.name==="group",0),f=d(m=>!!(m.value&&String(m.value).replace(new RegExp(`[${U}]`,"g"),""))&&c===e.markers.atMatch(m,v=>v.name==="group",0),"hasValueInSameGroup"),p=e.holes(o.end,i.start,{predicate:f}),h=e.holes(i.end,l.start,{predicate:f}),g=oe(p),x=oe(h);!g&&!x||this.affectedIfHolesAfter.includes(i.name??"")&&!x||(n.push(i),i.parent&&n.push(i.parent))}}return n}};d(Wn,"RemoveConflictsWithEpisodeTitle"),Wn.priority=64;let js=Wn;const jn=class jn extends y{when(e,t){const n=e.named("title"),r={};for(const l of n){const c=String(l.value);r[c]=r[c]||[],r[c].push(l)}const s=[];if(Object.keys(r).length<2)return s;const a=new Set(["episode","season","date","year"]),i=d(l=>{const c=e.markers.atMatch(l,h=>h.name==="path",0);if(!c)return;const f=e.range(c.start,l.start,h=>!h.private&&a.has(h.name??"")),p=Array.isArray(f)?f:f?[f]:[];return p.length>0?p[p.length-1]:void 0},"findPrevEpisode"),o=new Set;for(const l of n)i(l)||o.add(io(String(l.value)));for(const l of n)if(i(l)){const f=io(String(l.value));o.has(f)||s.push(l)}return s}then(e,t,n){const r=t;for(const s of r)e.remove(s),s.name="episode_title",e.append(s)}};d(jn,"TitleToEpisodeTitle"),jn.dependency=["TitleFromPosition"];let Ks=jn;const Kn=class Kn extends y{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(c=>M.includes(c))){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)}};d(Kn,"ExtendEpisodeTitleWithDetails"),Kn.dependency=["TitleToEpisodeTitle"];let Gs=Kn;const Gn=class Gn 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=[],r=e.markers.named("path");for(const s of r){if(oe(e.range(s.start,s.end,p=>p.name==="episode_title",0)))continue;const i=oe(e.range(s.start,s.end,p=>p.name==="title",0)),o=oe(e.range(s.start,s.end,p=>p.name==="episode"&&!p.private,0));if(!i&&!o)continue;const l=e.holes(s.start,s.end,{formatter:wt(B,Ut),ignore:d(p=>this.isIgnored(p),"ignore"),predicate:d(p=>!!p.value,"predicate")}),c=Array.isArray(l)?l:l?[l]:[],f=e.inputString||"";for(const p of c){const h=e.markers?.atMatch?.(p,E=>E.name==="group",0);if(h&&e.range(h.start,h.end,$=>($.name==="year"||$.name==="date")&&!$.private,0))continue;const g=d(E=>E.name==="language"||E.name==="country","cropName"),x=e.range(s.start,s.end,E=>g(E)),m=Array.isArray(x)?x:x?[x]:[];let v=0;for(;v++<64;){let E=p.end;for(;E>p.start&&M.includes(f[E-1]);)E--;if(E<=p.start)break;const $=m.find(I=>I.start<=E-1&&I.end>=E);if($&&$.start<p.end)p.end=Math.min(p.end,$.start);else break}for(v=0;v++<64;){let E=p.start;for(;E<p.end&&M.includes(f[E]);)E++;if(E>=p.end)break;const $=m.find(I=>I.start<=E&&I.end>=E+1);if($&&$.end>p.start)p.start=Math.max(p.start,$.end);else break}for(;p.start<p.end&&M.includes(f[p.start]);)p.start++;for(;p.end>p.start&&M.includes(f[p.end-1]);)p.end--;if(p.end<=p.start||!p.value)continue;const C=d(E=>!E.private&&this.previousNames.includes(E.name??""),"prevPred"),b=e.range(s.start,p.start,C),k=Array.isArray(b)?b:b?[b]:[],D=k.length>0?k[k.length-1]:void 0;let N;if(!D){const E=e.range(s.start,p.start,I=>!I.private&&I.name==="crc32"),$=Array.isArray(E)?E:E?[E]:[];N=$.length>0?$[$.length-1]:void 0}!D&&!N||(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)}};d(Gn,"EpisodeTitleFromPosition"),Gn.dependency=["ExtendEpisodeTitleWithDetails"];let Xs=Gn;const Xn=class Xn extends y{constructor(){super(...arguments),this.previousNames=["episode","episode_count","season","season_count","date","title","year"]}when(e,t){if(oe(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,M,0,s=>s.name==="title",0);if(r){const s=e.markers.atMatch(r,x=>x.name==="path",0),a=s?.start??0,i=d(x=>!x.private&&this.previousNames.includes(x.name??""),"prevPred"),o=e.range(a,r.start,i),l=Array.isArray(o)?o:o?[o]:[],c=l.length>0?l[l.length-1]:void 0,f=s?.end??e.inputString?.length??r.end+100,p=c?void 0:e.range(a,f,x=>!x.private&&x.name==="crc32"),h=Array.isArray(p)?p:p?[p]:[],g=h.length>0?h[0]:void 0;if(c||g)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))}};d(Xn,"AlternativeTitleReplace"),Xn.dependency=["EpisodeTitleFromPosition"];let Ys=Xn;const Yn=class Yn 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 r=[];for(const s of n){let a=s.start,i=s.end;const o=e.range(s.start,s.end,c=>this.langNames.has(c.name??""));if(!o||o.length===0)continue;const l=[...o].sort((c,f)=>f.start-c.start);for(const c of l)if(c.start>=a&&c.start<i){const f=s.inputString??"",p=c.end>=i?"":f.slice(c.end,i);if(p===""||[...p].every(h=>M.includes(h))){let h=c.start;for(;h>a&&M.includes(f[h-1]);)h--;h<i&&(i=h)}}(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)}}};d(Yn,"TrimLanguageFromEpisodeTitle"),Yn.dependency=["EpisodeTitleFromPosition","AlternativeTitleReplace"];let Zs=Yn;function Do(u,e,t){const n=u.holes(e,t,{ignore:wo(i=>!!i.tags?.includes("weak-episode"),i=>i.name==="language"||i.name==="country"||i.name==="episode_details"),formatter:B,seps:Or,predicate:d(i=>!!i.value,"predicate")}),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),l=s.raw,c=i.raw;if(o==="-"&&l&&!M.includes(l[l.length-1])&&c&&!M.includes(c[0]))s.end=i.end;else break}return s}d(Do,"parentTitleHole");const Ci=class Ci extends y{constructor(){super(...arguments),this.consequence=new H("title")}when(e,t){if(oe(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,l=>l.name==="season",0)){const l=Do(e,a.start,a.end);if(l)return l}}};d(Ci,"Filepart3EpisodeTitle");let Js=Ci;const Mi=class Mi extends y{constructor(){super(...arguments),this.consequence=new H("title")}when(e,t){if(oe(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,c=>c.name==="season",0)||e.range(r.start,r.end,c=>c.name==="season",0),o=e.named("season"),l=Array.isArray(o)?o.length>0:!!o;if(i||!l){const c=Do(e,s.start,s.end);if(c){const f=e.markers.named("group"),h=(Array.isArray(f)?f:f?[f]:[]).filter(g=>g.start>=s.start&&g.end<=s.end&&!(g.start===s.start&&g.end===s.end));if(h.length>0){const g=c.crop(h),m=(Array.isArray(g)?g:g?[g]:[]).find(v=>v.value);if(m)return m.tags=m.tags||[],m.tags.push("filepart-title"),m}else return c.tags=c.tags||[],c.tags.push("filepart-title"),c}}}}};d(Mi,"Filepart2EpisodeTitle");let Qs=Mi;const et=class et extends y{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)}};d(et,"RenameEpisodeTitleWhenMovieType"),et.priority=O,et.dependency=["TypeProcessor"];let ea=et;const pe=[{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 gr(u){const e=new Map;for(const t of pe){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}d(gr,"buildLookupMap");const Tc=gr("alpha3"),Hc=gr("alpha2"),Fc=gr("name"),zc=gr("opensubtitles"),Bc={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"]},ae=class ae{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 pe)if(e.alpha3===this.alpha3&&e.country===this.country)return e.name;for(const e of pe)if(e.alpha3===this.alpha3&&!e.country)return e.name;return this.alpha3}getAlpha2(){for(const e of pe)if(e.alpha3===this.alpha3&&e.country===this.country)return e.alpha2;for(const e of pe)if(e.alpha3===this.alpha3&&!e.country)return e.alpha2}getOpenSubtitles(){for(const e of pe)if(e.alpha3===this.alpha3&&e.country===this.country)return e.opensubtitles;for(const e of pe)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=Tc.get(t);if(n)return new ae(n.alpha3,n.country,n.script)}static fromAlpha2(e){if(!e)return;const t=e.toLowerCase().trim(),n=Hc.get(t);if(n)return new ae(n.alpha3,n.country,n.script)}static fromName(e){if(!e)return;const t=e.toLowerCase().trim(),n=Fc.get(t);if(n)return new ae(n.alpha3,n.country,n.script)}static fromOpenSubtitles(e){if(!e)return;const t=e.toLowerCase().trim(),n=zc.get(t);if(n)return new ae(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(Bc))for(const s of r)if(s.toLowerCase()===t){const[a,i]=n.split("_");return new ae(a,i)}}equals(e){return this.alpha3===e.alpha3&&this.country===e.country&&this.script===e.script}};d(ae,"Language");let de=ae;const oo=new de("und"),Uc=new de("mul");function*Xa(u){let e=null;for(let t=0;t<=u.length;t++){const n=t<u.length?u[t]:null;n!==null&&!M.includes(n)?e===null&&(e=t):e!==null&&(yield{span:[e,t],value:u.slice(e,t)},e=null)}}d(Xa,"iterWords");const Zn=class Zn{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 Zn(this.start,this.nextWord.end,n,this.inputString,this.nextWord.nextWord)}}};d(Zn,"LanguageWord");let Be=Zn;const Ei=class Ei{constructor(e,t,n,r,s,a,i){const o=e?.allowed_languages||[];this.allowedLanguages=new Set(o.map(l=>l.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",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(oo)?(n.has(o)||n.set(o,new Set),n.get(o).add(i)):i.lang.equals(Uc)?(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=d(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)},"emit");for(const[i,o]of r)if(t.has(i)||!n.has(i))for(const l of o){const c=a(l);c&&(yield c)}for(const[i,o]of n)if(!t.has(i))for(const l of o){const c=a(l);c&&(yield c)}for(const i of t.values())for(const o of i){const l=a(o);l&&(yield l)}}toRebulkMatch(e){const t=e.word,n=t.start,r=t.end,s=e.propertyName;if(e.lang.equals(oo))return[n,r,{name:s,value:t.value.toLowerCase(),formatter:d(i=>new de("und"),"formatter"),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 Xa(e)){const s=new Be(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,l]of n)for(const c of l){if(!r(i,c))continue;let f;const p=s(i,c);if(!p)t&&(Math.abs(t.start-a.end)<=1||Math.abs(a.start-t.end)<=1)&&(f=this.findLanguageMatchForWord(t,o)),!f&&!this.weakAffixes.has(c)&&(f=this.createLanguageMatch(o,new Be(a.start,a.end,"und",a.inputString)));else{let h=a.start,g=a.end;if(a!==e){const x=p.trim();x&&e&&e.value.toLowerCase()===x?(h=e.start,g=e.end):x&&e&&e.nextWord&&e.nextWord.value.toLowerCase()===x?(h=e.nextWord.start,g=e.nextWord.end):x&&t&&(h=t.start,g=t.end)}f=this.createLanguageMatch(o,new Be(h,g,p,a.inputString))}if(f)return f}}}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=de.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}};d(Ei,"LanguageFinder");let ta=Ei;const Ni=class Ni extends y{constructor(){super(...arguments),this.consequence=S,this.properties={subtitle_language:[null]}}enabled(e){return!A(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(([l,c])=>c.start>=i.start&&c.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)}}};d(Ni,"SubtitlePrefixLanguageRule");let St=Ni;const Pi=class Pi extends y{constructor(){super(...arguments),this.dependency=St,this.consequence=S,this.properties={subtitle_language:[null]}}enabled(e){return!A(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,l=>l.name==="language"||l.name==="subtitle_language",0)||e.range?.(a.start,a.end+10,l=>(l.name==="language"||l.name==="subtitle_language")&&l.start>=a.start&&l.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)}};d(Pi,"SubtitleSuffixLanguageRule");let At=Pi;const tt=class tt extends y{constructor(){super(...arguments),this.dependency=At}when(e,t){const n=e.named("container")||[],s=(Array.isArray(n)?n:n?[n]:[]).find(p=>tt.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),l=e.named("language")||[],c=Array.isArray(l)?l:l?[l]:[];let f;return o?f=c.filter(p=>p.start>=o.start&&p.end<=o.end):f=c,f.length>0?f:!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)}};d(tt,"SubtitleExtensionRule"),tt.SUBTITLE_EXTENSIONS=new Set(["srt","sub","smi","ssa","ass","vtt","idx","sup"]);let Rt=tt;const Jn=class Jn extends y{constructor(){super(...arguments),this.consequence=S,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"),l=Array.isArray(o)?o.length>0:!!o,c=e.holes?.(i.start,i.end,{predicate:d(p=>p.value&&[...String(p.value)].some(h=>!M.includes(h)),"predicate")}),f=Array.isArray(c)?c.length>0:!!c;if(!l&&!f)continue}n.push(a)}return n.length>0?n:!1}};d(Jn,"RemoveCommonWordsLanguageRule"),Jn.priority=32;let na=Jn;const Oi=class Oi extends y{constructor(){super(...arguments),this.consequence=S}enabled(e){return A(e,"language")}when(e,t){return e.named("language")||!1}};d(Oi,"RemoveLanguageRule");let ra=Oi;const Qn=class Qn extends y{constructor(){super(...arguments),this.consequence=S,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 de&&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}};d(Qn,"RemoveUndeterminedLanguagesRule"),Qn.priority=32;let sa=Qn;const Ii=class Ii extends y{constructor(){super(...arguments),this.consequence=S,this.dependency=[St,At,Rt]}identity(e){const t=e.value;if(t instanceof de){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}};d(Ii,"DedupLanguageRule");let aa=Ii;function Vc(u,e){const t=u.subtitle_affixes,n=[...t,...u.subtitle_prefixes].sort((c,f)=>f.length-c.length),r=[...t,...u.subtitle_suffixes].sort((c,f)=>f.length-c.length),s=u.language_affixes,a=[...s,...u.language_prefixes].sort((c,f)=>f.length-c.length),i=[...s,...u.language_suffixes].sort((c,f)=>f.length-c.length),o=new Set(u.weak_affixes),l=new F().stringDefaults({ignoreCase:!0}).defaults({validator:T});for(const c of n)l.string(c,{name:"subtitle_language.prefix",ignoreCase:!0,private:!0,validator:T,tags:["release-group-prefix"],disabled:d(f=>A(f,"subtitle_language"),"disabled")});for(const c of r)l.string(c,{name:"subtitle_language.suffix",ignoreCase:!0,private:!0,validator:T,disabled:d(f=>A(f,"subtitle_language"),"disabled")});for(const c of i)l.string(c,{name:"language.suffix",ignoreCase:!0,private:!0,validator:T,tags:["source-suffix"],disabled:d(f=>A(f,"language"),"disabled")});return l.functional((c,f)=>{const p=new ta(f,n,r,a,i,Array.from(o),e);return Array.from(p.find(c))},{properties:{language:[null]},disabled:d(c=>A(c,"language")&&A(c,"subtitle_language"),"disabled")}),l.rules(St,At,Rt,na,ra,sa,aa,ia),l}d(Vc,"language");const er=class er extends y{constructor(){super(...arguments),this.consequence=S}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}};d(er,"RemoveLanguageInsideTitle"),er.priority=O;let ia=er;const qc={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 Rc(u,e){const t=new F({disabled:d(r=>A(r,"country"),"disabled")});t.defaults({name:"country"});function n(r,s){const a=s?.allowed_countries;return new oa(a,e).find(r)}return d(n,"findCountries"),t.functional(n,{conflictSolver:d((r,s)=>s.name!=="language"||!["US","GB"].includes(String(r.value))?r:s,"conflictSolver"),properties:{country:[null]},disabled:d(r=>!r?.allowed_countries,"disabled")}),t}d(Rc,"country");const Li=class Li{constructor(e,t){this.allowedCountries=new Set(e?.map(n=>n.toLowerCase())||[]),this.commonWords=t}find(e){const t=[];for(const n of Xa(e.trim().toLowerCase())){const r=n.value;if(this.commonWords.has(r.toLowerCase()))continue;const s=qc[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}};d(Li,"CountryFinder");let oa=Li;function Wc(u){const e=u.forbidden_names,t=u.ignored_seps,n=M.split("").filter(i=>!t.includes(i)).join("");function r(i){let o=_e(i,n);const l=t.split("").some(p=>o.includes(p)),c=t.split("").some(p=>o.startsWith(p)),f=t.split("").some(p=>o.endsWith(p));!(c&&f)&&!l&&(o=_e(o,t));for(const p of e)o.toLowerCase().startsWith(p)&&o.length>p.length&&M.includes(o[p.length])&&(o=_e(o.slice(p.length),n)),o.toLowerCase().endsWith(p)&&o.length>p.length&&M.includes(o[o.length-p.length-1])&&(o=_e(o.slice(0,o.length-p.length),n));return o=o.replace(/\s*[)\]]\s*$/,p=>{const g=p.trim()===")"?"(":"[";return o.includes(g)?p:""}).trim(),o.replace(/(.+)\)\s*\[(.+)\]/,"$1 $2").trim()}d(r,"cleanGroupname");const s=new F({disabled:d(i=>A(i,"release_group"),"disabled")}),a=ko("expected_group");return s.functional(a,{name:"release_group",tags:["expected"],validator:T,conflictSolver:d(()=>null,"conflictSolver"),disabled:d(i=>!i?.expected_group,"disabled")}),s.rules(new la(r),new ua(r),da,new pa(r),fa,ca)}d(Wc,"releaseGroup");const tr=class tr extends y{constructor(){super(...arguments),this.consequence=S}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}};d(tr,"RemoveSeasonPackReleaseGroup"),tr.priority=O;let ca=tr;const $i=class $i extends y{constructor(e){super(),this.consequence=[S,H],this.valueFormatter=e}isValid(e,t,n,r,s){if(!s){if(String(t.value).length<=1||e.markers.atMatch(t,h=>h.name==="group",0)||e.range(t.start,t.end,h=>h.name==="episode",0))return!1;const l=e.holes(t.end,r,{predicate:d(h=>h.start===t.end,"predicate"),index:0});if(!l)return!1;const f=String(l.raw??"").replace(new RegExp("^["+U+"]+|["+U+"]+$","g"),"");if(t.start===n&&!f.includes(".")&&!f.includes(" ")&&e.range(t.end,r,h=>["season","episode","date"].includes(h.name??"")&&!h.private,0))return!1;const p=l.raw;return p[0]==="-"&&!p.slice(1).includes("-")&&p.includes(".")&&!p.includes(" ")}const a=e.markers.atMatch(t,l=>l.name==="group",0);if(a&&e.atMatch(a,l=>!l.private&&l.span!==t.span))return!1;let i=0,o=t;for(;o;){const l=e.range(n,o.start,p=>!p.private&&!p.tags.includes("expected"),-1);if(!l)break;let f=(e.inputString??"").slice(l.end,o.start);if(!f&&(o.raw??"")[0]==="-"&&(f="-"),o=l,i===0){if(f!=="-")break;i++;continue}if(f===".")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=d(i=>!!(i.tags?.includes("weak-episode")||i.tags?.includes("weak-duplicate")),"ignoreWeak");r?s=e.holes(t,n,{seps:M,index:-1,ignore:a,predicate:d(i=>i.end===n&&!!(i.raw??"").trim()&&(i.raw??"")[0]==="-","predicate")}):s=e.holes(t,n,{seps:M,index:0,ignore:a,predicate:d(i=>i.start===t&&!!(i.raw??"").trim(),"predicate")})}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]}}}};d($i,"DashSeparatedReleaseGroup");let la=$i;const Ae=class Ae 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"],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 Te(e.markers.named("path"),e)){const{start:r,end:s}=n;if(e.named("release_group",l=>l.start>=r&&l.end<=s).length>0)continue;const a=e.named("title",l=>l.start>=r&&l.end<=s),i=d(l=>a.slice(1).includes(l)||l.name==="episode_title"||!!(l.tags?.includes("weak-episode")||l.tags?.includes("weak-duplicate")),"keepOnlyFirstTitle"),o=e.holes(r,s+1,{formatter:d(l=>B(l),"formatter"),ignore:i,predicate:d(l=>!!B(String(l.value??"")),"predicate"),index:-1});if(o){const l=e.markers.atMatch(o,g=>g.name==="group",0);if(l&&String(l.raw??"").startsWith("(")&&(e.range(r,s,x=>x.name==="episode"||x.name==="season")??[]).length>0){const x=e.markers.range(r,s,m=>m.name==="group"&&m.start===r,0);if(x){const m=e.range(x.start,x.end,b=>!b.tags.includes("weak-language"))??[],v=String(x.value??"").replace(new RegExp(`[${U}]`,"g"),"");if((m.length===0||m.every(b=>b.name==="container"&&b.tags?.includes("subtitle")))&&v&&!Le(v))continue}}const c=d(g=>g.start<n.start?!1:!g.private||this.isPreviousMatch(g),"previousMatchFilter"),f=e.previous(o,c,0),p=e.inputString??"",h=String(o.value??"");if(f&&this.isPreviousMatch(f)&&!p.slice(f.end,o.start).replace(new RegExp(`[${U}]`,"g"),"")&&!Le(h.replace(new RegExp(`[${U}]`,"g"),""))){o.name="release_group",o.tags=["scene"],o.formatter=this.valueFormatter;const g=e.markers.atMatch(o,m=>m.name==="group",0);g&&(g.formatter=this.valueFormatter,g.value===o.value&&(o.start=g.start+1,o.end=g.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}};d(Ae,"SceneReleaseGroup"),Ae.dependency=["TitleFromPosition"],Ae.consequence=H,Ae.properties={release_group:[null]};let ua=Ae;const ke=class ke 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 r of Te(e.markers.named("path"),e)){const s=d(i=>{const o=e.range(i.start,i.end,l=>!l.tags.includes("weak-language"));return!!(o.length===0||i.start===r.start&&o.every(l=>l.name==="container"&&l.tags?.includes("subtitle")))},"isGroupEmpty"),a=e.markers.range(r.start,r.end,i=>i.name==="group"&&s(i)&&String(i.value).replace(new RegExp(`[${U}]`,"g"),"")&&!Le(String(i.value).replace(new RegExp(`[${U}]`,"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}};d(ke,"AnimeReleaseGroup"),ke.dependency=["SceneReleaseGroup","TitleFromPosition"],ke.consequence=[S,H],ke.properties={release_group:[null]};let da=ke;const nr=class nr extends y{constructor(){super(...arguments),this.priority=-32,this.consequence=[S,H]}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),l=i[1].length;r.push(a),s.push(new P(a.start,a.start+l,{name:"episode",value:parseInt(i[1],10),inputString:n}));const c=o.indexOf("[");s.push(new P(a.start+c+1,a.end-1,{name:"release_group",value:i[2],inputString:n}))}return r.length||s.length?[r,s]:!1}};d(nr,"NumericPrefixedGroupRule"),nr.priority=-32;let fa=nr;const rr=class rr extends y{constructor(e){super(),this.consequence=[S,H],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,f=>!f.private&&f.name==="episode_title"&&f.value,-1);if(!a||e.range(a.end,s.end,f=>!f.private&&f.span[0]!==f.span[1],0))continue;const o=String(a.raw??a.value);if(/[\s.]/.test(o.trim())||t[a.start-1]!=="-")continue;const l=e.range(s.start,a.start,f=>!f.private,-1);if(!l||!["episode","absolute_episode"].includes(l.name??""))continue;const c=new P(a.start,a.end,{name:"release_group",inputString:t});c.formatter=this.valueFormatter,c.value&&(n.push(a),r.push(c))}return n.length||r.length?[n,r]:!1}};d(rr,"TrailingTokenAfterEpisodeAsReleaseGroup"),rr.dependency=["AnimeReleaseGroup"];let pa=rr;function jc(u){const e=new F({disabled:d(t=>A(t,"streaming_service"),"disabled")});return e.stringDefaults({ignoreCase:!0}).regexDefaults({flags:"i",abbreviations:[X]}),e.defaults({name:"streaming_service",tags:["source-prefix"]}),te(e,u),e.rules(ga),e}d(jc,"streamingService");const nt=class nt extends y{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 m=r[s.end],v=r[s.start-1];if(m&&/[a-z0-9]/i.test(m)||v&&/[a-z0-9]/i.test(v)){t.push(s);continue}}const i=d(m=>!m.private&&m.tags?.includes("streaming_service.suffix"),"suffixPred"),o=d(m=>!m.private&&m.tags?.includes("streaming_service.prefix"),"prefixPred"),l=e.range(s.end,s.end+30,i),c=Array.isArray(l)?l:l?[l]:[],f=c.length>0?c.reduce((m,v)=>m.start<v.start?m:v):void 0,p=e.range(Math.max(0,s.start-30),s.start,o),h=Array.isArray(p)?p:p?[p]:[],g=h.length>0?h.reduce((m,v)=>m.end>v.end?m:v):void 0,x=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=${f?.name}@${f?.start} prevMatch=${g?.name} sepsBefore=${ce(s)} sepsAfter=${le(s)}`),!x){const m=f?e.holes(s.end,f.start,{predicate:d(I=>!!String(I.value).replace(new RegExp(`[${U}]`,"g"),""),"predicate")}):null,v=g?e.holes(g.end,s.start,{predicate:d(I=>!!String(I.value).replace(new RegExp(`[${U}]`,"g"),""),"predicate")}):null,C=20,b=f&&f.start-s.end>C,k=g&&s.start-g.end>C,D=f?e.range(s.end,f.start,I=>I.name!=="streaming_service"&&!I.private&&I.name!=="other"):null,N=g?e.range(g.end,s.start,I=>I.name!=="streaming_service"&&!I.private&&I.name!=="other"):null,E=D&&D.length>0,$=N&&N.length>0;if((!f||b||E||m!==null&&m.length>0||!ce(s))&&(!g||k||$||v!==null&&v.length>0||!le(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",m=>m.value==="Criterion"))}return process.env.DEBUG_SS&&console.log(`[VS.when] returning toRemove.length=${t.length}`),t}};d(nt,"ValidateStreamingService"),nt.priority=128,nt.consequence=S;let ga=nt;function Kc(u){const e=new F({disabled:d(t=>A(t,"other"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"other",validator:T}),te(e,u.other),Qc(e),e.rules(ma,va,xa,ba,wa,Aa,Sa,ka,Da,Ca,Ma,Ea,Pa,Na,ha,ya,_a),e}d(Kc,"other");const Gc={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"},sr=class sr extends y{constructor(){super(...arguments),this.consequence=[S,H]}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,""),l=Gc[o];l&&(t.push(i),n.push(new P(i.start,i.end,{name:"other",value:l,inputString:e.inputString})))}}return t.length?[t,n]:!1}};d(sr,"ImageArtKeywordToOther"),sr.priority=O;let ha=sr;const Xc="(?P<credits_number>\\d+(?:(?![vV]\\d)[^\\W\\d_])?)?",Yc="(?:-?[vV](?P<version>\\d+))?",Zc=Xc+Yc;function Jc(u){const e=/^(\d+)(\w?)$/.exec(u);return e?String(parseInt(e[1],10))+e[2].toLowerCase():u}d(Jc,"formatCreditsNumber");function Qc(u){const e=d((t,n,r)=>{u.regex("(?P<other>"+t+")"+Zc,{flags:r?"i":"",name:"other",children:!0,privateParent:!0,validateAll:!0,validator:{__parent__:T},formatter:{other:d(()=>n,"other"),credits_number:Jc,version:d(s=>parseInt(s,10),"version")},disabled:d(s=>A(s,"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)}d(Qc,"openingEndingCredits");const rt=class rt extends y{constructor(){super(...arguments),this.priority=O,this.consequence=H}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}};d(rt,"AppendCreditless"),rt.priority=O,rt.properties={other:["Creditless"]};let ma=rt;const st=class st extends y{constructor(){super(...arguments),this.priority=O,this.consequence=H}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}};d(st,"AppendOpedEndingCredits"),st.priority=O,st.properties={other:["Ending Credits"]};let va=st;const el="stereo-vr-context",tl=new Set(["Virtual Reality","3D"]),ar=class ar extends y{constructor(){super(...arguments),this.priority=64,this.consequence=S}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(el));if(!a?.length)continue;if(e.range(s.start,s.end,o=>o.name==="other"&&tl.has(String(o.value)))?.length>0)for(const o of a)n.push(...e.range(o.start,o.end,l=>l.name==="streaming_service")??[]);else n.push(...a)}return n.length?n:!1}};d(ar,"ValidateStereoVRContext"),ar.priority=64;let xa=ar;const co="(?<![^\\W_])";function nl(u,e){const t=L(e.completeMarkerWords),n=L(e.seasonWords),r=L(e.completeArticleWords),s="(?:-+(?:\\d+|"+L(e.seasonNumberSeparators,void 0,!0)+"))+-+";function a(i){const o=i.children;return!(!o.named("completeWordsBefore")&&!o.named("completeWordsAfter"))}d(a,"validateComplete"),u.regex(co+`(?P<completeArticle>${r}-)?(?P<completeWordsBefore>${n}-)?`+t+`(?P<completeWordsAfter>-${n})?`,{privateNames:["completeArticle","completeWordsBefore","completeWordsAfter"],value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:d(i=>T(i)&&a(i),"__parent__")}}),u.regex(n+s+"(?P<other>"+t+")",{children:!0,privateParent:!0,validateAll:!0,value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:T}}),u.regex(co+"(?P<completePrefix>"+L(e.completePrefixWords)+"-?)"+t,{privateNames:["completePrefix"],value:{other:"Complete"},tags:["release-group-prefix"],validator:{__parent__:T}})}d(nl,"completeWords");const De=class De extends y{when(e,t){const n=e.named("other",l=>l.value==="Proper");if(!n||n.length===0)return;const r={};for(const l of n)r[So(l.raw)]=l;let s=0,a=null,i=null;for(const l of Object.values(r)){(!a||a>l.start)&&(a=l.start),(!i||i<l.end)&&(i=l.end);const c=l.children.named("proper_count",null,0);c?s+=parseInt(String(c.value),10):l.tags.includes("real")?s+=2:s+=1}const o=new P(a,i,{name:"proper_count"});return o.value=s,[o]}};d(De,"ProperCountRule"),De.priority=O,De.consequence=H,De.properties={proper_count:[null]};let ya=De;const Ce=class Ce extends y{when(e){const t=e.named("other",i=>i.value==="Fix").filter(i=>{const o=So(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]}};d(Ce,"FixCountRule"),Ce.priority=O,Ce.consequence=H,Ce.properties={proper_count:[null]};let _a=Ce;const at=class at extends y{when(e){return e.named("another")}};d(at,"RenameAnotherToOther"),at.priority=32,at.consequence=new ie("other");let ba=at;const it=class it extends y{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(`[${U}]`,"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(`[${U}]`,"g"),""))&&t.push(n)}return t}};d(it,"ValidateHasNeighbor"),it.consequence=S,it.priority=64;let wa=it;const ot=class ot extends y{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(`[${U}]`,"g"),""))&&t.push(n)}return t}};d(ot,"ValidateHasNeighborBefore"),ot.consequence=S,ot.priority=64;let Sa=ot;const ct=class ct extends y{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(`[${U}]`,"g"),""))&&t.push(n)}return t}};d(ct,"ValidateHasNeighborAfter"),ct.consequence=S,ct.priority=64;let Aa=ct;const lt=class lt extends y{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(`[${U}]`,"g"),""))&&t.push(n)}return t}};d(lt,"ValidateScreenerRule"),lt.consequence=S,lt.priority=64;let ka=lt;const ut=class ut extends y{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}};d(ut,"ValidateMuxRule"),ut.consequence=S,ut.priority=64;let Da=ut;const dt=class dt extends y{when(e){return[]}};d(dt,"ValidateHardcodedSubs"),dt.priority=32,dt.consequence=S;let Ca=dt;const ft=class ft extends y{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(le(r)){if(!ce(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(`[${U}]`,"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(`[${U}]`,"g"),"")).length)continue}r.children&&t.push(...r.children),t.push(r)}}return t}};d(ft,"ValidateStreamingServiceNeighbor"),ft.priority=32,ft.consequence=S;let Ma=ft;const pt=class pt extends y{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(`[${U}]`,"g"),"")).length||e.range(r.end,n.end,s=>!["other","container"].includes(s.name??"")).length)&&t.push(r);return t}};d(pt,"ValidateAtEnd"),pt.priority=32,pt.consequence=S;let Ea=pt;const gt=class gt extends y{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,l=>l.name==="path",0)?.end??e.inputString?.length??s.end;(e.range(s.end,i,l=>!l.private&&n.has(l.name??""))??[]).length>0||r.push(s)}return r.length?r:!1}};d(gt,"RemoveTitleCaseAmbiguous"),gt.consequence=S,gt.priority=64;let Na=gt;const ht=class ht extends y{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}};d(ht,"ValidateReal"),ht.consequence=S,ht.priority=64;let Pa=ht;function rl(u){const e=new F({disabled:d(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:d(t=>us.fromstring(t).toString(),"formatter"),tags:["release-group-prefix"]}),e}d(rl,"size");oc("guessit.rules.common.quantity:BitRate.fromstring",u=>ds.fromstring(u).toString());function sl(u){const e=new F({disabled:d(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,u.bit_rate),e.rules(Oa),e}d(sl,"bitRate");const ir=class ir extends y{when(e,t){const n=[],r=[];if(A(t,"audio_bit_rate"))r.push(...e.named("audio_bit_rate"));else{const s=A(t,"video_bit_rate");for(const a of e.named("audio_bit_rate")){const i=e.previous(a,f=>["source","screen_size","video_codec"].includes(f.name??""),0),o=e.inputString??"",l=d((f,p)=>o.slice(f,p).replace(new RegExp(`[${U}]`,"g"),"")==="","onlySepsBetween"),c=i?l(i.end,a.start):!1;if(i&&c){const p=String(a.value).toLowerCase(),h=/kbps$|kbits?$/.test(p),g=e.next(a,x=>x.name==="audio_codec",0);if(g&&l(a.end,g.start)){h||(s?r.push(a):n.push(a));continue}h||(s?r.push(a):n.push(a))}}}return n.length||r.length?[n,r]:!1}};d(ir,"BitRateTypeRule"),ir.consequence=[new ie("video_bit_rate"),S];let Oa=ir;function al(u){const e=new F({disabled:d(t=>A(t,"edition"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"edition",validator:T}),te(e,u.edition),e}d(al,"edition");function il(u){const e=new F({disabled:d(t=>A(t,"cd"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}),te(e,u),e}d(il,"cd");function ol(u){const e=new F({disabled:d(t=>A(t,"bonus"),"disabled")});return e.regexDefaults({name:"bonus",flags:"i"}),te(e,u.bonus),e.rules(Ia,La,$a),e}d(ol,"bonus");const or=class or extends y{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,c=>c.name==="path",0);if(!a)continue;const i=s.parent,o=i?i.start:s.start-1;[...t.slice(a.start,o)].every(c=>M.includes(c))&&(r.push(s),i&&r.push(i))}return r}then(e,t){for(const n of t)e.remove(n)}};d(or,"BonusAtFilepartStartRule"),or.priority=128;let Ia=or;const cr=class cr extends y{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)}};d(cr,"BonusToEpisodeRule"),cr.priority=64;let La=cr;const cl=new Set(["source","video_codec","audio_codec","screen_size","container","release_group","language","country","other","streaming_service","edition","audio_channels","season","date"]),mt=class mt 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 r=e.range(t.end,n.end+1,v=>(v.name==="title"||v.name==="alternative_title"||v.name==="episode_title")&&!v.private,0);if(r&&r.value){const v=e.inputString||"",C=e.range(t.end,n.end+1,V=>V.name==="container"&&!V.private,0),b=C?C.start:n.end;let k=t.end;for(;k<r.start&&/[\s._\-]/.test(v[k]);)k++;let D=r.end;const N=e.range(r.end,b,V=>!V.private&&V.name==="year",0);if(N){const V=v.slice(r.end,N.start),J=v.slice(N.end,b),fe=[...V].every(ne=>/[\s._\-]/.test(ne)),ve=[...J].every(ne=>/[\s._\-]/.test(ne));fe&&ve&&(D=N.end)}const E=v.slice(k,D),$=B(E),I=[r],w=e.range(k,D,V=>!V.private&&V.name!=="bonus"&&V.name!=="container")||[];for(const V of w)I.includes(V)||I.push(V);const j=new P(k,D,{name:"bonus_title",value:$||B(String(r.value)),inputString:v});return{toRemove:I,toAppend:[j]}}const s=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&&cl.has(v.name??""))||[];o.sort((v,C)=>v.start-C.start);let l=i;o.length>0&&(l=o[0].start);let c=t.end;for(;c<l&&/[\s._\-]/.test(s[c]);)c++;let f=l;for(;f>c&&/[\s._\-]/.test(s[f-1]);)f--;if(c>=f)return;const p=s.slice(c,f),h=B(p);if(!h)return;const g=[],x=e.range(c,f,v=>!v.private&&v.name!=="bonus"&&v.name!=="container")||[];for(const v of x)g.push(v);const m=new P(c,f,{name:"bonus_title",value:h,inputString:s});return{toRemove:g,toAppend:[m]}}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)}};d(mt,"BonusTitleRule"),mt.dependency=["TitleFromPosition"],mt.properties={bonus_title:[null]};let $a=mt;function ll(u){const e=new F({disabled:d(t=>A(t,"film"),"disabled")});return e.regexDefaults({flags:"i",abbreviations:[X]}).stringDefaults({ignoreCase:!0}),e.defaults({name:"film",validator:T}),te(e,u.film),e.rules(Ta,Ha),e}d(ll,"film");const lr=class lr extends y{constructor(){super(...arguments),this.consequence=S}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:B,index:0});i&&i.value||(n.push(s),s.parent&&n.push(s.parent))}return n.length?n:!1}};d(lr,"LeadingFilmNumberRule"),lr.consequence=S;let Ta=lr;const vt=class vt 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,s=>s.name==="path",0);if(!n)return;const r=e.holes(n.start,t.start+1,{formatter:B,predicate:d(s=>!!s.value,"predicate"),index:0});if(r&&r.value)return r.name="film_title",r}}};d(vt,"FilmTitleRule"),vt.consequence=H,vt.properties={film_title:[null]};let Ha=vt;function ul(u){const e=new F({disabled:d(a=>A(a,"part"),"disabled")});e.regexDefaults({flags:"i",abbreviations:[X],validator:{__parent__:T}});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 Le(a.raw)?!0:T(a)}return d(s,"validateRoman"),e.regex(`${L(t)}-?(?P<part>${r})`,{prefixes:t,validateAll:!0,privateParent:!0,children:!0,formatter:se,validator:{part:ye(s,a=>0<a.value&&a.value<100)}}),e}d(ul,"part");const dl=0,lo=1,fl=2,pl="[a-zA-Z0-9-]{20,}";function gl(u){const e=[],t=new RegExp(pl,"g");let n;for(;(n=t.exec(u))!==null;){const r=n[0];let s=0,a=0,i=0,o=null,l=lo;for(const p of r){let h;"0123456789".includes(p)?h=dl:/[a-zA-Z]/.test(p)?(h=lo,p!==o&&a++,o=p,i++):h=fl,h!==l&&s++,l=h}const c=s/r.length,f=i>0?a/i:1;if(c>.4&&f>.4){if(/^[sS]\d+[eE]\d+/i.test(r))continue;e.push([n.index,n.index+r.length])}}return e}d(gl,"guessIdnumber");function hl(u){const e=new F({disabled:d(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:d((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:d((t,n)=>["episode","season","crc32"].includes(n.name??"")?n:"__default__","conflictSolver")}),e.functional(gl,{name:"uuid",conflictSolver:d((t,n)=>["episode","season","crc32"].includes(n.name??"")?n:"__default__","conflictSolver")}),e}d(hl,"crc");function ml(u){const e=new F({disabled:d(t=>A(t,"imdb_id"),"disabled")});return e.regexDefaults({flags:"i"}),e.defaults({validator:T}),e.regex("tt\\d{7,8}",{name:"imdb_id",formatter:d(t=>t.toLowerCase(),"formatter")}),e.regex("tmdb(?:id)?[-=]?(?<tmdb_id>\\d{1,9})",{name:"tmdb_id",private_parent:!0,children:!0,formatter:d(t=>parseInt(t,10),"formatter")}),e.regex("tvdb(?:id)?[-=]?(?<tvdb_id>\\d{1,9})",{name:"tvdb_id",private_parent:!0,children:!0,formatter:d(t=>parseInt(t,10),"formatter")}),e}d(ml,"imdb");function vl(u){const e=new F({disabled:d(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:d(t=>parseInt(String(t).replace(/^vol(?:ume)?[-. ]*/i,"").replace(/[v&+].*$/i,""),10),"formatter"),conflictSolver:d((t,n)=>n.name==="episode"||n.name==="season"?n:"__default__","conflictSolver")}),e}d(vl,"volume");const xl={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 yl(u){const e=new F({disabled:d(t=>A(t,"mimetype"),"disabled")});return e.rules(Fa),e}d(yl,"mimetype");const Me=class Me extends y{when(e,t){const r=(e.inputString??"").split(".").pop()?.toLowerCase()||"";return xl[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)}}};d(Me,"Mimetype"),Me.priority=O,Me.dependency=void 0,Me.properties={mimetype:[null]};let Fa=Me;function _l(u,e){u.append(new P(u.inputString?.length??0,u.inputString?.length??0,{name:"type",value:e}))}d(_l,"addType");const Ee=class Ee extends y{constructor(){super(...arguments),this.priority=O,this.consequence=H}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"),l=Array.isArray(r)?r:r?[r]:[],c=Array.isArray(s)?s:s?[s]:[],f=!!(o&&(!Array.isArray(o)||o.length>0)),p=!!(a&&(!Array.isArray(a)||a.length>0)),h=!!(i&&(!Array.isArray(i)||i.length>0));if(l.length>0||c.length>0||h||p){l.length>0&&l.every(z=>z.tags.includes("weak-episode")||z.tags.includes("weak-duplicate"));const D=Array.isArray(o)?o:o?[o]:[],N=D.length>0?D[0].start:1/0,E=c.every(z=>(z.tags.includes("weak-duplicate")||z.tags.includes("weak-episode"))&&z.start<N);c.length;let $=!1;const I=l.filter(z=>z.tags.includes("weak-episode")||z.tags.includes("weak-duplicate"));if(I.length>=3)$=!0;else if(I.length===2){const z=[...I].sort((re,xe)=>re.start-xe.start),K=(e.inputString??"").slice(z[0].end,z[1].start).replace(/[\s._]/g,"");(K==="-"||K==="~"||K.toLowerCase()==="to")&&($=!0)}const w=l.length>0&&!$&&l.every(z=>z.tags.includes("weak-episode")||z.tags.includes("weak-duplicate")),j=c.every(z=>{if(!(z.tags.includes("weak-duplicate")||z.tags.includes("weak-episode")))return!1;if(z.start<N)return!0;const Y=e.inputString??"",K=z.initiator;if(K){const re=K.start??z.start,xe=K.end??z.end,Ui=re>0?Y[re-1]:"",Vi=xe<Y.length?Y[xe]:"";if(Ui&&/[a-zA-Z]/.test(Ui)||Vi&&/[a-zA-Z]/.test(Vi))return!0}return!1}),V=(c.length===0||j)&&!p&&!h,J=e.named("release_group"),fe=Array.isArray(J)?J:J?[J]:[],ve=e.inputString??"",ne=fe.some(z=>(z.start>0?ve[z.start-1]:"")==="[");if(w&&V&&f&&!ne)return{type:"movie",removeWeak:!0};if(l.length===0&&c.length===0&&!p&&h&&f){const z=Array.isArray(i)?i:i?[i]:[],Y=Array.isArray(o)?o:o?[o]:[],K=Y.length>0?Y[0].start:1/0;if(z.some(xe=>xe.start>K))return"episode"}else return"episode"}const g=e.named("other",D=>D.value==="Complete"&&!!(D.children?.named?.("completeWordsBefore")?.length||D.children?.named?.("completeWordsAfter")?.length));if(g&&(!Array.isArray(g)||g.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"),b=e.named("release_group",D=>D.tags.includes("anime"));if(C&&(!Array.isArray(C)||C.length>0)&&b&&(!Array.isArray(b)||b.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 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),l=Array.isArray(o)?o:o?[o]:[];for(const c of l)(c.tags.includes("weak-episode")||c.tags.includes("weak-duplicate"))&&a.push(c)}for(const i of a)e.remove(i)}_l(e,r)}};d(Ee,"TypeProcessor"),Ee.priority=O,Ee.dependency=void 0,Ee.properties={type:["episode","movie"]};let za=Ee;function bl(u){const e=new F({disabled:d(t=>A(t,"type"),"disabled")});return e.rules(za),e}d(bl,"type_");const Co=new Set(["language","subtitle_language"]);function uo(u){if(!Co.has(u.name??""))return!1;const e=u.value;return e==="und"?!0:e&&typeof e=="object"&&"alpha3"in e?e.alpha3==="und":!1}d(uo,"isUndeterminedLang");const ur=class ur extends Q{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)}};d(ur,"EnlargeGroupMatches"),ur.priority=Dr;let Ba=ur;function wl(u,e){return u===e||fo(u)&&!fo(e)||!u.toUpperCase().startsWith(u)&&e===e.toUpperCase()||!u.toUpperCase().startsWith(u)&&u[0]===u[0].toUpperCase()&&e[0]!==e[0].toUpperCase()||po(u)>po(e)?u:e}d(wl,"preferredString");function fo(u){return u.split(" ").every(e=>e.length===0||e[0]===e[0].toUpperCase())}d(fo,"isTitleCase");function po(u){let e=0;for(const t of Xa(u))t.value[0]===t.value[0].toUpperCase()&&t.value[0]!==t.value[0].toLowerCase()&&e++;return e}d(po,"countTitleWords");const xt=class xt extends y{when(e,t){const n=[];for(const r of Te(e.markers.named("path"),e)){const s=e.holes(r.start,r.end,{formatter:B});for(const a of e.names){const i=[...s];for(const o of[...i])for(const l of e.named(a))if(typeof l.value=="string"&&o.value&&typeof o.value=="string"&&o.value.toLowerCase()===l.value.toLowerCase()){if(l.tags.includes("equivalent-ignore"))continue;const c=wl(o.value,l.value);o.value!==c&&(o.value=c),l.value!==c&&(l.value=c),o.name=a,o.tags=["equivalent"],n.push(o);const f=i.indexOf(o);f>-1&&i.splice(f,1)}}}return n}};d(xt,"EquivalentHoles"),xt.priority=O,xt.consequence=H;let Ua=xt;const yt=class yt extends y{constructor(e,t){super(),this.sortFunction=e??Te,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),l=new Set;for(const c of o){const f=c.name??"";if(l.add(f),r.has(f)){const p=s.get(f)??[];if(!p.includes(c.value)){if(f==="episode_title"&&e.range(i.start,i.end,g=>!g.private&&(g.tags?.includes("SxxExx")??!1),0)){const g=e.named(f).filter(x=>x.start<i.start||x.end>i.end);a.push(...g),p.length=0,p.push(c.value),s.set(f,p);continue}if(!uo(c)&&Co.has(f)&&p.every(g=>g==="und"||g&&typeof g=="object"&&"alpha3"in g&&g.alpha3==="und")){const g=a.length>0?[]:e.named(f).filter(x=>uo(x));a.push(...g),p.length=0,p.push(c.value),s.set(f,p);continue}a.push(c)}}else{const p=s.get(f)??[];p.includes(c.value)||(p.push(c.value),s.set(f,p))}}for(const c of l)r.add(c)}return a}};d(yt,"RemoveAmbiguous"),yt.priority=O,yt.consequence=S;let Wt=yt;const go=d(u=>(u.name==="season"||u.name==="episode")&&u.tags.includes("SxxExx"),"sxxExxWeightPredicate"),Ti=class Ti extends Wt{constructor(e){super((t,n)=>Te(t,n,go),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,go);return new Set((Array.isArray(o)?o:[]).map(l=>l.name)).size}),a=Math.max(...s);if(s.filter(i=>i===a).length>1)return[]}return super.when(e,t)}};d(Ti,"RemoveLessSpecificSeasonEpisode");let jt=Ti;const Hi=class Hi extends jt{constructor(){super("season")}};d(Hi,"RemoveLessSpecificSeason");let Va=Hi;const Fi=class Fi extends jt{constructor(){super("episode")}};d(Fi,"RemoveLessSpecificEpisode");let qa=Fi;const _t=class _t extends y{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}};d(_t,"SeasonYear"),_t.priority=O,_t.consequence=H;let Ra=_t;const bt=class bt extends y{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}};d(bt,"YearSeason"),bt.priority=O,bt.consequence=H;let Wa=bt;const dr=class dr extends y{when(e,t){return!1}};d(dr,"Processors"),dr.priority=O;let ja=dr;const fr=class fr extends Q{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&&ze.includes(i[0])&&(i.length<3||!ze.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&&ze.includes(i[i.length-1])&&(i.length<3||!ze.includes(i[i.length-3])))r.rawEnd=r.rawEnd-1;else break}}}};d(fr,"StripSeparators"),fr.priority=O;let Ka=fr;const pr=class pr extends Q{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)}};d(pr,"RemoveInvalidMatches"),pr.priority=O;let Ga=pr;function Sl(u){return new F().rules(Ba,Ua,Va,qa,Wt,Ra,Wa,ja,Ka,Ga)}d(Sl,"processors");function Mo(u){function e(s){return u[s]??{}}d(e,"cfg");const t=new F,n=new Set(u.common_words??[]);t.rebulk(Ro(e("path"))),t.rebulk(Wo(e("groups")??{starting:"([{",ending:")]}"})),t.rebulk(nc(e("episodes"))),t.rebulk(sc(e("container"))),t.rebulk(ac(e("source"))),t.rebulk(ic(e("video_codec"))),t.rebulk(hc(e("audio_codec"))),t.rebulk(xc(e("screen_size"))),t.rebulk(_c(e("website"))),t.rebulk(Dc(e("date"))),t.rebulk(Pc(e("title"))),t.rebulk(Ic(e("episode_title"))),t.rebulk(Vc(e("language"),n)),t.rebulk(Rc(e("country"),n)),t.rebulk(Wc(e("release_group"))),t.rebulk(jc(e("streaming_service")));const r=Kc(e("other"));return e("episodes"),nl(r,{completeMarkerWords:["Complete","Int[ée]grale"],seasonWords:["seasons?","mini-?series?","series?"],completeArticleWords:["The"],completePrefixWords:["L['’]?","Coffret"],seasonNumberSeparators:["&","and"]}),t.rebulk(r),t.rebulk(rl(e("size"))),t.rebulk(sl(e("bit_rate"))),t.rebulk(al(e("edition"))),t.rebulk(il(e("cd"))),t.rebulk(ol(e("bonus"))),t.rebulk(ll(e("film"))),t.rebulk(ul(e("part"))),t.rebulk(hl(e("crc"))),t.rebulk(ml(e("imdb"))),t.rebulk(vl(e("volume"))),t.rebulk(Sl(e("processors"))),t.rebulk(yl(e("mimetype"))),t.rebulk(bl(e("type"))),t.customizeProperties=d(function(a){const i=a.count;return delete a.count,a.season_count=i,a.episode_count=i,a},"customizeProperties"),t}d(Mo,"rebulkBuilder");const Al=["OSS 117","This is Us"],kl=["au","gb","us"],Dl=["ca","cs","de","en","es","fr","he","hi","hu","it","ja","ko","mul","nl","no","pl","pt","ro","ru","sv","te","uk","und"],Cl={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"]}},ho={expected_title:Al,allowed_countries:kl,allowed_languages:Dl,advanced_config:Cl};function Ot(u,e=!1){return u?typeof u=="object"&&!Array.isArray(u)?u:{}:{}}d(Ot,"parseOptions");function Eo(u={}){const e=[];u.noDefaultConfig||e.push(ho);const t=e.length>0?Ne(...e):{};return"advanced_config"in t||(t.advanced_config=ho.advanced_config),t}d(Eo,"loadConfig");function Ne(...u){let e={};if(u.length===0)return e;u[0]&&(e=El(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))Ml(r,s,e)}return e}d(Ne,"mergeOptions");function Ml(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]=Ne(n,e):Array.isArray(e)?t[u]=[...e]:t[u]=e}}d(Ml,"mergeOptionValue");function El(u){return JSON.parse(JSON.stringify(u))}d(El,"deepCopy");const No={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}},zi=class zi extends Error{constructor(e,t,n){const r=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
+ `+r),this.name="GuessItException",this.string=e,this.options=t,n instanceof Error&&(this.cause=n)}};d(zi,"GuessItException");let kt=zi;const Bi=class Bi{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??Mo;let a=r?Ot(e,!0):e??{};const i=d((f,p)=>f.config===p.config&&f.noUserConfig===p.noUserConfig&&f.noDefaultConfig===p.noDefaultConfig,"hasSameConfigProps");let o;this._config===null||this._loadConfigOptions===null||n||!i(this._loadConfigOptions,a)?(o=Eo(a),this._loadConfigOptions=a):o=this._config;const l=Ne(o.advanced_config??{},a.advancedConfig??{});return(n||!this._rebulk||!this._advancedConfig||JSON.stringify(this._advancedConfig)!==JSON.stringify(l))&&(this._advancedConfig=JSON.parse(JSON.stringify(l)),this._rebulk=s(l)),this._config=o,o}guessit(e,t){try{const n=Ot(t,!0),r=this.configure(n,void 0,!1,!1),s=Ne(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 l of["language","subtitle_language"]){const c=o[l];if(!Array.isArray(c))continue;const f=new Set,p=c.filter(h=>{const g=h&&typeof h=="object"&&"alpha3"in h?`${h.alpha3}:${h.country??""}`:String(h);return f.has(g)?!1:(f.add(g),!0)});o[l]=p.length===1?p[0]:p}return(s.outputInputString||s.output_input_string)&&(o.input_string=a.inputString),o}catch(n){throw n instanceof kt?n:new kt(e,typeof t=="object"&&t!==null?t:{},n)}}properties(e){const t=Ot(e,!0),n=this.configure(t,void 0,!1,!1);if(Ne(n,t),!this._rebulk)return{};const r={};for(const i of this._rebulk.effectivePatterns())if(i.properties)for(const[o,l]of Object.entries(i.properties)){r[o]||(r[o]=new Set);for(const c of l)r[o].add(c)}let s={};for(const i of Object.keys(r).sort())s[i]=[...r[i]].sort((o,l)=>String(o).localeCompare(String(l)));const a=this._rebulk;a.customizeProperties&&(s=a.customizeProperties(s));for(const[i,o]of Object.entries(No)){const l=Array.isArray(s[i])?s[i]:[];if(o.enum){const c=new Set([...l,...o.enum]);s[i]=[...c].sort((f,p)=>String(f).localeCompare(String(p)))}else l.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}};d(Bi,"GuessItApi");let Kt=Bi;const Mt=new Kt;function Nl(u,e){return Mt.guessit(u,e)}d(Nl,"guessit");function Pl(u){return Mt.properties(u)}d(Pl,"properties");function Ol(u,e,t=!1){Mt.configure(u,e,t)}d(Ol,"configure");function Il(){Mt.reset()}d(Il,"reset");const Ll="4.8.0",$l=Ll;exports.GUESSIT_SCHEMA=No;exports.GuessItApi=Kt;exports.GuessItException=kt;exports.configure=Ol;exports.defaultApi=Mt;exports.guessit=Nl;exports.loadConfig=Eo;exports.mergeOptions=Ne;exports.parseOptions=Ot;exports.properties=Pl;exports.rebulkBuilder=Mo;exports.reset=Il;exports.version=$l;
5
5
  //# sourceMappingURL=guessit-js.cjs.map