@instantdb/platform 1.0.64 → 1.0.65

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,11 +1,11 @@
1
- (function(b,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(b=typeof globalThis<"u"?globalThis:b||self,N(b.instant={}))})(this,function(b){"use strict";var sc=Object.defineProperty;var lr=b=>{throw TypeError(b)};var ic=(b,N,k)=>N in b?sc(b,N,{enumerable:!0,configurable:!0,writable:!0,value:k}):b[N]=k;var m=(b,N,k)=>ic(b,typeof N!="symbol"?N+"":N,k),Ds=(b,N,k)=>N.has(b)||lr("Cannot "+k);var y=(b,N,k)=>(Ds(b,N,"read from private field"),k?k.call(b):N.get(b)),H=(b,N,k)=>N.has(b)?lr("Cannot add the same private member more than once"):N instanceof WeakSet?N.add(b):N.set(b,k),J=(b,N,k,tt)=>(Ds(b,N,"write to private field"),tt?tt.call(b,k):N.set(b,k),k),ie=(b,N,k)=>(Ds(b,N,"access private method"),k);var se,ft,Xe,Ye,dt,ae,fe,mt,je,Oe,Ze,Qe,et,Vt,pe,ne,$t,qt,zt,_,q;class N extends Error{constructor(s){super(s.message);m(this,"error");m(this,"errorDescription");const e=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,N),this.name="InstantOAuthError",this.error=s.error,this.errorDescription=s.errorDescription}get[Symbol.toStringTag](){return"InstantOAuthError"}}const k={Remove:"remove",Replace:"replace",Add:"add"},tt=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),Pt=Symbol.iterator,he={mutable:"mutable",immutable:"immutable"},Ht={};function st(r,t){return r instanceof Map?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function Ls(r,t){if(t in r){let s=Reflect.getPrototypeOf(r);for(;s;){const e=Reflect.getOwnPropertyDescriptor(s,t);if(e)return e;s=Reflect.getPrototypeOf(s)}}}function Ms(r){return Object.getPrototypeOf(r)===Set.prototype}function Fs(r){return Object.getPrototypeOf(r)===Map.prototype}function re(r){var t;return(t=r.copy)!==null&&t!==void 0?t:r.original}function Kt(r){return!!M(r)}function M(r){return typeof r!="object"?null:r==null?void 0:r[tt]}function Jt(r){var t;const s=M(r);return s?(t=s.copy)!==null&&t!==void 0?t:s.original:r}function Le(r,t){if(!r||typeof r!="object")return!1;let s;return Object.getPrototypeOf(r)===Object.prototype||Array.isArray(r)||r instanceof Map||r instanceof Set||!!(t!=null&&t.mark)&&((s=t.mark(r,he))===he.immutable||typeof s=="function")}function Bs(r,t=[]){if(Object.hasOwnProperty.call(r,"key")){const s=r.parent.copy,e=M(Se(s,r.key));if(e!==null&&(e==null?void 0:e.original)!==r.original)return null;const i=r.parent.type===3,a=i?Array.from(r.parent.setMap.keys()).indexOf(r.key):r.key;if(!(i&&s.size>a||st(s,a)))return null;t.push(a)}if(r.parent)return Bs(r.parent,t);t.reverse();try{ur(r.copy,t)}catch{return null}return t}function it(r){return Array.isArray(r)?1:r instanceof Map?2:r instanceof Set?3:0}function Se(r,t){return it(r)===2?r.get(t):r[t]}function Wt(r,t,s){it(r)===2?r.set(t,s):r[t]=s}function Gt(r,t){const s=M(r);return(s?re(s):r)[t]}function Me(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t}function Fe(r,t){return t?r:[""].concat(r).map(s=>{const e=`${s}`;return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function ur(r,t){for(let s=0;s<t.length-1;s+=1){const e=t[s];if(r=Se(it(r)===3?Array.from(r):r,e),typeof r!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return r}function pr(r){const t=Object.create(Object.getPrototypeOf(r));return Reflect.ownKeys(r).forEach(s=>{let e=Reflect.getOwnPropertyDescriptor(r,s);if(e.enumerable&&e.configurable&&e.writable){t[s]=r[s];return}e.writable||(e.writable=!0,e.configurable=!0),(e.get||e.set)&&(e={configurable:!0,writable:!0,enumerable:e.enumerable,value:r[s]}),Reflect.defineProperty(t,s,e)}),t}const fr=Object.prototype.propertyIsEnumerable;function dr(r,t){let s;if(Array.isArray(r))return Array.prototype.concat.call(r);if(r instanceof Set){if(!Ms(r)){const e=Object.getPrototypeOf(r).constructor;return new e(r.values())}return Set.prototype.difference?Set.prototype.difference.call(r,new Set):new Set(r.values())}else if(r instanceof Map){if(!Fs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(r)}return new Map(r)}else if(t!=null&&t.mark&&(s=t.mark(r,he),s!==void 0)&&s!==he.mutable){if(s===he.immutable)return pr(r);if(typeof s=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return s()}throw new Error(`Unsupported mark result: ${s}`)}else if(typeof r=="object"&&Object.getPrototypeOf(r)===Object.prototype){const e={};return Object.keys(r).forEach(i=>{e[i]=r[i]}),Object.getOwnPropertySymbols(r).forEach(i=>{fr.call(r,i)&&(e[i]=r[i])}),e}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function Q(r){r.copy||(r.copy=dr(r.original,r.options))}function rt(r){if(!Le(r))return Jt(r);if(Array.isArray(r))return r.map(rt);if(r instanceof Map){const s=Array.from(r.entries()).map(([e,i])=>[e,rt(i)]);if(!Fs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(s)}return new Map(s)}if(r instanceof Set){const s=Array.from(r).map(rt);if(!Ms(r)){const e=Object.getPrototypeOf(r).constructor;return new e(s)}return new Set(s)}const t=Object.create(Object.getPrototypeOf(r));for(const s in r)t[s]=rt(r[s]);return t}function bt(r){return Kt(r)?rt(r):r}function de(r){var t;r.assignedMap=(t=r.assignedMap)!==null&&t!==void 0?t:new Map,r.operated||(r.operated=!0,r.parent&&de(r.parent))}function mr(r,t){const s=it(r);if(s===0)Reflect.ownKeys(r).forEach(e=>{t(e,r[e],r)});else if(s===1){let e=0;for(const i of r)t(e,i,r),e+=1}else r.forEach((e,i)=>t(i,e,r))}function Rs(r,t,s){if(Kt(r)||!Le(r,s)||t.has(r)||Object.isFrozen(r))return;const e=r instanceof Set,i=e?new Map:void 0;if(t.add(r),mr(r,(a,n)=>{var o;if(Kt(n)){const c=M(n);Q(c);const h=!((o=c.assignedMap)===null||o===void 0)&&o.size||c.operated?c.copy:c.original;Wt(e?i:r,a,h)}else Rs(n,t,s)}),i){const a=r,n=Array.from(a);a.clear(),n.forEach(o=>{a.add(i.has(o)?i.get(o):o)})}}function yr(r,t){const s=r.type===3?r.setMap:r.copy;r.finalities.revoke.length>1&&r.assignedMap.get(t)&&s&&Rs(Se(s,t),r.finalities.handledSet,r.options)}function Xt(r){r.type===3&&r.copy&&(r.copy.clear(),r.setMap.forEach(t=>{r.copy.add(Jt(t))}))}function Yt(r,t,s,e){if(r.operated&&r.assignedMap&&r.assignedMap.size>0&&!r.finalized){if(s&&e){const a=Bs(r);a&&t(r,a,s,e)}r.finalized=!0}}function Zt(r,t,s,e){const i=M(s);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((a,n)=>{var o;const c=r.type===3?r.setMap:r.copy;if(Me(Se(c,t),s)){let h=i.original;i.copy&&(h=i.copy),Xt(r),Yt(r,e,a,n),r.options.enableAutoFreeze&&(r.options.updatedValues=(o=r.options.updatedValues)!==null&&o!==void 0?o:new WeakMap,r.options.updatedValues.set(h,i.original)),Wt(c,t,h)}}),r.options.enableAutoFreeze&&i.finalities!==r.finalities&&(r.options.enableAutoFreeze=!1)),Le(s,r.options)&&r.finalities.draft.push(()=>{const a=r.type===3?r.setMap:r.copy;Me(Se(a,t),s)&&yr(r,t)})}function xr(r,t,s,e,i){let{original:a,assignedMap:n,options:o}=r,c=r.copy;c.length<a.length&&([a,c]=[c,a],[s,e]=[e,s]);for(let h=0;h<a.length;h+=1)if(n.get(h.toString())&&c[h]!==a[h]){const l=t.concat([h]),u=Fe(l,i);s.push({op:k.Replace,path:u,value:bt(c[h])}),e.push({op:k.Replace,path:u,value:bt(a[h])})}for(let h=a.length;h<c.length;h+=1){const l=t.concat([h]),u=Fe(l,i);s.push({op:k.Add,path:u,value:bt(c[h])})}if(a.length<c.length){const{arrayLengthAssignment:h=!0}=o.enablePatches;if(h){const l=t.concat(["length"]),u=Fe(l,i);e.push({op:k.Replace,path:u,value:a.length})}else for(let l=c.length;a.length<l;l-=1){const u=t.concat([l-1]),f=Fe(u,i);e.push({op:k.Remove,path:f})}}}function Pr({original:r,copy:t,assignedMap:s},e,i,a,n){s.forEach((o,c)=>{const h=Se(r,c),l=bt(Se(t,c)),u=o?st(r,c)?k.Replace:k.Add:k.Remove;if(Me(h,l)&&u===k.Replace)return;const f=e.concat(c),d=Fe(f,n);i.push(u===k.Remove?{op:u,path:d}:{op:u,path:d,value:l}),a.push(u===k.Add?{op:k.Remove,path:d}:u===k.Remove?{op:k.Add,path:d,value:h}:{op:k.Replace,path:d,value:h})})}function br({original:r,copy:t},s,e,i,a){let n=0;r.forEach(o=>{if(!t.has(o)){const c=s.concat([n]),h=Fe(c,a);e.push({op:k.Remove,path:h,value:o}),i.unshift({op:k.Add,path:h,value:o})}n+=1}),n=0,t.forEach(o=>{if(!r.has(o)){const c=s.concat([n]),h=Fe(c,a);e.push({op:k.Add,path:h,value:o}),i.unshift({op:k.Remove,path:h,value:o})}n+=1})}function at(r,t,s,e){const{pathAsArray:i=!0}=r.options.enablePatches;switch(r.type){case 0:case 2:return Pr(r,t,s,e,i);case 1:return xr(r,t,s,e,i);case 3:return br(r,t,s,e,i)}}const gt=(r,t,s=!1)=>{if(typeof r=="object"&&r!==null&&(!Le(r,t)||s))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},Qt={get size(){return re(M(this)).size},has(r){return re(M(this)).has(r)},set(r,t){const s=M(this),e=re(s);return(!e.has(r)||!Me(e.get(r),t))&&(Q(s),de(s),s.assignedMap.set(r,!0),s.copy.set(r,t),Zt(s,r,t,at)),this},delete(r){if(!this.has(r))return!1;const t=M(this);return Q(t),de(t),t.original.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.copy.delete(r),!0},clear(){const r=M(this);if(this.size){Q(r),de(r),r.assignedMap=new Map;for(const[t]of r.original)r.assignedMap.set(t,!1);r.copy.clear()}},forEach(r,t){const s=M(this);re(s).forEach((e,i)=>{r.call(t,this.get(i),i,this)})},get(r){var t,s;const e=M(this),i=re(e).get(r),a=((s=(t=e.options).mark)===null||s===void 0?void 0:s.call(t,i,he))===he.mutable;if(e.options.strict&&gt(i,e.options,a),a||e.finalized||!Le(i,e.options)||i!==e.original.get(r))return i;const n=Ht.createDraft({original:i,parentDraft:e,key:r,finalities:e.finalities,options:e.options});return Q(e),e.copy.set(r,n),n},keys(){return re(M(this)).keys()},values(){const r=this.keys();return{[Pt]:()=>this.values(),next:()=>{const t=r.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const r=this.keys();return{[Pt]:()=>this.entries(),next:()=>{const t=r.next();if(t.done)return t;const s=this.get(t.value);return{done:!1,value:[t.value,s]}}}},[Pt](){return this.entries()}},gr=Reflect.ownKeys(Qt),_s=(r,t,{isValuesIterator:s})=>()=>{var e,i;const a=t.next();if(a.done)return a;const n=a.value;let o=r.setMap.get(n);const c=M(o),h=((i=(e=r.options).mark)===null||i===void 0?void 0:i.call(e,o,he))===he.mutable;if(r.options.strict&&gt(n,r.options,h),!h&&!c&&Le(n,r.options)&&!r.finalized&&r.original.has(n)){const l=Ht.createDraft({original:n,parentDraft:r,key:n,finalities:r.finalities,options:r.options});r.setMap.set(n,l),o=l}else c&&(o=c.proxy);return{done:!1,value:s?o:[o,o]}},wt={get size(){return M(this).setMap.size},has(r){const t=M(this);if(t.setMap.has(r))return!0;Q(t);const s=M(r);return!!(s&&t.setMap.has(s.original))},add(r){const t=M(this);return this.has(r)||(Q(t),de(t),t.assignedMap.set(r,!0),t.setMap.set(r,r),Zt(t,r,r,at)),this},delete(r){if(!this.has(r))return!1;const t=M(this);Q(t),de(t);const s=M(r);return s&&t.setMap.has(s.original)?(t.assignedMap.set(s.original,!1),t.setMap.delete(s.original)):(!s&&t.setMap.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.setMap.delete(r))},clear(){if(!this.size)return;const r=M(this);Q(r),de(r);for(const t of r.original)r.assignedMap.set(t,!1);r.setMap.clear()},values(){const r=M(this);Q(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:_s(r,t,{isValuesIterator:!0})}},entries(){const r=M(this);Q(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:_s(r,t,{isValuesIterator:!1})}},keys(){return this.values()},[Pt](){return this.values()},forEach(r,t){const s=this.values();let e=s.next();for(;!e.done;)r.call(t,e.value,e.value,this),e=s.next()}};Set.prototype.difference&&Object.assign(wt,{intersection(r){return Set.prototype.intersection.call(new Set(this.values()),r)},union(r){return Set.prototype.union.call(new Set(this.values()),r)},difference(r){return Set.prototype.difference.call(new Set(this.values()),r)},symmetricDifference(r){return Set.prototype.symmetricDifference.call(new Set(this.values()),r)},isSubsetOf(r){return Set.prototype.isSubsetOf.call(new Set(this.values()),r)},isSupersetOf(r){return Set.prototype.isSupersetOf.call(new Set(this.values()),r)},isDisjointFrom(r){return Set.prototype.isDisjointFrom.call(new Set(this.values()),r)}});const wr=Reflect.ownKeys(wt),js=new WeakSet,Us={get(r,t,s){var e,i;const a=(e=r.copy)===null||e===void 0?void 0:e[t];if(a&&js.has(a))return a;if(t===tt)return r;let n;if(r.options.mark){const h=t==="size"&&(r.original instanceof Map||r.original instanceof Set)?Reflect.get(r.original,t):Reflect.get(r.original,t,s);if(n=r.options.mark(h,he),n===he.mutable)return r.options.strict&&gt(h,r.options,!0),h}const o=re(r);if(o instanceof Map&&gr.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Qt,"size").get.call(r.proxy);const h=Qt[t];if(h)return h.bind(r.proxy)}if(o instanceof Set&&wr.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(wt,"size").get.call(r.proxy);const h=wt[t];if(h)return h.bind(r.proxy)}if(!st(o,t)){const h=Ls(o,t);return h?"value"in h?h.value:(i=h.get)===null||i===void 0?void 0:i.call(r.proxy):void 0}const c=o[t];if(r.options.strict&&gt(c,r.options),r.finalized||!Le(c,r.options))return c;if(c===Gt(r.original,t)){if(Q(r),r.copy[t]=$s({original:r.original[t],parentDraft:r,key:r.type===1?Number(t):t,finalities:r.finalities,options:r.options}),typeof n=="function"){const h=M(r.copy[t]);return Q(h),de(h),h.copy}return r.copy[t]}return c},set(r,t,s){var e;if(r.type===3||r.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(r.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const a=Ls(re(r),t);if(a!=null&&a.set)return a.set.call(r.proxy,s),!0;const n=Gt(re(r),t),o=M(n);return o&&Me(o.original,s)?(r.copy[t]=s,r.assignedMap=(e=r.assignedMap)!==null&&e!==void 0?e:new Map,r.assignedMap.set(t,!1),!0):(Me(s,n)&&(s!==void 0||st(r.original,t))||(Q(r),de(r),st(r.original,t)&&Me(s,r.original[t])?r.assignedMap.delete(t):r.assignedMap.set(t,!0),r.copy[t]=s,Zt(r,t,s,at)),!0)},has(r,t){return t in re(r)},ownKeys(r){return Reflect.ownKeys(re(r))},getOwnPropertyDescriptor(r,t){const s=re(r),e=Reflect.getOwnPropertyDescriptor(s,t);return e&&{writable:!0,configurable:r.type!==1||t!=="length",enumerable:e.enumerable,value:s[t]}},getPrototypeOf(r){return Reflect.getPrototypeOf(r.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(r,t){var s;return r.type===1?Us.set.call(this,r,t,void 0,r.proxy):(Gt(r.original,t)!==void 0||t in r.original?(Q(r),de(r),r.assignedMap.set(t,!1)):(r.assignedMap=(s=r.assignedMap)!==null&&s!==void 0?s:new Map,r.assignedMap.delete(t)),r.copy&&delete r.copy[t],!0)}};function $s(r){const{original:t,parentDraft:s,key:e,finalities:i,options:a}=r,n=it(t),o={type:n,finalized:!1,parent:s,original:t,copy:null,proxy:null,finalities:i,options:a,setMap:n===3?new Map(t.entries()):void 0};(e||"key"in r)&&(o.key=e);const{proxy:c,revoke:h}=Proxy.revocable(n===1?Object.assign([],o):o,Us);if(i.revoke.push(h),js.add(c),o.proxy=c,s){const l=s;l.finalities.draft.push((u,f)=>{var d,P;const S=M(c);let B=l.type===3?l.setMap:l.copy;const I=Se(B,e),D=M(I);if(D){let z=D.original;D.operated&&(z=Jt(I)),Xt(D),Yt(D,at,u,f),l.options.enableAutoFreeze&&(l.options.updatedValues=(d=l.options.updatedValues)!==null&&d!==void 0?d:new WeakMap,l.options.updatedValues.set(z,D.original)),Wt(B,e,z)}(P=S.callbacks)===null||P===void 0||P.forEach(z=>{z(u,f)})})}else{const l=M(c);l.finalities.draft.push((u,f)=>{Xt(l),Yt(l,at,u,f)})}return c}Ht.createDraft=$s,Object.prototype.constructor.toString();const W=[];for(let r=0;r<256;++r)W.push((r+256).toString(16).slice(1));function Tr(r,t=0){return(W[r[t+0]]+W[r[t+1]]+W[r[t+2]]+W[r[t+3]]+"-"+W[r[t+4]]+W[r[t+5]]+"-"+W[r[t+6]]+W[r[t+7]]+"-"+W[r[t+8]]+W[r[t+9]]+"-"+W[r[t+10]]+W[r[t+11]]+W[r[t+12]]+W[r[t+13]]+W[r[t+14]]+W[r[t+15]]).toLowerCase()}let es;const Ar=new Uint8Array(16);function Sr(){if(!es){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");es=crypto.getRandomValues.bind(crypto)}return es(Ar)}const qs={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ir(r,t,s){var i;if(qs.randomUUID&&!r)return qs.randomUUID();r=r||{};const e=r.random??((i=r.rng)==null?void 0:i.call(r))??Sr();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=e[6]&15|64,e[8]=e[8]&63|128,Tr(e)}function zs(){return Ir()}function Er(r,t){return r.localeCompare(t)}function Cr(){let r=Er;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{r=Intl.Collator("en-US").compare}catch{}return r}Cr();function kr(){const t={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(t))}const Nr=kr();function Tt(r,t,s){const e={__etype:r,__ops:s};return new Proxy(e,{get:(i,a)=>{if(a==="__ops")return s;if(a==="__etype")return r;if(Nr.has(a))return(n,o)=>Tt(r,t,[...s,o?[a,r,t,n,o]:[a,r,t,n]])}})}function vr(r,t){return`lookup__${r}__${JSON.stringify(t)}`}function Or(r){return r.startsWith("lookup__")}function Vs(r){const[t,s,...e]=r.split("__");return[s,JSON.parse(e.join("__"))]}function Dr(r){return new Proxy({__etype:r},{get(t,s){if(s==="lookup")return(i,a)=>Tt(r,Vs(vr(i,a)),[]);if(s==="__etype")return r;const e=s;return Or(e)?Tt(r,Vs(e),[]):Tt(r,e,[])}})}function Lr(){return new Proxy({},{get(r,t){return Dr(t)}})}Lr();class ee extends Error{constructor(s,e,i){super(s);m(this,"hint");m(this,"traceId");this.hint=e,i&&(this.traceId=i);const a=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,a),Error.captureStackTrace&&Error.captureStackTrace(this,ee),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class be extends ee{constructor(s){var a,n;const e=((a=s.body)==null?void 0:a.message)||`API Error (${s.status})`;super(e,s.body.hint,((n=s.body)==null?void 0:n.traceId)||s.body["trace-id"]);m(this,"body");m(this,"status");const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,be),this.name="InstantAPIError",this.status=s.status,this.body=s.body}get[Symbol.toStringTag](){return"InstantAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const me="v1.0.64";class le{constructor(t,s,e,i={indexed:!1,unique:!1}){m(this,"valueType");m(this,"required");m(this,"isIndexed");m(this,"config");m(this,"metadata",{});this.valueType=t,this.required=s,this.isIndexed=e,this.config=i}clientRequired(){return new le(this.valueType,!1,this.isIndexed,this.config)}optional(){return new le(this.valueType,!1,this.isIndexed,this.config)}unique(){return new le(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new le(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class At{constructor(t,s){m(this,"attrs");m(this,"links");this.attrs=t,this.links=s}asType(){return new At(this.attrs,this.links)}}class St{constructor(t,s,e){m(this,"entities");m(this,"links");m(this,"rooms");this.entities=t,this.links=s,this.rooms=e}withRoomSchema(){return new St(this.entities,this.links,{})}}var Hs;(function(r){r.InitialSyncBatch="InitialSyncBatch",r.InitialSyncComplete="InitialSyncComplete",r.LoadFromStorage="LoadFromStorage",r.SyncTransaction="SyncTransaction",r.Error="Error"})(Hs||(Hs={}));function Mr(r,t){return new St(Ks(r,t),t,void 0)}function Fr(r){return new At(r,{})}function Br(){return new le("string",!0,!1)}function Rr(){return new le("number",!0,!1)}function _r(){return new le("boolean",!0,!1)}function jr(){return new le("date",!0,!1)}function Ur(){return new le("json",!0,!1)}function $r(){return new le("json",!0,!1)}function Ks(r,t){var i,a,n,o;const s={fwd:{},rev:{}};for(const c of Object.values(t))(i=s.fwd)[a=c.forward.on]||(i[a]={}),(n=s.rev)[o=c.reverse.on]||(n[o]={}),s.fwd[c.forward.on][c.forward.label]={entityName:c.reverse.on,cardinality:c.forward.has},s.rev[c.reverse.on][c.reverse.label]={entityName:c.forward.on,cardinality:c.reverse.has};return Object.fromEntries(Object.entries(r).map(([c,h])=>[c,new At(h.attrs,{...s.fwd[c],...s.rev[c]})]))}function qr({entities:r,links:t,rooms:s}){const e=t??{},i=s??{};return new St(Ks(r,e),e,i)}const G={graph:Mr,schema:qr,entity:Fr,string:Br,number:Rr,boolean:_r,date:jr,json:Ur,any:$r};function zr(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function Vr(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}Vr(),zr();function Hr(){const r="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._~";let t="";for(const s of crypto.getRandomValues(new Uint8Array(64)))t=t+r[s%r.length];return t}function Kr(r){return crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(r))}function Jr(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Wr(r){return Kr(r).then(t=>Jr(btoa(String.fromCharCode(...Array.from(new Uint8Array(t))))))}function Gr(){const r=Math.min(800,Math.floor(window.outerWidth*.8)),t=Math.min(630,Math.floor(window.outerHeight*.5)),s={width:r,height:t,left:Math.round(window.screenX+(window.outerWidth-r)/2),top:Math.round(window.screenY+(window.outerHeight-t)/8)},e={width:s.width,height:s.height,left:s.left,top:s.top,toolbar:0,scrollbars:1,status:1,resizable:1,menuBar:0,rel:"opener"};return Object.keys(e).map(i=>`${i}=${e[i]}`).join(",")}let Js=null;function Xr({clientId:r,state:t,codeChallenge:s,apiURI:e,redirectUri:i,scopes:a}){const n=new URL(`${e}/platform/oauth/start`);return n.searchParams.set("client_id",r),n.searchParams.set("redirect_uri",i),n.searchParams.set("scope",a.join(" ")),n.searchParams.set("state",t),n.searchParams.set("response_type","code"),n.searchParams.set("code_challenge",s),n.searchParams.set("code_challenge_method","S256"),n.toString()}async function Yr({code:r,clientId:t,verifier:s,apiURI:e,redirectUri:i}){const a=await fetch(`${e}/platform/oauth/token`,{method:"POST",headers:{"Content-type":"application/json","Instant-Platform-Version":me,"Instant-Core-Version":me},body:JSON.stringify({grant_type:"authorization_code",code:r,redirect_uri:i,client_id:t,code_verifier:s})});if(!a.ok){const o=await a.text();let c;try{const h=JSON.parse(o);c={error:h.error,errorDescription:h.error_description,message:`OAuth error: ${h.error||"server_error"}`}}catch{c={error:"server_error",message:"OAuth error: server_error"}}throw new N(c)}const n=await a.json();return{token:n.access_token,expiresAt:new Date(Date.now()+(n.expires_in-30)*1e3)}}function Zr(){if(typeof window>"u")throw new Error("This function may only be used in a browser context.");const r=new URL(window.location.href).searchParams,t=r.get("state"),s=r.get("error"),e=r.get("error_description"),i=r.get("code");if(!t)throw new Error("Invalid redirect. The state param is missing.");const a=new BroadcastChannel(t);return a.addEventListener("message",n=>{n.data.type==="oauth-redirect-window-done"&&window.close()}),a.postMessage({type:"oauth-redirect",state:t,error:s,errorDescription:e,code:i}),()=>{a.close()}}function Qr({clientId:r,apiURI:t,redirectUri:s,scopes:e}){if(typeof window>"u")throw new Error("OAuth flow can only be started on the client.");const i=Js;i&&i.close();const a=crypto.randomUUID(),n=Hr(),o=new BroadcastChannel(a),c=new Promise((l,u)=>{o.addEventListener("message",async f=>{if(f.data.type!=="oauth-redirect")return;const{state:d,error:P,code:S,errorDescription:B}=f.data;if(!(!d||d!==a)){if(S)try{const I=await Yr({clientId:r,code:S,verifier:n,apiURI:t,redirectUri:s});l(I)}catch(I){I instanceof N&&u(I),u(new N({error:"server_error",message:"OAuth error exchanging code for token"}))}else u(typeof P=="string"?new N({error:P,errorDescription:B,message:`OAuth error: ${P}`}):new N({error:"server_error",message:"OAuth error: server_error"}));o.postMessage({type:"oauth-redirect-window-done"})}})}),h=window.open("",`instantdb_oauth_${Math.random()}`.replace(".",""),Gr());return h?(Js=h,Wr(n).then(l=>{const u=Xr({clientId:r,state:a,codeChallenge:l,apiURI:t,redirectUri:s,scopes:e});h.location.href=u}),c.finally(()=>o.close())):Promise.reject({error:"Could not open Auth window"})}class ea{constructor(t){m(this,"redirectUri");m(this,"clientId");m(this,"apiURI");this.redirectUri=t.redirectUri,this.apiURI=t.apiURI??"https://api.instantdb.com",this.clientId=t.clientId}startClientOnlyFlow(t){return Qr({clientId:this.clientId,apiURI:this.apiURI,redirectUri:this.redirectUri,scopes:t})}handleClientRedirect(){return Zr()}}function ta(r,t){if(r==null)return{};var s={};for(var e in r)if({}.hasOwnProperty.call(r,e)){if(t.indexOf(e)!==-1)continue;s[e]=r[e]}return s}class Ie{constructor(t,s,e){m(this,"line");m(this,"column");m(this,"index");this.line=t,this.column=s,this.index=e}}class It{constructor(t,s){m(this,"start");m(this,"end");m(this,"filename");m(this,"identifierName");this.start=t,this.end=s}}function ce(r,t){const{line:s,column:e,index:i}=r;return new Ie(s,e+t,i+t)}const Ws="BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";var sa={ImportMetaOutsideModule:{message:`import.meta may appear only with 'sourceType: "module"'`,code:Ws},ImportOutsideModule:{message:`'import' and 'export' may appear only with 'sourceType: "module"'`,code:Ws}};const Gs={ArrayPattern:"array destructuring pattern",AssignmentExpression:"assignment expression",AssignmentPattern:"assignment expression",ArrowFunctionExpression:"arrow function expression",ConditionalExpression:"conditional expression",CatchClause:"catch clause",ForOfStatement:"for-of statement",ForInStatement:"for-in statement",ForStatement:"for-loop",FormalParameters:"function parameter list",Identifier:"identifier",ImportSpecifier:"import specifier",ImportDefaultSpecifier:"import default specifier",ImportNamespaceSpecifier:"import namespace specifier",ObjectPattern:"object destructuring pattern",ParenthesizedExpression:"parenthesized expression",RestElement:"rest element",UpdateExpression:{true:"prefix operation",false:"postfix operation"},VariableDeclarator:"variable declaration",YieldExpression:"yield expression"},Et=r=>r.type==="UpdateExpression"?Gs.UpdateExpression[`${r.prefix}`]:Gs[r.type];var ia={AccessorIsGenerator:({kind:r})=>`A ${r}ter cannot be a generator.`,ArgumentsInClass:"'arguments' is only allowed in functions and class methods.",AsyncFunctionInSingleStatementContext:"Async functions can only be declared at the top level or inside a block.",AwaitBindingIdentifier:"Can not use 'await' as identifier inside an async function.",AwaitBindingIdentifierInStaticBlock:"Can not use 'await' as identifier inside a static block.",AwaitExpressionFormalParameter:"'await' is not allowed in async function parameters.",AwaitUsingNotInAsyncContext:"'await using' is only allowed within async functions and at the top levels of modules.",AwaitNotInAsyncContext:"'await' is only allowed within async functions and at the top levels of modules.",BadGetterArity:"A 'get' accessor must not have any formal parameters.",BadSetterArity:"A 'set' accessor must have exactly one formal parameter.",BadSetterRestParameter:"A 'set' accessor function argument must not be a rest parameter.",ConstructorClassField:"Classes may not have a field named 'constructor'.",ConstructorClassPrivateField:"Classes may not have a private field named '#constructor'.",ConstructorIsAccessor:"Class constructor may not be an accessor.",ConstructorIsAsync:"Constructor can't be an async function.",ConstructorIsGenerator:"Constructor can't be a generator.",DeclarationMissingInitializer:({kind:r})=>`Missing initializer in ${r} declaration.`,DecoratorArgumentsOutsideParentheses:"Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",DecoratorBeforeExport:"Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",DecoratorsBeforeAfterExport:"Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",DecoratorConstructor:"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",DecoratorExportClass:"Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",DecoratorSemicolon:"Decorators must not be followed by a semicolon.",DecoratorStaticBlock:"Decorators can't be used with a static block.",DeferImportRequiresNamespace:'Only `import defer * as x from "./module"` is valid.',DeletePrivateField:"Deleting a private field is not allowed.",DestructureNamedImport:"ES2015 named imports do not destructure. Use another statement for destructuring after the import.",DuplicateConstructor:"Duplicate constructor in the same class.",DuplicateDefaultExport:"Only one default export allowed per module.",DuplicateExport:({exportName:r})=>`\`${r}\` has already been exported. Exported identifiers must be unique.`,DuplicateProto:"Redefinition of __proto__ property.",DuplicateRegExpFlags:"Duplicate regular expression flag.",ElementAfterRest:"Rest element must be last element.",EscapedCharNotAnIdentifier:"Invalid Unicode escape.",ExportBindingIsString:({localName:r,exportName:t})=>`A string literal cannot be used as an exported binding without \`from\`.
1
+ (function(b,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(b=typeof globalThis<"u"?globalThis:b||self,N(b.instant={}))})(this,function(b){"use strict";var bc=Object.defineProperty;var xr=b=>{throw TypeError(b)};var gc=(b,N,k)=>N in b?bc(b,N,{enumerable:!0,configurable:!0,writable:!0,value:k}):b[N]=k;var m=(b,N,k)=>gc(b,typeof N!="symbol"?N+"":N,k),Ls=(b,N,k)=>N.has(b)||xr("Cannot "+k);var y=(b,N,k)=>(Ls(b,N,"read from private field"),k?k.call(b):N.get(b)),K=(b,N,k)=>N.has(b)?xr("Cannot add the same private member more than once"):N instanceof WeakSet?N.add(b):N.set(b,k),W=(b,N,k,it)=>(Ls(b,N,"write to private field"),it?it.call(b,k):N.set(b,k),k),ie=(b,N,k)=>(Ls(b,N,"access private method"),k);var se,mt,Xe,Ye,yt,ae,me,xt,Ue,Le,Ze,Qe,et,Kt,pe,ne,$t,qt,zt,_,U;class N extends Error{constructor(s){super(s.message);m(this,"error");m(this,"errorDescription");const e=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,N),this.name="InstantOAuthError",this.error=s.error,this.errorDescription=s.errorDescription}get[Symbol.toStringTag](){return"InstantOAuthError"}}const k={Remove:"remove",Replace:"replace",Add:"add"},it=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),Pt=Symbol.iterator,he={mutable:"mutable",immutable:"immutable"},Wt={};function rt(r,t){return r instanceof Map?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function Ms(r,t){if(t in r){let s=Reflect.getPrototypeOf(r);for(;s;){const e=Reflect.getOwnPropertyDescriptor(s,t);if(e)return e;s=Reflect.getPrototypeOf(s)}}}function Fs(r){return Object.getPrototypeOf(r)===Set.prototype}function Bs(r){return Object.getPrototypeOf(r)===Map.prototype}function re(r){var t;return(t=r.copy)!==null&&t!==void 0?t:r.original}function Jt(r){return!!M(r)}function M(r){return typeof r!="object"?null:r==null?void 0:r[it]}function Gt(r){var t;const s=M(r);return s?(t=s.copy)!==null&&t!==void 0?t:s.original:r}function Me(r,t){if(!r||typeof r!="object")return!1;let s;return Object.getPrototypeOf(r)===Object.prototype||Array.isArray(r)||r instanceof Map||r instanceof Set||!!(t!=null&&t.mark)&&((s=t.mark(r,he))===he.immutable||typeof s=="function")}function Rs(r,t=[]){if(Object.hasOwnProperty.call(r,"key")){const s=r.parent.copy,e=M(Ee(s,r.key));if(e!==null&&(e==null?void 0:e.original)!==r.original)return null;const i=r.parent.type===3,a=i?Array.from(r.parent.setMap.keys()).indexOf(r.key):r.key;if(!(i&&s.size>a||rt(s,a)))return null;t.push(a)}if(r.parent)return Rs(r.parent,t);t.reverse();try{Pr(r.copy,t)}catch{return null}return t}function at(r){return Array.isArray(r)?1:r instanceof Map?2:r instanceof Set?3:0}function Ee(r,t){return at(r)===2?r.get(t):r[t]}function Xt(r,t,s){at(r)===2?r.set(t,s):r[t]=s}function Yt(r,t){const s=M(r);return(s?re(s):r)[t]}function Fe(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t}function Be(r,t){return t?r:[""].concat(r).map(s=>{const e=`${s}`;return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Pr(r,t){for(let s=0;s<t.length-1;s+=1){const e=t[s];if(r=Ee(at(r)===3?Array.from(r):r,e),typeof r!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return r}function br(r){const t=Object.create(Object.getPrototypeOf(r));return Reflect.ownKeys(r).forEach(s=>{let e=Reflect.getOwnPropertyDescriptor(r,s);if(e.enumerable&&e.configurable&&e.writable){t[s]=r[s];return}e.writable||(e.writable=!0,e.configurable=!0),(e.get||e.set)&&(e={configurable:!0,writable:!0,enumerable:e.enumerable,value:r[s]}),Reflect.defineProperty(t,s,e)}),t}const gr=Object.prototype.propertyIsEnumerable;function wr(r,t){let s;if(Array.isArray(r))return Array.prototype.concat.call(r);if(r instanceof Set){if(!Fs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(r.values())}return Set.prototype.difference?Set.prototype.difference.call(r,new Set):new Set(r.values())}else if(r instanceof Map){if(!Bs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(r)}return new Map(r)}else if(t!=null&&t.mark&&(s=t.mark(r,he),s!==void 0)&&s!==he.mutable){if(s===he.immutable)return br(r);if(typeof s=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return s()}throw new Error(`Unsupported mark result: ${s}`)}else if(typeof r=="object"&&Object.getPrototypeOf(r)===Object.prototype){const e={};return Object.keys(r).forEach(i=>{e[i]=r[i]}),Object.getOwnPropertySymbols(r).forEach(i=>{gr.call(r,i)&&(e[i]=r[i])}),e}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function Q(r){r.copy||(r.copy=wr(r.original,r.options))}function nt(r){if(!Me(r))return Gt(r);if(Array.isArray(r))return r.map(nt);if(r instanceof Map){const s=Array.from(r.entries()).map(([e,i])=>[e,nt(i)]);if(!Bs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(s)}return new Map(s)}if(r instanceof Set){const s=Array.from(r).map(nt);if(!Fs(r)){const e=Object.getPrototypeOf(r).constructor;return new e(s)}return new Set(s)}const t=Object.create(Object.getPrototypeOf(r));for(const s in r)t[s]=nt(r[s]);return t}function bt(r){return Jt(r)?nt(r):r}function ye(r){var t;r.assignedMap=(t=r.assignedMap)!==null&&t!==void 0?t:new Map,r.operated||(r.operated=!0,r.parent&&ye(r.parent))}function Tr(r,t){const s=at(r);if(s===0)Reflect.ownKeys(r).forEach(e=>{t(e,r[e],r)});else if(s===1){let e=0;for(const i of r)t(e,i,r),e+=1}else r.forEach((e,i)=>t(i,e,r))}function _s(r,t,s){if(Jt(r)||!Me(r,s)||t.has(r)||Object.isFrozen(r))return;const e=r instanceof Set,i=e?new Map:void 0;if(t.add(r),Tr(r,(a,n)=>{var o;if(Jt(n)){const c=M(n);Q(c);const h=!((o=c.assignedMap)===null||o===void 0)&&o.size||c.operated?c.copy:c.original;Xt(e?i:r,a,h)}else _s(n,t,s)}),i){const a=r,n=Array.from(a);a.clear(),n.forEach(o=>{a.add(i.has(o)?i.get(o):o)})}}function Ar(r,t){const s=r.type===3?r.setMap:r.copy;r.finalities.revoke.length>1&&r.assignedMap.get(t)&&s&&_s(Ee(s,t),r.finalities.handledSet,r.options)}function Zt(r){r.type===3&&r.copy&&(r.copy.clear(),r.setMap.forEach(t=>{r.copy.add(Gt(t))}))}function Qt(r,t,s,e){if(r.operated&&r.assignedMap&&r.assignedMap.size>0&&!r.finalized){if(s&&e){const a=Rs(r);a&&t(r,a,s,e)}r.finalized=!0}}function es(r,t,s,e){const i=M(s);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((a,n)=>{var o;const c=r.type===3?r.setMap:r.copy;if(Fe(Ee(c,t),s)){let h=i.original;i.copy&&(h=i.copy),Zt(r),Qt(r,e,a,n),r.options.enableAutoFreeze&&(r.options.updatedValues=(o=r.options.updatedValues)!==null&&o!==void 0?o:new WeakMap,r.options.updatedValues.set(h,i.original)),Xt(c,t,h)}}),r.options.enableAutoFreeze&&i.finalities!==r.finalities&&(r.options.enableAutoFreeze=!1)),Me(s,r.options)&&r.finalities.draft.push(()=>{const a=r.type===3?r.setMap:r.copy;Fe(Ee(a,t),s)&&Ar(r,t)})}function Sr(r,t,s,e,i){let{original:a,assignedMap:n,options:o}=r,c=r.copy;c.length<a.length&&([a,c]=[c,a],[s,e]=[e,s]);for(let h=0;h<a.length;h+=1)if(n.get(h.toString())&&c[h]!==a[h]){const l=t.concat([h]),u=Be(l,i);s.push({op:k.Replace,path:u,value:bt(c[h])}),e.push({op:k.Replace,path:u,value:bt(a[h])})}for(let h=a.length;h<c.length;h+=1){const l=t.concat([h]),u=Be(l,i);s.push({op:k.Add,path:u,value:bt(c[h])})}if(a.length<c.length){const{arrayLengthAssignment:h=!0}=o.enablePatches;if(h){const l=t.concat(["length"]),u=Be(l,i);e.push({op:k.Replace,path:u,value:a.length})}else for(let l=c.length;a.length<l;l-=1){const u=t.concat([l-1]),f=Be(u,i);e.push({op:k.Remove,path:f})}}}function Ir({original:r,copy:t,assignedMap:s},e,i,a,n){s.forEach((o,c)=>{const h=Ee(r,c),l=bt(Ee(t,c)),u=o?rt(r,c)?k.Replace:k.Add:k.Remove;if(Fe(h,l)&&u===k.Replace)return;const f=e.concat(c),d=Be(f,n);i.push(u===k.Remove?{op:u,path:d}:{op:u,path:d,value:l}),a.push(u===k.Add?{op:k.Remove,path:d}:u===k.Remove?{op:k.Add,path:d,value:h}:{op:k.Replace,path:d,value:h})})}function Er({original:r,copy:t},s,e,i,a){let n=0;r.forEach(o=>{if(!t.has(o)){const c=s.concat([n]),h=Be(c,a);e.push({op:k.Remove,path:h,value:o}),i.unshift({op:k.Add,path:h,value:o})}n+=1}),n=0,t.forEach(o=>{if(!r.has(o)){const c=s.concat([n]),h=Be(c,a);e.push({op:k.Add,path:h,value:o}),i.unshift({op:k.Remove,path:h,value:o})}n+=1})}function ot(r,t,s,e){const{pathAsArray:i=!0}=r.options.enablePatches;switch(r.type){case 0:case 2:return Ir(r,t,s,e,i);case 1:return Sr(r,t,s,e,i);case 3:return Er(r,t,s,e,i)}}const gt=(r,t,s=!1)=>{if(typeof r=="object"&&r!==null&&(!Me(r,t)||s))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},ts={get size(){return re(M(this)).size},has(r){return re(M(this)).has(r)},set(r,t){const s=M(this),e=re(s);return(!e.has(r)||!Fe(e.get(r),t))&&(Q(s),ye(s),s.assignedMap.set(r,!0),s.copy.set(r,t),es(s,r,t,ot)),this},delete(r){if(!this.has(r))return!1;const t=M(this);return Q(t),ye(t),t.original.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.copy.delete(r),!0},clear(){const r=M(this);if(this.size){Q(r),ye(r),r.assignedMap=new Map;for(const[t]of r.original)r.assignedMap.set(t,!1);r.copy.clear()}},forEach(r,t){const s=M(this);re(s).forEach((e,i)=>{r.call(t,this.get(i),i,this)})},get(r){var t,s;const e=M(this),i=re(e).get(r),a=((s=(t=e.options).mark)===null||s===void 0?void 0:s.call(t,i,he))===he.mutable;if(e.options.strict&&gt(i,e.options,a),a||e.finalized||!Me(i,e.options)||i!==e.original.get(r))return i;const n=Wt.createDraft({original:i,parentDraft:e,key:r,finalities:e.finalities,options:e.options});return Q(e),e.copy.set(r,n),n},keys(){return re(M(this)).keys()},values(){const r=this.keys();return{[Pt]:()=>this.values(),next:()=>{const t=r.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const r=this.keys();return{[Pt]:()=>this.entries(),next:()=>{const t=r.next();if(t.done)return t;const s=this.get(t.value);return{done:!1,value:[t.value,s]}}}},[Pt](){return this.entries()}},Cr=Reflect.ownKeys(ts),js=(r,t,{isValuesIterator:s})=>()=>{var e,i;const a=t.next();if(a.done)return a;const n=a.value;let o=r.setMap.get(n);const c=M(o),h=((i=(e=r.options).mark)===null||i===void 0?void 0:i.call(e,o,he))===he.mutable;if(r.options.strict&&gt(n,r.options,h),!h&&!c&&Me(n,r.options)&&!r.finalized&&r.original.has(n)){const l=Wt.createDraft({original:n,parentDraft:r,key:n,finalities:r.finalities,options:r.options});r.setMap.set(n,l),o=l}else c&&(o=c.proxy);return{done:!1,value:s?o:[o,o]}},wt={get size(){return M(this).setMap.size},has(r){const t=M(this);if(t.setMap.has(r))return!0;Q(t);const s=M(r);return!!(s&&t.setMap.has(s.original))},add(r){const t=M(this);return this.has(r)||(Q(t),ye(t),t.assignedMap.set(r,!0),t.setMap.set(r,r),es(t,r,r,ot)),this},delete(r){if(!this.has(r))return!1;const t=M(this);Q(t),ye(t);const s=M(r);return s&&t.setMap.has(s.original)?(t.assignedMap.set(s.original,!1),t.setMap.delete(s.original)):(!s&&t.setMap.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.setMap.delete(r))},clear(){if(!this.size)return;const r=M(this);Q(r),ye(r);for(const t of r.original)r.assignedMap.set(t,!1);r.setMap.clear()},values(){const r=M(this);Q(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:js(r,t,{isValuesIterator:!0})}},entries(){const r=M(this);Q(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:js(r,t,{isValuesIterator:!1})}},keys(){return this.values()},[Pt](){return this.values()},forEach(r,t){const s=this.values();let e=s.next();for(;!e.done;)r.call(t,e.value,e.value,this),e=s.next()}};Set.prototype.difference&&Object.assign(wt,{intersection(r){return Set.prototype.intersection.call(new Set(this.values()),r)},union(r){return Set.prototype.union.call(new Set(this.values()),r)},difference(r){return Set.prototype.difference.call(new Set(this.values()),r)},symmetricDifference(r){return Set.prototype.symmetricDifference.call(new Set(this.values()),r)},isSubsetOf(r){return Set.prototype.isSubsetOf.call(new Set(this.values()),r)},isSupersetOf(r){return Set.prototype.isSupersetOf.call(new Set(this.values()),r)},isDisjointFrom(r){return Set.prototype.isDisjointFrom.call(new Set(this.values()),r)}});const kr=Reflect.ownKeys(wt),Us=new WeakSet,$s={get(r,t,s){var e,i;const a=(e=r.copy)===null||e===void 0?void 0:e[t];if(a&&Us.has(a))return a;if(t===it)return r;let n;if(r.options.mark){const h=t==="size"&&(r.original instanceof Map||r.original instanceof Set)?Reflect.get(r.original,t):Reflect.get(r.original,t,s);if(n=r.options.mark(h,he),n===he.mutable)return r.options.strict&&gt(h,r.options,!0),h}const o=re(r);if(o instanceof Map&&Cr.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(ts,"size").get.call(r.proxy);const h=ts[t];if(h)return h.bind(r.proxy)}if(o instanceof Set&&kr.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(wt,"size").get.call(r.proxy);const h=wt[t];if(h)return h.bind(r.proxy)}if(!rt(o,t)){const h=Ms(o,t);return h?"value"in h?h.value:(i=h.get)===null||i===void 0?void 0:i.call(r.proxy):void 0}const c=o[t];if(r.options.strict&&gt(c,r.options),r.finalized||!Me(c,r.options))return c;if(c===Yt(r.original,t)){if(Q(r),r.copy[t]=qs({original:r.original[t],parentDraft:r,key:r.type===1?Number(t):t,finalities:r.finalities,options:r.options}),typeof n=="function"){const h=M(r.copy[t]);return Q(h),ye(h),h.copy}return r.copy[t]}return c},set(r,t,s){var e;if(r.type===3||r.type===2)throw new Error("Map/Set draft does not support any property assignment.");let i;if(r.type===1&&t!=="length"&&!(Number.isInteger(i=Number(t))&&i>=0&&(t===0||i===0||String(i)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const a=Ms(re(r),t);if(a!=null&&a.set)return a.set.call(r.proxy,s),!0;const n=Yt(re(r),t),o=M(n);return o&&Fe(o.original,s)?(r.copy[t]=s,r.assignedMap=(e=r.assignedMap)!==null&&e!==void 0?e:new Map,r.assignedMap.set(t,!1),!0):(Fe(s,n)&&(s!==void 0||rt(r.original,t))||(Q(r),ye(r),rt(r.original,t)&&Fe(s,r.original[t])?r.assignedMap.delete(t):r.assignedMap.set(t,!0),r.copy[t]=s,es(r,t,s,ot)),!0)},has(r,t){return t in re(r)},ownKeys(r){return Reflect.ownKeys(re(r))},getOwnPropertyDescriptor(r,t){const s=re(r),e=Reflect.getOwnPropertyDescriptor(s,t);return e&&{writable:!0,configurable:r.type!==1||t!=="length",enumerable:e.enumerable,value:s[t]}},getPrototypeOf(r){return Reflect.getPrototypeOf(r.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(r,t){var s;return r.type===1?$s.set.call(this,r,t,void 0,r.proxy):(Yt(r.original,t)!==void 0||t in r.original?(Q(r),ye(r),r.assignedMap.set(t,!1)):(r.assignedMap=(s=r.assignedMap)!==null&&s!==void 0?s:new Map,r.assignedMap.delete(t)),r.copy&&delete r.copy[t],!0)}};function qs(r){const{original:t,parentDraft:s,key:e,finalities:i,options:a}=r,n=at(t),o={type:n,finalized:!1,parent:s,original:t,copy:null,proxy:null,finalities:i,options:a,setMap:n===3?new Map(t.entries()):void 0};(e||"key"in r)&&(o.key=e);const{proxy:c,revoke:h}=Proxy.revocable(n===1?Object.assign([],o):o,$s);if(i.revoke.push(h),Us.add(c),o.proxy=c,s){const l=s;l.finalities.draft.push((u,f)=>{var d,P;const S=M(c);let F=l.type===3?l.setMap:l.copy;const I=Ee(F,e),O=M(I);if(O){let L=O.original;O.operated&&(L=Gt(I)),Zt(O),Qt(O,ot,u,f),l.options.enableAutoFreeze&&(l.options.updatedValues=(d=l.options.updatedValues)!==null&&d!==void 0?d:new WeakMap,l.options.updatedValues.set(L,O.original)),Xt(F,e,L)}(P=S.callbacks)===null||P===void 0||P.forEach(L=>{L(u,f)})})}else{const l=M(c);l.finalities.draft.push((u,f)=>{Zt(l),Qt(l,ot,u,f)})}return c}Wt.createDraft=qs,Object.prototype.constructor.toString();const J=[];for(let r=0;r<256;++r)J.push((r+256).toString(16).slice(1));function Nr(r,t=0){return(J[r[t+0]]+J[r[t+1]]+J[r[t+2]]+J[r[t+3]]+"-"+J[r[t+4]]+J[r[t+5]]+"-"+J[r[t+6]]+J[r[t+7]]+"-"+J[r[t+8]]+J[r[t+9]]+"-"+J[r[t+10]]+J[r[t+11]]+J[r[t+12]]+J[r[t+13]]+J[r[t+14]]+J[r[t+15]]).toLowerCase()}let ss;const vr=new Uint8Array(16);function Or(){if(!ss){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ss=crypto.getRandomValues.bind(crypto)}return ss(vr)}const zs={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Dr(r,t,s){var i;if(zs.randomUUID&&!r)return zs.randomUUID();r=r||{};const e=r.random??((i=r.rng)==null?void 0:i.call(r))??Or();if(e.length<16)throw new Error("Random bytes length must be >= 16");return e[6]=e[6]&15|64,e[8]=e[8]&63|128,Nr(e)}function Vs(){return Dr()}function Lr(r,t){return r.localeCompare(t)}function Mr(){let r=Lr;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{r=Intl.Collator("en-US").compare}catch{}return r}Mr();function Fr(){const t={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(t))}const Br=Fr();function Tt(r,t,s){const e={__etype:r,__ops:s};return new Proxy(e,{get:(i,a)=>{if(a==="__ops")return s;if(a==="__etype")return r;if(Br.has(a))return(n,o)=>Tt(r,t,[...s,o?[a,r,t,n,o]:[a,r,t,n]])}})}function Rr(r,t){return`lookup__${r}__${JSON.stringify(t)}`}function _r(r){return r.startsWith("lookup__")}function Hs(r){const[t,s,...e]=r.split("__");return[s,JSON.parse(e.join("__"))]}function jr(r){return new Proxy({__etype:r},{get(t,s){if(s==="lookup")return(i,a)=>Tt(r,Hs(Rr(i,a)),[]);if(s==="__etype")return r;const e=s;return _r(e)?Tt(r,Hs(e),[]):Tt(r,e,[])}})}function Ur(){return new Proxy({},{get(r,t){return jr(t)}})}Ur();class ee extends Error{constructor(s,e,i){super(s);m(this,"hint");m(this,"traceId");this.hint=e,i&&(this.traceId=i);const a=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,a),Error.captureStackTrace&&Error.captureStackTrace(this,ee),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class be extends ee{constructor(s){var a,n;const e=((a=s.body)==null?void 0:a.message)||`API Error (${s.status})`;super(e,s.body.hint,((n=s.body)==null?void 0:n.traceId)||s.body["trace-id"]);m(this,"body");m(this,"status");const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,be),this.name="InstantAPIError",this.status=s.status,this.body=s.body}get[Symbol.toStringTag](){return"InstantAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const xe="v1.0.65";class le{constructor(t,s,e,i={indexed:!1,unique:!1}){m(this,"valueType");m(this,"required");m(this,"isIndexed");m(this,"config");m(this,"metadata",{});this.valueType=t,this.required=s,this.isIndexed=e,this.config=i}clientRequired(){return new le(this.valueType,!1,this.isIndexed,this.config)}optional(){return new le(this.valueType,!1,this.isIndexed,this.config)}unique(){return new le(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new le(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class At{constructor(t,s){m(this,"attrs");m(this,"links");this.attrs=t,this.links=s}asType(){return new At(this.attrs,this.links)}}class St{constructor(t,s,e){m(this,"entities");m(this,"links");m(this,"rooms");this.entities=t,this.links=s,this.rooms=e}withRoomSchema(){return new St(this.entities,this.links,{})}}var Ks;(function(r){r.InitialSyncBatch="InitialSyncBatch",r.InitialSyncComplete="InitialSyncComplete",r.LoadFromStorage="LoadFromStorage",r.SyncTransaction="SyncTransaction",r.Error="Error"})(Ks||(Ks={}));function $r(r,t){return new St(Ws(r,t),t,void 0)}function qr(r){return new At(r,{})}function zr(){return new le("string",!0,!1)}function Vr(){return new le("number",!0,!1)}function Hr(){return new le("boolean",!0,!1)}function Kr(){return new le("date",!0,!1)}function Wr(){return new le("json",!0,!1)}function Jr(){return new le("json",!0,!1)}function Ws(r,t){var i,a,n,o;const s={fwd:{},rev:{}};for(const c of Object.values(t))(i=s.fwd)[a=c.forward.on]||(i[a]={}),(n=s.rev)[o=c.reverse.on]||(n[o]={}),s.fwd[c.forward.on][c.forward.label]={entityName:c.reverse.on,cardinality:c.forward.has},s.rev[c.reverse.on][c.reverse.label]={entityName:c.forward.on,cardinality:c.reverse.has};return Object.fromEntries(Object.entries(r).map(([c,h])=>[c,new At(h.attrs,{...s.fwd[c],...s.rev[c]})]))}function Gr({entities:r,links:t,rooms:s}){const e=t??{},i=s??{};return new St(Ws(r,e),e,i)}const G={graph:$r,schema:Gr,entity:qr,string:zr,number:Vr,boolean:Hr,date:Kr,json:Wr,any:Jr};function Xr(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function Yr(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}Yr(),Xr();function Zr(){const r="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._~";let t="";for(const s of crypto.getRandomValues(new Uint8Array(64)))t=t+r[s%r.length];return t}function Qr(r){return crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(r))}function ea(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ta(r){return Qr(r).then(t=>ea(btoa(String.fromCharCode(...Array.from(new Uint8Array(t))))))}function sa(){const r=Math.min(800,Math.floor(window.outerWidth*.8)),t=Math.min(630,Math.floor(window.outerHeight*.5)),s={width:r,height:t,left:Math.round(window.screenX+(window.outerWidth-r)/2),top:Math.round(window.screenY+(window.outerHeight-t)/8)},e={width:s.width,height:s.height,left:s.left,top:s.top,toolbar:0,scrollbars:1,status:1,resizable:1,menuBar:0,rel:"opener"};return Object.keys(e).map(i=>`${i}=${e[i]}`).join(",")}let Js=null;function ia({clientId:r,state:t,codeChallenge:s,apiURI:e,redirectUri:i,scopes:a}){const n=new URL(`${e}/platform/oauth/start`);return n.searchParams.set("client_id",r),n.searchParams.set("redirect_uri",i),n.searchParams.set("scope",a.join(" ")),n.searchParams.set("state",t),n.searchParams.set("response_type","code"),n.searchParams.set("code_challenge",s),n.searchParams.set("code_challenge_method","S256"),n.toString()}async function ra({code:r,clientId:t,verifier:s,apiURI:e,redirectUri:i}){const a=await fetch(`${e}/platform/oauth/token`,{method:"POST",headers:{"Content-type":"application/json","Instant-Platform-Version":xe,"Instant-Core-Version":xe},body:JSON.stringify({grant_type:"authorization_code",code:r,redirect_uri:i,client_id:t,code_verifier:s})});if(!a.ok){const o=await a.text();let c;try{const h=JSON.parse(o);c={error:h.error,errorDescription:h.error_description,message:`OAuth error: ${h.error||"server_error"}`}}catch{c={error:"server_error",message:"OAuth error: server_error"}}throw new N(c)}const n=await a.json();return{token:n.access_token,expiresAt:new Date(Date.now()+(n.expires_in-30)*1e3)}}function aa(){if(typeof window>"u")throw new Error("This function may only be used in a browser context.");const r=new URL(window.location.href).searchParams,t=r.get("state"),s=r.get("error"),e=r.get("error_description"),i=r.get("code");if(!t)throw new Error("Invalid redirect. The state param is missing.");const a=new BroadcastChannel(t);return a.addEventListener("message",n=>{n.data.type==="oauth-redirect-window-done"&&window.close()}),a.postMessage({type:"oauth-redirect",state:t,error:s,errorDescription:e,code:i}),()=>{a.close()}}function na({clientId:r,apiURI:t,redirectUri:s,scopes:e}){if(typeof window>"u")throw new Error("OAuth flow can only be started on the client.");const i=Js;i&&i.close();const a=crypto.randomUUID(),n=Zr(),o=new BroadcastChannel(a),c=new Promise((l,u)=>{o.addEventListener("message",async f=>{if(f.data.type!=="oauth-redirect")return;const{state:d,error:P,code:S,errorDescription:F}=f.data;if(!(!d||d!==a)){if(S)try{const I=await ra({clientId:r,code:S,verifier:n,apiURI:t,redirectUri:s});l(I)}catch(I){I instanceof N&&u(I),u(new N({error:"server_error",message:"OAuth error exchanging code for token"}))}else u(typeof P=="string"?new N({error:P,errorDescription:F,message:`OAuth error: ${P}`}):new N({error:"server_error",message:"OAuth error: server_error"}));o.postMessage({type:"oauth-redirect-window-done"})}})}),h=window.open("",`instantdb_oauth_${Math.random()}`.replace(".",""),sa());return h?(Js=h,ta(n).then(l=>{const u=ia({clientId:r,state:a,codeChallenge:l,apiURI:t,redirectUri:s,scopes:e});h.location.href=u}),c.finally(()=>o.close())):Promise.reject({error:"Could not open Auth window"})}class oa{constructor(t){m(this,"redirectUri");m(this,"clientId");m(this,"apiURI");this.redirectUri=t.redirectUri,this.apiURI=t.apiURI??"https://api.instantdb.com",this.clientId=t.clientId}startClientOnlyFlow(t){return na({clientId:this.clientId,apiURI:this.apiURI,redirectUri:this.redirectUri,scopes:t})}handleClientRedirect(){return aa()}}function ca(r,t){if(r==null)return{};var s={};for(var e in r)if({}.hasOwnProperty.call(r,e)){if(t.indexOf(e)!==-1)continue;s[e]=r[e]}return s}class Ce{constructor(t,s,e){m(this,"line");m(this,"column");m(this,"index");this.line=t,this.column=s,this.index=e}}class It{constructor(t,s){m(this,"start");m(this,"end");m(this,"filename");m(this,"identifierName");this.start=t,this.end=s}}function oe(r,t){const{line:s,column:e,index:i}=r;return new Ce(s,e+t,i+t)}const Gs="BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";var ha={ImportMetaOutsideModule:{message:`import.meta may appear only with 'sourceType: "module"'`,code:Gs},ImportOutsideModule:{message:`'import' and 'export' may appear only with 'sourceType: "module"'`,code:Gs}};const Xs={ArrayPattern:"array destructuring pattern",AssignmentExpression:"assignment expression",AssignmentPattern:"assignment expression",ArrowFunctionExpression:"arrow function expression",ConditionalExpression:"conditional expression",CatchClause:"catch clause",ForOfStatement:"for-of statement",ForInStatement:"for-in statement",ForStatement:"for-loop",FormalParameters:"function parameter list",Identifier:"identifier",ImportSpecifier:"import specifier",ImportDefaultSpecifier:"import default specifier",ImportNamespaceSpecifier:"import namespace specifier",ObjectPattern:"object destructuring pattern",ParenthesizedExpression:"parenthesized expression",RestElement:"rest element",UpdateExpression:{true:"prefix operation",false:"postfix operation"},VariableDeclarator:"variable declaration",YieldExpression:"yield expression"},Et=r=>r.type==="UpdateExpression"?Xs.UpdateExpression[`${r.prefix}`]:Xs[r.type];var la={AccessorIsGenerator:({kind:r})=>`A ${r}ter cannot be a generator.`,ArgumentsInClass:"'arguments' is only allowed in functions and class methods.",AsyncFunctionInSingleStatementContext:"Async functions can only be declared at the top level or inside a block.",AwaitBindingIdentifier:"Can not use 'await' as identifier inside an async function.",AwaitBindingIdentifierInStaticBlock:"Can not use 'await' as identifier inside a static block.",AwaitExpressionFormalParameter:"'await' is not allowed in async function parameters.",AwaitUsingNotInAsyncContext:"'await using' is only allowed within async functions and at the top levels of modules.",AwaitNotInAsyncContext:"'await' is only allowed within async functions and at the top levels of modules.",BadGetterArity:"A 'get' accessor must not have any formal parameters.",BadSetterArity:"A 'set' accessor must have exactly one formal parameter.",BadSetterRestParameter:"A 'set' accessor function argument must not be a rest parameter.",ConstructorClassField:"Classes may not have a field named 'constructor'.",ConstructorClassPrivateField:"Classes may not have a private field named '#constructor'.",ConstructorIsAccessor:"Class constructor may not be an accessor.",ConstructorIsAsync:"Constructor can't be an async function.",ConstructorIsGenerator:"Constructor can't be a generator.",DeclarationMissingInitializer:({kind:r})=>`Missing initializer in ${r} declaration.`,DecoratorArgumentsOutsideParentheses:"Decorator arguments must be moved inside parentheses: use '@(decorator(args))' instead of '@(decorator)(args)'.",DecoratorBeforeExport:"Decorators must be placed *before* the 'export' keyword. Remove the 'decoratorsBeforeExport: true' option to use the 'export @decorator class {}' syntax.",DecoratorsBeforeAfterExport:"Decorators can be placed *either* before or after the 'export' keyword, but not in both locations at the same time.",DecoratorConstructor:"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",DecoratorExportClass:"Decorators must be placed *after* the 'export' keyword. Remove the 'decoratorsBeforeExport: false' option to use the '@decorator export class {}' syntax.",DecoratorSemicolon:"Decorators must not be followed by a semicolon.",DecoratorStaticBlock:"Decorators can't be used with a static block.",DeferImportRequiresNamespace:'Only `import defer * as x from "./module"` is valid.',DeletePrivateField:"Deleting a private field is not allowed.",DestructureNamedImport:"ES2015 named imports do not destructure. Use another statement for destructuring after the import.",DuplicateConstructor:"Duplicate constructor in the same class.",DuplicateDefaultExport:"Only one default export allowed per module.",DuplicateExport:({exportName:r})=>`\`${r}\` has already been exported. Exported identifiers must be unique.`,DuplicateProto:"Redefinition of __proto__ property.",DuplicateRegExpFlags:"Duplicate regular expression flag.",ElementAfterRest:"Rest element must be last element.",EscapedCharNotAnIdentifier:"Invalid Unicode escape.",ExportBindingIsString:({localName:r,exportName:t})=>`A string literal cannot be used as an exported binding without \`from\`.
2
2
  - Did you mean \`export { '${r}' as '${t}' } from 'some-module'\`?`,ExportDefaultFromAsIdentifier:"'from' is not allowed as an identifier after 'export default'.",ForInOfLoopInitializer:({type:r})=>`'${r==="ForInStatement"?"for-in":"for-of"}' loop variable declaration may not have an initializer.`,ForInUsing:"For-in loop may not start with 'using' declaration.",ForOfAsync:"The left-hand side of a for-of loop may not be 'async'.",ForOfLet:"The left-hand side of a for-of loop may not start with 'let'.",GeneratorInSingleStatementContext:"Generators can only be declared at the top level or inside a block.",IllegalBreakContinue:({type:r})=>`Unsyntactic ${r==="BreakStatement"?"break":"continue"}.`,IllegalLanguageModeDirective:"Illegal 'use strict' directive in function with non-simple parameter list.",IllegalReturn:"'return' outside of function.",ImportAttributesUseAssert:"The `assert` keyword in import attributes is deprecated and it has been replaced by the `with` keyword. You can enable the `deprecatedImportAssert` parser plugin to suppress this error.",ImportBindingIsString:({importName:r})=>`A string literal cannot be used as an imported binding.
3
- - Did you mean \`import { "${r}" as foo }\`?`,ImportCallArity:"`import()` requires exactly one or two arguments.",ImportCallNotNewExpression:"Cannot use new with import(...).",ImportCallSpreadArgument:"`...` is not allowed in `import()`.",ImportJSONBindingNotDefault:"A JSON module can only be imported with `default`.",ImportReflectionHasAssertion:"`import module x` cannot have assertions.",ImportReflectionNotBinding:'Only `import module x from "./module"` is valid.',IncompatibleRegExpUVFlags:"The 'u' and 'v' regular expression flags cannot be enabled at the same time.",InvalidBigIntLiteral:"Invalid BigIntLiteral.",InvalidCodePoint:"Code point out of bounds.",InvalidCoverInitializedName:"Invalid shorthand property initializer.",InvalidDecimal:"Invalid decimal.",InvalidDigit:({radix:r})=>`Expected number in radix ${r}.`,InvalidEscapeSequence:"Bad character escape sequence.",InvalidEscapeSequenceTemplate:"Invalid escape sequence in template.",InvalidEscapedReservedWord:({reservedWord:r})=>`Escape sequence in keyword ${r}.`,InvalidIdentifier:({identifierName:r})=>`Invalid identifier ${r}.`,InvalidLhs:({ancestor:r})=>`Invalid left-hand side in ${Et(r)}.`,InvalidLhsBinding:({ancestor:r})=>`Binding invalid left-hand side in ${Et(r)}.`,InvalidLhsOptionalChaining:({ancestor:r})=>`Invalid optional chaining in the left-hand side of ${Et(r)}.`,InvalidNumber:"Invalid number.",InvalidOrMissingExponent:"Floating-point numbers require a valid exponent after the 'e'.",InvalidOrUnexpectedToken:({unexpected:r})=>`Unexpected character '${r}'.`,InvalidParenthesizedAssignment:"Invalid parenthesized assignment pattern.",InvalidPrivateFieldResolution:({identifierName:r})=>`Private name #${r} is not defined.`,InvalidPropertyBindingPattern:"Binding member expression.",InvalidRecordProperty:"Only properties and spread elements are allowed in record definitions.",InvalidRestAssignmentPattern:"Invalid rest operator's argument.",LabelRedeclaration:({labelName:r})=>`Label '${r}' is already declared.`,LetInLexicalBinding:"'let' is disallowed as a lexically bound name.",LineTerminatorBeforeArrow:"No line break is allowed before '=>'.",MalformedRegExpFlags:"Invalid regular expression flag.",MissingClassName:"A class name is required.",MissingEqInAssignment:"Only '=' operator can be used for specifying default value.",MissingSemicolon:"Missing semicolon.",MissingPlugin:({missingPlugin:r})=>`This experimental syntax requires enabling the parser plugin: ${r.map(t=>JSON.stringify(t)).join(", ")}.`,MissingOneOfPlugins:({missingPlugin:r})=>`This experimental syntax requires enabling one of the following parser plugin(s): ${r.map(t=>JSON.stringify(t)).join(", ")}.`,MissingUnicodeEscape:"Expecting Unicode escape sequence \\uXXXX.",MixingCoalesceWithLogical:"Nullish coalescing operator(??) requires parens when mixing with logical operators.",ModuleAttributeDifferentFromType:"The only accepted module attribute is `type`.",ModuleAttributeInvalidValue:"Only string literals are allowed as module attribute values.",ModuleAttributesWithDuplicateKeys:({key:r})=>`Duplicate key "${r}" is not allowed in module attributes.`,ModuleExportNameHasLoneSurrogate:({surrogateCharCode:r})=>`An export name cannot include a lone surrogate, found '\\u${r.toString(16)}'.`,ModuleExportUndefined:({localName:r})=>`Export '${r}' is not defined.`,MultipleDefaultsInSwitch:"Multiple default clauses.",NewlineAfterThrow:"Illegal newline after throw.",NoCatchOrFinally:"Missing catch or finally clause.",NumberIdentifier:"Identifier directly after number.",NumericSeparatorInEscapeSequence:"Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",ObsoleteAwaitStar:"'await*' has been removed from the async functions proposal. Use Promise.all() instead.",OptionalChainingNoNew:"Constructors in/after an Optional Chain are not allowed.",OptionalChainingNoTemplate:"Tagged Template Literals are not allowed in optionalChain.",OverrideOnConstructor:"'override' modifier cannot appear on a constructor declaration.",ParamDupe:"Argument name clash.",PatternHasAccessor:"Object pattern can't contain getter or setter.",PatternHasMethod:"Object pattern can't contain methods.",PrivateInExpectedIn:({identifierName:r})=>`Private names are only allowed in property accesses (\`obj.#${r}\`) or in \`in\` expressions (\`#${r} in obj\`).`,PrivateNameRedeclaration:({identifierName:r})=>`Duplicate private name #${r}.`,RecordExpressionBarIncorrectEndSyntaxType:"Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",RecordExpressionBarIncorrectStartSyntaxType:"Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",RecordExpressionHashIncorrectStartSyntaxType:"Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",RecordNoProto:"'__proto__' is not allowed in Record expressions.",RestTrailingComma:"Unexpected trailing comma after rest element.",SloppyFunction:"In non-strict mode code, functions can only be declared at top level or inside a block.",SloppyFunctionAnnexB:"In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",SourcePhaseImportRequiresDefault:'Only `import source x from "./module"` is valid.',StaticPrototype:"Classes may not have static property named prototype.",SuperNotAllowed:"`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",SuperPrivateField:"Private fields can't be accessed on super.",TrailingDecorator:"Decorators must be attached to a class element.",TupleExpressionBarIncorrectEndSyntaxType:"Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",TupleExpressionBarIncorrectStartSyntaxType:"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",TupleExpressionHashIncorrectStartSyntaxType:"Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",UnexpectedArgumentPlaceholder:"Unexpected argument placeholder.",UnexpectedAwaitAfterPipelineBody:'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',UnexpectedDigitAfterHash:"Unexpected digit after hash token.",UnexpectedImportExport:"'import' and 'export' may only appear at the top level.",UnexpectedKeyword:({keyword:r})=>`Unexpected keyword '${r}'.`,UnexpectedLeadingDecorator:"Leading decorators must be attached to a class declaration.",UnexpectedLexicalDeclaration:"Lexical declaration cannot appear in a single-statement context.",UnexpectedNewTarget:"`new.target` can only be used in functions or class properties.",UnexpectedNumericSeparator:"A numeric separator is only allowed between two digits.",UnexpectedPrivateField:"Unexpected private name.",UnexpectedReservedWord:({reservedWord:r})=>`Unexpected reserved word '${r}'.`,UnexpectedSuper:"'super' is only allowed in object methods and classes.",UnexpectedToken:({expected:r,unexpected:t})=>`Unexpected token${t?` '${t}'.`:""}${r?`, expected "${r}"`:""}`,UnexpectedTokenUnaryExponentiation:"Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",UnexpectedUsingDeclaration:"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement.",UnsupportedBind:"Binding should be performed on object property.",UnsupportedDecoratorExport:"A decorated export must export a class declaration.",UnsupportedDefaultExport:"Only expressions, functions or classes are allowed as the `default` export.",UnsupportedImport:"`import` can only be used in `import()` or `import.meta`.",UnsupportedMetaProperty:({target:r,onlyValidPropertyName:t})=>`The only valid meta property for ${r} is ${r}.${t}.`,UnsupportedParameterDecorator:"Decorators cannot be used to decorate parameters.",UnsupportedPropertyDecorator:"Decorators cannot be used to decorate object literal properties.",UnsupportedSuper:"'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",UnterminatedComment:"Unterminated comment.",UnterminatedRegExp:"Unterminated regular expression.",UnterminatedString:"Unterminated string constant.",UnterminatedTemplate:"Unterminated template.",UsingDeclarationExport:"Using declaration cannot be exported.",UsingDeclarationHasBindingPattern:"Using declaration cannot have destructuring patterns.",VarRedeclaration:({identifierName:r})=>`Identifier '${r}' has already been declared.`,YieldBindingIdentifier:"Can not use 'yield' as identifier inside a generator.",YieldInParameter:"Yield expression is not allowed in formal parameters.",YieldNotInGeneratorFunction:"'yield' is only allowed within generator functions.",ZeroDigitNumericSeparator:"Numeric separator can not be used after leading 0."},ra={StrictDelete:"Deleting local variable in strict mode.",StrictEvalArguments:({referenceName:r})=>`Assigning to '${r}' in strict mode.`,StrictEvalArgumentsBinding:({bindingName:r})=>`Binding '${r}' in strict mode.`,StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block.",StrictNumericEscape:"The only valid numeric escape in strict mode is '\\0'.",StrictOctalLiteral:"Legacy octal literals are not allowed in strict mode.",StrictWith:"'with' in strict mode."},aa={ParseExpressionEmptyInput:"Unexpected parseExpression() input: The input is empty or contains only comments.",ParseExpressionExpectsEOF:({unexpected:r})=>`Unexpected parseExpression() input: The input should contain exactly one expression, but the first expression is followed by the unexpected character \`${String.fromCodePoint(r)}\`.`};const na=new Set(["ArrowFunctionExpression","AssignmentExpression","ConditionalExpression","YieldExpression"]);var oa=Object.assign({PipeBodyIsTighter:"Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",PipeTopicRequiresHackPipes:'Topic references are only supported when using the `"proposal": "hack"` version of the pipeline proposal.',PipeTopicUnbound:"Topic reference is unbound; it must be inside a pipe body.",PipeTopicUnconfiguredToken:({token:r})=>`Invalid topic token ${r}. In order to use ${r} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${r}" }.`,PipeTopicUnused:"Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",PipeUnparenthesizedBody:({type:r})=>`Hack-style pipe body cannot be an unparenthesized ${Et({type:r})}; please wrap it in parentheses.`},{});const ca=["message"];function Xs(r,t,s){Object.defineProperty(r,t,{enumerable:!1,configurable:!0,value:s})}function ha({toMessage:r,code:t,reasonCode:s,syntaxPlugin:e}){const i=s==="MissingPlugin"||s==="MissingOneOfPlugins";return function a(n,o){const c=new SyntaxError;return c.code=t,c.reasonCode=s,c.loc=n,c.pos=n.index,c.syntaxPlugin=e,i&&(c.missingPlugin=o.missingPlugin),Xs(c,"clone",function(l={}){const{line:u,column:f,index:d}=l.loc??n;return a(new Ie(u,f,d),Object.assign({},o,l.details))}),Xs(c,"details",o),Object.defineProperty(c,"message",{configurable:!0,get(){const h=`${r(o)} (${n.line}:${n.column})`;return this.message=h,h},set(h){Object.defineProperty(this,"message",{value:h,writable:!0})}}),c}}function ye(r,t){if(Array.isArray(r))return e=>ye(e,r[0]);const s={};for(const e of Object.keys(r)){const i=r[e],a=typeof i=="string"?{message:()=>i}:typeof i=="function"?{message:i}:i,{message:n}=a,o=ta(a,ca),c=typeof n=="string"?()=>n:n;s[e]=ha(Object.assign({code:"BABEL_PARSER_SYNTAX_ERROR",reasonCode:e,toMessage:c},t?{syntaxPlugin:t}:{},o))}return s}const p=Object.assign({},ye(sa),ye(ia),ye(ra),ye(aa),ye`pipelineOperator`(oa));function la(){return{sourceType:"script",sourceFilename:void 0,startIndex:0,startColumn:0,startLine:1,allowAwaitOutsideFunction:!1,allowReturnOutsideFunction:!1,allowNewTargetOutsideFunction:!1,allowImportExportEverywhere:!1,allowSuperOutsideMethod:!1,allowUndeclaredExports:!1,allowYieldOutsideFunction:!1,plugins:[],strictMode:null,ranges:!1,tokens:!1,createImportExpressions:!0,createParenthesizedExpressions:!1,errorRecovery:!1,attachComment:!0,annexB:!0}}function ua(r){const t=la();if(r==null)return t;if(r.annexB!=null&&r.annexB!==!1)throw new Error("The `annexB` option can only be set to `false`.");for(const s of Object.keys(t))r[s]!=null&&(t[s]=r[s]);if(t.startLine===1)r.startIndex==null&&t.startColumn>0?t.startIndex=t.startColumn:r.startColumn==null&&t.startIndex>0&&(t.startColumn=t.startIndex);else if(r.startColumn==null||r.startIndex==null)throw new Error("With a `startLine > 1` you must also specify `startIndex` and `startColumn`.");return t}const{defineProperty:pa}=Object,Ys=(r,t)=>{r&&pa(r,t,{enumerable:!1,value:r[t]})};function nt(r){return Ys(r.loc.start,"index"),Ys(r.loc.end,"index"),r}var fa=r=>class extends r{parse(){const s=nt(super.parse());return this.optionFlags&256&&(s.tokens=s.tokens.map(nt)),s}parseRegExpLiteral({pattern:s,flags:e}){let i=null;try{i=new RegExp(s,e)}catch{}const a=this.estreeParseLiteral(i);return a.regex={pattern:s,flags:e},a}parseBigIntLiteral(s){let e;try{e=BigInt(s)}catch{e=null}const i=this.estreeParseLiteral(e);return i.bigint=String(i.value||s),i}parseDecimalLiteral(s){const i=this.estreeParseLiteral(null);return i.decimal=String(i.value||s),i}estreeParseLiteral(s){return this.parseLiteral(s,"Literal")}parseStringLiteral(s){return this.estreeParseLiteral(s)}parseNumericLiteral(s){return this.estreeParseLiteral(s)}parseNullLiteral(){return this.estreeParseLiteral(null)}parseBooleanLiteral(s){return this.estreeParseLiteral(s)}estreeParseChainExpression(s,e){const i=this.startNodeAtNode(s);return i.expression=s,this.finishNodeAt(i,"ChainExpression",e)}directiveToStmt(s){const e=s.value;delete s.value,this.castNodeTo(e,"Literal"),e.raw=e.extra.raw,e.value=e.extra.expressionValue;const i=this.castNodeTo(s,"ExpressionStatement");return i.expression=e,i.directive=e.extra.rawValue,delete e.extra,i}fillOptionalPropertiesForTSESLint(s){}cloneEstreeStringLiteral(s){const{start:e,end:i,loc:a,range:n,raw:o,value:c}=s,h=Object.create(s.constructor.prototype);return h.type="Literal",h.start=e,h.end=i,h.loc=a,h.range=n,h.raw=o,h.value=c,h}initFunction(s,e){super.initFunction(s,e),s.expression=!1}checkDeclaration(s){s!=null&&this.isObjectProperty(s)?this.checkDeclaration(s.value):super.checkDeclaration(s)}getObjectOrClassMethodParams(s){return s.value.params}isValidDirective(s){var e;return s.type==="ExpressionStatement"&&s.expression.type==="Literal"&&typeof s.expression.value=="string"&&!((e=s.expression.extra)!=null&&e.parenthesized)}parseBlockBody(s,e,i,a,n){super.parseBlockBody(s,e,i,a,n);const o=s.directives.map(c=>this.directiveToStmt(c));s.body=o.concat(s.body),delete s.directives}parsePrivateName(){const s=super.parsePrivateName();return this.convertPrivateNameToPrivateIdentifier(s)}convertPrivateNameToPrivateIdentifier(s){const e=super.getPrivateNameSV(s);return s=s,delete s.id,s.name=e,this.castNodeTo(s,"PrivateIdentifier")}isPrivateName(s){return s.type==="PrivateIdentifier"}getPrivateNameSV(s){return s.name}parseLiteral(s,e){const i=super.parseLiteral(s,e);return i.raw=i.extra.raw,delete i.extra,i}parseFunctionBody(s,e,i=!1){super.parseFunctionBody(s,e,i),s.expression=s.body.type!=="BlockStatement"}parseMethod(s,e,i,a,n,o,c=!1){let h=this.startNode();h.kind=s.kind,h=super.parseMethod(h,e,i,a,n,o,c),delete h.kind;const{typeParameters:l}=s;l&&(delete s.typeParameters,h.typeParameters=l,this.resetStartLocationFromNode(h,l));const u=this.castNodeTo(h,this.hasPlugin("typescript")&&!h.body?"TSEmptyBodyFunctionExpression":"FunctionExpression");return s.value=u,o==="ClassPrivateMethod"&&(s.computed=!1),this.hasPlugin("typescript")&&s.abstract?(delete s.abstract,this.finishNode(s,"TSAbstractMethodDefinition")):o==="ObjectMethod"?(s.kind==="method"&&(s.kind="init"),s.shorthand=!1,this.finishNode(s,"Property")):this.finishNode(s,"MethodDefinition")}nameIsConstructor(s){return s.type==="Literal"?s.value==="constructor":super.nameIsConstructor(s)}parseClassProperty(...s){const e=super.parseClassProperty(...s);return e.abstract&&this.hasPlugin("typescript")?(delete e.abstract,this.castNodeTo(e,"TSAbstractPropertyDefinition")):this.castNodeTo(e,"PropertyDefinition"),e}parseClassPrivateProperty(...s){const e=super.parseClassPrivateProperty(...s);return e.abstract&&this.hasPlugin("typescript")?this.castNodeTo(e,"TSAbstractPropertyDefinition"):this.castNodeTo(e,"PropertyDefinition"),e.computed=!1,e}parseClassAccessorProperty(s){const e=super.parseClassAccessorProperty(s);return e.abstract&&this.hasPlugin("typescript")?(delete e.abstract,this.castNodeTo(e,"TSAbstractAccessorProperty")):this.castNodeTo(e,"AccessorProperty"),e}parseObjectProperty(s,e,i,a){const n=super.parseObjectProperty(s,e,i,a);return n&&(n.kind="init",this.castNodeTo(n,"Property")),n}finishObjectProperty(s){return s.kind="init",this.finishNode(s,"Property")}isValidLVal(s,e,i){return s==="Property"?"value":super.isValidLVal(s,e,i)}isAssignable(s,e){return s!=null&&this.isObjectProperty(s)?this.isAssignable(s.value,e):super.isAssignable(s,e)}toAssignable(s,e=!1){if(s!=null&&this.isObjectProperty(s)){const{key:i,value:a}=s;this.isPrivateName(i)&&this.classScope.usePrivateName(this.getPrivateNameSV(i),i.loc.start),this.toAssignable(a,e)}else super.toAssignable(s,e)}toAssignableObjectExpressionProp(s,e,i){s.type==="Property"&&(s.kind==="get"||s.kind==="set")?this.raise(p.PatternHasAccessor,s.key):s.type==="Property"&&s.method?this.raise(p.PatternHasMethod,s.key):super.toAssignableObjectExpressionProp(s,e,i)}finishCallExpression(s,e){const i=super.finishCallExpression(s,e);return i.callee.type==="Import"?(this.castNodeTo(i,"ImportExpression"),i.source=i.arguments[0],i.options=i.arguments[1]??null,i.attributes=i.arguments[1]??null,delete i.arguments,delete i.callee):i.type==="OptionalCallExpression"?this.castNodeTo(i,"CallExpression"):i.optional=!1,i}toReferencedArguments(s){s.type!=="ImportExpression"&&super.toReferencedArguments(s)}parseExport(s,e){var n;const i=this.state.lastTokStartLoc,a=super.parseExport(s,e);switch(a.type){case"ExportAllDeclaration":a.exported=null;break;case"ExportNamedDeclaration":a.specifiers.length===1&&a.specifiers[0].type==="ExportNamespaceSpecifier"&&(this.castNodeTo(a,"ExportAllDeclaration"),a.exported=a.specifiers[0].exported,delete a.specifiers);case"ExportDefaultDeclaration":{const{declaration:o}=a;(o==null?void 0:o.type)==="ClassDeclaration"&&((n=o.decorators)==null?void 0:n.length)>0&&o.start===a.start&&this.resetStartLocation(a,i)}break}return a}stopParseSubscript(s,e){const i=super.stopParseSubscript(s,e);return e.optionalChainMember?this.estreeParseChainExpression(i,s.loc.end):i}parseMember(s,e,i,a,n){const o=super.parseMember(s,e,i,a,n);return o.type==="OptionalMemberExpression"?this.castNodeTo(o,"MemberExpression"):o.optional=!1,o}isOptionalMemberExpression(s){return s.type==="ChainExpression"?s.expression.type==="MemberExpression":super.isOptionalMemberExpression(s)}hasPropertyAsPrivateName(s){return s.type==="ChainExpression"&&(s=s.expression),super.hasPropertyAsPrivateName(s)}isObjectProperty(s){return s.type==="Property"&&s.kind==="init"&&!s.method}isObjectMethod(s){return s.type==="Property"&&(s.method||s.kind==="get"||s.kind==="set")}castNodeTo(s,e){const i=super.castNodeTo(s,e);return this.fillOptionalPropertiesForTSESLint(i),i}cloneIdentifier(s){const e=super.cloneIdentifier(s);return this.fillOptionalPropertiesForTSESLint(e),e}cloneStringLiteral(s){return s.type==="Literal"?this.cloneEstreeStringLiteral(s):super.cloneStringLiteral(s)}finishNodeAt(s,e,i){return nt(super.finishNodeAt(s,e,i))}finishNode(s,e){const i=super.finishNode(s,e);return this.fillOptionalPropertiesForTSESLint(i),i}resetStartLocation(s,e){super.resetStartLocation(s,e),nt(s)}resetEndLocation(s,e=this.state.lastTokEndLoc){super.resetEndLocation(s,e),nt(s)}};class Ct{constructor(t,s){m(this,"token");m(this,"preserveSpace");this.token=t,this.preserveSpace=!!s}}const R={brace:new Ct("{"),j_oTag:new Ct("<tag"),j_cTag:new Ct("</tag"),j_expr:new Ct("<tag>...</tag>",!0)},E=!0,x=!0,ts=!0,ot=!0,Ee=!0,da=!0;class Zs{constructor(t,s={}){m(this,"label");m(this,"keyword");m(this,"beforeExpr");m(this,"startsExpr");m(this,"rightAssociative");m(this,"isLoop");m(this,"isAssign");m(this,"prefix");m(this,"postfix");m(this,"binop");this.label=t,this.keyword=s.keyword,this.beforeExpr=!!s.beforeExpr,this.startsExpr=!!s.startsExpr,this.rightAssociative=!!s.rightAssociative,this.isLoop=!!s.isLoop,this.isAssign=!!s.isAssign,this.prefix=!!s.prefix,this.postfix=!!s.postfix,this.binop=s.binop!=null?s.binop:null}}const ss=new Map;function v(r,t={}){t.keyword=r;const s=T(r,t);return ss.set(r,s),s}function te(r,t){return T(r,{beforeExpr:E,binop:t})}let ct=-1;const is=[],rs=[],as=[],ns=[],os=[],cs=[];function T(r,t={}){return++ct,rs.push(r),as.push(t.binop??-1),ns.push(t.beforeExpr??!1),os.push(t.startsExpr??!1),cs.push(t.prefix??!1),is.push(new Zs(r,t)),ct}function C(r,t={}){return++ct,ss.set(r,ct),rs.push(r),as.push(t.binop??-1),ns.push(t.beforeExpr??!1),os.push(t.startsExpr??!1),cs.push(t.prefix??!1),is.push(new Zs("name",t)),ct}const ma={bracketL:T("[",{beforeExpr:E,startsExpr:x}),bracketHashL:T("#[",{beforeExpr:E,startsExpr:x}),bracketBarL:T("[|",{beforeExpr:E,startsExpr:x}),bracketR:T("]"),bracketBarR:T("|]"),braceL:T("{",{beforeExpr:E,startsExpr:x}),braceBarL:T("{|",{beforeExpr:E,startsExpr:x}),braceHashL:T("#{",{beforeExpr:E,startsExpr:x}),braceR:T("}"),braceBarR:T("|}"),parenL:T("(",{beforeExpr:E,startsExpr:x}),parenR:T(")"),comma:T(",",{beforeExpr:E}),semi:T(";",{beforeExpr:E}),colon:T(":",{beforeExpr:E}),doubleColon:T("::",{beforeExpr:E}),dot:T("."),question:T("?",{beforeExpr:E}),questionDot:T("?."),arrow:T("=>",{beforeExpr:E}),template:T("template"),ellipsis:T("...",{beforeExpr:E}),backQuote:T("`",{startsExpr:x}),dollarBraceL:T("${",{beforeExpr:E,startsExpr:x}),templateTail:T("...`",{startsExpr:x}),templateNonTail:T("...${",{beforeExpr:E,startsExpr:x}),at:T("@"),hash:T("#",{startsExpr:x}),interpreterDirective:T("#!..."),eq:T("=",{beforeExpr:E,isAssign:ot}),assign:T("_=",{beforeExpr:E,isAssign:ot}),slashAssign:T("_=",{beforeExpr:E,isAssign:ot}),xorAssign:T("_=",{beforeExpr:E,isAssign:ot}),moduloAssign:T("_=",{beforeExpr:E,isAssign:ot}),incDec:T("++/--",{prefix:Ee,postfix:da,startsExpr:x}),bang:T("!",{beforeExpr:E,prefix:Ee,startsExpr:x}),tilde:T("~",{beforeExpr:E,prefix:Ee,startsExpr:x}),doubleCaret:T("^^",{startsExpr:x}),doubleAt:T("@@",{startsExpr:x}),pipeline:te("|>",0),nullishCoalescing:te("??",1),logicalOR:te("||",1),logicalAND:te("&&",2),bitwiseOR:te("|",3),bitwiseXOR:te("^",4),bitwiseAND:te("&",5),equality:te("==/!=/===/!==",6),lt:te("</>/<=/>=",7),gt:te("</>/<=/>=",7),relational:te("</>/<=/>=",7),bitShift:te("<</>>/>>>",8),bitShiftL:te("<</>>/>>>",8),bitShiftR:te("<</>>/>>>",8),plusMin:T("+/-",{beforeExpr:E,binop:9,prefix:Ee,startsExpr:x}),modulo:T("%",{binop:10,startsExpr:x}),star:T("*",{binop:10}),slash:te("/",10),exponent:T("**",{beforeExpr:E,binop:11,rightAssociative:!0}),_in:v("in",{beforeExpr:E,binop:7}),_instanceof:v("instanceof",{beforeExpr:E,binop:7}),_break:v("break"),_case:v("case",{beforeExpr:E}),_catch:v("catch"),_continue:v("continue"),_debugger:v("debugger"),_default:v("default",{beforeExpr:E}),_else:v("else",{beforeExpr:E}),_finally:v("finally"),_function:v("function",{startsExpr:x}),_if:v("if"),_return:v("return",{beforeExpr:E}),_switch:v("switch"),_throw:v("throw",{beforeExpr:E,prefix:Ee,startsExpr:x}),_try:v("try"),_var:v("var"),_const:v("const"),_with:v("with"),_new:v("new",{beforeExpr:E,startsExpr:x}),_this:v("this",{startsExpr:x}),_super:v("super",{startsExpr:x}),_class:v("class",{startsExpr:x}),_extends:v("extends",{beforeExpr:E}),_export:v("export"),_import:v("import",{startsExpr:x}),_null:v("null",{startsExpr:x}),_true:v("true",{startsExpr:x}),_false:v("false",{startsExpr:x}),_typeof:v("typeof",{beforeExpr:E,prefix:Ee,startsExpr:x}),_void:v("void",{beforeExpr:E,prefix:Ee,startsExpr:x}),_delete:v("delete",{beforeExpr:E,prefix:Ee,startsExpr:x}),_do:v("do",{isLoop:ts,beforeExpr:E}),_for:v("for",{isLoop:ts}),_while:v("while",{isLoop:ts}),_as:C("as",{startsExpr:x}),_assert:C("assert",{startsExpr:x}),_async:C("async",{startsExpr:x}),_await:C("await",{startsExpr:x}),_defer:C("defer",{startsExpr:x}),_from:C("from",{startsExpr:x}),_get:C("get",{startsExpr:x}),_let:C("let",{startsExpr:x}),_meta:C("meta",{startsExpr:x}),_of:C("of",{startsExpr:x}),_sent:C("sent",{startsExpr:x}),_set:C("set",{startsExpr:x}),_source:C("source",{startsExpr:x}),_static:C("static",{startsExpr:x}),_using:C("using",{startsExpr:x}),_yield:C("yield",{startsExpr:x}),_asserts:C("asserts",{startsExpr:x}),_checks:C("checks",{startsExpr:x}),_exports:C("exports",{startsExpr:x}),_global:C("global",{startsExpr:x}),_implements:C("implements",{startsExpr:x}),_intrinsic:C("intrinsic",{startsExpr:x}),_infer:C("infer",{startsExpr:x}),_is:C("is",{startsExpr:x}),_mixins:C("mixins",{startsExpr:x}),_proto:C("proto",{startsExpr:x}),_require:C("require",{startsExpr:x}),_satisfies:C("satisfies",{startsExpr:x}),_keyof:C("keyof",{startsExpr:x}),_readonly:C("readonly",{startsExpr:x}),_unique:C("unique",{startsExpr:x}),_abstract:C("abstract",{startsExpr:x}),_declare:C("declare",{startsExpr:x}),_enum:C("enum",{startsExpr:x}),_module:C("module",{startsExpr:x}),_namespace:C("namespace",{startsExpr:x}),_interface:C("interface",{startsExpr:x}),_type:C("type",{startsExpr:x}),_opaque:C("opaque",{startsExpr:x}),name:T("name",{startsExpr:x}),placeholder:T("%%",{startsExpr:!0}),string:T("string",{startsExpr:x}),num:T("num",{startsExpr:x}),bigint:T("bigint",{startsExpr:x}),decimal:T("decimal",{startsExpr:x}),regexp:T("regexp",{startsExpr:x}),privateName:T("#name",{startsExpr:x}),eof:T("eof"),jsxName:T("jsxName"),jsxText:T("jsxText",{beforeExpr:!0}),jsxTagStart:T("jsxTagStart",{startsExpr:!0}),jsxTagEnd:T("jsxTagEnd")};function O(r){return r>=93&&r<=133}function ya(r){return r<=92}function ue(r){return r>=58&&r<=133}function Qs(r){return r>=58&&r<=137}function xa(r){return ns[r]}function ht(r){return os[r]}function Pa(r){return r>=29&&r<=33}function ei(r){return r>=129&&r<=131}function ba(r){return r>=90&&r<=92}function hs(r){return r>=58&&r<=92}function ga(r){return r>=39&&r<=59}function wa(r){return r===34}function Ta(r){return cs[r]}function Aa(r){return r>=121&&r<=123}function Sa(r){return r>=124&&r<=130}function Ce(r){return rs[r]}function kt(r){return as[r]}function Ia(r){return r===57}function ls(r){return r>=24&&r<=25}function ti(r){return is[r]}let us="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟍꟐꟑꟓꟕ-Ƛꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",si="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・";const Ea=new RegExp("["+us+"]"),Ca=new RegExp("["+us+si+"]");us=si=null;const ii=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],ka=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239];function ps(r,t){let s=65536;for(let e=0,i=t.length;e<i;e+=2){if(s+=t[e],s>r)return!1;if(s+=t[e+1],s>=r)return!0}return!1}function ge(r){return r<65?r===36:r<=90?!0:r<97?r===95:r<=122?!0:r<=65535?r>=170&&Ea.test(String.fromCharCode(r)):ps(r,ii)}function $e(r){return r<48?r===36:r<58?!0:r<65?!1:r<=90?!0:r<97?r===95:r<=122?!0:r<=65535?r>=170&&Ca.test(String.fromCharCode(r)):ps(r,ii)||ps(r,ka)}const fs={keyword:["break","case","catch","continue","debugger","default","do","else","finally","for","function","if","return","switch","throw","try","var","const","while","with","new","this","super","class","extends","export","import","null","true","false","in","instanceof","typeof","void","delete"],strict:["implements","interface","let","package","private","protected","public","static","yield"],strictBind:["eval","arguments"]},Na=new Set(fs.keyword),va=new Set(fs.strict),Oa=new Set(fs.strictBind);function ri(r,t){return t&&r==="await"||r==="enum"}function ai(r,t){return ri(r,t)||va.has(r)}function ni(r){return Oa.has(r)}function oi(r,t){return ai(r,t)||ni(r)}function Da(r){return Na.has(r)}function La(r,t,s){return r===64&&t===64&&ge(s)}const Ma=new Set(["break","case","catch","continue","debugger","default","do","else","finally","for","function","if","return","switch","throw","try","var","const","while","with","new","this","super","class","extends","export","import","null","true","false","in","instanceof","typeof","void","delete","implements","interface","let","package","private","protected","public","static","yield","eval","arguments","enum","await"]);function Fa(r){return Ma.has(r)}class ds{constructor(t){m(this,"flags",0);m(this,"names",new Map);m(this,"firstLexicalName","");this.flags=t}}class ms{constructor(t,s){m(this,"parser");m(this,"scopeStack",[]);m(this,"inModule");m(this,"undefinedExports",new Map);this.parser=t,this.inModule=s}get inTopLevel(){return(this.currentScope().flags&1)>0}get inFunction(){return(this.currentVarScopeFlags()&2)>0}get allowSuper(){return(this.currentThisScopeFlags()&16)>0}get allowDirectSuper(){return(this.currentThisScopeFlags()&32)>0}get inClass(){return(this.currentThisScopeFlags()&64)>0}get inClassAndNotInNonArrowFunction(){const t=this.currentThisScopeFlags();return(t&64)>0&&(t&2)===0}get inStaticBlock(){for(let t=this.scopeStack.length-1;;t--){const{flags:s}=this.scopeStack[t];if(s&128)return!0;if(s&707)return!1}}get inNonArrowFunction(){return(this.currentThisScopeFlags()&2)>0}get inBareCaseStatement(){return(this.currentScope().flags&256)>0}get treatFunctionsAsVar(){return this.treatFunctionsAsVarInScope(this.currentScope())}createScope(t){return new ds(t)}enter(t){this.scopeStack.push(this.createScope(t))}exit(){return this.scopeStack.pop().flags}treatFunctionsAsVarInScope(t){return!!(t.flags&130||!this.parser.inModule&&t.flags&1)}declareName(t,s,e){let i=this.currentScope();if(s&8||s&16){this.checkRedeclarationInScope(i,t,s,e);let a=i.names.get(t)||0;s&16?a=a|4:(i.firstLexicalName||(i.firstLexicalName=t),a=a|2),i.names.set(t,a),s&8&&this.maybeExportDefined(i,t)}else if(s&4)for(let a=this.scopeStack.length-1;a>=0&&(i=this.scopeStack[a],this.checkRedeclarationInScope(i,t,s,e),i.names.set(t,(i.names.get(t)||0)|1),this.maybeExportDefined(i,t),!(i.flags&643));--a);this.parser.inModule&&i.flags&1&&this.undefinedExports.delete(t)}maybeExportDefined(t,s){this.parser.inModule&&t.flags&1&&this.undefinedExports.delete(s)}checkRedeclarationInScope(t,s,e,i){this.isRedeclaredInScope(t,s,e)&&this.parser.raise(p.VarRedeclaration,i,{identifierName:s})}isRedeclaredInScope(t,s,e){if(!(e&1))return!1;if(e&8)return t.names.has(s);const i=t.names.get(s);return e&16?(i&2)>0||!this.treatFunctionsAsVarInScope(t)&&(i&1)>0:(i&2)>0&&!(t.flags&8&&t.firstLexicalName===s)||!this.treatFunctionsAsVarInScope(t)&&(i&4)>0}checkLocalExport(t){const{name:s}=t;this.scopeStack[0].names.has(s)||this.undefinedExports.set(s,t.loc.start)}currentScope(){return this.scopeStack[this.scopeStack.length-1]}currentVarScopeFlags(){for(let t=this.scopeStack.length-1;;t--){const{flags:s}=this.scopeStack[t];if(s&643)return s}}currentThisScopeFlags(){for(let t=this.scopeStack.length-1;;t--){const{flags:s}=this.scopeStack[t];if(s&707&&!(s&4))return s}}}class Ba extends ds{constructor(){super(...arguments);m(this,"declareFunctions",new Set)}}class Ra extends ms{createScope(t){return new Ba(t)}declareName(t,s,e){const i=this.currentScope();if(s&2048){this.checkRedeclarationInScope(i,t,s,e),this.maybeExportDefined(i,t),i.declareFunctions.add(t);return}super.declareName(t,s,e)}isRedeclaredInScope(t,s,e){if(super.isRedeclaredInScope(t,s,e))return!0;if(e&2048&&!t.declareFunctions.has(s)){const i=t.names.get(s);return(i&4)>0||(i&2)>0}return!1}checkLocalExport(t){this.scopeStack[0].declareFunctions.has(t.name)||super.checkLocalExport(t)}}const _a=new Set(["_","any","bool","boolean","empty","extends","false","interface","mixed","null","number","static","string","true","typeof","void"]),A=ye`flow`({AmbiguousConditionalArrow:"Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",AmbiguousDeclareModuleKind:"Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module.",AssignReservedType:({reservedType:r})=>`Cannot overwrite reserved type ${r}.`,DeclareClassElement:"The `declare` modifier can only appear on class fields.",DeclareClassFieldInitializer:"Initializers are not allowed in fields with the `declare` modifier.",DuplicateDeclareModuleExports:"Duplicate `declare module.exports` statement.",EnumBooleanMemberNotInitialized:({memberName:r,enumName:t})=>`Boolean enum members need to be initialized. Use either \`${r} = true,\` or \`${r} = false,\` in enum \`${t}\`.`,EnumDuplicateMemberName:({memberName:r,enumName:t})=>`Enum member names need to be unique, but the name \`${r}\` has already been used before in enum \`${t}\`.`,EnumInconsistentMemberValues:({enumName:r})=>`Enum \`${r}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,EnumInvalidExplicitType:({invalidEnumType:r,enumName:t})=>`Enum type \`${r}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${t}\`.`,EnumInvalidExplicitTypeUnknownSupplied:({enumName:r})=>`Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${r}\`.`,EnumInvalidMemberInitializerPrimaryType:({enumName:r,memberName:t,explicitType:s})=>`Enum \`${r}\` has type \`${s}\`, so the initializer of \`${t}\` needs to be a ${s} literal.`,EnumInvalidMemberInitializerSymbolType:({enumName:r,memberName:t})=>`Symbol enum members cannot be initialized. Use \`${t},\` in enum \`${r}\`.`,EnumInvalidMemberInitializerUnknownType:({enumName:r,memberName:t})=>`The enum member initializer for \`${t}\` needs to be a literal (either a boolean, number, or string) in enum \`${r}\`.`,EnumInvalidMemberName:({enumName:r,memberName:t,suggestion:s})=>`Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${t}\`, consider using \`${s}\`, in enum \`${r}\`.`,EnumNumberMemberNotInitialized:({enumName:r,memberName:t})=>`Number enum members need to be initialized, e.g. \`${t} = 1\` in enum \`${r}\`.`,EnumStringMemberInconsistentlyInitialized:({enumName:r})=>`String enum members need to consistently either all use initializers, or use no initializers, in enum \`${r}\`.`,GetterMayNotHaveThisParam:"A getter cannot have a `this` parameter.",ImportReflectionHasImportType:"An `import module` declaration can not use `type` or `typeof` keyword.",ImportTypeShorthandOnlyInPureImport:"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.",InexactInsideExact:"Explicit inexact syntax cannot appear inside an explicit exact object type.",InexactInsideNonObject:"Explicit inexact syntax cannot appear in class or interface definitions.",InexactVariance:"Explicit inexact syntax cannot have variance.",InvalidNonTypeImportInDeclareModule:"Imports within a `declare module` body must always be `import type` or `import typeof`.",MissingTypeParamDefault:"Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",NestedDeclareModule:"`declare module` cannot be used inside another `declare module`.",NestedFlowComment:"Cannot have a flow comment inside another flow comment.",PatternIsOptional:Object.assign({message:"A binding pattern parameter cannot be optional in an implementation signature."},{}),SetterMayNotHaveThisParam:"A setter cannot have a `this` parameter.",SpreadVariance:"Spread properties cannot have variance.",ThisParamAnnotationRequired:"A type annotation is required for the `this` parameter.",ThisParamBannedInConstructor:"Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",ThisParamMayNotBeOptional:"The `this` parameter cannot be optional.",ThisParamMustBeFirst:"The `this` parameter must be the first function parameter.",ThisParamNoDefault:"The `this` parameter may not have a default value.",TypeBeforeInitializer:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeCastInPattern:"The type cast expression is expected to be wrapped with parenthesis.",UnexpectedExplicitInexactInObject:"Explicit inexact syntax must appear at the end of an inexact object.",UnexpectedReservedType:({reservedType:r})=>`Unexpected reserved type ${r}.`,UnexpectedReservedUnderscore:"`_` is only allowed as a type argument to call or new.",UnexpectedSpaceBetweenModuloChecks:"Spaces between `%` and `checks` are not allowed here.",UnexpectedSpreadType:"Spread operator cannot appear in class or interface definitions.",UnexpectedSubtractionOperand:'Unexpected token, expected "number" or "bigint".',UnexpectedTokenAfterTypeParameter:"Expected an arrow function after this type parameter declaration.",UnexpectedTypeParameterBeforeAsyncArrowFunction:"Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",UnsupportedDeclareExportKind:({unsupportedExportKind:r,suggestion:t})=>`\`declare export ${r}\` is not supported. Use \`${t}\` instead.`,UnsupportedStatementInDeclareModule:"Only declares and type imports are allowed inside declare module.",UnterminatedFlowComment:"Unterminated flow-comment."});function ja(r){return r.type==="DeclareExportAllDeclaration"||r.type==="DeclareExportDeclaration"&&(!r.declaration||r.declaration.type!=="TypeAlias"&&r.declaration.type!=="InterfaceDeclaration")}function ci(r){return r.importKind==="type"||r.importKind==="typeof"}const Ua={const:"declare export var",let:"declare export var",type:"export type",interface:"export interface"};function $a(r,t){const s=[],e=[];for(let i=0;i<r.length;i++)(t(r[i],i,r)?s:e).push(r[i]);return[s,e]}const qa=/\*?\s*@((?:no)?flow)\b/;var za=r=>class extends r{constructor(){super(...arguments);m(this,"flowPragma")}getScopeHandler(){return Ra}shouldParseTypes(){return this.getPluginOption("flow","all")||this.flowPragma==="flow"}finishToken(e,i){e!==134&&e!==13&&e!==28&&this.flowPragma===void 0&&(this.flowPragma=null),super.finishToken(e,i)}addComment(e){if(this.flowPragma===void 0){const i=qa.exec(e.value);if(i)if(i[1]==="flow")this.flowPragma="flow";else if(i[1]==="noflow")this.flowPragma="noflow";else throw new Error("Unexpected flow pragma")}super.addComment(e)}flowParseTypeInitialiser(e){const i=this.state.inType;this.state.inType=!0,this.expect(e||14);const a=this.flowParseType();return this.state.inType=i,a}flowParsePredicate(){const e=this.startNode(),i=this.state.startLoc;return this.next(),this.expectContextual(110),this.state.lastTokStartLoc.index>i.index+1&&this.raise(A.UnexpectedSpaceBetweenModuloChecks,i),this.eat(10)?(e.value=super.parseExpression(),this.expect(11),this.finishNode(e,"DeclaredPredicate")):this.finishNode(e,"InferredPredicate")}flowParseTypeAndPredicateInitialiser(){const e=this.state.inType;this.state.inType=!0,this.expect(14);let i=null,a=null;return this.match(54)?(this.state.inType=e,a=this.flowParsePredicate()):(i=this.flowParseType(),this.state.inType=e,this.match(54)&&(a=this.flowParsePredicate())),[i,a]}flowParseDeclareClass(e){return this.next(),this.flowParseInterfaceish(e,!0),this.finishNode(e,"DeclareClass")}flowParseDeclareFunction(e){this.next();const i=e.id=this.parseIdentifier(),a=this.startNode(),n=this.startNode();this.match(47)?a.typeParameters=this.flowParseTypeParameterDeclaration():a.typeParameters=null,this.expect(10);const o=this.flowParseFunctionTypeParams();return a.params=o.params,a.rest=o.rest,a.this=o._this,this.expect(11),[a.returnType,e.predicate]=this.flowParseTypeAndPredicateInitialiser(),n.typeAnnotation=this.finishNode(a,"FunctionTypeAnnotation"),i.typeAnnotation=this.finishNode(n,"TypeAnnotation"),this.resetEndLocation(i),this.semicolon(),this.scope.declareName(e.id.name,2048,e.id.loc.start),this.finishNode(e,"DeclareFunction")}flowParseDeclare(e,i){if(this.match(80))return this.flowParseDeclareClass(e);if(this.match(68))return this.flowParseDeclareFunction(e);if(this.match(74))return this.flowParseDeclareVariable(e);if(this.eatContextual(127))return this.match(16)?this.flowParseDeclareModuleExports(e):(i&&this.raise(A.NestedDeclareModule,this.state.lastTokStartLoc),this.flowParseDeclareModule(e));if(this.isContextual(130))return this.flowParseDeclareTypeAlias(e);if(this.isContextual(131))return this.flowParseDeclareOpaqueType(e);if(this.isContextual(129))return this.flowParseDeclareInterface(e);if(this.match(82))return this.flowParseDeclareExportDeclaration(e,i);this.unexpected()}flowParseDeclareVariable(e){return this.next(),e.id=this.flowParseTypeAnnotatableIdentifier(!0),this.scope.declareName(e.id.name,5,e.id.loc.start),this.semicolon(),this.finishNode(e,"DeclareVariable")}flowParseDeclareModule(e){this.scope.enter(0),this.match(134)?e.id=super.parseExprAtom():e.id=this.parseIdentifier();const i=e.body=this.startNode(),a=i.body=[];for(this.expect(5);!this.match(8);){let c=this.startNode();this.match(83)?(this.next(),!this.isContextual(130)&&!this.match(87)&&this.raise(A.InvalidNonTypeImportInDeclareModule,this.state.lastTokStartLoc),super.parseImport(c)):(this.expectContextual(125,A.UnsupportedStatementInDeclareModule),c=this.flowParseDeclare(c,!0)),a.push(c)}this.scope.exit(),this.expect(8),this.finishNode(i,"BlockStatement");let n=null,o=!1;return a.forEach(c=>{ja(c)?(n==="CommonJS"&&this.raise(A.AmbiguousDeclareModuleKind,c),n="ES"):c.type==="DeclareModuleExports"&&(o&&this.raise(A.DuplicateDeclareModuleExports,c),n==="ES"&&this.raise(A.AmbiguousDeclareModuleKind,c),n="CommonJS",o=!0)}),e.kind=n||"CommonJS",this.finishNode(e,"DeclareModule")}flowParseDeclareExportDeclaration(e,i){if(this.expect(82),this.eat(65))return this.match(68)||this.match(80)?e.declaration=this.flowParseDeclare(this.startNode()):(e.declaration=this.flowParseType(),this.semicolon()),e.default=!0,this.finishNode(e,"DeclareExportDeclaration");if(this.match(75)||this.isLet()||(this.isContextual(130)||this.isContextual(129))&&!i){const a=this.state.value;throw this.raise(A.UnsupportedDeclareExportKind,this.state.startLoc,{unsupportedExportKind:a,suggestion:Ua[a]})}if(this.match(74)||this.match(68)||this.match(80)||this.isContextual(131))return e.declaration=this.flowParseDeclare(this.startNode()),e.default=!1,this.finishNode(e,"DeclareExportDeclaration");if(this.match(55)||this.match(5)||this.isContextual(129)||this.isContextual(130)||this.isContextual(131))return e=this.parseExport(e,null),e.type==="ExportNamedDeclaration"?(e.default=!1,delete e.exportKind,this.castNodeTo(e,"DeclareExportDeclaration")):this.castNodeTo(e,"DeclareExportAllDeclaration");this.unexpected()}flowParseDeclareModuleExports(e){return this.next(),this.expectContextual(111),e.typeAnnotation=this.flowParseTypeAnnotation(),this.semicolon(),this.finishNode(e,"DeclareModuleExports")}flowParseDeclareTypeAlias(e){this.next();const i=this.flowParseTypeAlias(e);return this.castNodeTo(i,"DeclareTypeAlias"),i}flowParseDeclareOpaqueType(e){this.next();const i=this.flowParseOpaqueType(e,!0);return this.castNodeTo(i,"DeclareOpaqueType"),i}flowParseDeclareInterface(e){return this.next(),this.flowParseInterfaceish(e,!1),this.finishNode(e,"DeclareInterface")}flowParseInterfaceish(e,i){if(e.id=this.flowParseRestrictedIdentifier(!i,!0),this.scope.declareName(e.id.name,i?17:8201,e.id.loc.start),this.match(47)?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.extends=[],this.eat(81))do e.extends.push(this.flowParseInterfaceExtends());while(!i&&this.eat(12));if(i){if(e.implements=[],e.mixins=[],this.eatContextual(117))do e.mixins.push(this.flowParseInterfaceExtends());while(this.eat(12));if(this.eatContextual(113))do e.implements.push(this.flowParseInterfaceExtends());while(this.eat(12))}e.body=this.flowParseObjectType({allowStatic:i,allowExact:!1,allowSpread:!1,allowProto:i,allowInexact:!1})}flowParseInterfaceExtends(){const e=this.startNode();return e.id=this.flowParseQualifiedTypeIdentifier(),this.match(47)?e.typeParameters=this.flowParseTypeParameterInstantiation():e.typeParameters=null,this.finishNode(e,"InterfaceExtends")}flowParseInterface(e){return this.flowParseInterfaceish(e,!1),this.finishNode(e,"InterfaceDeclaration")}checkNotUnderscore(e){e==="_"&&this.raise(A.UnexpectedReservedUnderscore,this.state.startLoc)}checkReservedType(e,i,a){_a.has(e)&&this.raise(a?A.AssignReservedType:A.UnexpectedReservedType,i,{reservedType:e})}flowParseRestrictedIdentifier(e,i){return this.checkReservedType(this.state.value,this.state.startLoc,i),this.parseIdentifier(e)}flowParseTypeAlias(e){return e.id=this.flowParseRestrictedIdentifier(!1,!0),this.scope.declareName(e.id.name,8201,e.id.loc.start),this.match(47)?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.right=this.flowParseTypeInitialiser(29),this.semicolon(),this.finishNode(e,"TypeAlias")}flowParseOpaqueType(e,i){return this.expectContextual(130),e.id=this.flowParseRestrictedIdentifier(!0,!0),this.scope.declareName(e.id.name,8201,e.id.loc.start),this.match(47)?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.supertype=null,this.match(14)&&(e.supertype=this.flowParseTypeInitialiser(14)),e.impltype=null,i||(e.impltype=this.flowParseTypeInitialiser(29)),this.semicolon(),this.finishNode(e,"OpaqueType")}flowParseTypeParameter(e=!1){const i=this.state.startLoc,a=this.startNode(),n=this.flowParseVariance(),o=this.flowParseTypeAnnotatableIdentifier();return a.name=o.name,a.variance=n,a.bound=o.typeAnnotation,this.match(29)?(this.eat(29),a.default=this.flowParseType()):e&&this.raise(A.MissingTypeParamDefault,i),this.finishNode(a,"TypeParameter")}flowParseTypeParameterDeclaration(){const e=this.state.inType,i=this.startNode();i.params=[],this.state.inType=!0,this.match(47)||this.match(143)?this.next():this.unexpected();let a=!1;do{const n=this.flowParseTypeParameter(a);i.params.push(n),n.default&&(a=!0),this.match(48)||this.expect(12)}while(!this.match(48));return this.expect(48),this.state.inType=e,this.finishNode(i,"TypeParameterDeclaration")}flowInTopLevelContext(e){if(this.curContext()!==R.brace){const i=this.state.context;this.state.context=[i[0]];try{return e()}finally{this.state.context=i}}else return e()}flowParseTypeParameterInstantiationInExpression(){if(this.reScan_lt()===47)return this.flowParseTypeParameterInstantiation()}flowParseTypeParameterInstantiation(){const e=this.startNode(),i=this.state.inType;return this.state.inType=!0,e.params=[],this.flowInTopLevelContext(()=>{this.expect(47);const a=this.state.noAnonFunctionType;for(this.state.noAnonFunctionType=!1;!this.match(48);)e.params.push(this.flowParseType()),this.match(48)||this.expect(12);this.state.noAnonFunctionType=a}),this.state.inType=i,!this.state.inType&&this.curContext()===R.brace&&this.reScan_lt_gt(),this.expect(48),this.finishNode(e,"TypeParameterInstantiation")}flowParseTypeParameterInstantiationCallOrNew(){if(this.reScan_lt()!==47)return;const e=this.startNode(),i=this.state.inType;for(e.params=[],this.state.inType=!0,this.expect(47);!this.match(48);)e.params.push(this.flowParseTypeOrImplicitInstantiation()),this.match(48)||this.expect(12);return this.expect(48),this.state.inType=i,this.finishNode(e,"TypeParameterInstantiation")}flowParseInterfaceType(){const e=this.startNode();if(this.expectContextual(129),e.extends=[],this.eat(81))do e.extends.push(this.flowParseInterfaceExtends());while(this.eat(12));return e.body=this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!1,allowProto:!1,allowInexact:!1}),this.finishNode(e,"InterfaceTypeAnnotation")}flowParseObjectPropertyKey(){return this.match(135)||this.match(134)?super.parseExprAtom():this.parseIdentifier(!0)}flowParseObjectTypeIndexer(e,i,a){return e.static=i,this.lookahead().type===14?(e.id=this.flowParseObjectPropertyKey(),e.key=this.flowParseTypeInitialiser()):(e.id=null,e.key=this.flowParseType()),this.expect(3),e.value=this.flowParseTypeInitialiser(),e.variance=a,this.finishNode(e,"ObjectTypeIndexer")}flowParseObjectTypeInternalSlot(e,i){return e.static=i,e.id=this.flowParseObjectPropertyKey(),this.expect(3),this.expect(3),this.match(47)||this.match(10)?(e.method=!0,e.optional=!1,e.value=this.flowParseObjectTypeMethodish(this.startNodeAt(e.loc.start))):(e.method=!1,this.eat(17)&&(e.optional=!0),e.value=this.flowParseTypeInitialiser()),this.finishNode(e,"ObjectTypeInternalSlot")}flowParseObjectTypeMethodish(e){for(e.params=[],e.rest=null,e.typeParameters=null,e.this=null,this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),this.expect(10),this.match(78)&&(e.this=this.flowParseFunctionTypeParam(!0),e.this.name=null,this.match(11)||this.expect(12));!this.match(11)&&!this.match(21);)e.params.push(this.flowParseFunctionTypeParam(!1)),this.match(11)||this.expect(12);return this.eat(21)&&(e.rest=this.flowParseFunctionTypeParam(!1)),this.expect(11),e.returnType=this.flowParseTypeInitialiser(),this.finishNode(e,"FunctionTypeAnnotation")}flowParseObjectTypeCallProperty(e,i){const a=this.startNode();return e.static=i,e.value=this.flowParseObjectTypeMethodish(a),this.finishNode(e,"ObjectTypeCallProperty")}flowParseObjectType({allowStatic:e,allowExact:i,allowSpread:a,allowProto:n,allowInexact:o}){const c=this.state.inType;this.state.inType=!0;const h=this.startNode();h.callProperties=[],h.properties=[],h.indexers=[],h.internalSlots=[];let l,u,f=!1;for(i&&this.match(6)?(this.expect(6),l=9,u=!0):(this.expect(5),l=8,u=!1),h.exact=u;!this.match(l);){let P=!1,S=null,B=null;const I=this.startNode();if(n&&this.isContextual(118)){const z=this.lookahead();z.type!==14&&z.type!==17&&(this.next(),S=this.state.startLoc,e=!1)}if(e&&this.isContextual(106)){const z=this.lookahead();z.type!==14&&z.type!==17&&(this.next(),P=!0)}const D=this.flowParseVariance();if(this.eat(0))S!=null&&this.unexpected(S),this.eat(0)?(D&&this.unexpected(D.loc.start),h.internalSlots.push(this.flowParseObjectTypeInternalSlot(I,P))):h.indexers.push(this.flowParseObjectTypeIndexer(I,P,D));else if(this.match(10)||this.match(47))S!=null&&this.unexpected(S),D&&this.unexpected(D.loc.start),h.callProperties.push(this.flowParseObjectTypeCallProperty(I,P));else{let z="init";if(this.isContextual(99)||this.isContextual(104)){const g=this.lookahead();Qs(g.type)&&(z=this.state.value,this.next())}const oe=this.flowParseObjectTypeProperty(I,P,S,D,z,a,o??!u);oe===null?(f=!0,B=this.state.lastTokStartLoc):h.properties.push(oe)}this.flowObjectTypeSemicolon(),B&&!this.match(8)&&!this.match(9)&&this.raise(A.UnexpectedExplicitInexactInObject,B)}this.expect(l),a&&(h.inexact=f);const d=this.finishNode(h,"ObjectTypeAnnotation");return this.state.inType=c,d}flowParseObjectTypeProperty(e,i,a,n,o,c,h){if(this.eat(21))return this.match(12)||this.match(13)||this.match(8)||this.match(9)?(c?h||this.raise(A.InexactInsideExact,this.state.lastTokStartLoc):this.raise(A.InexactInsideNonObject,this.state.lastTokStartLoc),n&&this.raise(A.InexactVariance,n),null):(c||this.raise(A.UnexpectedSpreadType,this.state.lastTokStartLoc),a!=null&&this.unexpected(a),n&&this.raise(A.SpreadVariance,n),e.argument=this.flowParseType(),this.finishNode(e,"ObjectTypeSpreadProperty"));{e.key=this.flowParseObjectPropertyKey(),e.static=i,e.proto=a!=null,e.kind=o;let l=!1;return this.match(47)||this.match(10)?(e.method=!0,a!=null&&this.unexpected(a),n&&this.unexpected(n.loc.start),e.value=this.flowParseObjectTypeMethodish(this.startNodeAt(e.loc.start)),(o==="get"||o==="set")&&this.flowCheckGetterSetterParams(e),!c&&e.key.name==="constructor"&&e.value.this&&this.raise(A.ThisParamBannedInConstructor,e.value.this)):(o!=="init"&&this.unexpected(),e.method=!1,this.eat(17)&&(l=!0),e.value=this.flowParseTypeInitialiser(),e.variance=n),e.optional=l,this.finishNode(e,"ObjectTypeProperty")}}flowCheckGetterSetterParams(e){const i=e.kind==="get"?0:1,a=e.value.params.length+(e.value.rest?1:0);e.value.this&&this.raise(e.kind==="get"?A.GetterMayNotHaveThisParam:A.SetterMayNotHaveThisParam,e.value.this),a!==i&&this.raise(e.kind==="get"?p.BadGetterArity:p.BadSetterArity,e),e.kind==="set"&&e.value.rest&&this.raise(p.BadSetterRestParameter,e)}flowObjectTypeSemicolon(){!this.eat(13)&&!this.eat(12)&&!this.match(8)&&!this.match(9)&&this.unexpected()}flowParseQualifiedTypeIdentifier(e,i){e??(e=this.state.startLoc);let a=i||this.flowParseRestrictedIdentifier(!0);for(;this.eat(16);){const n=this.startNodeAt(e);n.qualification=a,n.id=this.flowParseRestrictedIdentifier(!0),a=this.finishNode(n,"QualifiedTypeIdentifier")}return a}flowParseGenericType(e,i){const a=this.startNodeAt(e);return a.typeParameters=null,a.id=this.flowParseQualifiedTypeIdentifier(e,i),this.match(47)&&(a.typeParameters=this.flowParseTypeParameterInstantiation()),this.finishNode(a,"GenericTypeAnnotation")}flowParseTypeofType(){const e=this.startNode();return this.expect(87),e.argument=this.flowParsePrimaryType(),this.finishNode(e,"TypeofTypeAnnotation")}flowParseTupleType(){const e=this.startNode();for(e.types=[],this.expect(0);this.state.pos<this.length&&!this.match(3)&&(e.types.push(this.flowParseType()),!this.match(3));)this.expect(12);return this.expect(3),this.finishNode(e,"TupleTypeAnnotation")}flowParseFunctionTypeParam(e){let i=null,a=!1,n=null;const o=this.startNode(),c=this.lookahead(),h=this.state.type===78;return c.type===14||c.type===17?(h&&!e&&this.raise(A.ThisParamMustBeFirst,o),i=this.parseIdentifier(h),this.eat(17)&&(a=!0,h&&this.raise(A.ThisParamMayNotBeOptional,o)),n=this.flowParseTypeInitialiser()):n=this.flowParseType(),o.name=i,o.optional=a,o.typeAnnotation=n,this.finishNode(o,"FunctionTypeParam")}reinterpretTypeAsFunctionTypeParam(e){const i=this.startNodeAt(e.loc.start);return i.name=null,i.optional=!1,i.typeAnnotation=e,this.finishNode(i,"FunctionTypeParam")}flowParseFunctionTypeParams(e=[]){let i=null,a=null;for(this.match(78)&&(a=this.flowParseFunctionTypeParam(!0),a.name=null,this.match(11)||this.expect(12));!this.match(11)&&!this.match(21);)e.push(this.flowParseFunctionTypeParam(!1)),this.match(11)||this.expect(12);return this.eat(21)&&(i=this.flowParseFunctionTypeParam(!1)),{params:e,rest:i,_this:a}}flowIdentToTypeAnnotation(e,i,a){switch(a.name){case"any":return this.finishNode(i,"AnyTypeAnnotation");case"bool":case"boolean":return this.finishNode(i,"BooleanTypeAnnotation");case"mixed":return this.finishNode(i,"MixedTypeAnnotation");case"empty":return this.finishNode(i,"EmptyTypeAnnotation");case"number":return this.finishNode(i,"NumberTypeAnnotation");case"string":return this.finishNode(i,"StringTypeAnnotation");case"symbol":return this.finishNode(i,"SymbolTypeAnnotation");default:return this.checkNotUnderscore(a.name),this.flowParseGenericType(e,a)}}flowParsePrimaryType(){const e=this.state.startLoc,i=this.startNode();let a,n,o=!1;const c=this.state.noAnonFunctionType;switch(this.state.type){case 5:return this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!0,allowProto:!1,allowInexact:!0});case 6:return this.flowParseObjectType({allowStatic:!1,allowExact:!0,allowSpread:!0,allowProto:!1,allowInexact:!1});case 0:return this.state.noAnonFunctionType=!1,n=this.flowParseTupleType(),this.state.noAnonFunctionType=c,n;case 47:{const h=this.startNode();return h.typeParameters=this.flowParseTypeParameterDeclaration(),this.expect(10),a=this.flowParseFunctionTypeParams(),h.params=a.params,h.rest=a.rest,h.this=a._this,this.expect(11),this.expect(19),h.returnType=this.flowParseType(),this.finishNode(h,"FunctionTypeAnnotation")}case 10:{const h=this.startNode();if(this.next(),!this.match(11)&&!this.match(21))if(O(this.state.type)||this.match(78)){const l=this.lookahead().type;o=l!==17&&l!==14}else o=!0;if(o){if(this.state.noAnonFunctionType=!1,n=this.flowParseType(),this.state.noAnonFunctionType=c,this.state.noAnonFunctionType||!(this.match(12)||this.match(11)&&this.lookahead().type===19))return this.expect(11),n;this.eat(12)}return n?a=this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(n)]):a=this.flowParseFunctionTypeParams(),h.params=a.params,h.rest=a.rest,h.this=a._this,this.expect(11),this.expect(19),h.returnType=this.flowParseType(),h.typeParameters=null,this.finishNode(h,"FunctionTypeAnnotation")}case 134:return this.parseLiteral(this.state.value,"StringLiteralTypeAnnotation");case 85:case 86:return i.value=this.match(85),this.next(),this.finishNode(i,"BooleanLiteralTypeAnnotation");case 53:if(this.state.value==="-"){if(this.next(),this.match(135))return this.parseLiteralAtNode(-this.state.value,"NumberLiteralTypeAnnotation",i);if(this.match(136))return this.parseLiteralAtNode(-this.state.value,"BigIntLiteralTypeAnnotation",i);throw this.raise(A.UnexpectedSubtractionOperand,this.state.startLoc)}this.unexpected();return;case 135:return this.parseLiteral(this.state.value,"NumberLiteralTypeAnnotation");case 136:return this.parseLiteral(this.state.value,"BigIntLiteralTypeAnnotation");case 88:return this.next(),this.finishNode(i,"VoidTypeAnnotation");case 84:return this.next(),this.finishNode(i,"NullLiteralTypeAnnotation");case 78:return this.next(),this.finishNode(i,"ThisTypeAnnotation");case 55:return this.next(),this.finishNode(i,"ExistsTypeAnnotation");case 87:return this.flowParseTypeofType();default:if(hs(this.state.type)){const h=Ce(this.state.type);return this.next(),super.createIdentifier(i,h)}else if(O(this.state.type))return this.isContextual(129)?this.flowParseInterfaceType():this.flowIdentToTypeAnnotation(e,i,this.parseIdentifier())}this.unexpected()}flowParsePostfixType(){const e=this.state.startLoc;let i=this.flowParsePrimaryType(),a=!1;for(;(this.match(0)||this.match(18))&&!this.canInsertSemicolon();){const n=this.startNodeAt(e),o=this.eat(18);a=a||o,this.expect(0),!o&&this.match(3)?(n.elementType=i,this.next(),i=this.finishNode(n,"ArrayTypeAnnotation")):(n.objectType=i,n.indexType=this.flowParseType(),this.expect(3),a?(n.optional=o,i=this.finishNode(n,"OptionalIndexedAccessType")):i=this.finishNode(n,"IndexedAccessType"))}return i}flowParsePrefixType(){const e=this.startNode();return this.eat(17)?(e.typeAnnotation=this.flowParsePrefixType(),this.finishNode(e,"NullableTypeAnnotation")):this.flowParsePostfixType()}flowParseAnonFunctionWithoutParens(){const e=this.flowParsePrefixType();if(!this.state.noAnonFunctionType&&this.eat(19)){const i=this.startNodeAt(e.loc.start);return i.params=[this.reinterpretTypeAsFunctionTypeParam(e)],i.rest=null,i.this=null,i.returnType=this.flowParseType(),i.typeParameters=null,this.finishNode(i,"FunctionTypeAnnotation")}return e}flowParseIntersectionType(){const e=this.startNode();this.eat(45);const i=this.flowParseAnonFunctionWithoutParens();for(e.types=[i];this.eat(45);)e.types.push(this.flowParseAnonFunctionWithoutParens());return e.types.length===1?i:this.finishNode(e,"IntersectionTypeAnnotation")}flowParseUnionType(){const e=this.startNode();this.eat(43);const i=this.flowParseIntersectionType();for(e.types=[i];this.eat(43);)e.types.push(this.flowParseIntersectionType());return e.types.length===1?i:this.finishNode(e,"UnionTypeAnnotation")}flowParseType(){const e=this.state.inType;this.state.inType=!0;const i=this.flowParseUnionType();return this.state.inType=e,i}flowParseTypeOrImplicitInstantiation(){if(this.state.type===132&&this.state.value==="_"){const e=this.state.startLoc,i=this.parseIdentifier();return this.flowParseGenericType(e,i)}else return this.flowParseType()}flowParseTypeAnnotation(){const e=this.startNode();return e.typeAnnotation=this.flowParseTypeInitialiser(),this.finishNode(e,"TypeAnnotation")}flowParseTypeAnnotatableIdentifier(e){const i=e?this.parseIdentifier():this.flowParseRestrictedIdentifier();return this.match(14)&&(i.typeAnnotation=this.flowParseTypeAnnotation(),this.resetEndLocation(i)),i}typeCastToParameter(e){return e.expression.typeAnnotation=e.typeAnnotation,this.resetEndLocation(e.expression,e.typeAnnotation.loc.end),e.expression}flowParseVariance(){let e=null;return this.match(53)?(e=this.startNode(),this.state.value==="+"?e.kind="plus":e.kind="minus",this.next(),this.finishNode(e,"Variance")):e}parseFunctionBody(e,i,a=!1){if(i){this.forwardNoArrowParamsConversionAt(e,()=>super.parseFunctionBody(e,!0,a));return}super.parseFunctionBody(e,!1,a)}parseFunctionBodyAndFinish(e,i,a=!1){if(this.match(14)){const n=this.startNode();[n.typeAnnotation,e.predicate]=this.flowParseTypeAndPredicateInitialiser(),e.returnType=n.typeAnnotation?this.finishNode(n,"TypeAnnotation"):null}return super.parseFunctionBodyAndFinish(e,i,a)}parseStatementLike(e){if(this.state.strict&&this.isContextual(129)){const a=this.lookahead();if(ue(a.type)){const n=this.startNode();return this.next(),this.flowParseInterface(n)}}else if(this.isContextual(126)){const a=this.startNode();return this.next(),this.flowParseEnumDeclaration(a)}const i=super.parseStatementLike(e);return this.flowPragma===void 0&&!this.isValidDirective(i)&&(this.flowPragma=null),i}parseExpressionStatement(e,i,a){if(i.type==="Identifier"){if(i.name==="declare"){if(this.match(80)||O(this.state.type)||this.match(68)||this.match(74)||this.match(82))return this.flowParseDeclare(e)}else if(O(this.state.type)){if(i.name==="interface")return this.flowParseInterface(e);if(i.name==="type")return this.flowParseTypeAlias(e);if(i.name==="opaque")return this.flowParseOpaqueType(e,!1)}}return super.parseExpressionStatement(e,i,a)}shouldParseExportDeclaration(){const{type:e}=this.state;return e===126||ei(e)?!this.state.containsEsc:super.shouldParseExportDeclaration()}isExportDefaultSpecifier(){const{type:e}=this.state;return e===126||ei(e)?this.state.containsEsc:super.isExportDefaultSpecifier()}parseExportDefaultExpression(){if(this.isContextual(126)){const e=this.startNode();return this.next(),this.flowParseEnumDeclaration(e)}return super.parseExportDefaultExpression()}parseConditional(e,i,a){if(!this.match(17))return e;if(this.state.maybeInArrowParameters){const d=this.lookaheadCharCode();if(d===44||d===61||d===58||d===41)return this.setOptionalParametersError(a),e}this.expect(17);const n=this.state.clone(),o=this.state.noArrowAt,c=this.startNodeAt(i);let{consequent:h,failed:l}=this.tryParseConditionalConsequent(),[u,f]=this.getArrowLikeExpressions(h);if(l||f.length>0){const d=[...o];if(f.length>0){this.state=n,this.state.noArrowAt=d;for(let P=0;P<f.length;P++)d.push(f[P].start);({consequent:h,failed:l}=this.tryParseConditionalConsequent()),[u,f]=this.getArrowLikeExpressions(h)}l&&u.length>1&&this.raise(A.AmbiguousConditionalArrow,n.startLoc),l&&u.length===1&&(this.state=n,d.push(u[0].start),this.state.noArrowAt=d,{consequent:h,failed:l}=this.tryParseConditionalConsequent())}return this.getArrowLikeExpressions(h,!0),this.state.noArrowAt=o,this.expect(14),c.test=e,c.consequent=h,c.alternate=this.forwardNoArrowParamsConversionAt(c,()=>this.parseMaybeAssign(void 0,void 0)),this.finishNode(c,"ConditionalExpression")}tryParseConditionalConsequent(){this.state.noArrowParamsConversionAt.push(this.state.start);const e=this.parseMaybeAssignAllowIn(),i=!this.match(14);return this.state.noArrowParamsConversionAt.pop(),{consequent:e,failed:i}}getArrowLikeExpressions(e,i){const a=[e],n=[];for(;a.length!==0;){const o=a.pop();o.type==="ArrowFunctionExpression"&&o.body.type!=="BlockStatement"?(o.typeParameters||!o.returnType?this.finishArrowValidation(o):n.push(o),a.push(o.body)):o.type==="ConditionalExpression"&&(a.push(o.consequent),a.push(o.alternate))}return i?(n.forEach(o=>this.finishArrowValidation(o)),[n,[]]):$a(n,o=>o.params.every(c=>this.isAssignable(c,!0)))}finishArrowValidation(e){var i;this.toAssignableList(e.params,(i=e.extra)==null?void 0:i.trailingCommaLoc,!1),this.scope.enter(6),super.checkParams(e,!1,!0),this.scope.exit()}forwardNoArrowParamsConversionAt(e,i){let a;return this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start))?(this.state.noArrowParamsConversionAt.push(this.state.start),a=i(),this.state.noArrowParamsConversionAt.pop()):a=i(),a}parseParenItem(e,i){const a=super.parseParenItem(e,i);if(this.eat(17)&&(a.optional=!0,this.resetEndLocation(e)),this.match(14)){const n=this.startNodeAt(i);return n.expression=a,n.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(n,"TypeCastExpression")}return a}assertModuleNodeAllowed(e){e.type==="ImportDeclaration"&&(e.importKind==="type"||e.importKind==="typeof")||e.type==="ExportNamedDeclaration"&&e.exportKind==="type"||e.type==="ExportAllDeclaration"&&e.exportKind==="type"||super.assertModuleNodeAllowed(e)}parseExportDeclaration(e){if(this.isContextual(130)){e.exportKind="type";const i=this.startNode();return this.next(),this.match(5)?(e.specifiers=this.parseExportSpecifiers(!0),super.parseExportFrom(e),null):this.flowParseTypeAlias(i)}else if(this.isContextual(131)){e.exportKind="type";const i=this.startNode();return this.next(),this.flowParseOpaqueType(i,!1)}else if(this.isContextual(129)){e.exportKind="type";const i=this.startNode();return this.next(),this.flowParseInterface(i)}else if(this.isContextual(126)){e.exportKind="value";const i=this.startNode();return this.next(),this.flowParseEnumDeclaration(i)}else return super.parseExportDeclaration(e)}eatExportStar(e){return super.eatExportStar(e)?!0:this.isContextual(130)&&this.lookahead().type===55?(e.exportKind="type",this.next(),this.next(),!0):!1}maybeParseExportNamespaceSpecifier(e){const{startLoc:i}=this.state,a=super.maybeParseExportNamespaceSpecifier(e);return a&&e.exportKind==="type"&&this.unexpected(i),a}parseClassId(e,i,a){super.parseClassId(e,i,a),this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration())}parseClassMember(e,i,a){const{startLoc:n}=this.state;if(this.isContextual(125)){if(super.parseClassMemberFromModifier(e,i))return;i.declare=!0}super.parseClassMember(e,i,a),i.declare&&(i.type!=="ClassProperty"&&i.type!=="ClassPrivateProperty"&&i.type!=="PropertyDefinition"?this.raise(A.DeclareClassElement,n):i.value&&this.raise(A.DeclareClassFieldInitializer,i.value))}isIterator(e){return e==="iterator"||e==="asyncIterator"}readIterator(){const e=super.readWord1(),i="@@"+e;(!this.isIterator(e)||!this.state.inType)&&this.raise(p.InvalidIdentifier,this.state.curPosition(),{identifierName:i}),this.finishToken(132,i)}getTokenFromCode(e){const i=this.input.charCodeAt(this.state.pos+1);e===123&&i===124?this.finishOp(6,2):this.state.inType&&(e===62||e===60)?this.finishOp(e===62?48:47,1):this.state.inType&&e===63?i===46?this.finishOp(18,2):this.finishOp(17,1):La(e,i,this.input.charCodeAt(this.state.pos+2))?(this.state.pos+=2,this.readIterator()):super.getTokenFromCode(e)}isAssignable(e,i){return e.type==="TypeCastExpression"?this.isAssignable(e.expression,i):super.isAssignable(e,i)}toAssignable(e,i=!1){!i&&e.type==="AssignmentExpression"&&e.left.type==="TypeCastExpression"&&(e.left=this.typeCastToParameter(e.left)),super.toAssignable(e,i)}toAssignableList(e,i,a){for(let n=0;n<e.length;n++){const o=e[n];(o==null?void 0:o.type)==="TypeCastExpression"&&(e[n]=this.typeCastToParameter(o))}super.toAssignableList(e,i,a)}toReferencedList(e,i){var a;for(let n=0;n<e.length;n++){const o=e[n];o&&o.type==="TypeCastExpression"&&!((a=o.extra)!=null&&a.parenthesized)&&(e.length>1||!i)&&this.raise(A.TypeCastInPattern,o.typeAnnotation)}return e}parseArrayLike(e,i,a,n){const o=super.parseArrayLike(e,i,a,n);return i&&!this.state.maybeInArrowParameters&&this.toReferencedList(o.elements),o}isValidLVal(e,i,a){return e==="TypeCastExpression"||super.isValidLVal(e,i,a)}parseClassProperty(e){return this.match(14)&&(e.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassProperty(e)}parseClassPrivateProperty(e){return this.match(14)&&(e.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassPrivateProperty(e)}isClassMethod(){return this.match(47)||super.isClassMethod()}isClassProperty(){return this.match(14)||super.isClassProperty()}isNonstaticConstructor(e){return!this.match(14)&&super.isNonstaticConstructor(e)}pushClassMethod(e,i,a,n,o,c){if(i.variance&&this.unexpected(i.variance.loc.start),delete i.variance,this.match(47)&&(i.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassMethod(e,i,a,n,o,c),i.params&&o){const h=i.params;h.length>0&&this.isThisParam(h[0])&&this.raise(A.ThisParamBannedInConstructor,i)}else if(i.type==="MethodDefinition"&&o&&i.value.params){const h=i.value.params;h.length>0&&this.isThisParam(h[0])&&this.raise(A.ThisParamBannedInConstructor,i)}}pushClassPrivateMethod(e,i,a,n){i.variance&&this.unexpected(i.variance.loc.start),delete i.variance,this.match(47)&&(i.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassPrivateMethod(e,i,a,n)}parseClassSuper(e){if(super.parseClassSuper(e),e.superClass&&(this.match(47)||this.match(51))&&(e.superTypeArguments=this.flowParseTypeParameterInstantiationInExpression()),this.isContextual(113)){this.next();const i=e.implements=[];do{const a=this.startNode();a.id=this.flowParseRestrictedIdentifier(!0),this.match(47)?a.typeParameters=this.flowParseTypeParameterInstantiation():a.typeParameters=null,i.push(this.finishNode(a,"ClassImplements"))}while(this.eat(12))}}checkGetterSetterParams(e){super.checkGetterSetterParams(e);const i=this.getObjectOrClassMethodParams(e);if(i.length>0){const a=i[0];this.isThisParam(a)&&e.kind==="get"?this.raise(A.GetterMayNotHaveThisParam,a):this.isThisParam(a)&&this.raise(A.SetterMayNotHaveThisParam,a)}}parsePropertyNamePrefixOperator(e){e.variance=this.flowParseVariance()}parseObjPropValue(e,i,a,n,o,c,h){e.variance&&this.unexpected(e.variance.loc.start),delete e.variance;let l;this.match(47)&&!c&&(l=this.flowParseTypeParameterDeclaration(),this.match(10)||this.unexpected());const u=super.parseObjPropValue(e,i,a,n,o,c,h);return l&&((u.value||u).typeParameters=l),u}parseFunctionParamType(e){return this.eat(17)&&(e.type!=="Identifier"&&this.raise(A.PatternIsOptional,e),this.isThisParam(e)&&this.raise(A.ThisParamMayNotBeOptional,e),e.optional=!0),this.match(14)?e.typeAnnotation=this.flowParseTypeAnnotation():this.isThisParam(e)&&this.raise(A.ThisParamAnnotationRequired,e),this.match(29)&&this.isThisParam(e)&&this.raise(A.ThisParamNoDefault,e),this.resetEndLocation(e),e}parseMaybeDefault(e,i){const a=super.parseMaybeDefault(e,i);return a.type==="AssignmentPattern"&&a.typeAnnotation&&a.right.start<a.typeAnnotation.start&&this.raise(A.TypeBeforeInitializer,a.typeAnnotation),a}checkImportReflection(e){super.checkImportReflection(e),e.module&&e.importKind!=="value"&&this.raise(A.ImportReflectionHasImportType,e.specifiers[0].loc.start)}parseImportSpecifierLocal(e,i,a){i.local=ci(e)?this.flowParseRestrictedIdentifier(!0,!0):this.parseIdentifier(),e.specifiers.push(this.finishImportSpecifier(i,a))}isPotentialImportPhase(e){if(super.isPotentialImportPhase(e))return!0;if(this.isContextual(130)){if(!e)return!0;const i=this.lookaheadCharCode();return i===123||i===42}return!e&&this.isContextual(87)}applyImportPhase(e,i,a,n){if(super.applyImportPhase(e,i,a,n),i){if(!a&&this.match(65))return;e.exportKind=a==="type"?a:"value"}else a==="type"&&this.match(55)&&this.unexpected(),e.importKind=a==="type"||a==="typeof"?a:"value"}parseImportSpecifier(e,i,a,n,o){const c=e.imported;let h=null;c.type==="Identifier"&&(c.name==="type"?h="type":c.name==="typeof"&&(h="typeof"));let l=!1;if(this.isContextual(93)&&!this.isLookaheadContextual("as")){const f=this.parseIdentifier(!0);h!==null&&!ue(this.state.type)?(e.imported=f,e.importKind=h,e.local=this.cloneIdentifier(f)):(e.imported=c,e.importKind=null,e.local=this.parseIdentifier())}else{if(h!==null&&ue(this.state.type))e.imported=this.parseIdentifier(!0),e.importKind=h;else{if(i)throw this.raise(p.ImportBindingIsString,e,{importName:c.value});e.imported=c,e.importKind=null}this.eatContextual(93)?e.local=this.parseIdentifier():(l=!0,e.local=this.cloneIdentifier(e.imported))}const u=ci(e);return a&&u&&this.raise(A.ImportTypeShorthandOnlyInPureImport,e),(a||u)&&this.checkReservedType(e.local.name,e.local.loc.start,!0),l&&!a&&!u&&this.checkReservedWord(e.local.name,e.loc.start,!0,!0),this.finishImportSpecifier(e,"ImportSpecifier")}parseBindingAtom(){switch(this.state.type){case 78:return this.parseIdentifier(!0);default:return super.parseBindingAtom()}}parseFunctionParams(e,i){const a=e.kind;a!=="get"&&a!=="set"&&this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),super.parseFunctionParams(e,i)}parseVarId(e,i){super.parseVarId(e,i),this.match(14)&&(e.id.typeAnnotation=this.flowParseTypeAnnotation(),this.resetEndLocation(e.id))}parseAsyncArrowFromCallExpression(e,i){if(this.match(14)){const a=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0,e.returnType=this.flowParseTypeAnnotation(),this.state.noAnonFunctionType=a}return super.parseAsyncArrowFromCallExpression(e,i)}shouldParseAsyncArrow(){return this.match(14)||super.shouldParseAsyncArrow()}parseMaybeAssign(e,i){let a=null,n;if(this.hasPlugin("jsx")&&(this.match(143)||this.match(47))){if(a=this.state.clone(),n=this.tryParse(()=>super.parseMaybeAssign(e,i),a),!n.error)return n.node;const{context:o}=this.state,c=o[o.length-1];(c===R.j_oTag||c===R.j_expr)&&o.pop()}if(n!=null&&n.error||this.match(47)){a=a||this.state.clone();let o;const c=this.tryParse(l=>{var d;o=this.flowParseTypeParameterDeclaration();const u=this.forwardNoArrowParamsConversionAt(o,()=>{const P=super.parseMaybeAssign(e,i);return this.resetStartLocationFromNode(P,o),P});(d=u.extra)!=null&&d.parenthesized&&l();const f=this.maybeUnwrapTypeCastExpression(u);return f.type!=="ArrowFunctionExpression"&&l(),f.typeParameters=o,this.resetStartLocationFromNode(f,o),u},a);let h=null;if(c.node&&this.maybeUnwrapTypeCastExpression(c.node).type==="ArrowFunctionExpression"){if(!c.error&&!c.aborted)return c.node.async&&this.raise(A.UnexpectedTypeParameterBeforeAsyncArrowFunction,o),c.node;h=c.node}if(n!=null&&n.node)return this.state=n.failState,n.node;if(h)return this.state=c.failState,h;throw n!=null&&n.thrown?n.error:c.thrown?c.error:this.raise(A.UnexpectedTokenAfterTypeParameter,o)}return super.parseMaybeAssign(e,i)}parseArrow(e){if(this.match(14)){const i=this.tryParse(()=>{const a=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0;const n=this.startNode();return[n.typeAnnotation,e.predicate]=this.flowParseTypeAndPredicateInitialiser(),this.state.noAnonFunctionType=a,this.canInsertSemicolon()&&this.unexpected(),this.match(19)||this.unexpected(),n});if(i.thrown)return null;i.error&&(this.state=i.failState),e.returnType=i.node.typeAnnotation?this.finishNode(i.node,"TypeAnnotation"):null}return super.parseArrow(e)}shouldParseArrow(e){return this.match(14)||super.shouldParseArrow(e)}setArrowFunctionParameters(e,i){this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start))?e.params=i:super.setArrowFunctionParameters(e,i)}checkParams(e,i,a,n=!0){if(!(a&&this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start)))){for(let o=0;o<e.params.length;o++)this.isThisParam(e.params[o])&&o>0&&this.raise(A.ThisParamMustBeFirst,e.params[o]);super.checkParams(e,i,a,n)}}parseParenAndDistinguishExpression(e){return super.parseParenAndDistinguishExpression(e&&!this.state.noArrowAt.includes(this.sourceToOffsetPos(this.state.start)))}parseSubscripts(e,i,a){if(e.type==="Identifier"&&e.name==="async"&&this.state.noArrowAt.includes(i.index)){this.next();const n=this.startNodeAt(i);n.callee=e,n.arguments=super.parseCallExpressionArguments(11),e=this.finishNode(n,"CallExpression")}else if(e.type==="Identifier"&&e.name==="async"&&this.match(47)){const n=this.state.clone(),o=this.tryParse(h=>this.parseAsyncArrowWithTypeParameters(i)||h(),n);if(!o.error&&!o.aborted)return o.node;const c=this.tryParse(()=>super.parseSubscripts(e,i,a),n);if(c.node&&!c.error)return c.node;if(o.node)return this.state=o.failState,o.node;if(c.node)return this.state=c.failState,c.node;throw o.error||c.error}return super.parseSubscripts(e,i,a)}parseSubscript(e,i,a,n){if(this.match(18)&&this.isLookaheadToken_lt()){if(n.optionalChainMember=!0,a)return n.stop=!0,e;this.next();const o=this.startNodeAt(i);return o.callee=e,o.typeArguments=this.flowParseTypeParameterInstantiationInExpression(),this.expect(10),o.arguments=this.parseCallExpressionArguments(11),o.optional=!0,this.finishCallExpression(o,!0)}else if(!a&&this.shouldParseTypes()&&(this.match(47)||this.match(51))){const o=this.startNodeAt(i);o.callee=e;const c=this.tryParse(()=>(o.typeArguments=this.flowParseTypeParameterInstantiationCallOrNew(),this.expect(10),o.arguments=super.parseCallExpressionArguments(11),n.optionalChainMember&&(o.optional=!1),this.finishCallExpression(o,n.optionalChainMember)));if(c.node)return c.error&&(this.state=c.failState),c.node}return super.parseSubscript(e,i,a,n)}parseNewCallee(e){super.parseNewCallee(e);let i=null;this.shouldParseTypes()&&this.match(47)&&(i=this.tryParse(()=>this.flowParseTypeParameterInstantiationCallOrNew()).node),e.typeArguments=i}parseAsyncArrowWithTypeParameters(e){const i=this.startNodeAt(e);if(this.parseFunctionParams(i,!1),!!this.parseArrow(i))return super.parseArrowExpression(i,void 0,!0)}readToken_mult_modulo(e){const i=this.input.charCodeAt(this.state.pos+1);if(e===42&&i===47&&this.state.hasFlowComment){this.state.hasFlowComment=!1,this.state.pos+=2,this.nextToken();return}super.readToken_mult_modulo(e)}readToken_pipe_amp(e){const i=this.input.charCodeAt(this.state.pos+1);if(e===124&&i===125){this.finishOp(9,2);return}super.readToken_pipe_amp(e)}parseTopLevel(e,i){const a=super.parseTopLevel(e,i);return this.state.hasFlowComment&&this.raise(A.UnterminatedFlowComment,this.state.curPosition()),a}skipBlockComment(){if(this.hasPlugin("flowComments")&&this.skipFlowComment()){if(this.state.hasFlowComment)throw this.raise(A.NestedFlowComment,this.state.startLoc);this.hasFlowCommentCompletion();const e=this.skipFlowComment();e&&(this.state.pos+=e,this.state.hasFlowComment=!0);return}return super.skipBlockComment(this.state.hasFlowComment?"*-/":"*/")}skipFlowComment(){const{pos:e}=this.state;let i=2;for(;[32,9].includes(this.input.charCodeAt(e+i));)i++;const a=this.input.charCodeAt(i+e),n=this.input.charCodeAt(i+e+1);return a===58&&n===58?i+2:this.input.slice(i+e,i+e+12)==="flow-include"?i+12:a===58&&n!==58?i:!1}hasFlowCommentCompletion(){if(this.input.indexOf("*/",this.state.pos)===-1)throw this.raise(p.UnterminatedComment,this.state.curPosition())}flowEnumErrorBooleanMemberNotInitialized(e,{enumName:i,memberName:a}){this.raise(A.EnumBooleanMemberNotInitialized,e,{memberName:a,enumName:i})}flowEnumErrorInvalidMemberInitializer(e,i){return this.raise(i.explicitType?i.explicitType==="symbol"?A.EnumInvalidMemberInitializerSymbolType:A.EnumInvalidMemberInitializerPrimaryType:A.EnumInvalidMemberInitializerUnknownType,e,i)}flowEnumErrorNumberMemberNotInitialized(e,i){this.raise(A.EnumNumberMemberNotInitialized,e,i)}flowEnumErrorStringMemberInconsistentlyInitialized(e,i){this.raise(A.EnumStringMemberInconsistentlyInitialized,e,i)}flowEnumMemberInit(){const e=this.state.startLoc,i=()=>this.match(12)||this.match(8);switch(this.state.type){case 135:{const a=this.parseNumericLiteral(this.state.value);return i()?{type:"number",loc:a.loc.start,value:a}:{type:"invalid",loc:e}}case 134:{const a=this.parseStringLiteral(this.state.value);return i()?{type:"string",loc:a.loc.start,value:a}:{type:"invalid",loc:e}}case 85:case 86:{const a=this.parseBooleanLiteral(this.match(85));return i()?{type:"boolean",loc:a.loc.start,value:a}:{type:"invalid",loc:e}}default:return{type:"invalid",loc:e}}}flowEnumMemberRaw(){const e=this.state.startLoc,i=this.parseIdentifier(!0),a=this.eat(29)?this.flowEnumMemberInit():{type:"none",loc:e};return{id:i,init:a}}flowEnumCheckExplicitTypeMismatch(e,i,a){const{explicitType:n}=i;n!==null&&n!==a&&this.flowEnumErrorInvalidMemberInitializer(e,i)}flowEnumMembers({enumName:e,explicitType:i}){const a=new Set,n={booleanMembers:[],numberMembers:[],stringMembers:[],defaultedMembers:[]};let o=!1;for(;!this.match(8);){if(this.eat(21)){o=!0;break}const c=this.startNode(),{id:h,init:l}=this.flowEnumMemberRaw(),u=h.name;if(u==="")continue;/^[a-z]/.test(u)&&this.raise(A.EnumInvalidMemberName,h,{memberName:u,suggestion:u[0].toUpperCase()+u.slice(1),enumName:e}),a.has(u)&&this.raise(A.EnumDuplicateMemberName,h,{memberName:u,enumName:e}),a.add(u);const f={enumName:e,explicitType:i,memberName:u};switch(c.id=h,l.type){case"boolean":{this.flowEnumCheckExplicitTypeMismatch(l.loc,f,"boolean"),c.init=l.value,n.booleanMembers.push(this.finishNode(c,"EnumBooleanMember"));break}case"number":{this.flowEnumCheckExplicitTypeMismatch(l.loc,f,"number"),c.init=l.value,n.numberMembers.push(this.finishNode(c,"EnumNumberMember"));break}case"string":{this.flowEnumCheckExplicitTypeMismatch(l.loc,f,"string"),c.init=l.value,n.stringMembers.push(this.finishNode(c,"EnumStringMember"));break}case"invalid":throw this.flowEnumErrorInvalidMemberInitializer(l.loc,f);case"none":switch(i){case"boolean":this.flowEnumErrorBooleanMemberNotInitialized(l.loc,f);break;case"number":this.flowEnumErrorNumberMemberNotInitialized(l.loc,f);break;default:n.defaultedMembers.push(this.finishNode(c,"EnumDefaultedMember"))}}this.match(8)||this.expect(12)}return{members:n,hasUnknownMembers:o}}flowEnumStringMembers(e,i,{enumName:a}){if(e.length===0)return i;if(i.length===0)return e;if(i.length>e.length){for(const n of e)this.flowEnumErrorStringMemberInconsistentlyInitialized(n,{enumName:a});return i}else{for(const n of i)this.flowEnumErrorStringMemberInconsistentlyInitialized(n,{enumName:a});return e}}flowEnumParseExplicitType({enumName:e}){if(!this.eatContextual(102))return null;if(!O(this.state.type))throw this.raise(A.EnumInvalidExplicitTypeUnknownSupplied,this.state.startLoc,{enumName:e});const{value:i}=this.state;return this.next(),i!=="boolean"&&i!=="number"&&i!=="string"&&i!=="symbol"&&this.raise(A.EnumInvalidExplicitType,this.state.startLoc,{enumName:e,invalidEnumType:i}),i}flowEnumBody(e,i){const a=i.name,n=i.loc.start,o=this.flowEnumParseExplicitType({enumName:a});this.expect(5);const{members:c,hasUnknownMembers:h}=this.flowEnumMembers({enumName:a,explicitType:o});switch(e.hasUnknownMembers=h,o){case"boolean":return e.explicitType=!0,e.members=c.booleanMembers,this.expect(8),this.finishNode(e,"EnumBooleanBody");case"number":return e.explicitType=!0,e.members=c.numberMembers,this.expect(8),this.finishNode(e,"EnumNumberBody");case"string":return e.explicitType=!0,e.members=this.flowEnumStringMembers(c.stringMembers,c.defaultedMembers,{enumName:a}),this.expect(8),this.finishNode(e,"EnumStringBody");case"symbol":return e.members=c.defaultedMembers,this.expect(8),this.finishNode(e,"EnumSymbolBody");default:{const l=()=>(e.members=[],this.expect(8),this.finishNode(e,"EnumStringBody"));e.explicitType=!1;const u=c.booleanMembers.length,f=c.numberMembers.length,d=c.stringMembers.length,P=c.defaultedMembers.length;if(!u&&!f&&!d&&!P)return l();if(!u&&!f)return e.members=this.flowEnumStringMembers(c.stringMembers,c.defaultedMembers,{enumName:a}),this.expect(8),this.finishNode(e,"EnumStringBody");if(!f&&!d&&u>=P){for(const S of c.defaultedMembers)this.flowEnumErrorBooleanMemberNotInitialized(S.loc.start,{enumName:a,memberName:S.id.name});return e.members=c.booleanMembers,this.expect(8),this.finishNode(e,"EnumBooleanBody")}else if(!u&&!d&&f>=P){for(const S of c.defaultedMembers)this.flowEnumErrorNumberMemberNotInitialized(S.loc.start,{enumName:a,memberName:S.id.name});return e.members=c.numberMembers,this.expect(8),this.finishNode(e,"EnumNumberBody")}else return this.raise(A.EnumInconsistentMemberValues,n,{enumName:a}),l()}}}flowParseEnumDeclaration(e){const i=this.parseIdentifier();return e.id=i,e.body=this.flowEnumBody(this.startNode(),i),this.finishNode(e,"EnumDeclaration")}jsxParseOpeningElementAfterName(e){return this.shouldParseTypes()&&(this.match(47)||this.match(51))&&(e.typeArguments=this.flowParseTypeParameterInstantiationInExpression()),super.jsxParseOpeningElementAfterName(e)}isLookaheadToken_lt(){const e=this.nextTokenStart();if(this.input.charCodeAt(e)===60){const i=this.input.charCodeAt(e+1);return i!==60&&i!==61}return!1}reScan_lt_gt(){const{type:e}=this.state;e===47?(this.state.pos-=1,this.readToken_lt()):e===48&&(this.state.pos-=1,this.readToken_gt())}reScan_lt(){const{type:e}=this.state;return e===51?(this.state.pos-=2,this.finishOp(47,1),47):e}maybeUnwrapTypeCastExpression(e){return e.type==="TypeCastExpression"?e.expression:e}};const Va={__proto__:null,quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"},Ha=/\r\n|[\r\n\u2028\u2029]/,Nt=new RegExp(Ha.source,"g");function qe(r){switch(r){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function hi(r,t,s){for(let e=t;e<s;e++)if(qe(r.charCodeAt(e)))return!0;return!1}const ys=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,xs=/(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;function Ka(r){switch(r){case 9:case 11:case 12:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:case 65279:return!0;default:return!1}}const we=ye`jsx`({AttributeIsEmpty:"JSX attributes must only be assigned a non-empty expression.",MissingClosingTagElement:({openingTagName:r})=>`Expected corresponding JSX closing tag for <${r}>.`,MissingClosingTagFragment:"Expected corresponding JSX closing tag for <>.",UnexpectedSequenceExpression:"Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",UnexpectedToken:({unexpected:r,HTMLEntity:t})=>`Unexpected token \`${r}\`. Did you mean \`${t}\` or \`{'${r}'}\`?`,UnsupportedJsxValue:"JSX value should be either an expression or a quoted JSX text.",UnterminatedJsxContent:"Unterminated JSX contents.",UnwrappedAdjacentJSXElements:"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"});function ke(r){return r?r.type==="JSXOpeningFragment"||r.type==="JSXClosingFragment":!1}function ze(r){if(r.type==="JSXIdentifier")return r.name;if(r.type==="JSXNamespacedName")return r.namespace.name+":"+r.name.name;if(r.type==="JSXMemberExpression")return ze(r.object)+"."+ze(r.property);throw new Error("Node had unexpected type: "+r.type)}var Ja=r=>class extends r{jsxReadToken(){let s="",e=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(we.UnterminatedJsxContent,this.state.startLoc);const i=this.input.charCodeAt(this.state.pos);switch(i){case 60:case 123:if(this.state.pos===this.state.start){i===60&&this.state.canStartJSXElement?(++this.state.pos,this.finishToken(143)):super.getTokenFromCode(i);return}s+=this.input.slice(e,this.state.pos),this.finishToken(142,s);return;case 38:s+=this.input.slice(e,this.state.pos),s+=this.jsxReadEntity(),e=this.state.pos;break;case 62:case 125:this.raise(we.UnexpectedToken,this.state.curPosition(),{unexpected:this.input[this.state.pos],HTMLEntity:i===125?"&rbrace;":"&gt;"});default:qe(i)?(s+=this.input.slice(e,this.state.pos),s+=this.jsxReadNewLine(!0),e=this.state.pos):++this.state.pos}}}jsxReadNewLine(s){const e=this.input.charCodeAt(this.state.pos);let i;return++this.state.pos,e===13&&this.input.charCodeAt(this.state.pos)===10?(++this.state.pos,i=s?`
3
+ - Did you mean \`import { "${r}" as foo }\`?`,ImportCallArity:"`import()` requires exactly one or two arguments.",ImportCallNotNewExpression:"Cannot use new with import(...).",ImportCallSpreadArgument:"`...` is not allowed in `import()`.",ImportJSONBindingNotDefault:"A JSON module can only be imported with `default`.",ImportReflectionHasAssertion:"`import module x` cannot have assertions.",ImportReflectionNotBinding:'Only `import module x from "./module"` is valid.',IncompatibleRegExpUVFlags:"The 'u' and 'v' regular expression flags cannot be enabled at the same time.",InvalidBigIntLiteral:"Invalid BigIntLiteral.",InvalidCodePoint:"Code point out of bounds.",InvalidCoverInitializedName:"Invalid shorthand property initializer.",InvalidDecimal:"Invalid decimal.",InvalidDigit:({radix:r})=>`Expected number in radix ${r}.`,InvalidEscapeSequence:"Bad character escape sequence.",InvalidEscapeSequenceTemplate:"Invalid escape sequence in template.",InvalidEscapedReservedWord:({reservedWord:r})=>`Escape sequence in keyword ${r}.`,InvalidIdentifier:({identifierName:r})=>`Invalid identifier ${r}.`,InvalidLhs:({ancestor:r})=>`Invalid left-hand side in ${Et(r)}.`,InvalidLhsBinding:({ancestor:r})=>`Binding invalid left-hand side in ${Et(r)}.`,InvalidLhsOptionalChaining:({ancestor:r})=>`Invalid optional chaining in the left-hand side of ${Et(r)}.`,InvalidNumber:"Invalid number.",InvalidOrMissingExponent:"Floating-point numbers require a valid exponent after the 'e'.",InvalidOrUnexpectedToken:({unexpected:r})=>`Unexpected character '${r}'.`,InvalidParenthesizedAssignment:"Invalid parenthesized assignment pattern.",InvalidPrivateFieldResolution:({identifierName:r})=>`Private name #${r} is not defined.`,InvalidPropertyBindingPattern:"Binding member expression.",InvalidRecordProperty:"Only properties and spread elements are allowed in record definitions.",InvalidRestAssignmentPattern:"Invalid rest operator's argument.",LabelRedeclaration:({labelName:r})=>`Label '${r}' is already declared.`,LetInLexicalBinding:"'let' is disallowed as a lexically bound name.",LineTerminatorBeforeArrow:"No line break is allowed before '=>'.",MalformedRegExpFlags:"Invalid regular expression flag.",MissingClassName:"A class name is required.",MissingEqInAssignment:"Only '=' operator can be used for specifying default value.",MissingSemicolon:"Missing semicolon.",MissingPlugin:({missingPlugin:r})=>`This experimental syntax requires enabling the parser plugin: ${r.map(t=>JSON.stringify(t)).join(", ")}.`,MissingOneOfPlugins:({missingPlugin:r})=>`This experimental syntax requires enabling one of the following parser plugin(s): ${r.map(t=>JSON.stringify(t)).join(", ")}.`,MissingUnicodeEscape:"Expecting Unicode escape sequence \\uXXXX.",MixingCoalesceWithLogical:"Nullish coalescing operator(??) requires parens when mixing with logical operators.",ModuleAttributeDifferentFromType:"The only accepted module attribute is `type`.",ModuleAttributeInvalidValue:"Only string literals are allowed as module attribute values.",ModuleAttributesWithDuplicateKeys:({key:r})=>`Duplicate key "${r}" is not allowed in module attributes.`,ModuleExportNameHasLoneSurrogate:({surrogateCharCode:r})=>`An export name cannot include a lone surrogate, found '\\u${r.toString(16)}'.`,ModuleExportUndefined:({localName:r})=>`Export '${r}' is not defined.`,MultipleDefaultsInSwitch:"Multiple default clauses.",NewlineAfterThrow:"Illegal newline after throw.",NoCatchOrFinally:"Missing catch or finally clause.",NumberIdentifier:"Identifier directly after number.",NumericSeparatorInEscapeSequence:"Numeric separators are not allowed inside unicode escape sequences or hex escape sequences.",ObsoleteAwaitStar:"'await*' has been removed from the async functions proposal. Use Promise.all() instead.",OptionalChainingNoNew:"Constructors in/after an Optional Chain are not allowed.",OptionalChainingNoTemplate:"Tagged Template Literals are not allowed in optionalChain.",OverrideOnConstructor:"'override' modifier cannot appear on a constructor declaration.",ParamDupe:"Argument name clash.",PatternHasAccessor:"Object pattern can't contain getter or setter.",PatternHasMethod:"Object pattern can't contain methods.",PrivateInExpectedIn:({identifierName:r})=>`Private names are only allowed in property accesses (\`obj.#${r}\`) or in \`in\` expressions (\`#${r} in obj\`).`,PrivateNameRedeclaration:({identifierName:r})=>`Duplicate private name #${r}.`,RecordExpressionBarIncorrectEndSyntaxType:"Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",RecordExpressionBarIncorrectStartSyntaxType:"Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",RecordExpressionHashIncorrectStartSyntaxType:"Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",RecordNoProto:"'__proto__' is not allowed in Record expressions.",RestTrailingComma:"Unexpected trailing comma after rest element.",SloppyFunction:"In non-strict mode code, functions can only be declared at top level or inside a block.",SloppyFunctionAnnexB:"In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement.",SourcePhaseImportRequiresDefault:'Only `import source x from "./module"` is valid.',StaticPrototype:"Classes may not have static property named prototype.",SuperNotAllowed:"`super()` is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",SuperPrivateField:"Private fields can't be accessed on super.",TrailingDecorator:"Decorators must be attached to a class element.",TupleExpressionBarIncorrectEndSyntaxType:"Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",TupleExpressionBarIncorrectStartSyntaxType:"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'.",TupleExpressionHashIncorrectStartSyntaxType:"Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'.",UnexpectedArgumentPlaceholder:"Unexpected argument placeholder.",UnexpectedAwaitAfterPipelineBody:'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal.',UnexpectedDigitAfterHash:"Unexpected digit after hash token.",UnexpectedImportExport:"'import' and 'export' may only appear at the top level.",UnexpectedKeyword:({keyword:r})=>`Unexpected keyword '${r}'.`,UnexpectedLeadingDecorator:"Leading decorators must be attached to a class declaration.",UnexpectedLexicalDeclaration:"Lexical declaration cannot appear in a single-statement context.",UnexpectedNewTarget:"`new.target` can only be used in functions or class properties.",UnexpectedNumericSeparator:"A numeric separator is only allowed between two digits.",UnexpectedPrivateField:"Unexpected private name.",UnexpectedReservedWord:({reservedWord:r})=>`Unexpected reserved word '${r}'.`,UnexpectedSuper:"'super' is only allowed in object methods and classes.",UnexpectedToken:({expected:r,unexpected:t})=>`Unexpected token${t?` '${t}'.`:""}${r?`, expected "${r}"`:""}`,UnexpectedTokenUnaryExponentiation:"Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",UnexpectedUsingDeclaration:"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement.",UnsupportedBind:"Binding should be performed on object property.",UnsupportedDecoratorExport:"A decorated export must export a class declaration.",UnsupportedDefaultExport:"Only expressions, functions or classes are allowed as the `default` export.",UnsupportedImport:"`import` can only be used in `import()` or `import.meta`.",UnsupportedMetaProperty:({target:r,onlyValidPropertyName:t})=>`The only valid meta property for ${r} is ${r}.${t}.`,UnsupportedParameterDecorator:"Decorators cannot be used to decorate parameters.",UnsupportedPropertyDecorator:"Decorators cannot be used to decorate object literal properties.",UnsupportedSuper:"'super' can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop]).",UnterminatedComment:"Unterminated comment.",UnterminatedRegExp:"Unterminated regular expression.",UnterminatedString:"Unterminated string constant.",UnterminatedTemplate:"Unterminated template.",UsingDeclarationExport:"Using declaration cannot be exported.",UsingDeclarationHasBindingPattern:"Using declaration cannot have destructuring patterns.",VarRedeclaration:({identifierName:r})=>`Identifier '${r}' has already been declared.`,YieldBindingIdentifier:"Can not use 'yield' as identifier inside a generator.",YieldInParameter:"Yield expression is not allowed in formal parameters.",YieldNotInGeneratorFunction:"'yield' is only allowed within generator functions.",ZeroDigitNumericSeparator:"Numeric separator can not be used after leading 0."},ua={StrictDelete:"Deleting local variable in strict mode.",StrictEvalArguments:({referenceName:r})=>`Assigning to '${r}' in strict mode.`,StrictEvalArgumentsBinding:({bindingName:r})=>`Binding '${r}' in strict mode.`,StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block.",StrictNumericEscape:"The only valid numeric escape in strict mode is '\\0'.",StrictOctalLiteral:"Legacy octal literals are not allowed in strict mode.",StrictWith:"'with' in strict mode."},pa={ParseExpressionEmptyInput:"Unexpected parseExpression() input: The input is empty or contains only comments.",ParseExpressionExpectsEOF:({unexpected:r})=>`Unexpected parseExpression() input: The input should contain exactly one expression, but the first expression is followed by the unexpected character \`${String.fromCodePoint(r)}\`.`};const fa=new Set(["ArrowFunctionExpression","AssignmentExpression","ConditionalExpression","YieldExpression"]);var da=Object.assign({PipeBodyIsTighter:"Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",PipeTopicRequiresHackPipes:'Topic references are only supported when using the `"proposal": "hack"` version of the pipeline proposal.',PipeTopicUnbound:"Topic reference is unbound; it must be inside a pipe body.",PipeTopicUnconfiguredToken:({token:r})=>`Invalid topic token ${r}. In order to use ${r} as a topic reference, the pipelineOperator plugin must be configured with { "proposal": "hack", "topicToken": "${r}" }.`,PipeTopicUnused:"Hack-style pipe body does not contain a topic reference; Hack-style pipes must use topic at least once.",PipeUnparenthesizedBody:({type:r})=>`Hack-style pipe body cannot be an unparenthesized ${Et({type:r})}; please wrap it in parentheses.`},{});const ma=["message"];function Ys(r,t,s){Object.defineProperty(r,t,{enumerable:!1,configurable:!0,value:s})}function ya({toMessage:r,code:t,reasonCode:s,syntaxPlugin:e}){const i=s==="MissingPlugin"||s==="MissingOneOfPlugins";return function a(n,o){const c=new SyntaxError;return c.code=t,c.reasonCode=s,c.loc=n,c.pos=n.index,c.syntaxPlugin=e,i&&(c.missingPlugin=o.missingPlugin),Ys(c,"clone",function(l={}){const{line:u,column:f,index:d}=l.loc??n;return a(new Ce(u,f,d),Object.assign({},o,l.details))}),Ys(c,"details",o),Object.defineProperty(c,"message",{configurable:!0,get(){const h=`${r(o)} (${n.line}:${n.column})`;return this.message=h,h},set(h){Object.defineProperty(this,"message",{value:h,writable:!0})}}),c}}function Pe(r,t){if(Array.isArray(r))return e=>Pe(e,r[0]);const s={};for(const e of Object.keys(r)){const i=r[e],a=typeof i=="string"?{message:()=>i}:typeof i=="function"?{message:i}:i,{message:n}=a,o=ca(a,ma),c=typeof n=="string"?()=>n:n;s[e]=ya(Object.assign({code:"BABEL_PARSER_SYNTAX_ERROR",reasonCode:e,toMessage:c},t?{syntaxPlugin:t}:{},o))}return s}const p=Object.assign({},Pe(ha),Pe(la),Pe(ua),Pe(pa),Pe`pipelineOperator`(da));function xa(){return{sourceType:"script",sourceFilename:void 0,startIndex:0,startColumn:0,startLine:1,allowAwaitOutsideFunction:!1,allowReturnOutsideFunction:!1,allowNewTargetOutsideFunction:!1,allowImportExportEverywhere:!1,allowSuperOutsideMethod:!1,allowUndeclaredExports:!1,allowYieldOutsideFunction:!1,plugins:[],strictMode:null,ranges:!1,tokens:!1,createImportExpressions:!0,createParenthesizedExpressions:!1,errorRecovery:!1,attachComment:!0,annexB:!0}}function Pa(r){const t=xa();if(r==null)return t;if(r.annexB!=null&&r.annexB!==!1)throw new Error("The `annexB` option can only be set to `false`.");for(const s of Object.keys(t))r[s]!=null&&(t[s]=r[s]);if(t.startLine===1)r.startIndex==null&&t.startColumn>0?t.startIndex=t.startColumn:r.startColumn==null&&t.startIndex>0&&(t.startColumn=t.startIndex);else if(r.startColumn==null||r.startIndex==null)throw new Error("With a `startLine > 1` you must also specify `startIndex` and `startColumn`.");return t}const{defineProperty:ba}=Object,Zs=(r,t)=>{r&&ba(r,t,{enumerable:!1,value:r[t]})};function ct(r){return Zs(r.loc.start,"index"),Zs(r.loc.end,"index"),r}var ga=r=>class extends r{parse(){const s=ct(super.parse());return this.optionFlags&256&&(s.tokens=s.tokens.map(ct)),s}parseRegExpLiteral({pattern:s,flags:e}){let i=null;try{i=new RegExp(s,e)}catch{}const a=this.estreeParseLiteral(i);return a.regex={pattern:s,flags:e},a}parseBigIntLiteral(s){let e;try{e=BigInt(s)}catch{e=null}const i=this.estreeParseLiteral(e);return i.bigint=String(i.value||s),i}parseDecimalLiteral(s){const i=this.estreeParseLiteral(null);return i.decimal=String(i.value||s),i}estreeParseLiteral(s){return this.parseLiteral(s,"Literal")}parseStringLiteral(s){return this.estreeParseLiteral(s)}parseNumericLiteral(s){return this.estreeParseLiteral(s)}parseNullLiteral(){return this.estreeParseLiteral(null)}parseBooleanLiteral(s){return this.estreeParseLiteral(s)}estreeParseChainExpression(s,e){const i=this.startNodeAtNode(s);return i.expression=s,this.finishNodeAt(i,"ChainExpression",e)}directiveToStmt(s){const e=s.value;delete s.value,this.castNodeTo(e,"Literal"),e.raw=e.extra.raw,e.value=e.extra.expressionValue;const i=this.castNodeTo(s,"ExpressionStatement");return i.expression=e,i.directive=e.extra.rawValue,delete e.extra,i}fillOptionalPropertiesForTSESLint(s){}cloneEstreeStringLiteral(s){const{start:e,end:i,loc:a,range:n,raw:o,value:c}=s,h=Object.create(s.constructor.prototype);return h.type="Literal",h.start=e,h.end=i,h.loc=a,h.range=n,h.raw=o,h.value=c,h}initFunction(s,e){super.initFunction(s,e),s.expression=!1}checkDeclaration(s){s!=null&&this.isObjectProperty(s)?this.checkDeclaration(s.value):super.checkDeclaration(s)}getObjectOrClassMethodParams(s){return s.value.params}isValidDirective(s){var e;return s.type==="ExpressionStatement"&&s.expression.type==="Literal"&&typeof s.expression.value=="string"&&!((e=s.expression.extra)!=null&&e.parenthesized)}parseBlockBody(s,e,i,a,n){super.parseBlockBody(s,e,i,a,n);const o=s.directives.map(c=>this.directiveToStmt(c));s.body=o.concat(s.body),delete s.directives}parsePrivateName(){const s=super.parsePrivateName();return this.convertPrivateNameToPrivateIdentifier(s)}convertPrivateNameToPrivateIdentifier(s){const e=super.getPrivateNameSV(s);return s=s,delete s.id,s.name=e,this.castNodeTo(s,"PrivateIdentifier")}isPrivateName(s){return s.type==="PrivateIdentifier"}getPrivateNameSV(s){return s.name}parseLiteral(s,e){const i=super.parseLiteral(s,e);return i.raw=i.extra.raw,delete i.extra,i}parseFunctionBody(s,e,i=!1){super.parseFunctionBody(s,e,i),s.expression=s.body.type!=="BlockStatement"}parseMethod(s,e,i,a,n,o,c=!1){let h=this.startNode();h.kind=s.kind,h=super.parseMethod(h,e,i,a,n,o,c),delete h.kind;const{typeParameters:l}=s;l&&(delete s.typeParameters,h.typeParameters=l,this.resetStartLocationFromNode(h,l));const u=this.castNodeTo(h,this.hasPlugin("typescript")&&!h.body?"TSEmptyBodyFunctionExpression":"FunctionExpression");return s.value=u,o==="ClassPrivateMethod"&&(s.computed=!1),this.hasPlugin("typescript")&&s.abstract?(delete s.abstract,this.finishNode(s,"TSAbstractMethodDefinition")):o==="ObjectMethod"?(s.kind==="method"&&(s.kind="init"),s.shorthand=!1,this.finishNode(s,"Property")):this.finishNode(s,"MethodDefinition")}nameIsConstructor(s){return s.type==="Literal"?s.value==="constructor":super.nameIsConstructor(s)}parseClassProperty(...s){const e=super.parseClassProperty(...s);return e.abstract&&this.hasPlugin("typescript")?(delete e.abstract,this.castNodeTo(e,"TSAbstractPropertyDefinition")):this.castNodeTo(e,"PropertyDefinition"),e}parseClassPrivateProperty(...s){const e=super.parseClassPrivateProperty(...s);return e.abstract&&this.hasPlugin("typescript")?this.castNodeTo(e,"TSAbstractPropertyDefinition"):this.castNodeTo(e,"PropertyDefinition"),e.computed=!1,e}parseClassAccessorProperty(s){const e=super.parseClassAccessorProperty(s);return e.abstract&&this.hasPlugin("typescript")?(delete e.abstract,this.castNodeTo(e,"TSAbstractAccessorProperty")):this.castNodeTo(e,"AccessorProperty"),e}parseObjectProperty(s,e,i,a){const n=super.parseObjectProperty(s,e,i,a);return n&&(n.kind="init",this.castNodeTo(n,"Property")),n}finishObjectProperty(s){return s.kind="init",this.finishNode(s,"Property")}isValidLVal(s,e,i){return s==="Property"?"value":super.isValidLVal(s,e,i)}isAssignable(s,e){return s!=null&&this.isObjectProperty(s)?this.isAssignable(s.value,e):super.isAssignable(s,e)}toAssignable(s,e=!1){if(s!=null&&this.isObjectProperty(s)){const{key:i,value:a}=s;this.isPrivateName(i)&&this.classScope.usePrivateName(this.getPrivateNameSV(i),i.loc.start),this.toAssignable(a,e)}else super.toAssignable(s,e)}toAssignableObjectExpressionProp(s,e,i){s.type==="Property"&&(s.kind==="get"||s.kind==="set")?this.raise(p.PatternHasAccessor,s.key):s.type==="Property"&&s.method?this.raise(p.PatternHasMethod,s.key):super.toAssignableObjectExpressionProp(s,e,i)}finishCallExpression(s,e){const i=super.finishCallExpression(s,e);return i.callee.type==="Import"?(this.castNodeTo(i,"ImportExpression"),i.source=i.arguments[0],i.options=i.arguments[1]??null,i.attributes=i.arguments[1]??null,delete i.arguments,delete i.callee):i.type==="OptionalCallExpression"?this.castNodeTo(i,"CallExpression"):i.optional=!1,i}toReferencedArguments(s){s.type!=="ImportExpression"&&super.toReferencedArguments(s)}parseExport(s,e){var n;const i=this.state.lastTokStartLoc,a=super.parseExport(s,e);switch(a.type){case"ExportAllDeclaration":a.exported=null;break;case"ExportNamedDeclaration":a.specifiers.length===1&&a.specifiers[0].type==="ExportNamespaceSpecifier"&&(this.castNodeTo(a,"ExportAllDeclaration"),a.exported=a.specifiers[0].exported,delete a.specifiers);case"ExportDefaultDeclaration":{const{declaration:o}=a;(o==null?void 0:o.type)==="ClassDeclaration"&&((n=o.decorators)==null?void 0:n.length)>0&&o.start===a.start&&this.resetStartLocation(a,i)}break}return a}stopParseSubscript(s,e){const i=super.stopParseSubscript(s,e);return e.optionalChainMember?this.estreeParseChainExpression(i,s.loc.end):i}parseMember(s,e,i,a,n){const o=super.parseMember(s,e,i,a,n);return o.type==="OptionalMemberExpression"?this.castNodeTo(o,"MemberExpression"):o.optional=!1,o}isOptionalMemberExpression(s){return s.type==="ChainExpression"?s.expression.type==="MemberExpression":super.isOptionalMemberExpression(s)}hasPropertyAsPrivateName(s){return s.type==="ChainExpression"&&(s=s.expression),super.hasPropertyAsPrivateName(s)}isObjectProperty(s){return s.type==="Property"&&s.kind==="init"&&!s.method}isObjectMethod(s){return s.type==="Property"&&(s.method||s.kind==="get"||s.kind==="set")}castNodeTo(s,e){const i=super.castNodeTo(s,e);return this.fillOptionalPropertiesForTSESLint(i),i}cloneIdentifier(s){const e=super.cloneIdentifier(s);return this.fillOptionalPropertiesForTSESLint(e),e}cloneStringLiteral(s){return s.type==="Literal"?this.cloneEstreeStringLiteral(s):super.cloneStringLiteral(s)}finishNodeAt(s,e,i){return ct(super.finishNodeAt(s,e,i))}finishNode(s,e){const i=super.finishNode(s,e);return this.fillOptionalPropertiesForTSESLint(i),i}resetStartLocation(s,e){super.resetStartLocation(s,e),ct(s)}resetEndLocation(s,e=this.state.lastTokEndLoc){super.resetEndLocation(s,e),ct(s)}};class Ct{constructor(t,s){m(this,"token");m(this,"preserveSpace");this.token=t,this.preserveSpace=!!s}}const R={brace:new Ct("{"),j_oTag:new Ct("<tag"),j_cTag:new Ct("</tag"),j_expr:new Ct("<tag>...</tag>",!0)},E=!0,x=!0,is=!0,ht=!0,ke=!0,wa=!0;class Qs{constructor(t,s={}){m(this,"label");m(this,"keyword");m(this,"beforeExpr");m(this,"startsExpr");m(this,"rightAssociative");m(this,"isLoop");m(this,"isAssign");m(this,"prefix");m(this,"postfix");m(this,"binop");this.label=t,this.keyword=s.keyword,this.beforeExpr=!!s.beforeExpr,this.startsExpr=!!s.startsExpr,this.rightAssociative=!!s.rightAssociative,this.isLoop=!!s.isLoop,this.isAssign=!!s.isAssign,this.prefix=!!s.prefix,this.postfix=!!s.postfix,this.binop=s.binop!=null?s.binop:null}}const rs=new Map;function v(r,t={}){t.keyword=r;const s=T(r,t);return rs.set(r,s),s}function te(r,t){return T(r,{beforeExpr:E,binop:t})}let lt=-1;const as=[],ns=[],os=[],cs=[],hs=[],ls=[];function T(r,t={}){return++lt,ns.push(r),os.push(t.binop??-1),cs.push(t.beforeExpr??!1),hs.push(t.startsExpr??!1),ls.push(t.prefix??!1),as.push(new Qs(r,t)),lt}function C(r,t={}){return++lt,rs.set(r,lt),ns.push(r),os.push(t.binop??-1),cs.push(t.beforeExpr??!1),hs.push(t.startsExpr??!1),ls.push(t.prefix??!1),as.push(new Qs("name",t)),lt}const Ta={bracketL:T("[",{beforeExpr:E,startsExpr:x}),bracketHashL:T("#[",{beforeExpr:E,startsExpr:x}),bracketBarL:T("[|",{beforeExpr:E,startsExpr:x}),bracketR:T("]"),bracketBarR:T("|]"),braceL:T("{",{beforeExpr:E,startsExpr:x}),braceBarL:T("{|",{beforeExpr:E,startsExpr:x}),braceHashL:T("#{",{beforeExpr:E,startsExpr:x}),braceR:T("}"),braceBarR:T("|}"),parenL:T("(",{beforeExpr:E,startsExpr:x}),parenR:T(")"),comma:T(",",{beforeExpr:E}),semi:T(";",{beforeExpr:E}),colon:T(":",{beforeExpr:E}),doubleColon:T("::",{beforeExpr:E}),dot:T("."),question:T("?",{beforeExpr:E}),questionDot:T("?."),arrow:T("=>",{beforeExpr:E}),template:T("template"),ellipsis:T("...",{beforeExpr:E}),backQuote:T("`",{startsExpr:x}),dollarBraceL:T("${",{beforeExpr:E,startsExpr:x}),templateTail:T("...`",{startsExpr:x}),templateNonTail:T("...${",{beforeExpr:E,startsExpr:x}),at:T("@"),hash:T("#",{startsExpr:x}),interpreterDirective:T("#!..."),eq:T("=",{beforeExpr:E,isAssign:ht}),assign:T("_=",{beforeExpr:E,isAssign:ht}),slashAssign:T("_=",{beforeExpr:E,isAssign:ht}),xorAssign:T("_=",{beforeExpr:E,isAssign:ht}),moduloAssign:T("_=",{beforeExpr:E,isAssign:ht}),incDec:T("++/--",{prefix:ke,postfix:wa,startsExpr:x}),bang:T("!",{beforeExpr:E,prefix:ke,startsExpr:x}),tilde:T("~",{beforeExpr:E,prefix:ke,startsExpr:x}),doubleCaret:T("^^",{startsExpr:x}),doubleAt:T("@@",{startsExpr:x}),pipeline:te("|>",0),nullishCoalescing:te("??",1),logicalOR:te("||",1),logicalAND:te("&&",2),bitwiseOR:te("|",3),bitwiseXOR:te("^",4),bitwiseAND:te("&",5),equality:te("==/!=/===/!==",6),lt:te("</>/<=/>=",7),gt:te("</>/<=/>=",7),relational:te("</>/<=/>=",7),bitShift:te("<</>>/>>>",8),bitShiftL:te("<</>>/>>>",8),bitShiftR:te("<</>>/>>>",8),plusMin:T("+/-",{beforeExpr:E,binop:9,prefix:ke,startsExpr:x}),modulo:T("%",{binop:10,startsExpr:x}),star:T("*",{binop:10}),slash:te("/",10),exponent:T("**",{beforeExpr:E,binop:11,rightAssociative:!0}),_in:v("in",{beforeExpr:E,binop:7}),_instanceof:v("instanceof",{beforeExpr:E,binop:7}),_break:v("break"),_case:v("case",{beforeExpr:E}),_catch:v("catch"),_continue:v("continue"),_debugger:v("debugger"),_default:v("default",{beforeExpr:E}),_else:v("else",{beforeExpr:E}),_finally:v("finally"),_function:v("function",{startsExpr:x}),_if:v("if"),_return:v("return",{beforeExpr:E}),_switch:v("switch"),_throw:v("throw",{beforeExpr:E,prefix:ke,startsExpr:x}),_try:v("try"),_var:v("var"),_const:v("const"),_with:v("with"),_new:v("new",{beforeExpr:E,startsExpr:x}),_this:v("this",{startsExpr:x}),_super:v("super",{startsExpr:x}),_class:v("class",{startsExpr:x}),_extends:v("extends",{beforeExpr:E}),_export:v("export"),_import:v("import",{startsExpr:x}),_null:v("null",{startsExpr:x}),_true:v("true",{startsExpr:x}),_false:v("false",{startsExpr:x}),_typeof:v("typeof",{beforeExpr:E,prefix:ke,startsExpr:x}),_void:v("void",{beforeExpr:E,prefix:ke,startsExpr:x}),_delete:v("delete",{beforeExpr:E,prefix:ke,startsExpr:x}),_do:v("do",{isLoop:is,beforeExpr:E}),_for:v("for",{isLoop:is}),_while:v("while",{isLoop:is}),_as:C("as",{startsExpr:x}),_assert:C("assert",{startsExpr:x}),_async:C("async",{startsExpr:x}),_await:C("await",{startsExpr:x}),_defer:C("defer",{startsExpr:x}),_from:C("from",{startsExpr:x}),_get:C("get",{startsExpr:x}),_let:C("let",{startsExpr:x}),_meta:C("meta",{startsExpr:x}),_of:C("of",{startsExpr:x}),_sent:C("sent",{startsExpr:x}),_set:C("set",{startsExpr:x}),_source:C("source",{startsExpr:x}),_static:C("static",{startsExpr:x}),_using:C("using",{startsExpr:x}),_yield:C("yield",{startsExpr:x}),_asserts:C("asserts",{startsExpr:x}),_checks:C("checks",{startsExpr:x}),_exports:C("exports",{startsExpr:x}),_global:C("global",{startsExpr:x}),_implements:C("implements",{startsExpr:x}),_intrinsic:C("intrinsic",{startsExpr:x}),_infer:C("infer",{startsExpr:x}),_is:C("is",{startsExpr:x}),_mixins:C("mixins",{startsExpr:x}),_proto:C("proto",{startsExpr:x}),_require:C("require",{startsExpr:x}),_satisfies:C("satisfies",{startsExpr:x}),_keyof:C("keyof",{startsExpr:x}),_readonly:C("readonly",{startsExpr:x}),_unique:C("unique",{startsExpr:x}),_abstract:C("abstract",{startsExpr:x}),_declare:C("declare",{startsExpr:x}),_enum:C("enum",{startsExpr:x}),_module:C("module",{startsExpr:x}),_namespace:C("namespace",{startsExpr:x}),_interface:C("interface",{startsExpr:x}),_type:C("type",{startsExpr:x}),_opaque:C("opaque",{startsExpr:x}),name:T("name",{startsExpr:x}),placeholder:T("%%",{startsExpr:!0}),string:T("string",{startsExpr:x}),num:T("num",{startsExpr:x}),bigint:T("bigint",{startsExpr:x}),decimal:T("decimal",{startsExpr:x}),regexp:T("regexp",{startsExpr:x}),privateName:T("#name",{startsExpr:x}),eof:T("eof"),jsxName:T("jsxName"),jsxText:T("jsxText",{beforeExpr:!0}),jsxTagStart:T("jsxTagStart",{startsExpr:!0}),jsxTagEnd:T("jsxTagEnd")};function D(r){return r>=93&&r<=133}function Aa(r){return r<=92}function ue(r){return r>=58&&r<=133}function ei(r){return r>=58&&r<=137}function Sa(r){return cs[r]}function ut(r){return hs[r]}function Ia(r){return r>=29&&r<=33}function ti(r){return r>=129&&r<=131}function Ea(r){return r>=90&&r<=92}function us(r){return r>=58&&r<=92}function Ca(r){return r>=39&&r<=59}function ka(r){return r===34}function Na(r){return ls[r]}function va(r){return r>=121&&r<=123}function Oa(r){return r>=124&&r<=130}function Ne(r){return ns[r]}function kt(r){return os[r]}function Da(r){return r===57}function ps(r){return r>=24&&r<=25}function si(r){return as[r]}let fs="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟍꟐꟑꟓꟕ-Ƛꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",ii="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・";const La=new RegExp("["+fs+"]"),Ma=new RegExp("["+fs+ii+"]");fs=ii=null;const ri=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],Fa=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239];function ds(r,t){let s=65536;for(let e=0,i=t.length;e<i;e+=2){if(s+=t[e],s>r)return!1;if(s+=t[e+1],s>=r)return!0}return!1}function ge(r){return r<65?r===36:r<=90?!0:r<97?r===95:r<=122?!0:r<=65535?r>=170&&La.test(String.fromCharCode(r)):ds(r,ri)}function $e(r){return r<48?r===36:r<58?!0:r<65?!1:r<=90?!0:r<97?r===95:r<=122?!0:r<=65535?r>=170&&Ma.test(String.fromCharCode(r)):ds(r,ri)||ds(r,Fa)}const ms={keyword:["break","case","catch","continue","debugger","default","do","else","finally","for","function","if","return","switch","throw","try","var","const","while","with","new","this","super","class","extends","export","import","null","true","false","in","instanceof","typeof","void","delete"],strict:["implements","interface","let","package","private","protected","public","static","yield"],strictBind:["eval","arguments"]},Ba=new Set(ms.keyword),Ra=new Set(ms.strict),_a=new Set(ms.strictBind);function ai(r,t){return t&&r==="await"||r==="enum"}function ni(r,t){return ai(r,t)||Ra.has(r)}function oi(r){return _a.has(r)}function ci(r,t){return ni(r,t)||oi(r)}function ja(r){return Ba.has(r)}function Ua(r,t,s){return r===64&&t===64&&ge(s)}const $a=new Set(["break","case","catch","continue","debugger","default","do","else","finally","for","function","if","return","switch","throw","try","var","const","while","with","new","this","super","class","extends","export","import","null","true","false","in","instanceof","typeof","void","delete","implements","interface","let","package","private","protected","public","static","yield","eval","arguments","enum","await"]);function qa(r){return $a.has(r)}class ys{constructor(t){m(this,"flags",0);m(this,"names",new Map);m(this,"firstLexicalName","");this.flags=t}}class xs{constructor(t,s){m(this,"parser");m(this,"scopeStack",[]);m(this,"inModule");m(this,"undefinedExports",new Map);this.parser=t,this.inModule=s}get inTopLevel(){return(this.currentScope().flags&1)>0}get inFunction(){return(this.currentVarScopeFlags()&2)>0}get allowSuper(){return(this.currentThisScopeFlags()&16)>0}get allowDirectSuper(){return(this.currentThisScopeFlags()&32)>0}get inClass(){return(this.currentThisScopeFlags()&64)>0}get inClassAndNotInNonArrowFunction(){const t=this.currentThisScopeFlags();return(t&64)>0&&(t&2)===0}get inStaticBlock(){for(let t=this.scopeStack.length-1;;t--){const{flags:s}=this.scopeStack[t];if(s&128)return!0;if(s&707)return!1}}get inNonArrowFunction(){return(this.currentThisScopeFlags()&2)>0}get inBareCaseStatement(){return(this.currentScope().flags&256)>0}get treatFunctionsAsVar(){return this.treatFunctionsAsVarInScope(this.currentScope())}createScope(t){return new ys(t)}enter(t){this.scopeStack.push(this.createScope(t))}exit(){return this.scopeStack.pop().flags}treatFunctionsAsVarInScope(t){return!!(t.flags&130||!this.parser.inModule&&t.flags&1)}declareName(t,s,e){let i=this.currentScope();if(s&8||s&16){this.checkRedeclarationInScope(i,t,s,e);let a=i.names.get(t)||0;s&16?a=a|4:(i.firstLexicalName||(i.firstLexicalName=t),a=a|2),i.names.set(t,a),s&8&&this.maybeExportDefined(i,t)}else if(s&4)for(let a=this.scopeStack.length-1;a>=0&&(i=this.scopeStack[a],this.checkRedeclarationInScope(i,t,s,e),i.names.set(t,(i.names.get(t)||0)|1),this.maybeExportDefined(i,t),!(i.flags&643));--a);this.parser.inModule&&i.flags&1&&this.undefinedExports.delete(t)}maybeExportDefined(t,s){this.parser.inModule&&t.flags&1&&this.undefinedExports.delete(s)}checkRedeclarationInScope(t,s,e,i){this.isRedeclaredInScope(t,s,e)&&this.parser.raise(p.VarRedeclaration,i,{identifierName:s})}isRedeclaredInScope(t,s,e){if(!(e&1))return!1;if(e&8)return t.names.has(s);const i=t.names.get(s);return e&16?(i&2)>0||!this.treatFunctionsAsVarInScope(t)&&(i&1)>0:(i&2)>0&&!(t.flags&8&&t.firstLexicalName===s)||!this.treatFunctionsAsVarInScope(t)&&(i&4)>0}checkLocalExport(t){const{name:s}=t;this.scopeStack[0].names.has(s)||this.undefinedExports.set(s,t.loc.start)}currentScope(){return this.scopeStack[this.scopeStack.length-1]}currentVarScopeFlags(){for(let t=this.scopeStack.length-1;;t--){const{flags:s}=this.scopeStack[t];if(s&643)return s}}currentThisScopeFlags(){for(let t=this.scopeStack.length-1;;t--){const{flags:s}=this.scopeStack[t];if(s&707&&!(s&4))return s}}}class za extends ys{constructor(){super(...arguments);m(this,"declareFunctions",new Set)}}class Va extends xs{createScope(t){return new za(t)}declareName(t,s,e){const i=this.currentScope();if(s&2048){this.checkRedeclarationInScope(i,t,s,e),this.maybeExportDefined(i,t),i.declareFunctions.add(t);return}super.declareName(t,s,e)}isRedeclaredInScope(t,s,e){if(super.isRedeclaredInScope(t,s,e))return!0;if(e&2048&&!t.declareFunctions.has(s)){const i=t.names.get(s);return(i&4)>0||(i&2)>0}return!1}checkLocalExport(t){this.scopeStack[0].declareFunctions.has(t.name)||super.checkLocalExport(t)}}const Ha=new Set(["_","any","bool","boolean","empty","extends","false","interface","mixed","null","number","static","string","true","typeof","void"]),A=Pe`flow`({AmbiguousConditionalArrow:"Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",AmbiguousDeclareModuleKind:"Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module.",AssignReservedType:({reservedType:r})=>`Cannot overwrite reserved type ${r}.`,DeclareClassElement:"The `declare` modifier can only appear on class fields.",DeclareClassFieldInitializer:"Initializers are not allowed in fields with the `declare` modifier.",DuplicateDeclareModuleExports:"Duplicate `declare module.exports` statement.",EnumBooleanMemberNotInitialized:({memberName:r,enumName:t})=>`Boolean enum members need to be initialized. Use either \`${r} = true,\` or \`${r} = false,\` in enum \`${t}\`.`,EnumDuplicateMemberName:({memberName:r,enumName:t})=>`Enum member names need to be unique, but the name \`${r}\` has already been used before in enum \`${t}\`.`,EnumInconsistentMemberValues:({enumName:r})=>`Enum \`${r}\` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.`,EnumInvalidExplicitType:({invalidEnumType:r,enumName:t})=>`Enum type \`${r}\` is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${t}\`.`,EnumInvalidExplicitTypeUnknownSupplied:({enumName:r})=>`Supplied enum type is not valid. Use one of \`boolean\`, \`number\`, \`string\`, or \`symbol\` in enum \`${r}\`.`,EnumInvalidMemberInitializerPrimaryType:({enumName:r,memberName:t,explicitType:s})=>`Enum \`${r}\` has type \`${s}\`, so the initializer of \`${t}\` needs to be a ${s} literal.`,EnumInvalidMemberInitializerSymbolType:({enumName:r,memberName:t})=>`Symbol enum members cannot be initialized. Use \`${t},\` in enum \`${r}\`.`,EnumInvalidMemberInitializerUnknownType:({enumName:r,memberName:t})=>`The enum member initializer for \`${t}\` needs to be a literal (either a boolean, number, or string) in enum \`${r}\`.`,EnumInvalidMemberName:({enumName:r,memberName:t,suggestion:s})=>`Enum member names cannot start with lowercase 'a' through 'z'. Instead of using \`${t}\`, consider using \`${s}\`, in enum \`${r}\`.`,EnumNumberMemberNotInitialized:({enumName:r,memberName:t})=>`Number enum members need to be initialized, e.g. \`${t} = 1\` in enum \`${r}\`.`,EnumStringMemberInconsistentlyInitialized:({enumName:r})=>`String enum members need to consistently either all use initializers, or use no initializers, in enum \`${r}\`.`,GetterMayNotHaveThisParam:"A getter cannot have a `this` parameter.",ImportReflectionHasImportType:"An `import module` declaration can not use `type` or `typeof` keyword.",ImportTypeShorthandOnlyInPureImport:"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements.",InexactInsideExact:"Explicit inexact syntax cannot appear inside an explicit exact object type.",InexactInsideNonObject:"Explicit inexact syntax cannot appear in class or interface definitions.",InexactVariance:"Explicit inexact syntax cannot have variance.",InvalidNonTypeImportInDeclareModule:"Imports within a `declare module` body must always be `import type` or `import typeof`.",MissingTypeParamDefault:"Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",NestedDeclareModule:"`declare module` cannot be used inside another `declare module`.",NestedFlowComment:"Cannot have a flow comment inside another flow comment.",PatternIsOptional:Object.assign({message:"A binding pattern parameter cannot be optional in an implementation signature."},{}),SetterMayNotHaveThisParam:"A setter cannot have a `this` parameter.",SpreadVariance:"Spread properties cannot have variance.",ThisParamAnnotationRequired:"A type annotation is required for the `this` parameter.",ThisParamBannedInConstructor:"Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",ThisParamMayNotBeOptional:"The `this` parameter cannot be optional.",ThisParamMustBeFirst:"The `this` parameter must be the first function parameter.",ThisParamNoDefault:"The `this` parameter may not have a default value.",TypeBeforeInitializer:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeCastInPattern:"The type cast expression is expected to be wrapped with parenthesis.",UnexpectedExplicitInexactInObject:"Explicit inexact syntax must appear at the end of an inexact object.",UnexpectedReservedType:({reservedType:r})=>`Unexpected reserved type ${r}.`,UnexpectedReservedUnderscore:"`_` is only allowed as a type argument to call or new.",UnexpectedSpaceBetweenModuloChecks:"Spaces between `%` and `checks` are not allowed here.",UnexpectedSpreadType:"Spread operator cannot appear in class or interface definitions.",UnexpectedSubtractionOperand:'Unexpected token, expected "number" or "bigint".',UnexpectedTokenAfterTypeParameter:"Expected an arrow function after this type parameter declaration.",UnexpectedTypeParameterBeforeAsyncArrowFunction:"Type parameters must come after the async keyword, e.g. instead of `<T> async () => {}`, use `async <T>() => {}`.",UnsupportedDeclareExportKind:({unsupportedExportKind:r,suggestion:t})=>`\`declare export ${r}\` is not supported. Use \`${t}\` instead.`,UnsupportedStatementInDeclareModule:"Only declares and type imports are allowed inside declare module.",UnterminatedFlowComment:"Unterminated flow-comment."});function Ka(r){return r.type==="DeclareExportAllDeclaration"||r.type==="DeclareExportDeclaration"&&(!r.declaration||r.declaration.type!=="TypeAlias"&&r.declaration.type!=="InterfaceDeclaration")}function hi(r){return r.importKind==="type"||r.importKind==="typeof"}const Wa={const:"declare export var",let:"declare export var",type:"export type",interface:"export interface"};function Ja(r,t){const s=[],e=[];for(let i=0;i<r.length;i++)(t(r[i],i,r)?s:e).push(r[i]);return[s,e]}const Ga=/\*?\s*@((?:no)?flow)\b/;var Xa=r=>class extends r{constructor(){super(...arguments);m(this,"flowPragma")}getScopeHandler(){return Va}shouldParseTypes(){return this.getPluginOption("flow","all")||this.flowPragma==="flow"}finishToken(e,i){e!==134&&e!==13&&e!==28&&this.flowPragma===void 0&&(this.flowPragma=null),super.finishToken(e,i)}addComment(e){if(this.flowPragma===void 0){const i=Ga.exec(e.value);if(i)if(i[1]==="flow")this.flowPragma="flow";else if(i[1]==="noflow")this.flowPragma="noflow";else throw new Error("Unexpected flow pragma")}super.addComment(e)}flowParseTypeInitialiser(e){const i=this.state.inType;this.state.inType=!0,this.expect(e||14);const a=this.flowParseType();return this.state.inType=i,a}flowParsePredicate(){const e=this.startNode(),i=this.state.startLoc;return this.next(),this.expectContextual(110),this.state.lastTokStartLoc.index>i.index+1&&this.raise(A.UnexpectedSpaceBetweenModuloChecks,i),this.eat(10)?(e.value=super.parseExpression(),this.expect(11),this.finishNode(e,"DeclaredPredicate")):this.finishNode(e,"InferredPredicate")}flowParseTypeAndPredicateInitialiser(){const e=this.state.inType;this.state.inType=!0,this.expect(14);let i=null,a=null;return this.match(54)?(this.state.inType=e,a=this.flowParsePredicate()):(i=this.flowParseType(),this.state.inType=e,this.match(54)&&(a=this.flowParsePredicate())),[i,a]}flowParseDeclareClass(e){return this.next(),this.flowParseInterfaceish(e,!0),this.finishNode(e,"DeclareClass")}flowParseDeclareFunction(e){this.next();const i=e.id=this.parseIdentifier(),a=this.startNode(),n=this.startNode();this.match(47)?a.typeParameters=this.flowParseTypeParameterDeclaration():a.typeParameters=null,this.expect(10);const o=this.flowParseFunctionTypeParams();return a.params=o.params,a.rest=o.rest,a.this=o._this,this.expect(11),[a.returnType,e.predicate]=this.flowParseTypeAndPredicateInitialiser(),n.typeAnnotation=this.finishNode(a,"FunctionTypeAnnotation"),i.typeAnnotation=this.finishNode(n,"TypeAnnotation"),this.resetEndLocation(i),this.semicolon(),this.scope.declareName(e.id.name,2048,e.id.loc.start),this.finishNode(e,"DeclareFunction")}flowParseDeclare(e,i){if(this.match(80))return this.flowParseDeclareClass(e);if(this.match(68))return this.flowParseDeclareFunction(e);if(this.match(74))return this.flowParseDeclareVariable(e);if(this.eatContextual(127))return this.match(16)?this.flowParseDeclareModuleExports(e):(i&&this.raise(A.NestedDeclareModule,this.state.lastTokStartLoc),this.flowParseDeclareModule(e));if(this.isContextual(130))return this.flowParseDeclareTypeAlias(e);if(this.isContextual(131))return this.flowParseDeclareOpaqueType(e);if(this.isContextual(129))return this.flowParseDeclareInterface(e);if(this.match(82))return this.flowParseDeclareExportDeclaration(e,i);this.unexpected()}flowParseDeclareVariable(e){return this.next(),e.id=this.flowParseTypeAnnotatableIdentifier(!0),this.scope.declareName(e.id.name,5,e.id.loc.start),this.semicolon(),this.finishNode(e,"DeclareVariable")}flowParseDeclareModule(e){this.scope.enter(0),this.match(134)?e.id=super.parseExprAtom():e.id=this.parseIdentifier();const i=e.body=this.startNode(),a=i.body=[];for(this.expect(5);!this.match(8);){let c=this.startNode();this.match(83)?(this.next(),!this.isContextual(130)&&!this.match(87)&&this.raise(A.InvalidNonTypeImportInDeclareModule,this.state.lastTokStartLoc),super.parseImport(c)):(this.expectContextual(125,A.UnsupportedStatementInDeclareModule),c=this.flowParseDeclare(c,!0)),a.push(c)}this.scope.exit(),this.expect(8),this.finishNode(i,"BlockStatement");let n=null,o=!1;return a.forEach(c=>{Ka(c)?(n==="CommonJS"&&this.raise(A.AmbiguousDeclareModuleKind,c),n="ES"):c.type==="DeclareModuleExports"&&(o&&this.raise(A.DuplicateDeclareModuleExports,c),n==="ES"&&this.raise(A.AmbiguousDeclareModuleKind,c),n="CommonJS",o=!0)}),e.kind=n||"CommonJS",this.finishNode(e,"DeclareModule")}flowParseDeclareExportDeclaration(e,i){if(this.expect(82),this.eat(65))return this.match(68)||this.match(80)?e.declaration=this.flowParseDeclare(this.startNode()):(e.declaration=this.flowParseType(),this.semicolon()),e.default=!0,this.finishNode(e,"DeclareExportDeclaration");if(this.match(75)||this.isLet()||(this.isContextual(130)||this.isContextual(129))&&!i){const a=this.state.value;throw this.raise(A.UnsupportedDeclareExportKind,this.state.startLoc,{unsupportedExportKind:a,suggestion:Wa[a]})}if(this.match(74)||this.match(68)||this.match(80)||this.isContextual(131))return e.declaration=this.flowParseDeclare(this.startNode()),e.default=!1,this.finishNode(e,"DeclareExportDeclaration");if(this.match(55)||this.match(5)||this.isContextual(129)||this.isContextual(130)||this.isContextual(131))return e=this.parseExport(e,null),e.type==="ExportNamedDeclaration"?(e.default=!1,delete e.exportKind,this.castNodeTo(e,"DeclareExportDeclaration")):this.castNodeTo(e,"DeclareExportAllDeclaration");this.unexpected()}flowParseDeclareModuleExports(e){return this.next(),this.expectContextual(111),e.typeAnnotation=this.flowParseTypeAnnotation(),this.semicolon(),this.finishNode(e,"DeclareModuleExports")}flowParseDeclareTypeAlias(e){this.next();const i=this.flowParseTypeAlias(e);return this.castNodeTo(i,"DeclareTypeAlias"),i}flowParseDeclareOpaqueType(e){this.next();const i=this.flowParseOpaqueType(e,!0);return this.castNodeTo(i,"DeclareOpaqueType"),i}flowParseDeclareInterface(e){return this.next(),this.flowParseInterfaceish(e,!1),this.finishNode(e,"DeclareInterface")}flowParseInterfaceish(e,i){if(e.id=this.flowParseRestrictedIdentifier(!i,!0),this.scope.declareName(e.id.name,i?17:8201,e.id.loc.start),this.match(47)?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.extends=[],this.eat(81))do e.extends.push(this.flowParseInterfaceExtends());while(!i&&this.eat(12));if(i){if(e.implements=[],e.mixins=[],this.eatContextual(117))do e.mixins.push(this.flowParseInterfaceExtends());while(this.eat(12));if(this.eatContextual(113))do e.implements.push(this.flowParseInterfaceExtends());while(this.eat(12))}e.body=this.flowParseObjectType({allowStatic:i,allowExact:!1,allowSpread:!1,allowProto:i,allowInexact:!1})}flowParseInterfaceExtends(){const e=this.startNode();return e.id=this.flowParseQualifiedTypeIdentifier(),this.match(47)?e.typeParameters=this.flowParseTypeParameterInstantiation():e.typeParameters=null,this.finishNode(e,"InterfaceExtends")}flowParseInterface(e){return this.flowParseInterfaceish(e,!1),this.finishNode(e,"InterfaceDeclaration")}checkNotUnderscore(e){e==="_"&&this.raise(A.UnexpectedReservedUnderscore,this.state.startLoc)}checkReservedType(e,i,a){Ha.has(e)&&this.raise(a?A.AssignReservedType:A.UnexpectedReservedType,i,{reservedType:e})}flowParseRestrictedIdentifier(e,i){return this.checkReservedType(this.state.value,this.state.startLoc,i),this.parseIdentifier(e)}flowParseTypeAlias(e){return e.id=this.flowParseRestrictedIdentifier(!1,!0),this.scope.declareName(e.id.name,8201,e.id.loc.start),this.match(47)?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.right=this.flowParseTypeInitialiser(29),this.semicolon(),this.finishNode(e,"TypeAlias")}flowParseOpaqueType(e,i){return this.expectContextual(130),e.id=this.flowParseRestrictedIdentifier(!0,!0),this.scope.declareName(e.id.name,8201,e.id.loc.start),this.match(47)?e.typeParameters=this.flowParseTypeParameterDeclaration():e.typeParameters=null,e.supertype=null,this.match(14)&&(e.supertype=this.flowParseTypeInitialiser(14)),e.impltype=null,i||(e.impltype=this.flowParseTypeInitialiser(29)),this.semicolon(),this.finishNode(e,"OpaqueType")}flowParseTypeParameter(e=!1){const i=this.state.startLoc,a=this.startNode(),n=this.flowParseVariance(),o=this.flowParseTypeAnnotatableIdentifier();return a.name=o.name,a.variance=n,a.bound=o.typeAnnotation,this.match(29)?(this.eat(29),a.default=this.flowParseType()):e&&this.raise(A.MissingTypeParamDefault,i),this.finishNode(a,"TypeParameter")}flowParseTypeParameterDeclaration(){const e=this.state.inType,i=this.startNode();i.params=[],this.state.inType=!0,this.match(47)||this.match(143)?this.next():this.unexpected();let a=!1;do{const n=this.flowParseTypeParameter(a);i.params.push(n),n.default&&(a=!0),this.match(48)||this.expect(12)}while(!this.match(48));return this.expect(48),this.state.inType=e,this.finishNode(i,"TypeParameterDeclaration")}flowInTopLevelContext(e){if(this.curContext()!==R.brace){const i=this.state.context;this.state.context=[i[0]];try{return e()}finally{this.state.context=i}}else return e()}flowParseTypeParameterInstantiationInExpression(){if(this.reScan_lt()===47)return this.flowParseTypeParameterInstantiation()}flowParseTypeParameterInstantiation(){const e=this.startNode(),i=this.state.inType;return this.state.inType=!0,e.params=[],this.flowInTopLevelContext(()=>{this.expect(47);const a=this.state.noAnonFunctionType;for(this.state.noAnonFunctionType=!1;!this.match(48);)e.params.push(this.flowParseType()),this.match(48)||this.expect(12);this.state.noAnonFunctionType=a}),this.state.inType=i,!this.state.inType&&this.curContext()===R.brace&&this.reScan_lt_gt(),this.expect(48),this.finishNode(e,"TypeParameterInstantiation")}flowParseTypeParameterInstantiationCallOrNew(){if(this.reScan_lt()!==47)return;const e=this.startNode(),i=this.state.inType;for(e.params=[],this.state.inType=!0,this.expect(47);!this.match(48);)e.params.push(this.flowParseTypeOrImplicitInstantiation()),this.match(48)||this.expect(12);return this.expect(48),this.state.inType=i,this.finishNode(e,"TypeParameterInstantiation")}flowParseInterfaceType(){const e=this.startNode();if(this.expectContextual(129),e.extends=[],this.eat(81))do e.extends.push(this.flowParseInterfaceExtends());while(this.eat(12));return e.body=this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!1,allowProto:!1,allowInexact:!1}),this.finishNode(e,"InterfaceTypeAnnotation")}flowParseObjectPropertyKey(){return this.match(135)||this.match(134)?super.parseExprAtom():this.parseIdentifier(!0)}flowParseObjectTypeIndexer(e,i,a){return e.static=i,this.lookahead().type===14?(e.id=this.flowParseObjectPropertyKey(),e.key=this.flowParseTypeInitialiser()):(e.id=null,e.key=this.flowParseType()),this.expect(3),e.value=this.flowParseTypeInitialiser(),e.variance=a,this.finishNode(e,"ObjectTypeIndexer")}flowParseObjectTypeInternalSlot(e,i){return e.static=i,e.id=this.flowParseObjectPropertyKey(),this.expect(3),this.expect(3),this.match(47)||this.match(10)?(e.method=!0,e.optional=!1,e.value=this.flowParseObjectTypeMethodish(this.startNodeAt(e.loc.start))):(e.method=!1,this.eat(17)&&(e.optional=!0),e.value=this.flowParseTypeInitialiser()),this.finishNode(e,"ObjectTypeInternalSlot")}flowParseObjectTypeMethodish(e){for(e.params=[],e.rest=null,e.typeParameters=null,e.this=null,this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),this.expect(10),this.match(78)&&(e.this=this.flowParseFunctionTypeParam(!0),e.this.name=null,this.match(11)||this.expect(12));!this.match(11)&&!this.match(21);)e.params.push(this.flowParseFunctionTypeParam(!1)),this.match(11)||this.expect(12);return this.eat(21)&&(e.rest=this.flowParseFunctionTypeParam(!1)),this.expect(11),e.returnType=this.flowParseTypeInitialiser(),this.finishNode(e,"FunctionTypeAnnotation")}flowParseObjectTypeCallProperty(e,i){const a=this.startNode();return e.static=i,e.value=this.flowParseObjectTypeMethodish(a),this.finishNode(e,"ObjectTypeCallProperty")}flowParseObjectType({allowStatic:e,allowExact:i,allowSpread:a,allowProto:n,allowInexact:o}){const c=this.state.inType;this.state.inType=!0;const h=this.startNode();h.callProperties=[],h.properties=[],h.indexers=[],h.internalSlots=[];let l,u,f=!1;for(i&&this.match(6)?(this.expect(6),l=9,u=!0):(this.expect(5),l=8,u=!1),h.exact=u;!this.match(l);){let P=!1,S=null,F=null;const I=this.startNode();if(n&&this.isContextual(118)){const L=this.lookahead();L.type!==14&&L.type!==17&&(this.next(),S=this.state.startLoc,e=!1)}if(e&&this.isContextual(106)){const L=this.lookahead();L.type!==14&&L.type!==17&&(this.next(),P=!0)}const O=this.flowParseVariance();if(this.eat(0))S!=null&&this.unexpected(S),this.eat(0)?(O&&this.unexpected(O.loc.start),h.internalSlots.push(this.flowParseObjectTypeInternalSlot(I,P))):h.indexers.push(this.flowParseObjectTypeIndexer(I,P,O));else if(this.match(10)||this.match(47))S!=null&&this.unexpected(S),O&&this.unexpected(O.loc.start),h.callProperties.push(this.flowParseObjectTypeCallProperty(I,P));else{let L="init";if(this.isContextual(99)||this.isContextual(104)){const g=this.lookahead();ei(g.type)&&(L=this.state.value,this.next())}const fe=this.flowParseObjectTypeProperty(I,P,S,O,L,a,o??!u);fe===null?(f=!0,F=this.state.lastTokStartLoc):h.properties.push(fe)}this.flowObjectTypeSemicolon(),F&&!this.match(8)&&!this.match(9)&&this.raise(A.UnexpectedExplicitInexactInObject,F)}this.expect(l),a&&(h.inexact=f);const d=this.finishNode(h,"ObjectTypeAnnotation");return this.state.inType=c,d}flowParseObjectTypeProperty(e,i,a,n,o,c,h){if(this.eat(21))return this.match(12)||this.match(13)||this.match(8)||this.match(9)?(c?h||this.raise(A.InexactInsideExact,this.state.lastTokStartLoc):this.raise(A.InexactInsideNonObject,this.state.lastTokStartLoc),n&&this.raise(A.InexactVariance,n),null):(c||this.raise(A.UnexpectedSpreadType,this.state.lastTokStartLoc),a!=null&&this.unexpected(a),n&&this.raise(A.SpreadVariance,n),e.argument=this.flowParseType(),this.finishNode(e,"ObjectTypeSpreadProperty"));{e.key=this.flowParseObjectPropertyKey(),e.static=i,e.proto=a!=null,e.kind=o;let l=!1;return this.match(47)||this.match(10)?(e.method=!0,a!=null&&this.unexpected(a),n&&this.unexpected(n.loc.start),e.value=this.flowParseObjectTypeMethodish(this.startNodeAt(e.loc.start)),(o==="get"||o==="set")&&this.flowCheckGetterSetterParams(e),!c&&e.key.name==="constructor"&&e.value.this&&this.raise(A.ThisParamBannedInConstructor,e.value.this)):(o!=="init"&&this.unexpected(),e.method=!1,this.eat(17)&&(l=!0),e.value=this.flowParseTypeInitialiser(),e.variance=n),e.optional=l,this.finishNode(e,"ObjectTypeProperty")}}flowCheckGetterSetterParams(e){const i=e.kind==="get"?0:1,a=e.value.params.length+(e.value.rest?1:0);e.value.this&&this.raise(e.kind==="get"?A.GetterMayNotHaveThisParam:A.SetterMayNotHaveThisParam,e.value.this),a!==i&&this.raise(e.kind==="get"?p.BadGetterArity:p.BadSetterArity,e),e.kind==="set"&&e.value.rest&&this.raise(p.BadSetterRestParameter,e)}flowObjectTypeSemicolon(){!this.eat(13)&&!this.eat(12)&&!this.match(8)&&!this.match(9)&&this.unexpected()}flowParseQualifiedTypeIdentifier(e,i){e??(e=this.state.startLoc);let a=i||this.flowParseRestrictedIdentifier(!0);for(;this.eat(16);){const n=this.startNodeAt(e);n.qualification=a,n.id=this.flowParseRestrictedIdentifier(!0),a=this.finishNode(n,"QualifiedTypeIdentifier")}return a}flowParseGenericType(e,i){const a=this.startNodeAt(e);return a.typeParameters=null,a.id=this.flowParseQualifiedTypeIdentifier(e,i),this.match(47)&&(a.typeParameters=this.flowParseTypeParameterInstantiation()),this.finishNode(a,"GenericTypeAnnotation")}flowParseTypeofType(){const e=this.startNode();return this.expect(87),e.argument=this.flowParsePrimaryType(),this.finishNode(e,"TypeofTypeAnnotation")}flowParseTupleType(){const e=this.startNode();for(e.types=[],this.expect(0);this.state.pos<this.length&&!this.match(3)&&(e.types.push(this.flowParseType()),!this.match(3));)this.expect(12);return this.expect(3),this.finishNode(e,"TupleTypeAnnotation")}flowParseFunctionTypeParam(e){let i=null,a=!1,n=null;const o=this.startNode(),c=this.lookahead(),h=this.state.type===78;return c.type===14||c.type===17?(h&&!e&&this.raise(A.ThisParamMustBeFirst,o),i=this.parseIdentifier(h),this.eat(17)&&(a=!0,h&&this.raise(A.ThisParamMayNotBeOptional,o)),n=this.flowParseTypeInitialiser()):n=this.flowParseType(),o.name=i,o.optional=a,o.typeAnnotation=n,this.finishNode(o,"FunctionTypeParam")}reinterpretTypeAsFunctionTypeParam(e){const i=this.startNodeAt(e.loc.start);return i.name=null,i.optional=!1,i.typeAnnotation=e,this.finishNode(i,"FunctionTypeParam")}flowParseFunctionTypeParams(e=[]){let i=null,a=null;for(this.match(78)&&(a=this.flowParseFunctionTypeParam(!0),a.name=null,this.match(11)||this.expect(12));!this.match(11)&&!this.match(21);)e.push(this.flowParseFunctionTypeParam(!1)),this.match(11)||this.expect(12);return this.eat(21)&&(i=this.flowParseFunctionTypeParam(!1)),{params:e,rest:i,_this:a}}flowIdentToTypeAnnotation(e,i,a){switch(a.name){case"any":return this.finishNode(i,"AnyTypeAnnotation");case"bool":case"boolean":return this.finishNode(i,"BooleanTypeAnnotation");case"mixed":return this.finishNode(i,"MixedTypeAnnotation");case"empty":return this.finishNode(i,"EmptyTypeAnnotation");case"number":return this.finishNode(i,"NumberTypeAnnotation");case"string":return this.finishNode(i,"StringTypeAnnotation");case"symbol":return this.finishNode(i,"SymbolTypeAnnotation");default:return this.checkNotUnderscore(a.name),this.flowParseGenericType(e,a)}}flowParsePrimaryType(){const e=this.state.startLoc,i=this.startNode();let a,n,o=!1;const c=this.state.noAnonFunctionType;switch(this.state.type){case 5:return this.flowParseObjectType({allowStatic:!1,allowExact:!1,allowSpread:!0,allowProto:!1,allowInexact:!0});case 6:return this.flowParseObjectType({allowStatic:!1,allowExact:!0,allowSpread:!0,allowProto:!1,allowInexact:!1});case 0:return this.state.noAnonFunctionType=!1,n=this.flowParseTupleType(),this.state.noAnonFunctionType=c,n;case 47:{const h=this.startNode();return h.typeParameters=this.flowParseTypeParameterDeclaration(),this.expect(10),a=this.flowParseFunctionTypeParams(),h.params=a.params,h.rest=a.rest,h.this=a._this,this.expect(11),this.expect(19),h.returnType=this.flowParseType(),this.finishNode(h,"FunctionTypeAnnotation")}case 10:{const h=this.startNode();if(this.next(),!this.match(11)&&!this.match(21))if(D(this.state.type)||this.match(78)){const l=this.lookahead().type;o=l!==17&&l!==14}else o=!0;if(o){if(this.state.noAnonFunctionType=!1,n=this.flowParseType(),this.state.noAnonFunctionType=c,this.state.noAnonFunctionType||!(this.match(12)||this.match(11)&&this.lookahead().type===19))return this.expect(11),n;this.eat(12)}return n?a=this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(n)]):a=this.flowParseFunctionTypeParams(),h.params=a.params,h.rest=a.rest,h.this=a._this,this.expect(11),this.expect(19),h.returnType=this.flowParseType(),h.typeParameters=null,this.finishNode(h,"FunctionTypeAnnotation")}case 134:return this.parseLiteral(this.state.value,"StringLiteralTypeAnnotation");case 85:case 86:return i.value=this.match(85),this.next(),this.finishNode(i,"BooleanLiteralTypeAnnotation");case 53:if(this.state.value==="-"){if(this.next(),this.match(135))return this.parseLiteralAtNode(-this.state.value,"NumberLiteralTypeAnnotation",i);if(this.match(136))return this.parseLiteralAtNode(-this.state.value,"BigIntLiteralTypeAnnotation",i);throw this.raise(A.UnexpectedSubtractionOperand,this.state.startLoc)}this.unexpected();return;case 135:return this.parseLiteral(this.state.value,"NumberLiteralTypeAnnotation");case 136:return this.parseLiteral(this.state.value,"BigIntLiteralTypeAnnotation");case 88:return this.next(),this.finishNode(i,"VoidTypeAnnotation");case 84:return this.next(),this.finishNode(i,"NullLiteralTypeAnnotation");case 78:return this.next(),this.finishNode(i,"ThisTypeAnnotation");case 55:return this.next(),this.finishNode(i,"ExistsTypeAnnotation");case 87:return this.flowParseTypeofType();default:if(us(this.state.type)){const h=Ne(this.state.type);return this.next(),super.createIdentifier(i,h)}else if(D(this.state.type))return this.isContextual(129)?this.flowParseInterfaceType():this.flowIdentToTypeAnnotation(e,i,this.parseIdentifier())}this.unexpected()}flowParsePostfixType(){const e=this.state.startLoc;let i=this.flowParsePrimaryType(),a=!1;for(;(this.match(0)||this.match(18))&&!this.canInsertSemicolon();){const n=this.startNodeAt(e),o=this.eat(18);a=a||o,this.expect(0),!o&&this.match(3)?(n.elementType=i,this.next(),i=this.finishNode(n,"ArrayTypeAnnotation")):(n.objectType=i,n.indexType=this.flowParseType(),this.expect(3),a?(n.optional=o,i=this.finishNode(n,"OptionalIndexedAccessType")):i=this.finishNode(n,"IndexedAccessType"))}return i}flowParsePrefixType(){const e=this.startNode();return this.eat(17)?(e.typeAnnotation=this.flowParsePrefixType(),this.finishNode(e,"NullableTypeAnnotation")):this.flowParsePostfixType()}flowParseAnonFunctionWithoutParens(){const e=this.flowParsePrefixType();if(!this.state.noAnonFunctionType&&this.eat(19)){const i=this.startNodeAt(e.loc.start);return i.params=[this.reinterpretTypeAsFunctionTypeParam(e)],i.rest=null,i.this=null,i.returnType=this.flowParseType(),i.typeParameters=null,this.finishNode(i,"FunctionTypeAnnotation")}return e}flowParseIntersectionType(){const e=this.startNode();this.eat(45);const i=this.flowParseAnonFunctionWithoutParens();for(e.types=[i];this.eat(45);)e.types.push(this.flowParseAnonFunctionWithoutParens());return e.types.length===1?i:this.finishNode(e,"IntersectionTypeAnnotation")}flowParseUnionType(){const e=this.startNode();this.eat(43);const i=this.flowParseIntersectionType();for(e.types=[i];this.eat(43);)e.types.push(this.flowParseIntersectionType());return e.types.length===1?i:this.finishNode(e,"UnionTypeAnnotation")}flowParseType(){const e=this.state.inType;this.state.inType=!0;const i=this.flowParseUnionType();return this.state.inType=e,i}flowParseTypeOrImplicitInstantiation(){if(this.state.type===132&&this.state.value==="_"){const e=this.state.startLoc,i=this.parseIdentifier();return this.flowParseGenericType(e,i)}else return this.flowParseType()}flowParseTypeAnnotation(){const e=this.startNode();return e.typeAnnotation=this.flowParseTypeInitialiser(),this.finishNode(e,"TypeAnnotation")}flowParseTypeAnnotatableIdentifier(e){const i=e?this.parseIdentifier():this.flowParseRestrictedIdentifier();return this.match(14)&&(i.typeAnnotation=this.flowParseTypeAnnotation(),this.resetEndLocation(i)),i}typeCastToParameter(e){return e.expression.typeAnnotation=e.typeAnnotation,this.resetEndLocation(e.expression,e.typeAnnotation.loc.end),e.expression}flowParseVariance(){let e=null;return this.match(53)?(e=this.startNode(),this.state.value==="+"?e.kind="plus":e.kind="minus",this.next(),this.finishNode(e,"Variance")):e}parseFunctionBody(e,i,a=!1){if(i){this.forwardNoArrowParamsConversionAt(e,()=>super.parseFunctionBody(e,!0,a));return}super.parseFunctionBody(e,!1,a)}parseFunctionBodyAndFinish(e,i,a=!1){if(this.match(14)){const n=this.startNode();[n.typeAnnotation,e.predicate]=this.flowParseTypeAndPredicateInitialiser(),e.returnType=n.typeAnnotation?this.finishNode(n,"TypeAnnotation"):null}return super.parseFunctionBodyAndFinish(e,i,a)}parseStatementLike(e){if(this.state.strict&&this.isContextual(129)){const a=this.lookahead();if(ue(a.type)){const n=this.startNode();return this.next(),this.flowParseInterface(n)}}else if(this.isContextual(126)){const a=this.startNode();return this.next(),this.flowParseEnumDeclaration(a)}const i=super.parseStatementLike(e);return this.flowPragma===void 0&&!this.isValidDirective(i)&&(this.flowPragma=null),i}parseExpressionStatement(e,i,a){if(i.type==="Identifier"){if(i.name==="declare"){if(this.match(80)||D(this.state.type)||this.match(68)||this.match(74)||this.match(82))return this.flowParseDeclare(e)}else if(D(this.state.type)){if(i.name==="interface")return this.flowParseInterface(e);if(i.name==="type")return this.flowParseTypeAlias(e);if(i.name==="opaque")return this.flowParseOpaqueType(e,!1)}}return super.parseExpressionStatement(e,i,a)}shouldParseExportDeclaration(){const{type:e}=this.state;return e===126||ti(e)?!this.state.containsEsc:super.shouldParseExportDeclaration()}isExportDefaultSpecifier(){const{type:e}=this.state;return e===126||ti(e)?this.state.containsEsc:super.isExportDefaultSpecifier()}parseExportDefaultExpression(){if(this.isContextual(126)){const e=this.startNode();return this.next(),this.flowParseEnumDeclaration(e)}return super.parseExportDefaultExpression()}parseConditional(e,i,a){if(!this.match(17))return e;if(this.state.maybeInArrowParameters){const d=this.lookaheadCharCode();if(d===44||d===61||d===58||d===41)return this.setOptionalParametersError(a),e}this.expect(17);const n=this.state.clone(),o=this.state.noArrowAt,c=this.startNodeAt(i);let{consequent:h,failed:l}=this.tryParseConditionalConsequent(),[u,f]=this.getArrowLikeExpressions(h);if(l||f.length>0){const d=[...o];if(f.length>0){this.state=n,this.state.noArrowAt=d;for(let P=0;P<f.length;P++)d.push(f[P].start);({consequent:h,failed:l}=this.tryParseConditionalConsequent()),[u,f]=this.getArrowLikeExpressions(h)}l&&u.length>1&&this.raise(A.AmbiguousConditionalArrow,n.startLoc),l&&u.length===1&&(this.state=n,d.push(u[0].start),this.state.noArrowAt=d,{consequent:h,failed:l}=this.tryParseConditionalConsequent())}return this.getArrowLikeExpressions(h,!0),this.state.noArrowAt=o,this.expect(14),c.test=e,c.consequent=h,c.alternate=this.forwardNoArrowParamsConversionAt(c,()=>this.parseMaybeAssign(void 0,void 0)),this.finishNode(c,"ConditionalExpression")}tryParseConditionalConsequent(){this.state.noArrowParamsConversionAt.push(this.state.start);const e=this.parseMaybeAssignAllowIn(),i=!this.match(14);return this.state.noArrowParamsConversionAt.pop(),{consequent:e,failed:i}}getArrowLikeExpressions(e,i){const a=[e],n=[];for(;a.length!==0;){const o=a.pop();o.type==="ArrowFunctionExpression"&&o.body.type!=="BlockStatement"?(o.typeParameters||!o.returnType?this.finishArrowValidation(o):n.push(o),a.push(o.body)):o.type==="ConditionalExpression"&&(a.push(o.consequent),a.push(o.alternate))}return i?(n.forEach(o=>this.finishArrowValidation(o)),[n,[]]):Ja(n,o=>o.params.every(c=>this.isAssignable(c,!0)))}finishArrowValidation(e){var i;this.toAssignableList(e.params,(i=e.extra)==null?void 0:i.trailingCommaLoc,!1),this.scope.enter(6),super.checkParams(e,!1,!0),this.scope.exit()}forwardNoArrowParamsConversionAt(e,i){let a;return this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start))?(this.state.noArrowParamsConversionAt.push(this.state.start),a=i(),this.state.noArrowParamsConversionAt.pop()):a=i(),a}parseParenItem(e,i){const a=super.parseParenItem(e,i);if(this.eat(17)&&(a.optional=!0,this.resetEndLocation(e)),this.match(14)){const n=this.startNodeAt(i);return n.expression=a,n.typeAnnotation=this.flowParseTypeAnnotation(),this.finishNode(n,"TypeCastExpression")}return a}assertModuleNodeAllowed(e){e.type==="ImportDeclaration"&&(e.importKind==="type"||e.importKind==="typeof")||e.type==="ExportNamedDeclaration"&&e.exportKind==="type"||e.type==="ExportAllDeclaration"&&e.exportKind==="type"||super.assertModuleNodeAllowed(e)}parseExportDeclaration(e){if(this.isContextual(130)){e.exportKind="type";const i=this.startNode();return this.next(),this.match(5)?(e.specifiers=this.parseExportSpecifiers(!0),super.parseExportFrom(e),null):this.flowParseTypeAlias(i)}else if(this.isContextual(131)){e.exportKind="type";const i=this.startNode();return this.next(),this.flowParseOpaqueType(i,!1)}else if(this.isContextual(129)){e.exportKind="type";const i=this.startNode();return this.next(),this.flowParseInterface(i)}else if(this.isContextual(126)){e.exportKind="value";const i=this.startNode();return this.next(),this.flowParseEnumDeclaration(i)}else return super.parseExportDeclaration(e)}eatExportStar(e){return super.eatExportStar(e)?!0:this.isContextual(130)&&this.lookahead().type===55?(e.exportKind="type",this.next(),this.next(),!0):!1}maybeParseExportNamespaceSpecifier(e){const{startLoc:i}=this.state,a=super.maybeParseExportNamespaceSpecifier(e);return a&&e.exportKind==="type"&&this.unexpected(i),a}parseClassId(e,i,a){super.parseClassId(e,i,a),this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration())}parseClassMember(e,i,a){const{startLoc:n}=this.state;if(this.isContextual(125)){if(super.parseClassMemberFromModifier(e,i))return;i.declare=!0}super.parseClassMember(e,i,a),i.declare&&(i.type!=="ClassProperty"&&i.type!=="ClassPrivateProperty"&&i.type!=="PropertyDefinition"?this.raise(A.DeclareClassElement,n):i.value&&this.raise(A.DeclareClassFieldInitializer,i.value))}isIterator(e){return e==="iterator"||e==="asyncIterator"}readIterator(){const e=super.readWord1(),i="@@"+e;(!this.isIterator(e)||!this.state.inType)&&this.raise(p.InvalidIdentifier,this.state.curPosition(),{identifierName:i}),this.finishToken(132,i)}getTokenFromCode(e){const i=this.input.charCodeAt(this.state.pos+1);e===123&&i===124?this.finishOp(6,2):this.state.inType&&(e===62||e===60)?this.finishOp(e===62?48:47,1):this.state.inType&&e===63?i===46?this.finishOp(18,2):this.finishOp(17,1):Ua(e,i,this.input.charCodeAt(this.state.pos+2))?(this.state.pos+=2,this.readIterator()):super.getTokenFromCode(e)}isAssignable(e,i){return e.type==="TypeCastExpression"?this.isAssignable(e.expression,i):super.isAssignable(e,i)}toAssignable(e,i=!1){!i&&e.type==="AssignmentExpression"&&e.left.type==="TypeCastExpression"&&(e.left=this.typeCastToParameter(e.left)),super.toAssignable(e,i)}toAssignableList(e,i,a){for(let n=0;n<e.length;n++){const o=e[n];(o==null?void 0:o.type)==="TypeCastExpression"&&(e[n]=this.typeCastToParameter(o))}super.toAssignableList(e,i,a)}toReferencedList(e,i){var a;for(let n=0;n<e.length;n++){const o=e[n];o&&o.type==="TypeCastExpression"&&!((a=o.extra)!=null&&a.parenthesized)&&(e.length>1||!i)&&this.raise(A.TypeCastInPattern,o.typeAnnotation)}return e}parseArrayLike(e,i,a,n){const o=super.parseArrayLike(e,i,a,n);return i&&!this.state.maybeInArrowParameters&&this.toReferencedList(o.elements),o}isValidLVal(e,i,a){return e==="TypeCastExpression"||super.isValidLVal(e,i,a)}parseClassProperty(e){return this.match(14)&&(e.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassProperty(e)}parseClassPrivateProperty(e){return this.match(14)&&(e.typeAnnotation=this.flowParseTypeAnnotation()),super.parseClassPrivateProperty(e)}isClassMethod(){return this.match(47)||super.isClassMethod()}isClassProperty(){return this.match(14)||super.isClassProperty()}isNonstaticConstructor(e){return!this.match(14)&&super.isNonstaticConstructor(e)}pushClassMethod(e,i,a,n,o,c){if(i.variance&&this.unexpected(i.variance.loc.start),delete i.variance,this.match(47)&&(i.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassMethod(e,i,a,n,o,c),i.params&&o){const h=i.params;h.length>0&&this.isThisParam(h[0])&&this.raise(A.ThisParamBannedInConstructor,i)}else if(i.type==="MethodDefinition"&&o&&i.value.params){const h=i.value.params;h.length>0&&this.isThisParam(h[0])&&this.raise(A.ThisParamBannedInConstructor,i)}}pushClassPrivateMethod(e,i,a,n){i.variance&&this.unexpected(i.variance.loc.start),delete i.variance,this.match(47)&&(i.typeParameters=this.flowParseTypeParameterDeclaration()),super.pushClassPrivateMethod(e,i,a,n)}parseClassSuper(e){if(super.parseClassSuper(e),e.superClass&&(this.match(47)||this.match(51))&&(e.superTypeArguments=this.flowParseTypeParameterInstantiationInExpression()),this.isContextual(113)){this.next();const i=e.implements=[];do{const a=this.startNode();a.id=this.flowParseRestrictedIdentifier(!0),this.match(47)?a.typeParameters=this.flowParseTypeParameterInstantiation():a.typeParameters=null,i.push(this.finishNode(a,"ClassImplements"))}while(this.eat(12))}}checkGetterSetterParams(e){super.checkGetterSetterParams(e);const i=this.getObjectOrClassMethodParams(e);if(i.length>0){const a=i[0];this.isThisParam(a)&&e.kind==="get"?this.raise(A.GetterMayNotHaveThisParam,a):this.isThisParam(a)&&this.raise(A.SetterMayNotHaveThisParam,a)}}parsePropertyNamePrefixOperator(e){e.variance=this.flowParseVariance()}parseObjPropValue(e,i,a,n,o,c,h){e.variance&&this.unexpected(e.variance.loc.start),delete e.variance;let l;this.match(47)&&!c&&(l=this.flowParseTypeParameterDeclaration(),this.match(10)||this.unexpected());const u=super.parseObjPropValue(e,i,a,n,o,c,h);return l&&((u.value||u).typeParameters=l),u}parseFunctionParamType(e){return this.eat(17)&&(e.type!=="Identifier"&&this.raise(A.PatternIsOptional,e),this.isThisParam(e)&&this.raise(A.ThisParamMayNotBeOptional,e),e.optional=!0),this.match(14)?e.typeAnnotation=this.flowParseTypeAnnotation():this.isThisParam(e)&&this.raise(A.ThisParamAnnotationRequired,e),this.match(29)&&this.isThisParam(e)&&this.raise(A.ThisParamNoDefault,e),this.resetEndLocation(e),e}parseMaybeDefault(e,i){const a=super.parseMaybeDefault(e,i);return a.type==="AssignmentPattern"&&a.typeAnnotation&&a.right.start<a.typeAnnotation.start&&this.raise(A.TypeBeforeInitializer,a.typeAnnotation),a}checkImportReflection(e){super.checkImportReflection(e),e.module&&e.importKind!=="value"&&this.raise(A.ImportReflectionHasImportType,e.specifiers[0].loc.start)}parseImportSpecifierLocal(e,i,a){i.local=hi(e)?this.flowParseRestrictedIdentifier(!0,!0):this.parseIdentifier(),e.specifiers.push(this.finishImportSpecifier(i,a))}isPotentialImportPhase(e){if(super.isPotentialImportPhase(e))return!0;if(this.isContextual(130)){if(!e)return!0;const i=this.lookaheadCharCode();return i===123||i===42}return!e&&this.isContextual(87)}applyImportPhase(e,i,a,n){if(super.applyImportPhase(e,i,a,n),i){if(!a&&this.match(65))return;e.exportKind=a==="type"?a:"value"}else a==="type"&&this.match(55)&&this.unexpected(),e.importKind=a==="type"||a==="typeof"?a:"value"}parseImportSpecifier(e,i,a,n,o){const c=e.imported;let h=null;c.type==="Identifier"&&(c.name==="type"?h="type":c.name==="typeof"&&(h="typeof"));let l=!1;if(this.isContextual(93)&&!this.isLookaheadContextual("as")){const f=this.parseIdentifier(!0);h!==null&&!ue(this.state.type)?(e.imported=f,e.importKind=h,e.local=this.cloneIdentifier(f)):(e.imported=c,e.importKind=null,e.local=this.parseIdentifier())}else{if(h!==null&&ue(this.state.type))e.imported=this.parseIdentifier(!0),e.importKind=h;else{if(i)throw this.raise(p.ImportBindingIsString,e,{importName:c.value});e.imported=c,e.importKind=null}this.eatContextual(93)?e.local=this.parseIdentifier():(l=!0,e.local=this.cloneIdentifier(e.imported))}const u=hi(e);return a&&u&&this.raise(A.ImportTypeShorthandOnlyInPureImport,e),(a||u)&&this.checkReservedType(e.local.name,e.local.loc.start,!0),l&&!a&&!u&&this.checkReservedWord(e.local.name,e.loc.start,!0,!0),this.finishImportSpecifier(e,"ImportSpecifier")}parseBindingAtom(){switch(this.state.type){case 78:return this.parseIdentifier(!0);default:return super.parseBindingAtom()}}parseFunctionParams(e,i){const a=e.kind;a!=="get"&&a!=="set"&&this.match(47)&&(e.typeParameters=this.flowParseTypeParameterDeclaration()),super.parseFunctionParams(e,i)}parseVarId(e,i){super.parseVarId(e,i),this.match(14)&&(e.id.typeAnnotation=this.flowParseTypeAnnotation(),this.resetEndLocation(e.id))}parseAsyncArrowFromCallExpression(e,i){if(this.match(14)){const a=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0,e.returnType=this.flowParseTypeAnnotation(),this.state.noAnonFunctionType=a}return super.parseAsyncArrowFromCallExpression(e,i)}shouldParseAsyncArrow(){return this.match(14)||super.shouldParseAsyncArrow()}parseMaybeAssign(e,i){let a=null,n;if(this.hasPlugin("jsx")&&(this.match(143)||this.match(47))){if(a=this.state.clone(),n=this.tryParse(()=>super.parseMaybeAssign(e,i),a),!n.error)return n.node;const{context:o}=this.state,c=o[o.length-1];(c===R.j_oTag||c===R.j_expr)&&o.pop()}if(n!=null&&n.error||this.match(47)){a=a||this.state.clone();let o;const c=this.tryParse(l=>{var d;o=this.flowParseTypeParameterDeclaration();const u=this.forwardNoArrowParamsConversionAt(o,()=>{const P=super.parseMaybeAssign(e,i);return this.resetStartLocationFromNode(P,o),P});(d=u.extra)!=null&&d.parenthesized&&l();const f=this.maybeUnwrapTypeCastExpression(u);return f.type!=="ArrowFunctionExpression"&&l(),f.typeParameters=o,this.resetStartLocationFromNode(f,o),u},a);let h=null;if(c.node&&this.maybeUnwrapTypeCastExpression(c.node).type==="ArrowFunctionExpression"){if(!c.error&&!c.aborted)return c.node.async&&this.raise(A.UnexpectedTypeParameterBeforeAsyncArrowFunction,o),c.node;h=c.node}if(n!=null&&n.node)return this.state=n.failState,n.node;if(h)return this.state=c.failState,h;throw n!=null&&n.thrown?n.error:c.thrown?c.error:this.raise(A.UnexpectedTokenAfterTypeParameter,o)}return super.parseMaybeAssign(e,i)}parseArrow(e){if(this.match(14)){const i=this.tryParse(()=>{const a=this.state.noAnonFunctionType;this.state.noAnonFunctionType=!0;const n=this.startNode();return[n.typeAnnotation,e.predicate]=this.flowParseTypeAndPredicateInitialiser(),this.state.noAnonFunctionType=a,this.canInsertSemicolon()&&this.unexpected(),this.match(19)||this.unexpected(),n});if(i.thrown)return null;i.error&&(this.state=i.failState),e.returnType=i.node.typeAnnotation?this.finishNode(i.node,"TypeAnnotation"):null}return super.parseArrow(e)}shouldParseArrow(e){return this.match(14)||super.shouldParseArrow(e)}setArrowFunctionParameters(e,i){this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start))?e.params=i:super.setArrowFunctionParameters(e,i)}checkParams(e,i,a,n=!0){if(!(a&&this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(e.start)))){for(let o=0;o<e.params.length;o++)this.isThisParam(e.params[o])&&o>0&&this.raise(A.ThisParamMustBeFirst,e.params[o]);super.checkParams(e,i,a,n)}}parseParenAndDistinguishExpression(e){return super.parseParenAndDistinguishExpression(e&&!this.state.noArrowAt.includes(this.sourceToOffsetPos(this.state.start)))}parseSubscripts(e,i,a){if(e.type==="Identifier"&&e.name==="async"&&this.state.noArrowAt.includes(i.index)){this.next();const n=this.startNodeAt(i);n.callee=e,n.arguments=super.parseCallExpressionArguments(11),e=this.finishNode(n,"CallExpression")}else if(e.type==="Identifier"&&e.name==="async"&&this.match(47)){const n=this.state.clone(),o=this.tryParse(h=>this.parseAsyncArrowWithTypeParameters(i)||h(),n);if(!o.error&&!o.aborted)return o.node;const c=this.tryParse(()=>super.parseSubscripts(e,i,a),n);if(c.node&&!c.error)return c.node;if(o.node)return this.state=o.failState,o.node;if(c.node)return this.state=c.failState,c.node;throw o.error||c.error}return super.parseSubscripts(e,i,a)}parseSubscript(e,i,a,n){if(this.match(18)&&this.isLookaheadToken_lt()){if(n.optionalChainMember=!0,a)return n.stop=!0,e;this.next();const o=this.startNodeAt(i);return o.callee=e,o.typeArguments=this.flowParseTypeParameterInstantiationInExpression(),this.expect(10),o.arguments=this.parseCallExpressionArguments(11),o.optional=!0,this.finishCallExpression(o,!0)}else if(!a&&this.shouldParseTypes()&&(this.match(47)||this.match(51))){const o=this.startNodeAt(i);o.callee=e;const c=this.tryParse(()=>(o.typeArguments=this.flowParseTypeParameterInstantiationCallOrNew(),this.expect(10),o.arguments=super.parseCallExpressionArguments(11),n.optionalChainMember&&(o.optional=!1),this.finishCallExpression(o,n.optionalChainMember)));if(c.node)return c.error&&(this.state=c.failState),c.node}return super.parseSubscript(e,i,a,n)}parseNewCallee(e){super.parseNewCallee(e);let i=null;this.shouldParseTypes()&&this.match(47)&&(i=this.tryParse(()=>this.flowParseTypeParameterInstantiationCallOrNew()).node),e.typeArguments=i}parseAsyncArrowWithTypeParameters(e){const i=this.startNodeAt(e);if(this.parseFunctionParams(i,!1),!!this.parseArrow(i))return super.parseArrowExpression(i,void 0,!0)}readToken_mult_modulo(e){const i=this.input.charCodeAt(this.state.pos+1);if(e===42&&i===47&&this.state.hasFlowComment){this.state.hasFlowComment=!1,this.state.pos+=2,this.nextToken();return}super.readToken_mult_modulo(e)}readToken_pipe_amp(e){const i=this.input.charCodeAt(this.state.pos+1);if(e===124&&i===125){this.finishOp(9,2);return}super.readToken_pipe_amp(e)}parseTopLevel(e,i){const a=super.parseTopLevel(e,i);return this.state.hasFlowComment&&this.raise(A.UnterminatedFlowComment,this.state.curPosition()),a}skipBlockComment(){if(this.hasPlugin("flowComments")&&this.skipFlowComment()){if(this.state.hasFlowComment)throw this.raise(A.NestedFlowComment,this.state.startLoc);this.hasFlowCommentCompletion();const e=this.skipFlowComment();e&&(this.state.pos+=e,this.state.hasFlowComment=!0);return}return super.skipBlockComment(this.state.hasFlowComment?"*-/":"*/")}skipFlowComment(){const{pos:e}=this.state;let i=2;for(;[32,9].includes(this.input.charCodeAt(e+i));)i++;const a=this.input.charCodeAt(i+e),n=this.input.charCodeAt(i+e+1);return a===58&&n===58?i+2:this.input.slice(i+e,i+e+12)==="flow-include"?i+12:a===58&&n!==58?i:!1}hasFlowCommentCompletion(){if(this.input.indexOf("*/",this.state.pos)===-1)throw this.raise(p.UnterminatedComment,this.state.curPosition())}flowEnumErrorBooleanMemberNotInitialized(e,{enumName:i,memberName:a}){this.raise(A.EnumBooleanMemberNotInitialized,e,{memberName:a,enumName:i})}flowEnumErrorInvalidMemberInitializer(e,i){return this.raise(i.explicitType?i.explicitType==="symbol"?A.EnumInvalidMemberInitializerSymbolType:A.EnumInvalidMemberInitializerPrimaryType:A.EnumInvalidMemberInitializerUnknownType,e,i)}flowEnumErrorNumberMemberNotInitialized(e,i){this.raise(A.EnumNumberMemberNotInitialized,e,i)}flowEnumErrorStringMemberInconsistentlyInitialized(e,i){this.raise(A.EnumStringMemberInconsistentlyInitialized,e,i)}flowEnumMemberInit(){const e=this.state.startLoc,i=()=>this.match(12)||this.match(8);switch(this.state.type){case 135:{const a=this.parseNumericLiteral(this.state.value);return i()?{type:"number",loc:a.loc.start,value:a}:{type:"invalid",loc:e}}case 134:{const a=this.parseStringLiteral(this.state.value);return i()?{type:"string",loc:a.loc.start,value:a}:{type:"invalid",loc:e}}case 85:case 86:{const a=this.parseBooleanLiteral(this.match(85));return i()?{type:"boolean",loc:a.loc.start,value:a}:{type:"invalid",loc:e}}default:return{type:"invalid",loc:e}}}flowEnumMemberRaw(){const e=this.state.startLoc,i=this.parseIdentifier(!0),a=this.eat(29)?this.flowEnumMemberInit():{type:"none",loc:e};return{id:i,init:a}}flowEnumCheckExplicitTypeMismatch(e,i,a){const{explicitType:n}=i;n!==null&&n!==a&&this.flowEnumErrorInvalidMemberInitializer(e,i)}flowEnumMembers({enumName:e,explicitType:i}){const a=new Set,n={booleanMembers:[],numberMembers:[],stringMembers:[],defaultedMembers:[]};let o=!1;for(;!this.match(8);){if(this.eat(21)){o=!0;break}const c=this.startNode(),{id:h,init:l}=this.flowEnumMemberRaw(),u=h.name;if(u==="")continue;/^[a-z]/.test(u)&&this.raise(A.EnumInvalidMemberName,h,{memberName:u,suggestion:u[0].toUpperCase()+u.slice(1),enumName:e}),a.has(u)&&this.raise(A.EnumDuplicateMemberName,h,{memberName:u,enumName:e}),a.add(u);const f={enumName:e,explicitType:i,memberName:u};switch(c.id=h,l.type){case"boolean":{this.flowEnumCheckExplicitTypeMismatch(l.loc,f,"boolean"),c.init=l.value,n.booleanMembers.push(this.finishNode(c,"EnumBooleanMember"));break}case"number":{this.flowEnumCheckExplicitTypeMismatch(l.loc,f,"number"),c.init=l.value,n.numberMembers.push(this.finishNode(c,"EnumNumberMember"));break}case"string":{this.flowEnumCheckExplicitTypeMismatch(l.loc,f,"string"),c.init=l.value,n.stringMembers.push(this.finishNode(c,"EnumStringMember"));break}case"invalid":throw this.flowEnumErrorInvalidMemberInitializer(l.loc,f);case"none":switch(i){case"boolean":this.flowEnumErrorBooleanMemberNotInitialized(l.loc,f);break;case"number":this.flowEnumErrorNumberMemberNotInitialized(l.loc,f);break;default:n.defaultedMembers.push(this.finishNode(c,"EnumDefaultedMember"))}}this.match(8)||this.expect(12)}return{members:n,hasUnknownMembers:o}}flowEnumStringMembers(e,i,{enumName:a}){if(e.length===0)return i;if(i.length===0)return e;if(i.length>e.length){for(const n of e)this.flowEnumErrorStringMemberInconsistentlyInitialized(n,{enumName:a});return i}else{for(const n of i)this.flowEnumErrorStringMemberInconsistentlyInitialized(n,{enumName:a});return e}}flowEnumParseExplicitType({enumName:e}){if(!this.eatContextual(102))return null;if(!D(this.state.type))throw this.raise(A.EnumInvalidExplicitTypeUnknownSupplied,this.state.startLoc,{enumName:e});const{value:i}=this.state;return this.next(),i!=="boolean"&&i!=="number"&&i!=="string"&&i!=="symbol"&&this.raise(A.EnumInvalidExplicitType,this.state.startLoc,{enumName:e,invalidEnumType:i}),i}flowEnumBody(e,i){const a=i.name,n=i.loc.start,o=this.flowEnumParseExplicitType({enumName:a});this.expect(5);const{members:c,hasUnknownMembers:h}=this.flowEnumMembers({enumName:a,explicitType:o});switch(e.hasUnknownMembers=h,o){case"boolean":return e.explicitType=!0,e.members=c.booleanMembers,this.expect(8),this.finishNode(e,"EnumBooleanBody");case"number":return e.explicitType=!0,e.members=c.numberMembers,this.expect(8),this.finishNode(e,"EnumNumberBody");case"string":return e.explicitType=!0,e.members=this.flowEnumStringMembers(c.stringMembers,c.defaultedMembers,{enumName:a}),this.expect(8),this.finishNode(e,"EnumStringBody");case"symbol":return e.members=c.defaultedMembers,this.expect(8),this.finishNode(e,"EnumSymbolBody");default:{const l=()=>(e.members=[],this.expect(8),this.finishNode(e,"EnumStringBody"));e.explicitType=!1;const u=c.booleanMembers.length,f=c.numberMembers.length,d=c.stringMembers.length,P=c.defaultedMembers.length;if(!u&&!f&&!d&&!P)return l();if(!u&&!f)return e.members=this.flowEnumStringMembers(c.stringMembers,c.defaultedMembers,{enumName:a}),this.expect(8),this.finishNode(e,"EnumStringBody");if(!f&&!d&&u>=P){for(const S of c.defaultedMembers)this.flowEnumErrorBooleanMemberNotInitialized(S.loc.start,{enumName:a,memberName:S.id.name});return e.members=c.booleanMembers,this.expect(8),this.finishNode(e,"EnumBooleanBody")}else if(!u&&!d&&f>=P){for(const S of c.defaultedMembers)this.flowEnumErrorNumberMemberNotInitialized(S.loc.start,{enumName:a,memberName:S.id.name});return e.members=c.numberMembers,this.expect(8),this.finishNode(e,"EnumNumberBody")}else return this.raise(A.EnumInconsistentMemberValues,n,{enumName:a}),l()}}}flowParseEnumDeclaration(e){const i=this.parseIdentifier();return e.id=i,e.body=this.flowEnumBody(this.startNode(),i),this.finishNode(e,"EnumDeclaration")}jsxParseOpeningElementAfterName(e){return this.shouldParseTypes()&&(this.match(47)||this.match(51))&&(e.typeArguments=this.flowParseTypeParameterInstantiationInExpression()),super.jsxParseOpeningElementAfterName(e)}isLookaheadToken_lt(){const e=this.nextTokenStart();if(this.input.charCodeAt(e)===60){const i=this.input.charCodeAt(e+1);return i!==60&&i!==61}return!1}reScan_lt_gt(){const{type:e}=this.state;e===47?(this.state.pos-=1,this.readToken_lt()):e===48&&(this.state.pos-=1,this.readToken_gt())}reScan_lt(){const{type:e}=this.state;return e===51?(this.state.pos-=2,this.finishOp(47,1),47):e}maybeUnwrapTypeCastExpression(e){return e.type==="TypeCastExpression"?e.expression:e}};const Ya={__proto__:null,quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"},Za=/\r\n|[\r\n\u2028\u2029]/,Nt=new RegExp(Za.source,"g");function qe(r){switch(r){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function li(r,t,s){for(let e=t;e<s;e++)if(qe(r.charCodeAt(e)))return!0;return!1}const Ps=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,bs=/(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;function Qa(r){switch(r){case 9:case 11:case 12:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:case 65279:return!0;default:return!1}}const we=Pe`jsx`({AttributeIsEmpty:"JSX attributes must only be assigned a non-empty expression.",MissingClosingTagElement:({openingTagName:r})=>`Expected corresponding JSX closing tag for <${r}>.`,MissingClosingTagFragment:"Expected corresponding JSX closing tag for <>.",UnexpectedSequenceExpression:"Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",UnexpectedToken:({unexpected:r,HTMLEntity:t})=>`Unexpected token \`${r}\`. Did you mean \`${t}\` or \`{'${r}'}\`?`,UnsupportedJsxValue:"JSX value should be either an expression or a quoted JSX text.",UnterminatedJsxContent:"Unterminated JSX contents.",UnwrappedAdjacentJSXElements:"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?"});function ve(r){return r?r.type==="JSXOpeningFragment"||r.type==="JSXClosingFragment":!1}function ze(r){if(r.type==="JSXIdentifier")return r.name;if(r.type==="JSXNamespacedName")return r.namespace.name+":"+r.name.name;if(r.type==="JSXMemberExpression")return ze(r.object)+"."+ze(r.property);throw new Error("Node had unexpected type: "+r.type)}var en=r=>class extends r{jsxReadToken(){let s="",e=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(we.UnterminatedJsxContent,this.state.startLoc);const i=this.input.charCodeAt(this.state.pos);switch(i){case 60:case 123:if(this.state.pos===this.state.start){i===60&&this.state.canStartJSXElement?(++this.state.pos,this.finishToken(143)):super.getTokenFromCode(i);return}s+=this.input.slice(e,this.state.pos),this.finishToken(142,s);return;case 38:s+=this.input.slice(e,this.state.pos),s+=this.jsxReadEntity(),e=this.state.pos;break;case 62:case 125:this.raise(we.UnexpectedToken,this.state.curPosition(),{unexpected:this.input[this.state.pos],HTMLEntity:i===125?"&rbrace;":"&gt;"});default:qe(i)?(s+=this.input.slice(e,this.state.pos),s+=this.jsxReadNewLine(!0),e=this.state.pos):++this.state.pos}}}jsxReadNewLine(s){const e=this.input.charCodeAt(this.state.pos);let i;return++this.state.pos,e===13&&this.input.charCodeAt(this.state.pos)===10?(++this.state.pos,i=s?`
4
4
  `:`\r
5
- `):i=String.fromCharCode(e),++this.state.curLine,this.state.lineStart=this.state.pos,i}jsxReadString(s){let e="",i=++this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(p.UnterminatedString,this.state.startLoc);const a=this.input.charCodeAt(this.state.pos);if(a===s)break;a===38?(e+=this.input.slice(i,this.state.pos),e+=this.jsxReadEntity(),i=this.state.pos):qe(a)?(e+=this.input.slice(i,this.state.pos),e+=this.jsxReadNewLine(!1),i=this.state.pos):++this.state.pos}e+=this.input.slice(i,this.state.pos++),this.finishToken(134,e)}jsxReadEntity(){const s=++this.state.pos;if(this.codePointAtPos(this.state.pos)===35){++this.state.pos;let e=10;this.codePointAtPos(this.state.pos)===120&&(e=16,++this.state.pos);const i=this.readInt(e,void 0,!1,"bail");if(i!==null&&this.codePointAtPos(this.state.pos)===59)return++this.state.pos,String.fromCodePoint(i)}else{let e=0,i=!1;for(;e++<10&&this.state.pos<this.length&&!(i=this.codePointAtPos(this.state.pos)===59);)++this.state.pos;if(i){const a=this.input.slice(s,this.state.pos),n=Va[a];if(++this.state.pos,n)return n}}return this.state.pos=s,"&"}jsxReadWord(){let s;const e=this.state.pos;do s=this.input.charCodeAt(++this.state.pos);while($e(s)||s===45);this.finishToken(141,this.input.slice(e,this.state.pos))}jsxParseIdentifier(){const s=this.startNode();return this.match(141)?s.name=this.state.value:hs(this.state.type)?s.name=Ce(this.state.type):this.unexpected(),this.next(),this.finishNode(s,"JSXIdentifier")}jsxParseNamespacedName(){const s=this.state.startLoc,e=this.jsxParseIdentifier();if(!this.eat(14))return e;const i=this.startNodeAt(s);return i.namespace=e,i.name=this.jsxParseIdentifier(),this.finishNode(i,"JSXNamespacedName")}jsxParseElementName(){const s=this.state.startLoc;let e=this.jsxParseNamespacedName();if(e.type==="JSXNamespacedName")return e;for(;this.eat(16);){const i=this.startNodeAt(s);i.object=e,i.property=this.jsxParseIdentifier(),e=this.finishNode(i,"JSXMemberExpression")}return e}jsxParseAttributeValue(){let s;switch(this.state.type){case 5:return s=this.startNode(),this.setContext(R.brace),this.next(),s=this.jsxParseExpressionContainer(s,R.j_oTag),s.expression.type==="JSXEmptyExpression"&&this.raise(we.AttributeIsEmpty,s),s;case 143:case 134:return this.parseExprAtom();default:throw this.raise(we.UnsupportedJsxValue,this.state.startLoc)}}jsxParseEmptyExpression(){const s=this.startNodeAt(this.state.lastTokEndLoc);return this.finishNodeAt(s,"JSXEmptyExpression",this.state.startLoc)}jsxParseSpreadChild(s){return this.next(),s.expression=this.parseExpression(),this.setContext(R.j_expr),this.state.canStartJSXElement=!0,this.expect(8),this.finishNode(s,"JSXSpreadChild")}jsxParseExpressionContainer(s,e){var i;if(this.match(8))s.expression=this.jsxParseEmptyExpression();else{const a=this.parseExpression();a.type==="SequenceExpression"&&!((i=a.extra)!=null&&i.parenthesized)&&this.raise(we.UnexpectedSequenceExpression,a.expressions[1]),s.expression=a}return this.setContext(e),this.state.canStartJSXElement=!0,this.expect(8),this.finishNode(s,"JSXExpressionContainer")}jsxParseAttribute(){const s=this.startNode();return this.match(5)?(this.setContext(R.brace),this.next(),this.expect(21),s.argument=this.parseMaybeAssignAllowIn(),this.setContext(R.j_oTag),this.state.canStartJSXElement=!0,this.expect(8),this.finishNode(s,"JSXSpreadAttribute")):(s.name=this.jsxParseNamespacedName(),s.value=this.eat(29)?this.jsxParseAttributeValue():null,this.finishNode(s,"JSXAttribute"))}jsxParseOpeningElementAt(s){const e=this.startNodeAt(s);return this.eat(144)?this.finishNode(e,"JSXOpeningFragment"):(e.name=this.jsxParseElementName(),this.jsxParseOpeningElementAfterName(e))}jsxParseOpeningElementAfterName(s){const e=[];for(;!this.match(56)&&!this.match(144);)e.push(this.jsxParseAttribute());return s.attributes=e,s.selfClosing=this.eat(56),this.expect(144),this.finishNode(s,"JSXOpeningElement")}jsxParseClosingElementAt(s){const e=this.startNodeAt(s);return this.eat(144)?this.finishNode(e,"JSXClosingFragment"):(e.name=this.jsxParseElementName(),this.expect(144),this.finishNode(e,"JSXClosingElement"))}jsxParseElementAt(s){const e=this.startNodeAt(s),i=[],a=this.jsxParseOpeningElementAt(s);let n=null;if(!a.selfClosing){e:for(;;)switch(this.state.type){case 143:if(s=this.state.startLoc,this.next(),this.eat(56)){n=this.jsxParseClosingElementAt(s);break e}i.push(this.jsxParseElementAt(s));break;case 142:i.push(this.parseLiteral(this.state.value,"JSXText"));break;case 5:{const o=this.startNode();this.setContext(R.brace),this.next(),this.match(21)?i.push(this.jsxParseSpreadChild(o)):i.push(this.jsxParseExpressionContainer(o,R.j_expr));break}default:this.unexpected()}ke(a)&&!ke(n)&&n!==null?this.raise(we.MissingClosingTagFragment,n):!ke(a)&&ke(n)?this.raise(we.MissingClosingTagElement,n,{openingTagName:ze(a.name)}):!ke(a)&&!ke(n)&&ze(n.name)!==ze(a.name)&&this.raise(we.MissingClosingTagElement,n,{openingTagName:ze(a.name)})}if(ke(a)?(e.openingFragment=a,e.closingFragment=n):(e.openingElement=a,e.closingElement=n),e.children=i,this.match(47))throw this.raise(we.UnwrappedAdjacentJSXElements,this.state.startLoc);return ke(a)?this.finishNode(e,"JSXFragment"):this.finishNode(e,"JSXElement")}jsxParseElement(){const s=this.state.startLoc;return this.next(),this.jsxParseElementAt(s)}setContext(s){const{context:e}=this.state;e[e.length-1]=s}parseExprAtom(s){return this.match(143)?this.jsxParseElement():this.match(47)&&this.input.charCodeAt(this.state.pos)!==33?(this.replaceToken(143),this.jsxParseElement()):super.parseExprAtom(s)}skipSpace(){this.curContext().preserveSpace||super.skipSpace()}getTokenFromCode(s){const e=this.curContext();if(e===R.j_expr){this.jsxReadToken();return}if(e===R.j_oTag||e===R.j_cTag){if(ge(s)){this.jsxReadWord();return}if(s===62){++this.state.pos,this.finishToken(144);return}if((s===34||s===39)&&e===R.j_oTag){this.jsxReadString(s);return}}if(s===60&&this.state.canStartJSXElement&&this.input.charCodeAt(this.state.pos+1)!==33){++this.state.pos,this.finishToken(143);return}super.getTokenFromCode(s)}updateContext(s){const{context:e,type:i}=this.state;if(i===56&&s===143)e.splice(-2,2,R.j_cTag),this.state.canStartJSXElement=!1;else if(i===143)e.push(R.j_oTag);else if(i===144){const a=e[e.length-1];a===R.j_oTag&&s===56||a===R.j_cTag?(e.pop(),this.state.canStartJSXElement=e[e.length-1]===R.j_expr):(this.setContext(R.j_expr),this.state.canStartJSXElement=!0)}else this.state.canStartJSXElement=xa(i)}};class Wa extends ds{constructor(){super(...arguments);m(this,"tsNames",new Map)}}class Ga extends ms{constructor(){super(...arguments);m(this,"importsStack",[])}createScope(s){return this.importsStack.push(new Set),new Wa(s)}enter(s){s===512&&this.importsStack.push(new Set),super.enter(s)}exit(){const s=super.exit();return s===512&&this.importsStack.pop(),s}hasImport(s,e){const i=this.importsStack.length;if(this.importsStack[i-1].has(s))return!0;if(!e&&i>1){for(let a=0;a<i-1;a++)if(this.importsStack[a].has(s))return!0}return!1}declareName(s,e,i){if(e&4096){this.hasImport(s,!0)&&this.parser.raise(p.VarRedeclaration,i,{identifierName:s}),this.importsStack[this.importsStack.length-1].add(s);return}const a=this.currentScope();let n=a.tsNames.get(s)||0;if(e&1024){this.maybeExportDefined(a,s),a.tsNames.set(s,n|16);return}super.declareName(s,e,i),e&2&&(e&1||(this.checkRedeclarationInScope(a,s,e,i),this.maybeExportDefined(a,s)),n=n|1),e&256&&(n=n|2),e&512&&(n=n|4),e&128&&(n=n|8),n&&a.tsNames.set(s,n)}isRedeclaredInScope(s,e,i){const a=s.tsNames.get(e);if((a&2)>0){if(i&256){const n=!!(i&512),o=(a&4)>0;return n!==o}return!0}return i&128&&(a&8)>0?s.names.get(e)&2?!!(i&1):!1:i&2&&(a&1)>0?!0:super.isRedeclaredInScope(s,e,i)}checkLocalExport(s){const{name:e}=s;if(this.hasImport(e))return;const i=this.scopeStack.length;for(let a=i-1;a>=0;a--){const o=this.scopeStack[a].tsNames.get(e);if((o&1)>0||(o&16)>0)return}super.checkLocalExport(s)}}class Xa{constructor(){m(this,"stacks",[])}enter(t){this.stacks.push(t)}exit(){this.stacks.pop()}currentFlags(){return this.stacks[this.stacks.length-1]}get hasAwait(){return(this.currentFlags()&2)>0}get hasYield(){return(this.currentFlags()&1)>0}get hasReturn(){return(this.currentFlags()&4)>0}get hasIn(){return(this.currentFlags()&8)>0}}function vt(r,t){return(r?2:0)|(t?1:0)}class Ya{constructor(){m(this,"sawUnambiguousESM",!1);m(this,"ambiguousScriptDifferentAst",!1)}sourceToOffsetPos(t){return t+this.startIndex}offsetToSourcePos(t){return t-this.startIndex}hasPlugin(t){if(typeof t=="string")return this.plugins.has(t);{const[s,e]=t;if(!this.hasPlugin(s))return!1;const i=this.plugins.get(s);for(const a of Object.keys(e))if((i==null?void 0:i[a])!==e[a])return!1;return!0}}getPluginOption(t,s){var e;return(e=this.plugins.get(t))==null?void 0:e[s]}}function li(r,t){r.trailingComments===void 0?r.trailingComments=t:r.trailingComments.unshift(...t)}function Za(r,t){r.leadingComments===void 0?r.leadingComments=t:r.leadingComments.unshift(...t)}function Ve(r,t){r.innerComments===void 0?r.innerComments=t:r.innerComments.unshift(...t)}function Be(r,t,s){let e=null,i=t.length;for(;e===null&&i>0;)e=t[--i];e===null||e.start>s.start?Ve(r,s.comments):li(e,s.comments)}class Qa extends Ya{addComment(t){this.filename&&(t.loc.filename=this.filename);const{commentsLen:s}=this.state;this.comments.length!==s&&(this.comments.length=s),this.comments.push(t),this.state.commentsLen++}processComment(t){const{commentStack:s}=this.state,e=s.length;if(e===0)return;let i=e-1;const a=s[i];a.start===t.end&&(a.leadingNode=t,i--);const{start:n}=t;for(;i>=0;i--){const o=s[i],c=o.end;if(c>n)o.containingNode=t,this.finalizeComment(o),s.splice(i,1);else{c===n&&(o.trailingNode=t);break}}}finalizeComment(t){const{comments:s}=t;if(t.leadingNode!==null||t.trailingNode!==null)t.leadingNode!==null&&li(t.leadingNode,s),t.trailingNode!==null&&Za(t.trailingNode,s);else{const{containingNode:e,start:i}=t;if(this.input.charCodeAt(this.offsetToSourcePos(i)-1)===44)switch(e.type){case"ObjectExpression":case"ObjectPattern":case"RecordExpression":Be(e,e.properties,t);break;case"CallExpression":case"OptionalCallExpression":Be(e,e.arguments,t);break;case"ImportExpression":Be(e,[e.source,e.options??null],t);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":Be(e,e.params,t);break;case"ArrayExpression":case"ArrayPattern":case"TupleExpression":Be(e,e.elements,t);break;case"ExportNamedDeclaration":case"ImportDeclaration":Be(e,e.specifiers,t);break;case"TSEnumDeclaration":Ve(e,s);break;case"TSEnumBody":Be(e,e.members,t);break;default:Ve(e,s)}else Ve(e,s)}}finalizeRemainingComments(){const{commentStack:t}=this.state;for(let s=t.length-1;s>=0;s--)this.finalizeComment(t[s]);this.state.commentStack=[]}resetPreviousNodeTrailingComments(t){const{commentStack:s}=this.state,{length:e}=s;if(e===0)return;const i=s[e-1];i.leadingNode===t&&(i.leadingNode=null)}takeSurroundingComments(t,s,e){const{commentStack:i}=this.state,a=i.length;if(a===0)return;let n=a-1;for(;n>=0;n--){const o=i[n],c=o.end;if(o.start===e)o.leadingNode=t;else if(c===s)o.trailingNode=t;else if(c<s)break}}}class Ps{constructor(){m(this,"flags",1024);m(this,"startIndex");m(this,"curLine");m(this,"lineStart");m(this,"startLoc");m(this,"endLoc");m(this,"errors",[]);m(this,"potentialArrowAt",-1);m(this,"noArrowAt",[]);m(this,"noArrowParamsConversionAt",[]);m(this,"topicContext",{maxNumOfResolvableTopics:0,maxTopicIndex:null});m(this,"labels",[]);m(this,"commentsLen",0);m(this,"commentStack",[]);m(this,"pos",0);m(this,"type",140);m(this,"value",null);m(this,"start",0);m(this,"end",0);m(this,"lastTokEndLoc",null);m(this,"lastTokStartLoc",null);m(this,"context",[R.brace]);m(this,"firstInvalidTemplateEscapePos",null);m(this,"strictErrors",new Map);m(this,"tokensLength",0)}get strict(){return(this.flags&1)>0}set strict(t){t?this.flags|=1:this.flags&=-2}init({strictMode:t,sourceType:s,startIndex:e,startLine:i,startColumn:a}){this.strict=t===!1?!1:t===!0?!0:s==="module",this.startIndex=e,this.curLine=i,this.lineStart=-a,this.startLoc=this.endLoc=new Ie(i,a,e)}get maybeInArrowParameters(){return(this.flags&2)>0}set maybeInArrowParameters(t){t?this.flags|=2:this.flags&=-3}get inType(){return(this.flags&4)>0}set inType(t){t?this.flags|=4:this.flags&=-5}get noAnonFunctionType(){return(this.flags&8)>0}set noAnonFunctionType(t){t?this.flags|=8:this.flags&=-9}get hasFlowComment(){return(this.flags&16)>0}set hasFlowComment(t){t?this.flags|=16:this.flags&=-17}get isAmbientContext(){return(this.flags&32)>0}set isAmbientContext(t){t?this.flags|=32:this.flags&=-33}get inAbstractClass(){return(this.flags&64)>0}set inAbstractClass(t){t?this.flags|=64:this.flags&=-65}get inDisallowConditionalTypesContext(){return(this.flags&128)>0}set inDisallowConditionalTypesContext(t){t?this.flags|=128:this.flags&=-129}get soloAwait(){return(this.flags&256)>0}set soloAwait(t){t?this.flags|=256:this.flags&=-257}get inFSharpPipelineDirectBody(){return(this.flags&512)>0}set inFSharpPipelineDirectBody(t){t?this.flags|=512:this.flags&=-513}get canStartJSXElement(){return(this.flags&1024)>0}set canStartJSXElement(t){t?this.flags|=1024:this.flags&=-1025}get containsEsc(){return(this.flags&2048)>0}set containsEsc(t){t?this.flags|=2048:this.flags&=-2049}get hasTopLevelAwait(){return(this.flags&4096)>0}set hasTopLevelAwait(t){t?this.flags|=4096:this.flags&=-4097}curPosition(){return new Ie(this.curLine,this.pos-this.lineStart,this.pos+this.startIndex)}clone(){const t=new Ps;return t.flags=this.flags,t.startIndex=this.startIndex,t.curLine=this.curLine,t.lineStart=this.lineStart,t.startLoc=this.startLoc,t.endLoc=this.endLoc,t.errors=this.errors.slice(),t.potentialArrowAt=this.potentialArrowAt,t.noArrowAt=this.noArrowAt.slice(),t.noArrowParamsConversionAt=this.noArrowParamsConversionAt.slice(),t.topicContext=this.topicContext,t.labels=this.labels.slice(),t.commentsLen=this.commentsLen,t.commentStack=this.commentStack.slice(),t.pos=this.pos,t.type=this.type,t.value=this.value,t.start=this.start,t.end=this.end,t.lastTokEndLoc=this.lastTokEndLoc,t.lastTokStartLoc=this.lastTokStartLoc,t.context=this.context.slice(),t.firstInvalidTemplateEscapePos=this.firstInvalidTemplateEscapePos,t.strictErrors=this.strictErrors,t.tokensLength=this.tokensLength,t}}var en=function(t){return t>=48&&t<=57};const ui={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},Ot={bin:r=>r===48||r===49,oct:r=>r>=48&&r<=55,dec:r=>r>=48&&r<=57,hex:r=>r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102};function pi(r,t,s,e,i,a){const n=s,o=e,c=i;let h="",l=null,u=s;const{length:f}=t;for(;;){if(s>=f){a.unterminated(n,o,c),h+=t.slice(u,s);break}const d=t.charCodeAt(s);if(tn(r,d,t,s)){h+=t.slice(u,s);break}if(d===92){h+=t.slice(u,s);const P=sn(t,s,e,i,r==="template",a);P.ch===null&&!l?l={pos:s,lineStart:e,curLine:i}:h+=P.ch,{pos:s,lineStart:e,curLine:i}=P,u=s}else d===8232||d===8233?(++s,++i,e=s):d===10||d===13?r==="template"?(h+=t.slice(u,s)+`
6
- `,++s,d===13&&t.charCodeAt(s)===10&&++s,++i,u=e=s):a.unterminated(n,o,c):++s}return{pos:s,str:h,firstInvalidLoc:l,lineStart:e,curLine:i}}function tn(r,t,s,e){return r==="template"?t===96||t===36&&s.charCodeAt(e+1)===123:t===(r==="double"?34:39)}function sn(r,t,s,e,i,a){const n=!i;t++;const o=h=>({pos:t,ch:h,lineStart:s,curLine:e}),c=r.charCodeAt(t++);switch(c){case 110:return o(`
7
- `);case 114:return o("\r");case 120:{let h;return{code:h,pos:t}=bs(r,t,s,e,2,!1,n,a),o(h===null?null:String.fromCharCode(h))}case 117:{let h;return{code:h,pos:t}=di(r,t,s,e,n,a),o(h===null?null:String.fromCodePoint(h))}case 116:return o(" ");case 98:return o("\b");case 118:return o("\v");case 102:return o("\f");case 13:r.charCodeAt(t)===10&&++t;case 10:s=t,++e;case 8232:case 8233:return o("");case 56:case 57:if(i)return o(null);a.strictNumericEscape(t-1,s,e);default:if(c>=48&&c<=55){const h=t-1;let u=/^[0-7]+/.exec(r.slice(h,t+2))[0],f=parseInt(u,8);f>255&&(u=u.slice(0,-1),f=parseInt(u,8)),t+=u.length-1;const d=r.charCodeAt(t);if(u!=="0"||d===56||d===57){if(i)return o(null);a.strictNumericEscape(h,s,e)}return o(String.fromCharCode(f))}return o(String.fromCharCode(c))}}function bs(r,t,s,e,i,a,n,o){const c=t;let h;return{n:h,pos:t}=fi(r,t,s,e,16,i,a,!1,o,!n),h===null&&(n?o.invalidEscapeSequence(c,s,e):t=c-1),{code:h,pos:t}}function fi(r,t,s,e,i,a,n,o,c,h){const l=t,u=i===16?ui.hex:ui.decBinOct,f=i===16?Ot.hex:i===10?Ot.dec:i===8?Ot.oct:Ot.bin;let d=!1,P=0;for(let S=0,B=a??1/0;S<B;++S){const I=r.charCodeAt(t);let D;if(I===95&&o!=="bail"){const z=r.charCodeAt(t-1),oe=r.charCodeAt(t+1);if(o){if(Number.isNaN(oe)||!f(oe)||u.has(z)||u.has(oe)){if(h)return{n:null,pos:t};c.unexpectedNumericSeparator(t,s,e)}}else{if(h)return{n:null,pos:t};c.numericSeparatorInEscapeSequence(t,s,e)}++t;continue}if(I>=97?D=I-97+10:I>=65?D=I-65+10:en(I)?D=I-48:D=1/0,D>=i){if(D<=9&&h)return{n:null,pos:t};if(D<=9&&c.invalidDigit(t,s,e,i))D=0;else if(n)D=0,d=!0;else break}++t,P=P*i+D}return t===l||a!=null&&t-l!==a||d?{n:null,pos:t}:{n:P,pos:t}}function di(r,t,s,e,i,a){const n=r.charCodeAt(t);let o;if(n===123){if(++t,{code:o,pos:t}=bs(r,t,s,e,r.indexOf("}",t)-t,!0,i,a),++t,o!==null&&o>1114111)if(i)a.invalidCodePoint(t,s,e);else return{code:null,pos:t}}else({code:o,pos:t}=bs(r,t,s,e,4,!1,i,a));return{code:o,pos:t}}function lt(r,t,s){return new Ie(s,r-t,r)}const rn=new Set([103,109,115,105,121,117,100,118]);class an{constructor(t){const s=t.startIndex||0;this.type=t.type,this.value=t.value,this.start=s+t.start,this.end=s+t.end,this.loc=new It(t.startLoc,t.endLoc)}}class nn extends Qa{constructor(s,e){super();m(this,"isLookahead");m(this,"tokens",[]);m(this,"errorHandlers_readInt",{invalidDigit:(s,e,i,a)=>this.optionFlags&2048?(this.raise(p.InvalidDigit,lt(s,e,i),{radix:a}),!0):!1,numericSeparatorInEscapeSequence:this.errorBuilder(p.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(p.UnexpectedNumericSeparator)});m(this,"errorHandlers_readCodePoint",Object.assign({},this.errorHandlers_readInt,{invalidEscapeSequence:this.errorBuilder(p.InvalidEscapeSequence),invalidCodePoint:this.errorBuilder(p.InvalidCodePoint)}));m(this,"errorHandlers_readStringContents_string",Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:(s,e,i)=>{this.recordStrictModeErrors(p.StrictNumericEscape,lt(s,e,i))},unterminated:(s,e,i)=>{throw this.raise(p.UnterminatedString,lt(s-1,e,i))}}));m(this,"errorHandlers_readStringContents_template",Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:this.errorBuilder(p.StrictNumericEscape),unterminated:(s,e,i)=>{throw this.raise(p.UnterminatedTemplate,lt(s,e,i))}}));this.state=new Ps,this.state.init(s),this.input=e,this.length=e.length,this.comments=[],this.isLookahead=!1}pushToken(s){this.tokens.length=this.state.tokensLength,this.tokens.push(s),++this.state.tokensLength}next(){this.checkKeywordEscapes(),this.optionFlags&256&&this.pushToken(new an(this.state)),this.state.lastTokEndLoc=this.state.endLoc,this.state.lastTokStartLoc=this.state.startLoc,this.nextToken()}eat(s){return this.match(s)?(this.next(),!0):!1}match(s){return this.state.type===s}createLookaheadState(s){return{pos:s.pos,value:null,type:s.type,start:s.start,end:s.end,context:[this.curContext()],inType:s.inType,startLoc:s.startLoc,lastTokEndLoc:s.lastTokEndLoc,curLine:s.curLine,lineStart:s.lineStart,curPosition:s.curPosition}}lookahead(){const s=this.state;this.state=this.createLookaheadState(s),this.isLookahead=!0,this.nextToken(),this.isLookahead=!1;const e=this.state;return this.state=s,e}nextTokenStart(){return this.nextTokenStartSince(this.state.pos)}nextTokenStartSince(s){return ys.lastIndex=s,ys.test(this.input)?ys.lastIndex:s}lookaheadCharCode(){return this.lookaheadCharCodeSince(this.state.pos)}lookaheadCharCodeSince(s){return this.input.charCodeAt(this.nextTokenStartSince(s))}nextTokenInLineStart(){return this.nextTokenInLineStartSince(this.state.pos)}nextTokenInLineStartSince(s){return xs.lastIndex=s,xs.test(this.input)?xs.lastIndex:s}lookaheadInLineCharCode(){return this.input.charCodeAt(this.nextTokenInLineStart())}codePointAtPos(s){let e=this.input.charCodeAt(s);if((e&64512)===55296&&++s<this.input.length){const i=this.input.charCodeAt(s);(i&64512)===56320&&(e=65536+((e&1023)<<10)+(i&1023))}return e}setStrict(s){this.state.strict=s,s&&(this.state.strictErrors.forEach(([e,i])=>this.raise(e,i)),this.state.strictErrors.clear())}curContext(){return this.state.context[this.state.context.length-1]}nextToken(){if(this.skipSpace(),this.state.start=this.state.pos,this.isLookahead||(this.state.startLoc=this.state.curPosition()),this.state.pos>=this.length){this.finishToken(140);return}this.getTokenFromCode(this.codePointAtPos(this.state.pos))}skipBlockComment(s){let e;this.isLookahead||(e=this.state.curPosition());const i=this.state.pos,a=this.input.indexOf(s,i+2);if(a===-1)throw this.raise(p.UnterminatedComment,this.state.curPosition());for(this.state.pos=a+s.length,Nt.lastIndex=i+2;Nt.test(this.input)&&Nt.lastIndex<=a;)++this.state.curLine,this.state.lineStart=Nt.lastIndex;if(this.isLookahead)return;const n={type:"CommentBlock",value:this.input.slice(i+2,a),start:this.sourceToOffsetPos(i),end:this.sourceToOffsetPos(a+s.length),loc:new It(e,this.state.curPosition())};return this.optionFlags&256&&this.pushToken(n),n}skipLineComment(s){const e=this.state.pos;let i;this.isLookahead||(i=this.state.curPosition());let a=this.input.charCodeAt(this.state.pos+=s);if(this.state.pos<this.length)for(;!qe(a)&&++this.state.pos<this.length;)a=this.input.charCodeAt(this.state.pos);if(this.isLookahead)return;const n=this.state.pos,c={type:"CommentLine",value:this.input.slice(e+s,n),start:this.sourceToOffsetPos(e),end:this.sourceToOffsetPos(n),loc:new It(i,this.state.curPosition())};return this.optionFlags&256&&this.pushToken(c),c}skipSpace(){const s=this.state.pos,e=this.optionFlags&4096?[]:null;e:for(;this.state.pos<this.length;){const i=this.input.charCodeAt(this.state.pos);switch(i){case 32:case 160:case 9:++this.state.pos;break;case 13:this.input.charCodeAt(this.state.pos+1)===10&&++this.state.pos;case 10:case 8232:case 8233:++this.state.pos,++this.state.curLine,this.state.lineStart=this.state.pos;break;case 47:switch(this.input.charCodeAt(this.state.pos+1)){case 42:{const a=this.skipBlockComment("*/");a!==void 0&&(this.addComment(a),e==null||e.push(a));break}case 47:{const a=this.skipLineComment(2);a!==void 0&&(this.addComment(a),e==null||e.push(a));break}default:break e}break;default:if(Ka(i))++this.state.pos;else if(i===45&&!this.inModule&&this.optionFlags&8192){const a=this.state.pos;if(this.input.charCodeAt(a+1)===45&&this.input.charCodeAt(a+2)===62&&(s===0||this.state.lineStart>s)){const n=this.skipLineComment(3);n!==void 0&&(this.addComment(n),e==null||e.push(n))}else break e}else if(i===60&&!this.inModule&&this.optionFlags&8192){const a=this.state.pos;if(this.input.charCodeAt(a+1)===33&&this.input.charCodeAt(a+2)===45&&this.input.charCodeAt(a+3)===45){const n=this.skipLineComment(4);n!==void 0&&(this.addComment(n),e==null||e.push(n))}else break e}else break e}}if((e==null?void 0:e.length)>0){const i=this.state.pos,a={start:this.sourceToOffsetPos(s),end:this.sourceToOffsetPos(i),comments:e,leadingNode:null,trailingNode:null,containingNode:null};this.state.commentStack.push(a)}}finishToken(s,e){this.state.end=this.state.pos,this.state.endLoc=this.state.curPosition();const i=this.state.type;this.state.type=s,this.state.value=e,this.isLookahead||this.updateContext(i)}replaceToken(s){this.state.type=s,this.updateContext()}readToken_numberSign(){if(this.state.pos===0&&this.readToken_interpreter())return;const s=this.state.pos+1,e=this.codePointAtPos(s);if(e>=48&&e<=57)throw this.raise(p.UnexpectedDigitAfterHash,this.state.curPosition());ge(e)?(++this.state.pos,this.finishToken(139,this.readWord1(e))):e===92?(++this.state.pos,this.finishToken(139,this.readWord1())):this.finishOp(27,1)}readToken_dot(){const s=this.input.charCodeAt(this.state.pos+1);if(s>=48&&s<=57){this.readNumber(!0);return}s===46&&this.input.charCodeAt(this.state.pos+2)===46?(this.state.pos+=3,this.finishToken(21)):(++this.state.pos,this.finishToken(16))}readToken_slash(){this.input.charCodeAt(this.state.pos+1)===61?this.finishOp(31,2):this.finishOp(56,1)}readToken_interpreter(){if(this.state.pos!==0||this.length<2)return!1;let s=this.input.charCodeAt(this.state.pos+1);if(s!==33)return!1;const e=this.state.pos;for(this.state.pos+=1;!qe(s)&&++this.state.pos<this.length;)s=this.input.charCodeAt(this.state.pos);const i=this.input.slice(e+2,this.state.pos);return this.finishToken(28,i),!0}readToken_mult_modulo(s){let e=s===42?55:54,i=1,a=this.input.charCodeAt(this.state.pos+1);s===42&&a===42&&(i++,a=this.input.charCodeAt(this.state.pos+2),e=57),a===61&&!this.state.inType&&(i++,e=s===37?33:30),this.finishOp(e,i)}readToken_pipe_amp(s){const e=this.input.charCodeAt(this.state.pos+1);if(e===s){this.input.charCodeAt(this.state.pos+2)===61?this.finishOp(30,3):this.finishOp(s===124?41:42,2);return}if(s===124&&e===62){this.finishOp(39,2);return}if(e===61){this.finishOp(30,2);return}this.finishOp(s===124?43:45,1)}readToken_caret(){const s=this.input.charCodeAt(this.state.pos+1);s===61&&!this.state.inType?this.finishOp(32,2):s===94&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"^^"}])?(this.finishOp(37,2),this.input.codePointAt(this.state.pos)===94&&this.unexpected()):this.finishOp(44,1)}readToken_atSign(){this.input.charCodeAt(this.state.pos+1)===64&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"@@"}])?this.finishOp(38,2):this.finishOp(26,1)}readToken_plus_min(s){const e=this.input.charCodeAt(this.state.pos+1);if(e===s){this.finishOp(34,2);return}e===61?this.finishOp(30,2):this.finishOp(53,1)}readToken_lt(){const{pos:s}=this.state,e=this.input.charCodeAt(s+1);if(e===60){if(this.input.charCodeAt(s+2)===61){this.finishOp(30,3);return}this.finishOp(51,2);return}if(e===61){this.finishOp(49,2);return}this.finishOp(47,1)}readToken_gt(){const{pos:s}=this.state,e=this.input.charCodeAt(s+1);if(e===62){const i=this.input.charCodeAt(s+2)===62?3:2;if(this.input.charCodeAt(s+i)===61){this.finishOp(30,i+1);return}this.finishOp(52,i);return}if(e===61){this.finishOp(49,2);return}this.finishOp(48,1)}readToken_eq_excl(s){const e=this.input.charCodeAt(this.state.pos+1);if(e===61){this.finishOp(46,this.input.charCodeAt(this.state.pos+2)===61?3:2);return}if(s===61&&e===62){this.state.pos+=2,this.finishToken(19);return}this.finishOp(s===61?29:35,1)}readToken_question(){const s=this.input.charCodeAt(this.state.pos+1),e=this.input.charCodeAt(this.state.pos+2);s===63?e===61?this.finishOp(30,3):this.finishOp(40,2):s===46&&!(e>=48&&e<=57)?(this.state.pos+=2,this.finishToken(18)):(++this.state.pos,this.finishToken(17))}getTokenFromCode(s){switch(s){case 46:this.readToken_dot();return;case 40:++this.state.pos,this.finishToken(10);return;case 41:++this.state.pos,this.finishToken(11);return;case 59:++this.state.pos,this.finishToken(13);return;case 44:++this.state.pos,this.finishToken(12);return;case 91:++this.state.pos,this.finishToken(0);return;case 93:++this.state.pos,this.finishToken(3);return;case 123:++this.state.pos,this.finishToken(5);return;case 125:++this.state.pos,this.finishToken(8);return;case 58:this.hasPlugin("functionBind")&&this.input.charCodeAt(this.state.pos+1)===58?this.finishOp(15,2):(++this.state.pos,this.finishToken(14));return;case 63:this.readToken_question();return;case 96:this.readTemplateToken();return;case 48:{const e=this.input.charCodeAt(this.state.pos+1);if(e===120||e===88){this.readRadixNumber(16);return}if(e===111||e===79){this.readRadixNumber(8);return}if(e===98||e===66){this.readRadixNumber(2);return}}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:this.readNumber(!1);return;case 34:case 39:this.readString(s);return;case 47:this.readToken_slash();return;case 37:case 42:this.readToken_mult_modulo(s);return;case 124:case 38:this.readToken_pipe_amp(s);return;case 94:this.readToken_caret();return;case 43:case 45:this.readToken_plus_min(s);return;case 60:this.readToken_lt();return;case 62:this.readToken_gt();return;case 61:case 33:this.readToken_eq_excl(s);return;case 126:this.finishOp(36,1);return;case 64:this.readToken_atSign();return;case 35:this.readToken_numberSign();return;case 92:this.readWord();return;default:if(ge(s)){this.readWord(s);return}}throw this.raise(p.InvalidOrUnexpectedToken,this.state.curPosition(),{unexpected:String.fromCodePoint(s)})}finishOp(s,e){const i=this.input.slice(this.state.pos,this.state.pos+e);this.state.pos+=e,this.finishToken(s,i)}readRegexp(){const s=this.state.startLoc,e=this.state.start+1;let i,a,{pos:n}=this.state;for(;;++n){if(n>=this.length)throw this.raise(p.UnterminatedRegExp,ce(s,1));const l=this.input.charCodeAt(n);if(qe(l))throw this.raise(p.UnterminatedRegExp,ce(s,1));if(i)i=!1;else{if(l===91)a=!0;else if(l===93&&a)a=!1;else if(l===47&&!a)break;i=l===92}}const o=this.input.slice(e,n);++n;let c="";const h=()=>ce(s,n+2-e);for(;n<this.length;){const l=this.codePointAtPos(n),u=String.fromCharCode(l);if(rn.has(l))l===118?c.includes("u")&&this.raise(p.IncompatibleRegExpUVFlags,h()):l===117&&c.includes("v")&&this.raise(p.IncompatibleRegExpUVFlags,h()),c.includes(u)&&this.raise(p.DuplicateRegExpFlags,h());else if($e(l)||l===92)this.raise(p.MalformedRegExpFlags,h());else break;++n,c+=u}this.state.pos=n,this.finishToken(138,{pattern:o,flags:c})}readInt(s,e,i=!1,a=!0){const{n,pos:o}=fi(this.input,this.state.pos,this.state.lineStart,this.state.curLine,s,e,i,a,this.errorHandlers_readInt,!1);return this.state.pos=o,n}readRadixNumber(s){const e=this.state.pos,i=this.state.curPosition();let a=!1;this.state.pos+=2;const n=this.readInt(s);n==null&&this.raise(p.InvalidDigit,ce(i,2),{radix:s});const o=this.input.charCodeAt(this.state.pos);if(o===110)++this.state.pos,a=!0;else if(o===109)throw this.raise(p.InvalidDecimal,i);if(ge(this.codePointAtPos(this.state.pos)))throw this.raise(p.NumberIdentifier,this.state.curPosition());if(a){const c=this.input.slice(e,this.state.pos).replace(/[_n]/g,"");this.finishToken(136,c);return}this.finishToken(135,n)}readNumber(s){const e=this.state.pos,i=this.state.curPosition();let a=!1,n=!1,o=!1;!s&&this.readInt(10)===null&&this.raise(p.InvalidNumber,this.state.curPosition());const c=this.state.pos-e>=2&&this.input.charCodeAt(e)===48;if(c){const f=this.input.slice(e,this.state.pos);if(this.recordStrictModeErrors(p.StrictOctalLiteral,i),!this.state.strict){const d=f.indexOf("_");d>0&&this.raise(p.ZeroDigitNumericSeparator,ce(i,d))}o=c&&!/[89]/.test(f)}let h=this.input.charCodeAt(this.state.pos);if(h===46&&!o&&(++this.state.pos,this.readInt(10),a=!0,h=this.input.charCodeAt(this.state.pos)),(h===69||h===101)&&!o&&(h=this.input.charCodeAt(++this.state.pos),(h===43||h===45)&&++this.state.pos,this.readInt(10)===null&&this.raise(p.InvalidOrMissingExponent,i),a=!0,h=this.input.charCodeAt(this.state.pos)),h===110&&((a||c)&&this.raise(p.InvalidBigIntLiteral,i),++this.state.pos,n=!0),ge(this.codePointAtPos(this.state.pos)))throw this.raise(p.NumberIdentifier,this.state.curPosition());const l=this.input.slice(e,this.state.pos).replace(/[_mn]/g,"");if(n){this.finishToken(136,l);return}const u=o?parseInt(l,8):parseFloat(l);this.finishToken(135,u)}readCodePoint(s){const{code:e,pos:i}=di(this.input,this.state.pos,this.state.lineStart,this.state.curLine,s,this.errorHandlers_readCodePoint);return this.state.pos=i,e}readString(s){const{str:e,pos:i,curLine:a,lineStart:n}=pi(s===34?"double":"single",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_string);this.state.pos=i+1,this.state.lineStart=n,this.state.curLine=a,this.finishToken(134,e)}readTemplateContinuation(){this.match(8)||this.unexpected(null,8),this.state.pos--,this.readTemplateToken()}readTemplateToken(){const s=this.input[this.state.pos],{str:e,firstInvalidLoc:i,pos:a,curLine:n,lineStart:o}=pi("template",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_template);this.state.pos=a+1,this.state.lineStart=o,this.state.curLine=n,i&&(this.state.firstInvalidTemplateEscapePos=new Ie(i.curLine,i.pos-i.lineStart,this.sourceToOffsetPos(i.pos))),this.input.codePointAt(a)===96?this.finishToken(24,i?null:s+e+"`"):(this.state.pos++,this.finishToken(25,i?null:s+e+"${"))}recordStrictModeErrors(s,e){const i=e.index;this.state.strict&&!this.state.strictErrors.has(i)?this.raise(s,e):this.state.strictErrors.set(i,[s,e])}readWord1(s){this.state.containsEsc=!1;let e="";const i=this.state.pos;let a=this.state.pos;for(s!==void 0&&(this.state.pos+=s<=65535?1:2);this.state.pos<this.length;){const n=this.codePointAtPos(this.state.pos);if($e(n))this.state.pos+=n<=65535?1:2;else if(n===92){this.state.containsEsc=!0,e+=this.input.slice(a,this.state.pos);const o=this.state.curPosition(),c=this.state.pos===i?ge:$e;if(this.input.charCodeAt(++this.state.pos)!==117){this.raise(p.MissingUnicodeEscape,this.state.curPosition()),a=this.state.pos-1;continue}++this.state.pos;const h=this.readCodePoint(!0);h!==null&&(c(h)||this.raise(p.EscapedCharNotAnIdentifier,o),e+=String.fromCodePoint(h)),a=this.state.pos}else break}return e+this.input.slice(a,this.state.pos)}readWord(s){const e=this.readWord1(s),i=ss.get(e);i!==void 0?this.finishToken(i,Ce(i)):this.finishToken(132,e)}checkKeywordEscapes(){const{type:s}=this.state;hs(s)&&this.state.containsEsc&&this.raise(p.InvalidEscapedReservedWord,this.state.startLoc,{reservedWord:Ce(s)})}raise(s,e,i={}){const a=e instanceof Ie?e:e.loc.start,n=s(a,i);if(!(this.optionFlags&2048))throw n;return this.isLookahead||this.state.errors.push(n),n}raiseOverwrite(s,e,i={}){const a=e instanceof Ie?e:e.loc.start,n=a.index,o=this.state.errors;for(let c=o.length-1;c>=0;c--){const h=o[c];if(h.loc.index===n)return o[c]=s(a,i);if(h.loc.index<n)break}return this.raise(s,e,i)}updateContext(s){}unexpected(s,e){throw this.raise(p.UnexpectedToken,s??this.state.startLoc,{expected:e?Ce(e):null})}expectPlugin(s,e){if(this.hasPlugin(s))return!0;throw this.raise(p.MissingPlugin,e??this.state.startLoc,{missingPlugin:[s]})}expectOnePlugin(s){if(!s.some(e=>this.hasPlugin(e)))throw this.raise(p.MissingOneOfPlugins,this.state.startLoc,{missingPlugin:s})}errorBuilder(s){return(e,i,a)=>{this.raise(s,lt(e,i,a))}}}class on{constructor(){m(this,"privateNames",new Set);m(this,"loneAccessors",new Map);m(this,"undefinedPrivateNames",new Map)}}class cn{constructor(t){m(this,"parser");m(this,"stack",[]);m(this,"undefinedPrivateNames",new Map);this.parser=t}current(){return this.stack[this.stack.length-1]}enter(){this.stack.push(new on)}exit(){const t=this.stack.pop(),s=this.current();for(const[e,i]of Array.from(t.undefinedPrivateNames))s?s.undefinedPrivateNames.has(e)||s.undefinedPrivateNames.set(e,i):this.parser.raise(p.InvalidPrivateFieldResolution,i,{identifierName:e})}declarePrivateName(t,s,e){const{privateNames:i,loneAccessors:a,undefinedPrivateNames:n}=this.current();let o=i.has(t);if(s&3){const c=o&&a.get(t);if(c){const h=c&4,l=s&4,u=c&3,f=s&3;o=u===f||h!==l,o||a.delete(t)}else o||a.set(t,s)}o&&this.parser.raise(p.PrivateNameRedeclaration,e,{identifierName:t}),i.add(t),n.delete(t)}usePrivateName(t,s){let e;for(e of this.stack)if(e.privateNames.has(t))return;e?e.undefinedPrivateNames.set(t,s):this.parser.raise(p.InvalidPrivateFieldResolution,s,{identifierName:t})}}class Dt{constructor(t=0){this.type=t}canBeArrowParameterDeclaration(){return this.type===2||this.type===1}isCertainlyParameterDeclaration(){return this.type===3}}class mi extends Dt{constructor(s){super(s);m(this,"declarationErrors",new Map)}recordDeclarationError(s,e){const i=e.index;this.declarationErrors.set(i,[s,e])}clearDeclarationError(s){this.declarationErrors.delete(s)}iterateErrors(s){this.declarationErrors.forEach(s)}}class hn{constructor(t){m(this,"parser");m(this,"stack",[new Dt]);this.parser=t}enter(t){this.stack.push(t)}exit(){this.stack.pop()}recordParameterInitializerError(t,s){const e=s.loc.start,{stack:i}=this;let a=i.length-1,n=i[a];for(;!n.isCertainlyParameterDeclaration();){if(n.canBeArrowParameterDeclaration())n.recordDeclarationError(t,e);else return;n=i[--a]}this.parser.raise(t,e)}recordArrowParameterBindingError(t,s){const{stack:e}=this,i=e[e.length-1],a=s.loc.start;if(i.isCertainlyParameterDeclaration())this.parser.raise(t,a);else if(i.canBeArrowParameterDeclaration())i.recordDeclarationError(t,a);else return}recordAsyncArrowParametersError(t){const{stack:s}=this;let e=s.length-1,i=s[e];for(;i.canBeArrowParameterDeclaration();)i.type===2&&i.recordDeclarationError(p.AwaitBindingIdentifier,t),i=s[--e]}validateAsPattern(){const{stack:t}=this,s=t[t.length-1];s.canBeArrowParameterDeclaration()&&s.iterateErrors(([e,i])=>{this.parser.raise(e,i);let a=t.length-2,n=t[a];for(;n.canBeArrowParameterDeclaration();)n.clearDeclarationError(i.index),n=t[--a]})}}function ln(){return new Dt(3)}function un(){return new mi(1)}function pn(){return new mi(2)}function yi(){return new Dt}class fn extends nn{addExtra(t,s,e,i=!0){if(!t)return;let{extra:a}=t;a==null&&(a={},t.extra=a),i?a[s]=e:Object.defineProperty(a,s,{enumerable:i,value:e})}isContextual(t){return this.state.type===t&&!this.state.containsEsc}isUnparsedContextual(t,s){const e=t+s.length;if(this.input.slice(t,e)===s){const i=this.input.charCodeAt(e);return!($e(i)||(i&64512)===55296)}return!1}isLookaheadContextual(t){const s=this.nextTokenStart();return this.isUnparsedContextual(s,t)}eatContextual(t){return this.isContextual(t)?(this.next(),!0):!1}expectContextual(t,s){if(!this.eatContextual(t)){if(s!=null)throw this.raise(s,this.state.startLoc);this.unexpected(null,t)}}canInsertSemicolon(){return this.match(140)||this.match(8)||this.hasPrecedingLineBreak()}hasPrecedingLineBreak(){return hi(this.input,this.offsetToSourcePos(this.state.lastTokEndLoc.index),this.state.start)}hasFollowingLineBreak(){return hi(this.input,this.state.end,this.nextTokenStart())}isLineTerminator(){return this.eat(13)||this.canInsertSemicolon()}semicolon(t=!0){(t?this.isLineTerminator():this.eat(13))||this.raise(p.MissingSemicolon,this.state.lastTokEndLoc)}expect(t,s){this.eat(t)||this.unexpected(s,t)}tryParse(t,s=this.state.clone()){const e={node:null};try{const i=t((a=null)=>{throw e.node=a,e});if(this.state.errors.length>s.errors.length){const a=this.state;return this.state=s,this.state.tokensLength=a.tokensLength,{node:i,error:a.errors[s.errors.length],thrown:!1,aborted:!1,failState:a}}return{node:i,error:null,thrown:!1,aborted:!1,failState:null}}catch(i){const a=this.state;if(this.state=s,i instanceof SyntaxError)return{node:null,error:i,thrown:!0,aborted:!1,failState:a};if(i===e)return{node:e.node,error:null,thrown:!1,aborted:!0,failState:a};throw i}}checkExpressionErrors(t,s){if(!t)return!1;const{shorthandAssignLoc:e,doubleProtoLoc:i,privateKeyLoc:a,optionalParametersLoc:n}=t,o=!!e||!!i||!!n||!!a;if(!s)return o;e!=null&&this.raise(p.InvalidCoverInitializedName,e),i!=null&&this.raise(p.DuplicateProto,i),a!=null&&this.raise(p.UnexpectedPrivateField,a),n!=null&&this.unexpected(n)}isLiteralPropertyName(){return Qs(this.state.type)}isPrivateName(t){return t.type==="PrivateName"}getPrivateNameSV(t){return t.id.name}hasPropertyAsPrivateName(t){return(t.type==="MemberExpression"||t.type==="OptionalMemberExpression")&&this.isPrivateName(t.property)}isObjectProperty(t){return t.type==="ObjectProperty"}isObjectMethod(t){return t.type==="ObjectMethod"}initializeScopes(t=this.options.sourceType==="module"){const s=this.state.labels;this.state.labels=[];const e=this.exportedIdentifiers;this.exportedIdentifiers=new Set;const i=this.inModule;this.inModule=t;const a=this.scope,n=this.getScopeHandler();this.scope=new n(this,t);const o=this.prodParam;this.prodParam=new Xa;const c=this.classScope;this.classScope=new cn(this);const h=this.expressionScope;return this.expressionScope=new hn(this),()=>{this.state.labels=s,this.exportedIdentifiers=e,this.inModule=i,this.scope=a,this.prodParam=o,this.classScope=c,this.expressionScope=h}}enterInitialScopes(){let t=0;this.inModule&&(t|=2),this.optionFlags&32&&(t|=1),this.scope.enter(1),this.prodParam.enter(t)}checkDestructuringPrivate(t){const{privateKeyLoc:s}=t;s!==null&&this.expectPlugin("destructuringPrivate",s)}}class Lt{constructor(){m(this,"shorthandAssignLoc",null);m(this,"doubleProtoLoc",null);m(this,"privateKeyLoc",null);m(this,"optionalParametersLoc",null)}}class gs{constructor(t,s,e){m(this,"type","");this.start=s,this.end=0,this.loc=new It(e),(t==null?void 0:t.optionFlags)&128&&(this.range=[s,0]),t!=null&&t.filename&&(this.loc.filename=t.filename)}}const xi=gs.prototype;class dn extends fn{startNode(){const t=this.state.startLoc;return new gs(this,t.index,t)}startNodeAt(t){return new gs(this,t.index,t)}startNodeAtNode(t){return this.startNodeAt(t.loc.start)}finishNode(t,s){return this.finishNodeAt(t,s,this.state.lastTokEndLoc)}finishNodeAt(t,s,e){return t.type=s,t.end=e.index,t.loc.end=e,this.optionFlags&128&&(t.range[1]=e.index),this.optionFlags&4096&&this.processComment(t),t}resetStartLocation(t,s){t.start=s.index,t.loc.start=s,this.optionFlags&128&&(t.range[0]=s.index)}resetEndLocation(t,s=this.state.lastTokEndLoc){t.end=s.index,t.loc.end=s,this.optionFlags&128&&(t.range[1]=s.index)}resetStartLocationFromNode(t,s){this.resetStartLocation(t,s.loc.start)}castNodeTo(t,s){return t.type=s,t}cloneIdentifier(t){const{type:s,start:e,end:i,loc:a,range:n,name:o}=t,c=Object.create(xi);return c.type=s,c.start=e,c.end=i,c.loc=a,c.range=n,c.name=o,t.extra&&(c.extra=t.extra),c}cloneStringLiteral(t){const{type:s,start:e,end:i,loc:a,range:n,extra:o}=t,c=Object.create(xi);return c.type=s,c.start=e,c.end=i,c.loc=a,c.range=n,c.extra=o,c.value=t.value,c}}const Pi=r=>r.type==="ParenthesizedExpression"?Pi(r.expression):r;class mn extends dn{toAssignable(t,s=!1){var i,a,n;let e;switch((t.type==="ParenthesizedExpression"||(i=t.extra)!=null&&i.parenthesized)&&(e=Pi(t),s?e.type==="Identifier"?this.expressionScope.recordArrowParameterBindingError(p.InvalidParenthesizedAssignment,t):e.type!=="MemberExpression"&&!this.isOptionalMemberExpression(e)&&this.raise(p.InvalidParenthesizedAssignment,t):this.raise(p.InvalidParenthesizedAssignment,t)),t.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":this.castNodeTo(t,"ObjectPattern");for(let o=0,c=t.properties.length,h=c-1;o<c;o++){const l=t.properties[o],u=o===h;this.toAssignableObjectExpressionProp(l,u,s),u&&l.type==="RestElement"&&((a=t.extra)!=null&&a.trailingCommaLoc)&&this.raise(p.RestTrailingComma,t.extra.trailingCommaLoc)}break;case"ObjectProperty":{const{key:o,value:c}=t;this.isPrivateName(o)&&this.classScope.usePrivateName(this.getPrivateNameSV(o),o.loc.start),this.toAssignable(c,s);break}case"SpreadElement":throw new Error("Internal @babel/parser error (this is a bug, please report it). SpreadElement should be converted by .toAssignable's caller.");case"ArrayExpression":this.castNodeTo(t,"ArrayPattern"),this.toAssignableList(t.elements,(n=t.extra)==null?void 0:n.trailingCommaLoc,s);break;case"AssignmentExpression":t.operator!=="="&&this.raise(p.MissingEqInAssignment,t.left.loc.end),this.castNodeTo(t,"AssignmentPattern"),delete t.operator,this.toAssignable(t.left,s);break;case"ParenthesizedExpression":this.toAssignable(e,s);break}}toAssignableObjectExpressionProp(t,s,e){if(t.type==="ObjectMethod")this.raise(t.kind==="get"||t.kind==="set"?p.PatternHasAccessor:p.PatternHasMethod,t.key);else if(t.type==="SpreadElement"){this.castNodeTo(t,"RestElement");const i=t.argument;this.checkToRestConversion(i,!1),this.toAssignable(i,e),s||this.raise(p.RestTrailingComma,t)}else this.toAssignable(t,e)}toAssignableList(t,s,e){const i=t.length-1;for(let a=0;a<=i;a++){const n=t[a];n&&(this.toAssignableListItem(t,a,e),n.type==="RestElement"&&(a<i?this.raise(p.RestTrailingComma,n):s&&this.raise(p.RestTrailingComma,s)))}}toAssignableListItem(t,s,e){const i=t[s];if(i.type==="SpreadElement"){this.castNodeTo(i,"RestElement");const a=i.argument;this.checkToRestConversion(a,!0),this.toAssignable(a,e)}else this.toAssignable(i,e)}isAssignable(t,s){switch(t.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":return!0;case"ObjectExpression":{const e=t.properties.length-1;return t.properties.every((i,a)=>i.type!=="ObjectMethod"&&(a===e||i.type!=="SpreadElement")&&this.isAssignable(i))}case"ObjectProperty":return this.isAssignable(t.value);case"SpreadElement":return this.isAssignable(t.argument);case"ArrayExpression":return t.elements.every(e=>e===null||this.isAssignable(e));case"AssignmentExpression":return t.operator==="=";case"ParenthesizedExpression":return this.isAssignable(t.expression);case"MemberExpression":case"OptionalMemberExpression":return!s;default:return!1}}toReferencedList(t,s){return t}toReferencedListDeep(t,s){this.toReferencedList(t,s);for(const e of t)(e==null?void 0:e.type)==="ArrayExpression"&&this.toReferencedListDeep(e.elements)}parseSpread(t){const s=this.startNode();return this.next(),s.argument=this.parseMaybeAssignAllowIn(t,void 0),this.finishNode(s,"SpreadElement")}parseRestBinding(){const t=this.startNode();return this.next(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")}parseBindingAtom(){switch(this.state.type){case 0:{const t=this.startNode();return this.next(),t.elements=this.parseBindingList(3,93,1),this.finishNode(t,"ArrayPattern")}case 5:return this.parseObjectLike(8,!0)}return this.parseIdentifier()}parseBindingList(t,s,e){const i=e&1,a=[];let n=!0;for(;!this.eat(t);)if(n?n=!1:this.expect(12),i&&this.match(12))a.push(null);else{if(this.eat(t))break;if(this.match(21)){let o=this.parseRestBinding();if(e&2&&(o=this.parseFunctionParamType(o)),a.push(o),!this.checkCommaAfterRest(s)){this.expect(t);break}}else{const o=[];if(e&2)for(this.match(26)&&this.hasPlugin("decorators")&&this.raise(p.UnsupportedParameterDecorator,this.state.startLoc);this.match(26);)o.push(this.parseDecorator());a.push(this.parseBindingElement(e,o))}}return a}parseBindingRestProperty(t){return this.next(),t.argument=this.parseIdentifier(),this.checkCommaAfterRest(125),this.finishNode(t,"RestElement")}parseBindingProperty(){const{type:t,startLoc:s}=this.state;if(t===21)return this.parseBindingRestProperty(this.startNode());const e=this.startNode();return t===139?(this.expectPlugin("destructuringPrivate",s),this.classScope.usePrivateName(this.state.value,s),e.key=this.parsePrivateName()):this.parsePropertyName(e),e.method=!1,this.parseObjPropValue(e,s,!1,!1,!0,!1)}parseBindingElement(t,s){const e=this.parseMaybeDefault();return t&2&&this.parseFunctionParamType(e),s.length&&(e.decorators=s,this.resetStartLocationFromNode(e,s[0])),this.parseMaybeDefault(e.loc.start,e)}parseFunctionParamType(t){return t}parseMaybeDefault(t,s){if(t??(t=this.state.startLoc),s=s??this.parseBindingAtom(),!this.eat(29))return s;const e=this.startNodeAt(t);return e.left=s,e.right=this.parseMaybeAssignAllowIn(),this.finishNode(e,"AssignmentPattern")}isValidLVal(t,s,e){switch(t){case"AssignmentPattern":return"left";case"RestElement":return"argument";case"ObjectProperty":return"value";case"ParenthesizedExpression":return"expression";case"ArrayPattern":return"elements";case"ObjectPattern":return"properties"}return!1}isOptionalMemberExpression(t){return t.type==="OptionalMemberExpression"}checkLVal(t,s,e=64,i=!1,a=!1,n=!1){var P;const o=t.type;if(this.isObjectMethod(t))return;const c=this.isOptionalMemberExpression(t);if(c||o==="MemberExpression"){c&&(this.expectPlugin("optionalChainingAssign",t.loc.start),s.type!=="AssignmentExpression"&&this.raise(p.InvalidLhsOptionalChaining,t,{ancestor:s})),e!==64&&this.raise(p.InvalidPropertyBindingPattern,t);return}if(o==="Identifier"){this.checkIdentifier(t,e,a);const{name:S}=t;i&&(i.has(S)?this.raise(p.ParamDupe,t):i.add(S));return}const h=this.isValidLVal(o,!(n||(P=t.extra)!=null&&P.parenthesized)&&s.type==="AssignmentExpression",e);if(h===!0)return;if(h===!1){const S=e===64?p.InvalidLhs:p.InvalidLhsBinding;this.raise(S,t,{ancestor:s});return}let l,u;typeof h=="string"?(l=h,u=o==="ParenthesizedExpression"):[l,u]=h;const f=o==="ArrayPattern"||o==="ObjectPattern"?{type:o}:s,d=t[l];if(Array.isArray(d))for(const S of d)S&&this.checkLVal(S,f,e,i,a,u);else d&&this.checkLVal(d,f,e,i,a,u)}checkIdentifier(t,s,e=!1){this.state.strict&&(e?oi(t.name,this.inModule):ni(t.name))&&(s===64?this.raise(p.StrictEvalArguments,t,{referenceName:t.name}):this.raise(p.StrictEvalArgumentsBinding,t,{bindingName:t.name})),s&8192&&t.name==="let"&&this.raise(p.LetInLexicalBinding,t),s&64||this.declareNameFromIdentifier(t,s)}declareNameFromIdentifier(t,s){this.scope.declareName(t.name,s,t.loc.start)}checkToRestConversion(t,s){switch(t.type){case"ParenthesizedExpression":this.checkToRestConversion(t.expression,s);break;case"Identifier":case"MemberExpression":break;case"ArrayExpression":case"ObjectExpression":if(s)break;default:this.raise(p.InvalidRestAssignmentPattern,t)}}checkCommaAfterRest(t){return this.match(12)?(this.raise(this.lookaheadCharCode()===t?p.RestTrailingComma:p.ElementAfterRest,this.state.startLoc),!0):!1}}function yn(r){if(r==null)throw new Error(`Unexpected ${r} value.`);return r}function bi(r){if(!r)throw new Error("Assert fail")}const w=ye`typescript`({AbstractMethodHasImplementation:({methodName:r})=>`Method '${r}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:r})=>`Property '${r}' cannot have an initializer because it is marked abstract.`,AccessorCannotBeOptional:"An 'accessor' property cannot be declared optional.",AccessorCannotDeclareThisParameter:"'get' and 'set' accessors cannot declare 'this' parameters.",AccessorCannotHaveTypeParameters:"An accessor cannot have type parameters.",ClassMethodHasDeclare:"Class methods cannot have the 'declare' modifier.",ClassMethodHasReadonly:"Class methods cannot have the 'readonly' modifier.",ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference:"A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",ConstructorHasTypeParameters:"Type parameters cannot appear on a constructor declaration.",DeclareAccessor:({kind:r})=>`'declare' is not allowed in ${r}ters.`,DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared in ambient contexts.",DuplicateAccessibilityModifier:({modifier:r})=>`Accessibility modifier already seen: '${r}'.`,DuplicateModifier:({modifier:r})=>`Duplicate modifier: '${r}'.`,EmptyHeritageClauseType:({token:r})=>`'${r}' list cannot be empty.`,EmptyTypeArguments:"Type argument list cannot be empty.",EmptyTypeParameters:"Type parameter list cannot be empty.",ExpectedAmbientAfterExportDeclare:"'export declare' must be followed by an ambient declaration.",ImportAliasHasImportType:"An import alias can not use 'import type'.",ImportReflectionHasImportType:"An `import module` declaration can not use `type` modifier",IncompatibleModifiers:({modifiers:r})=>`'${r[0]}' modifier cannot be used with '${r[1]}' modifier.`,IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:({modifier:r})=>`Index signatures cannot have an accessibility modifier ('${r}').`,IndexSignatureHasDeclare:"Index signatures cannot have the 'declare' modifier.",IndexSignatureHasOverride:"'override' modifier cannot appear on an index signature.",IndexSignatureHasStatic:"Index signatures cannot have the 'static' modifier.",InitializerNotAllowedInAmbientContext:"Initializers are not allowed in ambient contexts.",InvalidHeritageClauseType:({token:r})=>`'${r}' list can only include identifiers or qualified-names with optional type arguments.`,InvalidModifierOnTypeMember:({modifier:r})=>`'${r}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:r})=>`'${r}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:r})=>`'${r}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifiersOrder:({orderedModifiers:r})=>`'${r[0]}' modifier must precede '${r[1]}' modifier.`,InvalidPropertyAccessAfterInstantiationExpression:"Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",InvalidTupleMemberLabel:"Tuple members must be labeled with a simple identifier.",MissingInterfaceName:"'interface' declarations must be followed by an identifier.",NonAbstractClassHasAbstractMethod:"Abstract methods can only appear within an abstract class.",NonClassMethodPropertyHasAbstractModifier:"'abstract' modifier can only appear on a class, method, or property declaration.",OptionalTypeBeforeRequired:"A required element cannot follow an optional element.",OverrideNotInSubClass:"This member cannot have an 'override' modifier because its containing class does not extend another class.",PatternIsOptional:"A binding pattern parameter cannot be optional in an implementation signature.",PrivateElementHasAbstract:"Private elements cannot have the 'abstract' modifier.",PrivateElementHasAccessibility:({modifier:r})=>`Private elements cannot have an accessibility modifier ('${r}').`,ReadonlyForMethodSignature:"'readonly' modifier can only appear on a property declaration or index signature.",ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccessorCannotHaveOptionalParameter:"A 'set' accessor cannot have an optional parameter.",SetAccessorCannotHaveRestParameter:"A 'set' accessor cannot have rest parameter.",SetAccessorCannotHaveReturnType:"A 'set' accessor cannot have a return type annotation.",SingleTypeParameterWithoutTrailingComma:({typeParameterName:r})=>`Single type parameter ${r} should have a trailing comma. Example usage: <${r},>.`,StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:"A type-only import can specify a default import or named bindings, but not both.",TypeModifierIsUsedInTypeExports:"The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",TypeModifierIsUsedInTypeImports:"The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",UnexpectedParameterModifier:"A parameter property is only allowed in a constructor implementation.",UnexpectedReadonly:"'readonly' type modifier is only permitted on array and tuple literal types.",UnexpectedTypeAnnotation:"Did not expect a type annotation here.",UnexpectedTypeCastInParameter:"Unexpected type cast in parameter position.",UnsupportedImportTypeArgument:"Argument in a type import must be a string literal.",UnsupportedParameterPropertyKind:"A parameter property may not be declared using a binding pattern.",UnsupportedSignatureParameterKind:({type:r})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${r}.`});function xn(r){switch(r){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"TSBigIntKeyword";case"never":return"TSNeverKeyword";case"number":return"TSNumberKeyword";case"object":return"TSObjectKeyword";case"string":return"TSStringKeyword";case"symbol":return"TSSymbolKeyword";case"undefined":return"TSUndefinedKeyword";case"unknown":return"TSUnknownKeyword";default:return}}function gi(r){return r==="private"||r==="public"||r==="protected"}function Pn(r){return r==="in"||r==="out"}function ws(r){var t;if((t=r.extra)!=null&&t.parenthesized)return!1;switch(r.type){case"Identifier":return!0;case"MemberExpression":return!r.computed&&ws(r.object);case"TSInstantiationExpression":return ws(r.expression);default:return!1}}var bn=r=>class extends r{constructor(){super(...arguments);m(this,"tsParseInOutModifiers",this.tsParseModifiers.bind(this,{allowedModifiers:["in","out"],disallowedModifiers:["const","public","private","protected","readonly","declare","abstract","override"],errorTemplate:w.InvalidModifierOnTypeParameter}));m(this,"tsParseConstModifier",this.tsParseModifiers.bind(this,{allowedModifiers:["const"],disallowedModifiers:["in","out"],errorTemplate:w.InvalidModifierOnTypeParameterPositions}));m(this,"tsParseInOutConstModifiers",this.tsParseModifiers.bind(this,{allowedModifiers:["in","out","const"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:w.InvalidModifierOnTypeParameter}))}getScopeHandler(){return Ga}tsIsIdentifier(){return O(this.state.type)}tsTokenCanFollowModifier(){return this.match(0)||this.match(5)||this.match(55)||this.match(21)||this.match(139)||this.isLiteralPropertyName()}tsNextTokenOnSameLineAndCanFollowModifier(){return this.next(),this.hasPrecedingLineBreak()?!1:this.tsTokenCanFollowModifier()}tsNextTokenCanFollowModifier(){return this.match(106)?(this.next(),this.tsTokenCanFollowModifier()):this.tsNextTokenOnSameLineAndCanFollowModifier()}tsParseModifier(e,i,a){if(!O(this.state.type)&&this.state.type!==58&&this.state.type!==75)return;const n=this.state.value;if(e.includes(n)){if(a&&this.match(106)||i&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return n}}tsParseModifiers({allowedModifiers:e,disallowedModifiers:i,stopOnStartOfClassStaticBlock:a,errorTemplate:n=w.InvalidModifierOnTypeMember},o){const c=(l,u,f,d)=>{u===f&&o[d]&&this.raise(w.InvalidModifiersOrder,l,{orderedModifiers:[f,d]})},h=(l,u,f,d)=>{(o[f]&&u===d||o[d]&&u===f)&&this.raise(w.IncompatibleModifiers,l,{modifiers:[f,d]})};for(;;){const{startLoc:l}=this.state,u=this.tsParseModifier(e.concat(i??[]),a,o.static);if(!u)break;gi(u)?o.accessibility?this.raise(w.DuplicateAccessibilityModifier,l,{modifier:u}):(c(l,u,u,"override"),c(l,u,u,"static"),c(l,u,u,"readonly"),o.accessibility=u):Pn(u)?(o[u]&&this.raise(w.DuplicateModifier,l,{modifier:u}),o[u]=!0,c(l,u,"in","out")):(Object.hasOwn(o,u)?this.raise(w.DuplicateModifier,l,{modifier:u}):(c(l,u,"static","readonly"),c(l,u,"static","override"),c(l,u,"override","readonly"),c(l,u,"abstract","override"),h(l,u,"declare","override"),h(l,u,"static","abstract")),o[u]=!0),i!=null&&i.includes(u)&&this.raise(n,l,{modifier:u})}}tsIsListTerminator(e){switch(e){case"EnumMembers":case"TypeMembers":return this.match(8);case"HeritageClauseElement":return this.match(5);case"TupleElementTypes":return this.match(3);case"TypeParametersOrArguments":return this.match(48)}}tsParseList(e,i){const a=[];for(;!this.tsIsListTerminator(e);)a.push(i());return a}tsParseDelimitedList(e,i,a){return yn(this.tsParseDelimitedListWorker(e,i,!0,a))}tsParseDelimitedListWorker(e,i,a,n){const o=[];let c=-1;for(;!this.tsIsListTerminator(e);){c=-1;const h=i();if(h==null)return;if(o.push(h),this.eat(12)){c=this.state.lastTokStartLoc.index;continue}if(this.tsIsListTerminator(e))break;a&&this.expect(12);return}return n&&(n.value=c),o}tsParseBracketedList(e,i,a,n,o){n||(a?this.expect(0):this.expect(47));const c=this.tsParseDelimitedList(e,i,o);return a?this.expect(3):this.expect(48),c}tsParseImportType(){const e=this.startNode();return this.expect(83),this.expect(10),this.match(134)?e.argument=this.tsParseLiteralTypeNode():(this.raise(w.UnsupportedImportTypeArgument,this.state.startLoc),e.argument=this.tsParseNonConditionalType()),this.eat(12)?e.options=this.tsParseImportTypeOptions():e.options=null,this.expect(11),this.eat(16)&&(e.qualifier=this.tsParseEntityName(3)),this.match(47)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,"TSImportType")}tsParseImportTypeOptions(){const e=this.startNode();this.expect(5);const i=this.startNode();return this.isContextual(76)?(i.method=!1,i.key=this.parseIdentifier(!0),i.computed=!1,i.shorthand=!1):this.unexpected(null,76),this.expect(14),i.value=this.tsParseImportTypeWithPropertyValue(),e.properties=[this.finishObjectProperty(i)],this.expect(8),this.finishNode(e,"ObjectExpression")}tsParseImportTypeWithPropertyValue(){const e=this.startNode(),i=[];for(this.expect(5);!this.match(8);){const a=this.state.type;O(a)||a===134?i.push(super.parsePropertyDefinition(null)):this.unexpected(),this.eat(12)}return e.properties=i,this.next(),this.finishNode(e,"ObjectExpression")}tsParseEntityName(e){let i;if(e&1&&this.match(78))if(e&2)i=this.parseIdentifier(!0);else{const a=this.startNode();this.next(),i=this.finishNode(a,"ThisExpression")}else i=this.parseIdentifier(!!(e&1));for(;this.eat(16);){const a=this.startNodeAtNode(i);a.left=i,a.right=this.parseIdentifier(!!(e&1)),i=this.finishNode(a,"TSQualifiedName")}return i}tsParseTypeReference(){const e=this.startNode();return e.typeName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(47)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,"TSTypeReference")}tsParseThisTypePredicate(e){this.next();const i=this.startNodeAtNode(e);return i.parameterName=e,i.typeAnnotation=this.tsParseTypeAnnotation(!1),i.asserts=!1,this.finishNode(i,"TSTypePredicate")}tsParseThisTypeNode(){const e=this.startNode();return this.next(),this.finishNode(e,"TSThisType")}tsParseTypeQuery(){const e=this.startNode();return this.expect(87),this.match(83)?e.exprName=this.tsParseImportType():e.exprName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(47)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,"TSTypeQuery")}tsParseTypeParameter(e){const i=this.startNode();return e(i),i.name=this.tsParseTypeParameterName(),i.constraint=this.tsEatThenParseType(81),i.default=this.tsEatThenParseType(29),this.finishNode(i,"TSTypeParameter")}tsTryParseTypeParameters(e){if(this.match(47))return this.tsParseTypeParameters(e)}tsParseTypeParameters(e){const i=this.startNode();this.match(47)||this.match(143)?this.next():this.unexpected();const a={value:-1};return i.params=this.tsParseBracketedList("TypeParametersOrArguments",this.tsParseTypeParameter.bind(this,e),!1,!0,a),i.params.length===0&&this.raise(w.EmptyTypeParameters,i),a.value!==-1&&this.addExtra(i,"trailingComma",a.value),this.finishNode(i,"TSTypeParameterDeclaration")}tsFillSignature(e,i){const a=e===19,n="params",o="returnType";i.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),this.expect(10),i[n]=this.tsParseBindingListForSignature(),a?i[o]=this.tsParseTypeOrTypePredicateAnnotation(e):this.match(e)&&(i[o]=this.tsParseTypeOrTypePredicateAnnotation(e))}tsParseBindingListForSignature(){const e=super.parseBindingList(11,41,2);for(const i of e){const{type:a}=i;(a==="AssignmentPattern"||a==="TSParameterProperty")&&this.raise(w.UnsupportedSignatureParameterKind,i,{type:a})}return e}tsParseTypeMemberSemicolon(){!this.eat(12)&&!this.isLineTerminator()&&this.expect(13)}tsParseSignatureMember(e,i){return this.tsFillSignature(14,i),this.tsParseTypeMemberSemicolon(),this.finishNode(i,e)}tsIsUnambiguouslyIndexSignature(){return this.next(),O(this.state.type)?(this.next(),this.match(14)):!1}tsTryParseIndexSignature(e){if(!(this.match(0)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))))return;this.expect(0);const i=this.parseIdentifier();i.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(i),this.expect(3),e.parameters=[i];const a=this.tsTryParseTypeAnnotation();return a&&(e.typeAnnotation=a),this.tsParseTypeMemberSemicolon(),this.finishNode(e,"TSIndexSignature")}tsParsePropertyOrMethodSignature(e,i){if(this.eat(17)&&(e.optional=!0),this.match(10)||this.match(47)){i&&this.raise(w.ReadonlyForMethodSignature,e);const a=e;a.kind&&this.match(47)&&this.raise(w.AccessorCannotHaveTypeParameters,this.state.curPosition()),this.tsFillSignature(14,a),this.tsParseTypeMemberSemicolon();const n="params",o="returnType";if(a.kind==="get")a[n].length>0&&(this.raise(p.BadGetterArity,this.state.curPosition()),this.isThisParam(a[n][0])&&this.raise(w.AccessorCannotDeclareThisParameter,this.state.curPosition()));else if(a.kind==="set"){if(a[n].length!==1)this.raise(p.BadSetterArity,this.state.curPosition());else{const c=a[n][0];this.isThisParam(c)&&this.raise(w.AccessorCannotDeclareThisParameter,this.state.curPosition()),c.type==="Identifier"&&c.optional&&this.raise(w.SetAccessorCannotHaveOptionalParameter,this.state.curPosition()),c.type==="RestElement"&&this.raise(w.SetAccessorCannotHaveRestParameter,this.state.curPosition())}a[o]&&this.raise(w.SetAccessorCannotHaveReturnType,a[o])}else a.kind="method";return this.finishNode(a,"TSMethodSignature")}else{const a=e;i&&(a.readonly=!0);const n=this.tsTryParseTypeAnnotation();return n&&(a.typeAnnotation=n),this.tsParseTypeMemberSemicolon(),this.finishNode(a,"TSPropertySignature")}}tsParseTypeMember(){const e=this.startNode();if(this.match(10)||this.match(47))return this.tsParseSignatureMember("TSCallSignatureDeclaration",e);if(this.match(77)){const a=this.startNode();return this.next(),this.match(10)||this.match(47)?this.tsParseSignatureMember("TSConstructSignatureDeclaration",e):(e.key=this.createIdentifier(a,"new"),this.tsParsePropertyOrMethodSignature(e,!1))}this.tsParseModifiers({allowedModifiers:["readonly"],disallowedModifiers:["declare","abstract","private","protected","public","static","override"]},e);const i=this.tsTryParseIndexSignature(e);return i||(super.parsePropertyName(e),!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.tsTokenCanFollowModifier()&&(e.kind=e.key.name,super.parsePropertyName(e),!this.match(10)&&!this.match(47)&&this.unexpected(null,10)),this.tsParsePropertyOrMethodSignature(e,!!e.readonly))}tsParseTypeLiteral(){const e=this.startNode();return e.members=this.tsParseObjectTypeMembers(),this.finishNode(e,"TSTypeLiteral")}tsParseObjectTypeMembers(){this.expect(5);const e=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(8),e}tsIsStartOfMappedType(){return this.next(),this.eat(53)?this.isContextual(122):(this.isContextual(122)&&this.next(),!this.match(0)||(this.next(),!this.tsIsIdentifier())?!1:(this.next(),this.match(58)))}tsParseMappedType(){const e=this.startNode();return this.expect(5),this.match(53)?(e.readonly=this.state.value,this.next(),this.expectContextual(122)):this.eatContextual(122)&&(e.readonly=!0),this.expect(0),e.key=this.tsParseTypeParameterName(),e.constraint=this.tsExpectThenParseType(58),e.nameType=this.eatContextual(93)?this.tsParseType():null,this.expect(3),this.match(53)?(e.optional=this.state.value,this.next(),this.expect(17)):this.eat(17)&&(e.optional=!0),e.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(8),this.finishNode(e,"TSMappedType")}tsParseTupleType(){const e=this.startNode();e.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);let i=!1;return e.elementTypes.forEach(a=>{const{type:n}=a;i&&n!=="TSRestType"&&n!=="TSOptionalType"&&!(n==="TSNamedTupleMember"&&a.optional)&&this.raise(w.OptionalTypeBeforeRequired,a),i||(i=n==="TSNamedTupleMember"&&a.optional||n==="TSOptionalType")}),this.finishNode(e,"TSTupleType")}tsParseTupleElementType(){const e=this.state.startLoc,i=this.eat(21),{startLoc:a}=this.state;let n,o,c,h;const u=ue(this.state.type)?this.lookaheadCharCode():null;if(u===58)n=!0,c=!1,o=this.parseIdentifier(!0),this.expect(14),h=this.tsParseType();else if(u===63){c=!0;const f=this.state.value,d=this.tsParseNonArrayType();this.lookaheadCharCode()===58?(n=!0,o=this.createIdentifier(this.startNodeAt(a),f),this.expect(17),this.expect(14),h=this.tsParseType()):(n=!1,h=d,this.expect(17))}else h=this.tsParseType(),c=this.eat(17),n=this.eat(14);if(n){let f;o?(f=this.startNodeAt(a),f.optional=c,f.label=o,f.elementType=h,this.eat(17)&&(f.optional=!0,this.raise(w.TupleOptionalAfterType,this.state.lastTokStartLoc))):(f=this.startNodeAt(a),f.optional=c,this.raise(w.InvalidTupleMemberLabel,h),f.label=h,f.elementType=this.tsParseType()),h=this.finishNode(f,"TSNamedTupleMember")}else if(c){const f=this.startNodeAt(a);f.typeAnnotation=h,h=this.finishNode(f,"TSOptionalType")}if(i){const f=this.startNodeAt(e);f.typeAnnotation=h,h=this.finishNode(f,"TSRestType")}return h}tsParseParenthesizedType(){const e=this.startNode();return this.expect(10),e.typeAnnotation=this.tsParseType(),this.expect(11),this.finishNode(e,"TSParenthesizedType")}tsParseFunctionOrConstructorType(e,i){const a=this.startNode();return e==="TSConstructorType"&&(a.abstract=!!i,i&&this.next(),this.next()),this.tsInAllowConditionalTypesContext(()=>this.tsFillSignature(19,a)),this.finishNode(a,e)}tsParseLiteralTypeNode(){const e=this.startNode();switch(this.state.type){case 135:case 136:case 134:case 85:case 86:e.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode(e,"TSLiteralType")}tsParseTemplateLiteralType(){{const e=this.state.startLoc;let i=this.parseTemplateElement(!1);const a=[i];if(i.tail){const n=this.startNodeAt(e),o=this.startNodeAt(e);return o.expressions=[],o.quasis=a,n.literal=this.finishNode(o,"TemplateLiteral"),this.finishNode(n,"TSLiteralType")}else{const n=[];for(;!i.tail;)n.push(this.tsParseType()),this.readTemplateContinuation(),a.push(i=this.parseTemplateElement(!1));const o=this.startNodeAt(e);return o.types=n,o.quasis=a,this.finishNode(o,"TSTemplateLiteralType")}}}parseTemplateSubstitution(){return this.state.inType?this.tsParseType():super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){const e=this.tsParseThisTypeNode();return this.isContextual(116)&&!this.hasPrecedingLineBreak()?this.tsParseThisTypePredicate(e):e}tsParseNonArrayType(){switch(this.state.type){case 134:case 135:case 136:case 85:case 86:return this.tsParseLiteralTypeNode();case 53:if(this.state.value==="-"){const e=this.startNode(),i=this.lookahead();return i.type!==135&&i.type!==136&&this.unexpected(),e.literal=this.parseMaybeUnary(),this.finishNode(e,"TSLiteralType")}break;case 78:return this.tsParseThisTypeOrThisTypePredicate();case 87:return this.tsParseTypeQuery();case 83:return this.tsParseImportType();case 5:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.tsParseTupleType();case 10:if(!(this.optionFlags&1024)){const e=this.state.startLoc;this.next();const i=this.tsParseType();return this.expect(11),this.addExtra(i,"parenthesized",!0),this.addExtra(i,"parenStart",e.index),i}return this.tsParseParenthesizedType();case 25:case 24:return this.tsParseTemplateLiteralType();default:{const{type:e}=this.state;if(O(e)||e===88||e===84){const i=e===88?"TSVoidKeyword":e===84?"TSNullKeyword":xn(this.state.value);if(i!==void 0&&this.lookaheadCharCode()!==46){const a=this.startNode();return this.next(),this.finishNode(a,i)}return this.tsParseTypeReference()}}}this.unexpected()}tsParseArrayTypeOrHigher(){const{startLoc:e}=this.state;let i=this.tsParseNonArrayType();for(;!this.hasPrecedingLineBreak()&&this.eat(0);)if(this.match(3)){const a=this.startNodeAt(e);a.elementType=i,this.expect(3),i=this.finishNode(a,"TSArrayType")}else{const a=this.startNodeAt(e);a.objectType=i,a.indexType=this.tsParseType(),this.expect(3),i=this.finishNode(a,"TSIndexedAccessType")}return i}tsParseTypeOperator(){const e=this.startNode(),i=this.state.value;return this.next(),e.operator=i,e.typeAnnotation=this.tsParseTypeOperatorOrHigher(),i==="readonly"&&this.tsCheckTypeAnnotationForReadOnly(e),this.finishNode(e,"TSTypeOperator")}tsCheckTypeAnnotationForReadOnly(e){switch(e.typeAnnotation.type){case"TSTupleType":case"TSArrayType":return;default:this.raise(w.UnexpectedReadonly,e)}}tsParseInferType(){const e=this.startNode();this.expectContextual(115);const i=this.startNode();return i.name=this.tsParseTypeParameterName(),i.constraint=this.tsTryParse(()=>this.tsParseConstraintForInferType()),e.typeParameter=this.finishNode(i,"TSTypeParameter"),this.finishNode(e,"TSInferType")}tsParseConstraintForInferType(){if(this.eat(81)){const e=this.tsInDisallowConditionalTypesContext(()=>this.tsParseType());if(this.state.inDisallowConditionalTypesContext||!this.match(17))return e}}tsParseTypeOperatorOrHigher(){return Aa(this.state.type)&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(115)?this.tsParseInferType():this.tsInAllowConditionalTypesContext(()=>this.tsParseArrayTypeOrHigher())}tsParseUnionOrIntersectionType(e,i,a){const n=this.startNode(),o=this.eat(a),c=[];do c.push(i());while(this.eat(a));return c.length===1&&!o?c[0]:(n.types=c,this.finishNode(n,e))}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),45)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),43)}tsIsStartOfFunctionType(){return this.match(47)?!0:this.match(10)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(O(this.state.type)||this.match(78))return this.next(),!0;if(this.match(5)){const{errors:e}=this.state,i=e.length;try{return this.parseObjectLike(8,!0),e.length===i}catch{return!1}}if(this.match(0)){this.next();const{errors:e}=this.state,i=e.length;try{return super.parseBindingList(3,93,1),e.length===i}catch{return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){return this.next(),!!(this.match(11)||this.match(21)||this.tsSkipParameterStart()&&(this.match(14)||this.match(12)||this.match(17)||this.match(29)||this.match(11)&&(this.next(),this.match(19))))}tsParseTypeOrTypePredicateAnnotation(e){return this.tsInType(()=>{const i=this.startNode();this.expect(e);const a=this.startNode(),n=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(n&&this.match(78)){let h=this.tsParseThisTypeOrThisTypePredicate();return h.type==="TSThisType"?(a.parameterName=h,a.asserts=!0,a.typeAnnotation=null,h=this.finishNode(a,"TSTypePredicate")):(this.resetStartLocationFromNode(h,a),h.asserts=!0),i.typeAnnotation=h,this.finishNode(i,"TSTypeAnnotation")}const o=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!o)return n?(a.parameterName=this.parseIdentifier(),a.asserts=n,a.typeAnnotation=null,i.typeAnnotation=this.finishNode(a,"TSTypePredicate"),this.finishNode(i,"TSTypeAnnotation")):this.tsParseTypeAnnotation(!1,i);const c=this.tsParseTypeAnnotation(!1);return a.parameterName=o,a.typeAnnotation=c,a.asserts=n,i.typeAnnotation=this.finishNode(a,"TSTypePredicate"),this.finishNode(i,"TSTypeAnnotation")})}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(14))return this.tsParseTypeOrTypePredicateAnnotation(14)}tsTryParseTypeAnnotation(){if(this.match(14))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(14)}tsParseTypePredicatePrefix(){const e=this.parseIdentifier();if(this.isContextual(116)&&!this.hasPrecedingLineBreak())return this.next(),e}tsParseTypePredicateAsserts(){if(this.state.type!==109)return!1;const e=this.state.containsEsc;return this.next(),!O(this.state.type)&&!this.match(78)?!1:(e&&this.raise(p.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:"asserts"}),!0)}tsParseTypeAnnotation(e=!0,i=this.startNode()){return this.tsInType(()=>{e&&this.expect(14),i.typeAnnotation=this.tsParseType()}),this.finishNode(i,"TSTypeAnnotation")}tsParseType(){bi(this.state.inType);const e=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(81))return e;const i=this.startNodeAtNode(e);return i.checkType=e,i.extendsType=this.tsInDisallowConditionalTypesContext(()=>this.tsParseNonConditionalType()),this.expect(17),i.trueType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.expect(14),i.falseType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.finishNode(i,"TSConditionalType")}isAbstractConstructorSignature(){return this.isContextual(124)&&this.lookahead().type===77}tsParseNonConditionalType(){return this.tsIsStartOfFunctionType()?this.tsParseFunctionOrConstructorType("TSFunctionType"):this.match(77)?this.tsParseFunctionOrConstructorType("TSConstructorType"):this.isAbstractConstructorSignature()?this.tsParseFunctionOrConstructorType("TSConstructorType",!0):this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){this.getPluginOption("typescript","disallowAmbiguousJSXLike")&&this.raise(w.ReservedTypeAssertion,this.state.startLoc);const e=this.startNode();return e.typeAnnotation=this.tsInType(()=>(this.next(),this.match(75)?this.tsParseTypeReference():this.tsParseType())),this.expect(48),e.expression=this.parseMaybeUnary(),this.finishNode(e,"TSTypeAssertion")}tsParseHeritageClause(e){const i=this.state.startLoc,a=this.tsParseDelimitedList("HeritageClauseElement",()=>{{const n=super.parseExprSubscripts();ws(n)||this.raise(w.InvalidHeritageClauseType,n.loc.start,{token:e});const o=e==="extends"?"TSInterfaceHeritage":"TSClassImplements";if(n.type==="TSInstantiationExpression")return n.type=o,n;const c=this.startNodeAtNode(n);return c.expression=n,(this.match(47)||this.match(51))&&(c.typeArguments=this.tsParseTypeArgumentsInExpression()),this.finishNode(c,o)}});return a.length||this.raise(w.EmptyHeritageClauseType,i,{token:e}),a}tsParseInterfaceDeclaration(e,i={}){if(this.hasFollowingLineBreak())return null;this.expectContextual(129),i.declare&&(e.declare=!0),O(this.state.type)?(e.id=this.parseIdentifier(),this.checkIdentifier(e.id,130)):(e.id=null,this.raise(w.MissingInterfaceName,this.state.startLoc)),e.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(81)&&(e.extends=this.tsParseHeritageClause("extends"));const a=this.startNode();return a.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),e.body=this.finishNode(a,"TSInterfaceBody"),this.finishNode(e,"TSInterfaceDeclaration")}tsParseTypeAliasDeclaration(e){return e.id=this.parseIdentifier(),this.checkIdentifier(e.id,2),e.typeAnnotation=this.tsInType(()=>{if(e.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(29),this.isContextual(114)&&this.lookahead().type!==16){const i=this.startNode();return this.next(),this.finishNode(i,"TSIntrinsicKeyword")}return this.tsParseType()}),this.semicolon(),this.finishNode(e,"TSTypeAliasDeclaration")}tsInTopLevelContext(e){if(this.curContext()!==R.brace){const i=this.state.context;this.state.context=[i[0]];try{return e()}finally{this.state.context=i}}else return e()}tsInType(e){const i=this.state.inType;this.state.inType=!0;try{return e()}finally{this.state.inType=i}}tsInDisallowConditionalTypesContext(e){const i=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return e()}finally{this.state.inDisallowConditionalTypesContext=i}}tsInAllowConditionalTypesContext(e){const i=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return e()}finally{this.state.inDisallowConditionalTypesContext=i}}tsEatThenParseType(e){if(this.match(e))return this.tsNextThenParseType()}tsExpectThenParseType(e){return this.tsInType(()=>(this.expect(e),this.tsParseType()))}tsNextThenParseType(){return this.tsInType(()=>(this.next(),this.tsParseType()))}tsParseEnumMember(){const e=this.startNode();return e.id=this.match(134)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(29)&&(e.initializer=super.parseMaybeAssignAllowIn()),this.finishNode(e,"TSEnumMember")}tsParseEnumDeclaration(e,i={}){return i.const&&(e.const=!0),i.declare&&(e.declare=!0),this.expectContextual(126),e.id=this.parseIdentifier(),this.checkIdentifier(e.id,e.const?8971:8459),e.body=this.tsParseEnumBody(),this.finishNode(e,"TSEnumDeclaration")}tsParseEnumBody(){const e=this.startNode();return this.expect(5),e.members=this.tsParseDelimitedList("EnumMembers",this.tsParseEnumMember.bind(this)),this.expect(8),this.finishNode(e,"TSEnumBody")}tsParseModuleBlock(){const e=this.startNode();return this.scope.enter(0),this.expect(5),super.parseBlockOrModuleBlockBody(e.body=[],void 0,!0,8),this.scope.exit(),this.finishNode(e,"TSModuleBlock")}tsParseModuleOrNamespaceDeclaration(e,i=!1){return e.id=this.tsParseEntityName(1),e.id.type==="Identifier"&&this.checkIdentifier(e.id,1024),this.scope.enter(512),this.prodParam.enter(0),e.body=this.tsParseModuleBlock(),this.prodParam.exit(),this.scope.exit(),this.finishNode(e,"TSModuleDeclaration")}tsParseAmbientExternalModuleDeclaration(e){return this.isContextual(112)?(e.kind="global",e.id=this.parseIdentifier()):this.match(134)?(e.kind="module",e.id=super.parseStringLiteral(this.state.value)):this.unexpected(),this.match(5)?(this.scope.enter(512),this.prodParam.enter(0),e.body=this.tsParseModuleBlock(),this.prodParam.exit(),this.scope.exit()):this.semicolon(),this.finishNode(e,"TSModuleDeclaration")}tsParseImportEqualsDeclaration(e,i,a){e.id=i||this.parseIdentifier(),this.checkIdentifier(e.id,4096),this.expect(29);const n=this.tsParseModuleReference();return e.importKind==="type"&&n.type!=="TSExternalModuleReference"&&this.raise(w.ImportAliasHasImportType,n),e.moduleReference=n,this.semicolon(),this.finishNode(e,"TSImportEqualsDeclaration")}tsIsExternalModuleReference(){return this.isContextual(119)&&this.lookaheadCharCode()===40}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(0)}tsParseExternalModuleReference(){const e=this.startNode();return this.expectContextual(119),this.expect(10),this.match(134)||this.unexpected(),e.expression=super.parseExprAtom(),this.expect(11),this.sawUnambiguousESM=!0,this.finishNode(e,"TSExternalModuleReference")}tsLookAhead(e){const i=this.state.clone(),a=e();return this.state=i,a}tsTryParseAndCatch(e){const i=this.tryParse(a=>e()||a());if(!(i.aborted||!i.node))return i.error&&(this.state=i.failState),i.node}tsTryParse(e){const i=this.state.clone(),a=e();if(a!==void 0&&a!==!1)return a;this.state=i}tsTryParseDeclare(e){if(this.isLineTerminator())return;let i=this.state.type,a;return this.isContextual(100)&&(i=74,a="let"),this.tsInAmbientContext(()=>{switch(i){case 68:return e.declare=!0,super.parseFunctionStatement(e,!1,!1);case 80:return e.declare=!0,this.parseClass(e,!0,!1);case 126:return this.tsParseEnumDeclaration(e,{declare:!0});case 112:return this.tsParseAmbientExternalModuleDeclaration(e);case 75:case 74:return!this.match(75)||!this.isLookaheadContextual("enum")?(e.declare=!0,this.parseVarStatement(e,a||this.state.value,!0)):(this.expect(75),this.tsParseEnumDeclaration(e,{const:!0,declare:!0}));case 129:{const n=this.tsParseInterfaceDeclaration(e,{declare:!0});if(n)return n}default:if(O(i))return this.tsParseDeclaration(e,this.state.value,!0,null)}})}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.state.value,!0,null)}tsParseExpressionStatement(e,i,a){switch(i.name){case"declare":{const n=this.tsTryParseDeclare(e);return n&&(n.declare=!0),n}case"global":if(this.match(5)){this.scope.enter(512),this.prodParam.enter(0);const n=e;return n.kind="global",n.id=i,n.body=this.tsParseModuleBlock(),this.scope.exit(),this.prodParam.exit(),this.finishNode(n,"TSModuleDeclaration")}break;default:return this.tsParseDeclaration(e,i.name,!1,a)}}tsParseDeclaration(e,i,a,n){switch(i){case"abstract":if(this.tsCheckLineTerminator(a)&&(this.match(80)||O(this.state.type)))return this.tsParseAbstractDeclaration(e,n);break;case"module":if(this.tsCheckLineTerminator(a)){if(this.match(134))return this.tsParseAmbientExternalModuleDeclaration(e);if(O(this.state.type))return e.kind="module",this.tsParseModuleOrNamespaceDeclaration(e)}break;case"namespace":if(this.tsCheckLineTerminator(a)&&O(this.state.type))return e.kind="namespace",this.tsParseModuleOrNamespaceDeclaration(e);break;case"type":if(this.tsCheckLineTerminator(a)&&O(this.state.type))return this.tsParseTypeAliasDeclaration(e);break}}tsCheckLineTerminator(e){return e?this.hasFollowingLineBreak()?!1:(this.next(),!0):!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction(e){if(!this.match(47))return;const i=this.state.maybeInArrowParameters;this.state.maybeInArrowParameters=!0;const a=this.tsTryParseAndCatch(()=>{const n=this.startNodeAt(e);return n.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(n),n.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(19),n});if(this.state.maybeInArrowParameters=i,!!a)return super.parseArrowExpression(a,null,!0)}tsParseTypeArgumentsInExpression(){if(this.reScan_lt()===47)return this.tsParseTypeArguments()}tsParseTypeArguments(){const e=this.startNode();return e.params=this.tsInType(()=>this.tsInTopLevelContext(()=>(this.expect(47),this.tsParseDelimitedList("TypeParametersOrArguments",this.tsParseType.bind(this))))),e.params.length===0?this.raise(w.EmptyTypeArguments,e):!this.state.inType&&this.curContext()===R.brace&&this.reScan_lt_gt(),this.expect(48),this.finishNode(e,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return Sa(this.state.type)}isExportDefaultSpecifier(){return this.tsIsDeclarationStart()?!1:super.isExportDefaultSpecifier()}parseBindingElement(e,i){const a=i.length?i[0].loc.start:this.state.startLoc,n={};this.tsParseModifiers({allowedModifiers:["public","private","protected","override","readonly"]},n);const o=n.accessibility,c=n.override,h=n.readonly;!(e&4)&&(o||h||c)&&this.raise(w.UnexpectedParameterModifier,a);const l=this.parseMaybeDefault();e&2&&this.parseFunctionParamType(l);const u=this.parseMaybeDefault(l.loc.start,l);if(o||h||c){const f=this.startNodeAt(a);return i.length&&(f.decorators=i),o&&(f.accessibility=o),h&&(f.readonly=h),c&&(f.override=c),u.type!=="Identifier"&&u.type!=="AssignmentPattern"&&this.raise(w.UnsupportedParameterPropertyKind,f),f.parameter=u,this.finishNode(f,"TSParameterProperty")}return i.length&&(l.decorators=i),u}isSimpleParameter(e){return e.type==="TSParameterProperty"&&super.isSimpleParameter(e.parameter)||super.isSimpleParameter(e)}tsDisallowOptionalPattern(e){for(const i of e.params)i.type!=="Identifier"&&i.optional&&!this.state.isAmbientContext&&this.raise(w.PatternIsOptional,i)}setArrowFunctionParameters(e,i,a){super.setArrowFunctionParameters(e,i,a),this.tsDisallowOptionalPattern(e)}parseFunctionBodyAndFinish(e,i,a=!1){this.match(14)&&(e.returnType=this.tsParseTypeOrTypePredicateAnnotation(14));const n=i==="FunctionDeclaration"?"TSDeclareFunction":i==="ClassMethod"||i==="ClassPrivateMethod"?"TSDeclareMethod":void 0;return n&&!this.match(5)&&this.isLineTerminator()?this.finishNode(e,n):n==="TSDeclareFunction"&&this.state.isAmbientContext&&(this.raise(w.DeclareFunctionHasImplementation,e),e.declare)?super.parseFunctionBodyAndFinish(e,n,a):(this.tsDisallowOptionalPattern(e),super.parseFunctionBodyAndFinish(e,i,a))}registerFunctionStatementId(e){!e.body&&e.id?this.checkIdentifier(e.id,1024):super.registerFunctionStatementId(e)}tsCheckForInvalidTypeCasts(e){e.forEach(i=>{(i==null?void 0:i.type)==="TSTypeCastExpression"&&this.raise(w.UnexpectedTypeAnnotation,i.typeAnnotation)})}toReferencedList(e,i){return this.tsCheckForInvalidTypeCasts(e),e}parseArrayLike(e,i,a,n){const o=super.parseArrayLike(e,i,a,n);return o.type==="ArrayExpression"&&this.tsCheckForInvalidTypeCasts(o.elements),o}parseSubscript(e,i,a,n){if(!this.hasPrecedingLineBreak()&&this.match(35)){this.state.canStartJSXElement=!1,this.next();const c=this.startNodeAt(i);return c.expression=e,this.finishNode(c,"TSNonNullExpression")}let o=!1;if(this.match(18)&&this.lookaheadCharCode()===60){if(a)return n.stop=!0,e;n.optionalChainMember=o=!0,this.next()}if(this.match(47)||this.match(51)){let c;const h=this.tsTryParseAndCatch(()=>{if(!a&&this.atPossibleAsyncArrow(e)){const d=this.tsTryParseGenericAsyncArrowFunction(i);if(d)return d}const l=this.tsParseTypeArgumentsInExpression();if(!l)return;if(o&&!this.match(10)){c=this.state.curPosition();return}if(ls(this.state.type)){const d=super.parseTaggedTemplateExpression(e,i,n);return d.typeArguments=l,d}if(!a&&this.eat(10)){const d=this.startNodeAt(i);return d.callee=e,d.arguments=this.parseCallExpressionArguments(11),this.tsCheckForInvalidTypeCasts(d.arguments),d.typeArguments=l,n.optionalChainMember&&(d.optional=o),this.finishCallExpression(d,n.optionalChainMember)}const u=this.state.type;if(u===48||u===52||u!==10&&ht(u)&&!this.hasPrecedingLineBreak())return;const f=this.startNodeAt(i);return f.expression=e,f.typeArguments=l,this.finishNode(f,"TSInstantiationExpression")});if(c&&this.unexpected(c,10),h)return h.type==="TSInstantiationExpression"&&((this.match(16)||this.match(18)&&this.lookaheadCharCode()!==40)&&this.raise(w.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc),!this.match(16)&&!this.match(18)&&(h.expression=super.stopParseSubscript(e,n))),h}return super.parseSubscript(e,i,a,n)}parseNewCallee(e){var a;super.parseNewCallee(e);const{callee:i}=e;i.type==="TSInstantiationExpression"&&!((a=i.extra)!=null&&a.parenthesized)&&(e.typeArguments=i.typeArguments,e.callee=i.expression)}parseExprOp(e,i,a){let n;if(kt(58)>a&&!this.hasPrecedingLineBreak()&&(this.isContextual(93)||(n=this.isContextual(120)))){const o=this.startNodeAt(i);return o.expression=e,o.typeAnnotation=this.tsInType(()=>(this.next(),this.match(75)?(n&&this.raise(p.UnexpectedKeyword,this.state.startLoc,{keyword:"const"}),this.tsParseTypeReference()):this.tsParseType())),this.finishNode(o,n?"TSSatisfiesExpression":"TSAsExpression"),this.reScan_lt_gt(),this.parseExprOp(o,i,a)}return super.parseExprOp(e,i,a)}checkReservedWord(e,i,a,n){this.state.isAmbientContext||super.checkReservedWord(e,i,a,n)}checkImportReflection(e){super.checkImportReflection(e),e.module&&e.importKind!=="value"&&this.raise(w.ImportReflectionHasImportType,e.specifiers[0].loc.start)}checkDuplicateExports(){}isPotentialImportPhase(e){if(super.isPotentialImportPhase(e))return!0;if(this.isContextual(130)){const i=this.lookaheadCharCode();return e?i===123||i===42:i!==61}return!e&&this.isContextual(87)}applyImportPhase(e,i,a,n){super.applyImportPhase(e,i,a,n),i?e.exportKind=a==="type"?"type":"value":e.importKind=a==="type"||a==="typeof"?a:"value"}parseImport(e){if(this.match(134))return e.importKind="value",super.parseImport(e);let i;if(O(this.state.type)&&this.lookaheadCharCode()===61)return e.importKind="value",this.tsParseImportEqualsDeclaration(e);if(this.isContextual(130)){const a=this.parseMaybeImportPhase(e,!1);if(this.lookaheadCharCode()===61)return this.tsParseImportEqualsDeclaration(e,a);i=super.parseImportSpecifiersAndAfter(e,a)}else i=super.parseImport(e);return i.importKind==="type"&&i.specifiers.length>1&&i.specifiers[0].type==="ImportDefaultSpecifier"&&this.raise(w.TypeImportCannotSpecifyDefaultAndNamed,i),i}parseExport(e,i){if(this.match(83)){const a=this.startNode();this.next();let n=null;this.isContextual(130)&&this.isPotentialImportPhase(!1)?n=this.parseMaybeImportPhase(a,!1):a.importKind="value";const o=this.tsParseImportEqualsDeclaration(a,n,!0);return e.attributes=[],e.declaration=o,e.exportKind="value",e.source=null,e.specifiers=[],this.finishNode(e,"ExportNamedDeclaration")}else if(this.eat(29)){const a=e;return a.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(a,"TSExportAssignment")}else if(this.eatContextual(93)){const a=e;return this.expectContextual(128),a.id=this.parseIdentifier(),this.semicolon(),this.finishNode(a,"TSNamespaceExportDeclaration")}else return super.parseExport(e,i)}isAbstractClass(){return this.isContextual(124)&&this.lookahead().type===80}parseExportDefaultExpression(){if(this.isAbstractClass()){const e=this.startNode();return this.next(),e.abstract=!0,this.parseClass(e,!0,!0)}if(this.match(129)){const e=this.tsParseInterfaceDeclaration(this.startNode());if(e)return e}return super.parseExportDefaultExpression()}parseVarStatement(e,i,a=!1){const{isAmbientContext:n}=this.state,o=super.parseVarStatement(e,i,a||n);if(!n)return o;for(const{id:c,init:h}of o.declarations)h&&(i==="var"||i==="let"||c.typeAnnotation?this.raise(w.InitializerNotAllowedInAmbientContext,h):wn(h,this.hasPlugin("estree"))||this.raise(w.ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference,h));return o}parseStatementContent(e,i){if(this.match(75)&&this.isLookaheadContextual("enum")){const a=this.startNode();return this.expect(75),this.tsParseEnumDeclaration(a,{const:!0})}if(this.isContextual(126))return this.tsParseEnumDeclaration(this.startNode());if(this.isContextual(129)){const a=this.tsParseInterfaceDeclaration(this.startNode());if(a)return a}return super.parseStatementContent(e,i)}parseAccessModifier(){return this.tsParseModifier(["public","protected","private"])}tsHasSomeModifiers(e,i){return i.some(a=>gi(a)?e.accessibility===a:!!e[a])}tsIsStartOfStaticBlocks(){return this.isContextual(106)&&this.lookaheadCharCode()===123}parseClassMember(e,i,a){const n=["declare","private","public","protected","override","abstract","readonly","static"];this.tsParseModifiers({allowedModifiers:n,disallowedModifiers:["in","out"],stopOnStartOfClassStaticBlock:!0,errorTemplate:w.InvalidModifierOnTypeParameterPositions},i);const o=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(i,n)&&this.raise(w.StaticBlockCannotHaveModifier,this.state.curPosition()),super.parseClassStaticBlock(e,i)):this.parseClassMemberWithIsStatic(e,i,a,!!i.static)};i.declare?this.tsInAmbientContext(o):o()}parseClassMemberWithIsStatic(e,i,a,n){const o=this.tsTryParseIndexSignature(i);if(o){e.body.push(o),i.abstract&&this.raise(w.IndexSignatureHasAbstract,i),i.accessibility&&this.raise(w.IndexSignatureHasAccessibility,i,{modifier:i.accessibility}),i.declare&&this.raise(w.IndexSignatureHasDeclare,i),i.override&&this.raise(w.IndexSignatureHasOverride,i);return}!this.state.inAbstractClass&&i.abstract&&this.raise(w.NonAbstractClassHasAbstractMethod,i),i.override&&(a.hadSuperClass||this.raise(w.OverrideNotInSubClass,i)),super.parseClassMemberWithIsStatic(e,i,a,n)}parsePostMemberNameModifiers(e){this.eat(17)&&(e.optional=!0),e.readonly&&this.match(10)&&this.raise(w.ClassMethodHasReadonly,e),e.declare&&this.match(10)&&this.raise(w.ClassMethodHasDeclare,e)}parseExpressionStatement(e,i,a){return(i.type==="Identifier"?this.tsParseExpressionStatement(e,i,a):void 0)||super.parseExpressionStatement(e,i,a)}shouldParseExportDeclaration(){return this.tsIsDeclarationStart()?!0:super.shouldParseExportDeclaration()}parseConditional(e,i,a){if(!this.match(17))return e;if(this.state.maybeInArrowParameters){const n=this.lookaheadCharCode();if(n===44||n===61||n===58||n===41)return this.setOptionalParametersError(a),e}return super.parseConditional(e,i,a)}parseParenItem(e,i){const a=super.parseParenItem(e,i);if(this.eat(17)&&(a.optional=!0,this.resetEndLocation(e)),this.match(14)){const n=this.startNodeAt(i);return n.expression=e,n.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(n,"TSTypeCastExpression")}return e}parseExportDeclaration(e){if(!this.state.isAmbientContext&&this.isContextual(125))return this.tsInAmbientContext(()=>this.parseExportDeclaration(e));const i=this.state.startLoc,a=this.eatContextual(125);if(a&&(this.isContextual(125)||!this.shouldParseExportDeclaration()))throw this.raise(w.ExpectedAmbientAfterExportDeclare,this.state.startLoc);const o=O(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration(e);return o?((o.type==="TSInterfaceDeclaration"||o.type==="TSTypeAliasDeclaration"||a)&&(e.exportKind="type"),a&&o.type!=="TSImportEqualsDeclaration"&&(this.resetStartLocation(o,i),o.declare=!0),o):null}parseClassId(e,i,a,n){if((!i||a)&&this.isContextual(113))return;super.parseClassId(e,i,a,e.declare?1024:8331);const o=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);o&&(e.typeParameters=o)}parseClassPropertyAnnotation(e){e.optional||(this.eat(35)?e.definite=!0:this.eat(17)&&(e.optional=!0));const i=this.tsTryParseTypeAnnotation();i&&(e.typeAnnotation=i)}parseClassProperty(e){if(this.parseClassPropertyAnnotation(e),this.state.isAmbientContext&&!(e.readonly&&!e.typeAnnotation)&&this.match(29)&&this.raise(w.DeclareClassFieldHasInitializer,this.state.startLoc),e.abstract&&this.match(29)){const{key:i}=e;this.raise(w.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:i.type==="Identifier"&&!e.computed?i.name:`[${this.input.slice(this.offsetToSourcePos(i.start),this.offsetToSourcePos(i.end))}]`})}return super.parseClassProperty(e)}parseClassPrivateProperty(e){return e.abstract&&this.raise(w.PrivateElementHasAbstract,e),e.accessibility&&this.raise(w.PrivateElementHasAccessibility,e,{modifier:e.accessibility}),this.parseClassPropertyAnnotation(e),super.parseClassPrivateProperty(e)}parseClassAccessorProperty(e){return this.parseClassPropertyAnnotation(e),e.optional&&this.raise(w.AccessorCannotBeOptional,e),super.parseClassAccessorProperty(e)}pushClassMethod(e,i,a,n,o,c){const h=this.tsTryParseTypeParameters(this.tsParseConstModifier);h&&o&&this.raise(w.ConstructorHasTypeParameters,h);const{declare:l=!1,kind:u}=i;l&&(u==="get"||u==="set")&&this.raise(w.DeclareAccessor,i,{kind:u}),h&&(i.typeParameters=h),super.pushClassMethod(e,i,a,n,o,c)}pushClassPrivateMethod(e,i,a,n){const o=this.tsTryParseTypeParameters(this.tsParseConstModifier);o&&(i.typeParameters=o),super.pushClassPrivateMethod(e,i,a,n)}declareClassPrivateMethodInScope(e,i){e.type!=="TSDeclareMethod"&&(e.type==="MethodDefinition"&&e.value.body==null||super.declareClassPrivateMethodInScope(e,i))}parseClassSuper(e){super.parseClassSuper(e),e.superClass&&(this.match(47)||this.match(51))&&(e.superTypeArguments=this.tsParseTypeArgumentsInExpression()),this.eatContextual(113)&&(e.implements=this.tsParseHeritageClause("implements"))}parseObjPropValue(e,i,a,n,o,c,h){const l=this.tsTryParseTypeParameters(this.tsParseConstModifier);return l&&(e.typeParameters=l),super.parseObjPropValue(e,i,a,n,o,c,h)}parseFunctionParams(e,i){const a=this.tsTryParseTypeParameters(this.tsParseConstModifier);a&&(e.typeParameters=a),super.parseFunctionParams(e,i)}parseVarId(e,i){super.parseVarId(e,i),e.id.type==="Identifier"&&!this.hasPrecedingLineBreak()&&this.eat(35)&&(e.definite=!0);const a=this.tsTryParseTypeAnnotation();a&&(e.id.typeAnnotation=a,this.resetEndLocation(e.id))}parseAsyncArrowFromCallExpression(e,i){return this.match(14)&&(e.returnType=this.tsParseTypeAnnotation()),super.parseAsyncArrowFromCallExpression(e,i)}parseMaybeAssign(e,i){let a,n,o;if(this.hasPlugin("jsx")&&(this.match(143)||this.match(47))){if(a=this.state.clone(),n=this.tryParse(()=>super.parseMaybeAssign(e,i),a),!n.error)return n.node;const{context:l}=this.state,u=l[l.length-1];(u===R.j_oTag||u===R.j_expr)&&l.pop()}if(!(n!=null&&n.error)&&!this.match(47))return super.parseMaybeAssign(e,i);(!a||a===this.state)&&(a=this.state.clone());let c;const h=this.tryParse(l=>{var f,d;c=this.tsParseTypeParameters(this.tsParseConstModifier);const u=super.parseMaybeAssign(e,i);if((u.type!=="ArrowFunctionExpression"||(f=u.extra)!=null&&f.parenthesized)&&l(),(c==null?void 0:c.params.length)!==0&&this.resetStartLocationFromNode(u,c),u.typeParameters=c,this.hasPlugin("jsx")&&u.typeParameters.params.length===1&&!((d=u.typeParameters.extra)!=null&&d.trailingComma)){const P=u.typeParameters.params[0];P.constraint||this.raise(w.SingleTypeParameterWithoutTrailingComma,ce(P.loc.end,1),{typeParameterName:P.name.name})}return u},a);if(!h.error&&!h.aborted)return c&&this.reportReservedArrowTypeParam(c),h.node;if(!n&&(bi(!this.hasPlugin("jsx")),o=this.tryParse(()=>super.parseMaybeAssign(e,i),a),!o.error))return o.node;if(n!=null&&n.node)return this.state=n.failState,n.node;if(h.node)return this.state=h.failState,c&&this.reportReservedArrowTypeParam(c),h.node;if(o!=null&&o.node)return this.state=o.failState,o.node;throw(n==null?void 0:n.error)||h.error||(o==null?void 0:o.error)}reportReservedArrowTypeParam(e){var i;e.params.length===1&&!e.params[0].constraint&&!((i=e.extra)!=null&&i.trailingComma)&&this.getPluginOption("typescript","disallowAmbiguousJSXLike")&&this.raise(w.ReservedArrowTypeParam,e)}parseMaybeUnary(e,i){return!this.hasPlugin("jsx")&&this.match(47)?this.tsParseTypeAssertion():super.parseMaybeUnary(e,i)}parseArrow(e){if(this.match(14)){const i=this.tryParse(a=>{const n=this.tsParseTypeOrTypePredicateAnnotation(14);return(this.canInsertSemicolon()||!this.match(19))&&a(),n});if(i.aborted)return;i.thrown||(i.error&&(this.state=i.failState),e.returnType=i.node)}return super.parseArrow(e)}parseFunctionParamType(e){this.eat(17)&&(e.optional=!0);const i=this.tsTryParseTypeAnnotation();return i&&(e.typeAnnotation=i),this.resetEndLocation(e),e}isAssignable(e,i){switch(e.type){case"TSTypeCastExpression":return this.isAssignable(e.expression,i);case"TSParameterProperty":return!0;default:return super.isAssignable(e,i)}}toAssignable(e,i=!1){switch(e.type){case"ParenthesizedExpression":this.toAssignableParenthesizedExpression(e,i);break;case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":i?this.expressionScope.recordArrowParameterBindingError(w.UnexpectedTypeCastInParameter,e):this.raise(w.UnexpectedTypeCastInParameter,e),this.toAssignable(e.expression,i);break;case"AssignmentExpression":!i&&e.left.type==="TSTypeCastExpression"&&(e.left=this.typeCastToParameter(e.left));default:super.toAssignable(e,i)}}toAssignableParenthesizedExpression(e,i){switch(e.expression.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"ParenthesizedExpression":this.toAssignable(e.expression,i);break;default:super.toAssignable(e,i)}}checkToRestConversion(e,i){switch(e.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":this.checkToRestConversion(e.expression,!1);break;default:super.checkToRestConversion(e,i)}}isValidLVal(e,i,a){switch(e){case"TSTypeCastExpression":return!0;case"TSParameterProperty":return"parameter";case"TSNonNullExpression":return"expression";case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":return(a!==64||!i)&&["expression",!0];default:return super.isValidLVal(e,i,a)}}parseBindingAtom(){return this.state.type===78?this.parseIdentifier(!0):super.parseBindingAtom()}parseMaybeDecoratorArguments(e,i){if(this.match(47)||this.match(51)){const a=this.tsParseTypeArgumentsInExpression();if(this.match(10)){const n=super.parseMaybeDecoratorArguments(e,i);return n.typeArguments=a,n}this.unexpected(null,10)}return super.parseMaybeDecoratorArguments(e,i)}checkCommaAfterRest(e){return this.state.isAmbientContext&&this.match(12)&&this.lookaheadCharCode()===e?(this.next(),!1):super.checkCommaAfterRest(e)}isClassMethod(){return this.match(47)||super.isClassMethod()}isClassProperty(){return this.match(35)||this.match(14)||super.isClassProperty()}parseMaybeDefault(e,i){const a=super.parseMaybeDefault(e,i);return a.type==="AssignmentPattern"&&a.typeAnnotation&&a.right.start<a.typeAnnotation.start&&this.raise(w.TypeAnnotationAfterAssign,a.typeAnnotation),a}getTokenFromCode(e){if(this.state.inType){if(e===62){this.finishOp(48,1);return}if(e===60){this.finishOp(47,1);return}}super.getTokenFromCode(e)}reScan_lt_gt(){const{type:e}=this.state;e===47?(this.state.pos-=1,this.readToken_lt()):e===48&&(this.state.pos-=1,this.readToken_gt())}reScan_lt(){const{type:e}=this.state;return e===51?(this.state.pos-=2,this.finishOp(47,1),47):e}toAssignableListItem(e,i,a){const n=e[i];n.type==="TSTypeCastExpression"&&(e[i]=this.typeCastToParameter(n)),super.toAssignableListItem(e,i,a)}typeCastToParameter(e){return e.expression.typeAnnotation=e.typeAnnotation,this.resetEndLocation(e.expression,e.typeAnnotation.loc.end),e.expression}shouldParseArrow(e){return this.match(14)?e.every(i=>this.isAssignable(i,!0)):super.shouldParseArrow(e)}shouldParseAsyncArrow(){return this.match(14)||super.shouldParseAsyncArrow()}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName(e){if(this.match(47)||this.match(51)){const i=this.tsTryParseAndCatch(()=>this.tsParseTypeArgumentsInExpression());i&&(e.typeArguments=i)}return super.jsxParseOpeningElementAfterName(e)}getGetterSetterExpectedParamCount(e){const i=super.getGetterSetterExpectedParamCount(e),n=this.getObjectOrClassMethodParams(e)[0];return n&&this.isThisParam(n)?i+1:i}parseCatchClauseParam(){const e=super.parseCatchClauseParam(),i=this.tsTryParseTypeAnnotation();return i&&(e.typeAnnotation=i,this.resetEndLocation(e)),e}tsInAmbientContext(e){const{isAmbientContext:i,strict:a}=this.state;this.state.isAmbientContext=!0,this.state.strict=!1;try{return e()}finally{this.state.isAmbientContext=i,this.state.strict=a}}parseClass(e,i,a){const n=this.state.inAbstractClass;this.state.inAbstractClass=!!e.abstract;try{return super.parseClass(e,i,a)}finally{this.state.inAbstractClass=n}}tsParseAbstractDeclaration(e,i){if(this.match(80))return e.abstract=!0,this.maybeTakeDecorators(i,this.parseClass(e,!0,!1));if(this.isContextual(129)){if(!this.hasFollowingLineBreak())return e.abstract=!0,this.raise(w.NonClassMethodPropertyHasAbstractModifier,e),this.tsParseInterfaceDeclaration(e)}else this.unexpected(null,80)}parseMethod(e,i,a,n,o,c,h){const l=super.parseMethod(e,i,a,n,o,c,h);if((l.abstract||l.type==="TSAbstractMethodDefinition")&&(this.hasPlugin("estree")?l.value:l).body){const{key:d}=l;this.raise(w.AbstractMethodHasImplementation,l,{methodName:d.type==="Identifier"&&!l.computed?d.name:`[${this.input.slice(this.offsetToSourcePos(d.start),this.offsetToSourcePos(d.end))}]`})}return l}tsParseTypeParameterName(){return this.parseIdentifier()}shouldParseAsAmbientContext(){return!!this.getPluginOption("typescript","dts")}parse(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.parse()}getExpression(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.getExpression()}parseExportSpecifier(e,i,a,n){return!i&&n?(this.parseTypeOnlyImportExportSpecifier(e,!1,a),this.finishNode(e,"ExportSpecifier")):(e.exportKind="value",super.parseExportSpecifier(e,i,a,n))}parseImportSpecifier(e,i,a,n,o){return!i&&n?(this.parseTypeOnlyImportExportSpecifier(e,!0,a),this.finishNode(e,"ImportSpecifier")):(e.importKind="value",super.parseImportSpecifier(e,i,a,n,a?4098:4096))}parseTypeOnlyImportExportSpecifier(e,i,a){const n=i?"imported":"local",o=i?"local":"exported";let c=e[n],h,l=!1,u=!0;const f=c.loc.start;if(this.isContextual(93)){const P=this.parseIdentifier();if(this.isContextual(93)){const S=this.parseIdentifier();ue(this.state.type)?(l=!0,c=P,h=i?this.parseIdentifier():this.parseModuleExportName(),u=!1):(h=S,u=!1)}else ue(this.state.type)?(u=!1,h=i?this.parseIdentifier():this.parseModuleExportName()):(l=!0,c=P)}else ue(this.state.type)&&(l=!0,i?(c=this.parseIdentifier(!0),this.isContextual(93)||this.checkReservedWord(c.name,c.loc.start,!0,!0)):c=this.parseModuleExportName());l&&a&&this.raise(i?w.TypeModifierIsUsedInTypeImports:w.TypeModifierIsUsedInTypeExports,f),e[n]=c,e[o]=h;const d=i?"importKind":"exportKind";e[d]=l?"type":"value",u&&this.eatContextual(93)&&(e[o]=i?this.parseIdentifier():this.parseModuleExportName()),e[o]||(e[o]=this.cloneIdentifier(e[n])),i&&this.checkIdentifier(e[o],l?4098:4096)}fillOptionalPropertiesForTSESLint(e){switch(e.type){case"ExpressionStatement":e.directive??(e.directive=void 0);return;case"RestElement":e.value=void 0;case"Identifier":case"ArrayPattern":case"AssignmentPattern":case"ObjectPattern":e.decorators??(e.decorators=[]),e.optional??(e.optional=!1),e.typeAnnotation??(e.typeAnnotation=void 0);return;case"TSParameterProperty":e.accessibility??(e.accessibility=void 0),e.decorators??(e.decorators=[]),e.override??(e.override=!1),e.readonly??(e.readonly=!1),e.static??(e.static=!1);return;case"TSEmptyBodyFunctionExpression":e.body=null;case"TSDeclareFunction":case"FunctionDeclaration":case"FunctionExpression":case"ClassMethod":case"ClassPrivateMethod":e.declare??(e.declare=!1),e.returnType??(e.returnType=void 0),e.typeParameters??(e.typeParameters=void 0);return;case"Property":e.optional??(e.optional=!1);return;case"TSMethodSignature":case"TSPropertySignature":e.optional??(e.optional=!1);case"TSIndexSignature":e.accessibility??(e.accessibility=void 0),e.readonly??(e.readonly=!1),e.static??(e.static=!1);return;case"TSAbstractPropertyDefinition":case"PropertyDefinition":case"TSAbstractAccessorProperty":case"AccessorProperty":e.declare??(e.declare=!1),e.definite??(e.definite=!1),e.readonly??(e.readonly=!1),e.typeAnnotation??(e.typeAnnotation=void 0);case"TSAbstractMethodDefinition":case"MethodDefinition":e.accessibility??(e.accessibility=void 0),e.decorators??(e.decorators=[]),e.override??(e.override=!1),e.optional??(e.optional=!1);return;case"ClassExpression":e.id??(e.id=null);case"ClassDeclaration":e.abstract??(e.abstract=!1),e.declare??(e.declare=!1),e.decorators??(e.decorators=[]),e.implements??(e.implements=[]),e.superTypeArguments??(e.superTypeArguments=void 0),e.typeParameters??(e.typeParameters=void 0);return;case"TSTypeAliasDeclaration":case"VariableDeclaration":e.declare??(e.declare=!1);return;case"VariableDeclarator":e.definite??(e.definite=!1);return;case"TSEnumDeclaration":e.const??(e.const=!1),e.declare??(e.declare=!1);return;case"TSEnumMember":e.computed??(e.computed=!1);return;case"TSImportType":e.qualifier??(e.qualifier=null),e.options??(e.options=null),e.typeArguments??(e.typeArguments=null);return;case"TSInterfaceDeclaration":e.declare??(e.declare=!1),e.extends??(e.extends=[]);return;case"TSModuleDeclaration":e.declare??(e.declare=!1),e.global??(e.global=e.kind==="global");return;case"TSTypeParameter":e.const??(e.const=!1),e.in??(e.in=!1),e.out??(e.out=!1);return}}};function gn(r){if(r.type!=="MemberExpression")return!1;const{computed:t,property:s}=r;return t&&s.type!=="StringLiteral"&&(s.type!=="TemplateLiteral"||s.expressions.length>0)?!1:Ti(r.object)}function wn(r,t){var e;const{type:s}=r;if((e=r.extra)!=null&&e.parenthesized)return!1;if(t){if(s==="Literal"){const{value:i}=r;if(typeof i=="string"||typeof i=="boolean")return!0}}else if(s==="StringLiteral"||s==="BooleanLiteral")return!0;return!!(wi(r,t)||Tn(r,t)||s==="TemplateLiteral"&&r.expressions.length===0||gn(r))}function wi(r,t){return t?r.type==="Literal"&&(typeof r.value=="number"||"bigint"in r):r.type==="NumericLiteral"||r.type==="BigIntLiteral"}function Tn(r,t){if(r.type==="UnaryExpression"){const{operator:s,argument:e}=r;if(s==="-"&&wi(e,t))return!0}return!1}function Ti(r){return r.type==="Identifier"?!0:r.type!=="MemberExpression"||r.computed?!1:Ti(r.object)}const Ai=ye`placeholders`({ClassNameIsRequired:"A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."});var An=r=>class extends r{parsePlaceholder(s){if(this.match(133)){const e=this.startNode();return this.next(),this.assertNoSpace(),e.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(133),this.finishPlaceholder(e,s)}}finishPlaceholder(s,e){let i=s;return(!i.expectedNode||!i.type)&&(i=this.finishNode(i,"Placeholder")),i.expectedNode=e,i}getTokenFromCode(s){s===37&&this.input.charCodeAt(this.state.pos+1)===37?this.finishOp(133,2):super.getTokenFromCode(s)}parseExprAtom(s){return this.parsePlaceholder("Expression")||super.parseExprAtom(s)}parseIdentifier(s){return this.parsePlaceholder("Identifier")||super.parseIdentifier(s)}checkReservedWord(s,e,i,a){s!==void 0&&super.checkReservedWord(s,e,i,a)}cloneIdentifier(s){const e=super.cloneIdentifier(s);return e.type==="Placeholder"&&(e.expectedNode=s.expectedNode),e}cloneStringLiteral(s){return s.type==="Placeholder"?this.cloneIdentifier(s):super.cloneStringLiteral(s)}parseBindingAtom(){return this.parsePlaceholder("Pattern")||super.parseBindingAtom()}isValidLVal(s,e,i){return s==="Placeholder"||super.isValidLVal(s,e,i)}toAssignable(s,e){s&&s.type==="Placeholder"&&s.expectedNode==="Expression"?s.expectedNode="Pattern":super.toAssignable(s,e)}chStartsBindingIdentifier(s,e){return!!(super.chStartsBindingIdentifier(s,e)||this.lookahead().type===133)}verifyBreakContinue(s,e){s.label&&s.label.type==="Placeholder"||super.verifyBreakContinue(s,e)}parseExpressionStatement(s,e){var a;if(e.type!=="Placeholder"||(a=e.extra)!=null&&a.parenthesized)return super.parseExpressionStatement(s,e);if(this.match(14)){const n=s;return n.label=this.finishPlaceholder(e,"Identifier"),this.next(),n.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(n,"LabeledStatement")}this.semicolon();const i=s;return i.name=e.name,this.finishPlaceholder(i,"Statement")}parseBlock(s,e,i){return this.parsePlaceholder("BlockStatement")||super.parseBlock(s,e,i)}parseFunctionId(s){return this.parsePlaceholder("Identifier")||super.parseFunctionId(s)}parseClass(s,e,i){const a=e?"ClassDeclaration":"ClassExpression";this.next();const n=this.state.strict,o=this.parsePlaceholder("Identifier");if(o)if(this.match(81)||this.match(133)||this.match(5))s.id=o;else{if(i||!e)return s.id=null,s.body=this.finishPlaceholder(o,"ClassBody"),this.finishNode(s,a);throw this.raise(Ai.ClassNameIsRequired,this.state.startLoc)}else this.parseClassId(s,e,i);return super.parseClassSuper(s),s.body=this.parsePlaceholder("ClassBody")||super.parseClassBody(!!s.superClass,n),this.finishNode(s,a)}parseExport(s,e){const i=this.parsePlaceholder("Identifier");if(!i)return super.parseExport(s,e);const a=s;if(!this.isContextual(98)&&!this.match(12))return a.specifiers=[],a.source=null,a.declaration=this.finishPlaceholder(i,"Declaration"),this.finishNode(a,"ExportNamedDeclaration");this.expectPlugin("exportDefaultFrom");const n=this.startNode();return n.exported=i,a.specifiers=[this.finishNode(n,"ExportDefaultSpecifier")],super.parseExport(a,e)}isExportDefaultSpecifier(){if(this.match(65)){const s=this.nextTokenStart();if(this.isUnparsedContextual(s,"from")&&this.input.startsWith(Ce(133),this.nextTokenStartSince(s+4)))return!0}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier(s,e){var i;return(i=s.specifiers)!=null&&i.length?!0:super.maybeParseExportDefaultSpecifier(s,e)}checkExport(s){const{specifiers:e}=s;e!=null&&e.length&&(s.specifiers=e.filter(i=>i.exported.type==="Placeholder")),super.checkExport(s),s.specifiers=e}parseImport(s){const e=this.parsePlaceholder("Identifier");if(!e)return super.parseImport(s);if(s.specifiers=[],!this.isContextual(98)&&!this.match(12))return s.source=this.finishPlaceholder(e,"StringLiteral"),this.semicolon(),this.finishNode(s,"ImportDeclaration");const i=this.startNodeAtNode(e);return i.local=e,s.specifiers.push(this.finishNode(i,"ImportDefaultSpecifier")),this.eat(12)&&(this.maybeParseStarImportSpecifier(s)||this.parseNamedImportSpecifiers(s)),this.expectContextual(98),s.source=this.parseImportSource(),this.semicolon(),this.finishNode(s,"ImportDeclaration")}parseImportSource(){return this.parsePlaceholder("StringLiteral")||super.parseImportSource()}assertNoSpace(){this.state.start>this.offsetToSourcePos(this.state.lastTokEndLoc.index)&&this.raise(Ai.UnexpectedSpace,this.state.lastTokEndLoc)}},Sn=r=>class extends r{parseV8Intrinsic(){if(this.match(54)){const s=this.state.startLoc,e=this.startNode();if(this.next(),O(this.state.type)){const i=this.parseIdentifierName(),a=this.createIdentifier(e,i);if(this.castNodeTo(a,"V8IntrinsicIdentifier"),this.match(10))return a}this.unexpected(s)}}parseExprAtom(s){return this.parseV8Intrinsic()||super.parseExprAtom(s)}};const Si=["fsharp","hack"],Ii=["^^","@@","^","%","#"];function In(r){if(r.has("decorators")){if(r.has("decorators-legacy"))throw new Error("Cannot use the decorators and decorators-legacy plugin together");const t=r.get("decorators").decoratorsBeforeExport;if(t!=null&&typeof t!="boolean")throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");const s=r.get("decorators").allowCallParenthesized;if(s!=null&&typeof s!="boolean")throw new Error("'allowCallParenthesized' must be a boolean.")}if(r.has("flow")&&r.has("typescript"))throw new Error("Cannot combine flow and typescript plugins.");if(r.has("placeholders")&&r.has("v8intrinsic"))throw new Error("Cannot combine placeholders and v8intrinsic plugins.");if(r.has("pipelineOperator")){const t=r.get("pipelineOperator").proposal;if(!Si.includes(t)){const s=Si.map(e=>`"${e}"`).join(", ");throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${s}.`)}if(t==="hack"){if(r.has("placeholders"))throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");if(r.has("v8intrinsic"))throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");const s=r.get("pipelineOperator").topicToken;if(!Ii.includes(s)){const e=Ii.map(i=>`"${i}"`).join(", ");throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${e}.`)}}}if(r.has("moduleAttributes"))throw new Error("`moduleAttributes` has been removed in Babel 8, please migrate to import attributes instead.");if(r.has("importAssertions"))throw new Error("`importAssertions` has been removed in Babel 8, please use import attributes instead. To use the non-standard `assert` syntax you can enable the `deprecatedImportAssert` parser plugin.");if(!r.has("deprecatedImportAssert")&&r.has("importAttributes")&&r.get("importAttributes").deprecatedAssertSyntax)throw new Error("The 'importAttributes' plugin has been removed in Babel 8. If you need to enable support for the deprecated `assert` syntax, you can enable the `deprecatedImportAssert` parser plugin.");if(r.has("recordAndTuple"))throw new Error("The 'recordAndTuple' plugin has been removed in Babel 8. Please remove it from your configuration.");if(r.has("asyncDoExpressions")&&!r.has("doExpressions")){const t=new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");throw t.missingPlugins="doExpressions",t}if(r.has("optionalChainingAssign")&&r.get("optionalChainingAssign").version!=="2023-07")throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.");{if(r.has("decimal"))throw new Error("The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.");if(r.has("importReflection"))throw new Error("The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.")}}const Ei={estree:fa,jsx:Ja,flow:za,typescript:bn,v8intrinsic:Sn,placeholders:An},En=Object.keys(Ei);class Cn extends mn{checkProto(t,s,e,i){if(t.type==="SpreadElement"||this.isObjectMethod(t)||t.computed||t.shorthand)return e;const a=t.key;return(a.type==="Identifier"?a.name:a.value)==="__proto__"?s?(this.raise(p.RecordNoProto,a),!0):(e&&(i?i.doubleProtoLoc===null&&(i.doubleProtoLoc=a.loc.start):this.raise(p.DuplicateProto,a)),!0):e}shouldExitDescending(t,s){return t.type==="ArrowFunctionExpression"&&this.offsetToSourcePos(t.start)===s}getExpression(){if(this.enterInitialScopes(),this.nextToken(),this.match(140))throw this.raise(p.ParseExpressionEmptyInput,this.state.startLoc);const t=this.parseExpression();if(!this.match(140))throw this.raise(p.ParseExpressionExpectsEOF,this.state.startLoc,{unexpected:this.input.codePointAt(this.state.start)});return this.finalizeRemainingComments(),t.comments=this.comments,t.errors=this.state.errors,this.optionFlags&256&&(t.tokens=this.tokens),t}parseExpression(t,s){return t?this.disallowInAnd(()=>this.parseExpressionBase(s)):this.allowInAnd(()=>this.parseExpressionBase(s))}parseExpressionBase(t){const s=this.state.startLoc,e=this.parseMaybeAssign(t);if(this.match(12)){const i=this.startNodeAt(s);for(i.expressions=[e];this.eat(12);)i.expressions.push(this.parseMaybeAssign(t));return this.toReferencedList(i.expressions),this.finishNode(i,"SequenceExpression")}return e}parseMaybeAssignDisallowIn(t,s){return this.disallowInAnd(()=>this.parseMaybeAssign(t,s))}parseMaybeAssignAllowIn(t,s){return this.allowInAnd(()=>this.parseMaybeAssign(t,s))}setOptionalParametersError(t){t.optionalParametersLoc=this.state.startLoc}parseMaybeAssign(t,s){const e=this.state.startLoc,i=this.isContextual(108);if(i&&this.prodParam.hasYield){this.next();let c=this.parseYield(e);return s&&(c=s.call(this,c,e)),c}let a;t?a=!1:(t=new Lt,a=!0);const{type:n}=this.state;(n===10||O(n))&&(this.state.potentialArrowAt=this.state.start);let o=this.parseMaybeConditional(t);if(s&&(o=s.call(this,o,e)),Pa(this.state.type)){const c=this.startNodeAt(e),h=this.state.value;if(c.operator=h,this.match(29)){this.toAssignable(o,!0),c.left=o;const l=e.index;t.doubleProtoLoc!=null&&t.doubleProtoLoc.index>=l&&(t.doubleProtoLoc=null),t.shorthandAssignLoc!=null&&t.shorthandAssignLoc.index>=l&&(t.shorthandAssignLoc=null),t.privateKeyLoc!=null&&t.privateKeyLoc.index>=l&&(this.checkDestructuringPrivate(t),t.privateKeyLoc=null)}else c.left=o;return this.next(),c.right=this.parseMaybeAssign(),this.checkLVal(o,this.finishNode(c,"AssignmentExpression")),c}else a&&this.checkExpressionErrors(t,!0);if(i){const{type:c}=this.state;if((this.hasPlugin("v8intrinsic")?ht(c):ht(c)&&!this.match(54))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(p.YieldNotInGeneratorFunction,e),this.parseYield(e)}return o}parseMaybeConditional(t){const s=this.state.startLoc,e=this.state.potentialArrowAt,i=this.parseExprOps(t);return this.shouldExitDescending(i,e)?i:this.parseConditional(i,s,t)}parseConditional(t,s,e){if(this.eat(17)){const i=this.startNodeAt(s);return i.test=t,i.consequent=this.parseMaybeAssignAllowIn(),this.expect(14),i.alternate=this.parseMaybeAssign(),this.finishNode(i,"ConditionalExpression")}return t}parseMaybeUnaryOrPrivate(t){return this.match(139)?this.parsePrivateName():this.parseMaybeUnary(t)}parseExprOps(t){const s=this.state.startLoc,e=this.state.potentialArrowAt,i=this.parseMaybeUnaryOrPrivate(t);return this.shouldExitDescending(i,e)?i:this.parseExprOp(i,s,-1)}parseExprOp(t,s,e){if(this.isPrivateName(t)){const a=this.getPrivateNameSV(t);(e>=kt(58)||!this.prodParam.hasIn||!this.match(58))&&this.raise(p.PrivateInExpectedIn,t,{identifierName:a}),this.classScope.usePrivateName(a,t.loc.start)}const i=this.state.type;if(ga(i)&&(this.prodParam.hasIn||!this.match(58))){let a=kt(i);if(a>e){if(i===39){if(this.expectPlugin("pipelineOperator"),this.state.inFSharpPipelineDirectBody)return t;this.checkPipelineAtInfixOperator(t,s)}const n=this.startNodeAt(s);n.left=t,n.operator=this.state.value;const o=i===41||i===42,c=i===40;c&&(a=kt(42)),this.next(),n.right=this.parseExprOpRightExpr(i,a);const h=this.finishNode(n,o||c?"LogicalExpression":"BinaryExpression"),l=this.state.type;if(c&&(l===41||l===42)||o&&l===40)throw this.raise(p.MixingCoalesceWithLogical,this.state.startLoc);return this.parseExprOp(h,s,e)}}return t}parseExprOpRightExpr(t,s){switch(this.state.startLoc,t){case 39:switch(this.getPluginOption("pipelineOperator","proposal")){case"hack":return this.withTopicBindingContext(()=>this.parseHackPipeBody());case"fsharp":return this.withSoloAwaitPermittingContext(()=>this.parseFSharpPipelineBody(s))}default:return this.parseExprOpBaseRightExpr(t,s)}}parseExprOpBaseRightExpr(t,s){const e=this.state.startLoc;return this.parseExprOp(this.parseMaybeUnaryOrPrivate(),e,Ia(t)?s-1:s)}parseHackPipeBody(){var i;const{startLoc:t}=this.state,s=this.parseMaybeAssign();return na.has(s.type)&&!((i=s.extra)!=null&&i.parenthesized)&&this.raise(p.PipeUnparenthesizedBody,t,{type:s.type}),this.topicReferenceWasUsedInCurrentContext()||this.raise(p.PipeTopicUnused,t),s}checkExponentialAfterUnary(t){this.match(57)&&this.raise(p.UnexpectedTokenUnaryExponentiation,t.argument)}parseMaybeUnary(t,s){const e=this.state.startLoc,i=this.isContextual(96);if(i&&this.recordAwaitIfAllowed()){this.next();const c=this.parseAwait(e);return s||this.checkExponentialAfterUnary(c),c}const a=this.match(34),n=this.startNode();if(Ta(this.state.type)){n.operator=this.state.value,n.prefix=!0,this.match(72)&&this.expectPlugin("throwExpressions");const c=this.match(89);if(this.next(),n.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),this.state.strict&&c){const h=n.argument;h.type==="Identifier"?this.raise(p.StrictDelete,n):this.hasPropertyAsPrivateName(h)&&this.raise(p.DeletePrivateField,n)}if(!a)return s||this.checkExponentialAfterUnary(n),this.finishNode(n,"UnaryExpression")}const o=this.parseUpdate(n,a,t);if(i){const{type:c}=this.state;if((this.hasPlugin("v8intrinsic")?ht(c):ht(c)&&!this.match(54))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(p.AwaitNotInAsyncContext,e),this.parseAwait(e)}return o}parseUpdate(t,s,e){if(s){const n=t;return this.checkLVal(n.argument,this.finishNode(n,"UpdateExpression")),t}const i=this.state.startLoc;let a=this.parseExprSubscripts(e);if(this.checkExpressionErrors(e,!1))return a;for(;wa(this.state.type)&&!this.canInsertSemicolon();){const n=this.startNodeAt(i);n.operator=this.state.value,n.prefix=!1,n.argument=a,this.next(),this.checkLVal(a,a=this.finishNode(n,"UpdateExpression"))}return a}parseExprSubscripts(t){const s=this.state.startLoc,e=this.state.potentialArrowAt,i=this.parseExprAtom(t);return this.shouldExitDescending(i,e)?i:this.parseSubscripts(i,s)}parseSubscripts(t,s,e){const i={optionalChainMember:!1,maybeAsyncArrow:this.atPossibleAsyncArrow(t),stop:!1};do t=this.parseSubscript(t,s,e,i),i.maybeAsyncArrow=!1;while(!i.stop);return t}parseSubscript(t,s,e,i){const{type:a}=this.state;if(!e&&a===15)return this.parseBind(t,s,e,i);if(ls(a))return this.parseTaggedTemplateExpression(t,s,i);let n=!1;if(a===18){if(e&&(this.raise(p.OptionalChainingNoNew,this.state.startLoc),this.lookaheadCharCode()===40))return this.stopParseSubscript(t,i);i.optionalChainMember=n=!0,this.next()}if(!e&&this.match(10))return this.parseCoverCallAndAsyncArrowHead(t,s,i,n);{const o=this.eat(0);return o||n||this.eat(16)?this.parseMember(t,s,i,o,n):this.stopParseSubscript(t,i)}}stopParseSubscript(t,s){return s.stop=!0,t}parseMember(t,s,e,i,a){const n=this.startNodeAt(s);return n.object=t,n.computed=i,i?(n.property=this.parseExpression(),this.expect(3)):this.match(139)?(t.type==="Super"&&this.raise(p.SuperPrivateField,s),this.classScope.usePrivateName(this.state.value,this.state.startLoc),n.property=this.parsePrivateName()):n.property=this.parseIdentifier(!0),e.optionalChainMember?(n.optional=a,this.finishNode(n,"OptionalMemberExpression")):this.finishNode(n,"MemberExpression")}parseBind(t,s,e,i){const a=this.startNodeAt(s);return a.object=t,this.next(),a.callee=this.parseNoCallExpr(),i.stop=!0,this.parseSubscripts(this.finishNode(a,"BindExpression"),s,e)}parseCoverCallAndAsyncArrowHead(t,s,e,i){const a=this.state.maybeInArrowParameters;let n=null;this.state.maybeInArrowParameters=!0,this.next();const o=this.startNodeAt(s);o.callee=t;const{maybeAsyncArrow:c,optionalChainMember:h}=e;c&&(this.expressionScope.enter(pn()),n=new Lt),h&&(o.optional=i),i?o.arguments=this.parseCallExpressionArguments(11):o.arguments=this.parseCallExpressionArguments(11,t.type!=="Super",o,n);let l=this.finishCallExpression(o,h);return c&&this.shouldParseAsyncArrow()&&!i?(e.stop=!0,this.checkDestructuringPrivate(n),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),l=this.parseAsyncArrowFromCallExpression(this.startNodeAt(s),l)):(c&&(this.checkExpressionErrors(n,!0),this.expressionScope.exit()),this.toReferencedArguments(l)),this.state.maybeInArrowParameters=a,l}toReferencedArguments(t,s){this.toReferencedListDeep(t.arguments,s)}parseTaggedTemplateExpression(t,s,e){const i=this.startNodeAt(s);return i.tag=t,i.quasi=this.parseTemplate(!0),e.optionalChainMember&&this.raise(p.OptionalChainingNoTemplate,s),this.finishNode(i,"TaggedTemplateExpression")}atPossibleAsyncArrow(t){return t.type==="Identifier"&&t.name==="async"&&this.state.lastTokEndLoc.index===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.offsetToSourcePos(t.start)===this.state.potentialArrowAt}finishCallExpression(t,s){if(t.callee.type==="Import")if(t.arguments.length===0||t.arguments.length>2)this.raise(p.ImportCallArity,t);else for(const e of t.arguments)e.type==="SpreadElement"&&this.raise(p.ImportCallSpreadArgument,e);return this.finishNode(t,s?"OptionalCallExpression":"CallExpression")}parseCallExpressionArguments(t,s,e,i){const a=[];let n=!0;const o=this.state.inFSharpPipelineDirectBody;for(this.state.inFSharpPipelineDirectBody=!1;!this.eat(t);){if(n)n=!1;else if(this.expect(12),this.match(t)){e&&this.addTrailingCommaExtraToNode(e),this.next();break}a.push(this.parseExprListItem(!1,i,s))}return this.state.inFSharpPipelineDirectBody=o,a}shouldParseAsyncArrow(){return this.match(19)&&!this.canInsertSemicolon()}parseAsyncArrowFromCallExpression(t,s){var e;return this.resetPreviousNodeTrailingComments(s),this.expect(19),this.parseArrowExpression(t,s.arguments,!0,(e=s.extra)==null?void 0:e.trailingCommaLoc),s.innerComments&&Ve(t,s.innerComments),s.callee.trailingComments&&Ve(t,s.callee.trailingComments),t}parseNoCallExpr(){const t=this.state.startLoc;return this.parseSubscripts(this.parseExprAtom(),t,!0)}parseExprAtom(t){let s,e=null;const{type:i}=this.state;switch(i){case 79:return this.parseSuper();case 83:return s=this.startNode(),this.next(),this.match(16)?this.parseImportMetaPropertyOrPhaseCall(s):this.match(10)?this.optionFlags&512?this.parseImportCall(s):this.finishNode(s,"Import"):(this.raise(p.UnsupportedImport,this.state.lastTokStartLoc),this.finishNode(s,"Import"));case 78:return s=this.startNode(),this.next(),this.finishNode(s,"ThisExpression");case 90:return this.parseDo(this.startNode(),!1);case 56:case 31:return this.readRegexp(),this.parseRegExpLiteral(this.state.value);case 135:return this.parseNumericLiteral(this.state.value);case 136:return this.parseBigIntLiteral(this.state.value);case 134:return this.parseStringLiteral(this.state.value);case 84:return this.parseNullLiteral();case 85:return this.parseBooleanLiteral(!0);case 86:return this.parseBooleanLiteral(!1);case 10:{const a=this.state.potentialArrowAt===this.state.start;return this.parseParenAndDistinguishExpression(a)}case 0:return this.parseArrayLike(3,!0,!1,t);case 5:return this.parseObjectLike(8,!1,!1,t);case 68:return this.parseFunctionOrFunctionSent();case 26:e=this.parseDecorators();case 80:return this.parseClass(this.maybeTakeDecorators(e,this.startNode()),!1);case 77:return this.parseNewOrNewTarget();case 25:case 24:return this.parseTemplate(!1);case 15:{s=this.startNode(),this.next(),s.object=null;const a=s.callee=this.parseNoCallExpr();if(a.type==="MemberExpression")return this.finishNode(s,"BindExpression");throw this.raise(p.UnsupportedBind,a)}case 139:return this.raise(p.PrivateInExpectedIn,this.state.startLoc,{identifierName:this.state.value}),this.parsePrivateName();case 33:return this.parseTopicReferenceThenEqualsSign(54,"%");case 32:return this.parseTopicReferenceThenEqualsSign(44,"^");case 37:case 38:return this.parseTopicReference("hack");case 44:case 54:case 27:{const a=this.getPluginOption("pipelineOperator","proposal");if(a)return this.parseTopicReference(a);this.unexpected();break}case 47:{const a=this.input.codePointAt(this.nextTokenStart());ge(a)||a===62?this.expectOnePlugin(["jsx","flow","typescript"]):this.unexpected();break}default:if(O(i)){if(this.isContextual(127)&&this.lookaheadInLineCharCode()===123)return this.parseModuleExpression();const a=this.state.potentialArrowAt===this.state.start,n=this.state.containsEsc,o=this.parseIdentifier();if(!n&&o.name==="async"&&!this.canInsertSemicolon()){const{type:c}=this.state;if(c===68)return this.resetPreviousNodeTrailingComments(o),this.next(),this.parseAsyncFunctionExpression(this.startNodeAtNode(o));if(O(c))return this.lookaheadCharCode()===61?this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(o)):o;if(c===90)return this.resetPreviousNodeTrailingComments(o),this.parseDo(this.startNodeAtNode(o),!0)}return a&&this.match(19)&&!this.canInsertSemicolon()?(this.next(),this.parseArrowExpression(this.startNodeAtNode(o),[o],!1)):o}else this.unexpected()}}parseTopicReferenceThenEqualsSign(t,s){const e=this.getPluginOption("pipelineOperator","proposal");if(e)return this.state.type=t,this.state.value=s,this.state.pos--,this.state.end--,this.state.endLoc=ce(this.state.endLoc,-1),this.parseTopicReference(e);this.unexpected()}parseTopicReference(t){const s=this.startNode(),e=this.state.startLoc,i=this.state.type;return this.next(),this.finishTopicReference(s,e,t,i)}finishTopicReference(t,s,e,i){if(this.testTopicReferenceConfiguration(e,s,i))return this.topicReferenceIsAllowedInCurrentContext()||this.raise(p.PipeTopicUnbound,s),this.registerTopicReference(),this.finishNode(t,"TopicReference");throw this.raise(p.PipeTopicUnconfiguredToken,s,{token:Ce(i)})}testTopicReferenceConfiguration(t,s,e){switch(t){case"hack":return this.hasPlugin(["pipelineOperator",{topicToken:Ce(e)}]);case"smart":return e===27;default:throw this.raise(p.PipeTopicRequiresHackPipes,s)}}parseAsyncArrowUnaryFunction(t){this.prodParam.enter(vt(!0,this.prodParam.hasYield));const s=[this.parseIdentifier()];return this.prodParam.exit(),this.hasPrecedingLineBreak()&&this.raise(p.LineTerminatorBeforeArrow,this.state.curPosition()),this.expect(19),this.parseArrowExpression(t,s,!0)}parseDo(t,s){this.expectPlugin("doExpressions"),s&&this.expectPlugin("asyncDoExpressions"),t.async=s,this.next();const e=this.state.labels;return this.state.labels=[],s?(this.prodParam.enter(2),t.body=this.parseBlock(),this.prodParam.exit()):t.body=this.parseBlock(),this.state.labels=e,this.finishNode(t,"DoExpression")}parseSuper(){const t=this.startNode();return this.next(),this.match(10)&&!this.scope.allowDirectSuper&&!(this.optionFlags&16)?this.raise(p.SuperNotAllowed,t):!this.scope.allowSuper&&!(this.optionFlags&16)&&this.raise(p.UnexpectedSuper,t),!this.match(10)&&!this.match(0)&&!this.match(16)&&this.raise(p.UnsupportedSuper,t),this.finishNode(t,"Super")}parsePrivateName(){const t=this.startNode(),s=this.startNodeAt(ce(this.state.startLoc,1)),e=this.state.value;return this.next(),t.id=this.createIdentifier(s,e),this.finishNode(t,"PrivateName")}parseFunctionOrFunctionSent(){const t=this.startNode();if(this.next(),this.prodParam.hasYield&&this.match(16)){const s=this.createIdentifier(this.startNodeAtNode(t),"function");return this.next(),this.match(103)?this.expectPlugin("functionSent"):this.hasPlugin("functionSent")||this.unexpected(),this.parseMetaProperty(t,s,"sent")}return this.parseFunction(t)}parseMetaProperty(t,s,e){t.meta=s;const i=this.state.containsEsc;return t.property=this.parseIdentifier(!0),(t.property.name!==e||i)&&this.raise(p.UnsupportedMetaProperty,t.property,{target:s.name,onlyValidPropertyName:e}),this.finishNode(t,"MetaProperty")}parseImportMetaPropertyOrPhaseCall(t){if(this.next(),this.isContextual(105)||this.isContextual(97)){const s=this.isContextual(105);return this.expectPlugin(s?"sourcePhaseImports":"deferredImportEvaluation"),this.next(),t.phase=s?"source":"defer",this.parseImportCall(t)}else{const s=this.createIdentifierAt(this.startNodeAtNode(t),"import",this.state.lastTokStartLoc);return this.isContextual(101)&&(this.inModule||this.raise(p.ImportMetaOutsideModule,s),this.sawUnambiguousESM=!0),this.parseMetaProperty(t,s,"meta")}}parseLiteralAtNode(t,s,e){return this.addExtra(e,"rawValue",t),this.addExtra(e,"raw",this.input.slice(this.offsetToSourcePos(e.start),this.state.end)),e.value=t,this.next(),this.finishNode(e,s)}parseLiteral(t,s){const e=this.startNode();return this.parseLiteralAtNode(t,s,e)}parseStringLiteral(t){return this.parseLiteral(t,"StringLiteral")}parseNumericLiteral(t){return this.parseLiteral(t,"NumericLiteral")}parseBigIntLiteral(t){return this.parseLiteral(t,"BigIntLiteral")}parseDecimalLiteral(t){return this.parseLiteral(t,"DecimalLiteral")}parseRegExpLiteral(t){const s=this.startNode();return this.addExtra(s,"raw",this.input.slice(this.offsetToSourcePos(s.start),this.state.end)),s.pattern=t.pattern,s.flags=t.flags,this.next(),this.finishNode(s,"RegExpLiteral")}parseBooleanLiteral(t){const s=this.startNode();return s.value=t,this.next(),this.finishNode(s,"BooleanLiteral")}parseNullLiteral(){const t=this.startNode();return this.next(),this.finishNode(t,"NullLiteral")}parseParenAndDistinguishExpression(t){const s=this.state.startLoc;let e;this.next(),this.expressionScope.enter(un());const i=this.state.maybeInArrowParameters,a=this.state.inFSharpPipelineDirectBody;this.state.maybeInArrowParameters=!0,this.state.inFSharpPipelineDirectBody=!1;const n=this.state.startLoc,o=[],c=new Lt;let h=!0,l,u;for(;!this.match(11);){if(h)h=!1;else if(this.expect(12,c.optionalParametersLoc===null?null:c.optionalParametersLoc),this.match(11)){u=this.state.startLoc;break}if(this.match(21)){const P=this.state.startLoc;if(l=this.state.startLoc,o.push(this.parseParenItem(this.parseRestBinding(),P)),!this.checkCommaAfterRest(41))break}else o.push(this.parseMaybeAssignAllowIn(c,this.parseParenItem))}const f=this.state.lastTokEndLoc;this.expect(11),this.state.maybeInArrowParameters=i,this.state.inFSharpPipelineDirectBody=a;let d=this.startNodeAt(s);return t&&this.shouldParseArrow(o)&&(d=this.parseArrow(d))?(this.checkDestructuringPrivate(c),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(d,o,!1),d):(this.expressionScope.exit(),o.length||this.unexpected(this.state.lastTokStartLoc),u&&this.unexpected(u),l&&this.unexpected(l),this.checkExpressionErrors(c,!0),this.toReferencedListDeep(o,!0),o.length>1?(e=this.startNodeAt(n),e.expressions=o,this.finishNode(e,"SequenceExpression"),this.resetEndLocation(e,f)):e=o[0],this.wrapParenthesis(s,e))}wrapParenthesis(t,s){if(!(this.optionFlags&1024))return this.addExtra(s,"parenthesized",!0),this.addExtra(s,"parenStart",t.index),this.takeSurroundingComments(s,t.index,this.state.lastTokEndLoc.index),s;const e=this.startNodeAt(t);return e.expression=s,this.finishNode(e,"ParenthesizedExpression")}shouldParseArrow(t){return!this.canInsertSemicolon()}parseArrow(t){if(this.eat(19))return t}parseParenItem(t,s){return t}parseNewOrNewTarget(){const t=this.startNode();if(this.next(),this.match(16)){const s=this.createIdentifier(this.startNodeAtNode(t),"new");this.next();const e=this.parseMetaProperty(t,s,"target");return!this.scope.inNonArrowFunction&&!this.scope.inClass&&!(this.optionFlags&4)&&this.raise(p.UnexpectedNewTarget,e),e}return this.parseNew(t)}parseNew(t){if(this.parseNewCallee(t),this.eat(10)){const s=this.parseExprList(11);this.toReferencedList(s),t.arguments=s}else t.arguments=[];return this.finishNode(t,"NewExpression")}parseNewCallee(t){const s=this.match(83),e=this.parseNoCallExpr();t.callee=e,s&&(e.type==="Import"||e.type==="ImportExpression")&&this.raise(p.ImportCallNotNewExpression,e)}parseTemplateElement(t){const{start:s,startLoc:e,end:i,value:a}=this.state,n=s+1,o=this.startNodeAt(ce(e,1));a===null&&(t||this.raise(p.InvalidEscapeSequenceTemplate,ce(this.state.firstInvalidTemplateEscapePos,1)));const c=this.match(24),h=c?-1:-2,l=i+h;o.value={raw:this.input.slice(n,l).replace(/\r\n?/g,`
8
- `),cooked:a===null?null:a.slice(1,h)},o.tail=c,this.next();const u=this.finishNode(o,"TemplateElement");return this.resetEndLocation(u,ce(this.state.lastTokEndLoc,h)),u}parseTemplate(t){const s=this.startNode();let e=this.parseTemplateElement(t);const i=[e],a=[];for(;!e.tail;)a.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),i.push(e=this.parseTemplateElement(t));return s.expressions=a,s.quasis=i,this.finishNode(s,"TemplateLiteral")}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(t,s,e,i){e&&this.expectPlugin("recordAndTuple");const a=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!1;let n=!1,o=!0;const c=this.startNode();for(c.properties=[],this.next();!this.match(t);){if(o)o=!1;else if(this.expect(12),this.match(t)){this.addTrailingCommaExtraToNode(c);break}let l;s?l=this.parseBindingProperty():(l=this.parsePropertyDefinition(i),n=this.checkProto(l,e,n,i)),e&&!this.isObjectProperty(l)&&l.type!=="SpreadElement"&&this.raise(p.InvalidRecordProperty,l),c.properties.push(l)}this.next(),this.state.inFSharpPipelineDirectBody=a;let h="ObjectExpression";return s?h="ObjectPattern":e&&(h="RecordExpression"),this.finishNode(c,h)}addTrailingCommaExtraToNode(t){this.addExtra(t,"trailingComma",this.state.lastTokStartLoc.index),this.addExtra(t,"trailingCommaLoc",this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(t){return!t.computed&&t.key.type==="Identifier"&&(this.isLiteralPropertyName()||this.match(0)||this.match(55))}parsePropertyDefinition(t){let s=[];if(this.match(26))for(this.hasPlugin("decorators")&&this.raise(p.UnsupportedPropertyDecorator,this.state.startLoc);this.match(26);)s.push(this.parseDecorator());const e=this.startNode();let i=!1,a=!1,n;if(this.match(21))return s.length&&this.unexpected(),this.parseSpread();s.length&&(e.decorators=s,s=[]),e.method=!1,t&&(n=this.state.startLoc);let o=this.eat(55);this.parsePropertyNamePrefixOperator(e);const c=this.state.containsEsc;if(this.parsePropertyName(e,t),!o&&!c&&this.maybeAsyncOrAccessorProp(e)){const{key:h}=e,l=h.name;l==="async"&&!this.hasPrecedingLineBreak()&&(i=!0,this.resetPreviousNodeTrailingComments(h),o=this.eat(55),this.parsePropertyName(e)),(l==="get"||l==="set")&&(a=!0,this.resetPreviousNodeTrailingComments(h),e.kind=l,this.match(55)&&(o=!0,this.raise(p.AccessorIsGenerator,this.state.curPosition(),{kind:l}),this.next()),this.parsePropertyName(e))}return this.parseObjPropValue(e,n,o,i,!1,a,t)}getGetterSetterExpectedParamCount(t){return t.kind==="get"?0:1}getObjectOrClassMethodParams(t){return t.params}checkGetterSetterParams(t){var i;const s=this.getGetterSetterExpectedParamCount(t),e=this.getObjectOrClassMethodParams(t);e.length!==s&&this.raise(t.kind==="get"?p.BadGetterArity:p.BadSetterArity,t),t.kind==="set"&&((i=e[e.length-1])==null?void 0:i.type)==="RestElement"&&this.raise(p.BadSetterRestParameter,t)}parseObjectMethod(t,s,e,i,a){if(a){const n=this.parseMethod(t,s,!1,!1,!1,"ObjectMethod");return this.checkGetterSetterParams(n),n}if(e||s||this.match(10))return i&&this.unexpected(),t.kind="method",t.method=!0,this.parseMethod(t,s,e,!1,!1,"ObjectMethod")}parseObjectProperty(t,s,e,i){if(t.shorthand=!1,this.eat(14))return t.value=e?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowIn(i),this.finishObjectProperty(t);if(!t.computed&&t.key.type==="Identifier"){if(this.checkReservedWord(t.key.name,t.key.loc.start,!0,!1),e)t.value=this.parseMaybeDefault(s,this.cloneIdentifier(t.key));else if(this.match(29)){const a=this.state.startLoc;i!=null?i.shorthandAssignLoc===null&&(i.shorthandAssignLoc=a):this.raise(p.InvalidCoverInitializedName,a),t.value=this.parseMaybeDefault(s,this.cloneIdentifier(t.key))}else t.value=this.cloneIdentifier(t.key);return t.shorthand=!0,this.finishObjectProperty(t)}}finishObjectProperty(t){return this.finishNode(t,"ObjectProperty")}parseObjPropValue(t,s,e,i,a,n,o){const c=this.parseObjectMethod(t,e,i,a,n)||this.parseObjectProperty(t,s,a,o);return c||this.unexpected(),c}parsePropertyName(t,s){if(this.eat(0))t.computed=!0,t.key=this.parseMaybeAssignAllowIn(),this.expect(3);else{const{type:e,value:i}=this.state;let a;if(ue(e))a=this.parseIdentifier(!0);else switch(e){case 135:a=this.parseNumericLiteral(i);break;case 134:a=this.parseStringLiteral(i);break;case 136:a=this.parseBigIntLiteral(i);break;case 139:{const n=this.state.startLoc;s!=null?s.privateKeyLoc===null&&(s.privateKeyLoc=n):this.raise(p.UnexpectedPrivateField,n),a=this.parsePrivateName();break}default:this.unexpected()}t.key=a,e!==139&&(t.computed=!1)}}initFunction(t,s){t.id=null,t.generator=!1,t.async=s}parseMethod(t,s,e,i,a,n,o=!1){this.initFunction(t,e),t.generator=s,this.scope.enter(18|(o?64:0)|(a?32:0)),this.prodParam.enter(vt(e,t.generator)),this.parseFunctionParams(t,i);const c=this.parseFunctionBodyAndFinish(t,n,!0);return this.prodParam.exit(),this.scope.exit(),c}parseArrayLike(t,s,e,i){e&&this.expectPlugin("recordAndTuple");const a=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!1;const n=this.startNode();return this.next(),n.elements=this.parseExprList(t,!e,i,n),this.state.inFSharpPipelineDirectBody=a,this.finishNode(n,e?"TupleExpression":"ArrayExpression")}parseArrowExpression(t,s,e,i){this.scope.enter(6);let a=vt(e,!1);!this.match(5)&&this.prodParam.hasIn&&(a|=8),this.prodParam.enter(a),this.initFunction(t,e);const n=this.state.maybeInArrowParameters;return s&&(this.state.maybeInArrowParameters=!0,this.setArrowFunctionParameters(t,s,i)),this.state.maybeInArrowParameters=!1,this.parseFunctionBody(t,!0),this.prodParam.exit(),this.scope.exit(),this.state.maybeInArrowParameters=n,this.finishNode(t,"ArrowFunctionExpression")}setArrowFunctionParameters(t,s,e){this.toAssignableList(s,e,!1),t.params=s}parseFunctionBodyAndFinish(t,s,e=!1){return this.parseFunctionBody(t,!1,e),this.finishNode(t,s)}parseFunctionBody(t,s,e=!1){const i=s&&!this.match(5);if(this.expressionScope.enter(yi()),i)t.body=this.parseMaybeAssign(),this.checkParams(t,!1,s,!1);else{const a=this.state.strict,n=this.state.labels;this.state.labels=[],this.prodParam.enter(this.prodParam.currentFlags()|4),t.body=this.parseBlock(!0,!1,o=>{const c=!this.isSimpleParamList(t.params);o&&c&&this.raise(p.IllegalLanguageModeDirective,(t.kind==="method"||t.kind==="constructor")&&t.key?t.key.loc.end:t);const h=!a&&this.state.strict;this.checkParams(t,!this.state.strict&&!s&&!e&&!c,s,h),this.state.strict&&t.id&&this.checkIdentifier(t.id,65,h)}),this.prodParam.exit(),this.state.labels=n}this.expressionScope.exit()}isSimpleParameter(t){return t.type==="Identifier"}isSimpleParamList(t){for(let s=0,e=t.length;s<e;s++)if(!this.isSimpleParameter(t[s]))return!1;return!0}checkParams(t,s,e,i=!0){const a=!s&&new Set,n={type:"FormalParameters"};for(const o of t.params)this.checkLVal(o,n,5,a,i)}parseExprList(t,s,e,i){const a=[];let n=!0;for(;!this.eat(t);){if(n)n=!1;else if(this.expect(12),this.match(t)){i&&this.addTrailingCommaExtraToNode(i),this.next();break}a.push(this.parseExprListItem(s,e))}return a}parseExprListItem(t,s,e){let i;if(this.match(12))t||this.raise(p.UnexpectedToken,this.state.curPosition(),{unexpected:","}),i=null;else if(this.match(21)){const a=this.state.startLoc;i=this.parseParenItem(this.parseSpread(s),a)}else if(this.match(17)){this.expectPlugin("partialApplication"),e||this.raise(p.UnexpectedArgumentPlaceholder,this.state.startLoc);const a=this.startNode();this.next(),i=this.finishNode(a,"ArgumentPlaceholder")}else i=this.parseMaybeAssignAllowIn(s,this.parseParenItem);return i}parseIdentifier(t){const s=this.startNode(),e=this.parseIdentifierName(t);return this.createIdentifier(s,e)}createIdentifier(t,s){return t.name=s,t.loc.identifierName=s,this.finishNode(t,"Identifier")}createIdentifierAt(t,s,e){return t.name=s,t.loc.identifierName=s,this.finishNodeAt(t,"Identifier",e)}parseIdentifierName(t){let s;const{startLoc:e,type:i}=this.state;ue(i)?s=this.state.value:this.unexpected();const a=ya(i);return t?a&&this.replaceToken(132):this.checkReservedWord(s,e,a,!1),this.next(),s}checkReservedWord(t,s,e,i){if(t.length>10||!Fa(t))return;if(e&&Da(t)){this.raise(p.UnexpectedKeyword,s,{keyword:t});return}if((this.state.strict?i?oi:ai:ri)(t,this.inModule)){this.raise(p.UnexpectedReservedWord,s,{reservedWord:t});return}else if(t==="yield"){if(this.prodParam.hasYield){this.raise(p.YieldBindingIdentifier,s);return}}else if(t==="await"){if(this.prodParam.hasAwait){this.raise(p.AwaitBindingIdentifier,s);return}if(this.scope.inStaticBlock){this.raise(p.AwaitBindingIdentifierInStaticBlock,s);return}this.expressionScope.recordAsyncArrowParametersError(s)}else if(t==="arguments"&&this.scope.inClassAndNotInNonArrowFunction){this.raise(p.ArgumentsInClass,s);return}}recordAwaitIfAllowed(){const t=this.prodParam.hasAwait||this.optionFlags&1&&!this.scope.inFunction;return t&&!this.scope.inFunction&&(this.state.hasTopLevelAwait=!0),t}parseAwait(t){const s=this.startNodeAt(t);return this.expressionScope.recordParameterInitializerError(p.AwaitExpressionFormalParameter,s),this.eat(55)&&this.raise(p.ObsoleteAwaitStar,s),!this.scope.inFunction&&!(this.optionFlags&1)&&(this.isAmbiguousPrefixOrIdentifier()?this.ambiguousScriptDifferentAst=!0:this.sawUnambiguousESM=!0),this.state.soloAwait||(s.argument=this.parseMaybeUnary(null,!0)),this.finishNode(s,"AwaitExpression")}isAmbiguousPrefixOrIdentifier(){if(this.hasPrecedingLineBreak())return!0;const{type:t}=this.state;return t===53||t===10||t===0||ls(t)||t===102&&!this.state.containsEsc||t===138||t===56||this.hasPlugin("v8intrinsic")&&t===54}parseYield(t){const s=this.startNodeAt(t);this.expressionScope.recordParameterInitializerError(p.YieldInParameter,s);let e=!1,i=null;if(!this.hasPrecedingLineBreak())switch(e=this.eat(55),this.state.type){case 13:case 140:case 8:case 11:case 3:case 9:case 14:case 12:if(!e)break;default:i=this.parseMaybeAssign()}return s.delegate=e,s.argument=i,this.finishNode(s,"YieldExpression")}parseImportCall(t){if(this.next(),t.source=this.parseMaybeAssignAllowIn(),t.options=null,this.eat(12)){if(this.match(11))this.addTrailingCommaExtraToNode(t.source);else if(t.options=this.parseMaybeAssignAllowIn(),this.eat(12)&&(this.addTrailingCommaExtraToNode(t.options),!this.match(11))){do this.parseMaybeAssignAllowIn();while(this.eat(12)&&!this.match(11));this.raise(p.ImportCallArity,t)}}return this.expect(11),this.finishNode(t,"ImportExpression")}checkPipelineAtInfixOperator(t,s){this.hasPlugin(["pipelineOperator",{proposal:"smart"}])&&t.type==="SequenceExpression"&&this.raise(p.PipelineHeadSequenceExpression,s)}parseSmartPipelineBodyInStyle(t,s){if(this.isSimpleReference(t)){const e=this.startNodeAt(s);return e.callee=t,this.finishNode(e,"PipelineBareFunction")}else{const e=this.startNodeAt(s);return this.checkSmartPipeTopicBodyEarlyErrors(s),e.expression=t,this.finishNode(e,"PipelineTopicExpression")}}isSimpleReference(t){switch(t.type){case"MemberExpression":return!t.computed&&this.isSimpleReference(t.object);case"Identifier":return!0;default:return!1}}checkSmartPipeTopicBodyEarlyErrors(t){if(this.match(19))throw this.raise(p.PipelineBodyNoArrow,this.state.startLoc);this.topicReferenceWasUsedInCurrentContext()||this.raise(p.PipelineTopicUnused,t)}withTopicBindingContext(t){const s=this.state.topicContext;this.state.topicContext={maxNumOfResolvableTopics:1,maxTopicIndex:null};try{return t()}finally{this.state.topicContext=s}}withSmartMixTopicForbiddingContext(t){return t()}withSoloAwaitPermittingContext(t){const s=this.state.soloAwait;this.state.soloAwait=!0;try{return t()}finally{this.state.soloAwait=s}}allowInAnd(t){const s=this.prodParam.currentFlags();if(8&~s){this.prodParam.enter(s|8);try{return t()}finally{this.prodParam.exit()}}return t()}disallowInAnd(t){const s=this.prodParam.currentFlags();if(8&s){this.prodParam.enter(s&-9);try{return t()}finally{this.prodParam.exit()}}return t()}registerTopicReference(){this.state.topicContext.maxTopicIndex=0}topicReferenceIsAllowedInCurrentContext(){return this.state.topicContext.maxNumOfResolvableTopics>=1}topicReferenceWasUsedInCurrentContext(){return this.state.topicContext.maxTopicIndex!=null&&this.state.topicContext.maxTopicIndex>=0}parseFSharpPipelineBody(t){const s=this.state.startLoc;this.state.potentialArrowAt=this.state.start;const e=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!0;const i=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),s,t);return this.state.inFSharpPipelineDirectBody=e,i}parseModuleExpression(){this.expectPlugin("moduleBlocks");const t=this.startNode();this.next(),this.match(5)||this.unexpected(null,5);const s=this.startNodeAt(this.state.endLoc);this.next();const e=this.initializeScopes(!0);this.enterInitialScopes();try{t.body=this.parseProgram(s,8,"module")}finally{e()}return this.finishNode(t,"ModuleExpression")}parsePropertyNamePrefixOperator(t){}}const Ts={kind:1},kn={kind:2},Nn=/[\uD800-\uDFFF]/u,As=/in(?:stanceof)?/y;function vn(r,t,s){for(let e=0;e<r.length;e++){const i=r[e],{type:a}=i;typeof a=="number"&&(i.type=ti(a))}return r}class On extends Cn{parseTopLevel(t,s){return t.program=this.parseProgram(s),t.comments=this.comments,this.optionFlags&256&&(t.tokens=vn(this.tokens,this.input,this.startIndex)),this.finishNode(t,"File")}parseProgram(t,s=140,e=this.options.sourceType){if(t.sourceType=e,t.interpreter=this.parseInterpreterDirective(),this.parseBlockBody(t,!0,!0,s),this.inModule){if(!(this.optionFlags&64)&&this.scope.undefinedExports.size>0)for(const[a,n]of Array.from(this.scope.undefinedExports))this.raise(p.ModuleExportUndefined,n,{localName:a});this.addExtra(t,"topLevelAwait",this.state.hasTopLevelAwait)}let i;return s===140?i=this.finishNode(t,"Program"):i=this.finishNodeAt(t,"Program",ce(this.state.startLoc,-1)),i}stmtToDirective(t){const s=this.castNodeTo(t,"Directive"),e=this.castNodeTo(t.expression,"DirectiveLiteral"),i=e.value,a=this.input.slice(this.offsetToSourcePos(e.start),this.offsetToSourcePos(e.end)),n=e.value=a.slice(1,-1);return this.addExtra(e,"raw",a),this.addExtra(e,"rawValue",n),this.addExtra(e,"expressionValue",i),s.value=e,delete t.expression,s}parseInterpreterDirective(){if(!this.match(28))return null;const t=this.startNode();return t.value=this.state.value,this.next(),this.finishNode(t,"InterpreterDirective")}isLet(){return this.isContextual(100)?this.hasFollowingBindingAtom():!1}chStartsBindingIdentifier(t,s){if(ge(t)){if(As.lastIndex=s,As.test(this.input)){const e=this.codePointAtPos(As.lastIndex);if(!$e(e)&&e!==92)return!1}return!0}else return t===92}chStartsBindingPattern(t){return t===91||t===123}hasFollowingBindingAtom(){const t=this.nextTokenStart(),s=this.codePointAtPos(t);return this.chStartsBindingPattern(s)||this.chStartsBindingIdentifier(s,t)}hasInLineFollowingBindingIdentifierOrBrace(){const t=this.nextTokenInLineStart(),s=this.codePointAtPos(t);return s===123||this.chStartsBindingIdentifier(s,t)}allowsForUsing(){const{type:t,containsEsc:s,end:e}=this.lookahead();if(t===102&&!s){const i=this.lookaheadCharCodeSince(e);if(i!==61&&i!==58&&i!==59)return!1}return O(t)&&!this.hasFollowingLineBreak()?(this.expectPlugin("explicitResourceManagement"),!0):!1}allowsUsing(){return(this.scope.inModule||!this.scope.inTopLevel)&&!this.scope.inBareCaseStatement}startsAwaitUsing(){let t=this.nextTokenInLineStart();if(this.isUnparsedContextual(t,"using")){t=this.nextTokenInLineStartSince(t+5);const s=this.codePointAtPos(t);if(this.chStartsBindingIdentifier(s,t))return this.expectPlugin("explicitResourceManagement"),!0}return!1}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(t=!1){let s=0;return this.options.annexB&&!this.state.strict&&(s|=4,t&&(s|=8)),this.parseStatementLike(s)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(t){let s=null;return this.match(26)&&(s=this.parseDecorators(!0)),this.parseStatementContent(t,s)}parseStatementContent(t,s){const e=this.state.type,i=this.startNode(),a=!!(t&2),n=!!(t&4),o=t&1;switch(e){case 60:return this.parseBreakContinueStatement(i,!0);case 63:return this.parseBreakContinueStatement(i,!1);case 64:return this.parseDebuggerStatement(i);case 90:return this.parseDoWhileStatement(i);case 91:return this.parseForStatement(i);case 68:if(this.lookaheadCharCode()===46)break;return n||this.raise(this.state.strict?p.StrictFunction:this.options.annexB?p.SloppyFunctionAnnexB:p.SloppyFunction,this.state.startLoc),this.parseFunctionStatement(i,!1,!a&&n);case 80:return a||this.unexpected(),this.parseClass(this.maybeTakeDecorators(s,i),!0);case 69:return this.parseIfStatement(i);case 70:return this.parseReturnStatement(i);case 71:return this.parseSwitchStatement(i);case 72:return this.parseThrowStatement(i);case 73:return this.parseTryStatement(i);case 96:if(!this.state.containsEsc&&this.startsAwaitUsing())return this.allowsUsing()?a?this.recordAwaitIfAllowed()||this.raise(p.AwaitUsingNotInAsyncContext,i):this.raise(p.UnexpectedLexicalDeclaration,i):this.raise(p.UnexpectedUsingDeclaration,i),this.next(),this.parseVarStatement(i,"await using");break;case 107:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifierOrBrace())break;return this.expectPlugin("explicitResourceManagement"),this.allowsUsing()?a||this.raise(p.UnexpectedLexicalDeclaration,this.state.startLoc):this.raise(p.UnexpectedUsingDeclaration,this.state.startLoc),this.parseVarStatement(i,"using");case 100:{if(this.state.containsEsc)break;const l=this.nextTokenStart(),u=this.codePointAtPos(l);if(u!==91&&(!a&&this.hasFollowingLineBreak()||!this.chStartsBindingIdentifier(u,l)&&u!==123))break}case 75:a||this.raise(p.UnexpectedLexicalDeclaration,this.state.startLoc);case 74:{const l=this.state.value;return this.parseVarStatement(i,l)}case 92:return this.parseWhileStatement(i);case 76:return this.parseWithStatement(i);case 5:return this.parseBlock();case 13:return this.parseEmptyStatement(i);case 83:{const l=this.lookaheadCharCode();if(l===40||l===46)break}case 82:{!(this.optionFlags&8)&&!o&&this.raise(p.UnexpectedImportExport,this.state.startLoc),this.next();let l;return e===83?l=this.parseImport(i):l=this.parseExport(i,s),this.assertModuleNodeAllowed(l),l}default:if(this.isAsyncFunction())return a||this.raise(p.AsyncFunctionInSingleStatementContext,this.state.startLoc),this.next(),this.parseFunctionStatement(i,!0,!a&&n)}const c=this.state.value,h=this.parseExpression();return O(e)&&h.type==="Identifier"&&this.eat(14)?this.parseLabeledStatement(i,c,h,t):this.parseExpressionStatement(i,h,s)}assertModuleNodeAllowed(t){!(this.optionFlags&8)&&!this.inModule&&this.raise(p.ImportOutsideModule,t)}decoratorsEnabledBeforeExport(){return this.hasPlugin("decorators-legacy")?!0:this.hasPlugin("decorators")&&this.getPluginOption("decorators","decoratorsBeforeExport")!==!1}maybeTakeDecorators(t,s,e){var i;return t&&((i=s.decorators)!=null&&i.length?(typeof this.getPluginOption("decorators","decoratorsBeforeExport")!="boolean"&&this.raise(p.DecoratorsBeforeAfterExport,s.decorators[0]),s.decorators.unshift(...t)):s.decorators=t,this.resetStartLocationFromNode(s,t[0]),e&&this.resetStartLocationFromNode(e,s)),s}canHaveLeadingDecorator(){return this.match(80)}parseDecorators(t){const s=[];do s.push(this.parseDecorator());while(this.match(26));if(this.match(82))t||this.unexpected(),this.decoratorsEnabledBeforeExport()||this.raise(p.DecoratorExportClass,this.state.startLoc);else if(!this.canHaveLeadingDecorator())throw this.raise(p.UnexpectedLeadingDecorator,this.state.startLoc);return s}parseDecorator(){this.expectOnePlugin(["decorators","decorators-legacy"]);const t=this.startNode();if(this.next(),this.hasPlugin("decorators")){const s=this.state.startLoc;let e;if(this.match(10)){const i=this.state.startLoc;this.next(),e=this.parseExpression(),this.expect(11),e=this.wrapParenthesis(i,e);const a=this.state.startLoc;t.expression=this.parseMaybeDecoratorArguments(e,i),this.getPluginOption("decorators","allowCallParenthesized")===!1&&t.expression!==e&&this.raise(p.DecoratorArgumentsOutsideParentheses,a)}else{for(e=this.parseIdentifier(!1);this.eat(16);){const i=this.startNodeAt(s);i.object=e,this.match(139)?(this.classScope.usePrivateName(this.state.value,this.state.startLoc),i.property=this.parsePrivateName()):i.property=this.parseIdentifier(!0),i.computed=!1,e=this.finishNode(i,"MemberExpression")}t.expression=this.parseMaybeDecoratorArguments(e,s)}}else t.expression=this.parseExprSubscripts();return this.finishNode(t,"Decorator")}parseMaybeDecoratorArguments(t,s){if(this.eat(10)){const e=this.startNodeAt(s);return e.callee=t,e.arguments=this.parseCallExpressionArguments(11),this.toReferencedList(e.arguments),this.finishNode(e,"CallExpression")}return t}parseBreakContinueStatement(t,s){return this.next(),this.isLineTerminator()?t.label=null:(t.label=this.parseIdentifier(),this.semicolon()),this.verifyBreakContinue(t,s),this.finishNode(t,s?"BreakStatement":"ContinueStatement")}verifyBreakContinue(t,s){let e;for(e=0;e<this.state.labels.length;++e){const i=this.state.labels[e];if((t.label==null||i.name===t.label.name)&&(i.kind!=null&&(s||i.kind===1)||t.label&&s))break}if(e===this.state.labels.length){const i=s?"BreakStatement":"ContinueStatement";this.raise(p.IllegalBreakContinue,t,{type:i})}}parseDebuggerStatement(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")}parseHeaderExpression(){this.expect(10);const t=this.parseExpression();return this.expect(11),t}parseDoWhileStatement(t){return this.next(),this.state.labels.push(Ts),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.state.labels.pop(),this.expect(92),t.test=this.parseHeaderExpression(),this.eat(13),this.finishNode(t,"DoWhileStatement")}parseForStatement(t){this.next(),this.state.labels.push(Ts);let s=null;if(this.isContextual(96)&&this.recordAwaitIfAllowed()&&(s=this.state.startLoc,this.next()),this.scope.enter(0),this.expect(10),this.match(13))return s!==null&&this.unexpected(s),this.parseFor(t,null);const e=this.isContextual(100);{const c=this.isContextual(96)&&this.startsAwaitUsing(),h=c||this.isContextual(107)&&this.allowsForUsing(),l=e&&this.hasFollowingBindingAtom()||h;if(this.match(74)||this.match(75)||l){const u=this.startNode();let f;c?(f="await using",this.recordAwaitIfAllowed()||this.raise(p.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):f=this.state.value,this.next(),this.parseVar(u,!0,f);const d=this.finishNode(u,"VariableDeclaration"),P=this.match(58);return P&&h&&this.raise(p.ForInUsing,d),(P||this.isContextual(102))&&d.declarations.length===1?this.parseForIn(t,d,s):(s!==null&&this.unexpected(s),this.parseFor(t,d))}}const i=this.isContextual(95),a=new Lt,n=this.parseExpression(!0,a),o=this.isContextual(102);if(o&&(e&&this.raise(p.ForOfLet,n),s===null&&i&&n.type==="Identifier"&&this.raise(p.ForOfAsync,n)),o||this.match(58)){this.checkDestructuringPrivate(a),this.toAssignable(n,!0);const c=o?"ForOfStatement":"ForInStatement";return this.checkLVal(n,{type:c}),this.parseForIn(t,n,s)}else this.checkExpressionErrors(a,!0);return s!==null&&this.unexpected(s),this.parseFor(t,n)}parseFunctionStatement(t,s,e){return this.next(),this.parseFunction(t,1|(e?2:0)|(s?8:0))}parseIfStatement(t){return this.next(),t.test=this.parseHeaderExpression(),t.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),t.alternate=this.eat(66)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(t,"IfStatement")}parseReturnStatement(t){return!this.prodParam.hasReturn&&!(this.optionFlags&2)&&this.raise(p.IllegalReturn,this.state.startLoc),this.next(),this.isLineTerminator()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")}parseSwitchStatement(t){this.next(),t.discriminant=this.parseHeaderExpression();const s=t.cases=[];this.expect(5),this.state.labels.push(kn),this.scope.enter(256);let e;for(let i;!this.match(8);)if(this.match(61)||this.match(65)){const a=this.match(61);e&&this.finishNode(e,"SwitchCase"),s.push(e=this.startNode()),e.consequent=[],this.next(),a?e.test=this.parseExpression():(i&&this.raise(p.MultipleDefaultsInSwitch,this.state.lastTokStartLoc),i=!0,e.test=null),this.expect(14)}else e?e.consequent.push(this.parseStatementListItem()):this.unexpected();return this.scope.exit(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.state.labels.pop(),this.finishNode(t,"SwitchStatement")}parseThrowStatement(t){return this.next(),this.hasPrecedingLineBreak()&&this.raise(p.NewlineAfterThrow,this.state.lastTokEndLoc),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")}parseCatchClauseParam(){const t=this.parseBindingAtom();return this.scope.enter(this.options.annexB&&t.type==="Identifier"?8:0),this.checkLVal(t,{type:"CatchClause"},9),t}parseTryStatement(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.match(62)){const s=this.startNode();this.next(),this.match(10)?(this.expect(10),s.param=this.parseCatchClauseParam(),this.expect(11)):(s.param=null,this.scope.enter(0)),s.body=this.withSmartMixTopicForbiddingContext(()=>this.parseBlock(!1,!1)),this.scope.exit(),t.handler=this.finishNode(s,"CatchClause")}return t.finalizer=this.eat(67)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(p.NoCatchOrFinally,t),this.finishNode(t,"TryStatement")}parseVarStatement(t,s,e=!1){return this.next(),this.parseVar(t,!1,s,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")}parseWhileStatement(t){return this.next(),t.test=this.parseHeaderExpression(),this.state.labels.push(Ts),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.state.labels.pop(),this.finishNode(t,"WhileStatement")}parseWithStatement(t){return this.state.strict&&this.raise(p.StrictWith,this.state.startLoc),this.next(),t.object=this.parseHeaderExpression(),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.finishNode(t,"WithStatement")}parseEmptyStatement(t){return this.next(),this.finishNode(t,"EmptyStatement")}parseLabeledStatement(t,s,e,i){for(const n of this.state.labels)n.name===s&&this.raise(p.LabelRedeclaration,e,{labelName:s});const a=ba(this.state.type)?1:this.match(71)?2:null;for(let n=this.state.labels.length-1;n>=0;n--){const o=this.state.labels[n];if(o.statementStart===t.start)o.statementStart=this.sourceToOffsetPos(this.state.start),o.kind=a;else break}return this.state.labels.push({name:s,kind:a,statementStart:this.sourceToOffsetPos(this.state.start)}),t.body=i&8?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),t.label=e,this.finishNode(t,"LabeledStatement")}parseExpressionStatement(t,s,e){return t.expression=s,this.semicolon(),this.finishNode(t,"ExpressionStatement")}parseBlock(t=!1,s=!0,e){const i=this.startNode();return t&&this.state.strictErrors.clear(),this.expect(5),s&&this.scope.enter(0),this.parseBlockBody(i,t,!1,8,e),s&&this.scope.exit(),this.finishNode(i,"BlockStatement")}isValidDirective(t){return t.type==="ExpressionStatement"&&t.expression.type==="StringLiteral"&&!t.expression.extra.parenthesized}parseBlockBody(t,s,e,i,a){const n=t.body=[],o=t.directives=[];this.parseBlockOrModuleBlockBody(n,s?o:void 0,e,i,a)}parseBlockOrModuleBlockBody(t,s,e,i,a){const n=this.state.strict;let o=!1,c=!1;for(;!this.match(i);){const h=e?this.parseModuleItem():this.parseStatementListItem();if(s&&!c){if(this.isValidDirective(h)){const l=this.stmtToDirective(h);s.push(l),!o&&l.value.value==="use strict"&&(o=!0,this.setStrict(!0));continue}c=!0,this.state.strictErrors.clear()}t.push(h)}a==null||a.call(this,o),n||this.setStrict(!1),this.next()}parseFor(t,s){return t.init=s,this.semicolon(!1),t.test=this.match(13)?null:this.parseExpression(),this.semicolon(!1),t.update=this.match(11)?null:this.parseExpression(),this.expect(11),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.scope.exit(),this.state.labels.pop(),this.finishNode(t,"ForStatement")}parseForIn(t,s,e){const i=this.match(58);return this.next(),i?e!==null&&this.unexpected(e):t.await=e!==null,s.type==="VariableDeclaration"&&s.declarations[0].init!=null&&(!i||!this.options.annexB||this.state.strict||s.kind!=="var"||s.declarations[0].id.type!=="Identifier")&&this.raise(p.ForInOfLoopInitializer,s,{type:i?"ForInStatement":"ForOfStatement"}),s.type==="AssignmentPattern"&&this.raise(p.InvalidLhs,s,{ancestor:{type:"ForStatement"}}),t.left=s,t.right=i?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(11),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.scope.exit(),this.state.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")}parseVar(t,s,e,i=!1){const a=t.declarations=[];for(t.kind=e;;){const n=this.startNode();if(this.parseVarId(n,e),n.init=this.eat(29)?s?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn():null,n.init===null&&!i&&(n.id.type!=="Identifier"&&!(s&&(this.match(58)||this.isContextual(102)))?this.raise(p.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"destructuring"}):(e==="const"||e==="using"||e==="await using")&&!(this.match(58)||this.isContextual(102))&&this.raise(p.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:e})),a.push(this.finishNode(n,"VariableDeclarator")),!this.eat(12))break}return t}parseVarId(t,s){const e=this.parseBindingAtom();(s==="using"||s==="await using")&&(e.type==="ArrayPattern"||e.type==="ObjectPattern")&&this.raise(p.UsingDeclarationHasBindingPattern,e.loc.start),this.checkLVal(e,{type:"VariableDeclarator"},s==="var"?5:8201),t.id=e}parseAsyncFunctionExpression(t){return this.parseFunction(t,8)}parseFunction(t,s=0){const e=s&2,i=!!(s&1),a=i&&!(s&4),n=!!(s&8);this.initFunction(t,n),this.match(55)&&(e&&this.raise(p.GeneratorInSingleStatementContext,this.state.startLoc),this.next(),t.generator=!0),i&&(t.id=this.parseFunctionId(a));const o=this.state.maybeInArrowParameters;return this.state.maybeInArrowParameters=!1,this.scope.enter(2),this.prodParam.enter(vt(n,t.generator)),i||(t.id=this.parseFunctionId()),this.parseFunctionParams(t,!1),this.withSmartMixTopicForbiddingContext(()=>{this.parseFunctionBodyAndFinish(t,i?"FunctionDeclaration":"FunctionExpression")}),this.prodParam.exit(),this.scope.exit(),i&&!e&&this.registerFunctionStatementId(t),this.state.maybeInArrowParameters=o,t}parseFunctionId(t){return t||O(this.state.type)?this.parseIdentifier():null}parseFunctionParams(t,s){this.expect(10),this.expressionScope.enter(ln()),t.params=this.parseBindingList(11,41,2|(s?4:0)),this.expressionScope.exit()}registerFunctionStatementId(t){t.id&&this.scope.declareName(t.id.name,!this.options.annexB||this.state.strict||t.generator||t.async?this.scope.treatFunctionsAsVar?5:8201:17,t.id.loc.start)}parseClass(t,s,e){this.next();const i=this.state.strict;return this.state.strict=!0,this.parseClassId(t,s,e),this.parseClassSuper(t),t.body=this.parseClassBody(!!t.superClass,i),this.finishNode(t,s?"ClassDeclaration":"ClassExpression")}isClassProperty(){return this.match(29)||this.match(13)||this.match(8)}isClassMethod(){return this.match(10)}nameIsConstructor(t){return t.type==="Identifier"&&t.name==="constructor"||t.type==="StringLiteral"&&t.value==="constructor"}isNonstaticConstructor(t){return!t.computed&&!t.static&&this.nameIsConstructor(t.key)}parseClassBody(t,s){this.classScope.enter();const e={hadConstructor:!1,hadSuperClass:t};let i=[];const a=this.startNode();if(a.body=[],this.expect(5),this.withSmartMixTopicForbiddingContext(()=>{for(;!this.match(8);){if(this.eat(13)){if(i.length>0)throw this.raise(p.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(26)){i.push(this.parseDecorator());continue}const n=this.startNode();i.length&&(n.decorators=i,this.resetStartLocationFromNode(n,i[0]),i=[]),this.parseClassMember(a,n,e),n.kind==="constructor"&&n.decorators&&n.decorators.length>0&&this.raise(p.DecoratorConstructor,n)}}),this.state.strict=s,this.next(),i.length)throw this.raise(p.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(a,"ClassBody")}parseClassMemberFromModifier(t,s){const e=this.parseIdentifier(!0);if(this.isClassMethod()){const i=s;return i.kind="method",i.computed=!1,i.key=e,i.static=!1,this.pushClassMethod(t,i,!1,!1,!1,!1),!0}else if(this.isClassProperty()){const i=s;return i.computed=!1,i.key=e,i.static=!1,t.body.push(this.parseClassProperty(i)),!0}return this.resetPreviousNodeTrailingComments(e),!1}parseClassMember(t,s,e){const i=this.isContextual(106);if(i){if(this.parseClassMemberFromModifier(t,s))return;if(this.eat(5)){this.parseClassStaticBlock(t,s);return}}this.parseClassMemberWithIsStatic(t,s,e,i)}parseClassMemberWithIsStatic(t,s,e,i){const a=s,n=s,o=s,c=s,h=s,l=a,u=a;if(s.static=i,this.parsePropertyNamePrefixOperator(s),this.eat(55)){l.kind="method";const I=this.match(139);if(this.parseClassElementName(l),this.parsePostMemberNameModifiers(l),I){this.pushClassPrivateMethod(t,n,!0,!1);return}this.isNonstaticConstructor(a)&&this.raise(p.ConstructorIsGenerator,a.key),this.pushClassMethod(t,a,!0,!1,!1,!1);return}const f=!this.state.containsEsc&&O(this.state.type),d=this.parseClassElementName(s),P=f?d.name:null,S=this.isPrivateName(d),B=this.state.startLoc;if(this.parsePostMemberNameModifiers(u),this.isClassMethod()){if(l.kind="method",S){this.pushClassPrivateMethod(t,n,!1,!1);return}const I=this.isNonstaticConstructor(a);let D=!1;I&&(a.kind="constructor",e.hadConstructor&&!this.hasPlugin("typescript")&&this.raise(p.DuplicateConstructor,d),I&&this.hasPlugin("typescript")&&s.override&&this.raise(p.OverrideOnConstructor,d),e.hadConstructor=!0,D=e.hadSuperClass),this.pushClassMethod(t,a,!1,!1,I,D)}else if(this.isClassProperty())S?this.pushClassPrivateProperty(t,c):this.pushClassProperty(t,o);else if(P==="async"&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(d);const I=this.eat(55);u.optional&&this.unexpected(B),l.kind="method";const D=this.match(139);this.parseClassElementName(l),this.parsePostMemberNameModifiers(u),D?this.pushClassPrivateMethod(t,n,I,!0):(this.isNonstaticConstructor(a)&&this.raise(p.ConstructorIsAsync,a.key),this.pushClassMethod(t,a,I,!0,!1,!1))}else if((P==="get"||P==="set")&&!(this.match(55)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(d),l.kind=P;const I=this.match(139);this.parseClassElementName(a),I?this.pushClassPrivateMethod(t,n,!1,!1):(this.isNonstaticConstructor(a)&&this.raise(p.ConstructorIsAccessor,a.key),this.pushClassMethod(t,a,!1,!1,!1,!1)),this.checkGetterSetterParams(a)}else if(P==="accessor"&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(d);const I=this.match(139);this.parseClassElementName(o),this.pushClassAccessorProperty(t,h,I)}else this.isLineTerminator()?S?this.pushClassPrivateProperty(t,c):this.pushClassProperty(t,o):this.unexpected()}parseClassElementName(t){const{type:s,value:e}=this.state;if((s===132||s===134)&&t.static&&e==="prototype"&&this.raise(p.StaticPrototype,this.state.startLoc),s===139){e==="constructor"&&this.raise(p.ConstructorClassPrivateField,this.state.startLoc);const i=this.parsePrivateName();return t.key=i,i}return this.parsePropertyName(t),t.key}parseClassStaticBlock(t,s){var a;this.scope.enter(208);const e=this.state.labels;this.state.labels=[],this.prodParam.enter(0);const i=s.body=[];this.parseBlockOrModuleBlockBody(i,void 0,!1,8),this.prodParam.exit(),this.scope.exit(),this.state.labels=e,t.body.push(this.finishNode(s,"StaticBlock")),(a=s.decorators)!=null&&a.length&&this.raise(p.DecoratorStaticBlock,s)}pushClassProperty(t,s){!s.computed&&this.nameIsConstructor(s.key)&&this.raise(p.ConstructorClassField,s.key),t.body.push(this.parseClassProperty(s))}pushClassPrivateProperty(t,s){const e=this.parseClassPrivateProperty(s);t.body.push(e),this.classScope.declarePrivateName(this.getPrivateNameSV(e.key),0,e.key.loc.start)}pushClassAccessorProperty(t,s,e){!e&&!s.computed&&this.nameIsConstructor(s.key)&&this.raise(p.ConstructorClassField,s.key);const i=this.parseClassAccessorProperty(s);t.body.push(i),e&&this.classScope.declarePrivateName(this.getPrivateNameSV(i.key),0,i.key.loc.start)}pushClassMethod(t,s,e,i,a,n){t.body.push(this.parseMethod(s,e,i,a,n,"ClassMethod",!0))}pushClassPrivateMethod(t,s,e,i){const a=this.parseMethod(s,e,i,!1,!1,"ClassPrivateMethod",!0);t.body.push(a);const n=a.kind==="get"?a.static?6:2:a.kind==="set"?a.static?5:1:0;this.declareClassPrivateMethodInScope(a,n)}declareClassPrivateMethodInScope(t,s){this.classScope.declarePrivateName(this.getPrivateNameSV(t.key),s,t.key.loc.start)}parsePostMemberNameModifiers(t){}parseClassPrivateProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassPrivateProperty")}parseClassProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassProperty")}parseClassAccessorProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassAccessorProperty")}parseInitializer(t){this.scope.enter(80),this.expressionScope.enter(yi()),this.prodParam.enter(0),t.value=this.eat(29)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(t,s,e,i=8331){if(O(this.state.type))t.id=this.parseIdentifier(),s&&this.declareNameFromIdentifier(t.id,i);else if(e||!s)t.id=null;else throw this.raise(p.MissingClassName,this.state.startLoc)}parseClassSuper(t){t.superClass=this.eat(81)?this.parseExprSubscripts():null}parseExport(t,s){var f;const e=this.parseMaybeImportPhase(t,!0),i=this.maybeParseExportDefaultSpecifier(t,e),a=!i||this.eat(12),n=a&&this.eatExportStar(t),o=n&&this.maybeParseExportNamespaceSpecifier(t),c=a&&(!o||this.eat(12)),h=i||n;if(n&&!o){if(i&&this.unexpected(),s)throw this.raise(p.UnsupportedDecoratorExport,t);return this.parseExportFrom(t,!0),this.sawUnambiguousESM=!0,this.finishNode(t,"ExportAllDeclaration")}const l=this.maybeParseExportNamedSpecifiers(t);i&&a&&!n&&!l&&this.unexpected(null,5),o&&c&&this.unexpected(null,98);let u;if(h||l){if(u=!1,s)throw this.raise(p.UnsupportedDecoratorExport,t);this.parseExportFrom(t,h)}else u=this.maybeParseExportDeclaration(t);if(h||l||u){const d=t;if(this.checkExport(d,!0,!1,!!d.source),((f=d.declaration)==null?void 0:f.type)==="ClassDeclaration")this.maybeTakeDecorators(s,d.declaration,d);else if(s)throw this.raise(p.UnsupportedDecoratorExport,t);return this.sawUnambiguousESM=!0,this.finishNode(d,"ExportNamedDeclaration")}if(this.eat(65)){const d=t,P=this.parseExportDefaultExpression();if(d.declaration=P,P.type==="ClassDeclaration")this.maybeTakeDecorators(s,P,d);else if(s)throw this.raise(p.UnsupportedDecoratorExport,t);return this.checkExport(d,!0,!0),this.sawUnambiguousESM=!0,this.finishNode(d,"ExportDefaultDeclaration")}this.unexpected(null,5)}eatExportStar(t){return this.eat(55)}maybeParseExportDefaultSpecifier(t,s){if(s||this.isExportDefaultSpecifier()){this.expectPlugin("exportDefaultFrom",s==null?void 0:s.loc.start);const e=s||this.parseIdentifier(!0),i=this.startNodeAtNode(e);return i.exported=e,t.specifiers=[this.finishNode(i,"ExportDefaultSpecifier")],!0}return!1}maybeParseExportNamespaceSpecifier(t){if(this.isContextual(93)){t.specifiers??(t.specifiers=[]);const s=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),s.exported=this.parseModuleExportName(),t.specifiers.push(this.finishNode(s,"ExportNamespaceSpecifier")),!0}return!1}maybeParseExportNamedSpecifiers(t){if(this.match(5)){const s=t;s.specifiers||(s.specifiers=[]);const e=s.exportKind==="type";return s.specifiers.push(...this.parseExportSpecifiers(e)),s.source=null,s.attributes=[],s.declaration=null,!0}return!1}maybeParseExportDeclaration(t){return this.shouldParseExportDeclaration()?(t.specifiers=[],t.source=null,t.attributes=[],t.declaration=this.parseExportDeclaration(t),!0):!1}isAsyncFunction(){if(!this.isContextual(95))return!1;const t=this.nextTokenInLineStart();return this.isUnparsedContextual(t,"function")}parseExportDefaultExpression(){const t=this.startNode();if(this.match(68))return this.next(),this.parseFunction(t,5);if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(t,13);if(this.match(80))return this.parseClass(t,!0,!0);if(this.match(26))return this.hasPlugin("decorators")&&this.getPluginOption("decorators","decoratorsBeforeExport")===!0&&this.raise(p.DecoratorBeforeExport,this.state.startLoc),this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(75)||this.match(74)||this.isLet())throw this.raise(p.UnsupportedDefaultExport,this.state.startLoc);const s=this.parseMaybeAssignAllowIn();return this.semicolon(),s}parseExportDeclaration(t){return this.match(80)?this.parseClass(this.startNode(),!0,!1):this.parseStatementListItem()}isExportDefaultSpecifier(){const{type:t}=this.state;if(O(t)){if(t===95&&!this.state.containsEsc||t===100)return!1;if((t===130||t===129)&&!this.state.containsEsc){const{type:i}=this.lookahead();if(O(i)&&i!==98||i===5)return this.expectOnePlugin(["flow","typescript"]),!1}}else if(!this.match(65))return!1;const s=this.nextTokenStart(),e=this.isUnparsedContextual(s,"from");if(this.input.charCodeAt(s)===44||O(this.state.type)&&e)return!0;if(this.match(65)&&e){const i=this.input.charCodeAt(this.nextTokenStartSince(s+4));return i===34||i===39}return!1}parseExportFrom(t,s){this.eatContextual(98)?(t.source=this.parseImportSource(),this.checkExport(t),this.maybeParseImportAttributes(t),this.checkJSONModuleImport(t)):s&&this.unexpected(),this.semicolon()}shouldParseExportDeclaration(){const{type:t}=this.state;return t===26&&(this.expectOnePlugin(["decorators","decorators-legacy"]),this.hasPlugin("decorators"))?(this.getPluginOption("decorators","decoratorsBeforeExport")===!0&&this.raise(p.DecoratorBeforeExport,this.state.startLoc),!0):this.isContextual(107)?(this.raise(p.UsingDeclarationExport,this.state.startLoc),!0):this.isContextual(96)&&this.startsAwaitUsing()?(this.raise(p.UsingDeclarationExport,this.state.startLoc),!0):t===74||t===75||t===68||t===80||this.isLet()||this.isAsyncFunction()}checkExport(t,s,e,i){var a,n;if(s){if(e){if(this.checkDuplicateExports(t,"default"),this.hasPlugin("exportDefaultFrom")){const o=t.declaration;o.type==="Identifier"&&o.name==="from"&&o.end-o.start===4&&!((a=o.extra)!=null&&a.parenthesized)&&this.raise(p.ExportDefaultFromAsIdentifier,o)}}else if((n=t.specifiers)!=null&&n.length)for(const o of t.specifiers){const{exported:c}=o,h=c.type==="Identifier"?c.name:c.value;if(this.checkDuplicateExports(o,h),!i&&o.local){const{local:l}=o;l.type!=="Identifier"?this.raise(p.ExportBindingIsString,o,{localName:l.value,exportName:h}):(this.checkReservedWord(l.name,l.loc.start,!0,!1),this.scope.checkLocalExport(l))}}else if(t.declaration){const o=t.declaration;if(o.type==="FunctionDeclaration"||o.type==="ClassDeclaration"){const{id:c}=o;if(!c)throw new Error("Assertion failure");this.checkDuplicateExports(t,c.name)}else if(o.type==="VariableDeclaration")for(const c of o.declarations)this.checkDeclaration(c.id)}}}checkDeclaration(t){if(t.type==="Identifier")this.checkDuplicateExports(t,t.name);else if(t.type==="ObjectPattern")for(const s of t.properties)this.checkDeclaration(s);else if(t.type==="ArrayPattern")for(const s of t.elements)s&&this.checkDeclaration(s);else t.type==="ObjectProperty"?this.checkDeclaration(t.value):t.type==="RestElement"?this.checkDeclaration(t.argument):t.type==="AssignmentPattern"&&this.checkDeclaration(t.left)}checkDuplicateExports(t,s){this.exportedIdentifiers.has(s)&&(s==="default"?this.raise(p.DuplicateDefaultExport,t):this.raise(p.DuplicateExport,t,{exportName:s})),this.exportedIdentifiers.add(s)}parseExportSpecifiers(t){const s=[];let e=!0;for(this.expect(5);!this.eat(8);){if(e)e=!1;else if(this.expect(12),this.eat(8))break;const i=this.isContextual(130),a=this.match(134),n=this.startNode();n.local=this.parseModuleExportName(),s.push(this.parseExportSpecifier(n,a,t,i))}return s}parseExportSpecifier(t,s,e,i){return this.eatContextual(93)?t.exported=this.parseModuleExportName():s?t.exported=this.cloneStringLiteral(t.local):t.exported||(t.exported=this.cloneIdentifier(t.local)),this.finishNode(t,"ExportSpecifier")}parseModuleExportName(){if(this.match(134)){const t=this.parseStringLiteral(this.state.value),s=Nn.exec(t.value);return s&&this.raise(p.ModuleExportNameHasLoneSurrogate,t,{surrogateCharCode:s[0].charCodeAt(0)}),t}return this.parseIdentifier(!0)}isJSONModuleImport(t){return t.assertions!=null?t.assertions.some(({key:s,value:e})=>e.value==="json"&&(s.type==="Identifier"?s.name==="type":s.value==="type")):!1}checkImportReflection(t){var i;const{specifiers:s}=t,e=s.length===1?s[0].type:null;t.phase==="source"?e!=="ImportDefaultSpecifier"&&this.raise(p.SourcePhaseImportRequiresDefault,s[0].loc.start):t.phase==="defer"?e!=="ImportNamespaceSpecifier"&&this.raise(p.DeferImportRequiresNamespace,s[0].loc.start):t.module&&(e!=="ImportDefaultSpecifier"&&this.raise(p.ImportReflectionNotBinding,s[0].loc.start),((i=t.assertions)==null?void 0:i.length)>0&&this.raise(p.ImportReflectionHasAssertion,s[0].loc.start))}checkJSONModuleImport(t){if(this.isJSONModuleImport(t)&&t.type!=="ExportAllDeclaration"){const{specifiers:s}=t;if(s!=null){const e=s.find(i=>{let a;if(i.type==="ExportSpecifier"?a=i.local:i.type==="ImportSpecifier"&&(a=i.imported),a!==void 0)return a.type==="Identifier"?a.name!=="default":a.value!=="default"});e!==void 0&&this.raise(p.ImportJSONBindingNotDefault,e.loc.start)}}}isPotentialImportPhase(t){return t?!1:this.isContextual(105)||this.isContextual(97)}applyImportPhase(t,s,e,i){s||(this.hasPlugin("importReflection")&&(t.module=!1),e==="source"?(this.expectPlugin("sourcePhaseImports",i),t.phase="source"):e==="defer"?(this.expectPlugin("deferredImportEvaluation",i),t.phase="defer"):this.hasPlugin("sourcePhaseImports")&&(t.phase=null))}parseMaybeImportPhase(t,s){if(!this.isPotentialImportPhase(s))return this.applyImportPhase(t,s,null),null;const e=this.startNode(),i=this.parseIdentifierName(!0),{type:a}=this.state;return(ue(a)?a!==98||this.lookaheadCharCode()===102:a!==12)?(this.applyImportPhase(t,s,i,e.loc.start),null):(this.applyImportPhase(t,s,null),this.createIdentifier(e,i))}isPrecedingIdImportPhase(t){const{type:s}=this.state;return O(s)?s!==98||this.lookaheadCharCode()===102:s!==12}parseImport(t){return this.match(134)?this.parseImportSourceAndAttributes(t):this.parseImportSpecifiersAndAfter(t,this.parseMaybeImportPhase(t,!1))}parseImportSpecifiersAndAfter(t,s){t.specifiers=[];const i=!this.maybeParseDefaultImportSpecifier(t,s)||this.eat(12),a=i&&this.maybeParseStarImportSpecifier(t);return i&&!a&&this.parseNamedImportSpecifiers(t),this.expectContextual(98),this.parseImportSourceAndAttributes(t)}parseImportSourceAndAttributes(t){return t.specifiers??(t.specifiers=[]),t.source=this.parseImportSource(),this.maybeParseImportAttributes(t),this.checkImportReflection(t),this.checkJSONModuleImport(t),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(t,"ImportDeclaration")}parseImportSource(){return this.match(134)||this.unexpected(),this.parseExprAtom()}parseImportSpecifierLocal(t,s,e){s.local=this.parseIdentifier(),t.specifiers.push(this.finishImportSpecifier(s,e))}finishImportSpecifier(t,s,e=8201){return this.checkLVal(t.local,{type:s},e),this.finishNode(t,s)}parseImportAttributes(){this.expect(5);const t=[],s=new Set;do{if(this.match(8))break;const e=this.startNode(),i=this.state.value;if(s.has(i)&&this.raise(p.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:i}),s.add(i),this.match(134)?e.key=this.parseStringLiteral(i):e.key=this.parseIdentifier(!0),this.expect(14),!this.match(134))throw this.raise(p.ModuleAttributeInvalidValue,this.state.startLoc);e.value=this.parseStringLiteral(this.state.value),t.push(this.finishNode(e,"ImportAttribute"))}while(this.eat(12));return this.expect(8),t}parseModuleAttributes(){const t=[],s=new Set;do{const e=this.startNode();if(e.key=this.parseIdentifier(!0),e.key.name!=="type"&&this.raise(p.ModuleAttributeDifferentFromType,e.key),s.has(e.key.name)&&this.raise(p.ModuleAttributesWithDuplicateKeys,e.key,{key:e.key.name}),s.add(e.key.name),this.expect(14),!this.match(134))throw this.raise(p.ModuleAttributeInvalidValue,this.state.startLoc);e.value=this.parseStringLiteral(this.state.value),t.push(this.finishNode(e,"ImportAttribute"))}while(this.eat(12));return t}maybeParseImportAttributes(t){let s;if(this.match(76)){if(this.hasPrecedingLineBreak()&&this.lookaheadCharCode()===40)return;this.next(),s=this.parseImportAttributes()}else this.isContextual(94)&&!this.hasPrecedingLineBreak()?(this.hasPlugin("deprecatedImportAssert")||this.raise(p.ImportAttributesUseAssert,this.state.startLoc),this.addExtra(t,"deprecatedAssertSyntax",!0),this.next(),s=this.parseImportAttributes()):s=[];t.attributes=s}maybeParseDefaultImportSpecifier(t,s){if(s){const e=this.startNodeAtNode(s);return e.local=s,t.specifiers.push(this.finishImportSpecifier(e,"ImportDefaultSpecifier")),!0}else if(ue(this.state.type))return this.parseImportSpecifierLocal(t,this.startNode(),"ImportDefaultSpecifier"),!0;return!1}maybeParseStarImportSpecifier(t){if(this.match(55)){const s=this.startNode();return this.next(),this.expectContextual(93),this.parseImportSpecifierLocal(t,s,"ImportNamespaceSpecifier"),!0}return!1}parseNamedImportSpecifiers(t){let s=!0;for(this.expect(5);!this.eat(8);){if(s)s=!1;else{if(this.eat(14))throw this.raise(p.DestructureNamedImport,this.state.startLoc);if(this.expect(12),this.eat(8))break}const e=this.startNode(),i=this.match(134),a=this.isContextual(130);e.imported=this.parseModuleExportName();const n=this.parseImportSpecifier(e,i,t.importKind==="type"||t.importKind==="typeof",a,void 0);t.specifiers.push(n)}}parseImportSpecifier(t,s,e,i,a){if(this.eatContextual(93))t.local=this.parseIdentifier();else{const{imported:n}=t;if(s)throw this.raise(p.ImportBindingIsString,t,{importName:n.value});this.checkReservedWord(n.name,t.loc.start,!0,!0),t.local||(t.local=this.cloneIdentifier(n))}return this.finishImportSpecifier(t,"ImportSpecifier",a)}isThisParam(t){return t.type==="Identifier"&&t.name==="this"}}class Ci extends On{constructor(t,s,e){t=ua(t),super(t,s),this.options=t,this.initializeScopes(),this.plugins=e,this.filename=t.sourceFilename,this.startIndex=t.startIndex;let i=0;t.allowAwaitOutsideFunction&&(i|=1),t.allowReturnOutsideFunction&&(i|=2),t.allowImportExportEverywhere&&(i|=8),t.allowSuperOutsideMethod&&(i|=16),t.allowUndeclaredExports&&(i|=64),t.allowNewTargetOutsideFunction&&(i|=4),t.allowYieldOutsideFunction&&(i|=32),t.ranges&&(i|=128),t.tokens&&(i|=256),t.createImportExpressions&&(i|=512),t.createParenthesizedExpressions&&(i|=1024),t.errorRecovery&&(i|=2048),t.attachComment&&(i|=4096),t.annexB&&(i|=8192),this.optionFlags=i}getScopeHandler(){return ms}parse(){this.enterInitialScopes();const t=this.startNode(),s=this.startNode();return this.nextToken(),t.errors=null,this.parseTopLevel(t,s),t.errors=this.state.errors,t.comments.length=this.state.commentsLen,t}}function ki(r,t){if((t==null?void 0:t.sourceType)==="unambiguous"){t=Object.assign({},t);try{t.sourceType="module";const s=Mt(t,r),e=s.parse();if(s.sawUnambiguousESM)return e;if(s.ambiguousScriptDifferentAst)try{return t.sourceType="script",Mt(t,r).parse()}catch{}else e.program.sourceType="script";return e}catch(s){try{return t.sourceType="script",Mt(t,r).parse()}catch{}throw s}}else return Mt(t,r).parse()}function Dn(r){const t={};for(const s of Object.keys(r))t[s]=ti(r[s]);return t}Dn(ma);function Mt(r,t){let s=Ci;const e=new Map;if(r!=null&&r.plugins){for(const i of r.plugins){let a,n;typeof i=="string"?a=i:[a,n]=i,e.has(a)||e.set(a,n||{})}In(e),s=Ln(e)}return new s(r,t,e)}const Ni=new Map;function Ln(r){const t=[];for(const i of En)r.has(i)&&t.push(i);const s=t.join("|");let e=Ni.get(s);if(!e){e=Ci;for(const i of t)e=Ei[i](e);Ni.set(s,e)}return e}function ut(r){if(!r)return null;switch(r.type){case"ObjectExpression":return r.properties.reduce((n,o)=>{if(o.type==="ObjectProperty"){const c=o;let h;if(c.key.type==="Identifier")h=c.key.name;else if(c.key.type==="StringLiteral"||c.key.type==="NumericLiteral")h=c.key.value;else throw new Error(`Unsupported key type in ObjectProperty: ${c.key.type}`);n[h]=ut(c.value)}else if(o.type!=="SpreadElement"&&o.type!=="ObjectMethod")throw new Error(`Unsupported property type in ObjectExpression: ${o.type}`);return n},{});case"ArrayExpression":return r.elements.map(n=>{if(!(n&&n.type==="SpreadElement"))return ut(n)}).filter(n=>n!==void 0);case"ObjectProperty":const e=r;let i;if(e.key.type==="Identifier")i=e.key.name;else if(e.key.type==="StringLiteral"||e.key.type==="NumericLiteral")i=e.key.value;else throw new Error(`Unsupported key type for standalone ObjectProperty: ${e.key.type}`);const a={};return a[i]=ut(e.value),a;case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":return r.value;case"NullLiteral":return null;default:throw new Error(`Unsupported AST node type for JSON conversion: ${r.type}`)}}function He(r){switch(r.key.type){case"Identifier":return r.key.name;case"StringLiteral":return r.key.value;default:throw new Error(`Could not extract entities, expected object key to be an \`Identifier\` or \`StringLiteral\`, got \`${r.key.type}\`.`)}}function vi(r,t){const s={};for(const e of t.properties){if(e.type!=="ObjectProperty")throw new Error(`Expected i.entity for \`${r}\` to contain only \`ObjectProperty\`, got \`${e.type}\`.`);const i=He(e),a=[];if(e.value.type!=="CallExpression")throw new Error(`Could not extract \`${r}.${i}\`. Expected a call to \`i.string()\`, \`i.number()\`, etc. Got something else.`);let n=e.value,o=null;for(;n;){if(n.callee.type!=="MemberExpression"||n.callee.property.type!=="Identifier"||!(n.callee.object.type==="CallExpression"||n.callee.object.type==="Identifier"&&n.callee.object.name==="i"))throw new Error(`Could not extract \`${r}.${i}\`. Expected a call to \`i.string()\`, \`i.number()\`, etc. Got something else.`);if(n.callee.object.type==="CallExpression")a.push(n.callee.property.name),n=n.callee.object;else{switch(n.callee.property.name){case"string":{o=G.string();break}case"number":{o=G.number();break}case"boolean":{o=G.boolean();break}case"date":{o=G.date();break}case"json":{o=G.json();break}case"any":{o=G.any();break}}n=null}}if(!o)throw new Error(`Could not extract \`${r}.${i}\`. Found no call to \`i.string()\`, \`i.number()\`, etc.`);for(const c of a.reverse())switch(c){case"indexed":{o=o.indexed();break}case"unique":{o=o.unique();break}case"optional":{o=o.optional();break}case"clientRequired":{o=o.clientRequired();break}default:throw new Error(`Could not extract \`${r}.${i}\`. Found a call to \`${c}()\` that is not recognized.`)}s[i]=o}return G.entity(s)}function Oi(r){const t={};for(const s of r.properties){if(s.type!=="ObjectProperty")throw new Error(`Expected entities to contain only \`ObjectProperty\`, got \`${s.type}\`.`);const e=He(s);if(s.value.type!=="CallExpression"||s.value.callee.type!=="MemberExpression"||s.value.callee.object.type!=="Identifier"||s.value.callee.object.name!=="i"||s.value.arguments.length!==1||s.value.arguments[0].type!=="ObjectExpression")throw new Error(`Could not extract entity \`${e}\`. Expected a call to \`i.entity()\`, got something else.`);t[e]=vi(e,s.value.arguments[0])}return t}function Mn(r,t){let s=null,e;for(const i of t.properties){if(i.type!=="ObjectProperty")throw new Error(`Expected entities to contain only \`ObjectProperty\`, got \`${i.type}\`.`);const a=He(i);switch(a){case"topics":{if(i.value.type!=="ObjectExpression")throw new Error(`Could not exxtract \`rooms.${r}.topics\`. Expected an object, got \`${i.value.type}\`.`);e=Oi(i.value);break}case"presence":{if(i.value.type!=="CallExpression"||i.value.callee.type!=="MemberExpression"||i.value.callee.object.type!=="Identifier"||i.value.callee.object.name!=="i"||i.value.arguments.length!==1||i.value.arguments[0].type!=="ObjectExpression")throw new Error(`Could not extract \`rooms.${r}.presence\`. Expected a call to \`i.entity()\`, got something else.`);s=vi(r,i.value.arguments[0]);break}default:throw new Error(`Could not extract \`rooms.${r}\`. Unexpected property \`${a}\`.`)}}if(!s)throw new Error(`Could not extract room ${r}, \`presence\` key was missing from room definition.`);return{presence:s,topics:e}}function Fn(r){const t={};for(const s of r.properties){if(s.type!=="ObjectProperty")throw new Error(`Expected entities to contain only \`ObjectProperty\`, got \`${s.type}\`.`);const e=He(s);if(s.value.type!=="ObjectExpression")throw new Error(`Could not extract room \`${e}\`. Expected an object with topics and presence keys, got \`${s.value.type}\`.`);t[e]=Mn(e,s.value)}return t}function Bn(r){let t=null,s={},e={};for(const i of r.program.body){if(i.type!=="VariableDeclaration"||i.declarations.length!==1||i.declarations[0].id.type!=="Identifier"||i.declarations[0].id.name!=="_schema")continue;const a=i.declarations[0];if(!a.init||a.init.type!=="CallExpression"||a.init.callee.type!=="MemberExpression"||a.init.callee.object.type!=="Identifier"||a.init.callee.object.name!=="i"||a.init.arguments.length!==1||a.init.arguments[0].type!=="ObjectExpression")throw new Error("Could not extract schema. Expected a call to `i.schema()`, got something else.");for(const n of a.init.arguments[0].properties){if(n.type!=="ObjectProperty")throw new Error(`Could not extra schema property, expected an \`ObjectProperty\`, got \`${n.type}'.`);const o=He(n);if(n.value.type!=="ObjectExpression")throw new Error(`Failed to extract ${o}, expected an \`ObjectExpression\`, got \`${n.value.type}\`.`);switch(He(n)){case"entities":{t=Oi(n.value);break}case"links":{s=ut(n.value)||{};break}case"rooms":{e=Fn(n.value);break}}}}if(!t)throw new Error("Could not extract schema, did not find any entities.");return G.schema({entities:t,links:s,rooms:e})}function Rn(r,t="instant.schema.ts"){var e;const s=ki(r,{sourceFilename:t,sourceType:"module",errorRecovery:!1,plugins:["typescript"]});if((e=s.errors)!=null&&e.length)throw new Error(`Could not parse schema file. ${s.errors[0].reasonCode}.`);return Bn(s)}function _n(r,t){const s=r&&Object.keys(r).length?JSON.stringify(r,null,2):`{
5
+ `):i=String.fromCharCode(e),++this.state.curLine,this.state.lineStart=this.state.pos,i}jsxReadString(s){let e="",i=++this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(p.UnterminatedString,this.state.startLoc);const a=this.input.charCodeAt(this.state.pos);if(a===s)break;a===38?(e+=this.input.slice(i,this.state.pos),e+=this.jsxReadEntity(),i=this.state.pos):qe(a)?(e+=this.input.slice(i,this.state.pos),e+=this.jsxReadNewLine(!1),i=this.state.pos):++this.state.pos}e+=this.input.slice(i,this.state.pos++),this.finishToken(134,e)}jsxReadEntity(){const s=++this.state.pos;if(this.codePointAtPos(this.state.pos)===35){++this.state.pos;let e=10;this.codePointAtPos(this.state.pos)===120&&(e=16,++this.state.pos);const i=this.readInt(e,void 0,!1,"bail");if(i!==null&&this.codePointAtPos(this.state.pos)===59)return++this.state.pos,String.fromCodePoint(i)}else{let e=0,i=!1;for(;e++<10&&this.state.pos<this.length&&!(i=this.codePointAtPos(this.state.pos)===59);)++this.state.pos;if(i){const a=this.input.slice(s,this.state.pos),n=Ya[a];if(++this.state.pos,n)return n}}return this.state.pos=s,"&"}jsxReadWord(){let s;const e=this.state.pos;do s=this.input.charCodeAt(++this.state.pos);while($e(s)||s===45);this.finishToken(141,this.input.slice(e,this.state.pos))}jsxParseIdentifier(){const s=this.startNode();return this.match(141)?s.name=this.state.value:us(this.state.type)?s.name=Ne(this.state.type):this.unexpected(),this.next(),this.finishNode(s,"JSXIdentifier")}jsxParseNamespacedName(){const s=this.state.startLoc,e=this.jsxParseIdentifier();if(!this.eat(14))return e;const i=this.startNodeAt(s);return i.namespace=e,i.name=this.jsxParseIdentifier(),this.finishNode(i,"JSXNamespacedName")}jsxParseElementName(){const s=this.state.startLoc;let e=this.jsxParseNamespacedName();if(e.type==="JSXNamespacedName")return e;for(;this.eat(16);){const i=this.startNodeAt(s);i.object=e,i.property=this.jsxParseIdentifier(),e=this.finishNode(i,"JSXMemberExpression")}return e}jsxParseAttributeValue(){let s;switch(this.state.type){case 5:return s=this.startNode(),this.setContext(R.brace),this.next(),s=this.jsxParseExpressionContainer(s,R.j_oTag),s.expression.type==="JSXEmptyExpression"&&this.raise(we.AttributeIsEmpty,s),s;case 143:case 134:return this.parseExprAtom();default:throw this.raise(we.UnsupportedJsxValue,this.state.startLoc)}}jsxParseEmptyExpression(){const s=this.startNodeAt(this.state.lastTokEndLoc);return this.finishNodeAt(s,"JSXEmptyExpression",this.state.startLoc)}jsxParseSpreadChild(s){return this.next(),s.expression=this.parseExpression(),this.setContext(R.j_expr),this.state.canStartJSXElement=!0,this.expect(8),this.finishNode(s,"JSXSpreadChild")}jsxParseExpressionContainer(s,e){var i;if(this.match(8))s.expression=this.jsxParseEmptyExpression();else{const a=this.parseExpression();a.type==="SequenceExpression"&&!((i=a.extra)!=null&&i.parenthesized)&&this.raise(we.UnexpectedSequenceExpression,a.expressions[1]),s.expression=a}return this.setContext(e),this.state.canStartJSXElement=!0,this.expect(8),this.finishNode(s,"JSXExpressionContainer")}jsxParseAttribute(){const s=this.startNode();return this.match(5)?(this.setContext(R.brace),this.next(),this.expect(21),s.argument=this.parseMaybeAssignAllowIn(),this.setContext(R.j_oTag),this.state.canStartJSXElement=!0,this.expect(8),this.finishNode(s,"JSXSpreadAttribute")):(s.name=this.jsxParseNamespacedName(),s.value=this.eat(29)?this.jsxParseAttributeValue():null,this.finishNode(s,"JSXAttribute"))}jsxParseOpeningElementAt(s){const e=this.startNodeAt(s);return this.eat(144)?this.finishNode(e,"JSXOpeningFragment"):(e.name=this.jsxParseElementName(),this.jsxParseOpeningElementAfterName(e))}jsxParseOpeningElementAfterName(s){const e=[];for(;!this.match(56)&&!this.match(144);)e.push(this.jsxParseAttribute());return s.attributes=e,s.selfClosing=this.eat(56),this.expect(144),this.finishNode(s,"JSXOpeningElement")}jsxParseClosingElementAt(s){const e=this.startNodeAt(s);return this.eat(144)?this.finishNode(e,"JSXClosingFragment"):(e.name=this.jsxParseElementName(),this.expect(144),this.finishNode(e,"JSXClosingElement"))}jsxParseElementAt(s){const e=this.startNodeAt(s),i=[],a=this.jsxParseOpeningElementAt(s);let n=null;if(!a.selfClosing){e:for(;;)switch(this.state.type){case 143:if(s=this.state.startLoc,this.next(),this.eat(56)){n=this.jsxParseClosingElementAt(s);break e}i.push(this.jsxParseElementAt(s));break;case 142:i.push(this.parseLiteral(this.state.value,"JSXText"));break;case 5:{const o=this.startNode();this.setContext(R.brace),this.next(),this.match(21)?i.push(this.jsxParseSpreadChild(o)):i.push(this.jsxParseExpressionContainer(o,R.j_expr));break}default:this.unexpected()}ve(a)&&!ve(n)&&n!==null?this.raise(we.MissingClosingTagFragment,n):!ve(a)&&ve(n)?this.raise(we.MissingClosingTagElement,n,{openingTagName:ze(a.name)}):!ve(a)&&!ve(n)&&ze(n.name)!==ze(a.name)&&this.raise(we.MissingClosingTagElement,n,{openingTagName:ze(a.name)})}if(ve(a)?(e.openingFragment=a,e.closingFragment=n):(e.openingElement=a,e.closingElement=n),e.children=i,this.match(47))throw this.raise(we.UnwrappedAdjacentJSXElements,this.state.startLoc);return ve(a)?this.finishNode(e,"JSXFragment"):this.finishNode(e,"JSXElement")}jsxParseElement(){const s=this.state.startLoc;return this.next(),this.jsxParseElementAt(s)}setContext(s){const{context:e}=this.state;e[e.length-1]=s}parseExprAtom(s){return this.match(143)?this.jsxParseElement():this.match(47)&&this.input.charCodeAt(this.state.pos)!==33?(this.replaceToken(143),this.jsxParseElement()):super.parseExprAtom(s)}skipSpace(){this.curContext().preserveSpace||super.skipSpace()}getTokenFromCode(s){const e=this.curContext();if(e===R.j_expr){this.jsxReadToken();return}if(e===R.j_oTag||e===R.j_cTag){if(ge(s)){this.jsxReadWord();return}if(s===62){++this.state.pos,this.finishToken(144);return}if((s===34||s===39)&&e===R.j_oTag){this.jsxReadString(s);return}}if(s===60&&this.state.canStartJSXElement&&this.input.charCodeAt(this.state.pos+1)!==33){++this.state.pos,this.finishToken(143);return}super.getTokenFromCode(s)}updateContext(s){const{context:e,type:i}=this.state;if(i===56&&s===143)e.splice(-2,2,R.j_cTag),this.state.canStartJSXElement=!1;else if(i===143)e.push(R.j_oTag);else if(i===144){const a=e[e.length-1];a===R.j_oTag&&s===56||a===R.j_cTag?(e.pop(),this.state.canStartJSXElement=e[e.length-1]===R.j_expr):(this.setContext(R.j_expr),this.state.canStartJSXElement=!0)}else this.state.canStartJSXElement=Sa(i)}};class tn extends ys{constructor(){super(...arguments);m(this,"tsNames",new Map)}}class sn extends xs{constructor(){super(...arguments);m(this,"importsStack",[])}createScope(s){return this.importsStack.push(new Set),new tn(s)}enter(s){s===512&&this.importsStack.push(new Set),super.enter(s)}exit(){const s=super.exit();return s===512&&this.importsStack.pop(),s}hasImport(s,e){const i=this.importsStack.length;if(this.importsStack[i-1].has(s))return!0;if(!e&&i>1){for(let a=0;a<i-1;a++)if(this.importsStack[a].has(s))return!0}return!1}declareName(s,e,i){if(e&4096){this.hasImport(s,!0)&&this.parser.raise(p.VarRedeclaration,i,{identifierName:s}),this.importsStack[this.importsStack.length-1].add(s);return}const a=this.currentScope();let n=a.tsNames.get(s)||0;if(e&1024){this.maybeExportDefined(a,s),a.tsNames.set(s,n|16);return}super.declareName(s,e,i),e&2&&(e&1||(this.checkRedeclarationInScope(a,s,e,i),this.maybeExportDefined(a,s)),n=n|1),e&256&&(n=n|2),e&512&&(n=n|4),e&128&&(n=n|8),n&&a.tsNames.set(s,n)}isRedeclaredInScope(s,e,i){const a=s.tsNames.get(e);if((a&2)>0){if(i&256){const n=!!(i&512),o=(a&4)>0;return n!==o}return!0}return i&128&&(a&8)>0?s.names.get(e)&2?!!(i&1):!1:i&2&&(a&1)>0?!0:super.isRedeclaredInScope(s,e,i)}checkLocalExport(s){const{name:e}=s;if(this.hasImport(e))return;const i=this.scopeStack.length;for(let a=i-1;a>=0;a--){const o=this.scopeStack[a].tsNames.get(e);if((o&1)>0||(o&16)>0)return}super.checkLocalExport(s)}}class rn{constructor(){m(this,"stacks",[])}enter(t){this.stacks.push(t)}exit(){this.stacks.pop()}currentFlags(){return this.stacks[this.stacks.length-1]}get hasAwait(){return(this.currentFlags()&2)>0}get hasYield(){return(this.currentFlags()&1)>0}get hasReturn(){return(this.currentFlags()&4)>0}get hasIn(){return(this.currentFlags()&8)>0}}function vt(r,t){return(r?2:0)|(t?1:0)}class an{constructor(){m(this,"sawUnambiguousESM",!1);m(this,"ambiguousScriptDifferentAst",!1)}sourceToOffsetPos(t){return t+this.startIndex}offsetToSourcePos(t){return t-this.startIndex}hasPlugin(t){if(typeof t=="string")return this.plugins.has(t);{const[s,e]=t;if(!this.hasPlugin(s))return!1;const i=this.plugins.get(s);for(const a of Object.keys(e))if((i==null?void 0:i[a])!==e[a])return!1;return!0}}getPluginOption(t,s){var e;return(e=this.plugins.get(t))==null?void 0:e[s]}}function ui(r,t){r.trailingComments===void 0?r.trailingComments=t:r.trailingComments.unshift(...t)}function nn(r,t){r.leadingComments===void 0?r.leadingComments=t:r.leadingComments.unshift(...t)}function Ve(r,t){r.innerComments===void 0?r.innerComments=t:r.innerComments.unshift(...t)}function Re(r,t,s){let e=null,i=t.length;for(;e===null&&i>0;)e=t[--i];e===null||e.start>s.start?Ve(r,s.comments):ui(e,s.comments)}class on extends an{addComment(t){this.filename&&(t.loc.filename=this.filename);const{commentsLen:s}=this.state;this.comments.length!==s&&(this.comments.length=s),this.comments.push(t),this.state.commentsLen++}processComment(t){const{commentStack:s}=this.state,e=s.length;if(e===0)return;let i=e-1;const a=s[i];a.start===t.end&&(a.leadingNode=t,i--);const{start:n}=t;for(;i>=0;i--){const o=s[i],c=o.end;if(c>n)o.containingNode=t,this.finalizeComment(o),s.splice(i,1);else{c===n&&(o.trailingNode=t);break}}}finalizeComment(t){const{comments:s}=t;if(t.leadingNode!==null||t.trailingNode!==null)t.leadingNode!==null&&ui(t.leadingNode,s),t.trailingNode!==null&&nn(t.trailingNode,s);else{const{containingNode:e,start:i}=t;if(this.input.charCodeAt(this.offsetToSourcePos(i)-1)===44)switch(e.type){case"ObjectExpression":case"ObjectPattern":case"RecordExpression":Re(e,e.properties,t);break;case"CallExpression":case"OptionalCallExpression":Re(e,e.arguments,t);break;case"ImportExpression":Re(e,[e.source,e.options??null],t);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":Re(e,e.params,t);break;case"ArrayExpression":case"ArrayPattern":case"TupleExpression":Re(e,e.elements,t);break;case"ExportNamedDeclaration":case"ImportDeclaration":Re(e,e.specifiers,t);break;case"TSEnumDeclaration":Ve(e,s);break;case"TSEnumBody":Re(e,e.members,t);break;default:Ve(e,s)}else Ve(e,s)}}finalizeRemainingComments(){const{commentStack:t}=this.state;for(let s=t.length-1;s>=0;s--)this.finalizeComment(t[s]);this.state.commentStack=[]}resetPreviousNodeTrailingComments(t){const{commentStack:s}=this.state,{length:e}=s;if(e===0)return;const i=s[e-1];i.leadingNode===t&&(i.leadingNode=null)}takeSurroundingComments(t,s,e){const{commentStack:i}=this.state,a=i.length;if(a===0)return;let n=a-1;for(;n>=0;n--){const o=i[n],c=o.end;if(o.start===e)o.leadingNode=t;else if(c===s)o.trailingNode=t;else if(c<s)break}}}class gs{constructor(){m(this,"flags",1024);m(this,"startIndex");m(this,"curLine");m(this,"lineStart");m(this,"startLoc");m(this,"endLoc");m(this,"errors",[]);m(this,"potentialArrowAt",-1);m(this,"noArrowAt",[]);m(this,"noArrowParamsConversionAt",[]);m(this,"topicContext",{maxNumOfResolvableTopics:0,maxTopicIndex:null});m(this,"labels",[]);m(this,"commentsLen",0);m(this,"commentStack",[]);m(this,"pos",0);m(this,"type",140);m(this,"value",null);m(this,"start",0);m(this,"end",0);m(this,"lastTokEndLoc",null);m(this,"lastTokStartLoc",null);m(this,"context",[R.brace]);m(this,"firstInvalidTemplateEscapePos",null);m(this,"strictErrors",new Map);m(this,"tokensLength",0)}get strict(){return(this.flags&1)>0}set strict(t){t?this.flags|=1:this.flags&=-2}init({strictMode:t,sourceType:s,startIndex:e,startLine:i,startColumn:a}){this.strict=t===!1?!1:t===!0?!0:s==="module",this.startIndex=e,this.curLine=i,this.lineStart=-a,this.startLoc=this.endLoc=new Ce(i,a,e)}get maybeInArrowParameters(){return(this.flags&2)>0}set maybeInArrowParameters(t){t?this.flags|=2:this.flags&=-3}get inType(){return(this.flags&4)>0}set inType(t){t?this.flags|=4:this.flags&=-5}get noAnonFunctionType(){return(this.flags&8)>0}set noAnonFunctionType(t){t?this.flags|=8:this.flags&=-9}get hasFlowComment(){return(this.flags&16)>0}set hasFlowComment(t){t?this.flags|=16:this.flags&=-17}get isAmbientContext(){return(this.flags&32)>0}set isAmbientContext(t){t?this.flags|=32:this.flags&=-33}get inAbstractClass(){return(this.flags&64)>0}set inAbstractClass(t){t?this.flags|=64:this.flags&=-65}get inDisallowConditionalTypesContext(){return(this.flags&128)>0}set inDisallowConditionalTypesContext(t){t?this.flags|=128:this.flags&=-129}get soloAwait(){return(this.flags&256)>0}set soloAwait(t){t?this.flags|=256:this.flags&=-257}get inFSharpPipelineDirectBody(){return(this.flags&512)>0}set inFSharpPipelineDirectBody(t){t?this.flags|=512:this.flags&=-513}get canStartJSXElement(){return(this.flags&1024)>0}set canStartJSXElement(t){t?this.flags|=1024:this.flags&=-1025}get containsEsc(){return(this.flags&2048)>0}set containsEsc(t){t?this.flags|=2048:this.flags&=-2049}get hasTopLevelAwait(){return(this.flags&4096)>0}set hasTopLevelAwait(t){t?this.flags|=4096:this.flags&=-4097}curPosition(){return new Ce(this.curLine,this.pos-this.lineStart,this.pos+this.startIndex)}clone(){const t=new gs;return t.flags=this.flags,t.startIndex=this.startIndex,t.curLine=this.curLine,t.lineStart=this.lineStart,t.startLoc=this.startLoc,t.endLoc=this.endLoc,t.errors=this.errors.slice(),t.potentialArrowAt=this.potentialArrowAt,t.noArrowAt=this.noArrowAt.slice(),t.noArrowParamsConversionAt=this.noArrowParamsConversionAt.slice(),t.topicContext=this.topicContext,t.labels=this.labels.slice(),t.commentsLen=this.commentsLen,t.commentStack=this.commentStack.slice(),t.pos=this.pos,t.type=this.type,t.value=this.value,t.start=this.start,t.end=this.end,t.lastTokEndLoc=this.lastTokEndLoc,t.lastTokStartLoc=this.lastTokStartLoc,t.context=this.context.slice(),t.firstInvalidTemplateEscapePos=this.firstInvalidTemplateEscapePos,t.strictErrors=this.strictErrors,t.tokensLength=this.tokensLength,t}}var cn=function(t){return t>=48&&t<=57};const pi={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},Ot={bin:r=>r===48||r===49,oct:r=>r>=48&&r<=55,dec:r=>r>=48&&r<=57,hex:r=>r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102};function fi(r,t,s,e,i,a){const n=s,o=e,c=i;let h="",l=null,u=s;const{length:f}=t;for(;;){if(s>=f){a.unterminated(n,o,c),h+=t.slice(u,s);break}const d=t.charCodeAt(s);if(hn(r,d,t,s)){h+=t.slice(u,s);break}if(d===92){h+=t.slice(u,s);const P=ln(t,s,e,i,r==="template",a);P.ch===null&&!l?l={pos:s,lineStart:e,curLine:i}:h+=P.ch,{pos:s,lineStart:e,curLine:i}=P,u=s}else d===8232||d===8233?(++s,++i,e=s):d===10||d===13?r==="template"?(h+=t.slice(u,s)+`
6
+ `,++s,d===13&&t.charCodeAt(s)===10&&++s,++i,u=e=s):a.unterminated(n,o,c):++s}return{pos:s,str:h,firstInvalidLoc:l,lineStart:e,curLine:i}}function hn(r,t,s,e){return r==="template"?t===96||t===36&&s.charCodeAt(e+1)===123:t===(r==="double"?34:39)}function ln(r,t,s,e,i,a){const n=!i;t++;const o=h=>({pos:t,ch:h,lineStart:s,curLine:e}),c=r.charCodeAt(t++);switch(c){case 110:return o(`
7
+ `);case 114:return o("\r");case 120:{let h;return{code:h,pos:t}=ws(r,t,s,e,2,!1,n,a),o(h===null?null:String.fromCharCode(h))}case 117:{let h;return{code:h,pos:t}=mi(r,t,s,e,n,a),o(h===null?null:String.fromCodePoint(h))}case 116:return o(" ");case 98:return o("\b");case 118:return o("\v");case 102:return o("\f");case 13:r.charCodeAt(t)===10&&++t;case 10:s=t,++e;case 8232:case 8233:return o("");case 56:case 57:if(i)return o(null);a.strictNumericEscape(t-1,s,e);default:if(c>=48&&c<=55){const h=t-1;let u=/^[0-7]+/.exec(r.slice(h,t+2))[0],f=parseInt(u,8);f>255&&(u=u.slice(0,-1),f=parseInt(u,8)),t+=u.length-1;const d=r.charCodeAt(t);if(u!=="0"||d===56||d===57){if(i)return o(null);a.strictNumericEscape(h,s,e)}return o(String.fromCharCode(f))}return o(String.fromCharCode(c))}}function ws(r,t,s,e,i,a,n,o){const c=t;let h;return{n:h,pos:t}=di(r,t,s,e,16,i,a,!1,o,!n),h===null&&(n?o.invalidEscapeSequence(c,s,e):t=c-1),{code:h,pos:t}}function di(r,t,s,e,i,a,n,o,c,h){const l=t,u=i===16?pi.hex:pi.decBinOct,f=i===16?Ot.hex:i===10?Ot.dec:i===8?Ot.oct:Ot.bin;let d=!1,P=0;for(let S=0,F=a??1/0;S<F;++S){const I=r.charCodeAt(t);let O;if(I===95&&o!=="bail"){const L=r.charCodeAt(t-1),fe=r.charCodeAt(t+1);if(o){if(Number.isNaN(fe)||!f(fe)||u.has(L)||u.has(fe)){if(h)return{n:null,pos:t};c.unexpectedNumericSeparator(t,s,e)}}else{if(h)return{n:null,pos:t};c.numericSeparatorInEscapeSequence(t,s,e)}++t;continue}if(I>=97?O=I-97+10:I>=65?O=I-65+10:cn(I)?O=I-48:O=1/0,O>=i){if(O<=9&&h)return{n:null,pos:t};if(O<=9&&c.invalidDigit(t,s,e,i))O=0;else if(n)O=0,d=!0;else break}++t,P=P*i+O}return t===l||a!=null&&t-l!==a||d?{n:null,pos:t}:{n:P,pos:t}}function mi(r,t,s,e,i,a){const n=r.charCodeAt(t);let o;if(n===123){if(++t,{code:o,pos:t}=ws(r,t,s,e,r.indexOf("}",t)-t,!0,i,a),++t,o!==null&&o>1114111)if(i)a.invalidCodePoint(t,s,e);else return{code:null,pos:t}}else({code:o,pos:t}=ws(r,t,s,e,4,!1,i,a));return{code:o,pos:t}}function pt(r,t,s){return new Ce(s,r-t,r)}const un=new Set([103,109,115,105,121,117,100,118]);class pn{constructor(t){const s=t.startIndex||0;this.type=t.type,this.value=t.value,this.start=s+t.start,this.end=s+t.end,this.loc=new It(t.startLoc,t.endLoc)}}class fn extends on{constructor(s,e){super();m(this,"isLookahead");m(this,"tokens",[]);m(this,"errorHandlers_readInt",{invalidDigit:(s,e,i,a)=>this.optionFlags&2048?(this.raise(p.InvalidDigit,pt(s,e,i),{radix:a}),!0):!1,numericSeparatorInEscapeSequence:this.errorBuilder(p.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(p.UnexpectedNumericSeparator)});m(this,"errorHandlers_readCodePoint",Object.assign({},this.errorHandlers_readInt,{invalidEscapeSequence:this.errorBuilder(p.InvalidEscapeSequence),invalidCodePoint:this.errorBuilder(p.InvalidCodePoint)}));m(this,"errorHandlers_readStringContents_string",Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:(s,e,i)=>{this.recordStrictModeErrors(p.StrictNumericEscape,pt(s,e,i))},unterminated:(s,e,i)=>{throw this.raise(p.UnterminatedString,pt(s-1,e,i))}}));m(this,"errorHandlers_readStringContents_template",Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:this.errorBuilder(p.StrictNumericEscape),unterminated:(s,e,i)=>{throw this.raise(p.UnterminatedTemplate,pt(s,e,i))}}));this.state=new gs,this.state.init(s),this.input=e,this.length=e.length,this.comments=[],this.isLookahead=!1}pushToken(s){this.tokens.length=this.state.tokensLength,this.tokens.push(s),++this.state.tokensLength}next(){this.checkKeywordEscapes(),this.optionFlags&256&&this.pushToken(new pn(this.state)),this.state.lastTokEndLoc=this.state.endLoc,this.state.lastTokStartLoc=this.state.startLoc,this.nextToken()}eat(s){return this.match(s)?(this.next(),!0):!1}match(s){return this.state.type===s}createLookaheadState(s){return{pos:s.pos,value:null,type:s.type,start:s.start,end:s.end,context:[this.curContext()],inType:s.inType,startLoc:s.startLoc,lastTokEndLoc:s.lastTokEndLoc,curLine:s.curLine,lineStart:s.lineStart,curPosition:s.curPosition}}lookahead(){const s=this.state;this.state=this.createLookaheadState(s),this.isLookahead=!0,this.nextToken(),this.isLookahead=!1;const e=this.state;return this.state=s,e}nextTokenStart(){return this.nextTokenStartSince(this.state.pos)}nextTokenStartSince(s){return Ps.lastIndex=s,Ps.test(this.input)?Ps.lastIndex:s}lookaheadCharCode(){return this.lookaheadCharCodeSince(this.state.pos)}lookaheadCharCodeSince(s){return this.input.charCodeAt(this.nextTokenStartSince(s))}nextTokenInLineStart(){return this.nextTokenInLineStartSince(this.state.pos)}nextTokenInLineStartSince(s){return bs.lastIndex=s,bs.test(this.input)?bs.lastIndex:s}lookaheadInLineCharCode(){return this.input.charCodeAt(this.nextTokenInLineStart())}codePointAtPos(s){let e=this.input.charCodeAt(s);if((e&64512)===55296&&++s<this.input.length){const i=this.input.charCodeAt(s);(i&64512)===56320&&(e=65536+((e&1023)<<10)+(i&1023))}return e}setStrict(s){this.state.strict=s,s&&(this.state.strictErrors.forEach(([e,i])=>this.raise(e,i)),this.state.strictErrors.clear())}curContext(){return this.state.context[this.state.context.length-1]}nextToken(){if(this.skipSpace(),this.state.start=this.state.pos,this.isLookahead||(this.state.startLoc=this.state.curPosition()),this.state.pos>=this.length){this.finishToken(140);return}this.getTokenFromCode(this.codePointAtPos(this.state.pos))}skipBlockComment(s){let e;this.isLookahead||(e=this.state.curPosition());const i=this.state.pos,a=this.input.indexOf(s,i+2);if(a===-1)throw this.raise(p.UnterminatedComment,this.state.curPosition());for(this.state.pos=a+s.length,Nt.lastIndex=i+2;Nt.test(this.input)&&Nt.lastIndex<=a;)++this.state.curLine,this.state.lineStart=Nt.lastIndex;if(this.isLookahead)return;const n={type:"CommentBlock",value:this.input.slice(i+2,a),start:this.sourceToOffsetPos(i),end:this.sourceToOffsetPos(a+s.length),loc:new It(e,this.state.curPosition())};return this.optionFlags&256&&this.pushToken(n),n}skipLineComment(s){const e=this.state.pos;let i;this.isLookahead||(i=this.state.curPosition());let a=this.input.charCodeAt(this.state.pos+=s);if(this.state.pos<this.length)for(;!qe(a)&&++this.state.pos<this.length;)a=this.input.charCodeAt(this.state.pos);if(this.isLookahead)return;const n=this.state.pos,c={type:"CommentLine",value:this.input.slice(e+s,n),start:this.sourceToOffsetPos(e),end:this.sourceToOffsetPos(n),loc:new It(i,this.state.curPosition())};return this.optionFlags&256&&this.pushToken(c),c}skipSpace(){const s=this.state.pos,e=this.optionFlags&4096?[]:null;e:for(;this.state.pos<this.length;){const i=this.input.charCodeAt(this.state.pos);switch(i){case 32:case 160:case 9:++this.state.pos;break;case 13:this.input.charCodeAt(this.state.pos+1)===10&&++this.state.pos;case 10:case 8232:case 8233:++this.state.pos,++this.state.curLine,this.state.lineStart=this.state.pos;break;case 47:switch(this.input.charCodeAt(this.state.pos+1)){case 42:{const a=this.skipBlockComment("*/");a!==void 0&&(this.addComment(a),e==null||e.push(a));break}case 47:{const a=this.skipLineComment(2);a!==void 0&&(this.addComment(a),e==null||e.push(a));break}default:break e}break;default:if(Qa(i))++this.state.pos;else if(i===45&&!this.inModule&&this.optionFlags&8192){const a=this.state.pos;if(this.input.charCodeAt(a+1)===45&&this.input.charCodeAt(a+2)===62&&(s===0||this.state.lineStart>s)){const n=this.skipLineComment(3);n!==void 0&&(this.addComment(n),e==null||e.push(n))}else break e}else if(i===60&&!this.inModule&&this.optionFlags&8192){const a=this.state.pos;if(this.input.charCodeAt(a+1)===33&&this.input.charCodeAt(a+2)===45&&this.input.charCodeAt(a+3)===45){const n=this.skipLineComment(4);n!==void 0&&(this.addComment(n),e==null||e.push(n))}else break e}else break e}}if((e==null?void 0:e.length)>0){const i=this.state.pos,a={start:this.sourceToOffsetPos(s),end:this.sourceToOffsetPos(i),comments:e,leadingNode:null,trailingNode:null,containingNode:null};this.state.commentStack.push(a)}}finishToken(s,e){this.state.end=this.state.pos,this.state.endLoc=this.state.curPosition();const i=this.state.type;this.state.type=s,this.state.value=e,this.isLookahead||this.updateContext(i)}replaceToken(s){this.state.type=s,this.updateContext()}readToken_numberSign(){if(this.state.pos===0&&this.readToken_interpreter())return;const s=this.state.pos+1,e=this.codePointAtPos(s);if(e>=48&&e<=57)throw this.raise(p.UnexpectedDigitAfterHash,this.state.curPosition());ge(e)?(++this.state.pos,this.finishToken(139,this.readWord1(e))):e===92?(++this.state.pos,this.finishToken(139,this.readWord1())):this.finishOp(27,1)}readToken_dot(){const s=this.input.charCodeAt(this.state.pos+1);if(s>=48&&s<=57){this.readNumber(!0);return}s===46&&this.input.charCodeAt(this.state.pos+2)===46?(this.state.pos+=3,this.finishToken(21)):(++this.state.pos,this.finishToken(16))}readToken_slash(){this.input.charCodeAt(this.state.pos+1)===61?this.finishOp(31,2):this.finishOp(56,1)}readToken_interpreter(){if(this.state.pos!==0||this.length<2)return!1;let s=this.input.charCodeAt(this.state.pos+1);if(s!==33)return!1;const e=this.state.pos;for(this.state.pos+=1;!qe(s)&&++this.state.pos<this.length;)s=this.input.charCodeAt(this.state.pos);const i=this.input.slice(e+2,this.state.pos);return this.finishToken(28,i),!0}readToken_mult_modulo(s){let e=s===42?55:54,i=1,a=this.input.charCodeAt(this.state.pos+1);s===42&&a===42&&(i++,a=this.input.charCodeAt(this.state.pos+2),e=57),a===61&&!this.state.inType&&(i++,e=s===37?33:30),this.finishOp(e,i)}readToken_pipe_amp(s){const e=this.input.charCodeAt(this.state.pos+1);if(e===s){this.input.charCodeAt(this.state.pos+2)===61?this.finishOp(30,3):this.finishOp(s===124?41:42,2);return}if(s===124&&e===62){this.finishOp(39,2);return}if(e===61){this.finishOp(30,2);return}this.finishOp(s===124?43:45,1)}readToken_caret(){const s=this.input.charCodeAt(this.state.pos+1);s===61&&!this.state.inType?this.finishOp(32,2):s===94&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"^^"}])?(this.finishOp(37,2),this.input.codePointAt(this.state.pos)===94&&this.unexpected()):this.finishOp(44,1)}readToken_atSign(){this.input.charCodeAt(this.state.pos+1)===64&&this.hasPlugin(["pipelineOperator",{proposal:"hack",topicToken:"@@"}])?this.finishOp(38,2):this.finishOp(26,1)}readToken_plus_min(s){const e=this.input.charCodeAt(this.state.pos+1);if(e===s){this.finishOp(34,2);return}e===61?this.finishOp(30,2):this.finishOp(53,1)}readToken_lt(){const{pos:s}=this.state,e=this.input.charCodeAt(s+1);if(e===60){if(this.input.charCodeAt(s+2)===61){this.finishOp(30,3);return}this.finishOp(51,2);return}if(e===61){this.finishOp(49,2);return}this.finishOp(47,1)}readToken_gt(){const{pos:s}=this.state,e=this.input.charCodeAt(s+1);if(e===62){const i=this.input.charCodeAt(s+2)===62?3:2;if(this.input.charCodeAt(s+i)===61){this.finishOp(30,i+1);return}this.finishOp(52,i);return}if(e===61){this.finishOp(49,2);return}this.finishOp(48,1)}readToken_eq_excl(s){const e=this.input.charCodeAt(this.state.pos+1);if(e===61){this.finishOp(46,this.input.charCodeAt(this.state.pos+2)===61?3:2);return}if(s===61&&e===62){this.state.pos+=2,this.finishToken(19);return}this.finishOp(s===61?29:35,1)}readToken_question(){const s=this.input.charCodeAt(this.state.pos+1),e=this.input.charCodeAt(this.state.pos+2);s===63?e===61?this.finishOp(30,3):this.finishOp(40,2):s===46&&!(e>=48&&e<=57)?(this.state.pos+=2,this.finishToken(18)):(++this.state.pos,this.finishToken(17))}getTokenFromCode(s){switch(s){case 46:this.readToken_dot();return;case 40:++this.state.pos,this.finishToken(10);return;case 41:++this.state.pos,this.finishToken(11);return;case 59:++this.state.pos,this.finishToken(13);return;case 44:++this.state.pos,this.finishToken(12);return;case 91:++this.state.pos,this.finishToken(0);return;case 93:++this.state.pos,this.finishToken(3);return;case 123:++this.state.pos,this.finishToken(5);return;case 125:++this.state.pos,this.finishToken(8);return;case 58:this.hasPlugin("functionBind")&&this.input.charCodeAt(this.state.pos+1)===58?this.finishOp(15,2):(++this.state.pos,this.finishToken(14));return;case 63:this.readToken_question();return;case 96:this.readTemplateToken();return;case 48:{const e=this.input.charCodeAt(this.state.pos+1);if(e===120||e===88){this.readRadixNumber(16);return}if(e===111||e===79){this.readRadixNumber(8);return}if(e===98||e===66){this.readRadixNumber(2);return}}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:this.readNumber(!1);return;case 34:case 39:this.readString(s);return;case 47:this.readToken_slash();return;case 37:case 42:this.readToken_mult_modulo(s);return;case 124:case 38:this.readToken_pipe_amp(s);return;case 94:this.readToken_caret();return;case 43:case 45:this.readToken_plus_min(s);return;case 60:this.readToken_lt();return;case 62:this.readToken_gt();return;case 61:case 33:this.readToken_eq_excl(s);return;case 126:this.finishOp(36,1);return;case 64:this.readToken_atSign();return;case 35:this.readToken_numberSign();return;case 92:this.readWord();return;default:if(ge(s)){this.readWord(s);return}}throw this.raise(p.InvalidOrUnexpectedToken,this.state.curPosition(),{unexpected:String.fromCodePoint(s)})}finishOp(s,e){const i=this.input.slice(this.state.pos,this.state.pos+e);this.state.pos+=e,this.finishToken(s,i)}readRegexp(){const s=this.state.startLoc,e=this.state.start+1;let i,a,{pos:n}=this.state;for(;;++n){if(n>=this.length)throw this.raise(p.UnterminatedRegExp,oe(s,1));const l=this.input.charCodeAt(n);if(qe(l))throw this.raise(p.UnterminatedRegExp,oe(s,1));if(i)i=!1;else{if(l===91)a=!0;else if(l===93&&a)a=!1;else if(l===47&&!a)break;i=l===92}}const o=this.input.slice(e,n);++n;let c="";const h=()=>oe(s,n+2-e);for(;n<this.length;){const l=this.codePointAtPos(n),u=String.fromCharCode(l);if(un.has(l))l===118?c.includes("u")&&this.raise(p.IncompatibleRegExpUVFlags,h()):l===117&&c.includes("v")&&this.raise(p.IncompatibleRegExpUVFlags,h()),c.includes(u)&&this.raise(p.DuplicateRegExpFlags,h());else if($e(l)||l===92)this.raise(p.MalformedRegExpFlags,h());else break;++n,c+=u}this.state.pos=n,this.finishToken(138,{pattern:o,flags:c})}readInt(s,e,i=!1,a=!0){const{n,pos:o}=di(this.input,this.state.pos,this.state.lineStart,this.state.curLine,s,e,i,a,this.errorHandlers_readInt,!1);return this.state.pos=o,n}readRadixNumber(s){const e=this.state.pos,i=this.state.curPosition();let a=!1;this.state.pos+=2;const n=this.readInt(s);n==null&&this.raise(p.InvalidDigit,oe(i,2),{radix:s});const o=this.input.charCodeAt(this.state.pos);if(o===110)++this.state.pos,a=!0;else if(o===109)throw this.raise(p.InvalidDecimal,i);if(ge(this.codePointAtPos(this.state.pos)))throw this.raise(p.NumberIdentifier,this.state.curPosition());if(a){const c=this.input.slice(e,this.state.pos).replace(/[_n]/g,"");this.finishToken(136,c);return}this.finishToken(135,n)}readNumber(s){const e=this.state.pos,i=this.state.curPosition();let a=!1,n=!1,o=!1;!s&&this.readInt(10)===null&&this.raise(p.InvalidNumber,this.state.curPosition());const c=this.state.pos-e>=2&&this.input.charCodeAt(e)===48;if(c){const f=this.input.slice(e,this.state.pos);if(this.recordStrictModeErrors(p.StrictOctalLiteral,i),!this.state.strict){const d=f.indexOf("_");d>0&&this.raise(p.ZeroDigitNumericSeparator,oe(i,d))}o=c&&!/[89]/.test(f)}let h=this.input.charCodeAt(this.state.pos);if(h===46&&!o&&(++this.state.pos,this.readInt(10),a=!0,h=this.input.charCodeAt(this.state.pos)),(h===69||h===101)&&!o&&(h=this.input.charCodeAt(++this.state.pos),(h===43||h===45)&&++this.state.pos,this.readInt(10)===null&&this.raise(p.InvalidOrMissingExponent,i),a=!0,h=this.input.charCodeAt(this.state.pos)),h===110&&((a||c)&&this.raise(p.InvalidBigIntLiteral,i),++this.state.pos,n=!0),ge(this.codePointAtPos(this.state.pos)))throw this.raise(p.NumberIdentifier,this.state.curPosition());const l=this.input.slice(e,this.state.pos).replace(/[_mn]/g,"");if(n){this.finishToken(136,l);return}const u=o?parseInt(l,8):parseFloat(l);this.finishToken(135,u)}readCodePoint(s){const{code:e,pos:i}=mi(this.input,this.state.pos,this.state.lineStart,this.state.curLine,s,this.errorHandlers_readCodePoint);return this.state.pos=i,e}readString(s){const{str:e,pos:i,curLine:a,lineStart:n}=fi(s===34?"double":"single",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_string);this.state.pos=i+1,this.state.lineStart=n,this.state.curLine=a,this.finishToken(134,e)}readTemplateContinuation(){this.match(8)||this.unexpected(null,8),this.state.pos--,this.readTemplateToken()}readTemplateToken(){const s=this.input[this.state.pos],{str:e,firstInvalidLoc:i,pos:a,curLine:n,lineStart:o}=fi("template",this.input,this.state.pos+1,this.state.lineStart,this.state.curLine,this.errorHandlers_readStringContents_template);this.state.pos=a+1,this.state.lineStart=o,this.state.curLine=n,i&&(this.state.firstInvalidTemplateEscapePos=new Ce(i.curLine,i.pos-i.lineStart,this.sourceToOffsetPos(i.pos))),this.input.codePointAt(a)===96?this.finishToken(24,i?null:s+e+"`"):(this.state.pos++,this.finishToken(25,i?null:s+e+"${"))}recordStrictModeErrors(s,e){const i=e.index;this.state.strict&&!this.state.strictErrors.has(i)?this.raise(s,e):this.state.strictErrors.set(i,[s,e])}readWord1(s){this.state.containsEsc=!1;let e="";const i=this.state.pos;let a=this.state.pos;for(s!==void 0&&(this.state.pos+=s<=65535?1:2);this.state.pos<this.length;){const n=this.codePointAtPos(this.state.pos);if($e(n))this.state.pos+=n<=65535?1:2;else if(n===92){this.state.containsEsc=!0,e+=this.input.slice(a,this.state.pos);const o=this.state.curPosition(),c=this.state.pos===i?ge:$e;if(this.input.charCodeAt(++this.state.pos)!==117){this.raise(p.MissingUnicodeEscape,this.state.curPosition()),a=this.state.pos-1;continue}++this.state.pos;const h=this.readCodePoint(!0);h!==null&&(c(h)||this.raise(p.EscapedCharNotAnIdentifier,o),e+=String.fromCodePoint(h)),a=this.state.pos}else break}return e+this.input.slice(a,this.state.pos)}readWord(s){const e=this.readWord1(s),i=rs.get(e);i!==void 0?this.finishToken(i,Ne(i)):this.finishToken(132,e)}checkKeywordEscapes(){const{type:s}=this.state;us(s)&&this.state.containsEsc&&this.raise(p.InvalidEscapedReservedWord,this.state.startLoc,{reservedWord:Ne(s)})}raise(s,e,i={}){const a=e instanceof Ce?e:e.loc.start,n=s(a,i);if(!(this.optionFlags&2048))throw n;return this.isLookahead||this.state.errors.push(n),n}raiseOverwrite(s,e,i={}){const a=e instanceof Ce?e:e.loc.start,n=a.index,o=this.state.errors;for(let c=o.length-1;c>=0;c--){const h=o[c];if(h.loc.index===n)return o[c]=s(a,i);if(h.loc.index<n)break}return this.raise(s,e,i)}updateContext(s){}unexpected(s,e){throw this.raise(p.UnexpectedToken,s??this.state.startLoc,{expected:e?Ne(e):null})}expectPlugin(s,e){if(this.hasPlugin(s))return!0;throw this.raise(p.MissingPlugin,e??this.state.startLoc,{missingPlugin:[s]})}expectOnePlugin(s){if(!s.some(e=>this.hasPlugin(e)))throw this.raise(p.MissingOneOfPlugins,this.state.startLoc,{missingPlugin:s})}errorBuilder(s){return(e,i,a)=>{this.raise(s,pt(e,i,a))}}}class dn{constructor(){m(this,"privateNames",new Set);m(this,"loneAccessors",new Map);m(this,"undefinedPrivateNames",new Map)}}class mn{constructor(t){m(this,"parser");m(this,"stack",[]);m(this,"undefinedPrivateNames",new Map);this.parser=t}current(){return this.stack[this.stack.length-1]}enter(){this.stack.push(new dn)}exit(){const t=this.stack.pop(),s=this.current();for(const[e,i]of Array.from(t.undefinedPrivateNames))s?s.undefinedPrivateNames.has(e)||s.undefinedPrivateNames.set(e,i):this.parser.raise(p.InvalidPrivateFieldResolution,i,{identifierName:e})}declarePrivateName(t,s,e){const{privateNames:i,loneAccessors:a,undefinedPrivateNames:n}=this.current();let o=i.has(t);if(s&3){const c=o&&a.get(t);if(c){const h=c&4,l=s&4,u=c&3,f=s&3;o=u===f||h!==l,o||a.delete(t)}else o||a.set(t,s)}o&&this.parser.raise(p.PrivateNameRedeclaration,e,{identifierName:t}),i.add(t),n.delete(t)}usePrivateName(t,s){let e;for(e of this.stack)if(e.privateNames.has(t))return;e?e.undefinedPrivateNames.set(t,s):this.parser.raise(p.InvalidPrivateFieldResolution,s,{identifierName:t})}}class Dt{constructor(t=0){this.type=t}canBeArrowParameterDeclaration(){return this.type===2||this.type===1}isCertainlyParameterDeclaration(){return this.type===3}}class yi extends Dt{constructor(s){super(s);m(this,"declarationErrors",new Map)}recordDeclarationError(s,e){const i=e.index;this.declarationErrors.set(i,[s,e])}clearDeclarationError(s){this.declarationErrors.delete(s)}iterateErrors(s){this.declarationErrors.forEach(s)}}class yn{constructor(t){m(this,"parser");m(this,"stack",[new Dt]);this.parser=t}enter(t){this.stack.push(t)}exit(){this.stack.pop()}recordParameterInitializerError(t,s){const e=s.loc.start,{stack:i}=this;let a=i.length-1,n=i[a];for(;!n.isCertainlyParameterDeclaration();){if(n.canBeArrowParameterDeclaration())n.recordDeclarationError(t,e);else return;n=i[--a]}this.parser.raise(t,e)}recordArrowParameterBindingError(t,s){const{stack:e}=this,i=e[e.length-1],a=s.loc.start;if(i.isCertainlyParameterDeclaration())this.parser.raise(t,a);else if(i.canBeArrowParameterDeclaration())i.recordDeclarationError(t,a);else return}recordAsyncArrowParametersError(t){const{stack:s}=this;let e=s.length-1,i=s[e];for(;i.canBeArrowParameterDeclaration();)i.type===2&&i.recordDeclarationError(p.AwaitBindingIdentifier,t),i=s[--e]}validateAsPattern(){const{stack:t}=this,s=t[t.length-1];s.canBeArrowParameterDeclaration()&&s.iterateErrors(([e,i])=>{this.parser.raise(e,i);let a=t.length-2,n=t[a];for(;n.canBeArrowParameterDeclaration();)n.clearDeclarationError(i.index),n=t[--a]})}}function xn(){return new Dt(3)}function Pn(){return new yi(1)}function bn(){return new yi(2)}function xi(){return new Dt}class gn extends fn{addExtra(t,s,e,i=!0){if(!t)return;let{extra:a}=t;a==null&&(a={},t.extra=a),i?a[s]=e:Object.defineProperty(a,s,{enumerable:i,value:e})}isContextual(t){return this.state.type===t&&!this.state.containsEsc}isUnparsedContextual(t,s){const e=t+s.length;if(this.input.slice(t,e)===s){const i=this.input.charCodeAt(e);return!($e(i)||(i&64512)===55296)}return!1}isLookaheadContextual(t){const s=this.nextTokenStart();return this.isUnparsedContextual(s,t)}eatContextual(t){return this.isContextual(t)?(this.next(),!0):!1}expectContextual(t,s){if(!this.eatContextual(t)){if(s!=null)throw this.raise(s,this.state.startLoc);this.unexpected(null,t)}}canInsertSemicolon(){return this.match(140)||this.match(8)||this.hasPrecedingLineBreak()}hasPrecedingLineBreak(){return li(this.input,this.offsetToSourcePos(this.state.lastTokEndLoc.index),this.state.start)}hasFollowingLineBreak(){return li(this.input,this.state.end,this.nextTokenStart())}isLineTerminator(){return this.eat(13)||this.canInsertSemicolon()}semicolon(t=!0){(t?this.isLineTerminator():this.eat(13))||this.raise(p.MissingSemicolon,this.state.lastTokEndLoc)}expect(t,s){this.eat(t)||this.unexpected(s,t)}tryParse(t,s=this.state.clone()){const e={node:null};try{const i=t((a=null)=>{throw e.node=a,e});if(this.state.errors.length>s.errors.length){const a=this.state;return this.state=s,this.state.tokensLength=a.tokensLength,{node:i,error:a.errors[s.errors.length],thrown:!1,aborted:!1,failState:a}}return{node:i,error:null,thrown:!1,aborted:!1,failState:null}}catch(i){const a=this.state;if(this.state=s,i instanceof SyntaxError)return{node:null,error:i,thrown:!0,aborted:!1,failState:a};if(i===e)return{node:e.node,error:null,thrown:!1,aborted:!0,failState:a};throw i}}checkExpressionErrors(t,s){if(!t)return!1;const{shorthandAssignLoc:e,doubleProtoLoc:i,privateKeyLoc:a,optionalParametersLoc:n}=t,o=!!e||!!i||!!n||!!a;if(!s)return o;e!=null&&this.raise(p.InvalidCoverInitializedName,e),i!=null&&this.raise(p.DuplicateProto,i),a!=null&&this.raise(p.UnexpectedPrivateField,a),n!=null&&this.unexpected(n)}isLiteralPropertyName(){return ei(this.state.type)}isPrivateName(t){return t.type==="PrivateName"}getPrivateNameSV(t){return t.id.name}hasPropertyAsPrivateName(t){return(t.type==="MemberExpression"||t.type==="OptionalMemberExpression")&&this.isPrivateName(t.property)}isObjectProperty(t){return t.type==="ObjectProperty"}isObjectMethod(t){return t.type==="ObjectMethod"}initializeScopes(t=this.options.sourceType==="module"){const s=this.state.labels;this.state.labels=[];const e=this.exportedIdentifiers;this.exportedIdentifiers=new Set;const i=this.inModule;this.inModule=t;const a=this.scope,n=this.getScopeHandler();this.scope=new n(this,t);const o=this.prodParam;this.prodParam=new rn;const c=this.classScope;this.classScope=new mn(this);const h=this.expressionScope;return this.expressionScope=new yn(this),()=>{this.state.labels=s,this.exportedIdentifiers=e,this.inModule=i,this.scope=a,this.prodParam=o,this.classScope=c,this.expressionScope=h}}enterInitialScopes(){let t=0;this.inModule&&(t|=2),this.optionFlags&32&&(t|=1),this.scope.enter(1),this.prodParam.enter(t)}checkDestructuringPrivate(t){const{privateKeyLoc:s}=t;s!==null&&this.expectPlugin("destructuringPrivate",s)}}class Lt{constructor(){m(this,"shorthandAssignLoc",null);m(this,"doubleProtoLoc",null);m(this,"privateKeyLoc",null);m(this,"optionalParametersLoc",null)}}class Ts{constructor(t,s,e){m(this,"type","");this.start=s,this.end=0,this.loc=new It(e),(t==null?void 0:t.optionFlags)&128&&(this.range=[s,0]),t!=null&&t.filename&&(this.loc.filename=t.filename)}}const Pi=Ts.prototype;class wn extends gn{startNode(){const t=this.state.startLoc;return new Ts(this,t.index,t)}startNodeAt(t){return new Ts(this,t.index,t)}startNodeAtNode(t){return this.startNodeAt(t.loc.start)}finishNode(t,s){return this.finishNodeAt(t,s,this.state.lastTokEndLoc)}finishNodeAt(t,s,e){return t.type=s,t.end=e.index,t.loc.end=e,this.optionFlags&128&&(t.range[1]=e.index),this.optionFlags&4096&&this.processComment(t),t}resetStartLocation(t,s){t.start=s.index,t.loc.start=s,this.optionFlags&128&&(t.range[0]=s.index)}resetEndLocation(t,s=this.state.lastTokEndLoc){t.end=s.index,t.loc.end=s,this.optionFlags&128&&(t.range[1]=s.index)}resetStartLocationFromNode(t,s){this.resetStartLocation(t,s.loc.start)}castNodeTo(t,s){return t.type=s,t}cloneIdentifier(t){const{type:s,start:e,end:i,loc:a,range:n,name:o}=t,c=Object.create(Pi);return c.type=s,c.start=e,c.end=i,c.loc=a,c.range=n,c.name=o,t.extra&&(c.extra=t.extra),c}cloneStringLiteral(t){const{type:s,start:e,end:i,loc:a,range:n,extra:o}=t,c=Object.create(Pi);return c.type=s,c.start=e,c.end=i,c.loc=a,c.range=n,c.extra=o,c.value=t.value,c}}const bi=r=>r.type==="ParenthesizedExpression"?bi(r.expression):r;class Tn extends wn{toAssignable(t,s=!1){var i,a,n;let e;switch((t.type==="ParenthesizedExpression"||(i=t.extra)!=null&&i.parenthesized)&&(e=bi(t),s?e.type==="Identifier"?this.expressionScope.recordArrowParameterBindingError(p.InvalidParenthesizedAssignment,t):e.type!=="MemberExpression"&&!this.isOptionalMemberExpression(e)&&this.raise(p.InvalidParenthesizedAssignment,t):this.raise(p.InvalidParenthesizedAssignment,t)),t.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":this.castNodeTo(t,"ObjectPattern");for(let o=0,c=t.properties.length,h=c-1;o<c;o++){const l=t.properties[o],u=o===h;this.toAssignableObjectExpressionProp(l,u,s),u&&l.type==="RestElement"&&((a=t.extra)!=null&&a.trailingCommaLoc)&&this.raise(p.RestTrailingComma,t.extra.trailingCommaLoc)}break;case"ObjectProperty":{const{key:o,value:c}=t;this.isPrivateName(o)&&this.classScope.usePrivateName(this.getPrivateNameSV(o),o.loc.start),this.toAssignable(c,s);break}case"SpreadElement":throw new Error("Internal @babel/parser error (this is a bug, please report it). SpreadElement should be converted by .toAssignable's caller.");case"ArrayExpression":this.castNodeTo(t,"ArrayPattern"),this.toAssignableList(t.elements,(n=t.extra)==null?void 0:n.trailingCommaLoc,s);break;case"AssignmentExpression":t.operator!=="="&&this.raise(p.MissingEqInAssignment,t.left.loc.end),this.castNodeTo(t,"AssignmentPattern"),delete t.operator,this.toAssignable(t.left,s);break;case"ParenthesizedExpression":this.toAssignable(e,s);break}}toAssignableObjectExpressionProp(t,s,e){if(t.type==="ObjectMethod")this.raise(t.kind==="get"||t.kind==="set"?p.PatternHasAccessor:p.PatternHasMethod,t.key);else if(t.type==="SpreadElement"){this.castNodeTo(t,"RestElement");const i=t.argument;this.checkToRestConversion(i,!1),this.toAssignable(i,e),s||this.raise(p.RestTrailingComma,t)}else this.toAssignable(t,e)}toAssignableList(t,s,e){const i=t.length-1;for(let a=0;a<=i;a++){const n=t[a];n&&(this.toAssignableListItem(t,a,e),n.type==="RestElement"&&(a<i?this.raise(p.RestTrailingComma,n):s&&this.raise(p.RestTrailingComma,s)))}}toAssignableListItem(t,s,e){const i=t[s];if(i.type==="SpreadElement"){this.castNodeTo(i,"RestElement");const a=i.argument;this.checkToRestConversion(a,!0),this.toAssignable(a,e)}else this.toAssignable(i,e)}isAssignable(t,s){switch(t.type){case"Identifier":case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":return!0;case"ObjectExpression":{const e=t.properties.length-1;return t.properties.every((i,a)=>i.type!=="ObjectMethod"&&(a===e||i.type!=="SpreadElement")&&this.isAssignable(i))}case"ObjectProperty":return this.isAssignable(t.value);case"SpreadElement":return this.isAssignable(t.argument);case"ArrayExpression":return t.elements.every(e=>e===null||this.isAssignable(e));case"AssignmentExpression":return t.operator==="=";case"ParenthesizedExpression":return this.isAssignable(t.expression);case"MemberExpression":case"OptionalMemberExpression":return!s;default:return!1}}toReferencedList(t,s){return t}toReferencedListDeep(t,s){this.toReferencedList(t,s);for(const e of t)(e==null?void 0:e.type)==="ArrayExpression"&&this.toReferencedListDeep(e.elements)}parseSpread(t){const s=this.startNode();return this.next(),s.argument=this.parseMaybeAssignAllowIn(t,void 0),this.finishNode(s,"SpreadElement")}parseRestBinding(){const t=this.startNode();return this.next(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")}parseBindingAtom(){switch(this.state.type){case 0:{const t=this.startNode();return this.next(),t.elements=this.parseBindingList(3,93,1),this.finishNode(t,"ArrayPattern")}case 5:return this.parseObjectLike(8,!0)}return this.parseIdentifier()}parseBindingList(t,s,e){const i=e&1,a=[];let n=!0;for(;!this.eat(t);)if(n?n=!1:this.expect(12),i&&this.match(12))a.push(null);else{if(this.eat(t))break;if(this.match(21)){let o=this.parseRestBinding();if(e&2&&(o=this.parseFunctionParamType(o)),a.push(o),!this.checkCommaAfterRest(s)){this.expect(t);break}}else{const o=[];if(e&2)for(this.match(26)&&this.hasPlugin("decorators")&&this.raise(p.UnsupportedParameterDecorator,this.state.startLoc);this.match(26);)o.push(this.parseDecorator());a.push(this.parseBindingElement(e,o))}}return a}parseBindingRestProperty(t){return this.next(),t.argument=this.parseIdentifier(),this.checkCommaAfterRest(125),this.finishNode(t,"RestElement")}parseBindingProperty(){const{type:t,startLoc:s}=this.state;if(t===21)return this.parseBindingRestProperty(this.startNode());const e=this.startNode();return t===139?(this.expectPlugin("destructuringPrivate",s),this.classScope.usePrivateName(this.state.value,s),e.key=this.parsePrivateName()):this.parsePropertyName(e),e.method=!1,this.parseObjPropValue(e,s,!1,!1,!0,!1)}parseBindingElement(t,s){const e=this.parseMaybeDefault();return t&2&&this.parseFunctionParamType(e),s.length&&(e.decorators=s,this.resetStartLocationFromNode(e,s[0])),this.parseMaybeDefault(e.loc.start,e)}parseFunctionParamType(t){return t}parseMaybeDefault(t,s){if(t??(t=this.state.startLoc),s=s??this.parseBindingAtom(),!this.eat(29))return s;const e=this.startNodeAt(t);return e.left=s,e.right=this.parseMaybeAssignAllowIn(),this.finishNode(e,"AssignmentPattern")}isValidLVal(t,s,e){switch(t){case"AssignmentPattern":return"left";case"RestElement":return"argument";case"ObjectProperty":return"value";case"ParenthesizedExpression":return"expression";case"ArrayPattern":return"elements";case"ObjectPattern":return"properties"}return!1}isOptionalMemberExpression(t){return t.type==="OptionalMemberExpression"}checkLVal(t,s,e=64,i=!1,a=!1,n=!1){var P;const o=t.type;if(this.isObjectMethod(t))return;const c=this.isOptionalMemberExpression(t);if(c||o==="MemberExpression"){c&&(this.expectPlugin("optionalChainingAssign",t.loc.start),s.type!=="AssignmentExpression"&&this.raise(p.InvalidLhsOptionalChaining,t,{ancestor:s})),e!==64&&this.raise(p.InvalidPropertyBindingPattern,t);return}if(o==="Identifier"){this.checkIdentifier(t,e,a);const{name:S}=t;i&&(i.has(S)?this.raise(p.ParamDupe,t):i.add(S));return}const h=this.isValidLVal(o,!(n||(P=t.extra)!=null&&P.parenthesized)&&s.type==="AssignmentExpression",e);if(h===!0)return;if(h===!1){const S=e===64?p.InvalidLhs:p.InvalidLhsBinding;this.raise(S,t,{ancestor:s});return}let l,u;typeof h=="string"?(l=h,u=o==="ParenthesizedExpression"):[l,u]=h;const f=o==="ArrayPattern"||o==="ObjectPattern"?{type:o}:s,d=t[l];if(Array.isArray(d))for(const S of d)S&&this.checkLVal(S,f,e,i,a,u);else d&&this.checkLVal(d,f,e,i,a,u)}checkIdentifier(t,s,e=!1){this.state.strict&&(e?ci(t.name,this.inModule):oi(t.name))&&(s===64?this.raise(p.StrictEvalArguments,t,{referenceName:t.name}):this.raise(p.StrictEvalArgumentsBinding,t,{bindingName:t.name})),s&8192&&t.name==="let"&&this.raise(p.LetInLexicalBinding,t),s&64||this.declareNameFromIdentifier(t,s)}declareNameFromIdentifier(t,s){this.scope.declareName(t.name,s,t.loc.start)}checkToRestConversion(t,s){switch(t.type){case"ParenthesizedExpression":this.checkToRestConversion(t.expression,s);break;case"Identifier":case"MemberExpression":break;case"ArrayExpression":case"ObjectExpression":if(s)break;default:this.raise(p.InvalidRestAssignmentPattern,t)}}checkCommaAfterRest(t){return this.match(12)?(this.raise(this.lookaheadCharCode()===t?p.RestTrailingComma:p.ElementAfterRest,this.state.startLoc),!0):!1}}function An(r){if(r==null)throw new Error(`Unexpected ${r} value.`);return r}function gi(r){if(!r)throw new Error("Assert fail")}const w=Pe`typescript`({AbstractMethodHasImplementation:({methodName:r})=>`Method '${r}' cannot have an implementation because it is marked abstract.`,AbstractPropertyHasInitializer:({propertyName:r})=>`Property '${r}' cannot have an initializer because it is marked abstract.`,AccessorCannotBeOptional:"An 'accessor' property cannot be declared optional.",AccessorCannotDeclareThisParameter:"'get' and 'set' accessors cannot declare 'this' parameters.",AccessorCannotHaveTypeParameters:"An accessor cannot have type parameters.",ClassMethodHasDeclare:"Class methods cannot have the 'declare' modifier.",ClassMethodHasReadonly:"Class methods cannot have the 'readonly' modifier.",ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference:"A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.",ConstructorHasTypeParameters:"Type parameters cannot appear on a constructor declaration.",DeclareAccessor:({kind:r})=>`'declare' is not allowed in ${r}ters.`,DeclareClassFieldHasInitializer:"Initializers are not allowed in ambient contexts.",DeclareFunctionHasImplementation:"An implementation cannot be declared in ambient contexts.",DuplicateAccessibilityModifier:({modifier:r})=>`Accessibility modifier already seen: '${r}'.`,DuplicateModifier:({modifier:r})=>`Duplicate modifier: '${r}'.`,EmptyHeritageClauseType:({token:r})=>`'${r}' list cannot be empty.`,EmptyTypeArguments:"Type argument list cannot be empty.",EmptyTypeParameters:"Type parameter list cannot be empty.",ExpectedAmbientAfterExportDeclare:"'export declare' must be followed by an ambient declaration.",ImportAliasHasImportType:"An import alias can not use 'import type'.",ImportReflectionHasImportType:"An `import module` declaration can not use `type` modifier",IncompatibleModifiers:({modifiers:r})=>`'${r[0]}' modifier cannot be used with '${r[1]}' modifier.`,IndexSignatureHasAbstract:"Index signatures cannot have the 'abstract' modifier.",IndexSignatureHasAccessibility:({modifier:r})=>`Index signatures cannot have an accessibility modifier ('${r}').`,IndexSignatureHasDeclare:"Index signatures cannot have the 'declare' modifier.",IndexSignatureHasOverride:"'override' modifier cannot appear on an index signature.",IndexSignatureHasStatic:"Index signatures cannot have the 'static' modifier.",InitializerNotAllowedInAmbientContext:"Initializers are not allowed in ambient contexts.",InvalidHeritageClauseType:({token:r})=>`'${r}' list can only include identifiers or qualified-names with optional type arguments.`,InvalidModifierOnTypeMember:({modifier:r})=>`'${r}' modifier cannot appear on a type member.`,InvalidModifierOnTypeParameter:({modifier:r})=>`'${r}' modifier cannot appear on a type parameter.`,InvalidModifierOnTypeParameterPositions:({modifier:r})=>`'${r}' modifier can only appear on a type parameter of a class, interface or type alias.`,InvalidModifiersOrder:({orderedModifiers:r})=>`'${r[0]}' modifier must precede '${r[1]}' modifier.`,InvalidPropertyAccessAfterInstantiationExpression:"Invalid property access after an instantiation expression. You can either wrap the instantiation expression in parentheses, or delete the type arguments.",InvalidTupleMemberLabel:"Tuple members must be labeled with a simple identifier.",MissingInterfaceName:"'interface' declarations must be followed by an identifier.",NonAbstractClassHasAbstractMethod:"Abstract methods can only appear within an abstract class.",NonClassMethodPropertyHasAbstractModifier:"'abstract' modifier can only appear on a class, method, or property declaration.",OptionalTypeBeforeRequired:"A required element cannot follow an optional element.",OverrideNotInSubClass:"This member cannot have an 'override' modifier because its containing class does not extend another class.",PatternIsOptional:"A binding pattern parameter cannot be optional in an implementation signature.",PrivateElementHasAbstract:"Private elements cannot have the 'abstract' modifier.",PrivateElementHasAccessibility:({modifier:r})=>`Private elements cannot have an accessibility modifier ('${r}').`,ReadonlyForMethodSignature:"'readonly' modifier can only appear on a property declaration or index signature.",ReservedArrowTypeParam:"This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma, as in `<T,>() => ...`.",ReservedTypeAssertion:"This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.",SetAccessorCannotHaveOptionalParameter:"A 'set' accessor cannot have an optional parameter.",SetAccessorCannotHaveRestParameter:"A 'set' accessor cannot have rest parameter.",SetAccessorCannotHaveReturnType:"A 'set' accessor cannot have a return type annotation.",SingleTypeParameterWithoutTrailingComma:({typeParameterName:r})=>`Single type parameter ${r} should have a trailing comma. Example usage: <${r},>.`,StaticBlockCannotHaveModifier:"Static class blocks cannot have any modifier.",TupleOptionalAfterType:"A labeled tuple optional element must be declared using a question mark after the name and before the colon (`name?: type`), rather than after the type (`name: type?`).",TypeAnnotationAfterAssign:"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`.",TypeImportCannotSpecifyDefaultAndNamed:"A type-only import can specify a default import or named bindings, but not both.",TypeModifierIsUsedInTypeExports:"The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement.",TypeModifierIsUsedInTypeImports:"The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement.",UnexpectedParameterModifier:"A parameter property is only allowed in a constructor implementation.",UnexpectedReadonly:"'readonly' type modifier is only permitted on array and tuple literal types.",UnexpectedTypeAnnotation:"Did not expect a type annotation here.",UnexpectedTypeCastInParameter:"Unexpected type cast in parameter position.",UnsupportedImportTypeArgument:"Argument in a type import must be a string literal.",UnsupportedParameterPropertyKind:"A parameter property may not be declared using a binding pattern.",UnsupportedSignatureParameterKind:({type:r})=>`Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got ${r}.`});function Sn(r){switch(r){case"any":return"TSAnyKeyword";case"boolean":return"TSBooleanKeyword";case"bigint":return"TSBigIntKeyword";case"never":return"TSNeverKeyword";case"number":return"TSNumberKeyword";case"object":return"TSObjectKeyword";case"string":return"TSStringKeyword";case"symbol":return"TSSymbolKeyword";case"undefined":return"TSUndefinedKeyword";case"unknown":return"TSUnknownKeyword";default:return}}function wi(r){return r==="private"||r==="public"||r==="protected"}function In(r){return r==="in"||r==="out"}function As(r){var t;if((t=r.extra)!=null&&t.parenthesized)return!1;switch(r.type){case"Identifier":return!0;case"MemberExpression":return!r.computed&&As(r.object);case"TSInstantiationExpression":return As(r.expression);default:return!1}}var En=r=>class extends r{constructor(){super(...arguments);m(this,"tsParseInOutModifiers",this.tsParseModifiers.bind(this,{allowedModifiers:["in","out"],disallowedModifiers:["const","public","private","protected","readonly","declare","abstract","override"],errorTemplate:w.InvalidModifierOnTypeParameter}));m(this,"tsParseConstModifier",this.tsParseModifiers.bind(this,{allowedModifiers:["const"],disallowedModifiers:["in","out"],errorTemplate:w.InvalidModifierOnTypeParameterPositions}));m(this,"tsParseInOutConstModifiers",this.tsParseModifiers.bind(this,{allowedModifiers:["in","out","const"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:w.InvalidModifierOnTypeParameter}))}getScopeHandler(){return sn}tsIsIdentifier(){return D(this.state.type)}tsTokenCanFollowModifier(){return this.match(0)||this.match(5)||this.match(55)||this.match(21)||this.match(139)||this.isLiteralPropertyName()}tsNextTokenOnSameLineAndCanFollowModifier(){return this.next(),this.hasPrecedingLineBreak()?!1:this.tsTokenCanFollowModifier()}tsNextTokenCanFollowModifier(){return this.match(106)?(this.next(),this.tsTokenCanFollowModifier()):this.tsNextTokenOnSameLineAndCanFollowModifier()}tsParseModifier(e,i,a){if(!D(this.state.type)&&this.state.type!==58&&this.state.type!==75)return;const n=this.state.value;if(e.includes(n)){if(a&&this.match(106)||i&&this.tsIsStartOfStaticBlocks())return;if(this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this)))return n}}tsParseModifiers({allowedModifiers:e,disallowedModifiers:i,stopOnStartOfClassStaticBlock:a,errorTemplate:n=w.InvalidModifierOnTypeMember},o){const c=(l,u,f,d)=>{u===f&&o[d]&&this.raise(w.InvalidModifiersOrder,l,{orderedModifiers:[f,d]})},h=(l,u,f,d)=>{(o[f]&&u===d||o[d]&&u===f)&&this.raise(w.IncompatibleModifiers,l,{modifiers:[f,d]})};for(;;){const{startLoc:l}=this.state,u=this.tsParseModifier(e.concat(i??[]),a,o.static);if(!u)break;wi(u)?o.accessibility?this.raise(w.DuplicateAccessibilityModifier,l,{modifier:u}):(c(l,u,u,"override"),c(l,u,u,"static"),c(l,u,u,"readonly"),o.accessibility=u):In(u)?(o[u]&&this.raise(w.DuplicateModifier,l,{modifier:u}),o[u]=!0,c(l,u,"in","out")):(Object.hasOwn(o,u)?this.raise(w.DuplicateModifier,l,{modifier:u}):(c(l,u,"static","readonly"),c(l,u,"static","override"),c(l,u,"override","readonly"),c(l,u,"abstract","override"),h(l,u,"declare","override"),h(l,u,"static","abstract")),o[u]=!0),i!=null&&i.includes(u)&&this.raise(n,l,{modifier:u})}}tsIsListTerminator(e){switch(e){case"EnumMembers":case"TypeMembers":return this.match(8);case"HeritageClauseElement":return this.match(5);case"TupleElementTypes":return this.match(3);case"TypeParametersOrArguments":return this.match(48)}}tsParseList(e,i){const a=[];for(;!this.tsIsListTerminator(e);)a.push(i());return a}tsParseDelimitedList(e,i,a){return An(this.tsParseDelimitedListWorker(e,i,!0,a))}tsParseDelimitedListWorker(e,i,a,n){const o=[];let c=-1;for(;!this.tsIsListTerminator(e);){c=-1;const h=i();if(h==null)return;if(o.push(h),this.eat(12)){c=this.state.lastTokStartLoc.index;continue}if(this.tsIsListTerminator(e))break;a&&this.expect(12);return}return n&&(n.value=c),o}tsParseBracketedList(e,i,a,n,o){n||(a?this.expect(0):this.expect(47));const c=this.tsParseDelimitedList(e,i,o);return a?this.expect(3):this.expect(48),c}tsParseImportType(){const e=this.startNode();return this.expect(83),this.expect(10),this.match(134)?e.argument=this.tsParseLiteralTypeNode():(this.raise(w.UnsupportedImportTypeArgument,this.state.startLoc),e.argument=this.tsParseNonConditionalType()),this.eat(12)?e.options=this.tsParseImportTypeOptions():e.options=null,this.expect(11),this.eat(16)&&(e.qualifier=this.tsParseEntityName(3)),this.match(47)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,"TSImportType")}tsParseImportTypeOptions(){const e=this.startNode();this.expect(5);const i=this.startNode();return this.isContextual(76)?(i.method=!1,i.key=this.parseIdentifier(!0),i.computed=!1,i.shorthand=!1):this.unexpected(null,76),this.expect(14),i.value=this.tsParseImportTypeWithPropertyValue(),e.properties=[this.finishObjectProperty(i)],this.expect(8),this.finishNode(e,"ObjectExpression")}tsParseImportTypeWithPropertyValue(){const e=this.startNode(),i=[];for(this.expect(5);!this.match(8);){const a=this.state.type;D(a)||a===134?i.push(super.parsePropertyDefinition(null)):this.unexpected(),this.eat(12)}return e.properties=i,this.next(),this.finishNode(e,"ObjectExpression")}tsParseEntityName(e){let i;if(e&1&&this.match(78))if(e&2)i=this.parseIdentifier(!0);else{const a=this.startNode();this.next(),i=this.finishNode(a,"ThisExpression")}else i=this.parseIdentifier(!!(e&1));for(;this.eat(16);){const a=this.startNodeAtNode(i);a.left=i,a.right=this.parseIdentifier(!!(e&1)),i=this.finishNode(a,"TSQualifiedName")}return i}tsParseTypeReference(){const e=this.startNode();return e.typeName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(47)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,"TSTypeReference")}tsParseThisTypePredicate(e){this.next();const i=this.startNodeAtNode(e);return i.parameterName=e,i.typeAnnotation=this.tsParseTypeAnnotation(!1),i.asserts=!1,this.finishNode(i,"TSTypePredicate")}tsParseThisTypeNode(){const e=this.startNode();return this.next(),this.finishNode(e,"TSThisType")}tsParseTypeQuery(){const e=this.startNode();return this.expect(87),this.match(83)?e.exprName=this.tsParseImportType():e.exprName=this.tsParseEntityName(1),!this.hasPrecedingLineBreak()&&this.match(47)&&(e.typeArguments=this.tsParseTypeArguments()),this.finishNode(e,"TSTypeQuery")}tsParseTypeParameter(e){const i=this.startNode();return e(i),i.name=this.tsParseTypeParameterName(),i.constraint=this.tsEatThenParseType(81),i.default=this.tsEatThenParseType(29),this.finishNode(i,"TSTypeParameter")}tsTryParseTypeParameters(e){if(this.match(47))return this.tsParseTypeParameters(e)}tsParseTypeParameters(e){const i=this.startNode();this.match(47)||this.match(143)?this.next():this.unexpected();const a={value:-1};return i.params=this.tsParseBracketedList("TypeParametersOrArguments",this.tsParseTypeParameter.bind(this,e),!1,!0,a),i.params.length===0&&this.raise(w.EmptyTypeParameters,i),a.value!==-1&&this.addExtra(i,"trailingComma",a.value),this.finishNode(i,"TSTypeParameterDeclaration")}tsFillSignature(e,i){const a=e===19,n="params",o="returnType";i.typeParameters=this.tsTryParseTypeParameters(this.tsParseConstModifier),this.expect(10),i[n]=this.tsParseBindingListForSignature(),a?i[o]=this.tsParseTypeOrTypePredicateAnnotation(e):this.match(e)&&(i[o]=this.tsParseTypeOrTypePredicateAnnotation(e))}tsParseBindingListForSignature(){const e=super.parseBindingList(11,41,2);for(const i of e){const{type:a}=i;(a==="AssignmentPattern"||a==="TSParameterProperty")&&this.raise(w.UnsupportedSignatureParameterKind,i,{type:a})}return e}tsParseTypeMemberSemicolon(){!this.eat(12)&&!this.isLineTerminator()&&this.expect(13)}tsParseSignatureMember(e,i){return this.tsFillSignature(14,i),this.tsParseTypeMemberSemicolon(),this.finishNode(i,e)}tsIsUnambiguouslyIndexSignature(){return this.next(),D(this.state.type)?(this.next(),this.match(14)):!1}tsTryParseIndexSignature(e){if(!(this.match(0)&&this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))))return;this.expect(0);const i=this.parseIdentifier();i.typeAnnotation=this.tsParseTypeAnnotation(),this.resetEndLocation(i),this.expect(3),e.parameters=[i];const a=this.tsTryParseTypeAnnotation();return a&&(e.typeAnnotation=a),this.tsParseTypeMemberSemicolon(),this.finishNode(e,"TSIndexSignature")}tsParsePropertyOrMethodSignature(e,i){if(this.eat(17)&&(e.optional=!0),this.match(10)||this.match(47)){i&&this.raise(w.ReadonlyForMethodSignature,e);const a=e;a.kind&&this.match(47)&&this.raise(w.AccessorCannotHaveTypeParameters,this.state.curPosition()),this.tsFillSignature(14,a),this.tsParseTypeMemberSemicolon();const n="params",o="returnType";if(a.kind==="get")a[n].length>0&&(this.raise(p.BadGetterArity,this.state.curPosition()),this.isThisParam(a[n][0])&&this.raise(w.AccessorCannotDeclareThisParameter,this.state.curPosition()));else if(a.kind==="set"){if(a[n].length!==1)this.raise(p.BadSetterArity,this.state.curPosition());else{const c=a[n][0];this.isThisParam(c)&&this.raise(w.AccessorCannotDeclareThisParameter,this.state.curPosition()),c.type==="Identifier"&&c.optional&&this.raise(w.SetAccessorCannotHaveOptionalParameter,this.state.curPosition()),c.type==="RestElement"&&this.raise(w.SetAccessorCannotHaveRestParameter,this.state.curPosition())}a[o]&&this.raise(w.SetAccessorCannotHaveReturnType,a[o])}else a.kind="method";return this.finishNode(a,"TSMethodSignature")}else{const a=e;i&&(a.readonly=!0);const n=this.tsTryParseTypeAnnotation();return n&&(a.typeAnnotation=n),this.tsParseTypeMemberSemicolon(),this.finishNode(a,"TSPropertySignature")}}tsParseTypeMember(){const e=this.startNode();if(this.match(10)||this.match(47))return this.tsParseSignatureMember("TSCallSignatureDeclaration",e);if(this.match(77)){const a=this.startNode();return this.next(),this.match(10)||this.match(47)?this.tsParseSignatureMember("TSConstructSignatureDeclaration",e):(e.key=this.createIdentifier(a,"new"),this.tsParsePropertyOrMethodSignature(e,!1))}this.tsParseModifiers({allowedModifiers:["readonly"],disallowedModifiers:["declare","abstract","private","protected","public","static","override"]},e);const i=this.tsTryParseIndexSignature(e);return i||(super.parsePropertyName(e),!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.tsTokenCanFollowModifier()&&(e.kind=e.key.name,super.parsePropertyName(e),!this.match(10)&&!this.match(47)&&this.unexpected(null,10)),this.tsParsePropertyOrMethodSignature(e,!!e.readonly))}tsParseTypeLiteral(){const e=this.startNode();return e.members=this.tsParseObjectTypeMembers(),this.finishNode(e,"TSTypeLiteral")}tsParseObjectTypeMembers(){this.expect(5);const e=this.tsParseList("TypeMembers",this.tsParseTypeMember.bind(this));return this.expect(8),e}tsIsStartOfMappedType(){return this.next(),this.eat(53)?this.isContextual(122):(this.isContextual(122)&&this.next(),!this.match(0)||(this.next(),!this.tsIsIdentifier())?!1:(this.next(),this.match(58)))}tsParseMappedType(){const e=this.startNode();return this.expect(5),this.match(53)?(e.readonly=this.state.value,this.next(),this.expectContextual(122)):this.eatContextual(122)&&(e.readonly=!0),this.expect(0),e.key=this.tsParseTypeParameterName(),e.constraint=this.tsExpectThenParseType(58),e.nameType=this.eatContextual(93)?this.tsParseType():null,this.expect(3),this.match(53)?(e.optional=this.state.value,this.next(),this.expect(17)):this.eat(17)&&(e.optional=!0),e.typeAnnotation=this.tsTryParseType(),this.semicolon(),this.expect(8),this.finishNode(e,"TSMappedType")}tsParseTupleType(){const e=this.startNode();e.elementTypes=this.tsParseBracketedList("TupleElementTypes",this.tsParseTupleElementType.bind(this),!0,!1);let i=!1;return e.elementTypes.forEach(a=>{const{type:n}=a;i&&n!=="TSRestType"&&n!=="TSOptionalType"&&!(n==="TSNamedTupleMember"&&a.optional)&&this.raise(w.OptionalTypeBeforeRequired,a),i||(i=n==="TSNamedTupleMember"&&a.optional||n==="TSOptionalType")}),this.finishNode(e,"TSTupleType")}tsParseTupleElementType(){const e=this.state.startLoc,i=this.eat(21),{startLoc:a}=this.state;let n,o,c,h;const u=ue(this.state.type)?this.lookaheadCharCode():null;if(u===58)n=!0,c=!1,o=this.parseIdentifier(!0),this.expect(14),h=this.tsParseType();else if(u===63){c=!0;const f=this.state.value,d=this.tsParseNonArrayType();this.lookaheadCharCode()===58?(n=!0,o=this.createIdentifier(this.startNodeAt(a),f),this.expect(17),this.expect(14),h=this.tsParseType()):(n=!1,h=d,this.expect(17))}else h=this.tsParseType(),c=this.eat(17),n=this.eat(14);if(n){let f;o?(f=this.startNodeAt(a),f.optional=c,f.label=o,f.elementType=h,this.eat(17)&&(f.optional=!0,this.raise(w.TupleOptionalAfterType,this.state.lastTokStartLoc))):(f=this.startNodeAt(a),f.optional=c,this.raise(w.InvalidTupleMemberLabel,h),f.label=h,f.elementType=this.tsParseType()),h=this.finishNode(f,"TSNamedTupleMember")}else if(c){const f=this.startNodeAt(a);f.typeAnnotation=h,h=this.finishNode(f,"TSOptionalType")}if(i){const f=this.startNodeAt(e);f.typeAnnotation=h,h=this.finishNode(f,"TSRestType")}return h}tsParseParenthesizedType(){const e=this.startNode();return this.expect(10),e.typeAnnotation=this.tsParseType(),this.expect(11),this.finishNode(e,"TSParenthesizedType")}tsParseFunctionOrConstructorType(e,i){const a=this.startNode();return e==="TSConstructorType"&&(a.abstract=!!i,i&&this.next(),this.next()),this.tsInAllowConditionalTypesContext(()=>this.tsFillSignature(19,a)),this.finishNode(a,e)}tsParseLiteralTypeNode(){const e=this.startNode();switch(this.state.type){case 135:case 136:case 134:case 85:case 86:e.literal=super.parseExprAtom();break;default:this.unexpected()}return this.finishNode(e,"TSLiteralType")}tsParseTemplateLiteralType(){{const e=this.state.startLoc;let i=this.parseTemplateElement(!1);const a=[i];if(i.tail){const n=this.startNodeAt(e),o=this.startNodeAt(e);return o.expressions=[],o.quasis=a,n.literal=this.finishNode(o,"TemplateLiteral"),this.finishNode(n,"TSLiteralType")}else{const n=[];for(;!i.tail;)n.push(this.tsParseType()),this.readTemplateContinuation(),a.push(i=this.parseTemplateElement(!1));const o=this.startNodeAt(e);return o.types=n,o.quasis=a,this.finishNode(o,"TSTemplateLiteralType")}}}parseTemplateSubstitution(){return this.state.inType?this.tsParseType():super.parseTemplateSubstitution()}tsParseThisTypeOrThisTypePredicate(){const e=this.tsParseThisTypeNode();return this.isContextual(116)&&!this.hasPrecedingLineBreak()?this.tsParseThisTypePredicate(e):e}tsParseNonArrayType(){switch(this.state.type){case 134:case 135:case 136:case 85:case 86:return this.tsParseLiteralTypeNode();case 53:if(this.state.value==="-"){const e=this.startNode(),i=this.lookahead();return i.type!==135&&i.type!==136&&this.unexpected(),e.literal=this.parseMaybeUnary(),this.finishNode(e,"TSLiteralType")}break;case 78:return this.tsParseThisTypeOrThisTypePredicate();case 87:return this.tsParseTypeQuery();case 83:return this.tsParseImportType();case 5:return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))?this.tsParseMappedType():this.tsParseTypeLiteral();case 0:return this.tsParseTupleType();case 10:if(!(this.optionFlags&1024)){const e=this.state.startLoc;this.next();const i=this.tsParseType();return this.expect(11),this.addExtra(i,"parenthesized",!0),this.addExtra(i,"parenStart",e.index),i}return this.tsParseParenthesizedType();case 25:case 24:return this.tsParseTemplateLiteralType();default:{const{type:e}=this.state;if(D(e)||e===88||e===84){const i=e===88?"TSVoidKeyword":e===84?"TSNullKeyword":Sn(this.state.value);if(i!==void 0&&this.lookaheadCharCode()!==46){const a=this.startNode();return this.next(),this.finishNode(a,i)}return this.tsParseTypeReference()}}}this.unexpected()}tsParseArrayTypeOrHigher(){const{startLoc:e}=this.state;let i=this.tsParseNonArrayType();for(;!this.hasPrecedingLineBreak()&&this.eat(0);)if(this.match(3)){const a=this.startNodeAt(e);a.elementType=i,this.expect(3),i=this.finishNode(a,"TSArrayType")}else{const a=this.startNodeAt(e);a.objectType=i,a.indexType=this.tsParseType(),this.expect(3),i=this.finishNode(a,"TSIndexedAccessType")}return i}tsParseTypeOperator(){const e=this.startNode(),i=this.state.value;return this.next(),e.operator=i,e.typeAnnotation=this.tsParseTypeOperatorOrHigher(),i==="readonly"&&this.tsCheckTypeAnnotationForReadOnly(e),this.finishNode(e,"TSTypeOperator")}tsCheckTypeAnnotationForReadOnly(e){switch(e.typeAnnotation.type){case"TSTupleType":case"TSArrayType":return;default:this.raise(w.UnexpectedReadonly,e)}}tsParseInferType(){const e=this.startNode();this.expectContextual(115);const i=this.startNode();return i.name=this.tsParseTypeParameterName(),i.constraint=this.tsTryParse(()=>this.tsParseConstraintForInferType()),e.typeParameter=this.finishNode(i,"TSTypeParameter"),this.finishNode(e,"TSInferType")}tsParseConstraintForInferType(){if(this.eat(81)){const e=this.tsInDisallowConditionalTypesContext(()=>this.tsParseType());if(this.state.inDisallowConditionalTypesContext||!this.match(17))return e}}tsParseTypeOperatorOrHigher(){return va(this.state.type)&&!this.state.containsEsc?this.tsParseTypeOperator():this.isContextual(115)?this.tsParseInferType():this.tsInAllowConditionalTypesContext(()=>this.tsParseArrayTypeOrHigher())}tsParseUnionOrIntersectionType(e,i,a){const n=this.startNode(),o=this.eat(a),c=[];do c.push(i());while(this.eat(a));return c.length===1&&!o?c[0]:(n.types=c,this.finishNode(n,e))}tsParseIntersectionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSIntersectionType",this.tsParseTypeOperatorOrHigher.bind(this),45)}tsParseUnionTypeOrHigher(){return this.tsParseUnionOrIntersectionType("TSUnionType",this.tsParseIntersectionTypeOrHigher.bind(this),43)}tsIsStartOfFunctionType(){return this.match(47)?!0:this.match(10)&&this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))}tsSkipParameterStart(){if(D(this.state.type)||this.match(78))return this.next(),!0;if(this.match(5)){const{errors:e}=this.state,i=e.length;try{return this.parseObjectLike(8,!0),e.length===i}catch{return!1}}if(this.match(0)){this.next();const{errors:e}=this.state,i=e.length;try{return super.parseBindingList(3,93,1),e.length===i}catch{return!1}}return!1}tsIsUnambiguouslyStartOfFunctionType(){return this.next(),!!(this.match(11)||this.match(21)||this.tsSkipParameterStart()&&(this.match(14)||this.match(12)||this.match(17)||this.match(29)||this.match(11)&&(this.next(),this.match(19))))}tsParseTypeOrTypePredicateAnnotation(e){return this.tsInType(()=>{const i=this.startNode();this.expect(e);const a=this.startNode(),n=!!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));if(n&&this.match(78)){let h=this.tsParseThisTypeOrThisTypePredicate();return h.type==="TSThisType"?(a.parameterName=h,a.asserts=!0,a.typeAnnotation=null,h=this.finishNode(a,"TSTypePredicate")):(this.resetStartLocationFromNode(h,a),h.asserts=!0),i.typeAnnotation=h,this.finishNode(i,"TSTypeAnnotation")}const o=this.tsIsIdentifier()&&this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));if(!o)return n?(a.parameterName=this.parseIdentifier(),a.asserts=n,a.typeAnnotation=null,i.typeAnnotation=this.finishNode(a,"TSTypePredicate"),this.finishNode(i,"TSTypeAnnotation")):this.tsParseTypeAnnotation(!1,i);const c=this.tsParseTypeAnnotation(!1);return a.parameterName=o,a.typeAnnotation=c,a.asserts=n,i.typeAnnotation=this.finishNode(a,"TSTypePredicate"),this.finishNode(i,"TSTypeAnnotation")})}tsTryParseTypeOrTypePredicateAnnotation(){if(this.match(14))return this.tsParseTypeOrTypePredicateAnnotation(14)}tsTryParseTypeAnnotation(){if(this.match(14))return this.tsParseTypeAnnotation()}tsTryParseType(){return this.tsEatThenParseType(14)}tsParseTypePredicatePrefix(){const e=this.parseIdentifier();if(this.isContextual(116)&&!this.hasPrecedingLineBreak())return this.next(),e}tsParseTypePredicateAsserts(){if(this.state.type!==109)return!1;const e=this.state.containsEsc;return this.next(),!D(this.state.type)&&!this.match(78)?!1:(e&&this.raise(p.InvalidEscapedReservedWord,this.state.lastTokStartLoc,{reservedWord:"asserts"}),!0)}tsParseTypeAnnotation(e=!0,i=this.startNode()){return this.tsInType(()=>{e&&this.expect(14),i.typeAnnotation=this.tsParseType()}),this.finishNode(i,"TSTypeAnnotation")}tsParseType(){gi(this.state.inType);const e=this.tsParseNonConditionalType();if(this.state.inDisallowConditionalTypesContext||this.hasPrecedingLineBreak()||!this.eat(81))return e;const i=this.startNodeAtNode(e);return i.checkType=e,i.extendsType=this.tsInDisallowConditionalTypesContext(()=>this.tsParseNonConditionalType()),this.expect(17),i.trueType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.expect(14),i.falseType=this.tsInAllowConditionalTypesContext(()=>this.tsParseType()),this.finishNode(i,"TSConditionalType")}isAbstractConstructorSignature(){return this.isContextual(124)&&this.lookahead().type===77}tsParseNonConditionalType(){return this.tsIsStartOfFunctionType()?this.tsParseFunctionOrConstructorType("TSFunctionType"):this.match(77)?this.tsParseFunctionOrConstructorType("TSConstructorType"):this.isAbstractConstructorSignature()?this.tsParseFunctionOrConstructorType("TSConstructorType",!0):this.tsParseUnionTypeOrHigher()}tsParseTypeAssertion(){this.getPluginOption("typescript","disallowAmbiguousJSXLike")&&this.raise(w.ReservedTypeAssertion,this.state.startLoc);const e=this.startNode();return e.typeAnnotation=this.tsInType(()=>(this.next(),this.match(75)?this.tsParseTypeReference():this.tsParseType())),this.expect(48),e.expression=this.parseMaybeUnary(),this.finishNode(e,"TSTypeAssertion")}tsParseHeritageClause(e){const i=this.state.startLoc,a=this.tsParseDelimitedList("HeritageClauseElement",()=>{{const n=super.parseExprSubscripts();As(n)||this.raise(w.InvalidHeritageClauseType,n.loc.start,{token:e});const o=e==="extends"?"TSInterfaceHeritage":"TSClassImplements";if(n.type==="TSInstantiationExpression")return n.type=o,n;const c=this.startNodeAtNode(n);return c.expression=n,(this.match(47)||this.match(51))&&(c.typeArguments=this.tsParseTypeArgumentsInExpression()),this.finishNode(c,o)}});return a.length||this.raise(w.EmptyHeritageClauseType,i,{token:e}),a}tsParseInterfaceDeclaration(e,i={}){if(this.hasFollowingLineBreak())return null;this.expectContextual(129),i.declare&&(e.declare=!0),D(this.state.type)?(e.id=this.parseIdentifier(),this.checkIdentifier(e.id,130)):(e.id=null,this.raise(w.MissingInterfaceName,this.state.startLoc)),e.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers),this.eat(81)&&(e.extends=this.tsParseHeritageClause("extends"));const a=this.startNode();return a.body=this.tsInType(this.tsParseObjectTypeMembers.bind(this)),e.body=this.finishNode(a,"TSInterfaceBody"),this.finishNode(e,"TSInterfaceDeclaration")}tsParseTypeAliasDeclaration(e){return e.id=this.parseIdentifier(),this.checkIdentifier(e.id,2),e.typeAnnotation=this.tsInType(()=>{if(e.typeParameters=this.tsTryParseTypeParameters(this.tsParseInOutModifiers),this.expect(29),this.isContextual(114)&&this.lookahead().type!==16){const i=this.startNode();return this.next(),this.finishNode(i,"TSIntrinsicKeyword")}return this.tsParseType()}),this.semicolon(),this.finishNode(e,"TSTypeAliasDeclaration")}tsInTopLevelContext(e){if(this.curContext()!==R.brace){const i=this.state.context;this.state.context=[i[0]];try{return e()}finally{this.state.context=i}}else return e()}tsInType(e){const i=this.state.inType;this.state.inType=!0;try{return e()}finally{this.state.inType=i}}tsInDisallowConditionalTypesContext(e){const i=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!0;try{return e()}finally{this.state.inDisallowConditionalTypesContext=i}}tsInAllowConditionalTypesContext(e){const i=this.state.inDisallowConditionalTypesContext;this.state.inDisallowConditionalTypesContext=!1;try{return e()}finally{this.state.inDisallowConditionalTypesContext=i}}tsEatThenParseType(e){if(this.match(e))return this.tsNextThenParseType()}tsExpectThenParseType(e){return this.tsInType(()=>(this.expect(e),this.tsParseType()))}tsNextThenParseType(){return this.tsInType(()=>(this.next(),this.tsParseType()))}tsParseEnumMember(){const e=this.startNode();return e.id=this.match(134)?super.parseStringLiteral(this.state.value):this.parseIdentifier(!0),this.eat(29)&&(e.initializer=super.parseMaybeAssignAllowIn()),this.finishNode(e,"TSEnumMember")}tsParseEnumDeclaration(e,i={}){return i.const&&(e.const=!0),i.declare&&(e.declare=!0),this.expectContextual(126),e.id=this.parseIdentifier(),this.checkIdentifier(e.id,e.const?8971:8459),e.body=this.tsParseEnumBody(),this.finishNode(e,"TSEnumDeclaration")}tsParseEnumBody(){const e=this.startNode();return this.expect(5),e.members=this.tsParseDelimitedList("EnumMembers",this.tsParseEnumMember.bind(this)),this.expect(8),this.finishNode(e,"TSEnumBody")}tsParseModuleBlock(){const e=this.startNode();return this.scope.enter(0),this.expect(5),super.parseBlockOrModuleBlockBody(e.body=[],void 0,!0,8),this.scope.exit(),this.finishNode(e,"TSModuleBlock")}tsParseModuleOrNamespaceDeclaration(e,i=!1){return e.id=this.tsParseEntityName(1),e.id.type==="Identifier"&&this.checkIdentifier(e.id,1024),this.scope.enter(512),this.prodParam.enter(0),e.body=this.tsParseModuleBlock(),this.prodParam.exit(),this.scope.exit(),this.finishNode(e,"TSModuleDeclaration")}tsParseAmbientExternalModuleDeclaration(e){return this.isContextual(112)?(e.kind="global",e.id=this.parseIdentifier()):this.match(134)?(e.kind="module",e.id=super.parseStringLiteral(this.state.value)):this.unexpected(),this.match(5)?(this.scope.enter(512),this.prodParam.enter(0),e.body=this.tsParseModuleBlock(),this.prodParam.exit(),this.scope.exit()):this.semicolon(),this.finishNode(e,"TSModuleDeclaration")}tsParseImportEqualsDeclaration(e,i,a){e.id=i||this.parseIdentifier(),this.checkIdentifier(e.id,4096),this.expect(29);const n=this.tsParseModuleReference();return e.importKind==="type"&&n.type!=="TSExternalModuleReference"&&this.raise(w.ImportAliasHasImportType,n),e.moduleReference=n,this.semicolon(),this.finishNode(e,"TSImportEqualsDeclaration")}tsIsExternalModuleReference(){return this.isContextual(119)&&this.lookaheadCharCode()===40}tsParseModuleReference(){return this.tsIsExternalModuleReference()?this.tsParseExternalModuleReference():this.tsParseEntityName(0)}tsParseExternalModuleReference(){const e=this.startNode();return this.expectContextual(119),this.expect(10),this.match(134)||this.unexpected(),e.expression=super.parseExprAtom(),this.expect(11),this.sawUnambiguousESM=!0,this.finishNode(e,"TSExternalModuleReference")}tsLookAhead(e){const i=this.state.clone(),a=e();return this.state=i,a}tsTryParseAndCatch(e){const i=this.tryParse(a=>e()||a());if(!(i.aborted||!i.node))return i.error&&(this.state=i.failState),i.node}tsTryParse(e){const i=this.state.clone(),a=e();if(a!==void 0&&a!==!1)return a;this.state=i}tsTryParseDeclare(e){if(this.isLineTerminator())return;let i=this.state.type,a;return this.isContextual(100)&&(i=74,a="let"),this.tsInAmbientContext(()=>{switch(i){case 68:return e.declare=!0,super.parseFunctionStatement(e,!1,!1);case 80:return e.declare=!0,this.parseClass(e,!0,!1);case 126:return this.tsParseEnumDeclaration(e,{declare:!0});case 112:return this.tsParseAmbientExternalModuleDeclaration(e);case 75:case 74:return!this.match(75)||!this.isLookaheadContextual("enum")?(e.declare=!0,this.parseVarStatement(e,a||this.state.value,!0)):(this.expect(75),this.tsParseEnumDeclaration(e,{const:!0,declare:!0}));case 129:{const n=this.tsParseInterfaceDeclaration(e,{declare:!0});if(n)return n}default:if(D(i))return this.tsParseDeclaration(e,this.state.value,!0,null)}})}tsTryParseExportDeclaration(){return this.tsParseDeclaration(this.startNode(),this.state.value,!0,null)}tsParseExpressionStatement(e,i,a){switch(i.name){case"declare":{const n=this.tsTryParseDeclare(e);return n&&(n.declare=!0),n}case"global":if(this.match(5)){this.scope.enter(512),this.prodParam.enter(0);const n=e;return n.kind="global",n.id=i,n.body=this.tsParseModuleBlock(),this.scope.exit(),this.prodParam.exit(),this.finishNode(n,"TSModuleDeclaration")}break;default:return this.tsParseDeclaration(e,i.name,!1,a)}}tsParseDeclaration(e,i,a,n){switch(i){case"abstract":if(this.tsCheckLineTerminator(a)&&(this.match(80)||D(this.state.type)))return this.tsParseAbstractDeclaration(e,n);break;case"module":if(this.tsCheckLineTerminator(a)){if(this.match(134))return this.tsParseAmbientExternalModuleDeclaration(e);if(D(this.state.type))return e.kind="module",this.tsParseModuleOrNamespaceDeclaration(e)}break;case"namespace":if(this.tsCheckLineTerminator(a)&&D(this.state.type))return e.kind="namespace",this.tsParseModuleOrNamespaceDeclaration(e);break;case"type":if(this.tsCheckLineTerminator(a)&&D(this.state.type))return this.tsParseTypeAliasDeclaration(e);break}}tsCheckLineTerminator(e){return e?this.hasFollowingLineBreak()?!1:(this.next(),!0):!this.isLineTerminator()}tsTryParseGenericAsyncArrowFunction(e){if(!this.match(47))return;const i=this.state.maybeInArrowParameters;this.state.maybeInArrowParameters=!0;const a=this.tsTryParseAndCatch(()=>{const n=this.startNodeAt(e);return n.typeParameters=this.tsParseTypeParameters(this.tsParseConstModifier),super.parseFunctionParams(n),n.returnType=this.tsTryParseTypeOrTypePredicateAnnotation(),this.expect(19),n});if(this.state.maybeInArrowParameters=i,!!a)return super.parseArrowExpression(a,null,!0)}tsParseTypeArgumentsInExpression(){if(this.reScan_lt()===47)return this.tsParseTypeArguments()}tsParseTypeArguments(){const e=this.startNode();return e.params=this.tsInType(()=>this.tsInTopLevelContext(()=>(this.expect(47),this.tsParseDelimitedList("TypeParametersOrArguments",this.tsParseType.bind(this))))),e.params.length===0?this.raise(w.EmptyTypeArguments,e):!this.state.inType&&this.curContext()===R.brace&&this.reScan_lt_gt(),this.expect(48),this.finishNode(e,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return Oa(this.state.type)}isExportDefaultSpecifier(){return this.tsIsDeclarationStart()?!1:super.isExportDefaultSpecifier()}parseBindingElement(e,i){const a=i.length?i[0].loc.start:this.state.startLoc,n={};this.tsParseModifiers({allowedModifiers:["public","private","protected","override","readonly"]},n);const o=n.accessibility,c=n.override,h=n.readonly;!(e&4)&&(o||h||c)&&this.raise(w.UnexpectedParameterModifier,a);const l=this.parseMaybeDefault();e&2&&this.parseFunctionParamType(l);const u=this.parseMaybeDefault(l.loc.start,l);if(o||h||c){const f=this.startNodeAt(a);return i.length&&(f.decorators=i),o&&(f.accessibility=o),h&&(f.readonly=h),c&&(f.override=c),u.type!=="Identifier"&&u.type!=="AssignmentPattern"&&this.raise(w.UnsupportedParameterPropertyKind,f),f.parameter=u,this.finishNode(f,"TSParameterProperty")}return i.length&&(l.decorators=i),u}isSimpleParameter(e){return e.type==="TSParameterProperty"&&super.isSimpleParameter(e.parameter)||super.isSimpleParameter(e)}tsDisallowOptionalPattern(e){for(const i of e.params)i.type!=="Identifier"&&i.optional&&!this.state.isAmbientContext&&this.raise(w.PatternIsOptional,i)}setArrowFunctionParameters(e,i,a){super.setArrowFunctionParameters(e,i,a),this.tsDisallowOptionalPattern(e)}parseFunctionBodyAndFinish(e,i,a=!1){this.match(14)&&(e.returnType=this.tsParseTypeOrTypePredicateAnnotation(14));const n=i==="FunctionDeclaration"?"TSDeclareFunction":i==="ClassMethod"||i==="ClassPrivateMethod"?"TSDeclareMethod":void 0;return n&&!this.match(5)&&this.isLineTerminator()?this.finishNode(e,n):n==="TSDeclareFunction"&&this.state.isAmbientContext&&(this.raise(w.DeclareFunctionHasImplementation,e),e.declare)?super.parseFunctionBodyAndFinish(e,n,a):(this.tsDisallowOptionalPattern(e),super.parseFunctionBodyAndFinish(e,i,a))}registerFunctionStatementId(e){!e.body&&e.id?this.checkIdentifier(e.id,1024):super.registerFunctionStatementId(e)}tsCheckForInvalidTypeCasts(e){e.forEach(i=>{(i==null?void 0:i.type)==="TSTypeCastExpression"&&this.raise(w.UnexpectedTypeAnnotation,i.typeAnnotation)})}toReferencedList(e,i){return this.tsCheckForInvalidTypeCasts(e),e}parseArrayLike(e,i,a,n){const o=super.parseArrayLike(e,i,a,n);return o.type==="ArrayExpression"&&this.tsCheckForInvalidTypeCasts(o.elements),o}parseSubscript(e,i,a,n){if(!this.hasPrecedingLineBreak()&&this.match(35)){this.state.canStartJSXElement=!1,this.next();const c=this.startNodeAt(i);return c.expression=e,this.finishNode(c,"TSNonNullExpression")}let o=!1;if(this.match(18)&&this.lookaheadCharCode()===60){if(a)return n.stop=!0,e;n.optionalChainMember=o=!0,this.next()}if(this.match(47)||this.match(51)){let c;const h=this.tsTryParseAndCatch(()=>{if(!a&&this.atPossibleAsyncArrow(e)){const d=this.tsTryParseGenericAsyncArrowFunction(i);if(d)return d}const l=this.tsParseTypeArgumentsInExpression();if(!l)return;if(o&&!this.match(10)){c=this.state.curPosition();return}if(ps(this.state.type)){const d=super.parseTaggedTemplateExpression(e,i,n);return d.typeArguments=l,d}if(!a&&this.eat(10)){const d=this.startNodeAt(i);return d.callee=e,d.arguments=this.parseCallExpressionArguments(11),this.tsCheckForInvalidTypeCasts(d.arguments),d.typeArguments=l,n.optionalChainMember&&(d.optional=o),this.finishCallExpression(d,n.optionalChainMember)}const u=this.state.type;if(u===48||u===52||u!==10&&ut(u)&&!this.hasPrecedingLineBreak())return;const f=this.startNodeAt(i);return f.expression=e,f.typeArguments=l,this.finishNode(f,"TSInstantiationExpression")});if(c&&this.unexpected(c,10),h)return h.type==="TSInstantiationExpression"&&((this.match(16)||this.match(18)&&this.lookaheadCharCode()!==40)&&this.raise(w.InvalidPropertyAccessAfterInstantiationExpression,this.state.startLoc),!this.match(16)&&!this.match(18)&&(h.expression=super.stopParseSubscript(e,n))),h}return super.parseSubscript(e,i,a,n)}parseNewCallee(e){var a;super.parseNewCallee(e);const{callee:i}=e;i.type==="TSInstantiationExpression"&&!((a=i.extra)!=null&&a.parenthesized)&&(e.typeArguments=i.typeArguments,e.callee=i.expression)}parseExprOp(e,i,a){let n;if(kt(58)>a&&!this.hasPrecedingLineBreak()&&(this.isContextual(93)||(n=this.isContextual(120)))){const o=this.startNodeAt(i);return o.expression=e,o.typeAnnotation=this.tsInType(()=>(this.next(),this.match(75)?(n&&this.raise(p.UnexpectedKeyword,this.state.startLoc,{keyword:"const"}),this.tsParseTypeReference()):this.tsParseType())),this.finishNode(o,n?"TSSatisfiesExpression":"TSAsExpression"),this.reScan_lt_gt(),this.parseExprOp(o,i,a)}return super.parseExprOp(e,i,a)}checkReservedWord(e,i,a,n){this.state.isAmbientContext||super.checkReservedWord(e,i,a,n)}checkImportReflection(e){super.checkImportReflection(e),e.module&&e.importKind!=="value"&&this.raise(w.ImportReflectionHasImportType,e.specifiers[0].loc.start)}checkDuplicateExports(){}isPotentialImportPhase(e){if(super.isPotentialImportPhase(e))return!0;if(this.isContextual(130)){const i=this.lookaheadCharCode();return e?i===123||i===42:i!==61}return!e&&this.isContextual(87)}applyImportPhase(e,i,a,n){super.applyImportPhase(e,i,a,n),i?e.exportKind=a==="type"?"type":"value":e.importKind=a==="type"||a==="typeof"?a:"value"}parseImport(e){if(this.match(134))return e.importKind="value",super.parseImport(e);let i;if(D(this.state.type)&&this.lookaheadCharCode()===61)return e.importKind="value",this.tsParseImportEqualsDeclaration(e);if(this.isContextual(130)){const a=this.parseMaybeImportPhase(e,!1);if(this.lookaheadCharCode()===61)return this.tsParseImportEqualsDeclaration(e,a);i=super.parseImportSpecifiersAndAfter(e,a)}else i=super.parseImport(e);return i.importKind==="type"&&i.specifiers.length>1&&i.specifiers[0].type==="ImportDefaultSpecifier"&&this.raise(w.TypeImportCannotSpecifyDefaultAndNamed,i),i}parseExport(e,i){if(this.match(83)){const a=this.startNode();this.next();let n=null;this.isContextual(130)&&this.isPotentialImportPhase(!1)?n=this.parseMaybeImportPhase(a,!1):a.importKind="value";const o=this.tsParseImportEqualsDeclaration(a,n,!0);return e.attributes=[],e.declaration=o,e.exportKind="value",e.source=null,e.specifiers=[],this.finishNode(e,"ExportNamedDeclaration")}else if(this.eat(29)){const a=e;return a.expression=super.parseExpression(),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(a,"TSExportAssignment")}else if(this.eatContextual(93)){const a=e;return this.expectContextual(128),a.id=this.parseIdentifier(),this.semicolon(),this.finishNode(a,"TSNamespaceExportDeclaration")}else return super.parseExport(e,i)}isAbstractClass(){return this.isContextual(124)&&this.lookahead().type===80}parseExportDefaultExpression(){if(this.isAbstractClass()){const e=this.startNode();return this.next(),e.abstract=!0,this.parseClass(e,!0,!0)}if(this.match(129)){const e=this.tsParseInterfaceDeclaration(this.startNode());if(e)return e}return super.parseExportDefaultExpression()}parseVarStatement(e,i,a=!1){const{isAmbientContext:n}=this.state,o=super.parseVarStatement(e,i,a||n);if(!n)return o;for(const{id:c,init:h}of o.declarations)h&&(i==="var"||i==="let"||c.typeAnnotation?this.raise(w.InitializerNotAllowedInAmbientContext,h):kn(h,this.hasPlugin("estree"))||this.raise(w.ConstInitializerMustBeStringOrNumericLiteralOrLiteralEnumReference,h));return o}parseStatementContent(e,i){if(this.match(75)&&this.isLookaheadContextual("enum")){const a=this.startNode();return this.expect(75),this.tsParseEnumDeclaration(a,{const:!0})}if(this.isContextual(126))return this.tsParseEnumDeclaration(this.startNode());if(this.isContextual(129)){const a=this.tsParseInterfaceDeclaration(this.startNode());if(a)return a}return super.parseStatementContent(e,i)}parseAccessModifier(){return this.tsParseModifier(["public","protected","private"])}tsHasSomeModifiers(e,i){return i.some(a=>wi(a)?e.accessibility===a:!!e[a])}tsIsStartOfStaticBlocks(){return this.isContextual(106)&&this.lookaheadCharCode()===123}parseClassMember(e,i,a){const n=["declare","private","public","protected","override","abstract","readonly","static"];this.tsParseModifiers({allowedModifiers:n,disallowedModifiers:["in","out"],stopOnStartOfClassStaticBlock:!0,errorTemplate:w.InvalidModifierOnTypeParameterPositions},i);const o=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(i,n)&&this.raise(w.StaticBlockCannotHaveModifier,this.state.curPosition()),super.parseClassStaticBlock(e,i)):this.parseClassMemberWithIsStatic(e,i,a,!!i.static)};i.declare?this.tsInAmbientContext(o):o()}parseClassMemberWithIsStatic(e,i,a,n){const o=this.tsTryParseIndexSignature(i);if(o){e.body.push(o),i.abstract&&this.raise(w.IndexSignatureHasAbstract,i),i.accessibility&&this.raise(w.IndexSignatureHasAccessibility,i,{modifier:i.accessibility}),i.declare&&this.raise(w.IndexSignatureHasDeclare,i),i.override&&this.raise(w.IndexSignatureHasOverride,i);return}!this.state.inAbstractClass&&i.abstract&&this.raise(w.NonAbstractClassHasAbstractMethod,i),i.override&&(a.hadSuperClass||this.raise(w.OverrideNotInSubClass,i)),super.parseClassMemberWithIsStatic(e,i,a,n)}parsePostMemberNameModifiers(e){this.eat(17)&&(e.optional=!0),e.readonly&&this.match(10)&&this.raise(w.ClassMethodHasReadonly,e),e.declare&&this.match(10)&&this.raise(w.ClassMethodHasDeclare,e)}parseExpressionStatement(e,i,a){return(i.type==="Identifier"?this.tsParseExpressionStatement(e,i,a):void 0)||super.parseExpressionStatement(e,i,a)}shouldParseExportDeclaration(){return this.tsIsDeclarationStart()?!0:super.shouldParseExportDeclaration()}parseConditional(e,i,a){if(!this.match(17))return e;if(this.state.maybeInArrowParameters){const n=this.lookaheadCharCode();if(n===44||n===61||n===58||n===41)return this.setOptionalParametersError(a),e}return super.parseConditional(e,i,a)}parseParenItem(e,i){const a=super.parseParenItem(e,i);if(this.eat(17)&&(a.optional=!0,this.resetEndLocation(e)),this.match(14)){const n=this.startNodeAt(i);return n.expression=e,n.typeAnnotation=this.tsParseTypeAnnotation(),this.finishNode(n,"TSTypeCastExpression")}return e}parseExportDeclaration(e){if(!this.state.isAmbientContext&&this.isContextual(125))return this.tsInAmbientContext(()=>this.parseExportDeclaration(e));const i=this.state.startLoc,a=this.eatContextual(125);if(a&&(this.isContextual(125)||!this.shouldParseExportDeclaration()))throw this.raise(w.ExpectedAmbientAfterExportDeclare,this.state.startLoc);const o=D(this.state.type)&&this.tsTryParseExportDeclaration()||super.parseExportDeclaration(e);return o?((o.type==="TSInterfaceDeclaration"||o.type==="TSTypeAliasDeclaration"||a)&&(e.exportKind="type"),a&&o.type!=="TSImportEqualsDeclaration"&&(this.resetStartLocation(o,i),o.declare=!0),o):null}parseClassId(e,i,a,n){if((!i||a)&&this.isContextual(113))return;super.parseClassId(e,i,a,e.declare?1024:8331);const o=this.tsTryParseTypeParameters(this.tsParseInOutConstModifiers);o&&(e.typeParameters=o)}parseClassPropertyAnnotation(e){e.optional||(this.eat(35)?e.definite=!0:this.eat(17)&&(e.optional=!0));const i=this.tsTryParseTypeAnnotation();i&&(e.typeAnnotation=i)}parseClassProperty(e){if(this.parseClassPropertyAnnotation(e),this.state.isAmbientContext&&!(e.readonly&&!e.typeAnnotation)&&this.match(29)&&this.raise(w.DeclareClassFieldHasInitializer,this.state.startLoc),e.abstract&&this.match(29)){const{key:i}=e;this.raise(w.AbstractPropertyHasInitializer,this.state.startLoc,{propertyName:i.type==="Identifier"&&!e.computed?i.name:`[${this.input.slice(this.offsetToSourcePos(i.start),this.offsetToSourcePos(i.end))}]`})}return super.parseClassProperty(e)}parseClassPrivateProperty(e){return e.abstract&&this.raise(w.PrivateElementHasAbstract,e),e.accessibility&&this.raise(w.PrivateElementHasAccessibility,e,{modifier:e.accessibility}),this.parseClassPropertyAnnotation(e),super.parseClassPrivateProperty(e)}parseClassAccessorProperty(e){return this.parseClassPropertyAnnotation(e),e.optional&&this.raise(w.AccessorCannotBeOptional,e),super.parseClassAccessorProperty(e)}pushClassMethod(e,i,a,n,o,c){const h=this.tsTryParseTypeParameters(this.tsParseConstModifier);h&&o&&this.raise(w.ConstructorHasTypeParameters,h);const{declare:l=!1,kind:u}=i;l&&(u==="get"||u==="set")&&this.raise(w.DeclareAccessor,i,{kind:u}),h&&(i.typeParameters=h),super.pushClassMethod(e,i,a,n,o,c)}pushClassPrivateMethod(e,i,a,n){const o=this.tsTryParseTypeParameters(this.tsParseConstModifier);o&&(i.typeParameters=o),super.pushClassPrivateMethod(e,i,a,n)}declareClassPrivateMethodInScope(e,i){e.type!=="TSDeclareMethod"&&(e.type==="MethodDefinition"&&e.value.body==null||super.declareClassPrivateMethodInScope(e,i))}parseClassSuper(e){super.parseClassSuper(e),e.superClass&&(this.match(47)||this.match(51))&&(e.superTypeArguments=this.tsParseTypeArgumentsInExpression()),this.eatContextual(113)&&(e.implements=this.tsParseHeritageClause("implements"))}parseObjPropValue(e,i,a,n,o,c,h){const l=this.tsTryParseTypeParameters(this.tsParseConstModifier);return l&&(e.typeParameters=l),super.parseObjPropValue(e,i,a,n,o,c,h)}parseFunctionParams(e,i){const a=this.tsTryParseTypeParameters(this.tsParseConstModifier);a&&(e.typeParameters=a),super.parseFunctionParams(e,i)}parseVarId(e,i){super.parseVarId(e,i),e.id.type==="Identifier"&&!this.hasPrecedingLineBreak()&&this.eat(35)&&(e.definite=!0);const a=this.tsTryParseTypeAnnotation();a&&(e.id.typeAnnotation=a,this.resetEndLocation(e.id))}parseAsyncArrowFromCallExpression(e,i){return this.match(14)&&(e.returnType=this.tsParseTypeAnnotation()),super.parseAsyncArrowFromCallExpression(e,i)}parseMaybeAssign(e,i){let a,n,o;if(this.hasPlugin("jsx")&&(this.match(143)||this.match(47))){if(a=this.state.clone(),n=this.tryParse(()=>super.parseMaybeAssign(e,i),a),!n.error)return n.node;const{context:l}=this.state,u=l[l.length-1];(u===R.j_oTag||u===R.j_expr)&&l.pop()}if(!(n!=null&&n.error)&&!this.match(47))return super.parseMaybeAssign(e,i);(!a||a===this.state)&&(a=this.state.clone());let c;const h=this.tryParse(l=>{var f,d;c=this.tsParseTypeParameters(this.tsParseConstModifier);const u=super.parseMaybeAssign(e,i);if((u.type!=="ArrowFunctionExpression"||(f=u.extra)!=null&&f.parenthesized)&&l(),(c==null?void 0:c.params.length)!==0&&this.resetStartLocationFromNode(u,c),u.typeParameters=c,this.hasPlugin("jsx")&&u.typeParameters.params.length===1&&!((d=u.typeParameters.extra)!=null&&d.trailingComma)){const P=u.typeParameters.params[0];P.constraint||this.raise(w.SingleTypeParameterWithoutTrailingComma,oe(P.loc.end,1),{typeParameterName:P.name.name})}return u},a);if(!h.error&&!h.aborted)return c&&this.reportReservedArrowTypeParam(c),h.node;if(!n&&(gi(!this.hasPlugin("jsx")),o=this.tryParse(()=>super.parseMaybeAssign(e,i),a),!o.error))return o.node;if(n!=null&&n.node)return this.state=n.failState,n.node;if(h.node)return this.state=h.failState,c&&this.reportReservedArrowTypeParam(c),h.node;if(o!=null&&o.node)return this.state=o.failState,o.node;throw(n==null?void 0:n.error)||h.error||(o==null?void 0:o.error)}reportReservedArrowTypeParam(e){var i;e.params.length===1&&!e.params[0].constraint&&!((i=e.extra)!=null&&i.trailingComma)&&this.getPluginOption("typescript","disallowAmbiguousJSXLike")&&this.raise(w.ReservedArrowTypeParam,e)}parseMaybeUnary(e,i){return!this.hasPlugin("jsx")&&this.match(47)?this.tsParseTypeAssertion():super.parseMaybeUnary(e,i)}parseArrow(e){if(this.match(14)){const i=this.tryParse(a=>{const n=this.tsParseTypeOrTypePredicateAnnotation(14);return(this.canInsertSemicolon()||!this.match(19))&&a(),n});if(i.aborted)return;i.thrown||(i.error&&(this.state=i.failState),e.returnType=i.node)}return super.parseArrow(e)}parseFunctionParamType(e){this.eat(17)&&(e.optional=!0);const i=this.tsTryParseTypeAnnotation();return i&&(e.typeAnnotation=i),this.resetEndLocation(e),e}isAssignable(e,i){switch(e.type){case"TSTypeCastExpression":return this.isAssignable(e.expression,i);case"TSParameterProperty":return!0;default:return super.isAssignable(e,i)}}toAssignable(e,i=!1){switch(e.type){case"ParenthesizedExpression":this.toAssignableParenthesizedExpression(e,i);break;case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":i?this.expressionScope.recordArrowParameterBindingError(w.UnexpectedTypeCastInParameter,e):this.raise(w.UnexpectedTypeCastInParameter,e),this.toAssignable(e.expression,i);break;case"AssignmentExpression":!i&&e.left.type==="TSTypeCastExpression"&&(e.left=this.typeCastToParameter(e.left));default:super.toAssignable(e,i)}}toAssignableParenthesizedExpression(e,i){switch(e.expression.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSNonNullExpression":case"TSTypeAssertion":case"ParenthesizedExpression":this.toAssignable(e.expression,i);break;default:super.toAssignable(e,i)}}checkToRestConversion(e,i){switch(e.type){case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":case"TSNonNullExpression":this.checkToRestConversion(e.expression,!1);break;default:super.checkToRestConversion(e,i)}}isValidLVal(e,i,a){switch(e){case"TSTypeCastExpression":return!0;case"TSParameterProperty":return"parameter";case"TSNonNullExpression":return"expression";case"TSAsExpression":case"TSSatisfiesExpression":case"TSTypeAssertion":return(a!==64||!i)&&["expression",!0];default:return super.isValidLVal(e,i,a)}}parseBindingAtom(){return this.state.type===78?this.parseIdentifier(!0):super.parseBindingAtom()}parseMaybeDecoratorArguments(e,i){if(this.match(47)||this.match(51)){const a=this.tsParseTypeArgumentsInExpression();if(this.match(10)){const n=super.parseMaybeDecoratorArguments(e,i);return n.typeArguments=a,n}this.unexpected(null,10)}return super.parseMaybeDecoratorArguments(e,i)}checkCommaAfterRest(e){return this.state.isAmbientContext&&this.match(12)&&this.lookaheadCharCode()===e?(this.next(),!1):super.checkCommaAfterRest(e)}isClassMethod(){return this.match(47)||super.isClassMethod()}isClassProperty(){return this.match(35)||this.match(14)||super.isClassProperty()}parseMaybeDefault(e,i){const a=super.parseMaybeDefault(e,i);return a.type==="AssignmentPattern"&&a.typeAnnotation&&a.right.start<a.typeAnnotation.start&&this.raise(w.TypeAnnotationAfterAssign,a.typeAnnotation),a}getTokenFromCode(e){if(this.state.inType){if(e===62){this.finishOp(48,1);return}if(e===60){this.finishOp(47,1);return}}super.getTokenFromCode(e)}reScan_lt_gt(){const{type:e}=this.state;e===47?(this.state.pos-=1,this.readToken_lt()):e===48&&(this.state.pos-=1,this.readToken_gt())}reScan_lt(){const{type:e}=this.state;return e===51?(this.state.pos-=2,this.finishOp(47,1),47):e}toAssignableListItem(e,i,a){const n=e[i];n.type==="TSTypeCastExpression"&&(e[i]=this.typeCastToParameter(n)),super.toAssignableListItem(e,i,a)}typeCastToParameter(e){return e.expression.typeAnnotation=e.typeAnnotation,this.resetEndLocation(e.expression,e.typeAnnotation.loc.end),e.expression}shouldParseArrow(e){return this.match(14)?e.every(i=>this.isAssignable(i,!0)):super.shouldParseArrow(e)}shouldParseAsyncArrow(){return this.match(14)||super.shouldParseAsyncArrow()}canHaveLeadingDecorator(){return super.canHaveLeadingDecorator()||this.isAbstractClass()}jsxParseOpeningElementAfterName(e){if(this.match(47)||this.match(51)){const i=this.tsTryParseAndCatch(()=>this.tsParseTypeArgumentsInExpression());i&&(e.typeArguments=i)}return super.jsxParseOpeningElementAfterName(e)}getGetterSetterExpectedParamCount(e){const i=super.getGetterSetterExpectedParamCount(e),n=this.getObjectOrClassMethodParams(e)[0];return n&&this.isThisParam(n)?i+1:i}parseCatchClauseParam(){const e=super.parseCatchClauseParam(),i=this.tsTryParseTypeAnnotation();return i&&(e.typeAnnotation=i,this.resetEndLocation(e)),e}tsInAmbientContext(e){const{isAmbientContext:i,strict:a}=this.state;this.state.isAmbientContext=!0,this.state.strict=!1;try{return e()}finally{this.state.isAmbientContext=i,this.state.strict=a}}parseClass(e,i,a){const n=this.state.inAbstractClass;this.state.inAbstractClass=!!e.abstract;try{return super.parseClass(e,i,a)}finally{this.state.inAbstractClass=n}}tsParseAbstractDeclaration(e,i){if(this.match(80))return e.abstract=!0,this.maybeTakeDecorators(i,this.parseClass(e,!0,!1));if(this.isContextual(129)){if(!this.hasFollowingLineBreak())return e.abstract=!0,this.raise(w.NonClassMethodPropertyHasAbstractModifier,e),this.tsParseInterfaceDeclaration(e)}else this.unexpected(null,80)}parseMethod(e,i,a,n,o,c,h){const l=super.parseMethod(e,i,a,n,o,c,h);if((l.abstract||l.type==="TSAbstractMethodDefinition")&&(this.hasPlugin("estree")?l.value:l).body){const{key:d}=l;this.raise(w.AbstractMethodHasImplementation,l,{methodName:d.type==="Identifier"&&!l.computed?d.name:`[${this.input.slice(this.offsetToSourcePos(d.start),this.offsetToSourcePos(d.end))}]`})}return l}tsParseTypeParameterName(){return this.parseIdentifier()}shouldParseAsAmbientContext(){return!!this.getPluginOption("typescript","dts")}parse(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.parse()}getExpression(){return this.shouldParseAsAmbientContext()&&(this.state.isAmbientContext=!0),super.getExpression()}parseExportSpecifier(e,i,a,n){return!i&&n?(this.parseTypeOnlyImportExportSpecifier(e,!1,a),this.finishNode(e,"ExportSpecifier")):(e.exportKind="value",super.parseExportSpecifier(e,i,a,n))}parseImportSpecifier(e,i,a,n,o){return!i&&n?(this.parseTypeOnlyImportExportSpecifier(e,!0,a),this.finishNode(e,"ImportSpecifier")):(e.importKind="value",super.parseImportSpecifier(e,i,a,n,a?4098:4096))}parseTypeOnlyImportExportSpecifier(e,i,a){const n=i?"imported":"local",o=i?"local":"exported";let c=e[n],h,l=!1,u=!0;const f=c.loc.start;if(this.isContextual(93)){const P=this.parseIdentifier();if(this.isContextual(93)){const S=this.parseIdentifier();ue(this.state.type)?(l=!0,c=P,h=i?this.parseIdentifier():this.parseModuleExportName(),u=!1):(h=S,u=!1)}else ue(this.state.type)?(u=!1,h=i?this.parseIdentifier():this.parseModuleExportName()):(l=!0,c=P)}else ue(this.state.type)&&(l=!0,i?(c=this.parseIdentifier(!0),this.isContextual(93)||this.checkReservedWord(c.name,c.loc.start,!0,!0)):c=this.parseModuleExportName());l&&a&&this.raise(i?w.TypeModifierIsUsedInTypeImports:w.TypeModifierIsUsedInTypeExports,f),e[n]=c,e[o]=h;const d=i?"importKind":"exportKind";e[d]=l?"type":"value",u&&this.eatContextual(93)&&(e[o]=i?this.parseIdentifier():this.parseModuleExportName()),e[o]||(e[o]=this.cloneIdentifier(e[n])),i&&this.checkIdentifier(e[o],l?4098:4096)}fillOptionalPropertiesForTSESLint(e){switch(e.type){case"ExpressionStatement":e.directive??(e.directive=void 0);return;case"RestElement":e.value=void 0;case"Identifier":case"ArrayPattern":case"AssignmentPattern":case"ObjectPattern":e.decorators??(e.decorators=[]),e.optional??(e.optional=!1),e.typeAnnotation??(e.typeAnnotation=void 0);return;case"TSParameterProperty":e.accessibility??(e.accessibility=void 0),e.decorators??(e.decorators=[]),e.override??(e.override=!1),e.readonly??(e.readonly=!1),e.static??(e.static=!1);return;case"TSEmptyBodyFunctionExpression":e.body=null;case"TSDeclareFunction":case"FunctionDeclaration":case"FunctionExpression":case"ClassMethod":case"ClassPrivateMethod":e.declare??(e.declare=!1),e.returnType??(e.returnType=void 0),e.typeParameters??(e.typeParameters=void 0);return;case"Property":e.optional??(e.optional=!1);return;case"TSMethodSignature":case"TSPropertySignature":e.optional??(e.optional=!1);case"TSIndexSignature":e.accessibility??(e.accessibility=void 0),e.readonly??(e.readonly=!1),e.static??(e.static=!1);return;case"TSAbstractPropertyDefinition":case"PropertyDefinition":case"TSAbstractAccessorProperty":case"AccessorProperty":e.declare??(e.declare=!1),e.definite??(e.definite=!1),e.readonly??(e.readonly=!1),e.typeAnnotation??(e.typeAnnotation=void 0);case"TSAbstractMethodDefinition":case"MethodDefinition":e.accessibility??(e.accessibility=void 0),e.decorators??(e.decorators=[]),e.override??(e.override=!1),e.optional??(e.optional=!1);return;case"ClassExpression":e.id??(e.id=null);case"ClassDeclaration":e.abstract??(e.abstract=!1),e.declare??(e.declare=!1),e.decorators??(e.decorators=[]),e.implements??(e.implements=[]),e.superTypeArguments??(e.superTypeArguments=void 0),e.typeParameters??(e.typeParameters=void 0);return;case"TSTypeAliasDeclaration":case"VariableDeclaration":e.declare??(e.declare=!1);return;case"VariableDeclarator":e.definite??(e.definite=!1);return;case"TSEnumDeclaration":e.const??(e.const=!1),e.declare??(e.declare=!1);return;case"TSEnumMember":e.computed??(e.computed=!1);return;case"TSImportType":e.qualifier??(e.qualifier=null),e.options??(e.options=null),e.typeArguments??(e.typeArguments=null);return;case"TSInterfaceDeclaration":e.declare??(e.declare=!1),e.extends??(e.extends=[]);return;case"TSModuleDeclaration":e.declare??(e.declare=!1),e.global??(e.global=e.kind==="global");return;case"TSTypeParameter":e.const??(e.const=!1),e.in??(e.in=!1),e.out??(e.out=!1);return}}};function Cn(r){if(r.type!=="MemberExpression")return!1;const{computed:t,property:s}=r;return t&&s.type!=="StringLiteral"&&(s.type!=="TemplateLiteral"||s.expressions.length>0)?!1:Ai(r.object)}function kn(r,t){var e;const{type:s}=r;if((e=r.extra)!=null&&e.parenthesized)return!1;if(t){if(s==="Literal"){const{value:i}=r;if(typeof i=="string"||typeof i=="boolean")return!0}}else if(s==="StringLiteral"||s==="BooleanLiteral")return!0;return!!(Ti(r,t)||Nn(r,t)||s==="TemplateLiteral"&&r.expressions.length===0||Cn(r))}function Ti(r,t){return t?r.type==="Literal"&&(typeof r.value=="number"||"bigint"in r):r.type==="NumericLiteral"||r.type==="BigIntLiteral"}function Nn(r,t){if(r.type==="UnaryExpression"){const{operator:s,argument:e}=r;if(s==="-"&&Ti(e,t))return!0}return!1}function Ai(r){return r.type==="Identifier"?!0:r.type!=="MemberExpression"||r.computed?!1:Ai(r.object)}const Si=Pe`placeholders`({ClassNameIsRequired:"A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."});var vn=r=>class extends r{parsePlaceholder(s){if(this.match(133)){const e=this.startNode();return this.next(),this.assertNoSpace(),e.name=super.parseIdentifier(!0),this.assertNoSpace(),this.expect(133),this.finishPlaceholder(e,s)}}finishPlaceholder(s,e){let i=s;return(!i.expectedNode||!i.type)&&(i=this.finishNode(i,"Placeholder")),i.expectedNode=e,i}getTokenFromCode(s){s===37&&this.input.charCodeAt(this.state.pos+1)===37?this.finishOp(133,2):super.getTokenFromCode(s)}parseExprAtom(s){return this.parsePlaceholder("Expression")||super.parseExprAtom(s)}parseIdentifier(s){return this.parsePlaceholder("Identifier")||super.parseIdentifier(s)}checkReservedWord(s,e,i,a){s!==void 0&&super.checkReservedWord(s,e,i,a)}cloneIdentifier(s){const e=super.cloneIdentifier(s);return e.type==="Placeholder"&&(e.expectedNode=s.expectedNode),e}cloneStringLiteral(s){return s.type==="Placeholder"?this.cloneIdentifier(s):super.cloneStringLiteral(s)}parseBindingAtom(){return this.parsePlaceholder("Pattern")||super.parseBindingAtom()}isValidLVal(s,e,i){return s==="Placeholder"||super.isValidLVal(s,e,i)}toAssignable(s,e){s&&s.type==="Placeholder"&&s.expectedNode==="Expression"?s.expectedNode="Pattern":super.toAssignable(s,e)}chStartsBindingIdentifier(s,e){return!!(super.chStartsBindingIdentifier(s,e)||this.lookahead().type===133)}verifyBreakContinue(s,e){s.label&&s.label.type==="Placeholder"||super.verifyBreakContinue(s,e)}parseExpressionStatement(s,e){var a;if(e.type!=="Placeholder"||(a=e.extra)!=null&&a.parenthesized)return super.parseExpressionStatement(s,e);if(this.match(14)){const n=s;return n.label=this.finishPlaceholder(e,"Identifier"),this.next(),n.body=super.parseStatementOrSloppyAnnexBFunctionDeclaration(),this.finishNode(n,"LabeledStatement")}this.semicolon();const i=s;return i.name=e.name,this.finishPlaceholder(i,"Statement")}parseBlock(s,e,i){return this.parsePlaceholder("BlockStatement")||super.parseBlock(s,e,i)}parseFunctionId(s){return this.parsePlaceholder("Identifier")||super.parseFunctionId(s)}parseClass(s,e,i){const a=e?"ClassDeclaration":"ClassExpression";this.next();const n=this.state.strict,o=this.parsePlaceholder("Identifier");if(o)if(this.match(81)||this.match(133)||this.match(5))s.id=o;else{if(i||!e)return s.id=null,s.body=this.finishPlaceholder(o,"ClassBody"),this.finishNode(s,a);throw this.raise(Si.ClassNameIsRequired,this.state.startLoc)}else this.parseClassId(s,e,i);return super.parseClassSuper(s),s.body=this.parsePlaceholder("ClassBody")||super.parseClassBody(!!s.superClass,n),this.finishNode(s,a)}parseExport(s,e){const i=this.parsePlaceholder("Identifier");if(!i)return super.parseExport(s,e);const a=s;if(!this.isContextual(98)&&!this.match(12))return a.specifiers=[],a.source=null,a.declaration=this.finishPlaceholder(i,"Declaration"),this.finishNode(a,"ExportNamedDeclaration");this.expectPlugin("exportDefaultFrom");const n=this.startNode();return n.exported=i,a.specifiers=[this.finishNode(n,"ExportDefaultSpecifier")],super.parseExport(a,e)}isExportDefaultSpecifier(){if(this.match(65)){const s=this.nextTokenStart();if(this.isUnparsedContextual(s,"from")&&this.input.startsWith(Ne(133),this.nextTokenStartSince(s+4)))return!0}return super.isExportDefaultSpecifier()}maybeParseExportDefaultSpecifier(s,e){var i;return(i=s.specifiers)!=null&&i.length?!0:super.maybeParseExportDefaultSpecifier(s,e)}checkExport(s){const{specifiers:e}=s;e!=null&&e.length&&(s.specifiers=e.filter(i=>i.exported.type==="Placeholder")),super.checkExport(s),s.specifiers=e}parseImport(s){const e=this.parsePlaceholder("Identifier");if(!e)return super.parseImport(s);if(s.specifiers=[],!this.isContextual(98)&&!this.match(12))return s.source=this.finishPlaceholder(e,"StringLiteral"),this.semicolon(),this.finishNode(s,"ImportDeclaration");const i=this.startNodeAtNode(e);return i.local=e,s.specifiers.push(this.finishNode(i,"ImportDefaultSpecifier")),this.eat(12)&&(this.maybeParseStarImportSpecifier(s)||this.parseNamedImportSpecifiers(s)),this.expectContextual(98),s.source=this.parseImportSource(),this.semicolon(),this.finishNode(s,"ImportDeclaration")}parseImportSource(){return this.parsePlaceholder("StringLiteral")||super.parseImportSource()}assertNoSpace(){this.state.start>this.offsetToSourcePos(this.state.lastTokEndLoc.index)&&this.raise(Si.UnexpectedSpace,this.state.lastTokEndLoc)}},On=r=>class extends r{parseV8Intrinsic(){if(this.match(54)){const s=this.state.startLoc,e=this.startNode();if(this.next(),D(this.state.type)){const i=this.parseIdentifierName(),a=this.createIdentifier(e,i);if(this.castNodeTo(a,"V8IntrinsicIdentifier"),this.match(10))return a}this.unexpected(s)}}parseExprAtom(s){return this.parseV8Intrinsic()||super.parseExprAtom(s)}};const Ii=["fsharp","hack"],Ei=["^^","@@","^","%","#"];function Dn(r){if(r.has("decorators")){if(r.has("decorators-legacy"))throw new Error("Cannot use the decorators and decorators-legacy plugin together");const t=r.get("decorators").decoratorsBeforeExport;if(t!=null&&typeof t!="boolean")throw new Error("'decoratorsBeforeExport' must be a boolean, if specified.");const s=r.get("decorators").allowCallParenthesized;if(s!=null&&typeof s!="boolean")throw new Error("'allowCallParenthesized' must be a boolean.")}if(r.has("flow")&&r.has("typescript"))throw new Error("Cannot combine flow and typescript plugins.");if(r.has("placeholders")&&r.has("v8intrinsic"))throw new Error("Cannot combine placeholders and v8intrinsic plugins.");if(r.has("pipelineOperator")){const t=r.get("pipelineOperator").proposal;if(!Ii.includes(t)){const s=Ii.map(e=>`"${e}"`).join(", ");throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${s}.`)}if(t==="hack"){if(r.has("placeholders"))throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");if(r.has("v8intrinsic"))throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");const s=r.get("pipelineOperator").topicToken;if(!Ei.includes(s)){const e=Ei.map(i=>`"${i}"`).join(", ");throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${e}.`)}}}if(r.has("moduleAttributes"))throw new Error("`moduleAttributes` has been removed in Babel 8, please migrate to import attributes instead.");if(r.has("importAssertions"))throw new Error("`importAssertions` has been removed in Babel 8, please use import attributes instead. To use the non-standard `assert` syntax you can enable the `deprecatedImportAssert` parser plugin.");if(!r.has("deprecatedImportAssert")&&r.has("importAttributes")&&r.get("importAttributes").deprecatedAssertSyntax)throw new Error("The 'importAttributes' plugin has been removed in Babel 8. If you need to enable support for the deprecated `assert` syntax, you can enable the `deprecatedImportAssert` parser plugin.");if(r.has("recordAndTuple"))throw new Error("The 'recordAndTuple' plugin has been removed in Babel 8. Please remove it from your configuration.");if(r.has("asyncDoExpressions")&&!r.has("doExpressions")){const t=new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");throw t.missingPlugins="doExpressions",t}if(r.has("optionalChainingAssign")&&r.get("optionalChainingAssign").version!=="2023-07")throw new Error("The 'optionalChainingAssign' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is '2023-07'.");{if(r.has("decimal"))throw new Error("The 'decimal' plugin has been removed in Babel 8. Please remove it from your configuration.");if(r.has("importReflection"))throw new Error("The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and replace 'import module' with 'import source' in your code.")}}const Ci={estree:ga,jsx:en,flow:Xa,typescript:En,v8intrinsic:On,placeholders:vn},Ln=Object.keys(Ci);class Mn extends Tn{checkProto(t,s,e,i){if(t.type==="SpreadElement"||this.isObjectMethod(t)||t.computed||t.shorthand)return e;const a=t.key;return(a.type==="Identifier"?a.name:a.value)==="__proto__"?s?(this.raise(p.RecordNoProto,a),!0):(e&&(i?i.doubleProtoLoc===null&&(i.doubleProtoLoc=a.loc.start):this.raise(p.DuplicateProto,a)),!0):e}shouldExitDescending(t,s){return t.type==="ArrowFunctionExpression"&&this.offsetToSourcePos(t.start)===s}getExpression(){if(this.enterInitialScopes(),this.nextToken(),this.match(140))throw this.raise(p.ParseExpressionEmptyInput,this.state.startLoc);const t=this.parseExpression();if(!this.match(140))throw this.raise(p.ParseExpressionExpectsEOF,this.state.startLoc,{unexpected:this.input.codePointAt(this.state.start)});return this.finalizeRemainingComments(),t.comments=this.comments,t.errors=this.state.errors,this.optionFlags&256&&(t.tokens=this.tokens),t}parseExpression(t,s){return t?this.disallowInAnd(()=>this.parseExpressionBase(s)):this.allowInAnd(()=>this.parseExpressionBase(s))}parseExpressionBase(t){const s=this.state.startLoc,e=this.parseMaybeAssign(t);if(this.match(12)){const i=this.startNodeAt(s);for(i.expressions=[e];this.eat(12);)i.expressions.push(this.parseMaybeAssign(t));return this.toReferencedList(i.expressions),this.finishNode(i,"SequenceExpression")}return e}parseMaybeAssignDisallowIn(t,s){return this.disallowInAnd(()=>this.parseMaybeAssign(t,s))}parseMaybeAssignAllowIn(t,s){return this.allowInAnd(()=>this.parseMaybeAssign(t,s))}setOptionalParametersError(t){t.optionalParametersLoc=this.state.startLoc}parseMaybeAssign(t,s){const e=this.state.startLoc,i=this.isContextual(108);if(i&&this.prodParam.hasYield){this.next();let c=this.parseYield(e);return s&&(c=s.call(this,c,e)),c}let a;t?a=!1:(t=new Lt,a=!0);const{type:n}=this.state;(n===10||D(n))&&(this.state.potentialArrowAt=this.state.start);let o=this.parseMaybeConditional(t);if(s&&(o=s.call(this,o,e)),Ia(this.state.type)){const c=this.startNodeAt(e),h=this.state.value;if(c.operator=h,this.match(29)){this.toAssignable(o,!0),c.left=o;const l=e.index;t.doubleProtoLoc!=null&&t.doubleProtoLoc.index>=l&&(t.doubleProtoLoc=null),t.shorthandAssignLoc!=null&&t.shorthandAssignLoc.index>=l&&(t.shorthandAssignLoc=null),t.privateKeyLoc!=null&&t.privateKeyLoc.index>=l&&(this.checkDestructuringPrivate(t),t.privateKeyLoc=null)}else c.left=o;return this.next(),c.right=this.parseMaybeAssign(),this.checkLVal(o,this.finishNode(c,"AssignmentExpression")),c}else a&&this.checkExpressionErrors(t,!0);if(i){const{type:c}=this.state;if((this.hasPlugin("v8intrinsic")?ut(c):ut(c)&&!this.match(54))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(p.YieldNotInGeneratorFunction,e),this.parseYield(e)}return o}parseMaybeConditional(t){const s=this.state.startLoc,e=this.state.potentialArrowAt,i=this.parseExprOps(t);return this.shouldExitDescending(i,e)?i:this.parseConditional(i,s,t)}parseConditional(t,s,e){if(this.eat(17)){const i=this.startNodeAt(s);return i.test=t,i.consequent=this.parseMaybeAssignAllowIn(),this.expect(14),i.alternate=this.parseMaybeAssign(),this.finishNode(i,"ConditionalExpression")}return t}parseMaybeUnaryOrPrivate(t){return this.match(139)?this.parsePrivateName():this.parseMaybeUnary(t)}parseExprOps(t){const s=this.state.startLoc,e=this.state.potentialArrowAt,i=this.parseMaybeUnaryOrPrivate(t);return this.shouldExitDescending(i,e)?i:this.parseExprOp(i,s,-1)}parseExprOp(t,s,e){if(this.isPrivateName(t)){const a=this.getPrivateNameSV(t);(e>=kt(58)||!this.prodParam.hasIn||!this.match(58))&&this.raise(p.PrivateInExpectedIn,t,{identifierName:a}),this.classScope.usePrivateName(a,t.loc.start)}const i=this.state.type;if(Ca(i)&&(this.prodParam.hasIn||!this.match(58))){let a=kt(i);if(a>e){if(i===39){if(this.expectPlugin("pipelineOperator"),this.state.inFSharpPipelineDirectBody)return t;this.checkPipelineAtInfixOperator(t,s)}const n=this.startNodeAt(s);n.left=t,n.operator=this.state.value;const o=i===41||i===42,c=i===40;c&&(a=kt(42)),this.next(),n.right=this.parseExprOpRightExpr(i,a);const h=this.finishNode(n,o||c?"LogicalExpression":"BinaryExpression"),l=this.state.type;if(c&&(l===41||l===42)||o&&l===40)throw this.raise(p.MixingCoalesceWithLogical,this.state.startLoc);return this.parseExprOp(h,s,e)}}return t}parseExprOpRightExpr(t,s){switch(this.state.startLoc,t){case 39:switch(this.getPluginOption("pipelineOperator","proposal")){case"hack":return this.withTopicBindingContext(()=>this.parseHackPipeBody());case"fsharp":return this.withSoloAwaitPermittingContext(()=>this.parseFSharpPipelineBody(s))}default:return this.parseExprOpBaseRightExpr(t,s)}}parseExprOpBaseRightExpr(t,s){const e=this.state.startLoc;return this.parseExprOp(this.parseMaybeUnaryOrPrivate(),e,Da(t)?s-1:s)}parseHackPipeBody(){var i;const{startLoc:t}=this.state,s=this.parseMaybeAssign();return fa.has(s.type)&&!((i=s.extra)!=null&&i.parenthesized)&&this.raise(p.PipeUnparenthesizedBody,t,{type:s.type}),this.topicReferenceWasUsedInCurrentContext()||this.raise(p.PipeTopicUnused,t),s}checkExponentialAfterUnary(t){this.match(57)&&this.raise(p.UnexpectedTokenUnaryExponentiation,t.argument)}parseMaybeUnary(t,s){const e=this.state.startLoc,i=this.isContextual(96);if(i&&this.recordAwaitIfAllowed()){this.next();const c=this.parseAwait(e);return s||this.checkExponentialAfterUnary(c),c}const a=this.match(34),n=this.startNode();if(Na(this.state.type)){n.operator=this.state.value,n.prefix=!0,this.match(72)&&this.expectPlugin("throwExpressions");const c=this.match(89);if(this.next(),n.argument=this.parseMaybeUnary(null,!0),this.checkExpressionErrors(t,!0),this.state.strict&&c){const h=n.argument;h.type==="Identifier"?this.raise(p.StrictDelete,n):this.hasPropertyAsPrivateName(h)&&this.raise(p.DeletePrivateField,n)}if(!a)return s||this.checkExponentialAfterUnary(n),this.finishNode(n,"UnaryExpression")}const o=this.parseUpdate(n,a,t);if(i){const{type:c}=this.state;if((this.hasPlugin("v8intrinsic")?ut(c):ut(c)&&!this.match(54))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(p.AwaitNotInAsyncContext,e),this.parseAwait(e)}return o}parseUpdate(t,s,e){if(s){const n=t;return this.checkLVal(n.argument,this.finishNode(n,"UpdateExpression")),t}const i=this.state.startLoc;let a=this.parseExprSubscripts(e);if(this.checkExpressionErrors(e,!1))return a;for(;ka(this.state.type)&&!this.canInsertSemicolon();){const n=this.startNodeAt(i);n.operator=this.state.value,n.prefix=!1,n.argument=a,this.next(),this.checkLVal(a,a=this.finishNode(n,"UpdateExpression"))}return a}parseExprSubscripts(t){const s=this.state.startLoc,e=this.state.potentialArrowAt,i=this.parseExprAtom(t);return this.shouldExitDescending(i,e)?i:this.parseSubscripts(i,s)}parseSubscripts(t,s,e){const i={optionalChainMember:!1,maybeAsyncArrow:this.atPossibleAsyncArrow(t),stop:!1};do t=this.parseSubscript(t,s,e,i),i.maybeAsyncArrow=!1;while(!i.stop);return t}parseSubscript(t,s,e,i){const{type:a}=this.state;if(!e&&a===15)return this.parseBind(t,s,e,i);if(ps(a))return this.parseTaggedTemplateExpression(t,s,i);let n=!1;if(a===18){if(e&&(this.raise(p.OptionalChainingNoNew,this.state.startLoc),this.lookaheadCharCode()===40))return this.stopParseSubscript(t,i);i.optionalChainMember=n=!0,this.next()}if(!e&&this.match(10))return this.parseCoverCallAndAsyncArrowHead(t,s,i,n);{const o=this.eat(0);return o||n||this.eat(16)?this.parseMember(t,s,i,o,n):this.stopParseSubscript(t,i)}}stopParseSubscript(t,s){return s.stop=!0,t}parseMember(t,s,e,i,a){const n=this.startNodeAt(s);return n.object=t,n.computed=i,i?(n.property=this.parseExpression(),this.expect(3)):this.match(139)?(t.type==="Super"&&this.raise(p.SuperPrivateField,s),this.classScope.usePrivateName(this.state.value,this.state.startLoc),n.property=this.parsePrivateName()):n.property=this.parseIdentifier(!0),e.optionalChainMember?(n.optional=a,this.finishNode(n,"OptionalMemberExpression")):this.finishNode(n,"MemberExpression")}parseBind(t,s,e,i){const a=this.startNodeAt(s);return a.object=t,this.next(),a.callee=this.parseNoCallExpr(),i.stop=!0,this.parseSubscripts(this.finishNode(a,"BindExpression"),s,e)}parseCoverCallAndAsyncArrowHead(t,s,e,i){const a=this.state.maybeInArrowParameters;let n=null;this.state.maybeInArrowParameters=!0,this.next();const o=this.startNodeAt(s);o.callee=t;const{maybeAsyncArrow:c,optionalChainMember:h}=e;c&&(this.expressionScope.enter(bn()),n=new Lt),h&&(o.optional=i),i?o.arguments=this.parseCallExpressionArguments(11):o.arguments=this.parseCallExpressionArguments(11,t.type!=="Super",o,n);let l=this.finishCallExpression(o,h);return c&&this.shouldParseAsyncArrow()&&!i?(e.stop=!0,this.checkDestructuringPrivate(n),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),l=this.parseAsyncArrowFromCallExpression(this.startNodeAt(s),l)):(c&&(this.checkExpressionErrors(n,!0),this.expressionScope.exit()),this.toReferencedArguments(l)),this.state.maybeInArrowParameters=a,l}toReferencedArguments(t,s){this.toReferencedListDeep(t.arguments,s)}parseTaggedTemplateExpression(t,s,e){const i=this.startNodeAt(s);return i.tag=t,i.quasi=this.parseTemplate(!0),e.optionalChainMember&&this.raise(p.OptionalChainingNoTemplate,s),this.finishNode(i,"TaggedTemplateExpression")}atPossibleAsyncArrow(t){return t.type==="Identifier"&&t.name==="async"&&this.state.lastTokEndLoc.index===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.offsetToSourcePos(t.start)===this.state.potentialArrowAt}finishCallExpression(t,s){if(t.callee.type==="Import")if(t.arguments.length===0||t.arguments.length>2)this.raise(p.ImportCallArity,t);else for(const e of t.arguments)e.type==="SpreadElement"&&this.raise(p.ImportCallSpreadArgument,e);return this.finishNode(t,s?"OptionalCallExpression":"CallExpression")}parseCallExpressionArguments(t,s,e,i){const a=[];let n=!0;const o=this.state.inFSharpPipelineDirectBody;for(this.state.inFSharpPipelineDirectBody=!1;!this.eat(t);){if(n)n=!1;else if(this.expect(12),this.match(t)){e&&this.addTrailingCommaExtraToNode(e),this.next();break}a.push(this.parseExprListItem(!1,i,s))}return this.state.inFSharpPipelineDirectBody=o,a}shouldParseAsyncArrow(){return this.match(19)&&!this.canInsertSemicolon()}parseAsyncArrowFromCallExpression(t,s){var e;return this.resetPreviousNodeTrailingComments(s),this.expect(19),this.parseArrowExpression(t,s.arguments,!0,(e=s.extra)==null?void 0:e.trailingCommaLoc),s.innerComments&&Ve(t,s.innerComments),s.callee.trailingComments&&Ve(t,s.callee.trailingComments),t}parseNoCallExpr(){const t=this.state.startLoc;return this.parseSubscripts(this.parseExprAtom(),t,!0)}parseExprAtom(t){let s,e=null;const{type:i}=this.state;switch(i){case 79:return this.parseSuper();case 83:return s=this.startNode(),this.next(),this.match(16)?this.parseImportMetaPropertyOrPhaseCall(s):this.match(10)?this.optionFlags&512?this.parseImportCall(s):this.finishNode(s,"Import"):(this.raise(p.UnsupportedImport,this.state.lastTokStartLoc),this.finishNode(s,"Import"));case 78:return s=this.startNode(),this.next(),this.finishNode(s,"ThisExpression");case 90:return this.parseDo(this.startNode(),!1);case 56:case 31:return this.readRegexp(),this.parseRegExpLiteral(this.state.value);case 135:return this.parseNumericLiteral(this.state.value);case 136:return this.parseBigIntLiteral(this.state.value);case 134:return this.parseStringLiteral(this.state.value);case 84:return this.parseNullLiteral();case 85:return this.parseBooleanLiteral(!0);case 86:return this.parseBooleanLiteral(!1);case 10:{const a=this.state.potentialArrowAt===this.state.start;return this.parseParenAndDistinguishExpression(a)}case 0:return this.parseArrayLike(3,!0,!1,t);case 5:return this.parseObjectLike(8,!1,!1,t);case 68:return this.parseFunctionOrFunctionSent();case 26:e=this.parseDecorators();case 80:return this.parseClass(this.maybeTakeDecorators(e,this.startNode()),!1);case 77:return this.parseNewOrNewTarget();case 25:case 24:return this.parseTemplate(!1);case 15:{s=this.startNode(),this.next(),s.object=null;const a=s.callee=this.parseNoCallExpr();if(a.type==="MemberExpression")return this.finishNode(s,"BindExpression");throw this.raise(p.UnsupportedBind,a)}case 139:return this.raise(p.PrivateInExpectedIn,this.state.startLoc,{identifierName:this.state.value}),this.parsePrivateName();case 33:return this.parseTopicReferenceThenEqualsSign(54,"%");case 32:return this.parseTopicReferenceThenEqualsSign(44,"^");case 37:case 38:return this.parseTopicReference("hack");case 44:case 54:case 27:{const a=this.getPluginOption("pipelineOperator","proposal");if(a)return this.parseTopicReference(a);this.unexpected();break}case 47:{const a=this.input.codePointAt(this.nextTokenStart());ge(a)||a===62?this.expectOnePlugin(["jsx","flow","typescript"]):this.unexpected();break}default:if(D(i)){if(this.isContextual(127)&&this.lookaheadInLineCharCode()===123)return this.parseModuleExpression();const a=this.state.potentialArrowAt===this.state.start,n=this.state.containsEsc,o=this.parseIdentifier();if(!n&&o.name==="async"&&!this.canInsertSemicolon()){const{type:c}=this.state;if(c===68)return this.resetPreviousNodeTrailingComments(o),this.next(),this.parseAsyncFunctionExpression(this.startNodeAtNode(o));if(D(c))return this.lookaheadCharCode()===61?this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(o)):o;if(c===90)return this.resetPreviousNodeTrailingComments(o),this.parseDo(this.startNodeAtNode(o),!0)}return a&&this.match(19)&&!this.canInsertSemicolon()?(this.next(),this.parseArrowExpression(this.startNodeAtNode(o),[o],!1)):o}else this.unexpected()}}parseTopicReferenceThenEqualsSign(t,s){const e=this.getPluginOption("pipelineOperator","proposal");if(e)return this.state.type=t,this.state.value=s,this.state.pos--,this.state.end--,this.state.endLoc=oe(this.state.endLoc,-1),this.parseTopicReference(e);this.unexpected()}parseTopicReference(t){const s=this.startNode(),e=this.state.startLoc,i=this.state.type;return this.next(),this.finishTopicReference(s,e,t,i)}finishTopicReference(t,s,e,i){if(this.testTopicReferenceConfiguration(e,s,i))return this.topicReferenceIsAllowedInCurrentContext()||this.raise(p.PipeTopicUnbound,s),this.registerTopicReference(),this.finishNode(t,"TopicReference");throw this.raise(p.PipeTopicUnconfiguredToken,s,{token:Ne(i)})}testTopicReferenceConfiguration(t,s,e){switch(t){case"hack":return this.hasPlugin(["pipelineOperator",{topicToken:Ne(e)}]);case"smart":return e===27;default:throw this.raise(p.PipeTopicRequiresHackPipes,s)}}parseAsyncArrowUnaryFunction(t){this.prodParam.enter(vt(!0,this.prodParam.hasYield));const s=[this.parseIdentifier()];return this.prodParam.exit(),this.hasPrecedingLineBreak()&&this.raise(p.LineTerminatorBeforeArrow,this.state.curPosition()),this.expect(19),this.parseArrowExpression(t,s,!0)}parseDo(t,s){this.expectPlugin("doExpressions"),s&&this.expectPlugin("asyncDoExpressions"),t.async=s,this.next();const e=this.state.labels;return this.state.labels=[],s?(this.prodParam.enter(2),t.body=this.parseBlock(),this.prodParam.exit()):t.body=this.parseBlock(),this.state.labels=e,this.finishNode(t,"DoExpression")}parseSuper(){const t=this.startNode();return this.next(),this.match(10)&&!this.scope.allowDirectSuper&&!(this.optionFlags&16)?this.raise(p.SuperNotAllowed,t):!this.scope.allowSuper&&!(this.optionFlags&16)&&this.raise(p.UnexpectedSuper,t),!this.match(10)&&!this.match(0)&&!this.match(16)&&this.raise(p.UnsupportedSuper,t),this.finishNode(t,"Super")}parsePrivateName(){const t=this.startNode(),s=this.startNodeAt(oe(this.state.startLoc,1)),e=this.state.value;return this.next(),t.id=this.createIdentifier(s,e),this.finishNode(t,"PrivateName")}parseFunctionOrFunctionSent(){const t=this.startNode();if(this.next(),this.prodParam.hasYield&&this.match(16)){const s=this.createIdentifier(this.startNodeAtNode(t),"function");return this.next(),this.match(103)?this.expectPlugin("functionSent"):this.hasPlugin("functionSent")||this.unexpected(),this.parseMetaProperty(t,s,"sent")}return this.parseFunction(t)}parseMetaProperty(t,s,e){t.meta=s;const i=this.state.containsEsc;return t.property=this.parseIdentifier(!0),(t.property.name!==e||i)&&this.raise(p.UnsupportedMetaProperty,t.property,{target:s.name,onlyValidPropertyName:e}),this.finishNode(t,"MetaProperty")}parseImportMetaPropertyOrPhaseCall(t){if(this.next(),this.isContextual(105)||this.isContextual(97)){const s=this.isContextual(105);return this.expectPlugin(s?"sourcePhaseImports":"deferredImportEvaluation"),this.next(),t.phase=s?"source":"defer",this.parseImportCall(t)}else{const s=this.createIdentifierAt(this.startNodeAtNode(t),"import",this.state.lastTokStartLoc);return this.isContextual(101)&&(this.inModule||this.raise(p.ImportMetaOutsideModule,s),this.sawUnambiguousESM=!0),this.parseMetaProperty(t,s,"meta")}}parseLiteralAtNode(t,s,e){return this.addExtra(e,"rawValue",t),this.addExtra(e,"raw",this.input.slice(this.offsetToSourcePos(e.start),this.state.end)),e.value=t,this.next(),this.finishNode(e,s)}parseLiteral(t,s){const e=this.startNode();return this.parseLiteralAtNode(t,s,e)}parseStringLiteral(t){return this.parseLiteral(t,"StringLiteral")}parseNumericLiteral(t){return this.parseLiteral(t,"NumericLiteral")}parseBigIntLiteral(t){return this.parseLiteral(t,"BigIntLiteral")}parseDecimalLiteral(t){return this.parseLiteral(t,"DecimalLiteral")}parseRegExpLiteral(t){const s=this.startNode();return this.addExtra(s,"raw",this.input.slice(this.offsetToSourcePos(s.start),this.state.end)),s.pattern=t.pattern,s.flags=t.flags,this.next(),this.finishNode(s,"RegExpLiteral")}parseBooleanLiteral(t){const s=this.startNode();return s.value=t,this.next(),this.finishNode(s,"BooleanLiteral")}parseNullLiteral(){const t=this.startNode();return this.next(),this.finishNode(t,"NullLiteral")}parseParenAndDistinguishExpression(t){const s=this.state.startLoc;let e;this.next(),this.expressionScope.enter(Pn());const i=this.state.maybeInArrowParameters,a=this.state.inFSharpPipelineDirectBody;this.state.maybeInArrowParameters=!0,this.state.inFSharpPipelineDirectBody=!1;const n=this.state.startLoc,o=[],c=new Lt;let h=!0,l,u;for(;!this.match(11);){if(h)h=!1;else if(this.expect(12,c.optionalParametersLoc===null?null:c.optionalParametersLoc),this.match(11)){u=this.state.startLoc;break}if(this.match(21)){const P=this.state.startLoc;if(l=this.state.startLoc,o.push(this.parseParenItem(this.parseRestBinding(),P)),!this.checkCommaAfterRest(41))break}else o.push(this.parseMaybeAssignAllowIn(c,this.parseParenItem))}const f=this.state.lastTokEndLoc;this.expect(11),this.state.maybeInArrowParameters=i,this.state.inFSharpPipelineDirectBody=a;let d=this.startNodeAt(s);return t&&this.shouldParseArrow(o)&&(d=this.parseArrow(d))?(this.checkDestructuringPrivate(c),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(d,o,!1),d):(this.expressionScope.exit(),o.length||this.unexpected(this.state.lastTokStartLoc),u&&this.unexpected(u),l&&this.unexpected(l),this.checkExpressionErrors(c,!0),this.toReferencedListDeep(o,!0),o.length>1?(e=this.startNodeAt(n),e.expressions=o,this.finishNode(e,"SequenceExpression"),this.resetEndLocation(e,f)):e=o[0],this.wrapParenthesis(s,e))}wrapParenthesis(t,s){if(!(this.optionFlags&1024))return this.addExtra(s,"parenthesized",!0),this.addExtra(s,"parenStart",t.index),this.takeSurroundingComments(s,t.index,this.state.lastTokEndLoc.index),s;const e=this.startNodeAt(t);return e.expression=s,this.finishNode(e,"ParenthesizedExpression")}shouldParseArrow(t){return!this.canInsertSemicolon()}parseArrow(t){if(this.eat(19))return t}parseParenItem(t,s){return t}parseNewOrNewTarget(){const t=this.startNode();if(this.next(),this.match(16)){const s=this.createIdentifier(this.startNodeAtNode(t),"new");this.next();const e=this.parseMetaProperty(t,s,"target");return!this.scope.inNonArrowFunction&&!this.scope.inClass&&!(this.optionFlags&4)&&this.raise(p.UnexpectedNewTarget,e),e}return this.parseNew(t)}parseNew(t){if(this.parseNewCallee(t),this.eat(10)){const s=this.parseExprList(11);this.toReferencedList(s),t.arguments=s}else t.arguments=[];return this.finishNode(t,"NewExpression")}parseNewCallee(t){const s=this.match(83),e=this.parseNoCallExpr();t.callee=e,s&&(e.type==="Import"||e.type==="ImportExpression")&&this.raise(p.ImportCallNotNewExpression,e)}parseTemplateElement(t){const{start:s,startLoc:e,end:i,value:a}=this.state,n=s+1,o=this.startNodeAt(oe(e,1));a===null&&(t||this.raise(p.InvalidEscapeSequenceTemplate,oe(this.state.firstInvalidTemplateEscapePos,1)));const c=this.match(24),h=c?-1:-2,l=i+h;o.value={raw:this.input.slice(n,l).replace(/\r\n?/g,`
8
+ `),cooked:a===null?null:a.slice(1,h)},o.tail=c,this.next();const u=this.finishNode(o,"TemplateElement");return this.resetEndLocation(u,oe(this.state.lastTokEndLoc,h)),u}parseTemplate(t){const s=this.startNode();let e=this.parseTemplateElement(t);const i=[e],a=[];for(;!e.tail;)a.push(this.parseTemplateSubstitution()),this.readTemplateContinuation(),i.push(e=this.parseTemplateElement(t));return s.expressions=a,s.quasis=i,this.finishNode(s,"TemplateLiteral")}parseTemplateSubstitution(){return this.parseExpression()}parseObjectLike(t,s,e,i){e&&this.expectPlugin("recordAndTuple");const a=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!1;let n=!1,o=!0;const c=this.startNode();for(c.properties=[],this.next();!this.match(t);){if(o)o=!1;else if(this.expect(12),this.match(t)){this.addTrailingCommaExtraToNode(c);break}let l;s?l=this.parseBindingProperty():(l=this.parsePropertyDefinition(i),n=this.checkProto(l,e,n,i)),e&&!this.isObjectProperty(l)&&l.type!=="SpreadElement"&&this.raise(p.InvalidRecordProperty,l),c.properties.push(l)}this.next(),this.state.inFSharpPipelineDirectBody=a;let h="ObjectExpression";return s?h="ObjectPattern":e&&(h="RecordExpression"),this.finishNode(c,h)}addTrailingCommaExtraToNode(t){this.addExtra(t,"trailingComma",this.state.lastTokStartLoc.index),this.addExtra(t,"trailingCommaLoc",this.state.lastTokStartLoc,!1)}maybeAsyncOrAccessorProp(t){return!t.computed&&t.key.type==="Identifier"&&(this.isLiteralPropertyName()||this.match(0)||this.match(55))}parsePropertyDefinition(t){let s=[];if(this.match(26))for(this.hasPlugin("decorators")&&this.raise(p.UnsupportedPropertyDecorator,this.state.startLoc);this.match(26);)s.push(this.parseDecorator());const e=this.startNode();let i=!1,a=!1,n;if(this.match(21))return s.length&&this.unexpected(),this.parseSpread();s.length&&(e.decorators=s,s=[]),e.method=!1,t&&(n=this.state.startLoc);let o=this.eat(55);this.parsePropertyNamePrefixOperator(e);const c=this.state.containsEsc;if(this.parsePropertyName(e,t),!o&&!c&&this.maybeAsyncOrAccessorProp(e)){const{key:h}=e,l=h.name;l==="async"&&!this.hasPrecedingLineBreak()&&(i=!0,this.resetPreviousNodeTrailingComments(h),o=this.eat(55),this.parsePropertyName(e)),(l==="get"||l==="set")&&(a=!0,this.resetPreviousNodeTrailingComments(h),e.kind=l,this.match(55)&&(o=!0,this.raise(p.AccessorIsGenerator,this.state.curPosition(),{kind:l}),this.next()),this.parsePropertyName(e))}return this.parseObjPropValue(e,n,o,i,!1,a,t)}getGetterSetterExpectedParamCount(t){return t.kind==="get"?0:1}getObjectOrClassMethodParams(t){return t.params}checkGetterSetterParams(t){var i;const s=this.getGetterSetterExpectedParamCount(t),e=this.getObjectOrClassMethodParams(t);e.length!==s&&this.raise(t.kind==="get"?p.BadGetterArity:p.BadSetterArity,t),t.kind==="set"&&((i=e[e.length-1])==null?void 0:i.type)==="RestElement"&&this.raise(p.BadSetterRestParameter,t)}parseObjectMethod(t,s,e,i,a){if(a){const n=this.parseMethod(t,s,!1,!1,!1,"ObjectMethod");return this.checkGetterSetterParams(n),n}if(e||s||this.match(10))return i&&this.unexpected(),t.kind="method",t.method=!0,this.parseMethod(t,s,e,!1,!1,"ObjectMethod")}parseObjectProperty(t,s,e,i){if(t.shorthand=!1,this.eat(14))return t.value=e?this.parseMaybeDefault(this.state.startLoc):this.parseMaybeAssignAllowIn(i),this.finishObjectProperty(t);if(!t.computed&&t.key.type==="Identifier"){if(this.checkReservedWord(t.key.name,t.key.loc.start,!0,!1),e)t.value=this.parseMaybeDefault(s,this.cloneIdentifier(t.key));else if(this.match(29)){const a=this.state.startLoc;i!=null?i.shorthandAssignLoc===null&&(i.shorthandAssignLoc=a):this.raise(p.InvalidCoverInitializedName,a),t.value=this.parseMaybeDefault(s,this.cloneIdentifier(t.key))}else t.value=this.cloneIdentifier(t.key);return t.shorthand=!0,this.finishObjectProperty(t)}}finishObjectProperty(t){return this.finishNode(t,"ObjectProperty")}parseObjPropValue(t,s,e,i,a,n,o){const c=this.parseObjectMethod(t,e,i,a,n)||this.parseObjectProperty(t,s,a,o);return c||this.unexpected(),c}parsePropertyName(t,s){if(this.eat(0))t.computed=!0,t.key=this.parseMaybeAssignAllowIn(),this.expect(3);else{const{type:e,value:i}=this.state;let a;if(ue(e))a=this.parseIdentifier(!0);else switch(e){case 135:a=this.parseNumericLiteral(i);break;case 134:a=this.parseStringLiteral(i);break;case 136:a=this.parseBigIntLiteral(i);break;case 139:{const n=this.state.startLoc;s!=null?s.privateKeyLoc===null&&(s.privateKeyLoc=n):this.raise(p.UnexpectedPrivateField,n),a=this.parsePrivateName();break}default:this.unexpected()}t.key=a,e!==139&&(t.computed=!1)}}initFunction(t,s){t.id=null,t.generator=!1,t.async=s}parseMethod(t,s,e,i,a,n,o=!1){this.initFunction(t,e),t.generator=s,this.scope.enter(18|(o?64:0)|(a?32:0)),this.prodParam.enter(vt(e,t.generator)),this.parseFunctionParams(t,i);const c=this.parseFunctionBodyAndFinish(t,n,!0);return this.prodParam.exit(),this.scope.exit(),c}parseArrayLike(t,s,e,i){e&&this.expectPlugin("recordAndTuple");const a=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!1;const n=this.startNode();return this.next(),n.elements=this.parseExprList(t,!e,i,n),this.state.inFSharpPipelineDirectBody=a,this.finishNode(n,e?"TupleExpression":"ArrayExpression")}parseArrowExpression(t,s,e,i){this.scope.enter(6);let a=vt(e,!1);!this.match(5)&&this.prodParam.hasIn&&(a|=8),this.prodParam.enter(a),this.initFunction(t,e);const n=this.state.maybeInArrowParameters;return s&&(this.state.maybeInArrowParameters=!0,this.setArrowFunctionParameters(t,s,i)),this.state.maybeInArrowParameters=!1,this.parseFunctionBody(t,!0),this.prodParam.exit(),this.scope.exit(),this.state.maybeInArrowParameters=n,this.finishNode(t,"ArrowFunctionExpression")}setArrowFunctionParameters(t,s,e){this.toAssignableList(s,e,!1),t.params=s}parseFunctionBodyAndFinish(t,s,e=!1){return this.parseFunctionBody(t,!1,e),this.finishNode(t,s)}parseFunctionBody(t,s,e=!1){const i=s&&!this.match(5);if(this.expressionScope.enter(xi()),i)t.body=this.parseMaybeAssign(),this.checkParams(t,!1,s,!1);else{const a=this.state.strict,n=this.state.labels;this.state.labels=[],this.prodParam.enter(this.prodParam.currentFlags()|4),t.body=this.parseBlock(!0,!1,o=>{const c=!this.isSimpleParamList(t.params);o&&c&&this.raise(p.IllegalLanguageModeDirective,(t.kind==="method"||t.kind==="constructor")&&t.key?t.key.loc.end:t);const h=!a&&this.state.strict;this.checkParams(t,!this.state.strict&&!s&&!e&&!c,s,h),this.state.strict&&t.id&&this.checkIdentifier(t.id,65,h)}),this.prodParam.exit(),this.state.labels=n}this.expressionScope.exit()}isSimpleParameter(t){return t.type==="Identifier"}isSimpleParamList(t){for(let s=0,e=t.length;s<e;s++)if(!this.isSimpleParameter(t[s]))return!1;return!0}checkParams(t,s,e,i=!0){const a=!s&&new Set,n={type:"FormalParameters"};for(const o of t.params)this.checkLVal(o,n,5,a,i)}parseExprList(t,s,e,i){const a=[];let n=!0;for(;!this.eat(t);){if(n)n=!1;else if(this.expect(12),this.match(t)){i&&this.addTrailingCommaExtraToNode(i),this.next();break}a.push(this.parseExprListItem(s,e))}return a}parseExprListItem(t,s,e){let i;if(this.match(12))t||this.raise(p.UnexpectedToken,this.state.curPosition(),{unexpected:","}),i=null;else if(this.match(21)){const a=this.state.startLoc;i=this.parseParenItem(this.parseSpread(s),a)}else if(this.match(17)){this.expectPlugin("partialApplication"),e||this.raise(p.UnexpectedArgumentPlaceholder,this.state.startLoc);const a=this.startNode();this.next(),i=this.finishNode(a,"ArgumentPlaceholder")}else i=this.parseMaybeAssignAllowIn(s,this.parseParenItem);return i}parseIdentifier(t){const s=this.startNode(),e=this.parseIdentifierName(t);return this.createIdentifier(s,e)}createIdentifier(t,s){return t.name=s,t.loc.identifierName=s,this.finishNode(t,"Identifier")}createIdentifierAt(t,s,e){return t.name=s,t.loc.identifierName=s,this.finishNodeAt(t,"Identifier",e)}parseIdentifierName(t){let s;const{startLoc:e,type:i}=this.state;ue(i)?s=this.state.value:this.unexpected();const a=Aa(i);return t?a&&this.replaceToken(132):this.checkReservedWord(s,e,a,!1),this.next(),s}checkReservedWord(t,s,e,i){if(t.length>10||!qa(t))return;if(e&&ja(t)){this.raise(p.UnexpectedKeyword,s,{keyword:t});return}if((this.state.strict?i?ci:ni:ai)(t,this.inModule)){this.raise(p.UnexpectedReservedWord,s,{reservedWord:t});return}else if(t==="yield"){if(this.prodParam.hasYield){this.raise(p.YieldBindingIdentifier,s);return}}else if(t==="await"){if(this.prodParam.hasAwait){this.raise(p.AwaitBindingIdentifier,s);return}if(this.scope.inStaticBlock){this.raise(p.AwaitBindingIdentifierInStaticBlock,s);return}this.expressionScope.recordAsyncArrowParametersError(s)}else if(t==="arguments"&&this.scope.inClassAndNotInNonArrowFunction){this.raise(p.ArgumentsInClass,s);return}}recordAwaitIfAllowed(){const t=this.prodParam.hasAwait||this.optionFlags&1&&!this.scope.inFunction;return t&&!this.scope.inFunction&&(this.state.hasTopLevelAwait=!0),t}parseAwait(t){const s=this.startNodeAt(t);return this.expressionScope.recordParameterInitializerError(p.AwaitExpressionFormalParameter,s),this.eat(55)&&this.raise(p.ObsoleteAwaitStar,s),!this.scope.inFunction&&!(this.optionFlags&1)&&(this.isAmbiguousPrefixOrIdentifier()?this.ambiguousScriptDifferentAst=!0:this.sawUnambiguousESM=!0),this.state.soloAwait||(s.argument=this.parseMaybeUnary(null,!0)),this.finishNode(s,"AwaitExpression")}isAmbiguousPrefixOrIdentifier(){if(this.hasPrecedingLineBreak())return!0;const{type:t}=this.state;return t===53||t===10||t===0||ps(t)||t===102&&!this.state.containsEsc||t===138||t===56||this.hasPlugin("v8intrinsic")&&t===54}parseYield(t){const s=this.startNodeAt(t);this.expressionScope.recordParameterInitializerError(p.YieldInParameter,s);let e=!1,i=null;if(!this.hasPrecedingLineBreak())switch(e=this.eat(55),this.state.type){case 13:case 140:case 8:case 11:case 3:case 9:case 14:case 12:if(!e)break;default:i=this.parseMaybeAssign()}return s.delegate=e,s.argument=i,this.finishNode(s,"YieldExpression")}parseImportCall(t){if(this.next(),t.source=this.parseMaybeAssignAllowIn(),t.options=null,this.eat(12)){if(this.match(11))this.addTrailingCommaExtraToNode(t.source);else if(t.options=this.parseMaybeAssignAllowIn(),this.eat(12)&&(this.addTrailingCommaExtraToNode(t.options),!this.match(11))){do this.parseMaybeAssignAllowIn();while(this.eat(12)&&!this.match(11));this.raise(p.ImportCallArity,t)}}return this.expect(11),this.finishNode(t,"ImportExpression")}checkPipelineAtInfixOperator(t,s){this.hasPlugin(["pipelineOperator",{proposal:"smart"}])&&t.type==="SequenceExpression"&&this.raise(p.PipelineHeadSequenceExpression,s)}parseSmartPipelineBodyInStyle(t,s){if(this.isSimpleReference(t)){const e=this.startNodeAt(s);return e.callee=t,this.finishNode(e,"PipelineBareFunction")}else{const e=this.startNodeAt(s);return this.checkSmartPipeTopicBodyEarlyErrors(s),e.expression=t,this.finishNode(e,"PipelineTopicExpression")}}isSimpleReference(t){switch(t.type){case"MemberExpression":return!t.computed&&this.isSimpleReference(t.object);case"Identifier":return!0;default:return!1}}checkSmartPipeTopicBodyEarlyErrors(t){if(this.match(19))throw this.raise(p.PipelineBodyNoArrow,this.state.startLoc);this.topicReferenceWasUsedInCurrentContext()||this.raise(p.PipelineTopicUnused,t)}withTopicBindingContext(t){const s=this.state.topicContext;this.state.topicContext={maxNumOfResolvableTopics:1,maxTopicIndex:null};try{return t()}finally{this.state.topicContext=s}}withSmartMixTopicForbiddingContext(t){return t()}withSoloAwaitPermittingContext(t){const s=this.state.soloAwait;this.state.soloAwait=!0;try{return t()}finally{this.state.soloAwait=s}}allowInAnd(t){const s=this.prodParam.currentFlags();if(8&~s){this.prodParam.enter(s|8);try{return t()}finally{this.prodParam.exit()}}return t()}disallowInAnd(t){const s=this.prodParam.currentFlags();if(8&s){this.prodParam.enter(s&-9);try{return t()}finally{this.prodParam.exit()}}return t()}registerTopicReference(){this.state.topicContext.maxTopicIndex=0}topicReferenceIsAllowedInCurrentContext(){return this.state.topicContext.maxNumOfResolvableTopics>=1}topicReferenceWasUsedInCurrentContext(){return this.state.topicContext.maxTopicIndex!=null&&this.state.topicContext.maxTopicIndex>=0}parseFSharpPipelineBody(t){const s=this.state.startLoc;this.state.potentialArrowAt=this.state.start;const e=this.state.inFSharpPipelineDirectBody;this.state.inFSharpPipelineDirectBody=!0;const i=this.parseExprOp(this.parseMaybeUnaryOrPrivate(),s,t);return this.state.inFSharpPipelineDirectBody=e,i}parseModuleExpression(){this.expectPlugin("moduleBlocks");const t=this.startNode();this.next(),this.match(5)||this.unexpected(null,5);const s=this.startNodeAt(this.state.endLoc);this.next();const e=this.initializeScopes(!0);this.enterInitialScopes();try{t.body=this.parseProgram(s,8,"module")}finally{e()}return this.finishNode(t,"ModuleExpression")}parsePropertyNamePrefixOperator(t){}}const Ss={kind:1},Fn={kind:2},Bn=/[\uD800-\uDFFF]/u,Is=/in(?:stanceof)?/y;function Rn(r,t,s){for(let e=0;e<r.length;e++){const i=r[e],{type:a}=i;typeof a=="number"&&(i.type=si(a))}return r}class _n extends Mn{parseTopLevel(t,s){return t.program=this.parseProgram(s),t.comments=this.comments,this.optionFlags&256&&(t.tokens=Rn(this.tokens,this.input,this.startIndex)),this.finishNode(t,"File")}parseProgram(t,s=140,e=this.options.sourceType){if(t.sourceType=e,t.interpreter=this.parseInterpreterDirective(),this.parseBlockBody(t,!0,!0,s),this.inModule){if(!(this.optionFlags&64)&&this.scope.undefinedExports.size>0)for(const[a,n]of Array.from(this.scope.undefinedExports))this.raise(p.ModuleExportUndefined,n,{localName:a});this.addExtra(t,"topLevelAwait",this.state.hasTopLevelAwait)}let i;return s===140?i=this.finishNode(t,"Program"):i=this.finishNodeAt(t,"Program",oe(this.state.startLoc,-1)),i}stmtToDirective(t){const s=this.castNodeTo(t,"Directive"),e=this.castNodeTo(t.expression,"DirectiveLiteral"),i=e.value,a=this.input.slice(this.offsetToSourcePos(e.start),this.offsetToSourcePos(e.end)),n=e.value=a.slice(1,-1);return this.addExtra(e,"raw",a),this.addExtra(e,"rawValue",n),this.addExtra(e,"expressionValue",i),s.value=e,delete t.expression,s}parseInterpreterDirective(){if(!this.match(28))return null;const t=this.startNode();return t.value=this.state.value,this.next(),this.finishNode(t,"InterpreterDirective")}isLet(){return this.isContextual(100)?this.hasFollowingBindingAtom():!1}chStartsBindingIdentifier(t,s){if(ge(t)){if(Is.lastIndex=s,Is.test(this.input)){const e=this.codePointAtPos(Is.lastIndex);if(!$e(e)&&e!==92)return!1}return!0}else return t===92}chStartsBindingPattern(t){return t===91||t===123}hasFollowingBindingAtom(){const t=this.nextTokenStart(),s=this.codePointAtPos(t);return this.chStartsBindingPattern(s)||this.chStartsBindingIdentifier(s,t)}hasInLineFollowingBindingIdentifierOrBrace(){const t=this.nextTokenInLineStart(),s=this.codePointAtPos(t);return s===123||this.chStartsBindingIdentifier(s,t)}allowsForUsing(){const{type:t,containsEsc:s,end:e}=this.lookahead();if(t===102&&!s){const i=this.lookaheadCharCodeSince(e);if(i!==61&&i!==58&&i!==59)return!1}return D(t)&&!this.hasFollowingLineBreak()?(this.expectPlugin("explicitResourceManagement"),!0):!1}allowsUsing(){return(this.scope.inModule||!this.scope.inTopLevel)&&!this.scope.inBareCaseStatement}startsAwaitUsing(){let t=this.nextTokenInLineStart();if(this.isUnparsedContextual(t,"using")){t=this.nextTokenInLineStartSince(t+5);const s=this.codePointAtPos(t);if(this.chStartsBindingIdentifier(s,t))return this.expectPlugin("explicitResourceManagement"),!0}return!1}parseModuleItem(){return this.parseStatementLike(15)}parseStatementListItem(){return this.parseStatementLike(6|(!this.options.annexB||this.state.strict?0:8))}parseStatementOrSloppyAnnexBFunctionDeclaration(t=!1){let s=0;return this.options.annexB&&!this.state.strict&&(s|=4,t&&(s|=8)),this.parseStatementLike(s)}parseStatement(){return this.parseStatementLike(0)}parseStatementLike(t){let s=null;return this.match(26)&&(s=this.parseDecorators(!0)),this.parseStatementContent(t,s)}parseStatementContent(t,s){const e=this.state.type,i=this.startNode(),a=!!(t&2),n=!!(t&4),o=t&1;switch(e){case 60:return this.parseBreakContinueStatement(i,!0);case 63:return this.parseBreakContinueStatement(i,!1);case 64:return this.parseDebuggerStatement(i);case 90:return this.parseDoWhileStatement(i);case 91:return this.parseForStatement(i);case 68:if(this.lookaheadCharCode()===46)break;return n||this.raise(this.state.strict?p.StrictFunction:this.options.annexB?p.SloppyFunctionAnnexB:p.SloppyFunction,this.state.startLoc),this.parseFunctionStatement(i,!1,!a&&n);case 80:return a||this.unexpected(),this.parseClass(this.maybeTakeDecorators(s,i),!0);case 69:return this.parseIfStatement(i);case 70:return this.parseReturnStatement(i);case 71:return this.parseSwitchStatement(i);case 72:return this.parseThrowStatement(i);case 73:return this.parseTryStatement(i);case 96:if(!this.state.containsEsc&&this.startsAwaitUsing())return this.allowsUsing()?a?this.recordAwaitIfAllowed()||this.raise(p.AwaitUsingNotInAsyncContext,i):this.raise(p.UnexpectedLexicalDeclaration,i):this.raise(p.UnexpectedUsingDeclaration,i),this.next(),this.parseVarStatement(i,"await using");break;case 107:if(this.state.containsEsc||!this.hasInLineFollowingBindingIdentifierOrBrace())break;return this.expectPlugin("explicitResourceManagement"),this.allowsUsing()?a||this.raise(p.UnexpectedLexicalDeclaration,this.state.startLoc):this.raise(p.UnexpectedUsingDeclaration,this.state.startLoc),this.parseVarStatement(i,"using");case 100:{if(this.state.containsEsc)break;const l=this.nextTokenStart(),u=this.codePointAtPos(l);if(u!==91&&(!a&&this.hasFollowingLineBreak()||!this.chStartsBindingIdentifier(u,l)&&u!==123))break}case 75:a||this.raise(p.UnexpectedLexicalDeclaration,this.state.startLoc);case 74:{const l=this.state.value;return this.parseVarStatement(i,l)}case 92:return this.parseWhileStatement(i);case 76:return this.parseWithStatement(i);case 5:return this.parseBlock();case 13:return this.parseEmptyStatement(i);case 83:{const l=this.lookaheadCharCode();if(l===40||l===46)break}case 82:{!(this.optionFlags&8)&&!o&&this.raise(p.UnexpectedImportExport,this.state.startLoc),this.next();let l;return e===83?l=this.parseImport(i):l=this.parseExport(i,s),this.assertModuleNodeAllowed(l),l}default:if(this.isAsyncFunction())return a||this.raise(p.AsyncFunctionInSingleStatementContext,this.state.startLoc),this.next(),this.parseFunctionStatement(i,!0,!a&&n)}const c=this.state.value,h=this.parseExpression();return D(e)&&h.type==="Identifier"&&this.eat(14)?this.parseLabeledStatement(i,c,h,t):this.parseExpressionStatement(i,h,s)}assertModuleNodeAllowed(t){!(this.optionFlags&8)&&!this.inModule&&this.raise(p.ImportOutsideModule,t)}decoratorsEnabledBeforeExport(){return this.hasPlugin("decorators-legacy")?!0:this.hasPlugin("decorators")&&this.getPluginOption("decorators","decoratorsBeforeExport")!==!1}maybeTakeDecorators(t,s,e){var i;return t&&((i=s.decorators)!=null&&i.length?(typeof this.getPluginOption("decorators","decoratorsBeforeExport")!="boolean"&&this.raise(p.DecoratorsBeforeAfterExport,s.decorators[0]),s.decorators.unshift(...t)):s.decorators=t,this.resetStartLocationFromNode(s,t[0]),e&&this.resetStartLocationFromNode(e,s)),s}canHaveLeadingDecorator(){return this.match(80)}parseDecorators(t){const s=[];do s.push(this.parseDecorator());while(this.match(26));if(this.match(82))t||this.unexpected(),this.decoratorsEnabledBeforeExport()||this.raise(p.DecoratorExportClass,this.state.startLoc);else if(!this.canHaveLeadingDecorator())throw this.raise(p.UnexpectedLeadingDecorator,this.state.startLoc);return s}parseDecorator(){this.expectOnePlugin(["decorators","decorators-legacy"]);const t=this.startNode();if(this.next(),this.hasPlugin("decorators")){const s=this.state.startLoc;let e;if(this.match(10)){const i=this.state.startLoc;this.next(),e=this.parseExpression(),this.expect(11),e=this.wrapParenthesis(i,e);const a=this.state.startLoc;t.expression=this.parseMaybeDecoratorArguments(e,i),this.getPluginOption("decorators","allowCallParenthesized")===!1&&t.expression!==e&&this.raise(p.DecoratorArgumentsOutsideParentheses,a)}else{for(e=this.parseIdentifier(!1);this.eat(16);){const i=this.startNodeAt(s);i.object=e,this.match(139)?(this.classScope.usePrivateName(this.state.value,this.state.startLoc),i.property=this.parsePrivateName()):i.property=this.parseIdentifier(!0),i.computed=!1,e=this.finishNode(i,"MemberExpression")}t.expression=this.parseMaybeDecoratorArguments(e,s)}}else t.expression=this.parseExprSubscripts();return this.finishNode(t,"Decorator")}parseMaybeDecoratorArguments(t,s){if(this.eat(10)){const e=this.startNodeAt(s);return e.callee=t,e.arguments=this.parseCallExpressionArguments(11),this.toReferencedList(e.arguments),this.finishNode(e,"CallExpression")}return t}parseBreakContinueStatement(t,s){return this.next(),this.isLineTerminator()?t.label=null:(t.label=this.parseIdentifier(),this.semicolon()),this.verifyBreakContinue(t,s),this.finishNode(t,s?"BreakStatement":"ContinueStatement")}verifyBreakContinue(t,s){let e;for(e=0;e<this.state.labels.length;++e){const i=this.state.labels[e];if((t.label==null||i.name===t.label.name)&&(i.kind!=null&&(s||i.kind===1)||t.label&&s))break}if(e===this.state.labels.length){const i=s?"BreakStatement":"ContinueStatement";this.raise(p.IllegalBreakContinue,t,{type:i})}}parseDebuggerStatement(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")}parseHeaderExpression(){this.expect(10);const t=this.parseExpression();return this.expect(11),t}parseDoWhileStatement(t){return this.next(),this.state.labels.push(Ss),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.state.labels.pop(),this.expect(92),t.test=this.parseHeaderExpression(),this.eat(13),this.finishNode(t,"DoWhileStatement")}parseForStatement(t){this.next(),this.state.labels.push(Ss);let s=null;if(this.isContextual(96)&&this.recordAwaitIfAllowed()&&(s=this.state.startLoc,this.next()),this.scope.enter(0),this.expect(10),this.match(13))return s!==null&&this.unexpected(s),this.parseFor(t,null);const e=this.isContextual(100);{const c=this.isContextual(96)&&this.startsAwaitUsing(),h=c||this.isContextual(107)&&this.allowsForUsing(),l=e&&this.hasFollowingBindingAtom()||h;if(this.match(74)||this.match(75)||l){const u=this.startNode();let f;c?(f="await using",this.recordAwaitIfAllowed()||this.raise(p.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):f=this.state.value,this.next(),this.parseVar(u,!0,f);const d=this.finishNode(u,"VariableDeclaration"),P=this.match(58);return P&&h&&this.raise(p.ForInUsing,d),(P||this.isContextual(102))&&d.declarations.length===1?this.parseForIn(t,d,s):(s!==null&&this.unexpected(s),this.parseFor(t,d))}}const i=this.isContextual(95),a=new Lt,n=this.parseExpression(!0,a),o=this.isContextual(102);if(o&&(e&&this.raise(p.ForOfLet,n),s===null&&i&&n.type==="Identifier"&&this.raise(p.ForOfAsync,n)),o||this.match(58)){this.checkDestructuringPrivate(a),this.toAssignable(n,!0);const c=o?"ForOfStatement":"ForInStatement";return this.checkLVal(n,{type:c}),this.parseForIn(t,n,s)}else this.checkExpressionErrors(a,!0);return s!==null&&this.unexpected(s),this.parseFor(t,n)}parseFunctionStatement(t,s,e){return this.next(),this.parseFunction(t,1|(e?2:0)|(s?8:0))}parseIfStatement(t){return this.next(),t.test=this.parseHeaderExpression(),t.consequent=this.parseStatementOrSloppyAnnexBFunctionDeclaration(),t.alternate=this.eat(66)?this.parseStatementOrSloppyAnnexBFunctionDeclaration():null,this.finishNode(t,"IfStatement")}parseReturnStatement(t){return!this.prodParam.hasReturn&&!(this.optionFlags&2)&&this.raise(p.IllegalReturn,this.state.startLoc),this.next(),this.isLineTerminator()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")}parseSwitchStatement(t){this.next(),t.discriminant=this.parseHeaderExpression();const s=t.cases=[];this.expect(5),this.state.labels.push(Fn),this.scope.enter(256);let e;for(let i;!this.match(8);)if(this.match(61)||this.match(65)){const a=this.match(61);e&&this.finishNode(e,"SwitchCase"),s.push(e=this.startNode()),e.consequent=[],this.next(),a?e.test=this.parseExpression():(i&&this.raise(p.MultipleDefaultsInSwitch,this.state.lastTokStartLoc),i=!0,e.test=null),this.expect(14)}else e?e.consequent.push(this.parseStatementListItem()):this.unexpected();return this.scope.exit(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.state.labels.pop(),this.finishNode(t,"SwitchStatement")}parseThrowStatement(t){return this.next(),this.hasPrecedingLineBreak()&&this.raise(p.NewlineAfterThrow,this.state.lastTokEndLoc),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")}parseCatchClauseParam(){const t=this.parseBindingAtom();return this.scope.enter(this.options.annexB&&t.type==="Identifier"?8:0),this.checkLVal(t,{type:"CatchClause"},9),t}parseTryStatement(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.match(62)){const s=this.startNode();this.next(),this.match(10)?(this.expect(10),s.param=this.parseCatchClauseParam(),this.expect(11)):(s.param=null,this.scope.enter(0)),s.body=this.withSmartMixTopicForbiddingContext(()=>this.parseBlock(!1,!1)),this.scope.exit(),t.handler=this.finishNode(s,"CatchClause")}return t.finalizer=this.eat(67)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(p.NoCatchOrFinally,t),this.finishNode(t,"TryStatement")}parseVarStatement(t,s,e=!1){return this.next(),this.parseVar(t,!1,s,e),this.semicolon(),this.finishNode(t,"VariableDeclaration")}parseWhileStatement(t){return this.next(),t.test=this.parseHeaderExpression(),this.state.labels.push(Ss),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.state.labels.pop(),this.finishNode(t,"WhileStatement")}parseWithStatement(t){return this.state.strict&&this.raise(p.StrictWith,this.state.startLoc),this.next(),t.object=this.parseHeaderExpression(),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.finishNode(t,"WithStatement")}parseEmptyStatement(t){return this.next(),this.finishNode(t,"EmptyStatement")}parseLabeledStatement(t,s,e,i){for(const n of this.state.labels)n.name===s&&this.raise(p.LabelRedeclaration,e,{labelName:s});const a=Ea(this.state.type)?1:this.match(71)?2:null;for(let n=this.state.labels.length-1;n>=0;n--){const o=this.state.labels[n];if(o.statementStart===t.start)o.statementStart=this.sourceToOffsetPos(this.state.start),o.kind=a;else break}return this.state.labels.push({name:s,kind:a,statementStart:this.sourceToOffsetPos(this.state.start)}),t.body=i&8?this.parseStatementOrSloppyAnnexBFunctionDeclaration(!0):this.parseStatement(),this.state.labels.pop(),t.label=e,this.finishNode(t,"LabeledStatement")}parseExpressionStatement(t,s,e){return t.expression=s,this.semicolon(),this.finishNode(t,"ExpressionStatement")}parseBlock(t=!1,s=!0,e){const i=this.startNode();return t&&this.state.strictErrors.clear(),this.expect(5),s&&this.scope.enter(0),this.parseBlockBody(i,t,!1,8,e),s&&this.scope.exit(),this.finishNode(i,"BlockStatement")}isValidDirective(t){return t.type==="ExpressionStatement"&&t.expression.type==="StringLiteral"&&!t.expression.extra.parenthesized}parseBlockBody(t,s,e,i,a){const n=t.body=[],o=t.directives=[];this.parseBlockOrModuleBlockBody(n,s?o:void 0,e,i,a)}parseBlockOrModuleBlockBody(t,s,e,i,a){const n=this.state.strict;let o=!1,c=!1;for(;!this.match(i);){const h=e?this.parseModuleItem():this.parseStatementListItem();if(s&&!c){if(this.isValidDirective(h)){const l=this.stmtToDirective(h);s.push(l),!o&&l.value.value==="use strict"&&(o=!0,this.setStrict(!0));continue}c=!0,this.state.strictErrors.clear()}t.push(h)}a==null||a.call(this,o),n||this.setStrict(!1),this.next()}parseFor(t,s){return t.init=s,this.semicolon(!1),t.test=this.match(13)?null:this.parseExpression(),this.semicolon(!1),t.update=this.match(11)?null:this.parseExpression(),this.expect(11),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.scope.exit(),this.state.labels.pop(),this.finishNode(t,"ForStatement")}parseForIn(t,s,e){const i=this.match(58);return this.next(),i?e!==null&&this.unexpected(e):t.await=e!==null,s.type==="VariableDeclaration"&&s.declarations[0].init!=null&&(!i||!this.options.annexB||this.state.strict||s.kind!=="var"||s.declarations[0].id.type!=="Identifier")&&this.raise(p.ForInOfLoopInitializer,s,{type:i?"ForInStatement":"ForOfStatement"}),s.type==="AssignmentPattern"&&this.raise(p.InvalidLhs,s,{ancestor:{type:"ForStatement"}}),t.left=s,t.right=i?this.parseExpression():this.parseMaybeAssignAllowIn(),this.expect(11),t.body=this.withSmartMixTopicForbiddingContext(()=>this.parseStatement()),this.scope.exit(),this.state.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")}parseVar(t,s,e,i=!1){const a=t.declarations=[];for(t.kind=e;;){const n=this.startNode();if(this.parseVarId(n,e),n.init=this.eat(29)?s?this.parseMaybeAssignDisallowIn():this.parseMaybeAssignAllowIn():null,n.init===null&&!i&&(n.id.type!=="Identifier"&&!(s&&(this.match(58)||this.isContextual(102)))?this.raise(p.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"destructuring"}):(e==="const"||e==="using"||e==="await using")&&!(this.match(58)||this.isContextual(102))&&this.raise(p.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:e})),a.push(this.finishNode(n,"VariableDeclarator")),!this.eat(12))break}return t}parseVarId(t,s){const e=this.parseBindingAtom();(s==="using"||s==="await using")&&(e.type==="ArrayPattern"||e.type==="ObjectPattern")&&this.raise(p.UsingDeclarationHasBindingPattern,e.loc.start),this.checkLVal(e,{type:"VariableDeclarator"},s==="var"?5:8201),t.id=e}parseAsyncFunctionExpression(t){return this.parseFunction(t,8)}parseFunction(t,s=0){const e=s&2,i=!!(s&1),a=i&&!(s&4),n=!!(s&8);this.initFunction(t,n),this.match(55)&&(e&&this.raise(p.GeneratorInSingleStatementContext,this.state.startLoc),this.next(),t.generator=!0),i&&(t.id=this.parseFunctionId(a));const o=this.state.maybeInArrowParameters;return this.state.maybeInArrowParameters=!1,this.scope.enter(2),this.prodParam.enter(vt(n,t.generator)),i||(t.id=this.parseFunctionId()),this.parseFunctionParams(t,!1),this.withSmartMixTopicForbiddingContext(()=>{this.parseFunctionBodyAndFinish(t,i?"FunctionDeclaration":"FunctionExpression")}),this.prodParam.exit(),this.scope.exit(),i&&!e&&this.registerFunctionStatementId(t),this.state.maybeInArrowParameters=o,t}parseFunctionId(t){return t||D(this.state.type)?this.parseIdentifier():null}parseFunctionParams(t,s){this.expect(10),this.expressionScope.enter(xn()),t.params=this.parseBindingList(11,41,2|(s?4:0)),this.expressionScope.exit()}registerFunctionStatementId(t){t.id&&this.scope.declareName(t.id.name,!this.options.annexB||this.state.strict||t.generator||t.async?this.scope.treatFunctionsAsVar?5:8201:17,t.id.loc.start)}parseClass(t,s,e){this.next();const i=this.state.strict;return this.state.strict=!0,this.parseClassId(t,s,e),this.parseClassSuper(t),t.body=this.parseClassBody(!!t.superClass,i),this.finishNode(t,s?"ClassDeclaration":"ClassExpression")}isClassProperty(){return this.match(29)||this.match(13)||this.match(8)}isClassMethod(){return this.match(10)}nameIsConstructor(t){return t.type==="Identifier"&&t.name==="constructor"||t.type==="StringLiteral"&&t.value==="constructor"}isNonstaticConstructor(t){return!t.computed&&!t.static&&this.nameIsConstructor(t.key)}parseClassBody(t,s){this.classScope.enter();const e={hadConstructor:!1,hadSuperClass:t};let i=[];const a=this.startNode();if(a.body=[],this.expect(5),this.withSmartMixTopicForbiddingContext(()=>{for(;!this.match(8);){if(this.eat(13)){if(i.length>0)throw this.raise(p.DecoratorSemicolon,this.state.lastTokEndLoc);continue}if(this.match(26)){i.push(this.parseDecorator());continue}const n=this.startNode();i.length&&(n.decorators=i,this.resetStartLocationFromNode(n,i[0]),i=[]),this.parseClassMember(a,n,e),n.kind==="constructor"&&n.decorators&&n.decorators.length>0&&this.raise(p.DecoratorConstructor,n)}}),this.state.strict=s,this.next(),i.length)throw this.raise(p.TrailingDecorator,this.state.startLoc);return this.classScope.exit(),this.finishNode(a,"ClassBody")}parseClassMemberFromModifier(t,s){const e=this.parseIdentifier(!0);if(this.isClassMethod()){const i=s;return i.kind="method",i.computed=!1,i.key=e,i.static=!1,this.pushClassMethod(t,i,!1,!1,!1,!1),!0}else if(this.isClassProperty()){const i=s;return i.computed=!1,i.key=e,i.static=!1,t.body.push(this.parseClassProperty(i)),!0}return this.resetPreviousNodeTrailingComments(e),!1}parseClassMember(t,s,e){const i=this.isContextual(106);if(i){if(this.parseClassMemberFromModifier(t,s))return;if(this.eat(5)){this.parseClassStaticBlock(t,s);return}}this.parseClassMemberWithIsStatic(t,s,e,i)}parseClassMemberWithIsStatic(t,s,e,i){const a=s,n=s,o=s,c=s,h=s,l=a,u=a;if(s.static=i,this.parsePropertyNamePrefixOperator(s),this.eat(55)){l.kind="method";const I=this.match(139);if(this.parseClassElementName(l),this.parsePostMemberNameModifiers(l),I){this.pushClassPrivateMethod(t,n,!0,!1);return}this.isNonstaticConstructor(a)&&this.raise(p.ConstructorIsGenerator,a.key),this.pushClassMethod(t,a,!0,!1,!1,!1);return}const f=!this.state.containsEsc&&D(this.state.type),d=this.parseClassElementName(s),P=f?d.name:null,S=this.isPrivateName(d),F=this.state.startLoc;if(this.parsePostMemberNameModifiers(u),this.isClassMethod()){if(l.kind="method",S){this.pushClassPrivateMethod(t,n,!1,!1);return}const I=this.isNonstaticConstructor(a);let O=!1;I&&(a.kind="constructor",e.hadConstructor&&!this.hasPlugin("typescript")&&this.raise(p.DuplicateConstructor,d),I&&this.hasPlugin("typescript")&&s.override&&this.raise(p.OverrideOnConstructor,d),e.hadConstructor=!0,O=e.hadSuperClass),this.pushClassMethod(t,a,!1,!1,I,O)}else if(this.isClassProperty())S?this.pushClassPrivateProperty(t,c):this.pushClassProperty(t,o);else if(P==="async"&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(d);const I=this.eat(55);u.optional&&this.unexpected(F),l.kind="method";const O=this.match(139);this.parseClassElementName(l),this.parsePostMemberNameModifiers(u),O?this.pushClassPrivateMethod(t,n,I,!0):(this.isNonstaticConstructor(a)&&this.raise(p.ConstructorIsAsync,a.key),this.pushClassMethod(t,a,I,!0,!1,!1))}else if((P==="get"||P==="set")&&!(this.match(55)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(d),l.kind=P;const I=this.match(139);this.parseClassElementName(a),I?this.pushClassPrivateMethod(t,n,!1,!1):(this.isNonstaticConstructor(a)&&this.raise(p.ConstructorIsAccessor,a.key),this.pushClassMethod(t,a,!1,!1,!1,!1)),this.checkGetterSetterParams(a)}else if(P==="accessor"&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(d);const I=this.match(139);this.parseClassElementName(o),this.pushClassAccessorProperty(t,h,I)}else this.isLineTerminator()?S?this.pushClassPrivateProperty(t,c):this.pushClassProperty(t,o):this.unexpected()}parseClassElementName(t){const{type:s,value:e}=this.state;if((s===132||s===134)&&t.static&&e==="prototype"&&this.raise(p.StaticPrototype,this.state.startLoc),s===139){e==="constructor"&&this.raise(p.ConstructorClassPrivateField,this.state.startLoc);const i=this.parsePrivateName();return t.key=i,i}return this.parsePropertyName(t),t.key}parseClassStaticBlock(t,s){var a;this.scope.enter(208);const e=this.state.labels;this.state.labels=[],this.prodParam.enter(0);const i=s.body=[];this.parseBlockOrModuleBlockBody(i,void 0,!1,8),this.prodParam.exit(),this.scope.exit(),this.state.labels=e,t.body.push(this.finishNode(s,"StaticBlock")),(a=s.decorators)!=null&&a.length&&this.raise(p.DecoratorStaticBlock,s)}pushClassProperty(t,s){!s.computed&&this.nameIsConstructor(s.key)&&this.raise(p.ConstructorClassField,s.key),t.body.push(this.parseClassProperty(s))}pushClassPrivateProperty(t,s){const e=this.parseClassPrivateProperty(s);t.body.push(e),this.classScope.declarePrivateName(this.getPrivateNameSV(e.key),0,e.key.loc.start)}pushClassAccessorProperty(t,s,e){!e&&!s.computed&&this.nameIsConstructor(s.key)&&this.raise(p.ConstructorClassField,s.key);const i=this.parseClassAccessorProperty(s);t.body.push(i),e&&this.classScope.declarePrivateName(this.getPrivateNameSV(i.key),0,i.key.loc.start)}pushClassMethod(t,s,e,i,a,n){t.body.push(this.parseMethod(s,e,i,a,n,"ClassMethod",!0))}pushClassPrivateMethod(t,s,e,i){const a=this.parseMethod(s,e,i,!1,!1,"ClassPrivateMethod",!0);t.body.push(a);const n=a.kind==="get"?a.static?6:2:a.kind==="set"?a.static?5:1:0;this.declareClassPrivateMethodInScope(a,n)}declareClassPrivateMethodInScope(t,s){this.classScope.declarePrivateName(this.getPrivateNameSV(t.key),s,t.key.loc.start)}parsePostMemberNameModifiers(t){}parseClassPrivateProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassPrivateProperty")}parseClassProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassProperty")}parseClassAccessorProperty(t){return this.parseInitializer(t),this.semicolon(),this.finishNode(t,"ClassAccessorProperty")}parseInitializer(t){this.scope.enter(80),this.expressionScope.enter(xi()),this.prodParam.enter(0),t.value=this.eat(29)?this.parseMaybeAssignAllowIn():null,this.expressionScope.exit(),this.prodParam.exit(),this.scope.exit()}parseClassId(t,s,e,i=8331){if(D(this.state.type))t.id=this.parseIdentifier(),s&&this.declareNameFromIdentifier(t.id,i);else if(e||!s)t.id=null;else throw this.raise(p.MissingClassName,this.state.startLoc)}parseClassSuper(t){t.superClass=this.eat(81)?this.parseExprSubscripts():null}parseExport(t,s){var f;const e=this.parseMaybeImportPhase(t,!0),i=this.maybeParseExportDefaultSpecifier(t,e),a=!i||this.eat(12),n=a&&this.eatExportStar(t),o=n&&this.maybeParseExportNamespaceSpecifier(t),c=a&&(!o||this.eat(12)),h=i||n;if(n&&!o){if(i&&this.unexpected(),s)throw this.raise(p.UnsupportedDecoratorExport,t);return this.parseExportFrom(t,!0),this.sawUnambiguousESM=!0,this.finishNode(t,"ExportAllDeclaration")}const l=this.maybeParseExportNamedSpecifiers(t);i&&a&&!n&&!l&&this.unexpected(null,5),o&&c&&this.unexpected(null,98);let u;if(h||l){if(u=!1,s)throw this.raise(p.UnsupportedDecoratorExport,t);this.parseExportFrom(t,h)}else u=this.maybeParseExportDeclaration(t);if(h||l||u){const d=t;if(this.checkExport(d,!0,!1,!!d.source),((f=d.declaration)==null?void 0:f.type)==="ClassDeclaration")this.maybeTakeDecorators(s,d.declaration,d);else if(s)throw this.raise(p.UnsupportedDecoratorExport,t);return this.sawUnambiguousESM=!0,this.finishNode(d,"ExportNamedDeclaration")}if(this.eat(65)){const d=t,P=this.parseExportDefaultExpression();if(d.declaration=P,P.type==="ClassDeclaration")this.maybeTakeDecorators(s,P,d);else if(s)throw this.raise(p.UnsupportedDecoratorExport,t);return this.checkExport(d,!0,!0),this.sawUnambiguousESM=!0,this.finishNode(d,"ExportDefaultDeclaration")}this.unexpected(null,5)}eatExportStar(t){return this.eat(55)}maybeParseExportDefaultSpecifier(t,s){if(s||this.isExportDefaultSpecifier()){this.expectPlugin("exportDefaultFrom",s==null?void 0:s.loc.start);const e=s||this.parseIdentifier(!0),i=this.startNodeAtNode(e);return i.exported=e,t.specifiers=[this.finishNode(i,"ExportDefaultSpecifier")],!0}return!1}maybeParseExportNamespaceSpecifier(t){if(this.isContextual(93)){t.specifiers??(t.specifiers=[]);const s=this.startNodeAt(this.state.lastTokStartLoc);return this.next(),s.exported=this.parseModuleExportName(),t.specifiers.push(this.finishNode(s,"ExportNamespaceSpecifier")),!0}return!1}maybeParseExportNamedSpecifiers(t){if(this.match(5)){const s=t;s.specifiers||(s.specifiers=[]);const e=s.exportKind==="type";return s.specifiers.push(...this.parseExportSpecifiers(e)),s.source=null,s.attributes=[],s.declaration=null,!0}return!1}maybeParseExportDeclaration(t){return this.shouldParseExportDeclaration()?(t.specifiers=[],t.source=null,t.attributes=[],t.declaration=this.parseExportDeclaration(t),!0):!1}isAsyncFunction(){if(!this.isContextual(95))return!1;const t=this.nextTokenInLineStart();return this.isUnparsedContextual(t,"function")}parseExportDefaultExpression(){const t=this.startNode();if(this.match(68))return this.next(),this.parseFunction(t,5);if(this.isAsyncFunction())return this.next(),this.next(),this.parseFunction(t,13);if(this.match(80))return this.parseClass(t,!0,!0);if(this.match(26))return this.hasPlugin("decorators")&&this.getPluginOption("decorators","decoratorsBeforeExport")===!0&&this.raise(p.DecoratorBeforeExport,this.state.startLoc),this.parseClass(this.maybeTakeDecorators(this.parseDecorators(!1),this.startNode()),!0,!0);if(this.match(75)||this.match(74)||this.isLet())throw this.raise(p.UnsupportedDefaultExport,this.state.startLoc);const s=this.parseMaybeAssignAllowIn();return this.semicolon(),s}parseExportDeclaration(t){return this.match(80)?this.parseClass(this.startNode(),!0,!1):this.parseStatementListItem()}isExportDefaultSpecifier(){const{type:t}=this.state;if(D(t)){if(t===95&&!this.state.containsEsc||t===100)return!1;if((t===130||t===129)&&!this.state.containsEsc){const{type:i}=this.lookahead();if(D(i)&&i!==98||i===5)return this.expectOnePlugin(["flow","typescript"]),!1}}else if(!this.match(65))return!1;const s=this.nextTokenStart(),e=this.isUnparsedContextual(s,"from");if(this.input.charCodeAt(s)===44||D(this.state.type)&&e)return!0;if(this.match(65)&&e){const i=this.input.charCodeAt(this.nextTokenStartSince(s+4));return i===34||i===39}return!1}parseExportFrom(t,s){this.eatContextual(98)?(t.source=this.parseImportSource(),this.checkExport(t),this.maybeParseImportAttributes(t),this.checkJSONModuleImport(t)):s&&this.unexpected(),this.semicolon()}shouldParseExportDeclaration(){const{type:t}=this.state;return t===26&&(this.expectOnePlugin(["decorators","decorators-legacy"]),this.hasPlugin("decorators"))?(this.getPluginOption("decorators","decoratorsBeforeExport")===!0&&this.raise(p.DecoratorBeforeExport,this.state.startLoc),!0):this.isContextual(107)?(this.raise(p.UsingDeclarationExport,this.state.startLoc),!0):this.isContextual(96)&&this.startsAwaitUsing()?(this.raise(p.UsingDeclarationExport,this.state.startLoc),!0):t===74||t===75||t===68||t===80||this.isLet()||this.isAsyncFunction()}checkExport(t,s,e,i){var a,n;if(s){if(e){if(this.checkDuplicateExports(t,"default"),this.hasPlugin("exportDefaultFrom")){const o=t.declaration;o.type==="Identifier"&&o.name==="from"&&o.end-o.start===4&&!((a=o.extra)!=null&&a.parenthesized)&&this.raise(p.ExportDefaultFromAsIdentifier,o)}}else if((n=t.specifiers)!=null&&n.length)for(const o of t.specifiers){const{exported:c}=o,h=c.type==="Identifier"?c.name:c.value;if(this.checkDuplicateExports(o,h),!i&&o.local){const{local:l}=o;l.type!=="Identifier"?this.raise(p.ExportBindingIsString,o,{localName:l.value,exportName:h}):(this.checkReservedWord(l.name,l.loc.start,!0,!1),this.scope.checkLocalExport(l))}}else if(t.declaration){const o=t.declaration;if(o.type==="FunctionDeclaration"||o.type==="ClassDeclaration"){const{id:c}=o;if(!c)throw new Error("Assertion failure");this.checkDuplicateExports(t,c.name)}else if(o.type==="VariableDeclaration")for(const c of o.declarations)this.checkDeclaration(c.id)}}}checkDeclaration(t){if(t.type==="Identifier")this.checkDuplicateExports(t,t.name);else if(t.type==="ObjectPattern")for(const s of t.properties)this.checkDeclaration(s);else if(t.type==="ArrayPattern")for(const s of t.elements)s&&this.checkDeclaration(s);else t.type==="ObjectProperty"?this.checkDeclaration(t.value):t.type==="RestElement"?this.checkDeclaration(t.argument):t.type==="AssignmentPattern"&&this.checkDeclaration(t.left)}checkDuplicateExports(t,s){this.exportedIdentifiers.has(s)&&(s==="default"?this.raise(p.DuplicateDefaultExport,t):this.raise(p.DuplicateExport,t,{exportName:s})),this.exportedIdentifiers.add(s)}parseExportSpecifiers(t){const s=[];let e=!0;for(this.expect(5);!this.eat(8);){if(e)e=!1;else if(this.expect(12),this.eat(8))break;const i=this.isContextual(130),a=this.match(134),n=this.startNode();n.local=this.parseModuleExportName(),s.push(this.parseExportSpecifier(n,a,t,i))}return s}parseExportSpecifier(t,s,e,i){return this.eatContextual(93)?t.exported=this.parseModuleExportName():s?t.exported=this.cloneStringLiteral(t.local):t.exported||(t.exported=this.cloneIdentifier(t.local)),this.finishNode(t,"ExportSpecifier")}parseModuleExportName(){if(this.match(134)){const t=this.parseStringLiteral(this.state.value),s=Bn.exec(t.value);return s&&this.raise(p.ModuleExportNameHasLoneSurrogate,t,{surrogateCharCode:s[0].charCodeAt(0)}),t}return this.parseIdentifier(!0)}isJSONModuleImport(t){return t.assertions!=null?t.assertions.some(({key:s,value:e})=>e.value==="json"&&(s.type==="Identifier"?s.name==="type":s.value==="type")):!1}checkImportReflection(t){var i;const{specifiers:s}=t,e=s.length===1?s[0].type:null;t.phase==="source"?e!=="ImportDefaultSpecifier"&&this.raise(p.SourcePhaseImportRequiresDefault,s[0].loc.start):t.phase==="defer"?e!=="ImportNamespaceSpecifier"&&this.raise(p.DeferImportRequiresNamespace,s[0].loc.start):t.module&&(e!=="ImportDefaultSpecifier"&&this.raise(p.ImportReflectionNotBinding,s[0].loc.start),((i=t.assertions)==null?void 0:i.length)>0&&this.raise(p.ImportReflectionHasAssertion,s[0].loc.start))}checkJSONModuleImport(t){if(this.isJSONModuleImport(t)&&t.type!=="ExportAllDeclaration"){const{specifiers:s}=t;if(s!=null){const e=s.find(i=>{let a;if(i.type==="ExportSpecifier"?a=i.local:i.type==="ImportSpecifier"&&(a=i.imported),a!==void 0)return a.type==="Identifier"?a.name!=="default":a.value!=="default"});e!==void 0&&this.raise(p.ImportJSONBindingNotDefault,e.loc.start)}}}isPotentialImportPhase(t){return t?!1:this.isContextual(105)||this.isContextual(97)}applyImportPhase(t,s,e,i){s||(this.hasPlugin("importReflection")&&(t.module=!1),e==="source"?(this.expectPlugin("sourcePhaseImports",i),t.phase="source"):e==="defer"?(this.expectPlugin("deferredImportEvaluation",i),t.phase="defer"):this.hasPlugin("sourcePhaseImports")&&(t.phase=null))}parseMaybeImportPhase(t,s){if(!this.isPotentialImportPhase(s))return this.applyImportPhase(t,s,null),null;const e=this.startNode(),i=this.parseIdentifierName(!0),{type:a}=this.state;return(ue(a)?a!==98||this.lookaheadCharCode()===102:a!==12)?(this.applyImportPhase(t,s,i,e.loc.start),null):(this.applyImportPhase(t,s,null),this.createIdentifier(e,i))}isPrecedingIdImportPhase(t){const{type:s}=this.state;return D(s)?s!==98||this.lookaheadCharCode()===102:s!==12}parseImport(t){return this.match(134)?this.parseImportSourceAndAttributes(t):this.parseImportSpecifiersAndAfter(t,this.parseMaybeImportPhase(t,!1))}parseImportSpecifiersAndAfter(t,s){t.specifiers=[];const i=!this.maybeParseDefaultImportSpecifier(t,s)||this.eat(12),a=i&&this.maybeParseStarImportSpecifier(t);return i&&!a&&this.parseNamedImportSpecifiers(t),this.expectContextual(98),this.parseImportSourceAndAttributes(t)}parseImportSourceAndAttributes(t){return t.specifiers??(t.specifiers=[]),t.source=this.parseImportSource(),this.maybeParseImportAttributes(t),this.checkImportReflection(t),this.checkJSONModuleImport(t),this.semicolon(),this.sawUnambiguousESM=!0,this.finishNode(t,"ImportDeclaration")}parseImportSource(){return this.match(134)||this.unexpected(),this.parseExprAtom()}parseImportSpecifierLocal(t,s,e){s.local=this.parseIdentifier(),t.specifiers.push(this.finishImportSpecifier(s,e))}finishImportSpecifier(t,s,e=8201){return this.checkLVal(t.local,{type:s},e),this.finishNode(t,s)}parseImportAttributes(){this.expect(5);const t=[],s=new Set;do{if(this.match(8))break;const e=this.startNode(),i=this.state.value;if(s.has(i)&&this.raise(p.ModuleAttributesWithDuplicateKeys,this.state.startLoc,{key:i}),s.add(i),this.match(134)?e.key=this.parseStringLiteral(i):e.key=this.parseIdentifier(!0),this.expect(14),!this.match(134))throw this.raise(p.ModuleAttributeInvalidValue,this.state.startLoc);e.value=this.parseStringLiteral(this.state.value),t.push(this.finishNode(e,"ImportAttribute"))}while(this.eat(12));return this.expect(8),t}parseModuleAttributes(){const t=[],s=new Set;do{const e=this.startNode();if(e.key=this.parseIdentifier(!0),e.key.name!=="type"&&this.raise(p.ModuleAttributeDifferentFromType,e.key),s.has(e.key.name)&&this.raise(p.ModuleAttributesWithDuplicateKeys,e.key,{key:e.key.name}),s.add(e.key.name),this.expect(14),!this.match(134))throw this.raise(p.ModuleAttributeInvalidValue,this.state.startLoc);e.value=this.parseStringLiteral(this.state.value),t.push(this.finishNode(e,"ImportAttribute"))}while(this.eat(12));return t}maybeParseImportAttributes(t){let s;if(this.match(76)){if(this.hasPrecedingLineBreak()&&this.lookaheadCharCode()===40)return;this.next(),s=this.parseImportAttributes()}else this.isContextual(94)&&!this.hasPrecedingLineBreak()?(this.hasPlugin("deprecatedImportAssert")||this.raise(p.ImportAttributesUseAssert,this.state.startLoc),this.addExtra(t,"deprecatedAssertSyntax",!0),this.next(),s=this.parseImportAttributes()):s=[];t.attributes=s}maybeParseDefaultImportSpecifier(t,s){if(s){const e=this.startNodeAtNode(s);return e.local=s,t.specifiers.push(this.finishImportSpecifier(e,"ImportDefaultSpecifier")),!0}else if(ue(this.state.type))return this.parseImportSpecifierLocal(t,this.startNode(),"ImportDefaultSpecifier"),!0;return!1}maybeParseStarImportSpecifier(t){if(this.match(55)){const s=this.startNode();return this.next(),this.expectContextual(93),this.parseImportSpecifierLocal(t,s,"ImportNamespaceSpecifier"),!0}return!1}parseNamedImportSpecifiers(t){let s=!0;for(this.expect(5);!this.eat(8);){if(s)s=!1;else{if(this.eat(14))throw this.raise(p.DestructureNamedImport,this.state.startLoc);if(this.expect(12),this.eat(8))break}const e=this.startNode(),i=this.match(134),a=this.isContextual(130);e.imported=this.parseModuleExportName();const n=this.parseImportSpecifier(e,i,t.importKind==="type"||t.importKind==="typeof",a,void 0);t.specifiers.push(n)}}parseImportSpecifier(t,s,e,i,a){if(this.eatContextual(93))t.local=this.parseIdentifier();else{const{imported:n}=t;if(s)throw this.raise(p.ImportBindingIsString,t,{importName:n.value});this.checkReservedWord(n.name,t.loc.start,!0,!0),t.local||(t.local=this.cloneIdentifier(n))}return this.finishImportSpecifier(t,"ImportSpecifier",a)}isThisParam(t){return t.type==="Identifier"&&t.name==="this"}}class ki extends _n{constructor(t,s,e){t=Pa(t),super(t,s),this.options=t,this.initializeScopes(),this.plugins=e,this.filename=t.sourceFilename,this.startIndex=t.startIndex;let i=0;t.allowAwaitOutsideFunction&&(i|=1),t.allowReturnOutsideFunction&&(i|=2),t.allowImportExportEverywhere&&(i|=8),t.allowSuperOutsideMethod&&(i|=16),t.allowUndeclaredExports&&(i|=64),t.allowNewTargetOutsideFunction&&(i|=4),t.allowYieldOutsideFunction&&(i|=32),t.ranges&&(i|=128),t.tokens&&(i|=256),t.createImportExpressions&&(i|=512),t.createParenthesizedExpressions&&(i|=1024),t.errorRecovery&&(i|=2048),t.attachComment&&(i|=4096),t.annexB&&(i|=8192),this.optionFlags=i}getScopeHandler(){return xs}parse(){this.enterInitialScopes();const t=this.startNode(),s=this.startNode();return this.nextToken(),t.errors=null,this.parseTopLevel(t,s),t.errors=this.state.errors,t.comments.length=this.state.commentsLen,t}}function Ni(r,t){if((t==null?void 0:t.sourceType)==="unambiguous"){t=Object.assign({},t);try{t.sourceType="module";const s=Mt(t,r),e=s.parse();if(s.sawUnambiguousESM)return e;if(s.ambiguousScriptDifferentAst)try{return t.sourceType="script",Mt(t,r).parse()}catch{}else e.program.sourceType="script";return e}catch(s){try{return t.sourceType="script",Mt(t,r).parse()}catch{}throw s}}else return Mt(t,r).parse()}function jn(r){const t={};for(const s of Object.keys(r))t[s]=si(r[s]);return t}jn(Ta);function Mt(r,t){let s=ki;const e=new Map;if(r!=null&&r.plugins){for(const i of r.plugins){let a,n;typeof i=="string"?a=i:[a,n]=i,e.has(a)||e.set(a,n||{})}Dn(e),s=Un(e)}return new s(r,t,e)}const vi=new Map;function Un(r){const t=[];for(const i of Ln)r.has(i)&&t.push(i);const s=t.join("|");let e=vi.get(s);if(!e){e=ki;for(const i of t)e=Ci[i](e);vi.set(s,e)}return e}function ft(r){if(!r)return null;switch(r.type){case"ObjectExpression":return r.properties.reduce((n,o)=>{if(o.type==="ObjectProperty"){const c=o;let h;if(c.key.type==="Identifier")h=c.key.name;else if(c.key.type==="StringLiteral"||c.key.type==="NumericLiteral")h=c.key.value;else throw new Error(`Unsupported key type in ObjectProperty: ${c.key.type}`);n[h]=ft(c.value)}else if(o.type!=="SpreadElement"&&o.type!=="ObjectMethod")throw new Error(`Unsupported property type in ObjectExpression: ${o.type}`);return n},{});case"ArrayExpression":return r.elements.map(n=>{if(!(n&&n.type==="SpreadElement"))return ft(n)}).filter(n=>n!==void 0);case"ObjectProperty":const e=r;let i;if(e.key.type==="Identifier")i=e.key.name;else if(e.key.type==="StringLiteral"||e.key.type==="NumericLiteral")i=e.key.value;else throw new Error(`Unsupported key type for standalone ObjectProperty: ${e.key.type}`);const a={};return a[i]=ft(e.value),a;case"StringLiteral":case"NumericLiteral":case"BooleanLiteral":return r.value;case"NullLiteral":return null;default:throw new Error(`Unsupported AST node type for JSON conversion: ${r.type}`)}}function He(r){switch(r.key.type){case"Identifier":return r.key.name;case"StringLiteral":return r.key.value;default:throw new Error(`Could not extract entities, expected object key to be an \`Identifier\` or \`StringLiteral\`, got \`${r.key.type}\`.`)}}function Oi(r,t){const s={};for(const e of t.properties){if(e.type!=="ObjectProperty")throw new Error(`Expected i.entity for \`${r}\` to contain only \`ObjectProperty\`, got \`${e.type}\`.`);const i=He(e),a=[];if(e.value.type!=="CallExpression")throw new Error(`Could not extract \`${r}.${i}\`. Expected a call to \`i.string()\`, \`i.number()\`, etc. Got something else.`);let n=e.value,o=null;for(;n;){if(n.callee.type!=="MemberExpression"||n.callee.property.type!=="Identifier"||!(n.callee.object.type==="CallExpression"||n.callee.object.type==="Identifier"&&n.callee.object.name==="i"))throw new Error(`Could not extract \`${r}.${i}\`. Expected a call to \`i.string()\`, \`i.number()\`, etc. Got something else.`);if(n.callee.object.type==="CallExpression")a.push(n.callee.property.name),n=n.callee.object;else{switch(n.callee.property.name){case"string":{o=G.string();break}case"number":{o=G.number();break}case"boolean":{o=G.boolean();break}case"date":{o=G.date();break}case"json":{o=G.json();break}case"any":{o=G.any();break}}n=null}}if(!o)throw new Error(`Could not extract \`${r}.${i}\`. Found no call to \`i.string()\`, \`i.number()\`, etc.`);for(const c of a.reverse())switch(c){case"indexed":{o=o.indexed();break}case"unique":{o=o.unique();break}case"optional":{o=o.optional();break}case"clientRequired":{o=o.clientRequired();break}default:throw new Error(`Could not extract \`${r}.${i}\`. Found a call to \`${c}()\` that is not recognized.`)}s[i]=o}return G.entity(s)}function Di(r){const t={};for(const s of r.properties){if(s.type!=="ObjectProperty")throw new Error(`Expected entities to contain only \`ObjectProperty\`, got \`${s.type}\`.`);const e=He(s);if(s.value.type!=="CallExpression"||s.value.callee.type!=="MemberExpression"||s.value.callee.object.type!=="Identifier"||s.value.callee.object.name!=="i"||s.value.arguments.length!==1||s.value.arguments[0].type!=="ObjectExpression")throw new Error(`Could not extract entity \`${e}\`. Expected a call to \`i.entity()\`, got something else.`);t[e]=Oi(e,s.value.arguments[0])}return t}function $n(r,t){let s=null,e;for(const i of t.properties){if(i.type!=="ObjectProperty")throw new Error(`Expected entities to contain only \`ObjectProperty\`, got \`${i.type}\`.`);const a=He(i);switch(a){case"topics":{if(i.value.type!=="ObjectExpression")throw new Error(`Could not exxtract \`rooms.${r}.topics\`. Expected an object, got \`${i.value.type}\`.`);e=Di(i.value);break}case"presence":{if(i.value.type!=="CallExpression"||i.value.callee.type!=="MemberExpression"||i.value.callee.object.type!=="Identifier"||i.value.callee.object.name!=="i"||i.value.arguments.length!==1||i.value.arguments[0].type!=="ObjectExpression")throw new Error(`Could not extract \`rooms.${r}.presence\`. Expected a call to \`i.entity()\`, got something else.`);s=Oi(r,i.value.arguments[0]);break}default:throw new Error(`Could not extract \`rooms.${r}\`. Unexpected property \`${a}\`.`)}}if(!s)throw new Error(`Could not extract room ${r}, \`presence\` key was missing from room definition.`);return{presence:s,topics:e}}function qn(r){const t={};for(const s of r.properties){if(s.type!=="ObjectProperty")throw new Error(`Expected entities to contain only \`ObjectProperty\`, got \`${s.type}\`.`);const e=He(s);if(s.value.type!=="ObjectExpression")throw new Error(`Could not extract room \`${e}\`. Expected an object with topics and presence keys, got \`${s.value.type}\`.`);t[e]=$n(e,s.value)}return t}function zn(r){let t=null,s={},e={};for(const i of r.program.body){if(i.type!=="VariableDeclaration"||i.declarations.length!==1||i.declarations[0].id.type!=="Identifier"||i.declarations[0].id.name!=="_schema")continue;const a=i.declarations[0];if(!a.init||a.init.type!=="CallExpression"||a.init.callee.type!=="MemberExpression"||a.init.callee.object.type!=="Identifier"||a.init.callee.object.name!=="i"||a.init.arguments.length!==1||a.init.arguments[0].type!=="ObjectExpression")throw new Error("Could not extract schema. Expected a call to `i.schema()`, got something else.");for(const n of a.init.arguments[0].properties){if(n.type!=="ObjectProperty")throw new Error(`Could not extra schema property, expected an \`ObjectProperty\`, got \`${n.type}'.`);const o=He(n);if(n.value.type!=="ObjectExpression")throw new Error(`Failed to extract ${o}, expected an \`ObjectExpression\`, got \`${n.value.type}\`.`);switch(He(n)){case"entities":{t=Di(n.value);break}case"links":{s=ft(n.value)||{};break}case"rooms":{e=qn(n.value);break}}}}if(!t)throw new Error("Could not extract schema, did not find any entities.");return G.schema({entities:t,links:s,rooms:e})}function Vn(r,t="instant.schema.ts"){var e;const s=Ni(r,{sourceFilename:t,sourceType:"module",errorRecovery:!1,plugins:["typescript"]});if((e=s.errors)!=null&&e.length)throw new Error(`Could not parse schema file. ${s.errors[0].reasonCode}.`);return zn(s)}function Hn(r,t){const s=r&&Object.keys(r).length?JSON.stringify(r,null,2):`{
9
9
  /**
10
10
  * Welcome to Instant's permission system!
11
11
  * Right now your rules are empty. To start filling them in, check out the docs:
@@ -30,22 +30,22 @@ import type { InstantRules } from "${t??"@instantdb/core"}";
30
30
  const rules = ${s} satisfies InstantRules;
31
31
 
32
32
  export default rules;
33
- `}function jn(r){for(const t of r.program.body){if(t.type!=="VariableDeclaration"||t.declarations.length!==1||t.declarations[0].id.type!=="Identifier"||t.declarations[0].id.name!=="rules")continue;const s=t.declarations[0];if(!s.init||s.init.type!=="TSSatisfiesExpression")throw new Error("Could not extract rules");return ut(s.init.expression)}throw new Error("Could not extract rules, did not find the rules variable declaration.")}function Un(r,t){var e;const s=ki(r,{sourceFilename:t,sourceType:"module",errorRecovery:!1,plugins:["typescript"]});if((e=s.errors)!=null&&e.length)throw new Error(`Could not parse perms file. ${s.errors[0].reasonCode}.`);return jn(s)}function Re(r){return Object.entries(r).sort(([t],[s])=>t.localeCompare(s))}function $n(r){return r.charAt(0).toUpperCase()+r.slice(1)}const qn={"many-false":["many","many"],"one-true":["one","one"],"many-true":["many","one"],"one-false":["one","many"]};function pt(r,t=2){if(!r)return r;const s=" ".repeat(t);return r.split(`
33
+ `}function Kn(r){for(const t of r.program.body){if(t.type!=="VariableDeclaration"||t.declarations.length!==1||t.declarations[0].id.type!=="Identifier"||t.declarations[0].id.name!=="rules")continue;const s=t.declarations[0];if(!s.init||s.init.type!=="TSSatisfiesExpression")throw new Error("Could not extract rules");return ft(s.init.expression)}throw new Error("Could not extract rules, did not find the rules variable declaration.")}function Wn(r,t){var e;const s=Ni(r,{sourceFilename:t,sourceType:"module",errorRecovery:!1,plugins:["typescript"]});if((e=s.errors)!=null&&e.length)throw new Error(`Could not parse perms file. ${s.errors[0].reasonCode}.`);return Kn(s)}function _e(r){return Object.entries(r).sort(([t],[s])=>t.localeCompare(s))}function Jn(r){return r.charAt(0).toUpperCase()+r.slice(1)}const Gn={"many-false":["many","many"],"one-true":["one","one"],"many-true":["many","one"],"one-false":["one","many"]};function dt(r,t=2){if(!r)return r;const s=" ".repeat(t);return r.split(`
34
34
  `).map(e=>`${s}${e}`).join(`
35
- `)}function Di(r,t,s=t){const e=r.join(t);return r.length?e+s:e}function zn(r){return r["checked-data-type"]?{type:r["checked-data-type"],origin:"checked"}:{type:"any",origin:"unknown"}}function Ss(r){return`"${r}"`}function Vn([r,t]){var n;const s=((n=t.metadata.derivedType)==null?void 0:n.type)||t.valueType||"any",e=t.config.unique?".unique()":"",i=t.config.indexed?".indexed()":"",a=t.required?"":".optional()";return`${Ss(r)}: i.${s}()${e}${i}${a}`}function Is(r,t){const s=Di(Re(t.attrs).map(Vn),`,
36
- `,",");return`${Ss(r)}: i.entity({${s.length?`
37
- `:""}${pt(s,2)}${s.length?`
38
- `:""}})`}function Hn(r){return r[1]}function Kn(r){return r[2]}function Te(r){return`${Hn(r)}.${Kn(r)}`}function Li(r){var t;return(t=r["forward-identity"])==null?void 0:t[2]}function Jn(r){var t;return(t=r["forward-identity"])==null?void 0:t[1]}function Wn(r){var t;return(t=r["reverse-identity"])==null?void 0:t[2]}function Gn(r){var t;return(t=r["reverse-identity"])==null?void 0:t[1]}function Mi(r){return`${Jn(r)}.${Li(r)}`}function Xn(r){if(r["reverse-identity"])return`${Gn(r)}.${Wn(r)}`}function Yn(r){let t="{";if(r.presence&&(t+=`
39
- ${pt(Is("presence",r.presence),4)},`),r.topics){t+=`
35
+ `)}function Li(r,t,s=t){const e=r.join(t);return r.length?e+s:e}function Xn(r){return r["checked-data-type"]?{type:r["checked-data-type"],origin:"checked"}:{type:"any",origin:"unknown"}}function Es(r){return`"${r}"`}function Yn([r,t]){var n;const s=((n=t.metadata.derivedType)==null?void 0:n.type)||t.valueType||"any",e=t.config.unique?".unique()":"",i=t.config.indexed?".indexed()":"",a=t.required?"":".optional()";return`${Es(r)}: i.${s}()${e}${i}${a}`}function Cs(r,t){const s=Li(_e(t.attrs).map(Yn),`,
36
+ `,",");return`${Es(r)}: i.entity({${s.length?`
37
+ `:""}${dt(s,2)}${s.length?`
38
+ `:""}})`}function Zn(r){return r[1]}function Qn(r){return r[2]}function Te(r){return`${Zn(r)}.${Qn(r)}`}function Mi(r){var t;return(t=r["forward-identity"])==null?void 0:t[2]}function eo(r){var t;return(t=r["forward-identity"])==null?void 0:t[1]}function to(r){var t;return(t=r["reverse-identity"])==null?void 0:t[2]}function so(r){var t;return(t=r["reverse-identity"])==null?void 0:t[1]}function Fi(r){return`${eo(r)}.${Mi(r)}`}function io(r){if(r["reverse-identity"])return`${so(r)}.${to(r)}`}function ro(r){let t="{";if(r.presence&&(t+=`
39
+ ${dt(Cs("presence",r.presence),4)},`),r.topics){t+=`
40
40
  "topics": {`;for(const[s,e]of Object.entries(r.topics))t+=`
41
- ${pt(Is(s,e),6)},`;t+=`
41
+ ${dt(Cs(s,e),6)},`;t+=`
42
42
  }`}return t+=t==="{"?"}":`
43
- }`,t}function Zn(r){let t="{";for(const[s,e]of Object.entries(r))t+=`
44
- ${Ss(s)}: ${Yn(e)},`;return t+=t==="{"?"}":`
45
- }`,t}function Qn(r,t,s){const e=Di(Re(t.entities).map(([l,u])=>Is(l,u)),`,
43
+ }`,t}function ao(r){let t="{";for(const[s,e]of Object.entries(r))t+=`
44
+ ${Es(s)}: ${ro(e)},`;return t+=t==="{"?"}":`
45
+ }`,t}function no(r,t,s){const e=Li(_e(t.entities).map(([l,u])=>Cs(l,u)),`,
46
46
  `,","),i=`{
47
- ${pt(e,2)}
48
- }`,a=JSON.stringify(t.links,null,2).trim(),n=(r==null?void 0:r.rooms)||{},o=Zn(n),c=(l,u)=>pt(`${l}: ${u}`,2);return`// Docs: https://www.instantdb.com/docs/modeling-data
47
+ ${dt(e,2)}
48
+ }`,a=JSON.stringify(t.links,null,2).trim(),n=(r==null?void 0:r.rooms)||{},o=ao(n),c=(l,u)=>dt(`${l}: ${u}`,2);return`// Docs: https://www.instantdb.com/docs/modeling-data
49
49
 
50
50
  import { i } from "${s??"@instantdb/core"}";
51
51
 
@@ -62,11 +62,11 @@ const schema: AppSchema = _schema;
62
62
 
63
63
  export type { AppSchema }
64
64
  export default schema;
65
- `}class Ne extends Error{constructor(t){super(t),this.name="SchemaValidationError"}}function Fi(r){const t=r.filter(e=>e.catalog==="system").flatMap(e=>[e["forward-identity"],e["reverse-identity"]].filter(Boolean)).filter(e=>!!e);let s={};for(const[e,i,a]of t)s[i]=s[i]||new Set,s[i].add(a);return s}const Bi=(r,t)=>{const s=Object.keys(r.entities);for(const[e,i]of Object.entries(r.entities))if(e.startsWith("$")){if(!t[e])throw new Ne(`The $ keyword is reserved for system namespaces.
66
- You can't create '${e}'. Perhaps call it '${e.slice(1)}' instead?`);for(const[a,n]of Object.entries(i.attrs))if(!t[e].has(a)&&n.required)throw new Ne(`The '${e}' namespace is managed by the system and can't modify required constraints yet.
65
+ `}class Oe extends Error{constructor(t){super(t),this.name="SchemaValidationError"}}function Bi(r){const t=r.filter(e=>e.catalog==="system").flatMap(e=>[e["forward-identity"],e["reverse-identity"]].filter(Boolean)).filter(e=>!!e);let s={};for(const[e,i,a]of t)s[i]=s[i]||new Set,s[i].add(a);return s}const Ri=(r,t)=>{const s=Object.keys(r.entities);for(const[e,i]of Object.entries(r.entities))if(e.startsWith("$")){if(!t[e])throw new Oe(`The $ keyword is reserved for system namespaces.
66
+ You can't create '${e}'. Perhaps call it '${e.slice(1)}' instead?`);for(const[a,n]of Object.entries(i.attrs))if(!t[e].has(a)&&n.required)throw new Oe(`The '${e}' namespace is managed by the system and can't modify required constraints yet.
67
67
  Make sure to set ${e}.${a} as optional.
68
- i.e { ${a}: i.${n.valueType}().optional() }`)}for(const e of Object.values(r.links)){if(t[e.forward.on]&&!t[e.forward.on].has(e.forward.label)&&e.forward.required)throw new Ne(`The ${e.forward.on} namespace is managed by the system and can't modify required constraints yet.
68
+ i.e { ${a}: i.${n.valueType}().optional() }`)}for(const e of Object.values(r.links)){if(t[e.forward.on]&&!t[e.forward.on].has(e.forward.label)&&e.forward.required)throw new Oe(`The ${e.forward.on} namespace is managed by the system and can't modify required constraints yet.
69
69
  Make sure to set ${e.forward.on}${e.forward.label} as 'optional'.
70
- i.e { 'on': '${e.forward.on}', 'label': ${e.forward.label}, 'required': false }`);if(e.forward.has==="many"&&e.forward.onDelete==="cascade")throw new Ne(`${e.forward.on}${e.forward.label} -> ${e.reverse.on}${e.reverse.label} has onDelete: "cascade" with has: "many"`);if(e.reverse.has==="many"&&e.reverse.onDelete==="cascade")throw new Ne(`${e.forward.on}${e.forward.label} -> ${e.reverse.on}${e.reverse.label} has onDelete: "cascade" with has: "many"`);const i=`${e.forward.on}${e.forward.label} -> ${e.reverse.on}${e.reverse.label}`;if(!s.includes(e.forward.on))throw new Ne(`${i} connects to non existing entity "${e.forward.on}".`);if(!s.includes(e.reverse.on))throw new Ne(`${i} connects to non existing entity "${e.forward.on}".`)}},eo={"https://api.instantdb.com":{keys:[{kty:"OKP",crv:"Ed25519",alg:"EdDSA",use:"sig",kid:"1034696293",x:"N-C41432STKAKkXAWmeIOXMnZcGRR1b9u1L3bTVqI_o"}]},"http://localhost:8888":{keys:[{kty:"OKP",crv:"Ed25519",alg:"EdDSA",use:"sig",kid:"503090235",x:"qrSkwDaMITRMF9nOgpueqxgaAiuFmJperYE3mkyl8Ow"}]}};function to(r){if(r.kty==="OKP"&&r.crv==="Ed25519")return{name:"Ed25519"};if(r.kty==="EC")return{name:"ECDSA",namedCurve:r.crv};if(r.kty==="RSA")return{name:"RSASSA-PKCS1-v1_5",hash:{RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"}[r.alg]||"SHA-256"};throw new Error(`Unsupported JWK configuration: kty=${r.kty}, crv=${r.crv}`)}async function so(r){const t=to(r),s=await crypto.subtle.importKey("jwk",r,t,!1,["verify"]);return{alg:t,key:s}}function io(r,t,s,e){return crypto.subtle.verify(r,t,s,e)}function ro(r){const t=new Uint8Array(Math.ceil(r.length/2));for(let s=0;s<t.length;s++)t[s]=parseInt(r.substring(s*2,s*2+2),16);return t}function ao(r){let t,s,e;for(const a of r.split(",")){const[n,o]=a.split("=");switch(n){case"t":{t=o;break}case"kid":{s=o;break}case"v1":{e=o;break}}}const i=[];if(t||i.push("t"),s||i.push("kid"),e||i.push("v1"),i.length||!t||!s||!e)throw new ee("Invalid Instant-Signature header.",{header:r,missingKeys:i});return{t,kid:s,v1:e}}function no(r,t,s){if(Math.floor(r.getTime()/1e3)-parseInt(t,10)>s)throw new ee("Webhook signature is too old",{tolerance:s,receivedAt:r,t})}const Ri={},oo=300;async function co(r,t){const s=await t.text();try{const e=JSON.parse(s);return r(new be({status:t.status,body:e}))}catch{return r(new be({status:t.status,body:{type:void 0,message:s}}))}}const ho=async(r,t)=>{const s={...(t==null?void 0:t.headers)||{},"Instant-Core-Version":me},e=await fetch(r,{...t,headers:s});return e.status===200?e.json():co(i=>Promise.reject(i),e)};function _i(r){return r?new Date(r):null}function Ke(r){return{id:r.id,sink:r.sink,namespaces:r.namespaces??[],actions:r.actions,status:r.status,disabledReason:r.disabled_reason??null,createdAt:new Date(r.created_at),updatedAt:new Date(r.updated_at)}}function lo(r){return{attemptAt:_i(r["attempt-at"]),durationMs:r["duration-ms"]??null,success:r["success?"]??null,statusCode:r["status-code"]??null,responseText:r["response-text"]??null,errorType:r["error-type"]??null,errorMessage:r["error-message"]??null}}function Es(r){return{isn:r.isn,status:r.status,attempts:r.attempts?r.attempts.map(lo):null,nextAttemptAfter:_i(r.next_attempt_after),createdAt:new Date(r.created_at),updatedAt:new Date(r.updated_at)}}class ji{constructor(t){H(this,ae);H(this,se);H(this,ft);H(this,Xe);H(this,Ye);H(this,dt);J(this,se,t.appId),J(this,ft,t.apiURI),J(this,Xe,t.token),J(this,Ye,t.withAuth),J(this,dt,t.jsonFetch)}async list(){return((await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks`)).webhooks||[]).map(Ke)}async create(t){const s=await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks`,{method:"POST",body:t});return Ke(s.webhook)}async update(t,s){const e=await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}`,{method:"POST",body:s});return Ke(e.webhook)}async delete(t){const s=await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}`,{method:"DELETE"});return Ke(s.webhook)}async enable(t){const s=await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/enable`,{method:"POST",body:{}});return Ke(s.webhook)}async disable(t,s){const e=s!=null&&s.reason?{reason:s.reason}:{},i=await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/disable`,{method:"POST",body:e});return Ke(i.webhook)}async listEvents(t,s){var a,n,o;const e=s!=null&&s.after?`?after=${encodeURIComponent(s.after)}`:"",i=await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/events${e}`);return{events:(i.events||[]).map(Es),pageInfo:{startCursor:((a=i.pageInfo)==null?void 0:a.startCursor)??null,endCursor:((n=i.pageInfo)==null?void 0:n.endCursor)??null,hasNextPage:!!((o=i.pageInfo)!=null&&o.hasNextPage)}}}async getEvent(t,s){const e=await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/events/${s}`);return Es(e.event)}async getPayload(t,s){return ie(this,ae,fe).call(this,`/webhooks/payload/${y(this,se)}/${t}/${s}`)}async resendEvent(t,s){const e=await ie(this,ae,fe).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/events/${s}`,{method:"POST",body:{}});return Es(e.event)}}se=new WeakMap,ft=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,dt=new WeakMap,ae=new WeakSet,fe=function(t,s){if(!y(this,se))throw new ee("appId is required to manage webhooks. Pass it to the Webhooks constructor.");const e=i=>{const a={method:s==null?void 0:s.method,headers:{authorization:`Bearer ${i}`,"content-type":"application/json"}};return(s==null?void 0:s.body)!==void 0&&(a.body=JSON.stringify(s.body)),y(this,dt).call(this,`${y(this,ft)}${t}`,a)};if(y(this,Ye))return y(this,Ye).call(this,e);if(!y(this,Xe))throw new ee("A token is required to manage webhooks. Pass `adminToken` or `token` to the Webhooks constructor.");return e(y(this,Xe))};const Os=class Os{constructor(t,s){m(this,"appId");m(this,"schema");H(this,mt);m(this,"apiURI");H(this,je);m(this,"manager");this.appId=t.appId,this.schema=t.schema,J(this,mt,t.adminToken||t.token),this.apiURI=t.apiURI||"https://api.instantdb.com",J(this,je,s||ho),this.manager=new ji({appId:this.appId,apiURI:this.apiURI,token:y(this,mt),withAuth:t.withAuth,jsonFetch:y(this,je)})}static helpers(){function t(...e){if(e.length===2)return{$default:e[1]};const[i,a,n]=e;return{[i]:{[a]:n}}}function s(...e){const i={};for(const a of e)for(const n of Object.keys(a))n==="$default"?i.$default=a.$default:i[n]={...i[n],...a[n]};return i}return{typedHandlers:t,combineHandlers:s}}helpers(){return Os.helpers()}async fetchJwks(){return await y(this,je).call(this,`${this.apiURI}/.well-known/webhooks/jwks.json`)}async keyOfKid(t){var n,o,c;const s=`${this.apiURI}:${t}`,e=Ri[s];if(e)return e;const i=((n=eo[this.apiURI])==null?void 0:n.keys.find(h=>h.kid===t))||((c=(o=await this.fetchJwks())==null?void 0:o.keys)==null?void 0:c.find(h=>h.kid===t));if(!i)throw new ee("Could not find matching signing key",{kid:t});const a=await so(i);return Ri[s]=a,a}async validate(t,s,e){const i=(e==null?void 0:e.receivedAt)||new Date,{t:a,kid:n,v1:o}=ao(t),c=(e==null?void 0:e.tolerance)??oo;no(i,a,c);const{alg:h,key:l}=await this.keyOfKid(n),u=typeof s=="function"?await s():s,f=new TextEncoder().encode(`${a}.${u}`);if(!await io(h,l,ro(o),f))throw new ee("Instant Signature did not validate",{header:t});const P=JSON.parse(u);if(typeof P!="object"||typeof P.payloadUrl!="string"||typeof P.token!="string")throw new ee("Invalid webhook body, expected an object with payloadUrl and token fields",{body:P});return P}async validateRequest(t,s){const e=t.headers.get("instant-signature");if(!e)throw new ee("Request is missing Instant-Signature header");return this.validate(e,()=>t.text(),s)}fetchPayloads({payloadUrl:t,token:s}){return y(this,je).call(this,t,{headers:{Authorization:`Bearer ${s}`,accept:"application/json"}})}async processPayload(t,s){var i,a;const e=[];for(const n of s.data){const{namespace:o,action:c}=n,h=((i=t==null?void 0:t[o])==null?void 0:i[c])||((a=t==null?void 0:t[o])==null?void 0:a.$default)||(t==null?void 0:t.$default);h&&e.push(h(n))}await Promise.all(e)}async processRequest(t,s,e){const i=await this.validateRequest(s,e),a=await this.fetchPayloads(i);await this.processPayload(t,a)}async processNodeRequest(t,s,e){let i,a=!1,n=(e==null?void 0:e.body)??s.rawBody??s.body;if(n!=null&&typeof n.then=="function"&&(n=await n),typeof n=="string")i=n;else if(n instanceof Uint8Array)i=new TextDecoder("utf-8").decode(n);else if(n!=null&&typeof n=="object")try{i=JSON.stringify(n),a=!0}catch{throw new ee("Webhook request body has already been parsed and could not be re-serialized. Configure this route to receive the raw request body instead of parsed JSON.")}else if(s[Symbol.asyncIterator]){const u=new TextEncoder,f=[];for await(const B of s)f.push(typeof B=="string"?u.encode(B):B);let d=0;for(const B of f)d+=B.byteLength;const P=new Uint8Array(d);let S=0;for(const B of f)P.set(B,S),S+=B.byteLength;i=new TextDecoder("utf-8").decode(P)}else throw new ee("Could not read the webhook request body. Pass a Node IncomingMessage with an unconsumed stream, or set `req.body` to the raw bytes (Buffer/Uint8Array) or string.");const o=typeof s.headers.host=="string"?s.headers.host:"localhost",c=new URL(s.url??"/",`https://${o}`),h=new Headers;for(const[u,f]of Object.entries(s.headers))typeof f=="string"?h.set(u,f):Array.isArray(f)&&h.set(u,f.join(", "));const l=new Request(c,{method:s.method??"POST",headers:h,body:i});try{await this.processRequest(t,l,e)}catch(u){throw a&&u instanceof ee&&u.message==="Instant Signature did not validate"?new ee("Webhook signature did not validate. The request body was re-serialized from a parsed JSON object, which can produce different bytes than the server signed. Configure this route to receive the raw request body instead of parsed JSON.",{hint:u.hint}):u}}};mt=new WeakMap,je=new WeakMap;let Ft=Os;const Cs=r=>(r==null?void 0:r.name)==="AbortError",Ui=r=>r instanceof Error?r.message:String(r);async function uo(r){var V,X;const{manager:t,backup:s,fetchBody:e,createWriter:i,onProgress:a}=r,n=new AbortController;(V=r.signal)!=null&&V.aborted?n.abort():(X=r.signal)==null||X.addEventListener("abort",()=>n.abort(),{once:!0});const o=n.signal;let c=0,h=null,l=0,u=null,f=0,d=0,P="",S="";const B=s.uncompressedSize!=null?s.uncompressedSize+(s.filesSize??0):null,I=()=>a==null?void 0:a({entitiesCompleted:c,entitiesTotal:h,filesCompleted:l,filesTotal:u,zipBytes:f,bytesRead:d,bytesTotal:B,currentEntity:P,currentFile:S}),D=100;let z=0;const oe=()=>{const L=Date.now();L-z>=D&&(z=L,I())},g=L=>L.pipeThrough(new TransformStream({transform(U,Y){d+=U.byteLength,oe(),Y.enqueue(U)}})),j=[];let K=0,xe=!1,Pe=null,F=null;const De=()=>{const L=F;F=null,L==null||L()},hr=(async()=>{let L=!1;try{for await(const U of t.streamStorageFiles(s.id,{signal:o}))j.push(U),u=(u??0)+1,oe(),De();L=!0}catch(U){Cs(U)||(Pe=U)}finally{L&&u==null&&(u=0),xe=!0,I(),De()}})(),yt=async function*(){const L=await t.listFiles(s.id,{signal:o});if(L.length===0)throw new Error("No files found for this backup.");if(L[0].name!=="config.json")throw new Error(`Backup files came back in an unexpected order (expected config.json first, got "${L[0].name}").`);h=L.filter(U=>U.name!=="config.json").length,I();for(const U of L){P=U.name,I();const Y=await t.getFileUrl(s.id,U.name,{signal:o});let xt;try{xt=await e(Y,o)}catch(Ue){throw Cs(Ue)?Ue:new Error(`Failed to fetch ${U.name}: ${Ui(Ue)}.`)}yield{name:U.name,input:g(xt),onAdded:()=>{U.name!=="config.json"&&c++,I()}}}for(P="",I();;){if(Pe)throw Pe;o.throwIfAborted();let U;if(K<j.length&&(U=j[K],j[K]=void 0,K++),U){const Y=U.path||U.locationId;S=Y,I();let xt;try{xt=await e(U.url,o)}catch(Ue){throw Cs(Ue)?Ue:new Error(`Couldn't download storage file "${Y}" (${Ui(Ue)}).`)}yield{name:`files/${U.locationId}`,input:g(xt),onAdded:()=>{l++,I()}}}else{if(xe)break;await new Promise(Y=>{F=Y})}}if(S="",I(),Pe)throw Pe}(),$=r.sink.getWriter();try{const L=new WritableStream({async write(Y){f+=Y.byteLength,oe(),await $.write(Y)},async close(){await $.close(),I()},async abort(Y){await $.abort(Y)}}),U=await i(L,o);for await(const Y of yt)await U.add(Y.name,Y.input,{lastModDate:s.backupAt}),Y.onAdded();return o.throwIfAborted(),await U.close(),await hr,I(),{entities:c,files:l,zipBytes:f}}catch(L){throw n.abort(),await $.abort(L).catch(()=>{}),L}}function $i(r){return{id:r.id,isn:r.isn,backupAt:new Date(r.backup_at),filesSize:r.files_size,dbSize:r.db_size,uncompressedSize:r.uncompressed_size,description:r.description,expiresAt:r.expires_at?new Date(r.expires_at):null}}function po(r){return`instant-backup-${r.backupAt.toISOString().replace(/[:.]/g,"-")}.zip`}function fo(r){if(r<1e3)return`${r} B`;const t=["KB","MB","GB","TB"];let s=-1,e=r;do e/=1e3,s++;while(e>=1e3&&s<t.length-1);let i=e<10?2:e<100?1:0;return Number(e.toFixed(i))>=1e3&&s<t.length-1&&(e/=1e3,s++,i=2),`${e.toFixed(i)} ${t[s]}`}function mo(r){const t=r.uncompressedSize??r.dbSize;if(t==null||r.filesSize==null)return null;const s=t+r.filesSize;return{min:Math.round(s/4),max:s}}function qi(r){return{authorization:`Bearer ${r}`,"Instant-Platform-Version":me,"Instant-Core-Version":me,"X-Instant-Source":"platform-sdk","X-Instant-Version":me}}async function zi(r){const t=await r.text();try{return new be({status:r.status,body:JSON.parse(t)})}catch{return new be({status:r.status,body:{type:void 0,message:t}})}}async function*yo(r){const t=r.getReader();try{const s=new TextDecoder;let e="";for(;;){const{done:a,value:n}=await t.read();if(a)break;e+=s.decode(n,{stream:!0});let o=e.indexOf(`
70
+ i.e { 'on': '${e.forward.on}', 'label': ${e.forward.label}, 'required': false }`);if(e.forward.has==="many"&&e.forward.onDelete==="cascade")throw new Oe(`${e.forward.on}${e.forward.label} -> ${e.reverse.on}${e.reverse.label} has onDelete: "cascade" with has: "many"`);if(e.reverse.has==="many"&&e.reverse.onDelete==="cascade")throw new Oe(`${e.forward.on}${e.forward.label} -> ${e.reverse.on}${e.reverse.label} has onDelete: "cascade" with has: "many"`);const i=`${e.forward.on}${e.forward.label} -> ${e.reverse.on}${e.reverse.label}`;if(!s.includes(e.forward.on))throw new Oe(`${i} connects to non existing entity "${e.forward.on}".`);if(!s.includes(e.reverse.on))throw new Oe(`${i} connects to non existing entity "${e.forward.on}".`)}},oo={"https://api.instantdb.com":{keys:[{kty:"OKP",crv:"Ed25519",alg:"EdDSA",use:"sig",kid:"1034696293",x:"N-C41432STKAKkXAWmeIOXMnZcGRR1b9u1L3bTVqI_o"}]},"http://localhost:8888":{keys:[{kty:"OKP",crv:"Ed25519",alg:"EdDSA",use:"sig",kid:"503090235",x:"qrSkwDaMITRMF9nOgpueqxgaAiuFmJperYE3mkyl8Ow"}]}};function co(r){if(r.kty==="OKP"&&r.crv==="Ed25519")return{name:"Ed25519"};if(r.kty==="EC")return{name:"ECDSA",namedCurve:r.crv};if(r.kty==="RSA")return{name:"RSASSA-PKCS1-v1_5",hash:{RS256:"SHA-256",RS384:"SHA-384",RS512:"SHA-512"}[r.alg]||"SHA-256"};throw new Error(`Unsupported JWK configuration: kty=${r.kty}, crv=${r.crv}`)}async function ho(r){const t=co(r),s=await crypto.subtle.importKey("jwk",r,t,!1,["verify"]);return{alg:t,key:s}}function lo(r,t,s,e){return crypto.subtle.verify(r,t,s,e)}function uo(r){const t=new Uint8Array(Math.ceil(r.length/2));for(let s=0;s<t.length;s++)t[s]=parseInt(r.substring(s*2,s*2+2),16);return t}function po(r){let t,s,e;for(const a of r.split(",")){const[n,o]=a.split("=");switch(n){case"t":{t=o;break}case"kid":{s=o;break}case"v1":{e=o;break}}}const i=[];if(t||i.push("t"),s||i.push("kid"),e||i.push("v1"),i.length||!t||!s||!e)throw new ee("Invalid Instant-Signature header.",{header:r,missingKeys:i});return{t,kid:s,v1:e}}function fo(r,t,s){if(Math.floor(r.getTime()/1e3)-parseInt(t,10)>s)throw new ee("Webhook signature is too old",{tolerance:s,receivedAt:r,t})}const _i={},mo=300;async function yo(r,t){const s=await t.text();try{const e=JSON.parse(s);return r(new be({status:t.status,body:e}))}catch{return r(new be({status:t.status,body:{type:void 0,message:s}}))}}const xo=async(r,t)=>{const s={...(t==null?void 0:t.headers)||{},"Instant-Core-Version":xe},e=await fetch(r,{...t,headers:s});return e.status===200?e.json():yo(i=>Promise.reject(i),e)};function ji(r){return r?new Date(r):null}function Ke(r){return{id:r.id,sink:r.sink,namespaces:r.namespaces??[],actions:r.actions,status:r.status,disabledReason:r.disabled_reason??null,createdAt:new Date(r.created_at),updatedAt:new Date(r.updated_at)}}function Po(r){return{attemptAt:ji(r["attempt-at"]),durationMs:r["duration-ms"]??null,success:r["success?"]??null,statusCode:r["status-code"]??null,responseText:r["response-text"]??null,errorType:r["error-type"]??null,errorMessage:r["error-message"]??null}}function ks(r){return{isn:r.isn,status:r.status,attempts:r.attempts?r.attempts.map(Po):null,nextAttemptAfter:ji(r.next_attempt_after),createdAt:new Date(r.created_at),updatedAt:new Date(r.updated_at)}}class Ui{constructor(t){K(this,ae);K(this,se);K(this,mt);K(this,Xe);K(this,Ye);K(this,yt);W(this,se,t.appId),W(this,mt,t.apiURI),W(this,Xe,t.token),W(this,Ye,t.withAuth),W(this,yt,t.jsonFetch)}async list(){return((await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks`)).webhooks||[]).map(Ke)}async create(t){const s=await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks`,{method:"POST",body:t});return Ke(s.webhook)}async update(t,s){const e=await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}`,{method:"POST",body:s});return Ke(e.webhook)}async delete(t){const s=await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}`,{method:"DELETE"});return Ke(s.webhook)}async enable(t){const s=await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/enable`,{method:"POST",body:{}});return Ke(s.webhook)}async disable(t,s){const e=s!=null&&s.reason?{reason:s.reason}:{},i=await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/disable`,{method:"POST",body:e});return Ke(i.webhook)}async listEvents(t,s){var a,n,o;const e=s!=null&&s.after?`?after=${encodeURIComponent(s.after)}`:"",i=await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/events${e}`);return{events:(i.events||[]).map(ks),pageInfo:{startCursor:((a=i.pageInfo)==null?void 0:a.startCursor)??null,endCursor:((n=i.pageInfo)==null?void 0:n.endCursor)??null,hasNextPage:!!((o=i.pageInfo)!=null&&o.hasNextPage)}}}async getEvent(t,s){const e=await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/events/${s}`);return ks(e.event)}async getPayload(t,s){return ie(this,ae,me).call(this,`/webhooks/payload/${y(this,se)}/${t}/${s}`)}async resendEvent(t,s){const e=await ie(this,ae,me).call(this,`/dash/apps/${y(this,se)}/webhooks/${t}/events/${s}`,{method:"POST",body:{}});return ks(e.event)}}se=new WeakMap,mt=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,yt=new WeakMap,ae=new WeakSet,me=function(t,s){if(!y(this,se))throw new ee("appId is required to manage webhooks. Pass it to the Webhooks constructor.");const e=i=>{const a={method:s==null?void 0:s.method,headers:{authorization:`Bearer ${i}`,"content-type":"application/json"}};return(s==null?void 0:s.body)!==void 0&&(a.body=JSON.stringify(s.body)),y(this,yt).call(this,`${y(this,mt)}${t}`,a)};if(y(this,Ye))return y(this,Ye).call(this,e);if(!y(this,Xe))throw new ee("A token is required to manage webhooks. Pass `adminToken` or `token` to the Webhooks constructor.");return e(y(this,Xe))};const Ds=class Ds{constructor(t,s){m(this,"appId");m(this,"schema");K(this,xt);m(this,"apiURI");K(this,Ue);m(this,"manager");this.appId=t.appId,this.schema=t.schema,W(this,xt,t.adminToken||t.token),this.apiURI=t.apiURI||"https://api.instantdb.com",W(this,Ue,s||xo),this.manager=new Ui({appId:this.appId,apiURI:this.apiURI,token:y(this,xt),withAuth:t.withAuth,jsonFetch:y(this,Ue)})}static helpers(){function t(...e){if(e.length===2)return{$default:e[1]};const[i,a,n]=e;return{[i]:{[a]:n}}}function s(...e){const i={};for(const a of e)for(const n of Object.keys(a))n==="$default"?i.$default=a.$default:i[n]={...i[n],...a[n]};return i}return{typedHandlers:t,combineHandlers:s}}helpers(){return Ds.helpers()}async fetchJwks(){return await y(this,Ue).call(this,`${this.apiURI}/.well-known/webhooks/jwks.json`)}async keyOfKid(t){var n,o,c;const s=`${this.apiURI}:${t}`,e=_i[s];if(e)return e;const i=((n=oo[this.apiURI])==null?void 0:n.keys.find(h=>h.kid===t))||((c=(o=await this.fetchJwks())==null?void 0:o.keys)==null?void 0:c.find(h=>h.kid===t));if(!i)throw new ee("Could not find matching signing key",{kid:t});const a=await ho(i);return _i[s]=a,a}async validate(t,s,e){const i=(e==null?void 0:e.receivedAt)||new Date,{t:a,kid:n,v1:o}=po(t),c=(e==null?void 0:e.tolerance)??mo;fo(i,a,c);const{alg:h,key:l}=await this.keyOfKid(n),u=typeof s=="function"?await s():s,f=new TextEncoder().encode(`${a}.${u}`);if(!await lo(h,l,uo(o),f))throw new ee("Instant Signature did not validate",{header:t});const P=JSON.parse(u);if(typeof P!="object"||typeof P.payloadUrl!="string"||typeof P.token!="string")throw new ee("Invalid webhook body, expected an object with payloadUrl and token fields",{body:P});return P}async validateRequest(t,s){const e=t.headers.get("instant-signature");if(!e)throw new ee("Request is missing Instant-Signature header");return this.validate(e,()=>t.text(),s)}fetchPayloads({payloadUrl:t,token:s}){return y(this,Ue).call(this,t,{headers:{Authorization:`Bearer ${s}`,accept:"application/json"}})}async processPayload(t,s){var i,a;const e=[];for(const n of s.data){const{namespace:o,action:c}=n,h=((i=t==null?void 0:t[o])==null?void 0:i[c])||((a=t==null?void 0:t[o])==null?void 0:a.$default)||(t==null?void 0:t.$default);h&&e.push(h(n))}await Promise.all(e)}async processRequest(t,s,e){const i=await this.validateRequest(s,e),a=await this.fetchPayloads(i);await this.processPayload(t,a)}async processNodeRequest(t,s,e){let i,a=!1,n=(e==null?void 0:e.body)??s.rawBody??s.body;if(n!=null&&typeof n.then=="function"&&(n=await n),typeof n=="string")i=n;else if(n instanceof Uint8Array)i=new TextDecoder("utf-8").decode(n);else if(n!=null&&typeof n=="object")try{i=JSON.stringify(n),a=!0}catch{throw new ee("Webhook request body has already been parsed and could not be re-serialized. Configure this route to receive the raw request body instead of parsed JSON.")}else if(s[Symbol.asyncIterator]){const u=new TextEncoder,f=[];for await(const F of s)f.push(typeof F=="string"?u.encode(F):F);let d=0;for(const F of f)d+=F.byteLength;const P=new Uint8Array(d);let S=0;for(const F of f)P.set(F,S),S+=F.byteLength;i=new TextDecoder("utf-8").decode(P)}else throw new ee("Could not read the webhook request body. Pass a Node IncomingMessage with an unconsumed stream, or set `req.body` to the raw bytes (Buffer/Uint8Array) or string.");const o=typeof s.headers.host=="string"?s.headers.host:"localhost",c=new URL(s.url??"/",`https://${o}`),h=new Headers;for(const[u,f]of Object.entries(s.headers))typeof f=="string"?h.set(u,f):Array.isArray(f)&&h.set(u,f.join(", "));const l=new Request(c,{method:s.method??"POST",headers:h,body:i});try{await this.processRequest(t,l,e)}catch(u){throw a&&u instanceof ee&&u.message==="Instant Signature did not validate"?new ee("Webhook signature did not validate. The request body was re-serialized from a parsed JSON object, which can produce different bytes than the server signed. Configure this route to receive the raw request body instead of parsed JSON.",{hint:u.hint}):u}}};xt=new WeakMap,Ue=new WeakMap;let Ft=Ds;const bo=4,go=3,wo=500,To=5e3,$i=(r,t)=>r!=null&&Number.isInteger(r)&&r>0?r:t,Ao=(r,t)=>r!=null&&Number.isFinite(r)&&r>=0?r:t,qi=r=>(r==null?void 0:r.name)==="AbortError",zi=r=>r instanceof Error?r.message:String(r),So=(r,t)=>new Promise((s,e)=>{const i=()=>{clearTimeout(a),e(t.reason??new DOMException("Aborted","AbortError"))},a=setTimeout(()=>{t.removeEventListener("abort",i),s()},r);t.addEventListener("abort",i,{once:!0})});function Io(r,t){let s=!1;return new ReadableStream({async pull(e){if(!s){if(s=!0,r.done){e.close();return}e.enqueue(r.value);return}const{done:i,value:a}=await t.read();i?e.close():e.enqueue(a)},async cancel(e){await t.cancel(e)}})}async function Vi(r,t){let s;for(let e=1;e<=t.attempts;e++){t.signal.throwIfAborted();let i;try{i=(await r()).getReader();const n=await i.read();return Io(n,i)}catch(a){if(i&&i.cancel().catch(()=>{}),qi(a))throw a;if(s=a,e<t.attempts){const n=Math.min(t.delayMs*2**(e-1),To);await So(n,t.signal)}}}throw new Error(t.describe(s))}async function*Eo(r,t){const s=[],e={done:!1,producerError:null,onItem:null,onSpace:null},i=()=>{const o=e.onItem;e.onItem=null,o&&o()},a=()=>{const o=e.onSpace;e.onSpace=null,o&&o()},n=(async()=>{try{for await(const o of r){for(;s.length>=t;)await new Promise(h=>{e.onSpace=h});const c=o();c.catch(()=>{}),s.push(c),i()}}catch(o){e.producerError=o}finally{e.done=!0,i()}})();try{for(;;){if(s.length===0){if(e.done){if(e.producerError)throw e.producerError;break}await new Promise(c=>{e.onItem=c});continue}const o=await s.shift();a(),yield o}}finally{a(),n.catch(()=>{})}}async function Co(r){var fr,dr,mr,yr;const{manager:t,backup:s,fetchBody:e,createWriter:i,onProgress:a}=r,n=new AbortController;(fr=r.signal)!=null&&fr.aborted?n.abort():(dr=r.signal)==null||dr.addEventListener("abort",()=>n.abort(),{once:!0});const o=n.signal;let c=0,h=null,l=0,u=null,f=0,d=0,P="",S="";const F=s.uncompressedSize!=null?s.uncompressedSize+(s.filesSize??0):null,I=$i((mr=r.retry)==null?void 0:mr.attempts,go),O=Ao((yr=r.retry)==null?void 0:yr.delayMs,wo),L=()=>a==null?void 0:a({entitiesCompleted:c,entitiesTotal:h,filesCompleted:l,filesTotal:u,zipBytes:f,bytesRead:d,bytesTotal:F,currentEntity:P,currentFile:S}),fe=100;let g=0;const j=()=>{const $=Date.now();$-g>=fe&&(g=$,L())},X=$=>$.pipeThrough(new TransformStream({transform(q,H){d+=q.byteLength,j(),H.enqueue(q)}})),ce=[];let Se=0,B=!1,de=null,Vt=null;const tt=()=>{const $=Vt;Vt=null,$==null||$()},z=(async()=>{let $=!1;try{for await(const q of t.streamStorageFiles(s.id,{signal:o}))ce.push(q),u=(u??0)+1,j(),tt();$=!0}catch(q){qi(q)||(de=q)}finally{$&&u==null&&(u=0),B=!0,L(),tt()}})(),V=async function*(){const $=await t.listFiles(s.id,{signal:o});if($.length===0)throw new Error("No files found for this backup.");if($[0].name!=="config.json")throw new Error(`Backup files came back in an unexpected order (expected config.json first, got "${$[0].name}").`);h=$.filter(q=>q.name!=="config.json").length,L();for(const q of $)yield async()=>{const H=await Vi(async()=>{const st=await t.getFileUrl(s.id,q.name,{signal:o});return e(st,o)},{signal:o,attempts:I,delayMs:O,describe:st=>`Failed to fetch ${q.name}: ${zi(st)}.`});return{name:q.name,input:X(H),onWriting:()=>{P=q.name,S="",L()},onAdded:()=>{q.name!=="config.json"&&c++,L()}}};for(;;){if(de)throw de;o.throwIfAborted();let q;if(Se<ce.length&&(q=ce[Se],ce[Se]=void 0,Se++),q){const H=q,st=H.path||H.locationId;yield async()=>{const xc=await Vi(()=>e(H.url,o),{signal:o,attempts:I,delayMs:O,describe:Pc=>`Couldn't download storage file "${st}" (${zi(Pc)}).`});return{name:`files/${H.locationId}`,input:X(xc),onWriting:()=>{P="",S=st,L()},onAdded:()=>{l++,L()}}}}else{if(B)break;await new Promise(H=>{Vt=H})}}if(de)throw de}(),Z=$i(r.prefetch,bo),Ie=Eo(V,Z),Ht=r.sink.getWriter();try{const $=new WritableStream({async write(H){f+=H.byteLength,j(),await Ht.write(H)},async close(){await Ht.close(),L()},async abort(H){await Ht.abort(H)}}),q=await i($,o);for await(const H of Ie)H.onWriting(),await q.add(H.name,H.input,{lastModDate:s.backupAt}),H.onAdded();return P="",S="",L(),o.throwIfAborted(),await q.close(),await z,L(),{entities:c,files:l,zipBytes:f}}catch($){throw n.abort(),await Ht.abort($).catch(()=>{}),$}}function Hi(r){return{id:r.id,isn:r.isn,backupAt:new Date(r.backup_at),filesSize:r.files_size,dbSize:r.db_size,uncompressedSize:r.uncompressed_size,description:r.description,expiresAt:r.expires_at?new Date(r.expires_at):null}}function ko(r){return`instant-backup-${r.backupAt.toISOString().replace(/[:.]/g,"-")}.zip`}function No(r){if(r<1e3)return`${r} B`;const t=["KB","MB","GB","TB"];let s=-1,e=r;do e/=1e3,s++;while(e>=1e3&&s<t.length-1);let i=e<10?2:e<100?1:0;return Number(e.toFixed(i))>=1e3&&s<t.length-1&&(e/=1e3,s++,i=2),`${e.toFixed(i)} ${t[s]}`}function vo(r){const t=r.uncompressedSize??r.dbSize;if(t==null||r.filesSize==null)return null;const s=t+r.filesSize;return{min:Math.round(s/4),max:s}}function Ki(r){return{authorization:`Bearer ${r}`,"Instant-Platform-Version":xe,"Instant-Core-Version":xe,"X-Instant-Source":"platform-sdk","X-Instant-Version":xe}}async function Wi(r){const t=await r.text();try{return new be({status:r.status,body:JSON.parse(t)})}catch{return new be({status:r.status,body:{type:void 0,message:t}})}}async function*Oo(r){const t=r.getReader();try{const s=new TextDecoder;let e="";for(;;){const{done:a,value:n}=await t.read();if(a)break;e+=s.decode(n,{stream:!0});let o=e.indexOf(`
71
71
  `);for(;o!==-1;){const c=e.slice(0,o).trim();e=e.slice(o+1),c.length>0&&(yield JSON.parse(c)),o=e.indexOf(`
72
- `)}}const i=e.trim();i.length>0&&(yield JSON.parse(i))}finally{await t.cancel().catch(()=>{})}}class Vi{constructor(t){H(this,et);H(this,Oe);H(this,Ze);H(this,Qe);J(this,Oe,t.appId),J(this,Ze,t.apiURI),J(this,Qe,t.withAuth)}async list(t){return((await ie(this,et,Vt).call(this,`/dash/apps/${y(this,Oe)}/backups`,t==null?void 0:t.signal)).backups||[]).map($i)}async listFiles(t,s){return(await ie(this,et,Vt).call(this,`/dash/apps/${y(this,Oe)}/backups/${t}/files`,s==null?void 0:s.signal)).files||[]}async getFileUrl(t,s,e){return(await ie(this,et,Vt).call(this,`/dash/apps/${y(this,Oe)}/backups/${t}/file-url?name=${encodeURIComponent(s)}`,e==null?void 0:e.signal)).url}async*streamStorageFiles(t,s){const e=await y(this,Qe).call(this,async a=>{const n=await fetch(`${y(this,Ze)}/dash/apps/${y(this,Oe)}/backups/${t}/storage-files`,{headers:qi(a),signal:s==null?void 0:s.signal});if(n.status!==200)throw await zi(n);return n});if(!e.body)throw new Error("Storage file listing returned no body.");let i=!1;for await(const a of yo(e.body)){if(a.done===!0){i=!0;break}if(typeof a.locationId!="string"||a.locationId.length===0||/[/\\\u0000-\u001f\u007f]/.test(a.locationId)||a.locationId==="."||a.locationId===".."||typeof a.url!="string"||a.url.length===0)throw new Error("Storage file listing returned a malformed record. Please retry the download.");yield{locationId:a.locationId,path:a.path??null,url:a.url}}if(!i)throw new Error("Storage file listing ended before it finished. Please retry the download.")}downloadArchive(t){return uo({manager:this,...t})}}Oe=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakSet,Vt=function(t,s){return y(this,Qe).call(this,async e=>{const i=await fetch(`${y(this,Ze)}${t}`,{headers:qi(e),signal:s});if(i.status!==200)throw await zi(i);return i.json()})};class Bt{constructor(t){H(this,pe,[]);H(this,ne,null);H(this,$t,t=>{if(!y(this,ne))for(const s of y(this,pe))try{s.next&&s.next(t)}catch{}});H(this,qt,t=>{if(!y(this,ne)){J(this,ne,{type:"error",error:t});for(const s of y(this,pe))try{s.error&&s.error(t)}catch{}J(this,pe,[])}});H(this,zt,t=>{if(!y(this,ne)){J(this,ne,{type:"complete",result:t});for(const s of y(this,pe))try{s.complete&&s.complete(t)}catch{}J(this,pe,[])}});t(y(this,$t),y(this,zt),y(this,qt))}subscribe(t){if(y(this,ne)){const s={unsubscribe:()=>null};if(y(this,ne).type==="error")return t.error&&t.error(y(this,ne).error),s;if(y(this,ne).type==="complete")return t.complete&&t.complete(y(this,ne).result),s}return y(this,pe).push(t),{unsubscribe:()=>{J(this,pe,y(this,pe).filter(s=>s!==t))}}}then(t,s){this.subscribe({error:s,complete:t})}catch(t){this.subscribe({error:t})}finally(t){this.subscribe({error:()=>t(),complete:()=>t()})}}pe=new WeakMap,ne=new WeakMap,$t=new WeakMap,qt=new WeakMap,zt=new WeakMap;async function xo({code:r,clientId:t,clientSecret:s,redirectUri:e,apiURI:i="https://api.instantdb.com"}){const a=await fetch(`${i}/platform/oauth/token`,{method:"POST",headers:{"Content-type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:r,redirect_uri:e,client_id:t,client_secret:s})});if(!a.ok){const o=await a.text();let c;try{const h=JSON.parse(o);c={error:h.error,errorDescription:h.error_description,message:`OAuth error: ${h.error||"server_error"}`}}catch{c={error:"server_error",message:"OAuth error: server_error"}}throw new N(c)}const n=await a.json();return{accessToken:n.access_token,expiresAt:new Date(Date.now()+(n.expires_in-30)*1e3),refreshToken:n.refresh_token,scopes:n.scopes,tokenType:n.token_type}}async function Hi({clientId:r,clientSecret:t,refreshToken:s,apiURI:e="https://api.instantdb.com"}){const a=await(await fetch(`${e}/platform/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:s,client_id:r,client_secret:t})})).json();return{accessToken:a.access_token,expiresAt:new Date((a.expires_in-30)*1e3),scopes:a.scopes,tokenType:a.token_type}}const Rt={"many-many":{cardinality:"many","unique?":!1},"one-one":{cardinality:"one","unique?":!0},"many-one":{cardinality:"many","unique?":!0},"one-many":{cardinality:"one","unique?":!1}};Object.fromEntries(Object.entries(Rt).map(([r,t])=>[`${t.cardinality}-${t["unique?"]}`,r]));const Ki=(r,t,s)=>({type:"add-attr","unique?":r.config.unique,"value-type":"blob",cardinality:"one",identifier:{namespace:t,attrName:s},"required?":r.required,"forward-identity":{attrName:s,namespace:t},"index?":r.config.indexed,"checked-data-type":r.valueType!=="json"?r.valueType:null}),Po=r=>{const t=`${r.forward.has}-${r.reverse.has}`;return{"checked-data-type":null,"index?":!1,...Rt[t],"required?":!!r.forward.required,identifier:{attrName:r.forward.label,namespace:r.forward.on},"value-type":"ref",type:"add-attr","forward-identity":{attrName:r.forward.label,namespace:r.forward.on},"on-delete":r.forward.onDelete,"on-delete-reverse":r.reverse.onDelete,"reverse-identity":{attrName:r.reverse.label,namespace:r.reverse.on}}},_t=(r,t)=>{const s=t.find(e=>e["forward-identity"][1]===r.namespace&&e["forward-identity"][2]===r.attrName)||null;if(!s)throw new Error(`Attribute ${r.namespace}.${r.attrName} not found`);return s},_e=(r,t)=>{const s=_t(r.identifier,t);return{"attr-id":s.id,"forward-identity":s["forward-identity"]}},bo={index:_e,unique:_e,required:_e,"remove-index":_e,"remove-unique":_e,"remove-required":_e,"delete-attr":(r,t)=>_t(r.identifier,t).id,"update-attr":(r,t)=>{const s=_t(r.identifier,t);return{id:s.id,"forward-identity":r.partialAttr["forward-identity"]?[s.id,r.partialAttr["forward-identity"].namespace,r.partialAttr["forward-identity"].attrName]:void 0,"reverse-identity":r.partialAttr["reverse-identity"]?[s.id,r.partialAttr["reverse-identity"].namespace,r.partialAttr["reverse-identity"].attrName]:void 0,cardinality:r.partialAttr.cardinality?r.partialAttr.cardinality:void 0,"on-delete":r.partialAttr["on-delete"]?r.partialAttr["on-delete"]:void 0,"on-delete-reverse":r.partialAttr["on-delete-reverse"]?r.partialAttr["on-delete-reverse"]:void 0}},"add-attr":(r,t)=>{const s=zs(),e=[s,r.identifier.namespace,r.identifier.attrName],i=[];return i.push(["add-attr",{"forward-identity":e,"reverse-identity":r["reverse-identity"]?[zs(),r["reverse-identity"].namespace,r["reverse-identity"].attrName]:null,"inferred-types":null,"value-type":r["value-type"],id:s,cardinality:r.cardinality,"index?":!1,"required?":!1,"unique?":!1,catalog:"user","on-delete":r["on-delete"],"on-delete-reverse":r["on-delete-reverse"],"checked-data-type":r["checked-data-type"]}]),r["unique?"]&&i.push(["unique",{"attr-id":s,"forward-identity":e}]),r["required?"]&&i.push(["required",{"attr-id":s,"forward-identity":e}]),r["index?"]&&i.push(["index",{"attr-id":s,"forward-identity":e}]),i},"remove-data-type":_e,"check-data-type":(r,t)=>{const s=_t(r.identifier,t);return{"attr-id":s.id,"checked-data-type":r["checked-data-type"],"forward-identity":s["forward-identity"]}}};function Ae(r,t,s){var e;return!!((e=r[t])!=null&&e.has(s))}const Ji=(r,t)=>{if(!t)throw new Error("Existing attributes are required");const s=[];return r.forEach(e=>{const i=bo[e.type];if(!i)throw new Error(`Unknown transaction type: ${e.type}`);const a=i(e,t);Array.isArray(a)?s.push(...a):s.push([e.type,a])}),s},Wi=async(r,t,s,e)=>{var z,oe;const i=[],a=r.entities,n=t.entities,o=Object.keys(a),c=Object.keys(n),h=o.filter(g=>!c.includes(g));for(const g of h)Object.keys(a[g].attrs).forEach(j=>{Ae(e,g,j)||i.push({type:"delete-attr",identifier:{attrName:j,namespace:g}})}),!Ae(e,g,"id")&&i.push({type:"delete-attr",identifier:{attrName:"id",namespace:g}});const l=c.filter(g=>!o.includes(g));for(const g of l){Ae(e,g,"id")||i.push({type:"add-attr","forward-identity":{namespace:g,attrName:"id"},identifier:{attrName:"id",namespace:g},"index?":!1,"required?":!0,cardinality:"one","unique?":!0,"value-type":"blob"});for(const j of Object.keys(n[g].attrs)){if(Ae(e,g,j))continue;const K=n[g].attrs[j];i.push(Ki(K,g,j))}}const u=o.filter(g=>c.includes(g));for(const g of u){const j=Object.keys(n[g].attrs).filter(F=>Ae(e,g,F)?!1:!Object.keys(a[g].attrs).includes(F)),K=Object.keys(a[g].attrs).filter(F=>Ae(e,g,F)?!1:!Object.keys(n[g].attrs).includes(F)),xe=await Zi(j,K,s,{type:"attribute",entityName:g});Object.keys(a[g].attrs).filter(F=>Object.keys(n[g].attrs).includes(F)).forEach(F=>{Ae(e,g,F)||i.push(...Gi({attrName:F,namespace:g},a[g].attrs[F],n[g].attrs[F]))}),xe.deleted.forEach(F=>{i.push({type:"delete-attr",identifier:{attrName:F,namespace:g}})}),xe.created.forEach(F=>{const De=t.entities[g].attrs[F];i.push(Ki(De,g,F))}),xe.renamed.forEach(F=>{i.push({type:"update-attr",identifier:{attrName:F.from,namespace:g},partialAttr:{"value-type":"blob",cardinality:"one","forward-identity":{attrName:F.to,namespace:g}}}),i.push(...Gi({attrName:F.from,namespace:g},a[g].attrs[F.from],n[g].attrs[F.to]))})}const f=Object.values(r.links).filter(g=>!Ae(e,g.forward.on,g.forward.label)),d=Object.values(t.links).filter(g=>!Ae(e,g.forward.on,g.forward.label)),P=g=>`${g.forward.on}<->${g.reverse.on}`,S=g=>`${g.forward.on}.${g.forward.label}<->${g.reverse.on}.${g.reverse.label}`,B=new Map,I=new Map;for(const g of d){const j=P(g),K=B.get(j)||[];K.push(g),B.set(j,K)}for(const g of f){const j=P(g),K=I.get(j)||[];K.push(g),I.set(j,K)}const D=new Set([...I.keys(),...B.keys()]);for(const g of D){const j=I.get(g)||[],K=B.get(g)||[],xe=j.map($=>S($)),Pe=K.map($=>S($)),F=Pe.filter($=>!xe.includes($)),De=xe.filter($=>!Pe.includes($));xe.filter($=>Pe.includes($)).forEach($=>{const V=j.find(L=>S(L)===$),X=K.find(L=>S(L)===$);!V||!X||i.push(...Xi({namespace:V.forward.on,attrName:V.forward.label},V,X))});const yt=await Zi(F,De,s,{type:"link",forwardEntityName:(z=j[0])==null?void 0:z.forward.on,reverseEntityName:(oe=j[0])==null?void 0:oe.reverse.on});yt.deleted.forEach($=>{const V=j.find(X=>S(X)===$);V&&i.push({type:"delete-attr",identifier:{attrName:V.forward.label,namespace:V.forward.on}})}),yt.created.forEach($=>{const V=K.find(X=>S(X)===$);V&&i.push(Po(V))}),yt.renamed.forEach($=>{const V=j.find(L=>S(L)===$.from),X=K.find(L=>S(L)===$.to);!V||!X||(i.push({type:"update-attr",identifier:{attrName:V.forward.label,namespace:V.forward.on},partialAttr:{"value-type":"ref",cardinality:X.forward.has==="one"?"one":"many","forward-identity":{attrName:X.forward.label,namespace:X.forward.on},"reverse-identity":{attrName:X.reverse.label,namespace:X.reverse.on}}}),i.push(...Xi({attrName:V.forward.label,namespace:V.forward.on},V,X)))})}return i},Gi=(r,t,s)=>{const e=[],i=a=>{e.push({type:a,identifier:r})};return t.isIndexed===!1&&s.isIndexed===!0&&i("index"),t.isIndexed===!0&&s.isIndexed===!1&&i("remove-index"),t.config.unique===!1&&s.config.unique===!0&&i("unique"),t.config.unique===!0&&s.config.unique===!1&&i("remove-unique"),t.required===!1&&s.required===!0&&i("required"),t.required===!0&&s.required===!1&&i("remove-required"),t.valueType!=="json"&&s.valueType==="json"?e.push({type:"remove-data-type",identifier:r}):t.valueType!==s.valueType&&s.valueType!=="json"&&e.push({type:"check-data-type",identifier:r,"checked-data-type":s.valueType}),e},Xi=(r,t,s)=>{const e=[],i=`${t.forward.has}-${t.reverse.has}`,{cardinality:a,"unique?":n}=Rt[i],o=!!t.forward.required,c=`${s.forward.has}-${s.reverse.has}`,{cardinality:h,"unique?":l}=Rt[c],u=!!s.forward.required;return!n&&l&&e.push({type:"unique",identifier:r}),!l&&l!==n&&e.push({type:"remove-unique",identifier:r}),u!==o&&e.push({type:u?"required":"remove-required",identifier:r}),(t.reverse.onDelete!==s.reverse.onDelete||t.forward.onDelete!==s.forward.onDelete||a!==h)&&e.push({type:"update-attr",identifier:r,partialAttr:{"value-type":"ref","on-delete-reverse":s.reverse.onDelete,"on-delete":s.forward.onDelete,cardinality:h}}),e},Yi=r=>typeof r=="object",Zi=async(r,t,s,e)=>{if(t.length===0||r.length===0)return{created:r,deleted:t,renamed:[]};const i={created:[],renamed:[],deleted:[]};let a=0,n=[...t];do{const o=r[a],c=n.map(u=>({from:u,to:o})),h=[o,...c],l=await s(o,h,e);Yi(l)?(l.from!==l.to&&i.renamed.push(l),delete n[n.indexOf(l.from)],n=n.filter(Boolean)):i.created.push(o),a+=1}while(a<r.length);return i.deleted.push(...n),i};function Qi(r){const[t,s]=r.split(".").map(e=>e.trim());if(!t||!s)throw new Error(`Invalid lookup. Got '${r}'. We expect a pattern like 'entityname.columname;.For example: posts.title`)}function go(r){const t=new Map;for(const s of r){let[e,i]=s.split(":").map(a=>a.trim());if(!e||!i)throw new Error(`Invalid rename command: ${s}. We could not parse a distinct 'from' and 'to'. The structure should look like 'from:to'. For example: 'posts.name:posts.title'`);Qi(e),Qi(i),t.set(i.trim(),e.trim())}return t}function er(r){const t=go(r);return async function(e,i,a){let n=[];if((a==null?void 0:a.type)==="attribute"&&(a!=null&&a.entityName))n=[`${a.entityName}.${e}`];else if((a==null?void 0:a.type)==="link"){const c=e.split("<->");n=[c[0],c[1]]}else return e;let o=null;for(const c of n)if(t.has(c)){o=t.get(c)||null;break}if(o){let c;if((a==null?void 0:a.type)==="attribute")c=o.split(".").pop();else{const l=i.find(u=>{const d=(typeof u=="string"?u:u.from).split("<->");return d[0]===o||d[1]===o});if(l)c=typeof l=="string"?l:l.from;else return e}const h=i.some(l=>typeof l=="string"?l===c:l.from?l.from===c:!1);if(c&&h)return{from:c,to:e}}return e}}async function Z(r,t){const s={...(t==null?void 0:t.headers)||{},"Instant-Platform-Version":me,"Instant-Core-Version":me,"X-Instant-Source":"platform-sdk","X-Instant-Version":me},e=await fetch(r,{...t,headers:s});if(e.status===200){const a=await e.json();return Promise.resolve(a)}const i=await e.text();try{const a=JSON.parse(i);return Promise.reject(new be({status:e.status,body:a}))}catch{return Promise.reject(new be({status:e.status,body:{type:void 0,message:i}}))}}function wo(r){switch(r){case"string":return G.string();case"any":return G.any();case"json":return G.json();case"boolean":return G.boolean();case"date":return G.date();case"number":return G.number();default:{const t=r;throw new Error(`Unknown type ${t}.`)}}}function To(r){const t=zn(r);let s=wo(t.type);return r["unique?"]&&(s=s.unique()),r["index?"]&&(s=s.indexed()),r["required?"]||(s=s.optional()),s.metadata.derivedType=t,s}function Ao(r){const t={};for(const[s,e]of Re(r))s!=="id"&&(t[s]=To(e));return G.entity(t)}function So(r){const[,t,s]=r["forward-identity"];return`${t}${$n(s)}`}function Io(r){const[,t,s]=r["forward-identity"],[,e,i]=r["reverse-identity"],[a,n]=qn[`${r.cardinality}-${r["unique?"]}`];return{forward:{on:t,has:a,label:s,required:r["required?"]||void 0,onDelete:r["on-delete"]==="cascade"?"cascade":void 0},reverse:{on:e,has:n,label:i,onDelete:r["on-delete-reverse"]==="cascade"?"cascade":void 0}}}function tr(r){let t=[];for(const[s,e]of Re(r.blobs))Object.values(e).forEach(i=>{t.push(i)});for(const[s,e]of Re(r.refs))t.push(e);return t}function Je(r){const t={};for(const[e,i]of Re(r.blobs))t[e]=Ao(i);const s={};for(const[e,i]of Re(r.refs)){const a=Io(i),n=So(i);s[n]=a}return G.schema({entities:t,links:s})}function ve(r){const t={id:r.id,title:r.title,createdAt:new Date(r.created_at),orgId:r.org_id,...r["admin-token"]?{adminToken:r["admin-token"]}:{}},s="perms"in r?{perms:r.perms}:{},e="schema"in r?{schema:Je(r.schema)}:{};return{...t,...s,...e}}function Eo(r){return{id:r.id,title:r.title,createdAt:new Date(r.created_at)}}async function Co(r,t,s){const e=new URL(`${r}/superadmin/apps`),i=[];return s!=null&&s.includePerms&&i.push("perms"),s!=null&&s.includeSchema&&i.push("schema"),i.length&&e.searchParams.set("include",i.join(",")),{apps:(await Z(e.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).apps.map(ve)}}async function ko(r,t){const s=new URL(`${r}/superadmin/orgs`);return{orgs:(await Z(s.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).orgs.map(Eo)}}async function No(r,t,s,e){const i=new URL(`${r}/superadmin/orgs/${s}/apps`),a=[];return e!=null&&e.includePerms&&a.push("perms"),e!=null&&e.includeSchema&&a.push("schema"),a.length&&i.searchParams.set("include",a.join(",")),{apps:(await Z(i.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).apps.map(ve)}}async function ks(r,t,s){const{schema:e}=await Z(`${r}/superadmin/apps/${s}/schema`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});return e}async function jt(r,t,s){const e=await ks(r,t,s);return{schema:Je(e)}}async function sr(r,t,s){return await Z(`${r}/superadmin/apps/${s}/perms`,{method:"GET",headers:{Authorization:`Bearer ${t}`}})}async function vo(r,t,s,e){let i=null,a=null;e!=null&&e.includePerms&&(i=sr(r,t,s)),e!=null&&e.includeSchema&&(a=jt(r,t,s));const{app:n}=await Z(`${r}/superadmin/apps/${s}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});return!i&&!a?{app:ve(n)}:{app:{...ve(n),...i?{perms:(await i).perms}:{},...a?{schema:(await a).schema}:{}}}}async function Oo(r,t,s){const e=s;e.org_id=s.orgId;const{app:i}=await Z(`${r}/superadmin/apps`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)});return{app:{...ve(i),adminToken:i["admin-token"]}}}async function Do(r,t){const s=await Z(`${r}/dash/apps/ephemeral`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{app:{...ve(s.app),adminToken:s.app["admin-token"]},expiresMs:s.expires_ms}}async function Lo(r,t,s,e){const{app:i}=await Z(`${r}/superadmin/apps/${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)});return{app:ve(i)}}async function Mo(r,t,s){const{app:e}=await Z(`${r}/superadmin/apps/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});return{app:ve(e)}}function Ns(r,t){const[s,e]=r;switch(s){case"add-attr":{const i=e,a=Mi(i);return{type:"add-attr",friendlyDescription:i["value-type"]==="blob"?Li(i)==="id"?`Create new entity ${a}.`:`Add attribute ${a}.`:`Link ${a} to ${Xn(i)}.`,attr:i}}case"update-attr":{const i=e;return{type:"update-attr",friendlyDescription:`Update attribute ${Mi(i)}.`,attr:i}}case"index":return{type:"index",friendlyDescription:`Add index to ${Te(e["forward-identity"])}.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"remove-index":return{type:"remove-index",friendlyDescription:`Remove index from ${Te(e["forward-identity"])}.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"unique":return{type:"unique",friendlyDescription:`Ensure that ${Te(e["forward-identity"])} is unique.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"remove-unique":return{type:"remove-unique",friendlyDescription:`Remove uniqueness constraint from ${Te(e["forward-identity"])}.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"required":return{type:"required",friendlyDescription:`Make ${Te(e["forward-identity"])} a required attribute.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"remove-required":return{type:"remove-required",friendlyDescription:`Allow ${Te(e["forward-identity"])} to be missing or null.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"check-data-type":{const i=e["forward-identity"],a=e["checked-data-type"];return{type:"check-data-type",friendlyDescription:`Enforce data type of ${Te(i)} as type ${a}.`,attrId:e["attr-id"],forwardIdentity:i,checkedDataType:a}}case"remove-data-type":{const i=e["forward-identity"];return{type:"remove-data-type",friendlyDescription:`Stop enforcing data type of ${Te(i)}.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]}}case"delete-attr":{const i=e,a=t.find(o=>o.id===i),n=a?Te(a["forward-identity"]):i;return{type:"delete-attr",attrId:e,friendlyDescription:`Delete attribute ${n}.`}}default:{const i=s;throw new Error(`Unknown schema operation ${i}.`)}}}function vs(r,t){return r.map(s=>Ns(s,t))}function Fo(r,t,s){const[e,i]=r;if(e==="add-attr"||e==="update-attr"||e==="delete-attr"){const h=Ns(r,s);if(h.type!=="add-attr"&&h.type!=="update-attr"&&h.type!=="delete-attr")throw new Error("Invalid step.");return h}const a=i["job-id"],n=t.find(h=>h.id===a),o=Ns(r,s),c=_o(n);if(o.type!==c.type)throw new Error("Invalid type");return{...o,backgroundJob:c}}function We(r,t,s){return r.map(e=>Fo(e,t,s))}function ir(r){if("renames"in r&&!r.overwrite)throw new Error("If you pass in `renames`, you _must_ pass in `overwrite: true`");return!!r.overwrite}async function Bo(r,t,s,e){const i=await Z(`${r}/superadmin/apps/${s}/schema/push/plan`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({...e,check_types:!0,supports_background_updates:!0})}),a=i["current-attrs"];return{newSchema:Je(i["new-schema"]),currentSchema:Je(i["current-schema"]),steps:vs(i.steps,a)}}async function rr(r,t,s,e){const i=await ks(r,t,s),a=Je(i),n=tr(i),o=Fi(n),c=e.schema;Bi(c,o);const h=("renames"in e?e.renames:null)||[],l=er(h),u=await Wi(a,c,l,o),f=Ji(u,n);return{currentSchema:a,currentAttrs:n,txSteps:f,steps:vs(f,n)}}async function Ro(r,t,s,e){const{currentSchema:i,steps:a}=await rr(r,t,s,e);return{newSchema:e.schema,currentSchema:i,steps:a}}function ar(r){return r.length===0?!0:r.every(t=>t.job_status==="completed"||t.job_status==="errored")}function nr(r){return r.reduce((s,e)=>{if(e.updated_at){const i=new Date(e.updated_at);if(!s||i>s)return i}return s},null)}async function or(r,t,s,e,i,a){let n=100,o=i,c=0;for(;!ar(o);){await new Promise(h=>setTimeout(h,n));try{const h=(await Z(`${r}/dash/apps/${s}/indexing-jobs/group/${e}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}})).jobs;if(a(h),ar(h))return h;c=0;const l=nr(o),u=nr(h);o=h,n=u===null||l&&l>=u?Math.min(n*2,1e4):100}catch(h){if(c>3)throw h;c++,n=Math.min(n*2,1e4)}}return o}function _o(r){var s;const t={id:r.id,createdAt:new Date(r.created_at),updatedAt:new Date(r.updated_at),status:r.job_status,workEstimate:r.work_estimate,workCompleted:r.work_completed,error:r.error,invalidTriplesSample:(s=r.invalid_triples_sample)==null?void 0:s.map(e=>({entityId:e.entity_id,value:e.value,jsonType:e.json_type}))};switch(r.job_type){case"remove-data-type":case"index":case"remove-index":case"required":case"remove-required":case"remove-unique":return{...t,type:r.job_type};case"check-data-type":return{...t,type:r.job_type,checkedDataType:r.checked_data_type};case"unique":return{...t,type:r.job_type,invalidUniqueValue:r.invalid_unique_value};default:{const e=r.job_type;throw new Error(`Unknown job type: ${e}.`)}}}function Ut(r){const t=r.filter(i=>"backgroundJob"in i&&(i.backgroundJob.status==="processing"||i.backgroundJob.status==="waiting")),s=r.filter(i=>!("backgroundJob"in i)||i.backgroundJob.status==="completed"),e=r.filter(i=>"backgroundJob"in i&&i.backgroundJob.status==="errored");return{friendlyDescription:t.length?`Completing ${t.length} of ${r.length} schema operations.`:`Finished ${r.length} schema operation${r.length===1?"":"s"}${e.length?`, with ${e.length} error${e.length>1?"s":""}`:"."}`,totalCount:r.length,inProgressCount:t.length,completedCount:s.length,errorCount:e.length,steps:r,inProgressSteps:t,completedSteps:s,erroredSteps:e}}function jo(r,t,s,e){return new Bt(async(i,a,n)=>{try{const o=await ks(r,t,s),c=tr(o),h=await Z(`${r}/superadmin/apps/${s}/schema/push/apply`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({...e,check_types:!0,supports_background_updates:!0})}),l=h["indexing-jobs"],u=l?await or(r,t,s,l["group-id"],l.jobs,d=>{i(Ut(We(h.steps,d,c)))}):[],f=await jt(r,t,s);a({newSchema:f.schema,steps:We(h.steps,u,c),summary:Ut(We(h.steps,u,c))})}catch(o){n(o)}})}function Uo(r,t,s,e){return new Bt(async(i,a,n)=>{try{const{currentAttrs:o,txSteps:c}=await rr(r,t,s,e),h=await Z(`${r}/dash/apps/${s}/schema/steps/apply`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({steps:c})}),l=h["indexing-jobs"],u=l?await or(r,t,s,l["group-id"],l.jobs,d=>{i(Ut(We(h.steps,d,o)))}):[],f=await jt(r,t,s);a({newSchema:f.schema,steps:We(h.steps,u,o),summary:Ut(We(h.steps,u,o))})}catch(o){n(o)}})}async function $o(r,t,s,e){return{perms:(await Z(`${r}/superadmin/apps/${s}/perms`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({code:e.perms})})).rules.code}}async function qo(r,t){const s=await Z(`${r}/platform/oauth/token-info?access_token=${t}`,{method:"GET"});return{tokenType:s.token_type,scopes:s.scopes,expiresAt:new Date(Date.now()+(s.expires_in-60)*1e3)}}class Ge extends Error{constructor(){super("PlatformApi was not provided auth.")}}class zo{constructor(t){H(this,_);H(this,q);J(this,_,t==null?void 0:t.auth),J(this,q,(t==null?void 0:t.apiURI)||"https://api.instantdb.com")}token(){if(!y(this,_))throw new Ge;return"token"in y(this,_)?y(this,_).token:y(this,_).accessToken}canRefreshToken(){if(!y(this,_))throw new Ge;return"refreshToken"in y(this,_)&&"clientId"in y(this,_)&&"clientSecret"in y(this,_)&&y(this,_).refreshToken!=null&&y(this,_).clientId!=null&&y(this,_).clientSecret!=null}async refreshToken(){if(!y(this,_))throw new Ge;if(!this.canRefreshToken()||!("clientId"in y(this,_)))return null;const t=await Hi({apiURI:y(this,q),clientId:y(this,_).clientId,clientSecret:y(this,_).clientSecret,refreshToken:y(this,_).refreshToken});return y(this,_).accessToken=t.accessToken,y(this,_).onRefresh&&await y(this,_).onRefresh(t),t}async withRetry(t,s){var c,h;let e=0;const[i,a,...n]=s;let o=a;for(;e<2;)try{return await t(i,o,...n)}catch(l){if(l instanceof be&&(l.status===401||((c=l.body)==null?void 0:c.type)==="record-expired"||((h=l.body)==null?void 0:h.type)==="record-not-found"&&l.body.hint["record-type"].match(/token/i))&&this.canRefreshToken()){const u=await this.refreshToken();if(u){o=u.accessToken,e++;continue}}throw l}}async getApp(t,s){return this.withRetry(vo,[y(this,q),this.token(),t,s])}async getApps(t){return this.withRetry(Co,[y(this,q),this.token(),t])}async getOrgs(){return this.withRetry(ko,[y(this,q),this.token()])}async getAppsForOrg(t,s){return this.withRetry(No,[y(this,q),this.token(),t,s])}async getSchema(t){return this.withRetry(jt,[y(this,q),this.token(),t])}async getPerms(t){return this.withRetry(sr,[y(this,q),this.token(),t])}async createApp(t){return this.withRetry(Oo,[y(this,q),this.token(),t])}async createTemporaryApp(t){return Do(y(this,q),t)}async updateApp(t,s){return this.withRetry(Lo,[y(this,q),this.token(),t,s])}async deleteApp(t){return this.withRetry(Mo,[y(this,q),this.token(),t])}async planSchemaPush(t,s){const e=ir(s);return this.withRetry(e?Ro:Bo,[y(this,q),this.token(),t,s])}schemaPush(t,s){if(!y(this,_))throw new Ge;return new Bt(async(e,i,a)=>{try{const o=ir(s)?Uo:jo;if(this.canRefreshToken())try{await this.refreshToken()}catch{}o(y(this,q),this.token(),t,s).subscribe({complete(c){i(c)},error(c){a(c)},next(c){e(c)}})}catch(n){a(n)}})}async pushPerms(t,s){if(!y(this,_))throw new Ge;return this.withRetry($o,[y(this,q),this.token(),t,s])}async tokenInfo(){if(!y(this,_))throw new Ge;return this.withRetry(qo,[y(this,q),this.token()])}webhooks(t,s){const e=i=>this.withRetry((a,n)=>i(n),[y(this,q),this.token()]);return new Ft({appId:t,apiURI:y(this,q),schema:s==null?void 0:s.schema,withAuth:e})}backups(t){const s=e=>this.withRetry((i,a)=>e(a),[y(this,q),this.token()]);return new Vi({appId:t,apiURI:y(this,q),withAuth:s})}}_=new WeakMap,q=new WeakMap;function Vo(r){try{return Buffer.from(r,"base64").toString("utf-8")}catch{return Buffer.from(r,"base64url").toString("utf-8")}}function Ho(r){try{const t=r.split("_"),s=t[t.length-1];return Vo(s).replace("$","")}catch(t){return console.error("Error getting domain from clerk key",t),null}}function cr(r){return`${r.replace(/\/+$/,"")}/runtime/oauth/callback`}const Ko=cr("https://api.instantdb.com"),Jo="https://accounts.google.com/o/oauth2/v2/auth",Wo="https://oauth2.googleapis.com/token",Go="https://accounts.google.com/.well-known/openid-configuration",Xo="https://appleid.apple.com/auth/authorize",Yo="https://appleid.apple.com/auth/token",Zo="https://appleid.apple.com/.well-known/openid-configuration",Qo="https://www.linkedin.com/oauth/v2/authorization",ec="https://www.linkedin.com/oauth/v2/accessToken",tc="https://www.linkedin.com/oauth/.well-known/openid-configuration";b.APPLE_AUTHORIZATION_ENDPOINT=Xo,b.APPLE_DISCOVERY_ENDPOINT=Zo,b.APPLE_TOKEN_ENDPOINT=Yo,b.BackupsManager=Vi,b.DEFAULT_OAUTH_CALLBACK_URL=Ko,b.GOOGLE_AUTHORIZATION_ENDPOINT=Jo,b.GOOGLE_DISCOVERY_ENDPOINT=Go,b.GOOGLE_TOKEN_ENDPOINT=Wo,b.InstantOAuthError=N,b.LINKEDIN_AUTHORIZATION_ENDPOINT=Qo,b.LINKEDIN_DISCOVERY_ENDPOINT=tc,b.LINKEDIN_TOKEN_ENDPOINT=ec,b.OAuthHandler=ea,b.PlatformApi=zo,b.ProgressPromise=Bt,b.SchemaValidationError=Ne,b.Webhooks=Ft,b.WebhooksManager=ji,b.apiSchemaToInstantSchemaDef=Je,b.backupZipName=po,b.buildAutoRenameSelector=er,b.clerkDomainFromPublishableKey=Ho,b.collectSystemCatalogIdentNames=Fi,b.convertTxSteps=Ji,b.diffSchemas=Wi,b.estimateZipSize=mo,b.exchangeCodeForToken=xo,b.exchangeRefreshToken=Hi,b.formatFileSize=fo,b.generatePermsTypescriptFile=_n,b.generateSchemaTypescriptFile=Qn,b.i=G,b.isRenamePromptItem=Yi,b.oauthCallbackURL=cr,b.permsTypescriptFileToCode=Un,b.schemaTypescriptFileToInstantSchema=Rn,b.toAppBackup=$i,b.translatePlanSteps=vs,b.validateSchema=Bi,b.version=me,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
72
+ `)}}const i=e.trim();i.length>0&&(yield JSON.parse(i))}finally{await t.cancel().catch(()=>{})}}class Ji{constructor(t){K(this,et);K(this,Le);K(this,Ze);K(this,Qe);W(this,Le,t.appId),W(this,Ze,t.apiURI),W(this,Qe,t.withAuth)}async list(t){return((await ie(this,et,Kt).call(this,`/dash/apps/${y(this,Le)}/backups`,t==null?void 0:t.signal)).backups||[]).map(Hi)}async listFiles(t,s){return(await ie(this,et,Kt).call(this,`/dash/apps/${y(this,Le)}/backups/${t}/files`,s==null?void 0:s.signal)).files||[]}async getFileUrl(t,s,e){return(await ie(this,et,Kt).call(this,`/dash/apps/${y(this,Le)}/backups/${t}/file-url?name=${encodeURIComponent(s)}`,e==null?void 0:e.signal)).url}async*streamStorageFiles(t,s){const e=await y(this,Qe).call(this,async a=>{const n=await fetch(`${y(this,Ze)}/dash/apps/${y(this,Le)}/backups/${t}/storage-files`,{headers:Ki(a),signal:s==null?void 0:s.signal});if(n.status!==200)throw await Wi(n);return n});if(!e.body)throw new Error("Storage file listing returned no body.");let i=!1;for await(const a of Oo(e.body)){if(a.done===!0){i=!0;break}if(typeof a.locationId!="string"||a.locationId.length===0||/[/\\\u0000-\u001f\u007f]/.test(a.locationId)||a.locationId==="."||a.locationId===".."||typeof a.url!="string"||a.url.length===0)throw new Error("Storage file listing returned a malformed record. Please retry the download.");yield{locationId:a.locationId,path:a.path??null,url:a.url}}if(!i)throw new Error("Storage file listing ended before it finished. Please retry the download.")}downloadArchive(t){return Co({manager:this,...t})}}Le=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,et=new WeakSet,Kt=function(t,s){return y(this,Qe).call(this,async e=>{const i=await fetch(`${y(this,Ze)}${t}`,{headers:Ki(e),signal:s});if(i.status!==200)throw await Wi(i);return i.json()})};class Bt{constructor(t){K(this,pe,[]);K(this,ne,null);K(this,$t,t=>{if(!y(this,ne))for(const s of y(this,pe))try{s.next&&s.next(t)}catch{}});K(this,qt,t=>{if(!y(this,ne)){W(this,ne,{type:"error",error:t});for(const s of y(this,pe))try{s.error&&s.error(t)}catch{}W(this,pe,[])}});K(this,zt,t=>{if(!y(this,ne)){W(this,ne,{type:"complete",result:t});for(const s of y(this,pe))try{s.complete&&s.complete(t)}catch{}W(this,pe,[])}});t(y(this,$t),y(this,zt),y(this,qt))}subscribe(t){if(y(this,ne)){const s={unsubscribe:()=>null};if(y(this,ne).type==="error")return t.error&&t.error(y(this,ne).error),s;if(y(this,ne).type==="complete")return t.complete&&t.complete(y(this,ne).result),s}return y(this,pe).push(t),{unsubscribe:()=>{W(this,pe,y(this,pe).filter(s=>s!==t))}}}then(t,s){this.subscribe({error:s,complete:t})}catch(t){this.subscribe({error:t})}finally(t){this.subscribe({error:()=>t(),complete:()=>t()})}}pe=new WeakMap,ne=new WeakMap,$t=new WeakMap,qt=new WeakMap,zt=new WeakMap;async function Do({code:r,clientId:t,clientSecret:s,redirectUri:e,apiURI:i="https://api.instantdb.com"}){const a=await fetch(`${i}/platform/oauth/token`,{method:"POST",headers:{"Content-type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:r,redirect_uri:e,client_id:t,client_secret:s})});if(!a.ok){const o=await a.text();let c;try{const h=JSON.parse(o);c={error:h.error,errorDescription:h.error_description,message:`OAuth error: ${h.error||"server_error"}`}}catch{c={error:"server_error",message:"OAuth error: server_error"}}throw new N(c)}const n=await a.json();return{accessToken:n.access_token,expiresAt:new Date(Date.now()+(n.expires_in-30)*1e3),refreshToken:n.refresh_token,scopes:n.scopes,tokenType:n.token_type}}async function Gi({clientId:r,clientSecret:t,refreshToken:s,apiURI:e="https://api.instantdb.com"}){const a=await(await fetch(`${e}/platform/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:s,client_id:r,client_secret:t})})).json();return{accessToken:a.access_token,expiresAt:new Date((a.expires_in-30)*1e3),scopes:a.scopes,tokenType:a.token_type}}const Rt={"many-many":{cardinality:"many","unique?":!1},"one-one":{cardinality:"one","unique?":!0},"many-one":{cardinality:"many","unique?":!0},"one-many":{cardinality:"one","unique?":!1}};Object.fromEntries(Object.entries(Rt).map(([r,t])=>[`${t.cardinality}-${t["unique?"]}`,r]));const Xi=(r,t,s)=>({type:"add-attr","unique?":r.config.unique,"value-type":"blob",cardinality:"one",identifier:{namespace:t,attrName:s},"required?":r.required,"forward-identity":{attrName:s,namespace:t},"index?":r.config.indexed,"checked-data-type":r.valueType!=="json"?r.valueType:null}),Lo=r=>{const t=`${r.forward.has}-${r.reverse.has}`;return{"checked-data-type":null,"index?":!1,...Rt[t],"required?":!!r.forward.required,identifier:{attrName:r.forward.label,namespace:r.forward.on},"value-type":"ref",type:"add-attr","forward-identity":{attrName:r.forward.label,namespace:r.forward.on},"on-delete":r.forward.onDelete,"on-delete-reverse":r.reverse.onDelete,"reverse-identity":{attrName:r.reverse.label,namespace:r.reverse.on}}},_t=(r,t)=>{const s=t.find(e=>e["forward-identity"][1]===r.namespace&&e["forward-identity"][2]===r.attrName)||null;if(!s)throw new Error(`Attribute ${r.namespace}.${r.attrName} not found`);return s},je=(r,t)=>{const s=_t(r.identifier,t);return{"attr-id":s.id,"forward-identity":s["forward-identity"]}},Mo={index:je,unique:je,required:je,"remove-index":je,"remove-unique":je,"remove-required":je,"delete-attr":(r,t)=>_t(r.identifier,t).id,"update-attr":(r,t)=>{const s=_t(r.identifier,t);return{id:s.id,"forward-identity":r.partialAttr["forward-identity"]?[s.id,r.partialAttr["forward-identity"].namespace,r.partialAttr["forward-identity"].attrName]:void 0,"reverse-identity":r.partialAttr["reverse-identity"]?[s.id,r.partialAttr["reverse-identity"].namespace,r.partialAttr["reverse-identity"].attrName]:void 0,cardinality:r.partialAttr.cardinality?r.partialAttr.cardinality:void 0,"on-delete":r.partialAttr["on-delete"]?r.partialAttr["on-delete"]:void 0,"on-delete-reverse":r.partialAttr["on-delete-reverse"]?r.partialAttr["on-delete-reverse"]:void 0}},"add-attr":(r,t)=>{const s=Vs(),e=[s,r.identifier.namespace,r.identifier.attrName],i=[];return i.push(["add-attr",{"forward-identity":e,"reverse-identity":r["reverse-identity"]?[Vs(),r["reverse-identity"].namespace,r["reverse-identity"].attrName]:null,"inferred-types":null,"value-type":r["value-type"],id:s,cardinality:r.cardinality,"index?":!1,"required?":!1,"unique?":!1,catalog:"user","on-delete":r["on-delete"],"on-delete-reverse":r["on-delete-reverse"],"checked-data-type":r["checked-data-type"]}]),r["unique?"]&&i.push(["unique",{"attr-id":s,"forward-identity":e}]),r["required?"]&&i.push(["required",{"attr-id":s,"forward-identity":e}]),r["index?"]&&i.push(["index",{"attr-id":s,"forward-identity":e}]),i},"remove-data-type":je,"check-data-type":(r,t)=>{const s=_t(r.identifier,t);return{"attr-id":s.id,"checked-data-type":r["checked-data-type"],"forward-identity":s["forward-identity"]}}};function Ae(r,t,s){var e;return!!((e=r[t])!=null&&e.has(s))}const Yi=(r,t)=>{if(!t)throw new Error("Existing attributes are required");const s=[];return r.forEach(e=>{const i=Mo[e.type];if(!i)throw new Error(`Unknown transaction type: ${e.type}`);const a=i(e,t);Array.isArray(a)?s.push(...a):s.push([e.type,a])}),s},Zi=async(r,t,s,e)=>{var L,fe;const i=[],a=r.entities,n=t.entities,o=Object.keys(a),c=Object.keys(n),h=o.filter(g=>!c.includes(g));for(const g of h)Object.keys(a[g].attrs).forEach(j=>{Ae(e,g,j)||i.push({type:"delete-attr",identifier:{attrName:j,namespace:g}})}),!Ae(e,g,"id")&&i.push({type:"delete-attr",identifier:{attrName:"id",namespace:g}});const l=c.filter(g=>!o.includes(g));for(const g of l){Ae(e,g,"id")||i.push({type:"add-attr","forward-identity":{namespace:g,attrName:"id"},identifier:{attrName:"id",namespace:g},"index?":!1,"required?":!0,cardinality:"one","unique?":!0,"value-type":"blob"});for(const j of Object.keys(n[g].attrs)){if(Ae(e,g,j))continue;const X=n[g].attrs[j];i.push(Xi(X,g,j))}}const u=o.filter(g=>c.includes(g));for(const g of u){const j=Object.keys(n[g].attrs).filter(B=>Ae(e,g,B)?!1:!Object.keys(a[g].attrs).includes(B)),X=Object.keys(a[g].attrs).filter(B=>Ae(e,g,B)?!1:!Object.keys(n[g].attrs).includes(B)),ce=await sr(j,X,s,{type:"attribute",entityName:g});Object.keys(a[g].attrs).filter(B=>Object.keys(n[g].attrs).includes(B)).forEach(B=>{Ae(e,g,B)||i.push(...Qi({attrName:B,namespace:g},a[g].attrs[B],n[g].attrs[B]))}),ce.deleted.forEach(B=>{i.push({type:"delete-attr",identifier:{attrName:B,namespace:g}})}),ce.created.forEach(B=>{const de=t.entities[g].attrs[B];i.push(Xi(de,g,B))}),ce.renamed.forEach(B=>{i.push({type:"update-attr",identifier:{attrName:B.from,namespace:g},partialAttr:{"value-type":"blob",cardinality:"one","forward-identity":{attrName:B.to,namespace:g}}}),i.push(...Qi({attrName:B.from,namespace:g},a[g].attrs[B.from],n[g].attrs[B.to]))})}const f=Object.values(r.links).filter(g=>!Ae(e,g.forward.on,g.forward.label)),d=Object.values(t.links).filter(g=>!Ae(e,g.forward.on,g.forward.label)),P=g=>`${g.forward.on}<->${g.reverse.on}`,S=g=>`${g.forward.on}.${g.forward.label}<->${g.reverse.on}.${g.reverse.label}`,F=new Map,I=new Map;for(const g of d){const j=P(g),X=F.get(j)||[];X.push(g),F.set(j,X)}for(const g of f){const j=P(g),X=I.get(j)||[];X.push(g),I.set(j,X)}const O=new Set([...I.keys(),...F.keys()]);for(const g of O){const j=I.get(g)||[],X=F.get(g)||[],ce=j.map(z=>S(z)),Se=X.map(z=>S(z)),B=Se.filter(z=>!ce.includes(z)),de=ce.filter(z=>!Se.includes(z));ce.filter(z=>Se.includes(z)).forEach(z=>{const V=j.find(Ie=>S(Ie)===z),Z=X.find(Ie=>S(Ie)===z);!V||!Z||i.push(...er({namespace:V.forward.on,attrName:V.forward.label},V,Z))});const tt=await sr(B,de,s,{type:"link",forwardEntityName:(L=j[0])==null?void 0:L.forward.on,reverseEntityName:(fe=j[0])==null?void 0:fe.reverse.on});tt.deleted.forEach(z=>{const V=j.find(Z=>S(Z)===z);V&&i.push({type:"delete-attr",identifier:{attrName:V.forward.label,namespace:V.forward.on}})}),tt.created.forEach(z=>{const V=X.find(Z=>S(Z)===z);V&&i.push(Lo(V))}),tt.renamed.forEach(z=>{const V=j.find(Ie=>S(Ie)===z.from),Z=X.find(Ie=>S(Ie)===z.to);!V||!Z||(i.push({type:"update-attr",identifier:{attrName:V.forward.label,namespace:V.forward.on},partialAttr:{"value-type":"ref",cardinality:Z.forward.has==="one"?"one":"many","forward-identity":{attrName:Z.forward.label,namespace:Z.forward.on},"reverse-identity":{attrName:Z.reverse.label,namespace:Z.reverse.on}}}),i.push(...er({attrName:V.forward.label,namespace:V.forward.on},V,Z)))})}return i},Qi=(r,t,s)=>{const e=[],i=a=>{e.push({type:a,identifier:r})};return t.isIndexed===!1&&s.isIndexed===!0&&i("index"),t.isIndexed===!0&&s.isIndexed===!1&&i("remove-index"),t.config.unique===!1&&s.config.unique===!0&&i("unique"),t.config.unique===!0&&s.config.unique===!1&&i("remove-unique"),t.required===!1&&s.required===!0&&i("required"),t.required===!0&&s.required===!1&&i("remove-required"),t.valueType!=="json"&&s.valueType==="json"?e.push({type:"remove-data-type",identifier:r}):t.valueType!==s.valueType&&s.valueType!=="json"&&e.push({type:"check-data-type",identifier:r,"checked-data-type":s.valueType}),e},er=(r,t,s)=>{const e=[],i=`${t.forward.has}-${t.reverse.has}`,{cardinality:a,"unique?":n}=Rt[i],o=!!t.forward.required,c=`${s.forward.has}-${s.reverse.has}`,{cardinality:h,"unique?":l}=Rt[c],u=!!s.forward.required;return!n&&l&&e.push({type:"unique",identifier:r}),!l&&l!==n&&e.push({type:"remove-unique",identifier:r}),u!==o&&e.push({type:u?"required":"remove-required",identifier:r}),(t.reverse.onDelete!==s.reverse.onDelete||t.forward.onDelete!==s.forward.onDelete||a!==h)&&e.push({type:"update-attr",identifier:r,partialAttr:{"value-type":"ref","on-delete-reverse":s.reverse.onDelete,"on-delete":s.forward.onDelete,cardinality:h}}),e},tr=r=>typeof r=="object",sr=async(r,t,s,e)=>{if(t.length===0||r.length===0)return{created:r,deleted:t,renamed:[]};const i={created:[],renamed:[],deleted:[]};let a=0,n=[...t];do{const o=r[a],c=n.map(u=>({from:u,to:o})),h=[o,...c],l=await s(o,h,e);tr(l)?(l.from!==l.to&&i.renamed.push(l),delete n[n.indexOf(l.from)],n=n.filter(Boolean)):i.created.push(o),a+=1}while(a<r.length);return i.deleted.push(...n),i};function ir(r){const[t,s]=r.split(".").map(e=>e.trim());if(!t||!s)throw new Error(`Invalid lookup. Got '${r}'. We expect a pattern like 'entityname.columname;.For example: posts.title`)}function Fo(r){const t=new Map;for(const s of r){let[e,i]=s.split(":").map(a=>a.trim());if(!e||!i)throw new Error(`Invalid rename command: ${s}. We could not parse a distinct 'from' and 'to'. The structure should look like 'from:to'. For example: 'posts.name:posts.title'`);ir(e),ir(i),t.set(i.trim(),e.trim())}return t}function rr(r){const t=Fo(r);return async function(e,i,a){let n=[];if((a==null?void 0:a.type)==="attribute"&&(a!=null&&a.entityName))n=[`${a.entityName}.${e}`];else if((a==null?void 0:a.type)==="link"){const c=e.split("<->");n=[c[0],c[1]]}else return e;let o=null;for(const c of n)if(t.has(c)){o=t.get(c)||null;break}if(o){let c;if((a==null?void 0:a.type)==="attribute")c=o.split(".").pop();else{const l=i.find(u=>{const d=(typeof u=="string"?u:u.from).split("<->");return d[0]===o||d[1]===o});if(l)c=typeof l=="string"?l:l.from;else return e}const h=i.some(l=>typeof l=="string"?l===c:l.from?l.from===c:!1);if(c&&h)return{from:c,to:e}}return e}}async function Y(r,t){const s={...(t==null?void 0:t.headers)||{},"Instant-Platform-Version":xe,"Instant-Core-Version":xe,"X-Instant-Source":"platform-sdk","X-Instant-Version":xe},e=await fetch(r,{...t,headers:s});if(e.status===200){const a=await e.json();return Promise.resolve(a)}const i=await e.text();try{const a=JSON.parse(i);return Promise.reject(new be({status:e.status,body:a}))}catch{return Promise.reject(new be({status:e.status,body:{type:void 0,message:i}}))}}function Bo(r){switch(r){case"string":return G.string();case"any":return G.any();case"json":return G.json();case"boolean":return G.boolean();case"date":return G.date();case"number":return G.number();default:{const t=r;throw new Error(`Unknown type ${t}.`)}}}function Ro(r){const t=Xn(r);let s=Bo(t.type);return r["unique?"]&&(s=s.unique()),r["index?"]&&(s=s.indexed()),r["required?"]||(s=s.optional()),s.metadata.derivedType=t,s}function _o(r){const t={};for(const[s,e]of _e(r))s!=="id"&&(t[s]=Ro(e));return G.entity(t)}function jo(r){const[,t,s]=r["forward-identity"];return`${t}${Jn(s)}`}function Uo(r){const[,t,s]=r["forward-identity"],[,e,i]=r["reverse-identity"],[a,n]=Gn[`${r.cardinality}-${r["unique?"]}`];return{forward:{on:t,has:a,label:s,required:r["required?"]||void 0,onDelete:r["on-delete"]==="cascade"?"cascade":void 0},reverse:{on:e,has:n,label:i,onDelete:r["on-delete-reverse"]==="cascade"?"cascade":void 0}}}function ar(r){let t=[];for(const[s,e]of _e(r.blobs))Object.values(e).forEach(i=>{t.push(i)});for(const[s,e]of _e(r.refs))t.push(e);return t}function We(r){const t={};for(const[e,i]of _e(r.blobs))t[e]=_o(i);const s={};for(const[e,i]of _e(r.refs)){const a=Uo(i),n=jo(i);s[n]=a}return G.schema({entities:t,links:s})}function De(r){const t={id:r.id,title:r.title,createdAt:new Date(r.created_at),orgId:r.org_id,...r["admin-token"]?{adminToken:r["admin-token"]}:{}},s="perms"in r?{perms:r.perms}:{},e="schema"in r?{schema:We(r.schema)}:{};return{...t,...s,...e}}function $o(r){return{id:r.id,title:r.title,createdAt:new Date(r.created_at)}}async function qo(r,t,s){const e=new URL(`${r}/superadmin/apps`),i=[];return s!=null&&s.includePerms&&i.push("perms"),s!=null&&s.includeSchema&&i.push("schema"),i.length&&e.searchParams.set("include",i.join(",")),{apps:(await Y(e.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).apps.map(De)}}async function zo(r,t){const s=new URL(`${r}/superadmin/orgs`);return{orgs:(await Y(s.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).orgs.map($o)}}async function Vo(r,t,s,e){const i=new URL(`${r}/superadmin/orgs/${s}/apps`),a=[];return e!=null&&e.includePerms&&a.push("perms"),e!=null&&e.includeSchema&&a.push("schema"),a.length&&i.searchParams.set("include",a.join(",")),{apps:(await Y(i.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).apps.map(De)}}async function Ns(r,t,s){const{schema:e}=await Y(`${r}/superadmin/apps/${s}/schema`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});return e}async function jt(r,t,s){const e=await Ns(r,t,s);return{schema:We(e)}}async function nr(r,t,s){return await Y(`${r}/superadmin/apps/${s}/perms`,{method:"GET",headers:{Authorization:`Bearer ${t}`}})}async function Ho(r,t,s,e){let i=null,a=null;e!=null&&e.includePerms&&(i=nr(r,t,s)),e!=null&&e.includeSchema&&(a=jt(r,t,s));const{app:n}=await Y(`${r}/superadmin/apps/${s}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});return!i&&!a?{app:De(n)}:{app:{...De(n),...i?{perms:(await i).perms}:{},...a?{schema:(await a).schema}:{}}}}async function Ko(r,t,s){const e=s;e.org_id=s.orgId;const{app:i}=await Y(`${r}/superadmin/apps`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)});return{app:{...De(i),adminToken:i["admin-token"]}}}async function Wo(r,t){const s=await Y(`${r}/dash/apps/ephemeral`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{app:{...De(s.app),adminToken:s.app["admin-token"]},expiresMs:s.expires_ms}}async function Jo(r,t,s,e){const{app:i}=await Y(`${r}/superadmin/apps/${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)});return{app:De(i)}}async function Go(r,t,s){const{app:e}=await Y(`${r}/superadmin/apps/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});return{app:De(e)}}function vs(r,t){const[s,e]=r;switch(s){case"add-attr":{const i=e,a=Fi(i);return{type:"add-attr",friendlyDescription:i["value-type"]==="blob"?Mi(i)==="id"?`Create new entity ${a}.`:`Add attribute ${a}.`:`Link ${a} to ${io(i)}.`,attr:i}}case"update-attr":{const i=e;return{type:"update-attr",friendlyDescription:`Update attribute ${Fi(i)}.`,attr:i}}case"index":return{type:"index",friendlyDescription:`Add index to ${Te(e["forward-identity"])}.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"remove-index":return{type:"remove-index",friendlyDescription:`Remove index from ${Te(e["forward-identity"])}.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"unique":return{type:"unique",friendlyDescription:`Ensure that ${Te(e["forward-identity"])} is unique.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"remove-unique":return{type:"remove-unique",friendlyDescription:`Remove uniqueness constraint from ${Te(e["forward-identity"])}.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"required":return{type:"required",friendlyDescription:`Make ${Te(e["forward-identity"])} a required attribute.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"remove-required":return{type:"remove-required",friendlyDescription:`Allow ${Te(e["forward-identity"])} to be missing or null.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]};case"check-data-type":{const i=e["forward-identity"],a=e["checked-data-type"];return{type:"check-data-type",friendlyDescription:`Enforce data type of ${Te(i)} as type ${a}.`,attrId:e["attr-id"],forwardIdentity:i,checkedDataType:a}}case"remove-data-type":{const i=e["forward-identity"];return{type:"remove-data-type",friendlyDescription:`Stop enforcing data type of ${Te(i)}.`,attrId:e["attr-id"],forwardIdentity:e["forward-identity"]}}case"delete-attr":{const i=e,a=t.find(o=>o.id===i),n=a?Te(a["forward-identity"]):i;return{type:"delete-attr",attrId:e,friendlyDescription:`Delete attribute ${n}.`}}default:{const i=s;throw new Error(`Unknown schema operation ${i}.`)}}}function Os(r,t){return r.map(s=>vs(s,t))}function Xo(r,t,s){const[e,i]=r;if(e==="add-attr"||e==="update-attr"||e==="delete-attr"){const h=vs(r,s);if(h.type!=="add-attr"&&h.type!=="update-attr"&&h.type!=="delete-attr")throw new Error("Invalid step.");return h}const a=i["job-id"],n=t.find(h=>h.id===a),o=vs(r,s),c=Qo(n);if(o.type!==c.type)throw new Error("Invalid type");return{...o,backgroundJob:c}}function Je(r,t,s){return r.map(e=>Xo(e,t,s))}function or(r){if("renames"in r&&!r.overwrite)throw new Error("If you pass in `renames`, you _must_ pass in `overwrite: true`");return!!r.overwrite}async function Yo(r,t,s,e){const i=await Y(`${r}/superadmin/apps/${s}/schema/push/plan`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({...e,check_types:!0,supports_background_updates:!0})}),a=i["current-attrs"];return{newSchema:We(i["new-schema"]),currentSchema:We(i["current-schema"]),steps:Os(i.steps,a)}}async function cr(r,t,s,e){const i=await Ns(r,t,s),a=We(i),n=ar(i),o=Bi(n),c=e.schema;Ri(c,o);const h=("renames"in e?e.renames:null)||[],l=rr(h),u=await Zi(a,c,l,o),f=Yi(u,n);return{currentSchema:a,currentAttrs:n,txSteps:f,steps:Os(f,n)}}async function Zo(r,t,s,e){const{currentSchema:i,steps:a}=await cr(r,t,s,e);return{newSchema:e.schema,currentSchema:i,steps:a}}function hr(r){return r.length===0?!0:r.every(t=>t.job_status==="completed"||t.job_status==="errored")}function lr(r){return r.reduce((s,e)=>{if(e.updated_at){const i=new Date(e.updated_at);if(!s||i>s)return i}return s},null)}async function ur(r,t,s,e,i,a){let n=100,o=i,c=0;for(;!hr(o);){await new Promise(h=>setTimeout(h,n));try{const h=(await Y(`${r}/dash/apps/${s}/indexing-jobs/group/${e}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}})).jobs;if(a(h),hr(h))return h;c=0;const l=lr(o),u=lr(h);o=h,n=u===null||l&&l>=u?Math.min(n*2,1e4):100}catch(h){if(c>3)throw h;c++,n=Math.min(n*2,1e4)}}return o}function Qo(r){var s;const t={id:r.id,createdAt:new Date(r.created_at),updatedAt:new Date(r.updated_at),status:r.job_status,workEstimate:r.work_estimate,workCompleted:r.work_completed,error:r.error,invalidTriplesSample:(s=r.invalid_triples_sample)==null?void 0:s.map(e=>({entityId:e.entity_id,value:e.value,jsonType:e.json_type}))};switch(r.job_type){case"remove-data-type":case"index":case"remove-index":case"required":case"remove-required":case"remove-unique":return{...t,type:r.job_type};case"check-data-type":return{...t,type:r.job_type,checkedDataType:r.checked_data_type};case"unique":return{...t,type:r.job_type,invalidUniqueValue:r.invalid_unique_value};default:{const e=r.job_type;throw new Error(`Unknown job type: ${e}.`)}}}function Ut(r){const t=r.filter(i=>"backgroundJob"in i&&(i.backgroundJob.status==="processing"||i.backgroundJob.status==="waiting")),s=r.filter(i=>!("backgroundJob"in i)||i.backgroundJob.status==="completed"),e=r.filter(i=>"backgroundJob"in i&&i.backgroundJob.status==="errored");return{friendlyDescription:t.length?`Completing ${t.length} of ${r.length} schema operations.`:`Finished ${r.length} schema operation${r.length===1?"":"s"}${e.length?`, with ${e.length} error${e.length>1?"s":""}`:"."}`,totalCount:r.length,inProgressCount:t.length,completedCount:s.length,errorCount:e.length,steps:r,inProgressSteps:t,completedSteps:s,erroredSteps:e}}function ec(r,t,s,e){return new Bt(async(i,a,n)=>{try{const o=await Ns(r,t,s),c=ar(o),h=await Y(`${r}/superadmin/apps/${s}/schema/push/apply`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({...e,check_types:!0,supports_background_updates:!0})}),l=h["indexing-jobs"],u=l?await ur(r,t,s,l["group-id"],l.jobs,d=>{i(Ut(Je(h.steps,d,c)))}):[],f=await jt(r,t,s);a({newSchema:f.schema,steps:Je(h.steps,u,c),summary:Ut(Je(h.steps,u,c))})}catch(o){n(o)}})}function tc(r,t,s,e){return new Bt(async(i,a,n)=>{try{const{currentAttrs:o,txSteps:c}=await cr(r,t,s,e),h=await Y(`${r}/dash/apps/${s}/schema/steps/apply`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({steps:c})}),l=h["indexing-jobs"],u=l?await ur(r,t,s,l["group-id"],l.jobs,d=>{i(Ut(Je(h.steps,d,o)))}):[],f=await jt(r,t,s);a({newSchema:f.schema,steps:Je(h.steps,u,o),summary:Ut(Je(h.steps,u,o))})}catch(o){n(o)}})}async function sc(r,t,s,e){return{perms:(await Y(`${r}/superadmin/apps/${s}/perms`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({code:e.perms})})).rules.code}}async function ic(r,t){const s=await Y(`${r}/platform/oauth/token-info?access_token=${t}`,{method:"GET"});return{tokenType:s.token_type,scopes:s.scopes,expiresAt:new Date(Date.now()+(s.expires_in-60)*1e3)}}class Ge extends Error{constructor(){super("PlatformApi was not provided auth.")}}class rc{constructor(t){K(this,_);K(this,U);W(this,_,t==null?void 0:t.auth),W(this,U,(t==null?void 0:t.apiURI)||"https://api.instantdb.com")}token(){if(!y(this,_))throw new Ge;return"token"in y(this,_)?y(this,_).token:y(this,_).accessToken}canRefreshToken(){if(!y(this,_))throw new Ge;return"refreshToken"in y(this,_)&&"clientId"in y(this,_)&&"clientSecret"in y(this,_)&&y(this,_).refreshToken!=null&&y(this,_).clientId!=null&&y(this,_).clientSecret!=null}async refreshToken(){if(!y(this,_))throw new Ge;if(!this.canRefreshToken()||!("clientId"in y(this,_)))return null;const t=await Gi({apiURI:y(this,U),clientId:y(this,_).clientId,clientSecret:y(this,_).clientSecret,refreshToken:y(this,_).refreshToken});return y(this,_).accessToken=t.accessToken,y(this,_).onRefresh&&await y(this,_).onRefresh(t),t}async withRetry(t,s){var c,h;let e=0;const[i,a,...n]=s;let o=a;for(;e<2;)try{return await t(i,o,...n)}catch(l){if(l instanceof be&&(l.status===401||((c=l.body)==null?void 0:c.type)==="record-expired"||((h=l.body)==null?void 0:h.type)==="record-not-found"&&l.body.hint["record-type"].match(/token/i))&&this.canRefreshToken()){const u=await this.refreshToken();if(u){o=u.accessToken,e++;continue}}throw l}}async getApp(t,s){return this.withRetry(Ho,[y(this,U),this.token(),t,s])}async getApps(t){return this.withRetry(qo,[y(this,U),this.token(),t])}async getOrgs(){return this.withRetry(zo,[y(this,U),this.token()])}async getAppsForOrg(t,s){return this.withRetry(Vo,[y(this,U),this.token(),t,s])}async getSchema(t){return this.withRetry(jt,[y(this,U),this.token(),t])}async getPerms(t){return this.withRetry(nr,[y(this,U),this.token(),t])}async createApp(t){return this.withRetry(Ko,[y(this,U),this.token(),t])}async createTemporaryApp(t){return Wo(y(this,U),t)}async updateApp(t,s){return this.withRetry(Jo,[y(this,U),this.token(),t,s])}async deleteApp(t){return this.withRetry(Go,[y(this,U),this.token(),t])}async planSchemaPush(t,s){const e=or(s);return this.withRetry(e?Zo:Yo,[y(this,U),this.token(),t,s])}schemaPush(t,s){if(!y(this,_))throw new Ge;return new Bt(async(e,i,a)=>{try{const o=or(s)?tc:ec;if(this.canRefreshToken())try{await this.refreshToken()}catch{}o(y(this,U),this.token(),t,s).subscribe({complete(c){i(c)},error(c){a(c)},next(c){e(c)}})}catch(n){a(n)}})}async pushPerms(t,s){if(!y(this,_))throw new Ge;return this.withRetry(sc,[y(this,U),this.token(),t,s])}async tokenInfo(){if(!y(this,_))throw new Ge;return this.withRetry(ic,[y(this,U),this.token()])}webhooks(t,s){const e=i=>this.withRetry((a,n)=>i(n),[y(this,U),this.token()]);return new Ft({appId:t,apiURI:y(this,U),schema:s==null?void 0:s.schema,withAuth:e})}backups(t){const s=e=>this.withRetry((i,a)=>e(a),[y(this,U),this.token()]);return new Ji({appId:t,apiURI:y(this,U),withAuth:s})}}_=new WeakMap,U=new WeakMap;function ac(r){try{return Buffer.from(r,"base64").toString("utf-8")}catch{return Buffer.from(r,"base64url").toString("utf-8")}}function nc(r){try{const t=r.split("_"),s=t[t.length-1];return ac(s).replace("$","")}catch(t){return console.error("Error getting domain from clerk key",t),null}}function pr(r){return`${r.replace(/\/+$/,"")}/runtime/oauth/callback`}const oc=pr("https://api.instantdb.com"),cc="https://accounts.google.com/o/oauth2/v2/auth",hc="https://oauth2.googleapis.com/token",lc="https://accounts.google.com/.well-known/openid-configuration",uc="https://appleid.apple.com/auth/authorize",pc="https://appleid.apple.com/auth/token",fc="https://appleid.apple.com/.well-known/openid-configuration",dc="https://www.linkedin.com/oauth/v2/authorization",mc="https://www.linkedin.com/oauth/v2/accessToken",yc="https://www.linkedin.com/oauth/.well-known/openid-configuration";b.APPLE_AUTHORIZATION_ENDPOINT=uc,b.APPLE_DISCOVERY_ENDPOINT=fc,b.APPLE_TOKEN_ENDPOINT=pc,b.BackupsManager=Ji,b.DEFAULT_OAUTH_CALLBACK_URL=oc,b.GOOGLE_AUTHORIZATION_ENDPOINT=cc,b.GOOGLE_DISCOVERY_ENDPOINT=lc,b.GOOGLE_TOKEN_ENDPOINT=hc,b.InstantOAuthError=N,b.LINKEDIN_AUTHORIZATION_ENDPOINT=dc,b.LINKEDIN_DISCOVERY_ENDPOINT=yc,b.LINKEDIN_TOKEN_ENDPOINT=mc,b.OAuthHandler=oa,b.PlatformApi=rc,b.ProgressPromise=Bt,b.SchemaValidationError=Oe,b.Webhooks=Ft,b.WebhooksManager=Ui,b.apiSchemaToInstantSchemaDef=We,b.backupZipName=ko,b.buildAutoRenameSelector=rr,b.clerkDomainFromPublishableKey=nc,b.collectSystemCatalogIdentNames=Bi,b.convertTxSteps=Yi,b.diffSchemas=Zi,b.estimateZipSize=vo,b.exchangeCodeForToken=Do,b.exchangeRefreshToken=Gi,b.formatFileSize=No,b.generatePermsTypescriptFile=Hn,b.generateSchemaTypescriptFile=no,b.i=G,b.isRenamePromptItem=tr,b.oauthCallbackURL=pr,b.permsTypescriptFileToCode=Wn,b.schemaTypescriptFileToInstantSchema=Vn,b.toAppBackup=Hi,b.translatePlanSteps=Os,b.validateSchema=Ri,b.version=xe,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});