@instantdb/platform 0.22.99-experimental.add-user-perm-rules.20792844601.1 → 0.22.99

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.
Files changed (48) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/dist/commonjs/ProgressPromise.js +45 -58
  3. package/dist/commonjs/ProgressPromise.js.map +1 -1
  4. package/dist/commonjs/api.js +366 -412
  5. package/dist/commonjs/api.js.map +1 -1
  6. package/dist/commonjs/migrationUtils.js +16 -4
  7. package/dist/commonjs/migrationUtils.js.map +1 -1
  8. package/dist/commonjs/migrations.js +10 -21
  9. package/dist/commonjs/migrations.js.map +1 -1
  10. package/dist/commonjs/oauth.js +52 -55
  11. package/dist/commonjs/oauth.js.map +1 -1
  12. package/dist/commonjs/oauthCommon.js +2 -0
  13. package/dist/commonjs/oauthCommon.js.map +1 -1
  14. package/dist/commonjs/perms.js +1 -1
  15. package/dist/commonjs/perms.js.map +1 -1
  16. package/dist/commonjs/schema.js +8 -14
  17. package/dist/commonjs/schema.js.map +1 -1
  18. package/dist/commonjs/serverOAuth.js +55 -68
  19. package/dist/commonjs/serverOAuth.js.map +1 -1
  20. package/dist/commonjs/typescript-schema.js +1 -2
  21. package/dist/commonjs/typescript-schema.js.map +1 -1
  22. package/dist/commonjs/util.js +1 -1
  23. package/dist/commonjs/util.js.map +1 -1
  24. package/dist/esm/ProgressPromise.js +45 -58
  25. package/dist/esm/ProgressPromise.js.map +1 -1
  26. package/dist/esm/api.js +366 -412
  27. package/dist/esm/api.js.map +1 -1
  28. package/dist/esm/migrationUtils.js +16 -4
  29. package/dist/esm/migrationUtils.js.map +1 -1
  30. package/dist/esm/migrations.js +10 -21
  31. package/dist/esm/migrations.js.map +1 -1
  32. package/dist/esm/oauth.js +52 -55
  33. package/dist/esm/oauth.js.map +1 -1
  34. package/dist/esm/oauthCommon.js +2 -0
  35. package/dist/esm/oauthCommon.js.map +1 -1
  36. package/dist/esm/perms.js +1 -1
  37. package/dist/esm/perms.js.map +1 -1
  38. package/dist/esm/schema.js +8 -14
  39. package/dist/esm/schema.js.map +1 -1
  40. package/dist/esm/serverOAuth.js +55 -68
  41. package/dist/esm/serverOAuth.js.map +1 -1
  42. package/dist/esm/typescript-schema.js +1 -2
  43. package/dist/esm/typescript-schema.js.map +1 -1
  44. package/dist/esm/util.js +1 -1
  45. package/dist/esm/util.js.map +1 -1
  46. package/dist/standalone/index.js +690 -660
  47. package/dist/standalone/index.umd.cjs +16 -16
  48. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- (function(S,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(S=typeof globalThis<"u"?globalThis:S||self,v(S.instant={}))})(this,function(S){"use strict";var Bn=Object.defineProperty;var yi=S=>{throw TypeError(S)};var _n=(S,v,N)=>v in S?Bn(S,v,{enumerable:!0,configurable:!0,writable:!0,value:N}):S[v]=N;var m=(S,v,N)=>_n(S,typeof v!="symbol"?v+"":v,N),xi=(S,v,N)=>v.has(S)||yi("Cannot "+N);var T=(S,v,N)=>(xi(S,v,"read from private field"),N?N.call(S):v.get(S)),xe=(S,v,N)=>v.has(S)?yi("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(S):v.set(S,N),Pe=(S,v,N,Le)=>(xi(S,v,"write to private field"),Le?Le.call(S,N):v.set(S,N),N);var se,Y,ft,dt,mt,F,R;class v extends Error{constructor(t){super(t.message);const s=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,s),Error.captureStackTrace&&Error.captureStackTrace(this,v),this.name="InstantOAuthError",this.error=t.error,this.errorDescription=t.errorDescription}get[Symbol.toStringTag](){return"InstantAPIError"}}const N={Remove:"remove",Replace:"replace",Add:"add"},Le=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),We=Symbol.iterator,Z={mutable:"mutable",immutable:"immutable"},xt={};function Me(r,t){return r instanceof Map?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function as(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 ns(r){return Object.getPrototypeOf(r)===Set.prototype}function os(r){return Object.getPrototypeOf(r)===Map.prototype}function G(r){var t;return(t=r.copy)!==null&&t!==void 0?t:r.original}function Pt(r){return!!L(r)}function L(r){return typeof r!="object"?null:r==null?void 0:r[Le]}function bt(r){var t;const s=L(r);return s?(t=s.copy)!==null&&t!==void 0?t:s.original:r}function be(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,Z))===Z.immutable||typeof s=="function")}function cs(r,t=[]){if(Object.hasOwnProperty.call(r,"key")){const s=r.parent.copy,e=L(he(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||Me(s,a)))return null;t.push(a)}if(r.parent)return cs(r.parent,t);t.reverse();try{Pi(r.copy,t)}catch{return null}return t}function Fe(r){return Array.isArray(r)?1:r instanceof Map?2:r instanceof Set?3:0}function he(r,t){return Fe(r)===2?r.get(t):r[t]}function gt(r,t,s){Fe(r)===2?r.set(t,s):r[t]=s}function wt(r,t){const s=L(r);return(s?G(s):r)[t]}function ge(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t}function we(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 Pi(r,t){for(let s=0;s<t.length-1;s+=1){const e=t[s];if(r=he(Fe(r)===3?Array.from(r):r,e),typeof r!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return r}function bi(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 gi=Object.prototype.propertyIsEnumerable;function wi(r,t){let s;if(Array.isArray(r))return Array.prototype.concat.call(r);if(r instanceof Set){if(!ns(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(!os(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,Z),s!==void 0)&&s!==Z.mutable){if(s===Z.immutable)return bi(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=>{gi.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 H(r){r.copy||(r.copy=wi(r.original,r.options))}function Be(r){if(!be(r))return bt(r);if(Array.isArray(r))return r.map(Be);if(r instanceof Map){const s=Array.from(r.entries()).map(([e,i])=>[e,Be(i)]);if(!os(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(Be);if(!ns(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]=Be(r[s]);return t}function Xe(r){return Pt(r)?Be(r):r}function ie(r){var t;r.assignedMap=(t=r.assignedMap)!==null&&t!==void 0?t:new Map,r.operated||(r.operated=!0,r.parent&&ie(r.parent))}function Ti(r,t){const s=Fe(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 hs(r,t,s){if(Pt(r)||!be(r,s)||t.has(r)||Object.isFrozen(r))return;const e=r instanceof Set,i=e?new Map:void 0;if(t.add(r),Ti(r,(a,n)=>{var o;if(Pt(n)){const c=L(n);H(c);const h=!((o=c.assignedMap)===null||o===void 0)&&o.size||c.operated?c.copy:c.original;gt(e?i:r,a,h)}else hs(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 Ai(r,t){const s=r.type===3?r.setMap:r.copy;r.finalities.revoke.length>1&&r.assignedMap.get(t)&&s&&hs(he(s,t),r.finalities.handledSet,r.options)}function Tt(r){r.type===3&&r.copy&&(r.copy.clear(),r.setMap.forEach(t=>{r.copy.add(bt(t))}))}function At(r,t,s,e){if(r.operated&&r.assignedMap&&r.assignedMap.size>0&&!r.finalized){if(s&&e){const a=cs(r);a&&t(r,a,s,e)}r.finalized=!0}}function St(r,t,s,e){const i=L(s);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((a,n)=>{var o;const c=r.type===3?r.setMap:r.copy;if(ge(he(c,t),s)){let h=i.original;i.copy&&(h=i.copy),Tt(r),At(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)),gt(c,t,h)}}),r.options.enableAutoFreeze&&i.finalities!==r.finalities&&(r.options.enableAutoFreeze=!1)),be(s,r.options)&&r.finalities.draft.push(()=>{const a=r.type===3?r.setMap:r.copy;ge(he(a,t),s)&&Ai(r,t)})}function Si(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=we(l,i);s.push({op:N.Replace,path:u,value:Xe(c[h])}),e.push({op:N.Replace,path:u,value:Xe(a[h])})}for(let h=a.length;h<c.length;h+=1){const l=t.concat([h]),u=we(l,i);s.push({op:N.Add,path:u,value:Xe(c[h])})}if(a.length<c.length){const{arrayLengthAssignment:h=!0}=o.enablePatches;if(h){const l=t.concat(["length"]),u=we(l,i);e.push({op:N.Replace,path:u,value:a.length})}else for(let l=c.length;a.length<l;l-=1){const u=t.concat([l-1]),d=we(u,i);e.push({op:N.Remove,path:d})}}}function Ii({original:r,copy:t,assignedMap:s},e,i,a,n){s.forEach((o,c)=>{const h=he(r,c),l=Xe(he(t,c)),u=o?Me(r,c)?N.Replace:N.Add:N.Remove;if(ge(h,l)&&u===N.Replace)return;const d=e.concat(c),f=we(d,n);i.push(u===N.Remove?{op:u,path:f}:{op:u,path:f,value:l}),a.push(u===N.Add?{op:N.Remove,path:f}:u===N.Remove?{op:N.Add,path:f,value:h}:{op:N.Replace,path:f,value:h})})}function Ei({original:r,copy:t},s,e,i,a){let n=0;r.forEach(o=>{if(!t.has(o)){const c=s.concat([n]),h=we(c,a);e.push({op:N.Remove,path:h,value:o}),i.unshift({op:N.Add,path:h,value:o})}n+=1}),n=0,t.forEach(o=>{if(!r.has(o)){const c=s.concat([n]),h=we(c,a);e.push({op:N.Add,path:h,value:o}),i.unshift({op:N.Remove,path:h,value:o})}n+=1})}function _e(r,t,s,e){const{pathAsArray:i=!0}=r.options.enablePatches;switch(r.type){case 0:case 2:return Ii(r,t,s,e,i);case 1:return Si(r,t,s,e,i);case 3:return Ei(r,t,s,e,i)}}const Ge=(r,t,s=!1)=>{if(typeof r=="object"&&r!==null&&(!be(r,t)||s))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},It={get size(){return G(L(this)).size},has(r){return G(L(this)).has(r)},set(r,t){const s=L(this),e=G(s);return(!e.has(r)||!ge(e.get(r),t))&&(H(s),ie(s),s.assignedMap.set(r,!0),s.copy.set(r,t),St(s,r,t,_e)),this},delete(r){if(!this.has(r))return!1;const t=L(this);return H(t),ie(t),t.original.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.copy.delete(r),!0},clear(){const r=L(this);if(this.size){H(r),ie(r),r.assignedMap=new Map;for(const[t]of r.original)r.assignedMap.set(t,!1);r.copy.clear()}},forEach(r,t){const s=L(this);G(s).forEach((e,i)=>{r.call(t,this.get(i),i,this)})},get(r){var t,s;const e=L(this),i=G(e).get(r),a=((s=(t=e.options).mark)===null||s===void 0?void 0:s.call(t,i,Z))===Z.mutable;if(e.options.strict&&Ge(i,e.options,a),a||e.finalized||!be(i,e.options)||i!==e.original.get(r))return i;const n=xt.createDraft({original:i,parentDraft:e,key:r,finalities:e.finalities,options:e.options});return H(e),e.copy.set(r,n),n},keys(){return G(L(this)).keys()},values(){const r=this.keys();return{[We]:()=>this.values(),next:()=>{const t=r.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const r=this.keys();return{[We]:()=>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]}}}},[We](){return this.entries()}},Ci=Reflect.ownKeys(It),ls=(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=L(o),h=((i=(e=r.options).mark)===null||i===void 0?void 0:i.call(e,o,Z))===Z.mutable;if(r.options.strict&&Ge(n,r.options,h),!h&&!c&&be(n,r.options)&&!r.finalized&&r.original.has(n)){const l=xt.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]}},Ye={get size(){return L(this).setMap.size},has(r){const t=L(this);if(t.setMap.has(r))return!0;H(t);const s=L(r);return!!(s&&t.setMap.has(s.original))},add(r){const t=L(this);return this.has(r)||(H(t),ie(t),t.assignedMap.set(r,!0),t.setMap.set(r,r),St(t,r,r,_e)),this},delete(r){if(!this.has(r))return!1;const t=L(this);H(t),ie(t);const s=L(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=L(this);H(r),ie(r);for(const t of r.original)r.assignedMap.set(t,!1);r.setMap.clear()},values(){const r=L(this);H(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:ls(r,t,{isValuesIterator:!0})}},entries(){const r=L(this);H(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:ls(r,t,{isValuesIterator:!1})}},keys(){return this.values()},[We](){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(Ye,{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 Ni=Reflect.ownKeys(Ye),us=new WeakSet,ps={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===Le)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,Z),n===Z.mutable)return r.options.strict&&Ge(h,r.options,!0),h}const o=G(r);if(o instanceof Map&&Ci.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(It,"size").get.call(r.proxy);const h=It[t];if(h)return h.bind(r.proxy)}if(o instanceof Set&&Ni.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Ye,"size").get.call(r.proxy);const h=Ye[t];if(h)return h.bind(r.proxy)}if(!Me(o,t)){const h=as(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&&Ge(c,r.options),r.finalized||!be(c,r.options))return c;if(c===wt(r.original,t)){if(H(r),r.copy[t]=fs({original:r.original[t],parentDraft:r,key:r.type===1?Number(t):t,finalities:r.finalities,options:r.options}),typeof n=="function"){const h=L(r.copy[t]);return H(h),ie(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=as(G(r),t);if(a!=null&&a.set)return a.set.call(r.proxy,s),!0;const n=wt(G(r),t),o=L(n);return o&&ge(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):(ge(s,n)&&(s!==void 0||Me(r.original,t))||(H(r),ie(r),Me(r.original,t)&&ge(s,r.original[t])?r.assignedMap.delete(t):r.assignedMap.set(t,!0),r.copy[t]=s,St(r,t,s,_e)),!0)},has(r,t){return t in G(r)},ownKeys(r){return Reflect.ownKeys(G(r))},getOwnPropertyDescriptor(r,t){const s=G(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?ps.set.call(this,r,t,void 0,r.proxy):(wt(r.original,t)!==void 0||t in r.original?(H(r),ie(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 fs(r){const{original:t,parentDraft:s,key:e,finalities:i,options:a}=r,n=Fe(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,ps);if(i.revoke.push(h),us.add(c),o.proxy=c,s){const l=s;l.finalities.draft.push((u,d)=>{var f,x;const A=L(c);let j=l.type===3?l.setMap:l.copy;const C=he(j,e),D=L(C);if(D){let U=D.original;D.operated&&(U=bt(C)),Tt(D),At(D,_e,u,d),l.options.enableAutoFreeze&&(l.options.updatedValues=(f=l.options.updatedValues)!==null&&f!==void 0?f:new WeakMap,l.options.updatedValues.set(U,D.original)),gt(j,e,U)}(x=A.callbacks)===null||x===void 0||x.forEach(U=>{U(u,d)})})}else{const l=L(c);l.finalities.draft.push((u,d)=>{Tt(l),At(l,_e,u,d)})}return c}xt.createDraft=fs,Object.prototype.constructor.toString();const z=[];for(let r=0;r<256;++r)z.push((r+256).toString(16).slice(1));function ki(r,t=0){return(z[r[t+0]]+z[r[t+1]]+z[r[t+2]]+z[r[t+3]]+"-"+z[r[t+4]]+z[r[t+5]]+"-"+z[r[t+6]]+z[r[t+7]]+"-"+z[r[t+8]]+z[r[t+9]]+"-"+z[r[t+10]]+z[r[t+11]]+z[r[t+12]]+z[r[t+13]]+z[r[t+14]]+z[r[t+15]]).toLowerCase()}let Et;const vi=new Uint8Array(16);function Oi(){if(!Et){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Et=crypto.getRandomValues.bind(crypto)}return Et(vi)}const ds={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Di(r,t,s){var i;if(ds.randomUUID&&!r)return ds.randomUUID();r=r||{};const e=r.random??((i=r.rng)==null?void 0:i.call(r))??Oi();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,ki(e)}function ms(){return Di()}function Li(r,t){return r.localeCompare(t)}function Mi(){let r=Li;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{r=Intl.Collator("en-US").compare}catch{}return r}Mi();function Fi(){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 Bi=Fi();function Ct(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(Bi.has(a))return(n,o)=>Ct(r,t,[...s,o?[a,r,t,n,o]:[a,r,t,n]])}})}function _i(r){return r.startsWith("lookup__")}function Ri(r){const[t,s,...e]=r.split("__");return[s,JSON.parse(e.join("__"))]}function ji(r){return new Proxy({__etype:r},{get(t,s){if(s==="__etype")return r;const e=s;return _i(e)?Ct(r,Ri(e),[]):Ct(r,e,[])}})}function Ui(){return new Proxy({},{get(r,t){return ji(t)}})}Ui(),Object.assign(Object.assign({},{"unique?":!0,"index?":!0}),{cardinality:"one"});class Nt extends Error{constructor(t,s){super(t),this.hint=s;const e=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,Nt),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class Re extends Nt{constructor(t){var s;const e=((s=t.body)===null||s===void 0?void 0:s.message)||`API Error (${t.status})`;super(e,t.body.hint);const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,Re),this.name="InstantAPIError",this.status=t.status,this.body=t.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 Ee="v0.22.99-experimental.add-user-perm-rules.20792844601.1";class ee{constructor(t,s,e,i={indexed:!1,unique:!1}){this.valueType=t,this.required=s,this.isIndexed=e,this.config=i,this.metadata={}}clientRequired(){return new ee(this.valueType,!1,this.isIndexed,this.config)}optional(){return new ee(this.valueType,!1,this.isIndexed,this.config)}unique(){return new ee(this.valueType,this.required,this.isIndexed,Object.assign(Object.assign({},this.config),{unique:!0}))}indexed(){return new ee(this.valueType,this.required,!0,Object.assign(Object.assign({},this.config),{indexed:!0}))}}class Qe{constructor(t,s){this.attrs=t,this.links=s}asType(){return new Qe(this.attrs,this.links)}}class Ze{constructor(t,s,e){this.entities=t,this.links=s,this.rooms=e}withRoomSchema(){return new Ze(this.entities,this.links,{})}}var ys;(function(r){r.InitialSyncBatch="InitialSyncBatch",r.InitialSyncComplete="InitialSyncComplete",r.LoadFromStorage="LoadFromStorage",r.SyncTransaction="SyncTransaction",r.Error="Error"})(ys||(ys={}));function $i(r,t){return new Ze(xs(r,t),t,void 0)}function qi(r){return new Qe(r,{})}function zi(){return new ee("string",!0,!1)}function Vi(){return new ee("number",!0,!1)}function Hi(){return new ee("boolean",!0,!1)}function Ki(){return new ee("date",!0,!1)}function Ji(){return new ee("json",!0,!1)}function Wi(){return new ee("json",!0,!1)}function xs(r,t){var s,e,i,a;const n={fwd:{},rev:{}};for(const c of Object.values(t))(s=n.fwd)[e=c.forward.on]||(s[e]={}),(i=n.rev)[a=c.reverse.on]||(i[a]={}),n.fwd[c.forward.on][c.forward.label]={entityName:c.reverse.on,cardinality:c.forward.has},n.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 Qe(h.attrs,Object.assign(Object.assign({},n.fwd[c]),n.rev[c]))]))}function Xi({entities:r,links:t,rooms:s}){const e=t??{},i=s??{};return new Ze(xs(r,e),e,i)}const V={graph:$i,schema:Xi,entity:qi,string:zi,number:Vi,boolean:Hi,date:Ki,json:Ji,any:Wi};function Gi(){var r;return globalThis.__instantDbSchemaHashStore=(r=globalThis.__instantDbSchemaHashStore)!==null&&r!==void 0?r:new WeakMap,globalThis.__instantDbSchemaHashStore}function Yi(){var r;return globalThis.__instantDbStore=(r=globalThis.__instantDbStore)!==null&&r!==void 0?r:{},globalThis.__instantDbStore}Yi(),Gi();function Qi(){const r="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._~";let t="";for(const s of crypto.getRandomValues(new Uint8Array(64)))t=t+r[s%r.length];return t}function Zi(r){return crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(r))}function er(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function tr(r){return Zi(r).then(t=>er(btoa(String.fromCharCode(...Array.from(new Uint8Array(t))))))}function sr(){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 Ps=null;function ir({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 rr({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":Ee,"Instant-Core-Version":Ee},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 v(c)}const n=await a.json();return{token:n.access_token,expiresAt:new Date(Date.now()+(n.expires_in-30)*1e3)}}function ar(){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 nr({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=Ps;i&&i.close();const a=crypto.randomUUID(),n=Qi(),o=new BroadcastChannel(a),c=new Promise((l,u)=>{o.addEventListener("message",async d=>{if(d.data.type!=="oauth-redirect")return;const{state:f,error:x,code:A,errorDescription:j}=d.data;if(!(!f||f!==a)){if(A)try{const C=await rr({clientId:r,code:A,verifier:n,apiURI:t,redirectUri:s});l(C)}catch(C){C instanceof v&&u(C),u(new v({error:"server_error",message:"OAuth error exchanging code for token"}))}else u(typeof x=="string"?new v({error:x,errorDescription:j,message:`OAuth error: ${x}`}):new v({error:"server_error",message:"OAuth error: server_error"}));o.postMessage({type:"oauth-redirect-window-done"})}})}),h=window.open("",`instantdb_oauth_${Math.random()}`.replace(".",""),sr());return h?(Ps=h,tr(n).then(l=>{const u=ir({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 or{constructor(t){this.redirectUri=t.redirectUri,this.apiURI=t.apiURI??"https://api.instantdb.com",this.clientId=t.clientId}startClientOnlyFlow(t){return nr({clientId:this.clientId,apiURI:this.apiURI,redirectUri:this.redirectUri,scopes:t})}handleClientRedirect(){return ar()}}function cr(r,t){const s=r&&Object.keys(r).length?JSON.stringify(r,null,2):`{
1
+ (function(S,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(S=typeof globalThis<"u"?globalThis:S||self,v(S.instant={}))})(this,function(S){"use strict";var Bn=Object.defineProperty;var yi=S=>{throw TypeError(S)};var Rn=(S,v,N)=>v in S?Bn(S,v,{enumerable:!0,configurable:!0,writable:!0,value:N}):S[v]=N;var m=(S,v,N)=>Rn(S,typeof v!="symbol"?v+"":v,N),xi=(S,v,N)=>v.has(S)||yi("Cannot "+N);var w=(S,v,N)=>(xi(S,v,"read from private field"),N?N.call(S):v.get(S)),xe=(S,v,N)=>v.has(S)?yi("Cannot add the same private member more than once"):v instanceof WeakSet?v.add(S):v.set(S,N),Pe=(S,v,N,Le)=>(xi(S,v,"write to private field"),Le?Le.call(S,N):v.set(S,N),N);var se,Y,ft,dt,mt,F,j;class v 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,v),this.name="InstantOAuthError",this.error=s.error,this.errorDescription=s.errorDescription}get[Symbol.toStringTag](){return"InstantAPIError"}}const N={Remove:"remove",Replace:"replace",Add:"add"},Le=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),We=Symbol.iterator,Z={mutable:"mutable",immutable:"immutable"},xt={};function Me(r,t){return r instanceof Map?r.has(t):Object.prototype.hasOwnProperty.call(r,t)}function as(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 ns(r){return Object.getPrototypeOf(r)===Set.prototype}function os(r){return Object.getPrototypeOf(r)===Map.prototype}function G(r){var t;return(t=r.copy)!==null&&t!==void 0?t:r.original}function Pt(r){return!!L(r)}function L(r){return typeof r!="object"?null:r==null?void 0:r[Le]}function gt(r){var t;const s=L(r);return s?(t=s.copy)!==null&&t!==void 0?t:s.original:r}function ge(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,Z))===Z.immutable||typeof s=="function")}function cs(r,t=[]){if(Object.hasOwnProperty.call(r,"key")){const s=r.parent.copy,e=L(he(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||Me(s,a)))return null;t.push(a)}if(r.parent)return cs(r.parent,t);t.reverse();try{Pi(r.copy,t)}catch{return null}return t}function Fe(r){return Array.isArray(r)?1:r instanceof Map?2:r instanceof Set?3:0}function he(r,t){return Fe(r)===2?r.get(t):r[t]}function bt(r,t,s){Fe(r)===2?r.set(t,s):r[t]=s}function Tt(r,t){const s=L(r);return(s?G(s):r)[t]}function be(r,t){return r===t?r!==0||1/r===1/t:r!==r&&t!==t}function Te(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 Pi(r,t){for(let s=0;s<t.length-1;s+=1){const e=t[s];if(r=he(Fe(r)===3?Array.from(r):r,e),typeof r!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return r}function gi(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 bi=Object.prototype.propertyIsEnumerable;function Ti(r,t){let s;if(Array.isArray(r))return Array.prototype.concat.call(r);if(r instanceof Set){if(!ns(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(!os(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,Z),s!==void 0)&&s!==Z.mutable){if(s===Z.immutable)return gi(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=>{bi.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 H(r){r.copy||(r.copy=Ti(r.original,r.options))}function Be(r){if(!ge(r))return gt(r);if(Array.isArray(r))return r.map(Be);if(r instanceof Map){const s=Array.from(r.entries()).map(([e,i])=>[e,Be(i)]);if(!os(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(Be);if(!ns(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]=Be(r[s]);return t}function Xe(r){return Pt(r)?Be(r):r}function ie(r){var t;r.assignedMap=(t=r.assignedMap)!==null&&t!==void 0?t:new Map,r.operated||(r.operated=!0,r.parent&&ie(r.parent))}function wi(r,t){const s=Fe(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 hs(r,t,s){if(Pt(r)||!ge(r,s)||t.has(r)||Object.isFrozen(r))return;const e=r instanceof Set,i=e?new Map:void 0;if(t.add(r),wi(r,(a,n)=>{var o;if(Pt(n)){const c=L(n);H(c);const h=!((o=c.assignedMap)===null||o===void 0)&&o.size||c.operated?c.copy:c.original;bt(e?i:r,a,h)}else hs(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 Ai(r,t){const s=r.type===3?r.setMap:r.copy;r.finalities.revoke.length>1&&r.assignedMap.get(t)&&s&&hs(he(s,t),r.finalities.handledSet,r.options)}function wt(r){r.type===3&&r.copy&&(r.copy.clear(),r.setMap.forEach(t=>{r.copy.add(gt(t))}))}function At(r,t,s,e){if(r.operated&&r.assignedMap&&r.assignedMap.size>0&&!r.finalized){if(s&&e){const a=cs(r);a&&t(r,a,s,e)}r.finalized=!0}}function St(r,t,s,e){const i=L(s);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push((a,n)=>{var o;const c=r.type===3?r.setMap:r.copy;if(be(he(c,t),s)){let h=i.original;i.copy&&(h=i.copy),wt(r),At(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)),bt(c,t,h)}}),r.options.enableAutoFreeze&&i.finalities!==r.finalities&&(r.options.enableAutoFreeze=!1)),ge(s,r.options)&&r.finalities.draft.push(()=>{const a=r.type===3?r.setMap:r.copy;be(he(a,t),s)&&Ai(r,t)})}function Si(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]),p=Te(l,i);s.push({op:N.Replace,path:p,value:Xe(c[h])}),e.push({op:N.Replace,path:p,value:Xe(a[h])})}for(let h=a.length;h<c.length;h+=1){const l=t.concat([h]),p=Te(l,i);s.push({op:N.Add,path:p,value:Xe(c[h])})}if(a.length<c.length){const{arrayLengthAssignment:h=!0}=o.enablePatches;if(h){const l=t.concat(["length"]),p=Te(l,i);e.push({op:N.Replace,path:p,value:a.length})}else for(let l=c.length;a.length<l;l-=1){const p=t.concat([l-1]),d=Te(p,i);e.push({op:N.Remove,path:d})}}}function Ii({original:r,copy:t,assignedMap:s},e,i,a,n){s.forEach((o,c)=>{const h=he(r,c),l=Xe(he(t,c)),p=o?Me(r,c)?N.Replace:N.Add:N.Remove;if(be(h,l)&&p===N.Replace)return;const d=e.concat(c),f=Te(d,n);i.push(p===N.Remove?{op:p,path:f}:{op:p,path:f,value:l}),a.push(p===N.Add?{op:N.Remove,path:f}:p===N.Remove?{op:N.Add,path:f,value:h}:{op:N.Replace,path:f,value:h})})}function Ei({original:r,copy:t},s,e,i,a){let n=0;r.forEach(o=>{if(!t.has(o)){const c=s.concat([n]),h=Te(c,a);e.push({op:N.Remove,path:h,value:o}),i.unshift({op:N.Add,path:h,value:o})}n+=1}),n=0,t.forEach(o=>{if(!r.has(o)){const c=s.concat([n]),h=Te(c,a);e.push({op:N.Add,path:h,value:o}),i.unshift({op:N.Remove,path:h,value:o})}n+=1})}function Re(r,t,s,e){const{pathAsArray:i=!0}=r.options.enablePatches;switch(r.type){case 0:case 2:return Ii(r,t,s,e,i);case 1:return Si(r,t,s,e,i);case 3:return Ei(r,t,s,e,i)}}const Ge=(r,t,s=!1)=>{if(typeof r=="object"&&r!==null&&(!ge(r,t)||s))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},It={get size(){return G(L(this)).size},has(r){return G(L(this)).has(r)},set(r,t){const s=L(this),e=G(s);return(!e.has(r)||!be(e.get(r),t))&&(H(s),ie(s),s.assignedMap.set(r,!0),s.copy.set(r,t),St(s,r,t,Re)),this},delete(r){if(!this.has(r))return!1;const t=L(this);return H(t),ie(t),t.original.has(r)?t.assignedMap.set(r,!1):t.assignedMap.delete(r),t.copy.delete(r),!0},clear(){const r=L(this);if(this.size){H(r),ie(r),r.assignedMap=new Map;for(const[t]of r.original)r.assignedMap.set(t,!1);r.copy.clear()}},forEach(r,t){const s=L(this);G(s).forEach((e,i)=>{r.call(t,this.get(i),i,this)})},get(r){var t,s;const e=L(this),i=G(e).get(r),a=((s=(t=e.options).mark)===null||s===void 0?void 0:s.call(t,i,Z))===Z.mutable;if(e.options.strict&&Ge(i,e.options,a),a||e.finalized||!ge(i,e.options)||i!==e.original.get(r))return i;const n=xt.createDraft({original:i,parentDraft:e,key:r,finalities:e.finalities,options:e.options});return H(e),e.copy.set(r,n),n},keys(){return G(L(this)).keys()},values(){const r=this.keys();return{[We]:()=>this.values(),next:()=>{const t=r.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const r=this.keys();return{[We]:()=>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]}}}},[We](){return this.entries()}},Ci=Reflect.ownKeys(It),ls=(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=L(o),h=((i=(e=r.options).mark)===null||i===void 0?void 0:i.call(e,o,Z))===Z.mutable;if(r.options.strict&&Ge(n,r.options,h),!h&&!c&&ge(n,r.options)&&!r.finalized&&r.original.has(n)){const l=xt.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]}},Ye={get size(){return L(this).setMap.size},has(r){const t=L(this);if(t.setMap.has(r))return!0;H(t);const s=L(r);return!!(s&&t.setMap.has(s.original))},add(r){const t=L(this);return this.has(r)||(H(t),ie(t),t.assignedMap.set(r,!0),t.setMap.set(r,r),St(t,r,r,Re)),this},delete(r){if(!this.has(r))return!1;const t=L(this);H(t),ie(t);const s=L(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=L(this);H(r),ie(r);for(const t of r.original)r.assignedMap.set(t,!1);r.setMap.clear()},values(){const r=L(this);H(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:ls(r,t,{isValuesIterator:!0})}},entries(){const r=L(this);H(r);const t=r.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:ls(r,t,{isValuesIterator:!1})}},keys(){return this.values()},[We](){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(Ye,{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 Ni=Reflect.ownKeys(Ye),us=new WeakSet,ps={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===Le)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,Z),n===Z.mutable)return r.options.strict&&Ge(h,r.options,!0),h}const o=G(r);if(o instanceof Map&&Ci.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(It,"size").get.call(r.proxy);const h=It[t];if(h)return h.bind(r.proxy)}if(o instanceof Set&&Ni.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(Ye,"size").get.call(r.proxy);const h=Ye[t];if(h)return h.bind(r.proxy)}if(!Me(o,t)){const h=as(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&&Ge(c,r.options),r.finalized||!ge(c,r.options))return c;if(c===Tt(r.original,t)){if(H(r),r.copy[t]=fs({original:r.original[t],parentDraft:r,key:r.type===1?Number(t):t,finalities:r.finalities,options:r.options}),typeof n=="function"){const h=L(r.copy[t]);return H(h),ie(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=as(G(r),t);if(a!=null&&a.set)return a.set.call(r.proxy,s),!0;const n=Tt(G(r),t),o=L(n);return o&&be(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):(be(s,n)&&(s!==void 0||Me(r.original,t))||(H(r),ie(r),Me(r.original,t)&&be(s,r.original[t])?r.assignedMap.delete(t):r.assignedMap.set(t,!0),r.copy[t]=s,St(r,t,s,Re)),!0)},has(r,t){return t in G(r)},ownKeys(r){return Reflect.ownKeys(G(r))},getOwnPropertyDescriptor(r,t){const s=G(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?ps.set.call(this,r,t,void 0,r.proxy):(Tt(r.original,t)!==void 0||t in r.original?(H(r),ie(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 fs(r){const{original:t,parentDraft:s,key:e,finalities:i,options:a}=r,n=Fe(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,ps);if(i.revoke.push(h),us.add(c),o.proxy=c,s){const l=s;l.finalities.draft.push((p,d)=>{var f,x;const A=L(c);let _=l.type===3?l.setMap:l.copy;const C=he(_,e),O=L(C);if(O){let U=O.original;O.operated&&(U=gt(C)),wt(O),At(O,Re,p,d),l.options.enableAutoFreeze&&(l.options.updatedValues=(f=l.options.updatedValues)!==null&&f!==void 0?f:new WeakMap,l.options.updatedValues.set(U,O.original)),bt(_,e,U)}(x=A.callbacks)===null||x===void 0||x.forEach(U=>{U(p,d)})})}else{const l=L(c);l.finalities.draft.push((p,d)=>{wt(l),At(l,Re,p,d)})}return c}xt.createDraft=fs,Object.prototype.constructor.toString();const z=[];for(let r=0;r<256;++r)z.push((r+256).toString(16).slice(1));function ki(r,t=0){return(z[r[t+0]]+z[r[t+1]]+z[r[t+2]]+z[r[t+3]]+"-"+z[r[t+4]]+z[r[t+5]]+"-"+z[r[t+6]]+z[r[t+7]]+"-"+z[r[t+8]]+z[r[t+9]]+"-"+z[r[t+10]]+z[r[t+11]]+z[r[t+12]]+z[r[t+13]]+z[r[t+14]]+z[r[t+15]]).toLowerCase()}let Et;const vi=new Uint8Array(16);function Di(){if(!Et){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Et=crypto.getRandomValues.bind(crypto)}return Et(vi)}const ds={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Oi(r,t,s){var i;if(ds.randomUUID&&!r)return ds.randomUUID();r=r||{};const e=r.random??((i=r.rng)==null?void 0:i.call(r))??Di();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,ki(e)}function ms(){return Oi()}function Li(r,t){return r.localeCompare(t)}function Mi(){let r=Li;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{r=Intl.Collator("en-US").compare}catch{}return r}Mi();function Fi(){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 Bi=Fi();function Ct(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(Bi.has(a))return(n,o)=>Ct(r,t,[...s,o?[a,r,t,n,o]:[a,r,t,n]])}})}function Ri(r){return r.startsWith("lookup__")}function ji(r){const[t,s,...e]=r.split("__");return[s,JSON.parse(e.join("__"))]}function _i(r){return new Proxy({__etype:r},{get(t,s){if(s==="__etype")return r;const e=s;return Ri(e)?Ct(r,ji(e),[]):Ct(r,e,[])}})}function Ui(){return new Proxy({},{get(r,t){return _i(t)}})}Ui();class Nt extends Error{constructor(s,e){super(s);m(this,"hint");this.hint=e;const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,Nt),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class je extends Nt{constructor(s){var a;const e=((a=s.body)==null?void 0:a.message)||`API Error (${s.status})`;super(e,s.body.hint);m(this,"body");m(this,"status");const i=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,i),Error.captureStackTrace&&Error.captureStackTrace(this,je),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 Ee="v0.22.99";class ee{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 ee(this.valueType,!1,this.isIndexed,this.config)}optional(){return new ee(this.valueType,!1,this.isIndexed,this.config)}unique(){return new ee(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new ee(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class Qe{constructor(t,s){m(this,"attrs");m(this,"links");this.attrs=t,this.links=s}asType(){return new Qe(this.attrs,this.links)}}class Ze{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 Ze(this.entities,this.links,{})}}var ys;(function(r){r.InitialSyncBatch="InitialSyncBatch",r.InitialSyncComplete="InitialSyncComplete",r.LoadFromStorage="LoadFromStorage",r.SyncTransaction="SyncTransaction",r.Error="Error"})(ys||(ys={}));function $i(r,t){return new Ze(xs(r,t),t,void 0)}function qi(r){return new Qe(r,{})}function zi(){return new ee("string",!0,!1)}function Vi(){return new ee("number",!0,!1)}function Hi(){return new ee("boolean",!0,!1)}function Ki(){return new ee("date",!0,!1)}function Ji(){return new ee("json",!0,!1)}function Wi(){return new ee("json",!0,!1)}function xs(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 Qe(h.attrs,{...s.fwd[c],...s.rev[c]})]))}function Xi({entities:r,links:t,rooms:s}){const e=t??{},i=s??{};return new Ze(xs(r,e),e,i)}const V={graph:$i,schema:Xi,entity:qi,string:zi,number:Vi,boolean:Hi,date:Ki,json:Ji,any:Wi};function Gi(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function Yi(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}Yi(),Gi();function Qi(){const r="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz-._~";let t="";for(const s of crypto.getRandomValues(new Uint8Array(64)))t=t+r[s%r.length];return t}function Zi(r){return crypto.subtle.digest({name:"SHA-256"},new TextEncoder().encode(r))}function er(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function tr(r){return Zi(r).then(t=>er(btoa(String.fromCharCode(...Array.from(new Uint8Array(t))))))}function sr(){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 Ps=null;function ir({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 rr({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":Ee,"Instant-Core-Version":Ee},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 v(c)}const n=await a.json();return{token:n.access_token,expiresAt:new Date(Date.now()+(n.expires_in-30)*1e3)}}function ar(){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 nr({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=Ps;i&&i.close();const a=crypto.randomUUID(),n=Qi(),o=new BroadcastChannel(a),c=new Promise((l,p)=>{o.addEventListener("message",async d=>{if(d.data.type!=="oauth-redirect")return;const{state:f,error:x,code:A,errorDescription:_}=d.data;if(!(!f||f!==a)){if(A)try{const C=await rr({clientId:r,code:A,verifier:n,apiURI:t,redirectUri:s});l(C)}catch(C){C instanceof v&&p(C),p(new v({error:"server_error",message:"OAuth error exchanging code for token"}))}else p(typeof x=="string"?new v({error:x,errorDescription:_,message:`OAuth error: ${x}`}):new v({error:"server_error",message:"OAuth error: server_error"}));o.postMessage({type:"oauth-redirect-window-done"})}})}),h=window.open("",`instantdb_oauth_${Math.random()}`.replace(".",""),sr());return h?(Ps=h,tr(n).then(l=>{const p=ir({clientId:r,state:a,codeChallenge:l,apiURI:t,redirectUri:s,scopes:e});h.location.href=p}),c.finally(()=>o.close())):Promise.reject({error:"Could not open Auth window"})}class or{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 nr({clientId:this.clientId,apiURI:this.apiURI,redirectUri:this.redirectUri,scopes:t})}handleClientRedirect(){return ar()}}function cr(r,t){const s=r&&Object.keys(r).length?JSON.stringify(r,null,2):`{
2
2
  /**
3
3
  * Welcome to Instant's permission system!
4
4
  * Right now your rules are empty. To start filling them in, check out the docs:
@@ -23,25 +23,25 @@ import type { InstantRules } from "${t??"@instantdb/core"}";
23
23
  const rules = ${s} satisfies InstantRules;
24
24
 
25
25
  export default rules;
26
- `}function je(r){return Object.entries(r).sort(([t],[s])=>t.localeCompare(s))}function hr(r){return r.charAt(0).toUpperCase()+r.slice(1)}const lr={"many-false":["many","many"],"one-true":["one","one"],"many-true":["many","one"],"one-false":["one","many"]};function Ue(r,t=2){if(!r)return r;const s=" ".repeat(t);return r.split(`
26
+ `}function _e(r){return Object.entries(r).sort(([t],[s])=>t.localeCompare(s))}function hr(r){return r.charAt(0).toUpperCase()+r.slice(1)}const lr={"many-false":["many","many"],"one-true":["one","one"],"many-true":["many","one"],"one-false":["one","many"]};function Ue(r,t=2){if(!r)return r;const s=" ".repeat(t);return r.split(`
27
27
  `).map(e=>`${s}${e}`).join(`
28
- `)}function bs(r,t,s=t){const e=r.join(t);return r.length?e+s:e}function ur(r){if(r.catalog==="system")return null;const t=r["inferred-types"];return(t==null?void 0:t.length)===1?t[0]:null}function pr(r,t){if(r["checked-data-type"])return{type:r["checked-data-type"],origin:"checked"};const s=ur(r);return s&&!t?{type:s,origin:"inferred"}:{type:"any",origin:"unknown"}}function kt(r){return`"${r}"`}function fr([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`${kt(r)}: i.${s}()${e}${i}${a}`}function vt(r,t){const s=bs(je(t.attrs).map(fr),`,
28
+ `)}function gs(r,t,s=t){const e=r.join(t);return r.length?e+s:e}function ur(r){if(r.catalog==="system")return null;const t=r["inferred-types"];return(t==null?void 0:t.length)===1?t[0]:null}function pr(r,t){if(r["checked-data-type"])return{type:r["checked-data-type"],origin:"checked"};const s=ur(r);return s&&!t?{type:s,origin:"inferred"}:{type:"any",origin:"unknown"}}function kt(r){return`"${r}"`}function fr([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`${kt(r)}: i.${s}()${e}${i}${a}`}function vt(r,t){const s=gs(_e(t.attrs).map(fr),`,
29
29
  `,",");return`${kt(r)}: i.entity({${s.length?`
30
30
  `:""}${Ue(s,2)}${s.length?`
31
- `:""}})`}function dr(r){return r[1]}function mr(r){return r[2]}function le(r){return`${dr(r)}.${mr(r)}`}function gs(r){var t;return(t=r["forward-identity"])==null?void 0:t[2]}function yr(r){var t;return(t=r["forward-identity"])==null?void 0:t[1]}function xr(r){var t;return(t=r["reverse-identity"])==null?void 0:t[2]}function Pr(r){var t;return(t=r["reverse-identity"])==null?void 0:t[1]}function ws(r){return`${yr(r)}.${gs(r)}`}function br(r){if(r["reverse-identity"])return`${Pr(r)}.${xr(r)}`}function gr(r,t){return t===1?r:r+"s"}function wr(r){let t="{";if(r.presence&&(t+=`
31
+ `:""}})`}function dr(r){return r[1]}function mr(r){return r[2]}function le(r){return`${dr(r)}.${mr(r)}`}function bs(r){var t;return(t=r["forward-identity"])==null?void 0:t[2]}function yr(r){var t;return(t=r["forward-identity"])==null?void 0:t[1]}function xr(r){var t;return(t=r["reverse-identity"])==null?void 0:t[2]}function Pr(r){var t;return(t=r["reverse-identity"])==null?void 0:t[1]}function Ts(r){return`${yr(r)}.${bs(r)}`}function gr(r){if(r["reverse-identity"])return`${Pr(r)}.${xr(r)}`}function br(r,t){return t===1?r:r+"s"}function Tr(r){let t="{";if(r.presence&&(t+=`
32
32
  ${Ue(vt("presence",r.presence),4)},`),r.topics){t+=`
33
33
  "topics": {`;for(const[s,e]of Object.entries(r.topics))t+=`
34
34
  ${Ue(vt(s,e),6)},`;t+=`
35
35
  }`}return t+=t==="{"?"}":`
36
- }`,t}function Tr(r){let t="{";for(const[s,e]of Object.entries(r))t+=`
37
- ${kt(s)}: ${wr(e)},`;return t+=t==="{"?"}":`
38
- }`,t}function Ar(r,t,s){var d;const e=bs(je(t.entities).map(([f,x])=>vt(f,x)),`,
36
+ }`,t}function wr(r){let t="{";for(const[s,e]of Object.entries(r))t+=`
37
+ ${kt(s)}: ${Tr(e)},`;return t+=t==="{"?"}":`
38
+ }`,t}function Ar(r,t,s){var d;const e=gs(_e(t.entities).map(([f,x])=>vt(f,x)),`,
39
39
  `,","),i=[];for(const f of Object.values(t.entities))for(const x of Object.values(f.attrs))((d=x.metadata.derivedType)==null?void 0:d.origin)==="inferred"&&i.push(x);const a=`{
40
40
  ${Ue(e,2)}
41
- }`,n=i.length>0?`// We inferred ${i.length} ${gr("attribute",i.length)}!
41
+ }`,n=i.length>0?`// We inferred ${i.length} ${br("attribute",i.length)}!
42
42
  // Take a look at this schema, and if everything looks good,
43
- // run \`push schema\` again to enforce the types.`:"",o=JSON.stringify(t.links,null,2).trim(),c=(r==null?void 0:r.rooms)||{},h=Tr(c),l=(f,x,A)=>{const j=A?`${A}
44
- ${f}: ${x}`:`${f}: ${x}`;return Ue(j,2)};return`// Docs: https://www.instantdb.com/docs/modeling-data
43
+ // run \`push schema\` again to enforce the types.`:"",o=JSON.stringify(t.links,null,2).trim(),c=(r==null?void 0:r.rooms)||{},h=wr(c),l=(f,x,A)=>{const _=A?`${A}
44
+ ${f}: ${x}`:`${f}: ${x}`;return Ue(_,2)};return`// Docs: https://www.instantdb.com/docs/modeling-data
45
45
 
46
46
  import { i } from "${s??"@instantdb/core"}";
47
47
 
@@ -63,11 +63,11 @@ You can't create '${e}'. Perhaps call it '${e.slice(1)}' instead?`);for(const[a,
63
63
  Make sure to set ${e}.${a} as optional.
64
64
  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 ue(`The ${e.forward.on} namespace is managed by the system and can't modify required constraints yet.
65
65
  Make sure to set ${e.forward.on}${e.forward.label} as 'optional'.
66
- i.e { 'on': '${e.forward.on}', 'label': ${e.forward.label}, 'required': false }`);if(e.forward.has==="many"&&e.forward.onDelete==="cascade")throw new ue(`${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 ue(`${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 ue(`${i} connects to non existing entity "${e.forward.on}".`);if(!s.includes(e.reverse.on))throw new ue(`${i} connects to non existing entity "${e.forward.on}".`)}};class Ot{constructor(t){xe(this,se,[]);xe(this,Y,null);xe(this,ft,t=>{if(!T(this,Y))for(const s of T(this,se))try{s.next&&s.next(t)}catch{}});xe(this,dt,t=>{if(!T(this,Y)){Pe(this,Y,{type:"error",error:t});for(const s of T(this,se))try{s.error&&s.error(t)}catch{}Pe(this,se,[])}});xe(this,mt,t=>{if(!T(this,Y)){Pe(this,Y,{type:"complete",result:t});for(const s of T(this,se))try{s.complete&&s.complete(t)}catch{}Pe(this,se,[])}});t(T(this,ft),T(this,mt),T(this,dt))}subscribe(t){if(T(this,Y)){const s={unsubscribe:()=>null};if(T(this,Y).type==="error")return t.error&&t.error(T(this,Y).error),s;if(T(this,Y).type==="complete")return t.complete&&t.complete(T(this,Y).result),s}return T(this,se).push(t),{unsubscribe:()=>{Pe(this,se,T(this,se).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()})}}se=new WeakMap,Y=new WeakMap,ft=new WeakMap,dt=new WeakMap,mt=new WeakMap;async function Ir({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 v(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 Ts({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}}async function K(r,t){const s={...(t==null?void 0:t.headers)||{},"Instant-Platform-Version":Ee,"Instant-Core-Version":Ee,"X-Instant-Source":"platform-sdk","X-Instant-Version":Ee},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 Re({status:e.status,body:a}))}catch{return Promise.reject(new Re({status:e.status,body:{type:void 0,message:i}}))}}function Er(r){switch(r){case"string":return V.string();case"any":return V.any();case"json":return V.json();case"boolean":return V.boolean();case"date":return V.date();case"number":return V.number();default:{const t=r;throw new Error(`Unknown type ${t}.`)}}}function Cr(r,t){const s=pr(r,t==null?void 0:t.disableTypeInference);let e=Er(s.type);return r["unique?"]&&(e=e.unique()),r["index?"]&&(e=e.indexed()),r["required?"]||(e=e.optional()),e.metadata.derivedType=s,e}function Nr(r,t){const s={};for(const[e,i]of je(r))e!=="id"&&(s[e]=Cr(i,t));return V.entity(s)}function kr(r){const[,t,s]=r["forward-identity"];return`${t}${hr(s)}`}function vr(r){const[,t,s]=r["forward-identity"],[,e,i]=r["reverse-identity"],[a,n]=lr[`${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 $e(r,t){const s={};for(const[i,a]of je(r.blobs))s[i]=Nr(a,t);const e={};for(const[i,a]of je(r.refs)){const n=vr(a),o=kr(a);e[o]=n}return V.schema({entities:s,links:e})}function pe(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:$e(r.schema)}:{};return{...t,...s,...e}}function Or(r){return{id:r.id,title:r.title,createdAt:new Date(r.created_at)}}async function Dr(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 K(e.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).apps.map(pe)}}async function Lr(r,t){const s=new URL(`${r}/superadmin/orgs`);return{orgs:(await K(s.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).orgs.map(Or)}}async function Mr(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 K(i.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).apps.map(pe)}}async function Dt(r,t,s){const{schema:e}=await K(`${r}/superadmin/apps/${s}/schema`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});return{schema:$e(e)}}async function As(r,t,s){return await K(`${r}/superadmin/apps/${s}/perms`,{method:"GET",headers:{Authorization:`Bearer ${t}`}})}async function Fr(r,t,s,e){let i=null,a=null;e!=null&&e.includePerms&&(i=As(r,t,s)),e!=null&&e.includeSchema&&(a=Dt(r,t,s));const{app:n}=await K(`${r}/superadmin/apps/${s}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});return!i&&!a?{app:pe(n)}:{app:{...pe(n),...i?{perms:(await i).perms}:{},...a?{schema:(await a).schema}:{}}}}async function Br(r,t,s){const e=s;e.org_id=s.orgId;const{app:i}=await K(`${r}/superadmin/apps`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)});return{app:{...pe(i),adminToken:i["admin-token"]}}}async function _r(r,t){const s=await K(`${r}/dash/apps/ephemeral`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{app:{...pe(s.app),adminToken:s.app["admin-token"]},expiresMs:s.expires_ms}}async function Rr(r,t,s,e){const{app:i}=await K(`${r}/superadmin/apps/${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)});return{app:pe(i)}}async function jr(r,t,s){const{app:e}=await K(`${r}/superadmin/apps/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});return{app:pe(e)}}function Lt(r){const[t,s]=r;switch(t){case"add-attr":{const e=s,i=ws(e);return{type:"add-attr",friendlyDescription:e["value-type"]==="blob"?gs(e)==="id"?`Create new entity ${i}.`:`Add attribute ${i}.`:`Link ${i} to ${br(e)}.`,attr:e}}case"update-attr":{const e=s;return{type:"update-attr",friendlyDescription:`Update attribute ${ws(e)}.`,attr:e}}case"index":return{type:"index",friendlyDescription:`Add index to ${le(s["forward-identity"])}.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"remove-index":return{type:"remove-index",friendlyDescription:`Remove index from ${le(s["forward-identity"])}.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"unique":return{type:"unique",friendlyDescription:`Ensure that ${le(s["forward-identity"])} is unique.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"remove-unique":return{type:"remove-unique",friendlyDescription:`Remove uniqueness constarint from ${le(s["forward-identity"])}.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"required":return{type:"required",friendlyDescription:`Make ${le(s["forward-identity"])} a required attribute.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"remove-required":return{type:"remove-required",friendlyDescription:`Allow ${le(s["forward-identity"])} to be missing or null.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"check-data-type":{const e=s["forward-identity"],i=s["checked-data-type"];return{type:"check-data-type",friendlyDescription:`Enforce data type of ${le(e)} as type ${i}.`,attrId:s["attr-id"],forwardIdentity:e,checkedDataType:i}}case"remove-data-type":{const e=s["forward-identity"];return{type:"remove-data-type",friendlyDescription:`Stop enforcing data type of ${le(e)}.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]}}case"delete-attr":return{type:"delete-attr",attrId:s,friendlyDescription:`Delete attribute ${s}.`};default:{const e=t;throw new Error(`Uknown schema operation ${e}.`)}}}function Ss(r){return r.map(t=>Lt(t))}function Ur(r,t){const[s,e]=r;if(s==="add-attr"||s==="update-attr"){const c=Lt(r);if(c.type!=="add-attr"&&c.type!=="update-attr")throw new Error("Invalid step.");return c}const i=e["job-id"],a=t.find(c=>c.id===i),n=Lt(r),o=zr(a);if(n.type!==o.type)throw new Error("Invalid type");return{...n,backgroundJob:o}}function Mt(r,t){return r.map(s=>Ur(s,t))}async function $r(r,t,s,e){const i=await K(`${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})});return{newSchema:$e(i["new-schema"]),currentSchema:$e(i["current-schema"]),steps:Ss(i.steps)}}function Is(r){return!!r.find(t=>t.job_status==="completed"||t.job_status==="errored")}function Es(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 qr(r,t,s,e,i,a){let n=100,o=i,c=0;for(;!Is(o);){await new Promise(h=>setTimeout(h,n));try{const h=(await K(`${r}/dash/apps/${s}/indexing-jobs/group/${e}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}})).jobs;if(a(h),Is(h))return h;c=0;const l=Es(o),u=Es(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 zr(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 Cs(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 Vr(r,t,s,e){return new Ot(async(i,a,n)=>{try{const o=await K(`${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})}),c=o["indexing-jobs"],h=c?await qr(r,t,s,c["group-id"],c.jobs,u=>{i(Cs(Mt(o.steps,u)))}):[],l=await Dt(r,t,s);a({newSchema:l.schema,steps:Mt(o.steps,h),summary:Cs(Mt(o.steps,h))})}catch(o){n(o)}})}async function Hr(r,t,s,e){return{perms:(await K(`${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 Kr(r,t){const s=await K(`${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 Ce extends Error{constructor(){super("PlatformApi was not provided auth.")}}class Jr{constructor(t){xe(this,F);xe(this,R);Pe(this,F,t==null?void 0:t.auth),Pe(this,R,(t==null?void 0:t.apiURI)||"https://api.instantdb.com")}token(){if(!T(this,F))throw new Ce;return"token"in T(this,F)?T(this,F).token:T(this,F).accessToken}canRefreshToken(){if(!T(this,F))throw new Ce;return"refreshToken"in T(this,F)&&"clientId"in T(this,F)&&"clientSecret"in T(this,F)&&T(this,F).refreshToken!=null&&T(this,F).clientId!=null&&T(this,F).clientSecret!=null}async refreshToken(){if(!T(this,F))throw new Ce;if(!this.canRefreshToken()||!("clientId"in T(this,F)))return null;const t=await Ts({apiURI:T(this,R),clientId:T(this,F).clientId,clientSecret:T(this,F).clientSecret,refreshToken:T(this,F).refreshToken});return T(this,F).accessToken=t.accessToken,T(this,F).onRefresh&&await T(this,F).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 Re&&(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(Fr,[T(this,R),this.token(),t,s])}async getApps(t){return this.withRetry(Dr,[T(this,R),this.token(),t])}async getOrgs(){return this.withRetry(Lr,[T(this,R),this.token()])}async getAppsForOrg(t,s){return this.withRetry(Mr,[T(this,R),this.token(),t,s])}async getSchema(t){return this.withRetry(Dt,[T(this,R),this.token(),t])}async getPerms(t){return this.withRetry(As,[T(this,R),this.token(),t])}async createApp(t){return this.withRetry(Br,[T(this,R),this.token(),t])}async createTemporaryApp(t){return _r(T(this,R),t)}async updateApp(t,s){return this.withRetry(Rr,[T(this,R),this.token(),t,s])}async deleteApp(t){return this.withRetry(jr,[T(this,R),this.token(),t])}async planSchemaPush(t,s){return this.withRetry($r,[T(this,R),this.token(),t,s])}schemaPush(t,s){if(!T(this,F))throw new Ce;return new Ot(async(e,i,a)=>{if(this.canRefreshToken())try{await this.refreshToken()}catch{}Vr(T(this,R),this.token(),t,s).subscribe({complete(n){i(n)},error(n){a(n)},next(n){e(n)}})})}async pushPerms(t,s){if(!T(this,F))throw new Ce;return this.withRetry(Hr,[T(this,R),this.token(),t,s])}async tokenInfo(){if(!T(this,F))throw new Ce;return this.withRetry(Kr,[T(this,R),this.token()])}}F=new WeakMap,R=new WeakMap;function Wr(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 fe{constructor(t,s,e){m(this,"line");m(this,"column");m(this,"index");this.line=t,this.column=s,this.index=e}}class et{constructor(t,s){m(this,"start");m(this,"end");m(this,"filename");m(this,"identifierName");this.start=t,this.end=s}}function Q(r,t){const{line:s,column:e,index:i}=r;return new fe(s,e+t,i+t)}const Ns="BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";var Xr={ImportMetaOutsideModule:{message:`import.meta may appear only with 'sourceType: "module"'`,code:Ns},ImportOutsideModule:{message:`'import' and 'export' may appear only with 'sourceType: "module"'`,code:Ns}};const ks={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"},tt=r=>r.type==="UpdateExpression"?ks.UpdateExpression[`${r.prefix}`]:ks[r.type];var Gr={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\`.
66
+ i.e { 'on': '${e.forward.on}', 'label': ${e.forward.label}, 'required': false }`);if(e.forward.has==="many"&&e.forward.onDelete==="cascade")throw new ue(`${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 ue(`${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 ue(`${i} connects to non existing entity "${e.forward.on}".`);if(!s.includes(e.reverse.on))throw new ue(`${i} connects to non existing entity "${e.forward.on}".`)}};class Dt{constructor(t){xe(this,se,[]);xe(this,Y,null);xe(this,ft,t=>{if(!w(this,Y))for(const s of w(this,se))try{s.next&&s.next(t)}catch{}});xe(this,dt,t=>{if(!w(this,Y)){Pe(this,Y,{type:"error",error:t});for(const s of w(this,se))try{s.error&&s.error(t)}catch{}Pe(this,se,[])}});xe(this,mt,t=>{if(!w(this,Y)){Pe(this,Y,{type:"complete",result:t});for(const s of w(this,se))try{s.complete&&s.complete(t)}catch{}Pe(this,se,[])}});t(w(this,ft),w(this,mt),w(this,dt))}subscribe(t){if(w(this,Y)){const s={unsubscribe:()=>null};if(w(this,Y).type==="error")return t.error&&t.error(w(this,Y).error),s;if(w(this,Y).type==="complete")return t.complete&&t.complete(w(this,Y).result),s}return w(this,se).push(t),{unsubscribe:()=>{Pe(this,se,w(this,se).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()})}}se=new WeakMap,Y=new WeakMap,ft=new WeakMap,dt=new WeakMap,mt=new WeakMap;async function Ir({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 v(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 ws({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}}async function K(r,t){const s={...(t==null?void 0:t.headers)||{},"Instant-Platform-Version":Ee,"Instant-Core-Version":Ee,"X-Instant-Source":"platform-sdk","X-Instant-Version":Ee},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 je({status:e.status,body:a}))}catch{return Promise.reject(new je({status:e.status,body:{type:void 0,message:i}}))}}function Er(r){switch(r){case"string":return V.string();case"any":return V.any();case"json":return V.json();case"boolean":return V.boolean();case"date":return V.date();case"number":return V.number();default:{const t=r;throw new Error(`Unknown type ${t}.`)}}}function Cr(r,t){const s=pr(r,t==null?void 0:t.disableTypeInference);let e=Er(s.type);return r["unique?"]&&(e=e.unique()),r["index?"]&&(e=e.indexed()),r["required?"]||(e=e.optional()),e.metadata.derivedType=s,e}function Nr(r,t){const s={};for(const[e,i]of _e(r))e!=="id"&&(s[e]=Cr(i,t));return V.entity(s)}function kr(r){const[,t,s]=r["forward-identity"];return`${t}${hr(s)}`}function vr(r){const[,t,s]=r["forward-identity"],[,e,i]=r["reverse-identity"],[a,n]=lr[`${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 $e(r,t){const s={};for(const[i,a]of _e(r.blobs))s[i]=Nr(a,t);const e={};for(const[i,a]of _e(r.refs)){const n=vr(a),o=kr(a);e[o]=n}return V.schema({entities:s,links:e})}function pe(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:$e(r.schema)}:{};return{...t,...s,...e}}function Dr(r){return{id:r.id,title:r.title,createdAt:new Date(r.created_at)}}async function Or(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 K(e.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).apps.map(pe)}}async function Lr(r,t){const s=new URL(`${r}/superadmin/orgs`);return{orgs:(await K(s.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).orgs.map(Dr)}}async function Mr(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 K(i.toString(),{method:"GET",headers:{Authorization:`Bearer ${t}`}})).apps.map(pe)}}async function Ot(r,t,s){const{schema:e}=await K(`${r}/superadmin/apps/${s}/schema`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});return{schema:$e(e)}}async function As(r,t,s){return await K(`${r}/superadmin/apps/${s}/perms`,{method:"GET",headers:{Authorization:`Bearer ${t}`}})}async function Fr(r,t,s,e){let i=null,a=null;e!=null&&e.includePerms&&(i=As(r,t,s)),e!=null&&e.includeSchema&&(a=Ot(r,t,s));const{app:n}=await K(`${r}/superadmin/apps/${s}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}});return!i&&!a?{app:pe(n)}:{app:{...pe(n),...i?{perms:(await i).perms}:{},...a?{schema:(await a).schema}:{}}}}async function Br(r,t,s){const e=s;e.org_id=s.orgId;const{app:i}=await K(`${r}/superadmin/apps`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)});return{app:{...pe(i),adminToken:i["admin-token"]}}}async function Rr(r,t){const s=await K(`${r}/dash/apps/ephemeral`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return{app:{...pe(s.app),adminToken:s.app["admin-token"]},expiresMs:s.expires_ms}}async function jr(r,t,s,e){const{app:i}=await K(`${r}/superadmin/apps/${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(e)});return{app:pe(i)}}async function _r(r,t,s){const{app:e}=await K(`${r}/superadmin/apps/${s}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}});return{app:pe(e)}}function Lt(r){const[t,s]=r;switch(t){case"add-attr":{const e=s,i=Ts(e);return{type:"add-attr",friendlyDescription:e["value-type"]==="blob"?bs(e)==="id"?`Create new entity ${i}.`:`Add attribute ${i}.`:`Link ${i} to ${gr(e)}.`,attr:e}}case"update-attr":{const e=s;return{type:"update-attr",friendlyDescription:`Update attribute ${Ts(e)}.`,attr:e}}case"index":return{type:"index",friendlyDescription:`Add index to ${le(s["forward-identity"])}.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"remove-index":return{type:"remove-index",friendlyDescription:`Remove index from ${le(s["forward-identity"])}.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"unique":return{type:"unique",friendlyDescription:`Ensure that ${le(s["forward-identity"])} is unique.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"remove-unique":return{type:"remove-unique",friendlyDescription:`Remove uniqueness constarint from ${le(s["forward-identity"])}.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"required":return{type:"required",friendlyDescription:`Make ${le(s["forward-identity"])} a required attribute.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"remove-required":return{type:"remove-required",friendlyDescription:`Allow ${le(s["forward-identity"])} to be missing or null.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]};case"check-data-type":{const e=s["forward-identity"],i=s["checked-data-type"];return{type:"check-data-type",friendlyDescription:`Enforce data type of ${le(e)} as type ${i}.`,attrId:s["attr-id"],forwardIdentity:e,checkedDataType:i}}case"remove-data-type":{const e=s["forward-identity"];return{type:"remove-data-type",friendlyDescription:`Stop enforcing data type of ${le(e)}.`,attrId:s["attr-id"],forwardIdentity:s["forward-identity"]}}case"delete-attr":return{type:"delete-attr",attrId:s,friendlyDescription:`Delete attribute ${s}.`};default:{const e=t;throw new Error(`Uknown schema operation ${e}.`)}}}function Ss(r){return r.map(t=>Lt(t))}function Ur(r,t){const[s,e]=r;if(s==="add-attr"||s==="update-attr"){const c=Lt(r);if(c.type!=="add-attr"&&c.type!=="update-attr")throw new Error("Invalid step.");return c}const i=e["job-id"],a=t.find(c=>c.id===i),n=Lt(r),o=zr(a);if(n.type!==o.type)throw new Error("Invalid type");return{...n,backgroundJob:o}}function Mt(r,t){return r.map(s=>Ur(s,t))}async function $r(r,t,s,e){const i=await K(`${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})});return{newSchema:$e(i["new-schema"]),currentSchema:$e(i["current-schema"]),steps:Ss(i.steps)}}function Is(r){return!!r.find(t=>t.job_status==="completed"||t.job_status==="errored")}function Es(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 qr(r,t,s,e,i,a){let n=100,o=i,c=0;for(;!Is(o);){await new Promise(h=>setTimeout(h,n));try{const h=(await K(`${r}/dash/apps/${s}/indexing-jobs/group/${e}`,{method:"GET",headers:{Authorization:`Bearer ${t}`}})).jobs;if(a(h),Is(h))return h;c=0;const l=Es(o),p=Es(h);n=p===null||l&&l>=p?Math.min(n*2,1e4):100}catch(h){if(c>3)throw h;c++,n=Math.min(n*2,1e4)}}return o}function zr(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 Cs(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 Vr(r,t,s,e){return new Dt(async(i,a,n)=>{try{const o=await K(`${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})}),c=o["indexing-jobs"],h=c?await qr(r,t,s,c["group-id"],c.jobs,p=>{i(Cs(Mt(o.steps,p)))}):[],l=await Ot(r,t,s);a({newSchema:l.schema,steps:Mt(o.steps,h),summary:Cs(Mt(o.steps,h))})}catch(o){n(o)}})}async function Hr(r,t,s,e){return{perms:(await K(`${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 Kr(r,t){const s=await K(`${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 Ce extends Error{constructor(){super("PlatformApi was not provided auth.")}}class Jr{constructor(t){xe(this,F);xe(this,j);Pe(this,F,t==null?void 0:t.auth),Pe(this,j,(t==null?void 0:t.apiURI)||"https://api.instantdb.com")}token(){if(!w(this,F))throw new Ce;return"token"in w(this,F)?w(this,F).token:w(this,F).accessToken}canRefreshToken(){if(!w(this,F))throw new Ce;return"refreshToken"in w(this,F)&&"clientId"in w(this,F)&&"clientSecret"in w(this,F)&&w(this,F).refreshToken!=null&&w(this,F).clientId!=null&&w(this,F).clientSecret!=null}async refreshToken(){if(!w(this,F))throw new Ce;if(!this.canRefreshToken()||!("clientId"in w(this,F)))return null;const t=await ws({apiURI:w(this,j),clientId:w(this,F).clientId,clientSecret:w(this,F).clientSecret,refreshToken:w(this,F).refreshToken});return w(this,F).accessToken=t.accessToken,w(this,F).onRefresh&&await w(this,F).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 je&&(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 p=await this.refreshToken();if(p){o=p.accessToken,e++;continue}}throw l}}async getApp(t,s){return this.withRetry(Fr,[w(this,j),this.token(),t,s])}async getApps(t){return this.withRetry(Or,[w(this,j),this.token(),t])}async getOrgs(){return this.withRetry(Lr,[w(this,j),this.token()])}async getAppsForOrg(t,s){return this.withRetry(Mr,[w(this,j),this.token(),t,s])}async getSchema(t){return this.withRetry(Ot,[w(this,j),this.token(),t])}async getPerms(t){return this.withRetry(As,[w(this,j),this.token(),t])}async createApp(t){return this.withRetry(Br,[w(this,j),this.token(),t])}async createTemporaryApp(t){return Rr(w(this,j),t)}async updateApp(t,s){return this.withRetry(jr,[w(this,j),this.token(),t,s])}async deleteApp(t){return this.withRetry(_r,[w(this,j),this.token(),t])}async planSchemaPush(t,s){return this.withRetry($r,[w(this,j),this.token(),t,s])}schemaPush(t,s){if(!w(this,F))throw new Ce;return new Dt(async(e,i,a)=>{if(this.canRefreshToken())try{await this.refreshToken()}catch{}Vr(w(this,j),this.token(),t,s).subscribe({complete(n){i(n)},error(n){a(n)},next(n){e(n)}})})}async pushPerms(t,s){if(!w(this,F))throw new Ce;return this.withRetry(Hr,[w(this,j),this.token(),t,s])}async tokenInfo(){if(!w(this,F))throw new Ce;return this.withRetry(Kr,[w(this,j),this.token()])}}F=new WeakMap,j=new WeakMap;function Wr(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 fe{constructor(t,s,e){m(this,"line");m(this,"column");m(this,"index");this.line=t,this.column=s,this.index=e}}class et{constructor(t,s){m(this,"start");m(this,"end");m(this,"filename");m(this,"identifierName");this.start=t,this.end=s}}function Q(r,t){const{line:s,column:e,index:i}=r;return new fe(s,e+t,i+t)}const Ns="BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";var Xr={ImportMetaOutsideModule:{message:`import.meta may appear only with 'sourceType: "module"'`,code:Ns},ImportOutsideModule:{message:`'import' and 'export' may appear only with 'sourceType: "module"'`,code:Ns}};const ks={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"},tt=r=>r.type==="UpdateExpression"?ks.UpdateExpression[`${r.prefix}`]:ks[r.type];var Gr={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\`.
67
67
  - 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.
68
- - 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 ${tt(r)}.`,InvalidLhsBinding:({ancestor:r})=>`Binding invalid left-hand side in ${tt(r)}.`,InvalidLhsOptionalChaining:({ancestor:r})=>`Invalid optional chaining in the left-hand side of ${tt(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."},Yr={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."},Qr={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 Zr=new Set(["ArrowFunctionExpression","AssignmentExpression","ConditionalExpression","YieldExpression"]);var ea=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 ${tt({type:r})}; please wrap it in parentheses.`},{});const ta=["message"];function vs(r,t,s){Object.defineProperty(r,t,{enumerable:!1,configurable:!0,value:s})}function sa({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),vs(c,"clone",function(l={}){const{line:u,column:d,index:f}=l.loc??n;return a(new fe(u,d,f),Object.assign({},o,l.details))}),vs(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 re(r,t){if(Array.isArray(r))return e=>re(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=Wr(a,ta),c=typeof n=="string"?()=>n:n;s[e]=sa(Object.assign({code:"BABEL_PARSER_SYNTAX_ERROR",reasonCode:e,toMessage:c},t?{syntaxPlugin:t}:{},o))}return s}const p=Object.assign({},re(Xr),re(Gr),re(Yr),re(Qr),re`pipelineOperator`(ea));function ia(){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 ra(r){const t=ia();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:aa}=Object,Os=(r,t)=>{r&&aa(r,t,{enumerable:!1,value:r[t]})};function qe(r){return Os(r.loc.start,"index"),Os(r.loc.end,"index"),r}var na=r=>class extends r{parse(){const s=qe(super.parse());return this.optionFlags&256&&(s.tokens=s.tokens.map(qe)),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 qe(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),qe(s)}resetEndLocation(s,e=this.state.lastTokEndLoc){super.resetEndLocation(s,e),qe(s)}};class st{constructor(t,s){m(this,"token");m(this,"preserveSpace");this.token=t,this.preserveSpace=!!s}}const M={brace:new st("{"),j_oTag:new st("<tag"),j_cTag:new st("</tag"),j_expr:new st("<tag>...</tag>",!0)},I=!0,y=!0,Ft=!0,ze=!0,de=!0,oa=!0;class Ds{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 Bt=new Map;function k(r,t={}){t.keyword=r;const s=g(r,t);return Bt.set(r,s),s}function J(r,t){return g(r,{beforeExpr:I,binop:t})}let Ve=-1;const _t=[],Rt=[],jt=[],Ut=[],$t=[],qt=[];function g(r,t={}){return++Ve,Rt.push(r),jt.push(t.binop??-1),Ut.push(t.beforeExpr??!1),$t.push(t.startsExpr??!1),qt.push(t.prefix??!1),_t.push(new Ds(r,t)),Ve}function E(r,t={}){return++Ve,Bt.set(r,Ve),Rt.push(r),jt.push(t.binop??-1),Ut.push(t.beforeExpr??!1),$t.push(t.startsExpr??!1),qt.push(t.prefix??!1),_t.push(new Ds("name",t)),Ve}const ca={bracketL:g("[",{beforeExpr:I,startsExpr:y}),bracketHashL:g("#[",{beforeExpr:I,startsExpr:y}),bracketBarL:g("[|",{beforeExpr:I,startsExpr:y}),bracketR:g("]"),bracketBarR:g("|]"),braceL:g("{",{beforeExpr:I,startsExpr:y}),braceBarL:g("{|",{beforeExpr:I,startsExpr:y}),braceHashL:g("#{",{beforeExpr:I,startsExpr:y}),braceR:g("}"),braceBarR:g("|}"),parenL:g("(",{beforeExpr:I,startsExpr:y}),parenR:g(")"),comma:g(",",{beforeExpr:I}),semi:g(";",{beforeExpr:I}),colon:g(":",{beforeExpr:I}),doubleColon:g("::",{beforeExpr:I}),dot:g("."),question:g("?",{beforeExpr:I}),questionDot:g("?."),arrow:g("=>",{beforeExpr:I}),template:g("template"),ellipsis:g("...",{beforeExpr:I}),backQuote:g("`",{startsExpr:y}),dollarBraceL:g("${",{beforeExpr:I,startsExpr:y}),templateTail:g("...`",{startsExpr:y}),templateNonTail:g("...${",{beforeExpr:I,startsExpr:y}),at:g("@"),hash:g("#",{startsExpr:y}),interpreterDirective:g("#!..."),eq:g("=",{beforeExpr:I,isAssign:ze}),assign:g("_=",{beforeExpr:I,isAssign:ze}),slashAssign:g("_=",{beforeExpr:I,isAssign:ze}),xorAssign:g("_=",{beforeExpr:I,isAssign:ze}),moduloAssign:g("_=",{beforeExpr:I,isAssign:ze}),incDec:g("++/--",{prefix:de,postfix:oa,startsExpr:y}),bang:g("!",{beforeExpr:I,prefix:de,startsExpr:y}),tilde:g("~",{beforeExpr:I,prefix:de,startsExpr:y}),doubleCaret:g("^^",{startsExpr:y}),doubleAt:g("@@",{startsExpr:y}),pipeline:J("|>",0),nullishCoalescing:J("??",1),logicalOR:J("||",1),logicalAND:J("&&",2),bitwiseOR:J("|",3),bitwiseXOR:J("^",4),bitwiseAND:J("&",5),equality:J("==/!=/===/!==",6),lt:J("</>/<=/>=",7),gt:J("</>/<=/>=",7),relational:J("</>/<=/>=",7),bitShift:J("<</>>/>>>",8),bitShiftL:J("<</>>/>>>",8),bitShiftR:J("<</>>/>>>",8),plusMin:g("+/-",{beforeExpr:I,binop:9,prefix:de,startsExpr:y}),modulo:g("%",{binop:10,startsExpr:y}),star:g("*",{binop:10}),slash:J("/",10),exponent:g("**",{beforeExpr:I,binop:11,rightAssociative:!0}),_in:k("in",{beforeExpr:I,binop:7}),_instanceof:k("instanceof",{beforeExpr:I,binop:7}),_break:k("break"),_case:k("case",{beforeExpr:I}),_catch:k("catch"),_continue:k("continue"),_debugger:k("debugger"),_default:k("default",{beforeExpr:I}),_else:k("else",{beforeExpr:I}),_finally:k("finally"),_function:k("function",{startsExpr:y}),_if:k("if"),_return:k("return",{beforeExpr:I}),_switch:k("switch"),_throw:k("throw",{beforeExpr:I,prefix:de,startsExpr:y}),_try:k("try"),_var:k("var"),_const:k("const"),_with:k("with"),_new:k("new",{beforeExpr:I,startsExpr:y}),_this:k("this",{startsExpr:y}),_super:k("super",{startsExpr:y}),_class:k("class",{startsExpr:y}),_extends:k("extends",{beforeExpr:I}),_export:k("export"),_import:k("import",{startsExpr:y}),_null:k("null",{startsExpr:y}),_true:k("true",{startsExpr:y}),_false:k("false",{startsExpr:y}),_typeof:k("typeof",{beforeExpr:I,prefix:de,startsExpr:y}),_void:k("void",{beforeExpr:I,prefix:de,startsExpr:y}),_delete:k("delete",{beforeExpr:I,prefix:de,startsExpr:y}),_do:k("do",{isLoop:Ft,beforeExpr:I}),_for:k("for",{isLoop:Ft}),_while:k("while",{isLoop:Ft}),_as:E("as",{startsExpr:y}),_assert:E("assert",{startsExpr:y}),_async:E("async",{startsExpr:y}),_await:E("await",{startsExpr:y}),_defer:E("defer",{startsExpr:y}),_from:E("from",{startsExpr:y}),_get:E("get",{startsExpr:y}),_let:E("let",{startsExpr:y}),_meta:E("meta",{startsExpr:y}),_of:E("of",{startsExpr:y}),_sent:E("sent",{startsExpr:y}),_set:E("set",{startsExpr:y}),_source:E("source",{startsExpr:y}),_static:E("static",{startsExpr:y}),_using:E("using",{startsExpr:y}),_yield:E("yield",{startsExpr:y}),_asserts:E("asserts",{startsExpr:y}),_checks:E("checks",{startsExpr:y}),_exports:E("exports",{startsExpr:y}),_global:E("global",{startsExpr:y}),_implements:E("implements",{startsExpr:y}),_intrinsic:E("intrinsic",{startsExpr:y}),_infer:E("infer",{startsExpr:y}),_is:E("is",{startsExpr:y}),_mixins:E("mixins",{startsExpr:y}),_proto:E("proto",{startsExpr:y}),_require:E("require",{startsExpr:y}),_satisfies:E("satisfies",{startsExpr:y}),_keyof:E("keyof",{startsExpr:y}),_readonly:E("readonly",{startsExpr:y}),_unique:E("unique",{startsExpr:y}),_abstract:E("abstract",{startsExpr:y}),_declare:E("declare",{startsExpr:y}),_enum:E("enum",{startsExpr:y}),_module:E("module",{startsExpr:y}),_namespace:E("namespace",{startsExpr:y}),_interface:E("interface",{startsExpr:y}),_type:E("type",{startsExpr:y}),_opaque:E("opaque",{startsExpr:y}),name:g("name",{startsExpr:y}),placeholder:g("%%",{startsExpr:!0}),string:g("string",{startsExpr:y}),num:g("num",{startsExpr:y}),bigint:g("bigint",{startsExpr:y}),decimal:g("decimal",{startsExpr:y}),regexp:g("regexp",{startsExpr:y}),privateName:g("#name",{startsExpr:y}),eof:g("eof"),jsxName:g("jsxName"),jsxText:g("jsxText",{beforeExpr:!0}),jsxTagStart:g("jsxTagStart",{startsExpr:!0}),jsxTagEnd:g("jsxTagEnd")};function O(r){return r>=93&&r<=133}function ha(r){return r<=92}function te(r){return r>=58&&r<=133}function Ls(r){return r>=58&&r<=137}function la(r){return Ut[r]}function He(r){return $t[r]}function ua(r){return r>=29&&r<=33}function Ms(r){return r>=129&&r<=131}function pa(r){return r>=90&&r<=92}function zt(r){return r>=58&&r<=92}function fa(r){return r>=39&&r<=59}function da(r){return r===34}function ma(r){return qt[r]}function ya(r){return r>=121&&r<=123}function xa(r){return r>=124&&r<=130}function me(r){return Rt[r]}function it(r){return jt[r]}function Pa(r){return r===57}function Vt(r){return r>=24&&r<=25}function Fs(r){return _t[r]}let Ht="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟍꟐꟑꟓꟕ-Ƛꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Bs="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・";const ba=new RegExp("["+Ht+"]"),ga=new RegExp("["+Ht+Bs+"]");Ht=Bs=null;const _s=[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],wa=[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 Kt(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 ae(r){return r<65?r===36:r<=90?!0:r<97?r===95:r<=122?!0:r<=65535?r>=170&&ba.test(String.fromCharCode(r)):Kt(r,_s)}function Ne(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&&ga.test(String.fromCharCode(r)):Kt(r,_s)||Kt(r,wa)}const Jt={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"]},Ta=new Set(Jt.keyword),Aa=new Set(Jt.strict),Sa=new Set(Jt.strictBind);function Rs(r,t){return t&&r==="await"||r==="enum"}function js(r,t){return Rs(r,t)||Aa.has(r)}function Us(r){return Sa.has(r)}function $s(r,t){return js(r,t)||Us(r)}function Ia(r){return Ta.has(r)}function Ea(r,t,s){return r===64&&t===64&&ae(s)}const Ca=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 Na(r){return Ca.has(r)}class Wt{constructor(t){m(this,"flags",0);m(this,"names",new Map);m(this,"firstLexicalName","");this.flags=t}}class Xt{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 Wt(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 ka extends Wt{constructor(){super(...arguments);m(this,"declareFunctions",new Set)}}class va extends Xt{createScope(t){return new ka(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 Oa=new Set(["_","any","bool","boolean","empty","extends","false","interface","mixed","null","number","static","string","true","typeof","void"]),w=re`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 Da(r){return r.type==="DeclareExportAllDeclaration"||r.type==="DeclareExportDeclaration"&&(!r.declaration||r.declaration.type!=="TypeAlias"&&r.declaration.type!=="InterfaceDeclaration")}function qs(r){return r.importKind==="type"||r.importKind==="typeof"}const La={const:"declare export var",let:"declare export var",type:"export type",interface:"export interface"};function Ma(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 Fa=/\*?\s*@((?:no)?flow)\b/;var Ba=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=Fa.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(w.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(w.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(w.InvalidNonTypeImportInDeclareModule,this.state.lastTokStartLoc),super.parseImport(c)):(this.expectContextual(125,w.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=>{Da(c)?(n==="CommonJS"&&this.raise(w.AmbiguousDeclareModuleKind,c),n="ES"):c.type==="DeclareModuleExports"&&(o&&this.raise(w.DuplicateDeclareModuleExports,c),n==="ES"&&this.raise(w.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(w.UnsupportedDeclareExportKind,this.state.startLoc,{unsupportedExportKind:a,suggestion:La[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(w.UnexpectedReservedUnderscore,this.state.startLoc)}checkReservedType(e,i,a){Oa.has(e)&&this.raise(a?w.AssignReservedType:w.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(w.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()!==M.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()===M.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,d=!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 x=!1,A=null,j=null;const C=this.startNode();if(n&&this.isContextual(118)){const U=this.lookahead();U.type!==14&&U.type!==17&&(this.next(),A=this.state.startLoc,e=!1)}if(e&&this.isContextual(106)){const U=this.lookahead();U.type!==14&&U.type!==17&&(this.next(),x=!0)}const D=this.flowParseVariance();if(this.eat(0))A!=null&&this.unexpected(A),this.eat(0)?(D&&this.unexpected(D.loc.start),h.internalSlots.push(this.flowParseObjectTypeInternalSlot(C,x))):h.indexers.push(this.flowParseObjectTypeIndexer(C,x,D));else if(this.match(10)||this.match(47))A!=null&&this.unexpected(A),D&&this.unexpected(D.loc.start),h.callProperties.push(this.flowParseObjectTypeCallProperty(C,x));else{let U="init";if(this.isContextual(99)||this.isContextual(104)){const b=this.lookahead();Ls(b.type)&&(U=this.state.value,this.next())}const ce=this.flowParseObjectTypeProperty(C,x,A,D,U,a,o??!u);ce===null?(d=!0,j=this.state.lastTokStartLoc):h.properties.push(ce)}this.flowObjectTypeSemicolon(),j&&!this.match(8)&&!this.match(9)&&this.raise(w.UnexpectedExplicitInexactInObject,j)}this.expect(l),a&&(h.inexact=d);const f=this.finishNode(h,"ObjectTypeAnnotation");return this.state.inType=c,f}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(w.InexactInsideExact,this.state.lastTokStartLoc):this.raise(w.InexactInsideNonObject,this.state.lastTokStartLoc),n&&this.raise(w.InexactVariance,n),null):(c||this.raise(w.UnexpectedSpreadType,this.state.lastTokStartLoc),a!=null&&this.unexpected(a),n&&this.raise(w.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(w.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"?w.GetterMayNotHaveThisParam:w.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(w.ThisParamMustBeFirst,o),i=this.parseIdentifier(h),this.eat(17)&&(a=!0,h&&this.raise(w.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(w.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(zt(this.state.type)){const h=me(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(te(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||Ms(e)?!this.state.containsEsc:super.shouldParseExportDeclaration()}isExportDefaultSpecifier(){const{type:e}=this.state;return e===126||Ms(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 f=this.lookaheadCharCode();if(f===44||f===61||f===58||f===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,d]=this.getArrowLikeExpressions(h);if(l||d.length>0){const f=[...o];if(d.length>0){this.state=n,this.state.noArrowAt=f;for(let x=0;x<d.length;x++)f.push(d[x].start);({consequent:h,failed:l}=this.tryParseConditionalConsequent()),[u,d]=this.getArrowLikeExpressions(h)}l&&u.length>1&&this.raise(w.AmbiguousConditionalArrow,n.startLoc),l&&u.length===1&&(this.state=n,f.push(u[0].start),this.state.noArrowAt=f,{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,[]]):Ma(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(w.DeclareClassElement,n):i.value&&this.raise(w.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):Ea(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(w.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(w.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(w.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(w.GetterMayNotHaveThisParam,a):this.isThisParam(a)&&this.raise(w.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(w.PatternIsOptional,e),this.isThisParam(e)&&this.raise(w.ThisParamMayNotBeOptional,e),e.optional=!0),this.match(14)?e.typeAnnotation=this.flowParseTypeAnnotation():this.isThisParam(e)&&this.raise(w.ThisParamAnnotationRequired,e),this.match(29)&&this.isThisParam(e)&&this.raise(w.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(w.TypeBeforeInitializer,a.typeAnnotation),a}checkImportReflection(e){super.checkImportReflection(e),e.module&&e.importKind!=="value"&&this.raise(w.ImportReflectionHasImportType,e.specifiers[0].loc.start)}parseImportSpecifierLocal(e,i,a){i.local=qs(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 d=this.parseIdentifier(!0);h!==null&&!te(this.state.type)?(e.imported=d,e.importKind=h,e.local=this.cloneIdentifier(d)):(e.imported=c,e.importKind=null,e.local=this.parseIdentifier())}else{if(h!==null&&te(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=qs(e);return a&&u&&this.raise(w.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===M.j_oTag||c===M.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 f;o=this.flowParseTypeParameterDeclaration();const u=this.forwardNoArrowParamsConversionAt(o,()=>{const x=super.parseMaybeAssign(e,i);return this.resetStartLocationFromNode(x,o),x});(f=u.extra)!=null&&f.parenthesized&&l();const d=this.maybeUnwrapTypeCastExpression(u);return d.type!=="ArrowFunctionExpression"&&l(),d.typeParameters=o,this.resetStartLocationFromNode(d,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(w.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(w.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(w.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(w.UnterminatedFlowComment,this.state.curPosition()),a}skipBlockComment(){if(this.hasPlugin("flowComments")&&this.skipFlowComment()){if(this.state.hasFlowComment)throw this.raise(w.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(w.EnumBooleanMemberNotInitialized,e,{memberName:a,enumName:i})}flowEnumErrorInvalidMemberInitializer(e,i){return this.raise(i.explicitType?i.explicitType==="symbol"?w.EnumInvalidMemberInitializerSymbolType:w.EnumInvalidMemberInitializerPrimaryType:w.EnumInvalidMemberInitializerUnknownType,e,i)}flowEnumErrorNumberMemberNotInitialized(e,i){this.raise(w.EnumNumberMemberNotInitialized,e,i)}flowEnumErrorStringMemberInconsistentlyInitialized(e,i){this.raise(w.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(w.EnumInvalidMemberName,h,{memberName:u,suggestion:u[0].toUpperCase()+u.slice(1),enumName:e}),a.has(u)&&this.raise(w.EnumDuplicateMemberName,h,{memberName:u,enumName:e}),a.add(u);const d={enumName:e,explicitType:i,memberName:u};switch(c.id=h,l.type){case"boolean":{this.flowEnumCheckExplicitTypeMismatch(l.loc,d,"boolean"),c.init=l.value,n.booleanMembers.push(this.finishNode(c,"EnumBooleanMember"));break}case"number":{this.flowEnumCheckExplicitTypeMismatch(l.loc,d,"number"),c.init=l.value,n.numberMembers.push(this.finishNode(c,"EnumNumberMember"));break}case"string":{this.flowEnumCheckExplicitTypeMismatch(l.loc,d,"string"),c.init=l.value,n.stringMembers.push(this.finishNode(c,"EnumStringMember"));break}case"invalid":throw this.flowEnumErrorInvalidMemberInitializer(l.loc,d);case"none":switch(i){case"boolean":this.flowEnumErrorBooleanMemberNotInitialized(l.loc,d);break;case"number":this.flowEnumErrorNumberMemberNotInitialized(l.loc,d);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(w.EnumInvalidExplicitTypeUnknownSupplied,this.state.startLoc,{enumName:e});const{value:i}=this.state;return this.next(),i!=="boolean"&&i!=="number"&&i!=="string"&&i!=="symbol"&&this.raise(w.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,d=c.numberMembers.length,f=c.stringMembers.length,x=c.defaultedMembers.length;if(!u&&!d&&!f&&!x)return l();if(!u&&!d)return e.members=this.flowEnumStringMembers(c.stringMembers,c.defaultedMembers,{enumName:a}),this.expect(8),this.finishNode(e,"EnumStringBody");if(!d&&!f&&u>=x){for(const A of c.defaultedMembers)this.flowEnumErrorBooleanMemberNotInitialized(A.loc.start,{enumName:a,memberName:A.id.name});return e.members=c.booleanMembers,this.expect(8),this.finishNode(e,"EnumBooleanBody")}else if(!u&&!f&&d>=x){for(const A of c.defaultedMembers)this.flowEnumErrorNumberMemberNotInitialized(A.loc.start,{enumName:a,memberName:A.id.name});return e.members=c.numberMembers,this.expect(8),this.finishNode(e,"EnumNumberBody")}else return this.raise(w.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 _a={__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:"♦"},Ra=/\r\n|[\r\n\u2028\u2029]/,rt=new RegExp(Ra.source,"g");function ke(r){switch(r){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function zs(r,t,s){for(let e=t;e<s;e++)if(ke(r.charCodeAt(e)))return!0;return!1}const Gt=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Yt=/(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;function ja(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 ne=re`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 ye(r){return r?r.type==="JSXOpeningFragment"||r.type==="JSXClosingFragment":!1}function ve(r){if(r.type==="JSXIdentifier")return r.name;if(r.type==="JSXNamespacedName")return r.namespace.name+":"+r.name.name;if(r.type==="JSXMemberExpression")return ve(r.object)+"."+ve(r.property);throw new Error("Node had unexpected type: "+r.type)}var Ua=r=>class extends r{jsxReadToken(){let s="",e=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(ne.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(ne.UnexpectedToken,this.state.curPosition(),{unexpected:this.input[this.state.pos],HTMLEntity:i===125?"&rbrace;":"&gt;"});default:ke(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?`
68
+ - 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 ${tt(r)}.`,InvalidLhsBinding:({ancestor:r})=>`Binding invalid left-hand side in ${tt(r)}.`,InvalidLhsOptionalChaining:({ancestor:r})=>`Invalid optional chaining in the left-hand side of ${tt(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."},Yr={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."},Qr={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 Zr=new Set(["ArrowFunctionExpression","AssignmentExpression","ConditionalExpression","YieldExpression"]);var ea=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 ${tt({type:r})}; please wrap it in parentheses.`},{});const ta=["message"];function vs(r,t,s){Object.defineProperty(r,t,{enumerable:!1,configurable:!0,value:s})}function sa({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),vs(c,"clone",function(l={}){const{line:p,column:d,index:f}=l.loc??n;return a(new fe(p,d,f),Object.assign({},o,l.details))}),vs(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 re(r,t){if(Array.isArray(r))return e=>re(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=Wr(a,ta),c=typeof n=="string"?()=>n:n;s[e]=sa(Object.assign({code:"BABEL_PARSER_SYNTAX_ERROR",reasonCode:e,toMessage:c},t?{syntaxPlugin:t}:{},o))}return s}const u=Object.assign({},re(Xr),re(Gr),re(Yr),re(Qr),re`pipelineOperator`(ea));function ia(){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 ra(r){const t=ia();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:aa}=Object,Ds=(r,t)=>{r&&aa(r,t,{enumerable:!1,value:r[t]})};function qe(r){return Ds(r.loc.start,"index"),Ds(r.loc.end,"index"),r}var na=r=>class extends r{parse(){const s=qe(super.parse());return this.optionFlags&256&&(s.tokens=s.tokens.map(qe)),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 p=this.castNodeTo(h,this.hasPlugin("typescript")&&!h.body?"TSEmptyBodyFunctionExpression":"FunctionExpression");return s.value=p,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(u.PatternHasAccessor,s.key):s.type==="Property"&&s.method?this.raise(u.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 qe(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),qe(s)}resetEndLocation(s,e=this.state.lastTokEndLoc){super.resetEndLocation(s,e),qe(s)}};class st{constructor(t,s){m(this,"token");m(this,"preserveSpace");this.token=t,this.preserveSpace=!!s}}const M={brace:new st("{"),j_oTag:new st("<tag"),j_cTag:new st("</tag"),j_expr:new st("<tag>...</tag>",!0)},I=!0,y=!0,Ft=!0,ze=!0,de=!0,oa=!0;class Os{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 Bt=new Map;function k(r,t={}){t.keyword=r;const s=b(r,t);return Bt.set(r,s),s}function J(r,t){return b(r,{beforeExpr:I,binop:t})}let Ve=-1;const Rt=[],jt=[],_t=[],Ut=[],$t=[],qt=[];function b(r,t={}){return++Ve,jt.push(r),_t.push(t.binop??-1),Ut.push(t.beforeExpr??!1),$t.push(t.startsExpr??!1),qt.push(t.prefix??!1),Rt.push(new Os(r,t)),Ve}function E(r,t={}){return++Ve,Bt.set(r,Ve),jt.push(r),_t.push(t.binop??-1),Ut.push(t.beforeExpr??!1),$t.push(t.startsExpr??!1),qt.push(t.prefix??!1),Rt.push(new Os("name",t)),Ve}const ca={bracketL:b("[",{beforeExpr:I,startsExpr:y}),bracketHashL:b("#[",{beforeExpr:I,startsExpr:y}),bracketBarL:b("[|",{beforeExpr:I,startsExpr:y}),bracketR:b("]"),bracketBarR:b("|]"),braceL:b("{",{beforeExpr:I,startsExpr:y}),braceBarL:b("{|",{beforeExpr:I,startsExpr:y}),braceHashL:b("#{",{beforeExpr:I,startsExpr:y}),braceR:b("}"),braceBarR:b("|}"),parenL:b("(",{beforeExpr:I,startsExpr:y}),parenR:b(")"),comma:b(",",{beforeExpr:I}),semi:b(";",{beforeExpr:I}),colon:b(":",{beforeExpr:I}),doubleColon:b("::",{beforeExpr:I}),dot:b("."),question:b("?",{beforeExpr:I}),questionDot:b("?."),arrow:b("=>",{beforeExpr:I}),template:b("template"),ellipsis:b("...",{beforeExpr:I}),backQuote:b("`",{startsExpr:y}),dollarBraceL:b("${",{beforeExpr:I,startsExpr:y}),templateTail:b("...`",{startsExpr:y}),templateNonTail:b("...${",{beforeExpr:I,startsExpr:y}),at:b("@"),hash:b("#",{startsExpr:y}),interpreterDirective:b("#!..."),eq:b("=",{beforeExpr:I,isAssign:ze}),assign:b("_=",{beforeExpr:I,isAssign:ze}),slashAssign:b("_=",{beforeExpr:I,isAssign:ze}),xorAssign:b("_=",{beforeExpr:I,isAssign:ze}),moduloAssign:b("_=",{beforeExpr:I,isAssign:ze}),incDec:b("++/--",{prefix:de,postfix:oa,startsExpr:y}),bang:b("!",{beforeExpr:I,prefix:de,startsExpr:y}),tilde:b("~",{beforeExpr:I,prefix:de,startsExpr:y}),doubleCaret:b("^^",{startsExpr:y}),doubleAt:b("@@",{startsExpr:y}),pipeline:J("|>",0),nullishCoalescing:J("??",1),logicalOR:J("||",1),logicalAND:J("&&",2),bitwiseOR:J("|",3),bitwiseXOR:J("^",4),bitwiseAND:J("&",5),equality:J("==/!=/===/!==",6),lt:J("</>/<=/>=",7),gt:J("</>/<=/>=",7),relational:J("</>/<=/>=",7),bitShift:J("<</>>/>>>",8),bitShiftL:J("<</>>/>>>",8),bitShiftR:J("<</>>/>>>",8),plusMin:b("+/-",{beforeExpr:I,binop:9,prefix:de,startsExpr:y}),modulo:b("%",{binop:10,startsExpr:y}),star:b("*",{binop:10}),slash:J("/",10),exponent:b("**",{beforeExpr:I,binop:11,rightAssociative:!0}),_in:k("in",{beforeExpr:I,binop:7}),_instanceof:k("instanceof",{beforeExpr:I,binop:7}),_break:k("break"),_case:k("case",{beforeExpr:I}),_catch:k("catch"),_continue:k("continue"),_debugger:k("debugger"),_default:k("default",{beforeExpr:I}),_else:k("else",{beforeExpr:I}),_finally:k("finally"),_function:k("function",{startsExpr:y}),_if:k("if"),_return:k("return",{beforeExpr:I}),_switch:k("switch"),_throw:k("throw",{beforeExpr:I,prefix:de,startsExpr:y}),_try:k("try"),_var:k("var"),_const:k("const"),_with:k("with"),_new:k("new",{beforeExpr:I,startsExpr:y}),_this:k("this",{startsExpr:y}),_super:k("super",{startsExpr:y}),_class:k("class",{startsExpr:y}),_extends:k("extends",{beforeExpr:I}),_export:k("export"),_import:k("import",{startsExpr:y}),_null:k("null",{startsExpr:y}),_true:k("true",{startsExpr:y}),_false:k("false",{startsExpr:y}),_typeof:k("typeof",{beforeExpr:I,prefix:de,startsExpr:y}),_void:k("void",{beforeExpr:I,prefix:de,startsExpr:y}),_delete:k("delete",{beforeExpr:I,prefix:de,startsExpr:y}),_do:k("do",{isLoop:Ft,beforeExpr:I}),_for:k("for",{isLoop:Ft}),_while:k("while",{isLoop:Ft}),_as:E("as",{startsExpr:y}),_assert:E("assert",{startsExpr:y}),_async:E("async",{startsExpr:y}),_await:E("await",{startsExpr:y}),_defer:E("defer",{startsExpr:y}),_from:E("from",{startsExpr:y}),_get:E("get",{startsExpr:y}),_let:E("let",{startsExpr:y}),_meta:E("meta",{startsExpr:y}),_of:E("of",{startsExpr:y}),_sent:E("sent",{startsExpr:y}),_set:E("set",{startsExpr:y}),_source:E("source",{startsExpr:y}),_static:E("static",{startsExpr:y}),_using:E("using",{startsExpr:y}),_yield:E("yield",{startsExpr:y}),_asserts:E("asserts",{startsExpr:y}),_checks:E("checks",{startsExpr:y}),_exports:E("exports",{startsExpr:y}),_global:E("global",{startsExpr:y}),_implements:E("implements",{startsExpr:y}),_intrinsic:E("intrinsic",{startsExpr:y}),_infer:E("infer",{startsExpr:y}),_is:E("is",{startsExpr:y}),_mixins:E("mixins",{startsExpr:y}),_proto:E("proto",{startsExpr:y}),_require:E("require",{startsExpr:y}),_satisfies:E("satisfies",{startsExpr:y}),_keyof:E("keyof",{startsExpr:y}),_readonly:E("readonly",{startsExpr:y}),_unique:E("unique",{startsExpr:y}),_abstract:E("abstract",{startsExpr:y}),_declare:E("declare",{startsExpr:y}),_enum:E("enum",{startsExpr:y}),_module:E("module",{startsExpr:y}),_namespace:E("namespace",{startsExpr:y}),_interface:E("interface",{startsExpr:y}),_type:E("type",{startsExpr:y}),_opaque:E("opaque",{startsExpr:y}),name:b("name",{startsExpr:y}),placeholder:b("%%",{startsExpr:!0}),string:b("string",{startsExpr:y}),num:b("num",{startsExpr:y}),bigint:b("bigint",{startsExpr:y}),decimal:b("decimal",{startsExpr:y}),regexp:b("regexp",{startsExpr:y}),privateName:b("#name",{startsExpr:y}),eof:b("eof"),jsxName:b("jsxName"),jsxText:b("jsxText",{beforeExpr:!0}),jsxTagStart:b("jsxTagStart",{startsExpr:!0}),jsxTagEnd:b("jsxTagEnd")};function D(r){return r>=93&&r<=133}function ha(r){return r<=92}function te(r){return r>=58&&r<=133}function Ls(r){return r>=58&&r<=137}function la(r){return Ut[r]}function He(r){return $t[r]}function ua(r){return r>=29&&r<=33}function Ms(r){return r>=129&&r<=131}function pa(r){return r>=90&&r<=92}function zt(r){return r>=58&&r<=92}function fa(r){return r>=39&&r<=59}function da(r){return r===34}function ma(r){return qt[r]}function ya(r){return r>=121&&r<=123}function xa(r){return r>=124&&r<=130}function me(r){return jt[r]}function it(r){return _t[r]}function Pa(r){return r===57}function Vt(r){return r>=24&&r<=25}function Fs(r){return Rt[r]}let Ht="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟍꟐꟑꟓꟕ-Ƛꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",Bs="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・";const ga=new RegExp("["+Ht+"]"),ba=new RegExp("["+Ht+Bs+"]");Ht=Bs=null;const Rs=[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],Ta=[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 Kt(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 ae(r){return r<65?r===36:r<=90?!0:r<97?r===95:r<=122?!0:r<=65535?r>=170&&ga.test(String.fromCharCode(r)):Kt(r,Rs)}function Ne(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&&ba.test(String.fromCharCode(r)):Kt(r,Rs)||Kt(r,Ta)}const Jt={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"]},wa=new Set(Jt.keyword),Aa=new Set(Jt.strict),Sa=new Set(Jt.strictBind);function js(r,t){return t&&r==="await"||r==="enum"}function _s(r,t){return js(r,t)||Aa.has(r)}function Us(r){return Sa.has(r)}function $s(r,t){return _s(r,t)||Us(r)}function Ia(r){return wa.has(r)}function Ea(r,t,s){return r===64&&t===64&&ae(s)}const Ca=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 Na(r){return Ca.has(r)}class Wt{constructor(t){m(this,"flags",0);m(this,"names",new Map);m(this,"firstLexicalName","");this.flags=t}}class Xt{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 Wt(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(u.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 ka extends Wt{constructor(){super(...arguments);m(this,"declareFunctions",new Set)}}class va extends Xt{createScope(t){return new ka(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 Da=new Set(["_","any","bool","boolean","empty","extends","false","interface","mixed","null","number","static","string","true","typeof","void"]),T=re`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 Oa(r){return r.type==="DeclareExportAllDeclaration"||r.type==="DeclareExportDeclaration"&&(!r.declaration||r.declaration.type!=="TypeAlias"&&r.declaration.type!=="InterfaceDeclaration")}function qs(r){return r.importKind==="type"||r.importKind==="typeof"}const La={const:"declare export var",let:"declare export var",type:"export type",interface:"export interface"};function Ma(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 Fa=/\*?\s*@((?:no)?flow)\b/;var Ba=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=Fa.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(T.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(T.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(T.InvalidNonTypeImportInDeclareModule,this.state.lastTokStartLoc),super.parseImport(c)):(this.expectContextual(125,T.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=>{Oa(c)?(n==="CommonJS"&&this.raise(T.AmbiguousDeclareModuleKind,c),n="ES"):c.type==="DeclareModuleExports"&&(o&&this.raise(T.DuplicateDeclareModuleExports,c),n==="ES"&&this.raise(T.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(T.UnsupportedDeclareExportKind,this.state.startLoc,{unsupportedExportKind:a,suggestion:La[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(T.UnexpectedReservedUnderscore,this.state.startLoc)}checkReservedType(e,i,a){Da.has(e)&&this.raise(a?T.AssignReservedType:T.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(T.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()!==M.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()===M.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,p,d=!1;for(i&&this.match(6)?(this.expect(6),l=9,p=!0):(this.expect(5),l=8,p=!1),h.exact=p;!this.match(l);){let x=!1,A=null,_=null;const C=this.startNode();if(n&&this.isContextual(118)){const U=this.lookahead();U.type!==14&&U.type!==17&&(this.next(),A=this.state.startLoc,e=!1)}if(e&&this.isContextual(106)){const U=this.lookahead();U.type!==14&&U.type!==17&&(this.next(),x=!0)}const O=this.flowParseVariance();if(this.eat(0))A!=null&&this.unexpected(A),this.eat(0)?(O&&this.unexpected(O.loc.start),h.internalSlots.push(this.flowParseObjectTypeInternalSlot(C,x))):h.indexers.push(this.flowParseObjectTypeIndexer(C,x,O));else if(this.match(10)||this.match(47))A!=null&&this.unexpected(A),O&&this.unexpected(O.loc.start),h.callProperties.push(this.flowParseObjectTypeCallProperty(C,x));else{let U="init";if(this.isContextual(99)||this.isContextual(104)){const g=this.lookahead();Ls(g.type)&&(U=this.state.value,this.next())}const ce=this.flowParseObjectTypeProperty(C,x,A,O,U,a,o??!p);ce===null?(d=!0,_=this.state.lastTokStartLoc):h.properties.push(ce)}this.flowObjectTypeSemicolon(),_&&!this.match(8)&&!this.match(9)&&this.raise(T.UnexpectedExplicitInexactInObject,_)}this.expect(l),a&&(h.inexact=d);const f=this.finishNode(h,"ObjectTypeAnnotation");return this.state.inType=c,f}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(T.InexactInsideExact,this.state.lastTokStartLoc):this.raise(T.InexactInsideNonObject,this.state.lastTokStartLoc),n&&this.raise(T.InexactVariance,n),null):(c||this.raise(T.UnexpectedSpreadType,this.state.lastTokStartLoc),a!=null&&this.unexpected(a),n&&this.raise(T.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(T.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"?T.GetterMayNotHaveThisParam:T.SetterMayNotHaveThisParam,e.value.this),a!==i&&this.raise(e.kind==="get"?u.BadGetterArity:u.BadSetterArity,e),e.kind==="set"&&e.value.rest&&this.raise(u.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(T.ThisParamMustBeFirst,o),i=this.parseIdentifier(h),this.eat(17)&&(a=!0,h&&this.raise(T.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(T.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(zt(this.state.type)){const h=me(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(te(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||Ms(e)?!this.state.containsEsc:super.shouldParseExportDeclaration()}isExportDefaultSpecifier(){const{type:e}=this.state;return e===126||Ms(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 f=this.lookaheadCharCode();if(f===44||f===61||f===58||f===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(),[p,d]=this.getArrowLikeExpressions(h);if(l||d.length>0){const f=[...o];if(d.length>0){this.state=n,this.state.noArrowAt=f;for(let x=0;x<d.length;x++)f.push(d[x].start);({consequent:h,failed:l}=this.tryParseConditionalConsequent()),[p,d]=this.getArrowLikeExpressions(h)}l&&p.length>1&&this.raise(T.AmbiguousConditionalArrow,n.startLoc),l&&p.length===1&&(this.state=n,f.push(p[0].start),this.state.noArrowAt=f,{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,[]]):Ma(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(T.DeclareClassElement,n):i.value&&this.raise(T.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(u.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):Ea(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(T.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(T.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(T.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(T.GetterMayNotHaveThisParam,a):this.isThisParam(a)&&this.raise(T.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 p=super.parseObjPropValue(e,i,a,n,o,c,h);return l&&((p.value||p).typeParameters=l),p}parseFunctionParamType(e){return this.eat(17)&&(e.type!=="Identifier"&&this.raise(T.PatternIsOptional,e),this.isThisParam(e)&&this.raise(T.ThisParamMayNotBeOptional,e),e.optional=!0),this.match(14)?e.typeAnnotation=this.flowParseTypeAnnotation():this.isThisParam(e)&&this.raise(T.ThisParamAnnotationRequired,e),this.match(29)&&this.isThisParam(e)&&this.raise(T.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(T.TypeBeforeInitializer,a.typeAnnotation),a}checkImportReflection(e){super.checkImportReflection(e),e.module&&e.importKind!=="value"&&this.raise(T.ImportReflectionHasImportType,e.specifiers[0].loc.start)}parseImportSpecifierLocal(e,i,a){i.local=qs(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 d=this.parseIdentifier(!0);h!==null&&!te(this.state.type)?(e.imported=d,e.importKind=h,e.local=this.cloneIdentifier(d)):(e.imported=c,e.importKind=null,e.local=this.parseIdentifier())}else{if(h!==null&&te(this.state.type))e.imported=this.parseIdentifier(!0),e.importKind=h;else{if(i)throw this.raise(u.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 p=qs(e);return a&&p&&this.raise(T.ImportTypeShorthandOnlyInPureImport,e),(a||p)&&this.checkReservedType(e.local.name,e.local.loc.start,!0),l&&!a&&!p&&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===M.j_oTag||c===M.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 f;o=this.flowParseTypeParameterDeclaration();const p=this.forwardNoArrowParamsConversionAt(o,()=>{const x=super.parseMaybeAssign(e,i);return this.resetStartLocationFromNode(x,o),x});(f=p.extra)!=null&&f.parenthesized&&l();const d=this.maybeUnwrapTypeCastExpression(p);return d.type!=="ArrowFunctionExpression"&&l(),d.typeParameters=o,this.resetStartLocationFromNode(d,o),p},a);let h=null;if(c.node&&this.maybeUnwrapTypeCastExpression(c.node).type==="ArrowFunctionExpression"){if(!c.error&&!c.aborted)return c.node.async&&this.raise(T.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(T.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(T.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(T.UnterminatedFlowComment,this.state.curPosition()),a}skipBlockComment(){if(this.hasPlugin("flowComments")&&this.skipFlowComment()){if(this.state.hasFlowComment)throw this.raise(T.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(u.UnterminatedComment,this.state.curPosition())}flowEnumErrorBooleanMemberNotInitialized(e,{enumName:i,memberName:a}){this.raise(T.EnumBooleanMemberNotInitialized,e,{memberName:a,enumName:i})}flowEnumErrorInvalidMemberInitializer(e,i){return this.raise(i.explicitType?i.explicitType==="symbol"?T.EnumInvalidMemberInitializerSymbolType:T.EnumInvalidMemberInitializerPrimaryType:T.EnumInvalidMemberInitializerUnknownType,e,i)}flowEnumErrorNumberMemberNotInitialized(e,i){this.raise(T.EnumNumberMemberNotInitialized,e,i)}flowEnumErrorStringMemberInconsistentlyInitialized(e,i){this.raise(T.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(),p=h.name;if(p==="")continue;/^[a-z]/.test(p)&&this.raise(T.EnumInvalidMemberName,h,{memberName:p,suggestion:p[0].toUpperCase()+p.slice(1),enumName:e}),a.has(p)&&this.raise(T.EnumDuplicateMemberName,h,{memberName:p,enumName:e}),a.add(p);const d={enumName:e,explicitType:i,memberName:p};switch(c.id=h,l.type){case"boolean":{this.flowEnumCheckExplicitTypeMismatch(l.loc,d,"boolean"),c.init=l.value,n.booleanMembers.push(this.finishNode(c,"EnumBooleanMember"));break}case"number":{this.flowEnumCheckExplicitTypeMismatch(l.loc,d,"number"),c.init=l.value,n.numberMembers.push(this.finishNode(c,"EnumNumberMember"));break}case"string":{this.flowEnumCheckExplicitTypeMismatch(l.loc,d,"string"),c.init=l.value,n.stringMembers.push(this.finishNode(c,"EnumStringMember"));break}case"invalid":throw this.flowEnumErrorInvalidMemberInitializer(l.loc,d);case"none":switch(i){case"boolean":this.flowEnumErrorBooleanMemberNotInitialized(l.loc,d);break;case"number":this.flowEnumErrorNumberMemberNotInitialized(l.loc,d);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(T.EnumInvalidExplicitTypeUnknownSupplied,this.state.startLoc,{enumName:e});const{value:i}=this.state;return this.next(),i!=="boolean"&&i!=="number"&&i!=="string"&&i!=="symbol"&&this.raise(T.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 p=c.booleanMembers.length,d=c.numberMembers.length,f=c.stringMembers.length,x=c.defaultedMembers.length;if(!p&&!d&&!f&&!x)return l();if(!p&&!d)return e.members=this.flowEnumStringMembers(c.stringMembers,c.defaultedMembers,{enumName:a}),this.expect(8),this.finishNode(e,"EnumStringBody");if(!d&&!f&&p>=x){for(const A of c.defaultedMembers)this.flowEnumErrorBooleanMemberNotInitialized(A.loc.start,{enumName:a,memberName:A.id.name});return e.members=c.booleanMembers,this.expect(8),this.finishNode(e,"EnumBooleanBody")}else if(!p&&!f&&d>=x){for(const A of c.defaultedMembers)this.flowEnumErrorNumberMemberNotInitialized(A.loc.start,{enumName:a,memberName:A.id.name});return e.members=c.numberMembers,this.expect(8),this.finishNode(e,"EnumNumberBody")}else return this.raise(T.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 Ra={__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:"♦"},ja=/\r\n|[\r\n\u2028\u2029]/,rt=new RegExp(ja.source,"g");function ke(r){switch(r){case 10:case 13:case 8232:case 8233:return!0;default:return!1}}function zs(r,t,s){for(let e=t;e<s;e++)if(ke(r.charCodeAt(e)))return!0;return!1}const Gt=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Yt=/(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/g;function _a(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 ne=re`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 ye(r){return r?r.type==="JSXOpeningFragment"||r.type==="JSXClosingFragment":!1}function ve(r){if(r.type==="JSXIdentifier")return r.name;if(r.type==="JSXNamespacedName")return r.namespace.name+":"+r.name.name;if(r.type==="JSXMemberExpression")return ve(r.object)+"."+ve(r.property);throw new Error("Node had unexpected type: "+r.type)}var Ua=r=>class extends r{jsxReadToken(){let s="",e=this.state.pos;for(;;){if(this.state.pos>=this.length)throw this.raise(ne.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(ne.UnexpectedToken,this.state.curPosition(),{unexpected:this.input[this.state.pos],HTMLEntity:i===125?"&rbrace;":"&gt;"});default:ke(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?`
69
69
  `:`\r
70
- `):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):ke(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=_a[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(Ne(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:zt(this.state.type)?s.name=me(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(M.brace),this.next(),s=this.jsxParseExpressionContainer(s,M.j_oTag),s.expression.type==="JSXEmptyExpression"&&this.raise(ne.AttributeIsEmpty,s),s;case 143:case 134:return this.parseExprAtom();default:throw this.raise(ne.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(M.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(ne.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(M.brace),this.next(),this.expect(21),s.argument=this.parseMaybeAssignAllowIn(),this.setContext(M.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(M.brace),this.next(),this.match(21)?i.push(this.jsxParseSpreadChild(o)):i.push(this.jsxParseExpressionContainer(o,M.j_expr));break}default:this.unexpected()}ye(a)&&!ye(n)&&n!==null?this.raise(ne.MissingClosingTagFragment,n):!ye(a)&&ye(n)?this.raise(ne.MissingClosingTagElement,n,{openingTagName:ve(a.name)}):!ye(a)&&!ye(n)&&ve(n.name)!==ve(a.name)&&this.raise(ne.MissingClosingTagElement,n,{openingTagName:ve(a.name)})}if(ye(a)?(e.openingFragment=a,e.closingFragment=n):(e.openingElement=a,e.closingElement=n),e.children=i,this.match(47))throw this.raise(ne.UnwrappedAdjacentJSXElements,this.state.startLoc);return ye(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===M.j_expr){this.jsxReadToken();return}if(e===M.j_oTag||e===M.j_cTag){if(ae(s)){this.jsxReadWord();return}if(s===62){++this.state.pos,this.finishToken(144);return}if((s===34||s===39)&&e===M.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,M.j_cTag),this.state.canStartJSXElement=!1;else if(i===143)e.push(M.j_oTag);else if(i===144){const a=e[e.length-1];a===M.j_oTag&&s===56||a===M.j_cTag?(e.pop(),this.state.canStartJSXElement=e[e.length-1]===M.j_expr):(this.setContext(M.j_expr),this.state.canStartJSXElement=!0)}else this.state.canStartJSXElement=la(i)}};class $a extends Wt{constructor(){super(...arguments);m(this,"tsNames",new Map)}}class qa extends Xt{constructor(){super(...arguments);m(this,"importsStack",[])}createScope(s){return this.importsStack.push(new Set),new $a(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 za{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 at(r,t){return(r?2:0)|(t?1:0)}class Va{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 Vs(r,t){r.trailingComments===void 0?r.trailingComments=t:r.trailingComments.unshift(...t)}function Ha(r,t){r.leadingComments===void 0?r.leadingComments=t:r.leadingComments.unshift(...t)}function Oe(r,t){r.innerComments===void 0?r.innerComments=t:r.innerComments.unshift(...t)}function Te(r,t,s){let e=null,i=t.length;for(;e===null&&i>0;)e=t[--i];e===null||e.start>s.start?Oe(r,s.comments):Vs(e,s.comments)}class Ka extends Va{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&&Vs(t.leadingNode,s),t.trailingNode!==null&&Ha(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":Te(e,e.properties,t);break;case"CallExpression":case"OptionalCallExpression":Te(e,e.arguments,t);break;case"ImportExpression":Te(e,[e.source,e.options??null],t);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":Te(e,e.params,t);break;case"ArrayExpression":case"ArrayPattern":case"TupleExpression":Te(e,e.elements,t);break;case"ExportNamedDeclaration":case"ImportDeclaration":Te(e,e.specifiers,t);break;case"TSEnumDeclaration":Oe(e,s);break;case"TSEnumBody":Te(e,e.members,t);break;default:Oe(e,s)}else Oe(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 Qt{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",[M.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 fe(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 fe(this.curLine,this.pos-this.lineStart,this.pos+this.startIndex)}clone(){const t=new Qt;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 Ja=function(t){return t>=48&&t<=57};const Hs={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},nt={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 Ks(r,t,s,e,i,a){const n=s,o=e,c=i;let h="",l=null,u=s;const{length:d}=t;for(;;){if(s>=d){a.unterminated(n,o,c),h+=t.slice(u,s);break}const f=t.charCodeAt(s);if(Wa(r,f,t,s)){h+=t.slice(u,s);break}if(f===92){h+=t.slice(u,s);const x=Xa(t,s,e,i,r==="template",a);x.ch===null&&!l?l={pos:s,lineStart:e,curLine:i}:h+=x.ch,{pos:s,lineStart:e,curLine:i}=x,u=s}else f===8232||f===8233?(++s,++i,e=s):f===10||f===13?r==="template"?(h+=t.slice(u,s)+`
71
- `,++s,f===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 Wa(r,t,s,e){return r==="template"?t===96||t===36&&s.charCodeAt(e+1)===123:t===(r==="double"?34:39)}function Xa(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(`
72
- `);case 114:return o("\r");case 120:{let h;return{code:h,pos:t}=Zt(r,t,s,e,2,!1,n,a),o(h===null?null:String.fromCharCode(h))}case 117:{let h;return{code:h,pos:t}=Ws(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],d=parseInt(u,8);d>255&&(u=u.slice(0,-1),d=parseInt(u,8)),t+=u.length-1;const f=r.charCodeAt(t);if(u!=="0"||f===56||f===57){if(i)return o(null);a.strictNumericEscape(h,s,e)}return o(String.fromCharCode(d))}return o(String.fromCharCode(c))}}function Zt(r,t,s,e,i,a,n,o){const c=t;let h;return{n:h,pos:t}=Js(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 Js(r,t,s,e,i,a,n,o,c,h){const l=t,u=i===16?Hs.hex:Hs.decBinOct,d=i===16?nt.hex:i===10?nt.dec:i===8?nt.oct:nt.bin;let f=!1,x=0;for(let A=0,j=a??1/0;A<j;++A){const C=r.charCodeAt(t);let D;if(C===95&&o!=="bail"){const U=r.charCodeAt(t-1),ce=r.charCodeAt(t+1);if(o){if(Number.isNaN(ce)||!d(ce)||u.has(U)||u.has(ce)){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(C>=97?D=C-97+10:C>=65?D=C-65+10:Ja(C)?D=C-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,f=!0;else break}++t,x=x*i+D}return t===l||a!=null&&t-l!==a||f?{n:null,pos:t}:{n:x,pos:t}}function Ws(r,t,s,e,i,a){const n=r.charCodeAt(t);let o;if(n===123){if(++t,{code:o,pos:t}=Zt(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}=Zt(r,t,s,e,4,!1,i,a));return{code:o,pos:t}}function Ke(r,t,s){return new fe(s,r-t,r)}const Ga=new Set([103,109,115,105,121,117,100,118]);class Ya{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 et(t.startLoc,t.endLoc)}}class Qa extends Ka{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,Ke(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,Ke(s,e,i))},unterminated:(s,e,i)=>{throw this.raise(p.UnterminatedString,Ke(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,Ke(s,e,i))}}));this.state=new Qt,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 Ya(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 Gt.lastIndex=s,Gt.test(this.input)?Gt.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 Yt.lastIndex=s,Yt.test(this.input)?Yt.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,rt.lastIndex=i+2;rt.test(this.input)&&rt.lastIndex<=a;)++this.state.curLine,this.state.lineStart=rt.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 et(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(;!ke(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 et(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(ja(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());ae(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;!ke(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(ae(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,Q(s,1));const l=this.input.charCodeAt(n);if(ke(l))throw this.raise(p.UnterminatedRegExp,Q(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=()=>Q(s,n+2-e);for(;n<this.length;){const l=this.codePointAtPos(n),u=String.fromCharCode(l);if(Ga.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(Ne(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}=Js(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,Q(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(ae(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 d=this.input.slice(e,this.state.pos);if(this.recordStrictModeErrors(p.StrictOctalLiteral,i),!this.state.strict){const f=d.indexOf("_");f>0&&this.raise(p.ZeroDigitNumericSeparator,Q(i,f))}o=c&&!/[89]/.test(d)}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),ae(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}=Ws(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}=Ks(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}=Ks("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 fe(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(Ne(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?ae:Ne;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=Bt.get(e);i!==void 0?this.finishToken(i,me(i)):this.finishToken(132,e)}checkKeywordEscapes(){const{type:s}=this.state;zt(s)&&this.state.containsEsc&&this.raise(p.InvalidEscapedReservedWord,this.state.startLoc,{reservedWord:me(s)})}raise(s,e,i={}){const a=e instanceof fe?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 fe?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?me(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,Ke(e,i,a))}}}class Za{constructor(){m(this,"privateNames",new Set);m(this,"loneAccessors",new Map);m(this,"undefinedPrivateNames",new Map)}}class en{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 Za)}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,d=s&3;o=u===d||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 ot{constructor(t=0){this.type=t}canBeArrowParameterDeclaration(){return this.type===2||this.type===1}isCertainlyParameterDeclaration(){return this.type===3}}class Xs extends ot{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 tn{constructor(t){m(this,"parser");m(this,"stack",[new ot]);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 sn(){return new ot(3)}function rn(){return new Xs(1)}function an(){return new Xs(2)}function Gs(){return new ot}class nn extends Qa{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!(Ne(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 zs(this.input,this.offsetToSourcePos(this.state.lastTokEndLoc.index),this.state.start)}hasFollowingLineBreak(){return zs(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 Ls(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 za;const c=this.classScope;this.classScope=new en(this);const h=this.expressionScope;return this.expressionScope=new tn(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 ct{constructor(){m(this,"shorthandAssignLoc",null);m(this,"doubleProtoLoc",null);m(this,"privateKeyLoc",null);m(this,"optionalParametersLoc",null)}}class es{constructor(t,s,e){m(this,"type","");this.start=s,this.end=0,this.loc=new et(e),(t==null?void 0:t.optionFlags)&128&&(this.range=[s,0]),t!=null&&t.filename&&(this.loc.filename=t.filename)}}const Ys=es.prototype;class on extends nn{startNode(){const t=this.state.startLoc;return new es(this,t.index,t)}startNodeAt(t){return new es(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(Ys);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(Ys);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 Qs=r=>r.type==="ParenthesizedExpression"?Qs(r.expression):r;class cn extends on{toAssignable(t,s=!1){var i,a,n;let e;switch((t.type==="ParenthesizedExpression"||(i=t.extra)!=null&&i.parenthesized)&&(e=Qs(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 x;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:A}=t;i&&(i.has(A)?this.raise(p.ParamDupe,t):i.add(A));return}const h=this.isValidLVal(o,!(n||(x=t.extra)!=null&&x.parenthesized)&&s.type==="AssignmentExpression",e);if(h===!0)return;if(h===!1){const A=e===64?p.InvalidLhs:p.InvalidLhsBinding;this.raise(A,t,{ancestor:s});return}let l,u;typeof h=="string"?(l=h,u=o==="ParenthesizedExpression"):[l,u]=h;const d=o==="ArrayPattern"||o==="ObjectPattern"?{type:o}:s,f=t[l];if(Array.isArray(f))for(const A of f)A&&this.checkLVal(A,d,e,i,a,u);else f&&this.checkLVal(f,d,e,i,a,u)}checkIdentifier(t,s,e=!1){this.state.strict&&(e?$s(t.name,this.inModule):Us(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 hn(r){if(r==null)throw new Error(`Unexpected ${r} value.`);return r}function Zs(r){if(!r)throw new Error("Assert fail")}const P=re`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 ln(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 ei(r){return r==="private"||r==="public"||r==="protected"}function un(r){return r==="in"||r==="out"}function ts(r){var t;if((t=r.extra)!=null&&t.parenthesized)return!1;switch(r.type){case"Identifier":return!0;case"MemberExpression":return!r.computed&&ts(r.object);case"TSInstantiationExpression":return ts(r.expression);default:return!1}}var pn=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:P.InvalidModifierOnTypeParameter}));m(this,"tsParseConstModifier",this.tsParseModifiers.bind(this,{allowedModifiers:["const"],disallowedModifiers:["in","out"],errorTemplate:P.InvalidModifierOnTypeParameterPositions}));m(this,"tsParseInOutConstModifiers",this.tsParseModifiers.bind(this,{allowedModifiers:["in","out","const"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:P.InvalidModifierOnTypeParameter}))}getScopeHandler(){return qa}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=P.InvalidModifierOnTypeMember},o){const c=(l,u,d,f)=>{u===d&&o[f]&&this.raise(P.InvalidModifiersOrder,l,{orderedModifiers:[d,f]})},h=(l,u,d,f)=>{(o[d]&&u===f||o[f]&&u===d)&&this.raise(P.IncompatibleModifiers,l,{modifiers:[d,f]})};for(;;){const{startLoc:l}=this.state,u=this.tsParseModifier(e.concat(i??[]),a,o.static);if(!u)break;ei(u)?o.accessibility?this.raise(P.DuplicateAccessibilityModifier,l,{modifier:u}):(c(l,u,u,"override"),c(l,u,u,"static"),c(l,u,u,"readonly"),o.accessibility=u):un(u)?(o[u]&&this.raise(P.DuplicateModifier,l,{modifier:u}),o[u]=!0,c(l,u,"in","out")):(Object.hasOwn(o,u)?this.raise(P.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 hn(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(P.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(P.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(P.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(P.ReadonlyForMethodSignature,e);const a=e;a.kind&&this.match(47)&&this.raise(P.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(P.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(P.AccessorCannotDeclareThisParameter,this.state.curPosition()),c.type==="Identifier"&&c.optional&&this.raise(P.SetAccessorCannotHaveOptionalParameter,this.state.curPosition()),c.type==="RestElement"&&this.raise(P.SetAccessorCannotHaveRestParameter,this.state.curPosition())}a[o]&&this.raise(P.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(P.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=te(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 d=this.state.value,f=this.tsParseNonArrayType();this.lookaheadCharCode()===58?(n=!0,o=this.createIdentifier(this.startNodeAt(a),d),this.expect(17),this.expect(14),h=this.tsParseType()):(n=!1,h=f,this.expect(17))}else h=this.tsParseType(),c=this.eat(17),n=this.eat(14);if(n){let d;o?(d=this.startNodeAt(a),d.optional=c,d.label=o,d.elementType=h,this.eat(17)&&(d.optional=!0,this.raise(P.TupleOptionalAfterType,this.state.lastTokStartLoc))):(d=this.startNodeAt(a),d.optional=c,this.raise(P.InvalidTupleMemberLabel,h),d.label=h,d.elementType=this.tsParseType()),h=this.finishNode(d,"TSNamedTupleMember")}else if(c){const d=this.startNodeAt(a);d.typeAnnotation=h,h=this.finishNode(d,"TSOptionalType")}if(i){const d=this.startNodeAt(e);d.typeAnnotation=h,h=this.finishNode(d,"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":ln(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(P.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 ya(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(){Zs(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(P.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();ts(n)||this.raise(P.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(P.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(P.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()!==M.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(P.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(P.EmptyTypeArguments,e):!this.state.inType&&this.curContext()===M.brace&&this.reScan_lt_gt(),this.expect(48),this.finishNode(e,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return xa(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(P.UnexpectedParameterModifier,a);const l=this.parseMaybeDefault();e&2&&this.parseFunctionParamType(l);const u=this.parseMaybeDefault(l.loc.start,l);if(o||h||c){const d=this.startNodeAt(a);return i.length&&(d.decorators=i),o&&(d.accessibility=o),h&&(d.readonly=h),c&&(d.override=c),u.type!=="Identifier"&&u.type!=="AssignmentPattern"&&this.raise(P.UnsupportedParameterPropertyKind,d),d.parameter=u,this.finishNode(d,"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(P.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(P.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(P.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 f=this.tsTryParseGenericAsyncArrowFunction(i);if(f)return f}const l=this.tsParseTypeArgumentsInExpression();if(!l)return;if(o&&!this.match(10)){c=this.state.curPosition();return}if(Vt(this.state.type)){const f=super.parseTaggedTemplateExpression(e,i,n);return f.typeArguments=l,f}if(!a&&this.eat(10)){const f=this.startNodeAt(i);return f.callee=e,f.arguments=this.parseCallExpressionArguments(11),this.tsCheckForInvalidTypeCasts(f.arguments),f.typeArguments=l,n.optionalChainMember&&(f.optional=o),this.finishCallExpression(f,n.optionalChainMember)}const u=this.state.type;if(u===48||u===52||u!==10&&He(u)&&!this.hasPrecedingLineBreak())return;const d=this.startNodeAt(i);return d.expression=e,d.typeArguments=l,this.finishNode(d,"TSInstantiationExpression")});if(c&&this.unexpected(c,10),h)return h.type==="TSInstantiationExpression"&&((this.match(16)||this.match(18)&&this.lookaheadCharCode()!==40)&&this.raise(P.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(it(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(P.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(P.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(P.InitializerNotAllowedInAmbientContext,h):dn(h,this.hasPlugin("estree"))||this.raise(P.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=>ei(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:P.InvalidModifierOnTypeParameterPositions},i);const o=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(i,n)&&this.raise(P.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(P.IndexSignatureHasAbstract,i),i.accessibility&&this.raise(P.IndexSignatureHasAccessibility,i,{modifier:i.accessibility}),i.declare&&this.raise(P.IndexSignatureHasDeclare,i),i.override&&this.raise(P.IndexSignatureHasOverride,i);return}!this.state.inAbstractClass&&i.abstract&&this.raise(P.NonAbstractClassHasAbstractMethod,i),i.override&&(a.hadSuperClass||this.raise(P.OverrideNotInSubClass,i)),super.parseClassMemberWithIsStatic(e,i,a,n)}parsePostMemberNameModifiers(e){this.eat(17)&&(e.optional=!0),e.readonly&&this.match(10)&&this.raise(P.ClassMethodHasReadonly,e),e.declare&&this.match(10)&&this.raise(P.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(P.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(P.DeclareClassFieldHasInitializer,this.state.startLoc),e.abstract&&this.match(29)){const{key:i}=e;this.raise(P.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(P.PrivateElementHasAbstract,e),e.accessibility&&this.raise(P.PrivateElementHasAccessibility,e,{modifier:e.accessibility}),this.parseClassPropertyAnnotation(e),super.parseClassPrivateProperty(e)}parseClassAccessorProperty(e){return this.parseClassPropertyAnnotation(e),e.optional&&this.raise(P.AccessorCannotBeOptional,e),super.parseClassAccessorProperty(e)}pushClassMethod(e,i,a,n,o,c){const h=this.tsTryParseTypeParameters(this.tsParseConstModifier);h&&o&&this.raise(P.ConstructorHasTypeParameters,h);const{declare:l=!1,kind:u}=i;l&&(u==="get"||u==="set")&&this.raise(P.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===M.j_oTag||u===M.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 d,f;c=this.tsParseTypeParameters(this.tsParseConstModifier);const u=super.parseMaybeAssign(e,i);if((u.type!=="ArrowFunctionExpression"||(d=u.extra)!=null&&d.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&&!((f=u.typeParameters.extra)!=null&&f.trailingComma)){const x=u.typeParameters.params[0];x.constraint||this.raise(P.SingleTypeParameterWithoutTrailingComma,Q(x.loc.end,1),{typeParameterName:x.name.name})}return u},a);if(!h.error&&!h.aborted)return c&&this.reportReservedArrowTypeParam(c),h.node;if(!n&&(Zs(!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(P.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(P.UnexpectedTypeCastInParameter,e):this.raise(P.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(P.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(P.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:f}=l;this.raise(P.AbstractMethodHasImplementation,l,{methodName:f.type==="Identifier"&&!l.computed?f.name:`[${this.input.slice(this.offsetToSourcePos(f.start),this.offsetToSourcePos(f.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 d=c.loc.start;if(this.isContextual(93)){const x=this.parseIdentifier();if(this.isContextual(93)){const A=this.parseIdentifier();te(this.state.type)?(l=!0,c=x,h=i?this.parseIdentifier():this.parseModuleExportName(),u=!1):(h=A,u=!1)}else te(this.state.type)?(u=!1,h=i?this.parseIdentifier():this.parseModuleExportName()):(l=!0,c=x)}else te(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?P.TypeModifierIsUsedInTypeImports:P.TypeModifierIsUsedInTypeExports,d),e[n]=c,e[o]=h;const f=i?"importKind":"exportKind";e[f]=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 fn(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:si(r.object)}function dn(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)||mn(r,t)||s==="TemplateLiteral"&&r.expressions.length===0||fn(r))}function ti(r,t){return t?r.type==="Literal"&&(typeof r.value=="number"||"bigint"in r):r.type==="NumericLiteral"||r.type==="BigIntLiteral"}function mn(r,t){if(r.type==="UnaryExpression"){const{operator:s,argument:e}=r;if(s==="-"&&ti(e,t))return!0}return!1}function si(r){return r.type==="Identifier"?!0:r.type!=="MemberExpression"||r.computed?!1:si(r.object)}const ii=re`placeholders`({ClassNameIsRequired:"A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."});var yn=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(ii.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(me(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(ii.UnexpectedSpace,this.state.lastTokEndLoc)}},xn=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 ri=["fsharp","hack"],ai=["^^","@@","^","%","#"];function Pn(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(!ri.includes(t)){const s=ri.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(!ai.includes(s)){const e=ai.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 ni={estree:na,jsx:Ua,flow:Ba,typescript:pn,v8intrinsic:xn,placeholders:yn},bn=Object.keys(ni);class gn extends cn{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 ct,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)),ua(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")?He(c):He(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>=it(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(fa(i)&&(this.prodParam.hasIn||!this.match(58))){let a=it(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=it(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,Pa(t)?s-1:s)}parseHackPipeBody(){var i;const{startLoc:t}=this.state,s=this.parseMaybeAssign();return Zr.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(ma(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")?He(c):He(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(;da(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(Vt(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(an()),n=new ct),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&&Oe(t,s.innerComments),s.callee.trailingComments&&Oe(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());ae(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=Q(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:me(i)})}testTopicReferenceConfiguration(t,s,e){switch(t){case"hack":return this.hasPlugin(["pipelineOperator",{topicToken:me(e)}]);case"smart":return e===27;default:throw this.raise(p.PipeTopicRequiresHackPipes,s)}}parseAsyncArrowUnaryFunction(t){this.prodParam.enter(at(!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(Q(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(rn());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 ct;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 x=this.state.startLoc;if(l=this.state.startLoc,o.push(this.parseParenItem(this.parseRestBinding(),x)),!this.checkCommaAfterRest(41))break}else o.push(this.parseMaybeAssignAllowIn(c,this.parseParenItem))}const d=this.state.lastTokEndLoc;this.expect(11),this.state.maybeInArrowParameters=i,this.state.inFSharpPipelineDirectBody=a;let f=this.startNodeAt(s);return t&&this.shouldParseArrow(o)&&(f=this.parseArrow(f))?(this.checkDestructuringPrivate(c),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(f,o,!1),f):(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,d)):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(Q(e,1));a===null&&(t||this.raise(p.InvalidEscapeSequenceTemplate,Q(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,`
73
- `),cooked:a===null?null:a.slice(1,h)},o.tail=c,this.next();const u=this.finishNode(o,"TemplateElement");return this.resetEndLocation(u,Q(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(te(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(at(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=at(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(Gs()),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;te(i)?s=this.state.value:this.unexpected();const a=ha(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||!Na(t))return;if(e&&Ia(t)){this.raise(p.UnexpectedKeyword,s,{keyword:t});return}if((this.state.strict?i?$s:js:Rs)(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||Vt(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},wn={kind:2},Tn=/[\uD800-\uDFFF]/u,is=/in(?:stanceof)?/y;function An(r,t,s){for(let e=0;e<r.length;e++){const i=r[e],{type:a}=i;typeof a=="number"&&(i.type=Fs(a))}return r}class Sn extends gn{parseTopLevel(t,s){return t.program=this.parseProgram(s),t.comments=this.comments,this.optionFlags&256&&(t.tokens=An(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",Q(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(ae(t)){if(is.lastIndex=s,is.test(this.input)){const e=this.codePointAtPos(is.lastIndex);if(!Ne(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(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 d;c?(d="await using",this.recordAwaitIfAllowed()||this.raise(p.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):d=this.state.value,this.next(),this.parseVar(u,!0,d);const f=this.finishNode(u,"VariableDeclaration"),x=this.match(58);return x&&h&&this.raise(p.ForInUsing,f),(x||this.isContextual(102))&&f.declarations.length===1?this.parseForIn(t,f,s):(s!==null&&this.unexpected(s),this.parseFor(t,f))}}const i=this.isContextual(95),a=new ct,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(wn),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=pa(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(at(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(sn()),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 C=this.match(139);if(this.parseClassElementName(l),this.parsePostMemberNameModifiers(l),C){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 d=!this.state.containsEsc&&O(this.state.type),f=this.parseClassElementName(s),x=d?f.name:null,A=this.isPrivateName(f),j=this.state.startLoc;if(this.parsePostMemberNameModifiers(u),this.isClassMethod()){if(l.kind="method",A){this.pushClassPrivateMethod(t,n,!1,!1);return}const C=this.isNonstaticConstructor(a);let D=!1;C&&(a.kind="constructor",e.hadConstructor&&!this.hasPlugin("typescript")&&this.raise(p.DuplicateConstructor,f),C&&this.hasPlugin("typescript")&&s.override&&this.raise(p.OverrideOnConstructor,f),e.hadConstructor=!0,D=e.hadSuperClass),this.pushClassMethod(t,a,!1,!1,C,D)}else if(this.isClassProperty())A?this.pushClassPrivateProperty(t,c):this.pushClassProperty(t,o);else if(x==="async"&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(f);const C=this.eat(55);u.optional&&this.unexpected(j),l.kind="method";const D=this.match(139);this.parseClassElementName(l),this.parsePostMemberNameModifiers(u),D?this.pushClassPrivateMethod(t,n,C,!0):(this.isNonstaticConstructor(a)&&this.raise(p.ConstructorIsAsync,a.key),this.pushClassMethod(t,a,C,!0,!1,!1))}else if((x==="get"||x==="set")&&!(this.match(55)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(f),l.kind=x;const C=this.match(139);this.parseClassElementName(a),C?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(x==="accessor"&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(f);const C=this.match(139);this.parseClassElementName(o),this.pushClassAccessorProperty(t,h,C)}else this.isLineTerminator()?A?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(Gs()),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 d;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 f=t;if(this.checkExport(f,!0,!1,!!f.source),((d=f.declaration)==null?void 0:d.type)==="ClassDeclaration")this.maybeTakeDecorators(s,f.declaration,f);else if(s)throw this.raise(p.UnsupportedDecoratorExport,t);return this.sawUnambiguousESM=!0,this.finishNode(f,"ExportNamedDeclaration")}if(this.eat(65)){const f=t,x=this.parseExportDefaultExpression();if(f.declaration=x,x.type==="ClassDeclaration")this.maybeTakeDecorators(s,x,f);else if(s)throw this.raise(p.UnsupportedDecoratorExport,t);return this.checkExport(f,!0,!0),this.sawUnambiguousESM=!0,this.finishNode(f,"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=Tn.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(te(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(te(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 oi extends Sn{constructor(t,s,e){t=ra(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 Xt}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 In(r,t){if((t==null?void 0:t.sourceType)==="unambiguous"){t=Object.assign({},t);try{t.sourceType="module";const s=ht(t,r),e=s.parse();if(s.sawUnambiguousESM)return e;if(s.ambiguousScriptDifferentAst)try{return t.sourceType="script",ht(t,r).parse()}catch{}else e.program.sourceType="script";return e}catch(s){try{return t.sourceType="script",ht(t,r).parse()}catch{}throw s}}else return ht(t,r).parse()}function En(r){const t={};for(const s of Object.keys(r))t[s]=Fs(r[s]);return t}En(ca);function ht(r,t){let s=oi;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||{})}Pn(e),s=Cn(e)}return new s(r,t,e)}const ci=new Map;function Cn(r){const t=[];for(const i of bn)r.has(i)&&t.push(i);const s=t.join("|");let e=ci.get(s);if(!e){e=oi;for(const i of t)e=ni[i](e);ci.set(s,e)}return e}function lt(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]=lt(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 lt(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]=lt(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 De(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 hi(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=De(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=V.string();break}case"number":{o=V.number();break}case"boolean":{o=V.boolean();break}case"date":{o=V.date();break}case"json":{o=V.json();break}case"any":{o=V.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 V.entity(s)}function li(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=De(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]=hi(e,s.value.arguments[0])}return t}function Nn(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=De(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=li(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=hi(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 kn(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=De(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]=Nn(e,s.value)}return t}function vn(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=De(n);if(n.value.type!=="ObjectExpression")throw new Error(`Failed to extract ${o}, expected an \`ObjectExpression\`, got \`${n.value.type}\`.`);switch(De(n)){case"entities":{t=li(n.value);break}case"links":{s=lt(n.value)||{};break}case"rooms":{e=kn(n.value);break}}}}if(!t)throw new Error("Could not extract schema, did not find any entities.");return V.schema({entities:t,links:s,rooms:e})}function On(r,t="instant.schema.ts"){var e;const s=In(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 vn(s)}const ut={"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(ut).map(([r,t])=>[`${t.cardinality}-${t["unique?"]}`,r]));const ui=(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}),Dn=r=>{const t=`${r.forward.has}-${r.reverse.has}`;return{"checked-data-type":null,"index?":!1,...ut[t],"required?":!1,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}}},pt=(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},Ae=(r,t)=>{const s=pt(r.identifier,t);return{"attr-id":s.id,"forward-identity":s["forward-identity"]}},Ln={index:Ae,unique:Ae,required:Ae,"remove-index":Ae,"remove-unique":Ae,"remove-required":Ae,"delete-attr":(r,t)=>pt(r.identifier,t).id,"update-attr":(r,t)=>{const s=pt(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=ms(),e=[s,r.identifier.namespace,r.identifier.attrName],i=[];return i.push(["add-attr",{"forward-identity":e,"reverse-identity":r["reverse-identity"]?[ms(),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":Ae,"check-data-type":(r,t)=>{const s=pt(r.identifier,t);return{"attr-id":s.id,"checked-data-type":r["checked-data-type"],"forward-identity":s["forward-identity"]}}};function oe(r,t,s){var e;return!!((e=r[t])!=null&&e.has(s))}const Mn=(r,t)=>{if(!t)throw new Error("Existing attributes are required");const s=[];return r.forEach(e=>{const i=Ln[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},Fn=async(r,t,s,e)=>{var U,ce;const i=[],a=r.entities,n=t.entities,o=Object.keys(a),c=Object.keys(n),h=o.filter(b=>!c.includes(b));for(const b of h)Object.keys(a[b].attrs).forEach(_=>{oe(e,b,_)||i.push({type:"delete-attr",identifier:{attrName:_,namespace:b}})}),!oe(e,b,"id")&&i.push({type:"delete-attr",identifier:{attrName:"id",namespace:b}});const l=c.filter(b=>!o.includes(b));for(const b of l){oe(e,b,"id")||i.push({type:"add-attr","forward-identity":{namespace:b,attrName:"id"},identifier:{attrName:"id",namespace:b},"index?":!1,"required?":!0,cardinality:"one","unique?":!0,"value-type":"blob"});for(const _ of Object.keys(n[b].attrs)){if(oe(e,b,_))continue;const W=n[b].attrs[_];i.push(ui(W,b,_))}}const u=o.filter(b=>c.includes(b));for(const b of u){const _=Object.keys(n[b].attrs).filter(B=>oe(e,b,B)?!1:!Object.keys(a[b].attrs).includes(B)),W=Object.keys(a[b].attrs).filter(B=>oe(e,b,B)?!1:!Object.keys(n[b].attrs).includes(B)),Se=await mi(_,W,s,{type:"attribute",entityName:b});Object.keys(a[b].attrs).filter(B=>Object.keys(n[b].attrs).includes(B)).forEach(B=>{oe(e,b,B)||i.push(...pi({attrName:B,namespace:b},a[b].attrs[B],n[b].attrs[B]))}),Se.deleted.forEach(B=>{i.push({type:"delete-attr",identifier:{attrName:B,namespace:b}})}),Se.created.forEach(B=>{const Je=t.entities[b].attrs[B];i.push(ui(Je,b,B))}),Se.renamed.forEach(B=>{i.push({type:"update-attr",identifier:{attrName:B.from,namespace:b},partialAttr:{"value-type":"blob",cardinality:"one","forward-identity":{attrName:B.to,namespace:b}}}),i.push(...pi({attrName:B.from,namespace:b},a[b].attrs[B.from],n[b].attrs[B.to]))})}const d=Object.values(r.links).filter(b=>!oe(e,b.forward.on,b.forward.label)),f=Object.values(t.links).filter(b=>!oe(e,b.forward.on,b.forward.label)),x=b=>`${b.forward.on}<->${b.reverse.on}`,A=b=>`${b.forward.on}.${b.forward.label}<->${b.reverse.on}.${b.reverse.label}`,j=new Map,C=new Map;for(const b of f){const _=x(b),W=j.get(_)||[];W.push(b),j.set(_,W)}for(const b of d){const _=x(b),W=C.get(_)||[];W.push(b),C.set(_,W)}const D=new Set([...C.keys(),...j.keys()]);for(const b of D){const _=C.get(b)||[],W=j.get(b)||[],Se=_.map($=>A($)),yt=W.map($=>A($)),B=yt.filter($=>!Se.includes($)),Je=Se.filter($=>!yt.includes($));Se.filter($=>yt.includes($)).forEach($=>{const q=_.find(Ie=>A(Ie)===$),X=W.find(Ie=>A(Ie)===$);!q||!X||i.push(...fi({namespace:q.forward.on,attrName:q.forward.label},q,X))});const rs=await mi(B,Je,s,{type:"link",forwardEntityName:(U=_[0])==null?void 0:U.forward.on,reverseEntityName:(ce=_[0])==null?void 0:ce.reverse.on});rs.deleted.forEach($=>{const q=_.find(X=>A(X)===$);q&&i.push({type:"delete-attr",identifier:{attrName:q.forward.label,namespace:q.forward.on}})}),rs.created.forEach($=>{const q=W.find(X=>A(X)===$);q&&i.push(Dn(q))}),rs.renamed.forEach($=>{const q=_.find(Ie=>A(Ie)===$.from),X=W.find(Ie=>A(Ie)===$.to);!q||!X||(i.push({type:"update-attr",identifier:{attrName:q.forward.label,namespace:q.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(...fi({attrName:q.forward.label,namespace:q.forward.on},q,X)))})}return i},pi=(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},fi=(r,t,s)=>{const e=[],i=`${t.forward.has}-${t.reverse.has}`,{cardinality:a,"unique?":n}=ut[i],o=`${s.forward.has}-${s.reverse.has}`,{cardinality:c,"unique?":h}=ut[o];return!n&&h&&e.push({type:"unique",identifier:r}),!h&&h!==n&&e.push({type:"remove-unique",identifier:r}),(t.reverse.onDelete!==s.reverse.onDelete||t.forward.onDelete!==s.forward.onDelete||a!==c)&&e.push({type:"update-attr",identifier:r,partialAttr:{"value-type":"ref","on-delete-reverse":s.reverse.onDelete,"on-delete":s.forward.onDelete,cardinality:c}}),e},di=r=>typeof r=="object",mi=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);di(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};S.InstantOAuthError=v,S.OAuthHandler=or,S.PlatformApi=Jr,S.ProgressPromise=Ot,S.SchemaValidationError=ue,S.apiSchemaToInstantSchemaDef=$e,S.convertTxSteps=Mn,S.diffSchemas=Fn,S.exchangeCodeForToken=Ir,S.exchangeRefreshToken=Ts,S.generatePermsTypescriptFile=cr,S.generateSchemaTypescriptFile=Ar,S.i=V,S.isRenamePromptItem=di,S.schemaTypescriptFileToInstantSchema=On,S.translatePlanSteps=Ss,S.validateSchema=Sr,S.version=Ee,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
70
+ `):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(u.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):ke(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=Ra[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(Ne(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:zt(this.state.type)?s.name=me(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(M.brace),this.next(),s=this.jsxParseExpressionContainer(s,M.j_oTag),s.expression.type==="JSXEmptyExpression"&&this.raise(ne.AttributeIsEmpty,s),s;case 143:case 134:return this.parseExprAtom();default:throw this.raise(ne.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(M.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(ne.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(M.brace),this.next(),this.expect(21),s.argument=this.parseMaybeAssignAllowIn(),this.setContext(M.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(M.brace),this.next(),this.match(21)?i.push(this.jsxParseSpreadChild(o)):i.push(this.jsxParseExpressionContainer(o,M.j_expr));break}default:this.unexpected()}ye(a)&&!ye(n)&&n!==null?this.raise(ne.MissingClosingTagFragment,n):!ye(a)&&ye(n)?this.raise(ne.MissingClosingTagElement,n,{openingTagName:ve(a.name)}):!ye(a)&&!ye(n)&&ve(n.name)!==ve(a.name)&&this.raise(ne.MissingClosingTagElement,n,{openingTagName:ve(a.name)})}if(ye(a)?(e.openingFragment=a,e.closingFragment=n):(e.openingElement=a,e.closingElement=n),e.children=i,this.match(47))throw this.raise(ne.UnwrappedAdjacentJSXElements,this.state.startLoc);return ye(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===M.j_expr){this.jsxReadToken();return}if(e===M.j_oTag||e===M.j_cTag){if(ae(s)){this.jsxReadWord();return}if(s===62){++this.state.pos,this.finishToken(144);return}if((s===34||s===39)&&e===M.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,M.j_cTag),this.state.canStartJSXElement=!1;else if(i===143)e.push(M.j_oTag);else if(i===144){const a=e[e.length-1];a===M.j_oTag&&s===56||a===M.j_cTag?(e.pop(),this.state.canStartJSXElement=e[e.length-1]===M.j_expr):(this.setContext(M.j_expr),this.state.canStartJSXElement=!0)}else this.state.canStartJSXElement=la(i)}};class $a extends Wt{constructor(){super(...arguments);m(this,"tsNames",new Map)}}class qa extends Xt{constructor(){super(...arguments);m(this,"importsStack",[])}createScope(s){return this.importsStack.push(new Set),new $a(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(u.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 za{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 at(r,t){return(r?2:0)|(t?1:0)}class Va{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 Vs(r,t){r.trailingComments===void 0?r.trailingComments=t:r.trailingComments.unshift(...t)}function Ha(r,t){r.leadingComments===void 0?r.leadingComments=t:r.leadingComments.unshift(...t)}function De(r,t){r.innerComments===void 0?r.innerComments=t:r.innerComments.unshift(...t)}function we(r,t,s){let e=null,i=t.length;for(;e===null&&i>0;)e=t[--i];e===null||e.start>s.start?De(r,s.comments):Vs(e,s.comments)}class Ka extends Va{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&&Vs(t.leadingNode,s),t.trailingNode!==null&&Ha(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":we(e,e.properties,t);break;case"CallExpression":case"OptionalCallExpression":we(e,e.arguments,t);break;case"ImportExpression":we(e,[e.source,e.options??null],t);break;case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":case"ObjectMethod":case"ClassMethod":case"ClassPrivateMethod":we(e,e.params,t);break;case"ArrayExpression":case"ArrayPattern":case"TupleExpression":we(e,e.elements,t);break;case"ExportNamedDeclaration":case"ImportDeclaration":we(e,e.specifiers,t);break;case"TSEnumDeclaration":De(e,s);break;case"TSEnumBody":we(e,e.members,t);break;default:De(e,s)}else De(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 Qt{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",[M.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 fe(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 fe(this.curLine,this.pos-this.lineStart,this.pos+this.startIndex)}clone(){const t=new Qt;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 Ja=function(t){return t>=48&&t<=57};const Hs={decBinOct:new Set([46,66,69,79,95,98,101,111]),hex:new Set([46,88,95,120])},nt={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 Ks(r,t,s,e,i,a){const n=s,o=e,c=i;let h="",l=null,p=s;const{length:d}=t;for(;;){if(s>=d){a.unterminated(n,o,c),h+=t.slice(p,s);break}const f=t.charCodeAt(s);if(Wa(r,f,t,s)){h+=t.slice(p,s);break}if(f===92){h+=t.slice(p,s);const x=Xa(t,s,e,i,r==="template",a);x.ch===null&&!l?l={pos:s,lineStart:e,curLine:i}:h+=x.ch,{pos:s,lineStart:e,curLine:i}=x,p=s}else f===8232||f===8233?(++s,++i,e=s):f===10||f===13?r==="template"?(h+=t.slice(p,s)+`
71
+ `,++s,f===13&&t.charCodeAt(s)===10&&++s,++i,p=e=s):a.unterminated(n,o,c):++s}return{pos:s,str:h,firstInvalidLoc:l,lineStart:e,curLine:i}}function Wa(r,t,s,e){return r==="template"?t===96||t===36&&s.charCodeAt(e+1)===123:t===(r==="double"?34:39)}function Xa(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(`
72
+ `);case 114:return o("\r");case 120:{let h;return{code:h,pos:t}=Zt(r,t,s,e,2,!1,n,a),o(h===null?null:String.fromCharCode(h))}case 117:{let h;return{code:h,pos:t}=Ws(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 p=/^[0-7]+/.exec(r.slice(h,t+2))[0],d=parseInt(p,8);d>255&&(p=p.slice(0,-1),d=parseInt(p,8)),t+=p.length-1;const f=r.charCodeAt(t);if(p!=="0"||f===56||f===57){if(i)return o(null);a.strictNumericEscape(h,s,e)}return o(String.fromCharCode(d))}return o(String.fromCharCode(c))}}function Zt(r,t,s,e,i,a,n,o){const c=t;let h;return{n:h,pos:t}=Js(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 Js(r,t,s,e,i,a,n,o,c,h){const l=t,p=i===16?Hs.hex:Hs.decBinOct,d=i===16?nt.hex:i===10?nt.dec:i===8?nt.oct:nt.bin;let f=!1,x=0;for(let A=0,_=a??1/0;A<_;++A){const C=r.charCodeAt(t);let O;if(C===95&&o!=="bail"){const U=r.charCodeAt(t-1),ce=r.charCodeAt(t+1);if(o){if(Number.isNaN(ce)||!d(ce)||p.has(U)||p.has(ce)){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(C>=97?O=C-97+10:C>=65?O=C-65+10:Ja(C)?O=C-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,f=!0;else break}++t,x=x*i+O}return t===l||a!=null&&t-l!==a||f?{n:null,pos:t}:{n:x,pos:t}}function Ws(r,t,s,e,i,a){const n=r.charCodeAt(t);let o;if(n===123){if(++t,{code:o,pos:t}=Zt(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}=Zt(r,t,s,e,4,!1,i,a));return{code:o,pos:t}}function Ke(r,t,s){return new fe(s,r-t,r)}const Ga=new Set([103,109,115,105,121,117,100,118]);class Ya{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 et(t.startLoc,t.endLoc)}}class Qa extends Ka{constructor(s,e){super();m(this,"isLookahead");m(this,"tokens",[]);m(this,"errorHandlers_readInt",{invalidDigit:(s,e,i,a)=>this.optionFlags&2048?(this.raise(u.InvalidDigit,Ke(s,e,i),{radix:a}),!0):!1,numericSeparatorInEscapeSequence:this.errorBuilder(u.NumericSeparatorInEscapeSequence),unexpectedNumericSeparator:this.errorBuilder(u.UnexpectedNumericSeparator)});m(this,"errorHandlers_readCodePoint",Object.assign({},this.errorHandlers_readInt,{invalidEscapeSequence:this.errorBuilder(u.InvalidEscapeSequence),invalidCodePoint:this.errorBuilder(u.InvalidCodePoint)}));m(this,"errorHandlers_readStringContents_string",Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:(s,e,i)=>{this.recordStrictModeErrors(u.StrictNumericEscape,Ke(s,e,i))},unterminated:(s,e,i)=>{throw this.raise(u.UnterminatedString,Ke(s-1,e,i))}}));m(this,"errorHandlers_readStringContents_template",Object.assign({},this.errorHandlers_readCodePoint,{strictNumericEscape:this.errorBuilder(u.StrictNumericEscape),unterminated:(s,e,i)=>{throw this.raise(u.UnterminatedTemplate,Ke(s,e,i))}}));this.state=new Qt,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 Ya(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 Gt.lastIndex=s,Gt.test(this.input)?Gt.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 Yt.lastIndex=s,Yt.test(this.input)?Yt.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(u.UnterminatedComment,this.state.curPosition());for(this.state.pos=a+s.length,rt.lastIndex=i+2;rt.test(this.input)&&rt.lastIndex<=a;)++this.state.curLine,this.state.lineStart=rt.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 et(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(;!ke(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 et(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(_a(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(u.UnexpectedDigitAfterHash,this.state.curPosition());ae(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;!ke(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(ae(s)){this.readWord(s);return}}throw this.raise(u.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(u.UnterminatedRegExp,Q(s,1));const l=this.input.charCodeAt(n);if(ke(l))throw this.raise(u.UnterminatedRegExp,Q(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=()=>Q(s,n+2-e);for(;n<this.length;){const l=this.codePointAtPos(n),p=String.fromCharCode(l);if(Ga.has(l))l===118?c.includes("u")&&this.raise(u.IncompatibleRegExpUVFlags,h()):l===117&&c.includes("v")&&this.raise(u.IncompatibleRegExpUVFlags,h()),c.includes(p)&&this.raise(u.DuplicateRegExpFlags,h());else if(Ne(l)||l===92)this.raise(u.MalformedRegExpFlags,h());else break;++n,c+=p}this.state.pos=n,this.finishToken(138,{pattern:o,flags:c})}readInt(s,e,i=!1,a=!0){const{n,pos:o}=Js(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(u.InvalidDigit,Q(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(u.InvalidDecimal,i);if(ae(this.codePointAtPos(this.state.pos)))throw this.raise(u.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(u.InvalidNumber,this.state.curPosition());const c=this.state.pos-e>=2&&this.input.charCodeAt(e)===48;if(c){const d=this.input.slice(e,this.state.pos);if(this.recordStrictModeErrors(u.StrictOctalLiteral,i),!this.state.strict){const f=d.indexOf("_");f>0&&this.raise(u.ZeroDigitNumericSeparator,Q(i,f))}o=c&&!/[89]/.test(d)}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(u.InvalidOrMissingExponent,i),a=!0,h=this.input.charCodeAt(this.state.pos)),h===110&&((a||c)&&this.raise(u.InvalidBigIntLiteral,i),++this.state.pos,n=!0),ae(this.codePointAtPos(this.state.pos)))throw this.raise(u.NumberIdentifier,this.state.curPosition());const l=this.input.slice(e,this.state.pos).replace(/[_mn]/g,"");if(n){this.finishToken(136,l);return}const p=o?parseInt(l,8):parseFloat(l);this.finishToken(135,p)}readCodePoint(s){const{code:e,pos:i}=Ws(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}=Ks(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}=Ks("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 fe(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(Ne(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?ae:Ne;if(this.input.charCodeAt(++this.state.pos)!==117){this.raise(u.MissingUnicodeEscape,this.state.curPosition()),a=this.state.pos-1;continue}++this.state.pos;const h=this.readCodePoint(!0);h!==null&&(c(h)||this.raise(u.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=Bt.get(e);i!==void 0?this.finishToken(i,me(i)):this.finishToken(132,e)}checkKeywordEscapes(){const{type:s}=this.state;zt(s)&&this.state.containsEsc&&this.raise(u.InvalidEscapedReservedWord,this.state.startLoc,{reservedWord:me(s)})}raise(s,e,i={}){const a=e instanceof fe?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 fe?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(u.UnexpectedToken,s??this.state.startLoc,{expected:e?me(e):null})}expectPlugin(s,e){if(this.hasPlugin(s))return!0;throw this.raise(u.MissingPlugin,e??this.state.startLoc,{missingPlugin:[s]})}expectOnePlugin(s){if(!s.some(e=>this.hasPlugin(e)))throw this.raise(u.MissingOneOfPlugins,this.state.startLoc,{missingPlugin:s})}errorBuilder(s){return(e,i,a)=>{this.raise(s,Ke(e,i,a))}}}class Za{constructor(){m(this,"privateNames",new Set);m(this,"loneAccessors",new Map);m(this,"undefinedPrivateNames",new Map)}}class en{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 Za)}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(u.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,p=c&3,d=s&3;o=p===d||h!==l,o||a.delete(t)}else o||a.set(t,s)}o&&this.parser.raise(u.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(u.InvalidPrivateFieldResolution,s,{identifierName:t})}}class ot{constructor(t=0){this.type=t}canBeArrowParameterDeclaration(){return this.type===2||this.type===1}isCertainlyParameterDeclaration(){return this.type===3}}class Xs extends ot{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 tn{constructor(t){m(this,"parser");m(this,"stack",[new ot]);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(u.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 sn(){return new ot(3)}function rn(){return new Xs(1)}function an(){return new Xs(2)}function Gs(){return new ot}class nn extends Qa{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!(Ne(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 zs(this.input,this.offsetToSourcePos(this.state.lastTokEndLoc.index),this.state.start)}hasFollowingLineBreak(){return zs(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(u.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(u.InvalidCoverInitializedName,e),i!=null&&this.raise(u.DuplicateProto,i),a!=null&&this.raise(u.UnexpectedPrivateField,a),n!=null&&this.unexpected(n)}isLiteralPropertyName(){return Ls(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 za;const c=this.classScope;this.classScope=new en(this);const h=this.expressionScope;return this.expressionScope=new tn(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 ct{constructor(){m(this,"shorthandAssignLoc",null);m(this,"doubleProtoLoc",null);m(this,"privateKeyLoc",null);m(this,"optionalParametersLoc",null)}}class es{constructor(t,s,e){m(this,"type","");this.start=s,this.end=0,this.loc=new et(e),(t==null?void 0:t.optionFlags)&128&&(this.range=[s,0]),t!=null&&t.filename&&(this.loc.filename=t.filename)}}const Ys=es.prototype;class on extends nn{startNode(){const t=this.state.startLoc;return new es(this,t.index,t)}startNodeAt(t){return new es(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(Ys);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(Ys);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 Qs=r=>r.type==="ParenthesizedExpression"?Qs(r.expression):r;class cn extends on{toAssignable(t,s=!1){var i,a,n;let e;switch((t.type==="ParenthesizedExpression"||(i=t.extra)!=null&&i.parenthesized)&&(e=Qs(t),s?e.type==="Identifier"?this.expressionScope.recordArrowParameterBindingError(u.InvalidParenthesizedAssignment,t):e.type!=="MemberExpression"&&!this.isOptionalMemberExpression(e)&&this.raise(u.InvalidParenthesizedAssignment,t):this.raise(u.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],p=o===h;this.toAssignableObjectExpressionProp(l,p,s),p&&l.type==="RestElement"&&((a=t.extra)!=null&&a.trailingCommaLoc)&&this.raise(u.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(u.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"?u.PatternHasAccessor:u.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(u.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(u.RestTrailingComma,n):s&&this.raise(u.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(u.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 x;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(u.InvalidLhsOptionalChaining,t,{ancestor:s})),e!==64&&this.raise(u.InvalidPropertyBindingPattern,t);return}if(o==="Identifier"){this.checkIdentifier(t,e,a);const{name:A}=t;i&&(i.has(A)?this.raise(u.ParamDupe,t):i.add(A));return}const h=this.isValidLVal(o,!(n||(x=t.extra)!=null&&x.parenthesized)&&s.type==="AssignmentExpression",e);if(h===!0)return;if(h===!1){const A=e===64?u.InvalidLhs:u.InvalidLhsBinding;this.raise(A,t,{ancestor:s});return}let l,p;typeof h=="string"?(l=h,p=o==="ParenthesizedExpression"):[l,p]=h;const d=o==="ArrayPattern"||o==="ObjectPattern"?{type:o}:s,f=t[l];if(Array.isArray(f))for(const A of f)A&&this.checkLVal(A,d,e,i,a,p);else f&&this.checkLVal(f,d,e,i,a,p)}checkIdentifier(t,s,e=!1){this.state.strict&&(e?$s(t.name,this.inModule):Us(t.name))&&(s===64?this.raise(u.StrictEvalArguments,t,{referenceName:t.name}):this.raise(u.StrictEvalArgumentsBinding,t,{bindingName:t.name})),s&8192&&t.name==="let"&&this.raise(u.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(u.InvalidRestAssignmentPattern,t)}}checkCommaAfterRest(t){return this.match(12)?(this.raise(this.lookaheadCharCode()===t?u.RestTrailingComma:u.ElementAfterRest,this.state.startLoc),!0):!1}}function hn(r){if(r==null)throw new Error(`Unexpected ${r} value.`);return r}function Zs(r){if(!r)throw new Error("Assert fail")}const P=re`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 ln(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 ei(r){return r==="private"||r==="public"||r==="protected"}function un(r){return r==="in"||r==="out"}function ts(r){var t;if((t=r.extra)!=null&&t.parenthesized)return!1;switch(r.type){case"Identifier":return!0;case"MemberExpression":return!r.computed&&ts(r.object);case"TSInstantiationExpression":return ts(r.expression);default:return!1}}var pn=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:P.InvalidModifierOnTypeParameter}));m(this,"tsParseConstModifier",this.tsParseModifiers.bind(this,{allowedModifiers:["const"],disallowedModifiers:["in","out"],errorTemplate:P.InvalidModifierOnTypeParameterPositions}));m(this,"tsParseInOutConstModifiers",this.tsParseModifiers.bind(this,{allowedModifiers:["in","out","const"],disallowedModifiers:["public","private","protected","readonly","declare","abstract","override"],errorTemplate:P.InvalidModifierOnTypeParameter}))}getScopeHandler(){return qa}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=P.InvalidModifierOnTypeMember},o){const c=(l,p,d,f)=>{p===d&&o[f]&&this.raise(P.InvalidModifiersOrder,l,{orderedModifiers:[d,f]})},h=(l,p,d,f)=>{(o[d]&&p===f||o[f]&&p===d)&&this.raise(P.IncompatibleModifiers,l,{modifiers:[d,f]})};for(;;){const{startLoc:l}=this.state,p=this.tsParseModifier(e.concat(i??[]),a,o.static);if(!p)break;ei(p)?o.accessibility?this.raise(P.DuplicateAccessibilityModifier,l,{modifier:p}):(c(l,p,p,"override"),c(l,p,p,"static"),c(l,p,p,"readonly"),o.accessibility=p):un(p)?(o[p]&&this.raise(P.DuplicateModifier,l,{modifier:p}),o[p]=!0,c(l,p,"in","out")):(Object.hasOwn(o,p)?this.raise(P.DuplicateModifier,l,{modifier:p}):(c(l,p,"static","readonly"),c(l,p,"static","override"),c(l,p,"override","readonly"),c(l,p,"abstract","override"),h(l,p,"declare","override"),h(l,p,"static","abstract")),o[p]=!0),i!=null&&i.includes(p)&&this.raise(n,l,{modifier:p})}}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 hn(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(P.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(P.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(P.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(P.ReadonlyForMethodSignature,e);const a=e;a.kind&&this.match(47)&&this.raise(P.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(u.BadGetterArity,this.state.curPosition()),this.isThisParam(a[n][0])&&this.raise(P.AccessorCannotDeclareThisParameter,this.state.curPosition()));else if(a.kind==="set"){if(a[n].length!==1)this.raise(u.BadSetterArity,this.state.curPosition());else{const c=a[n][0];this.isThisParam(c)&&this.raise(P.AccessorCannotDeclareThisParameter,this.state.curPosition()),c.type==="Identifier"&&c.optional&&this.raise(P.SetAccessorCannotHaveOptionalParameter,this.state.curPosition()),c.type==="RestElement"&&this.raise(P.SetAccessorCannotHaveRestParameter,this.state.curPosition())}a[o]&&this.raise(P.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(P.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 p=te(this.state.type)?this.lookaheadCharCode():null;if(p===58)n=!0,c=!1,o=this.parseIdentifier(!0),this.expect(14),h=this.tsParseType();else if(p===63){c=!0;const d=this.state.value,f=this.tsParseNonArrayType();this.lookaheadCharCode()===58?(n=!0,o=this.createIdentifier(this.startNodeAt(a),d),this.expect(17),this.expect(14),h=this.tsParseType()):(n=!1,h=f,this.expect(17))}else h=this.tsParseType(),c=this.eat(17),n=this.eat(14);if(n){let d;o?(d=this.startNodeAt(a),d.optional=c,d.label=o,d.elementType=h,this.eat(17)&&(d.optional=!0,this.raise(P.TupleOptionalAfterType,this.state.lastTokStartLoc))):(d=this.startNodeAt(a),d.optional=c,this.raise(P.InvalidTupleMemberLabel,h),d.label=h,d.elementType=this.tsParseType()),h=this.finishNode(d,"TSNamedTupleMember")}else if(c){const d=this.startNodeAt(a);d.typeAnnotation=h,h=this.finishNode(d,"TSOptionalType")}if(i){const d=this.startNodeAt(e);d.typeAnnotation=h,h=this.finishNode(d,"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":ln(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(P.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 ya(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(u.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(){Zs(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(P.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();ts(n)||this.raise(P.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(P.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(P.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()!==M.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(P.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(P.EmptyTypeArguments,e):!this.state.inType&&this.curContext()===M.brace&&this.reScan_lt_gt(),this.expect(48),this.finishNode(e,"TSTypeParameterInstantiation")}tsIsDeclarationStart(){return xa(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(P.UnexpectedParameterModifier,a);const l=this.parseMaybeDefault();e&2&&this.parseFunctionParamType(l);const p=this.parseMaybeDefault(l.loc.start,l);if(o||h||c){const d=this.startNodeAt(a);return i.length&&(d.decorators=i),o&&(d.accessibility=o),h&&(d.readonly=h),c&&(d.override=c),p.type!=="Identifier"&&p.type!=="AssignmentPattern"&&this.raise(P.UnsupportedParameterPropertyKind,d),d.parameter=p,this.finishNode(d,"TSParameterProperty")}return i.length&&(l.decorators=i),p}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(P.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(P.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(P.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 f=this.tsTryParseGenericAsyncArrowFunction(i);if(f)return f}const l=this.tsParseTypeArgumentsInExpression();if(!l)return;if(o&&!this.match(10)){c=this.state.curPosition();return}if(Vt(this.state.type)){const f=super.parseTaggedTemplateExpression(e,i,n);return f.typeArguments=l,f}if(!a&&this.eat(10)){const f=this.startNodeAt(i);return f.callee=e,f.arguments=this.parseCallExpressionArguments(11),this.tsCheckForInvalidTypeCasts(f.arguments),f.typeArguments=l,n.optionalChainMember&&(f.optional=o),this.finishCallExpression(f,n.optionalChainMember)}const p=this.state.type;if(p===48||p===52||p!==10&&He(p)&&!this.hasPrecedingLineBreak())return;const d=this.startNodeAt(i);return d.expression=e,d.typeArguments=l,this.finishNode(d,"TSInstantiationExpression")});if(c&&this.unexpected(c,10),h)return h.type==="TSInstantiationExpression"&&((this.match(16)||this.match(18)&&this.lookaheadCharCode()!==40)&&this.raise(P.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(it(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(u.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(P.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(P.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(P.InitializerNotAllowedInAmbientContext,h):dn(h,this.hasPlugin("estree"))||this.raise(P.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=>ei(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:P.InvalidModifierOnTypeParameterPositions},i);const o=()=>{this.tsIsStartOfStaticBlocks()?(this.next(),this.next(),this.tsHasSomeModifiers(i,n)&&this.raise(P.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(P.IndexSignatureHasAbstract,i),i.accessibility&&this.raise(P.IndexSignatureHasAccessibility,i,{modifier:i.accessibility}),i.declare&&this.raise(P.IndexSignatureHasDeclare,i),i.override&&this.raise(P.IndexSignatureHasOverride,i);return}!this.state.inAbstractClass&&i.abstract&&this.raise(P.NonAbstractClassHasAbstractMethod,i),i.override&&(a.hadSuperClass||this.raise(P.OverrideNotInSubClass,i)),super.parseClassMemberWithIsStatic(e,i,a,n)}parsePostMemberNameModifiers(e){this.eat(17)&&(e.optional=!0),e.readonly&&this.match(10)&&this.raise(P.ClassMethodHasReadonly,e),e.declare&&this.match(10)&&this.raise(P.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(P.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(P.DeclareClassFieldHasInitializer,this.state.startLoc),e.abstract&&this.match(29)){const{key:i}=e;this.raise(P.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(P.PrivateElementHasAbstract,e),e.accessibility&&this.raise(P.PrivateElementHasAccessibility,e,{modifier:e.accessibility}),this.parseClassPropertyAnnotation(e),super.parseClassPrivateProperty(e)}parseClassAccessorProperty(e){return this.parseClassPropertyAnnotation(e),e.optional&&this.raise(P.AccessorCannotBeOptional,e),super.parseClassAccessorProperty(e)}pushClassMethod(e,i,a,n,o,c){const h=this.tsTryParseTypeParameters(this.tsParseConstModifier);h&&o&&this.raise(P.ConstructorHasTypeParameters,h);const{declare:l=!1,kind:p}=i;l&&(p==="get"||p==="set")&&this.raise(P.DeclareAccessor,i,{kind:p}),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,p=l[l.length-1];(p===M.j_oTag||p===M.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 d,f;c=this.tsParseTypeParameters(this.tsParseConstModifier);const p=super.parseMaybeAssign(e,i);if((p.type!=="ArrowFunctionExpression"||(d=p.extra)!=null&&d.parenthesized)&&l(),(c==null?void 0:c.params.length)!==0&&this.resetStartLocationFromNode(p,c),p.typeParameters=c,this.hasPlugin("jsx")&&p.typeParameters.params.length===1&&!((f=p.typeParameters.extra)!=null&&f.trailingComma)){const x=p.typeParameters.params[0];x.constraint||this.raise(P.SingleTypeParameterWithoutTrailingComma,Q(x.loc.end,1),{typeParameterName:x.name.name})}return p},a);if(!h.error&&!h.aborted)return c&&this.reportReservedArrowTypeParam(c),h.node;if(!n&&(Zs(!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(P.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(P.UnexpectedTypeCastInParameter,e):this.raise(P.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(P.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(P.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:f}=l;this.raise(P.AbstractMethodHasImplementation,l,{methodName:f.type==="Identifier"&&!l.computed?f.name:`[${this.input.slice(this.offsetToSourcePos(f.start),this.offsetToSourcePos(f.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,p=!0;const d=c.loc.start;if(this.isContextual(93)){const x=this.parseIdentifier();if(this.isContextual(93)){const A=this.parseIdentifier();te(this.state.type)?(l=!0,c=x,h=i?this.parseIdentifier():this.parseModuleExportName(),p=!1):(h=A,p=!1)}else te(this.state.type)?(p=!1,h=i?this.parseIdentifier():this.parseModuleExportName()):(l=!0,c=x)}else te(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?P.TypeModifierIsUsedInTypeImports:P.TypeModifierIsUsedInTypeExports,d),e[n]=c,e[o]=h;const f=i?"importKind":"exportKind";e[f]=l?"type":"value",p&&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 fn(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:si(r.object)}function dn(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)||mn(r,t)||s==="TemplateLiteral"&&r.expressions.length===0||fn(r))}function ti(r,t){return t?r.type==="Literal"&&(typeof r.value=="number"||"bigint"in r):r.type==="NumericLiteral"||r.type==="BigIntLiteral"}function mn(r,t){if(r.type==="UnaryExpression"){const{operator:s,argument:e}=r;if(s==="-"&&ti(e,t))return!0}return!1}function si(r){return r.type==="Identifier"?!0:r.type!=="MemberExpression"||r.computed?!1:si(r.object)}const ii=re`placeholders`({ClassNameIsRequired:"A class name is required.",UnexpectedSpace:"Unexpected space in placeholder."});var yn=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(ii.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(me(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(ii.UnexpectedSpace,this.state.lastTokEndLoc)}},xn=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 ri=["fsharp","hack"],ai=["^^","@@","^","%","#"];function Pn(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(!ri.includes(t)){const s=ri.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(!ai.includes(s)){const e=ai.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 ni={estree:na,jsx:Ua,flow:Ba,typescript:pn,v8intrinsic:xn,placeholders:yn},gn=Object.keys(ni);class bn extends cn{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(u.RecordNoProto,a),!0):(e&&(i?i.doubleProtoLoc===null&&(i.doubleProtoLoc=a.loc.start):this.raise(u.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(u.ParseExpressionEmptyInput,this.state.startLoc);const t=this.parseExpression();if(!this.match(140))throw this.raise(u.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 ct,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)),ua(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")?He(c):He(c)&&!this.match(54))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(u.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>=it(58)||!this.prodParam.hasIn||!this.match(58))&&this.raise(u.PrivateInExpectedIn,t,{identifierName:a}),this.classScope.usePrivateName(a,t.loc.start)}const i=this.state.type;if(fa(i)&&(this.prodParam.hasIn||!this.match(58))){let a=it(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=it(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(u.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,Pa(t)?s-1:s)}parseHackPipeBody(){var i;const{startLoc:t}=this.state,s=this.parseMaybeAssign();return Zr.has(s.type)&&!((i=s.extra)!=null&&i.parenthesized)&&this.raise(u.PipeUnparenthesizedBody,t,{type:s.type}),this.topicReferenceWasUsedInCurrentContext()||this.raise(u.PipeTopicUnused,t),s}checkExponentialAfterUnary(t){this.match(57)&&this.raise(u.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(ma(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(u.StrictDelete,n):this.hasPropertyAsPrivateName(h)&&this.raise(u.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")?He(c):He(c)&&!this.match(54))&&!this.isAmbiguousPrefixOrIdentifier())return this.raiseOverwrite(u.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(;da(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(Vt(a))return this.parseTaggedTemplateExpression(t,s,i);let n=!1;if(a===18){if(e&&(this.raise(u.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(u.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(an()),n=new ct),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(u.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(u.ImportCallArity,t);else for(const e of t.arguments)e.type==="SpreadElement"&&this.raise(u.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&&De(t,s.innerComments),s.callee.trailingComments&&De(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(u.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(u.UnsupportedBind,a)}case 139:return this.raise(u.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());ae(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=Q(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(u.PipeTopicUnbound,s),this.registerTopicReference(),this.finishNode(t,"TopicReference");throw this.raise(u.PipeTopicUnconfiguredToken,s,{token:me(i)})}testTopicReferenceConfiguration(t,s,e){switch(t){case"hack":return this.hasPlugin(["pipelineOperator",{topicToken:me(e)}]);case"smart":return e===27;default:throw this.raise(u.PipeTopicRequiresHackPipes,s)}}parseAsyncArrowUnaryFunction(t){this.prodParam.enter(at(!0,this.prodParam.hasYield));const s=[this.parseIdentifier()];return this.prodParam.exit(),this.hasPrecedingLineBreak()&&this.raise(u.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(u.SuperNotAllowed,t):!this.scope.allowSuper&&!(this.optionFlags&16)&&this.raise(u.UnexpectedSuper,t),!this.match(10)&&!this.match(0)&&!this.match(16)&&this.raise(u.UnsupportedSuper,t),this.finishNode(t,"Super")}parsePrivateName(){const t=this.startNode(),s=this.startNodeAt(Q(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(u.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(u.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(rn());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 ct;let h=!0,l,p;for(;!this.match(11);){if(h)h=!1;else if(this.expect(12,c.optionalParametersLoc===null?null:c.optionalParametersLoc),this.match(11)){p=this.state.startLoc;break}if(this.match(21)){const x=this.state.startLoc;if(l=this.state.startLoc,o.push(this.parseParenItem(this.parseRestBinding(),x)),!this.checkCommaAfterRest(41))break}else o.push(this.parseMaybeAssignAllowIn(c,this.parseParenItem))}const d=this.state.lastTokEndLoc;this.expect(11),this.state.maybeInArrowParameters=i,this.state.inFSharpPipelineDirectBody=a;let f=this.startNodeAt(s);return t&&this.shouldParseArrow(o)&&(f=this.parseArrow(f))?(this.checkDestructuringPrivate(c),this.expressionScope.validateAsPattern(),this.expressionScope.exit(),this.parseArrowExpression(f,o,!1),f):(this.expressionScope.exit(),o.length||this.unexpected(this.state.lastTokStartLoc),p&&this.unexpected(p),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,d)):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(u.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(u.ImportCallNotNewExpression,e)}parseTemplateElement(t){const{start:s,startLoc:e,end:i,value:a}=this.state,n=s+1,o=this.startNodeAt(Q(e,1));a===null&&(t||this.raise(u.InvalidEscapeSequenceTemplate,Q(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,`
73
+ `),cooked:a===null?null:a.slice(1,h)},o.tail=c,this.next();const p=this.finishNode(o,"TemplateElement");return this.resetEndLocation(p,Q(this.state.lastTokEndLoc,h)),p}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(u.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(u.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(u.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"?u.BadGetterArity:u.BadSetterArity,t),t.kind==="set"&&((i=e[e.length-1])==null?void 0:i.type)==="RestElement"&&this.raise(u.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(u.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(te(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(u.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(at(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=at(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(Gs()),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(u.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(u.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(u.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;te(i)?s=this.state.value:this.unexpected();const a=ha(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||!Na(t))return;if(e&&Ia(t)){this.raise(u.UnexpectedKeyword,s,{keyword:t});return}if((this.state.strict?i?$s:_s:js)(t,this.inModule)){this.raise(u.UnexpectedReservedWord,s,{reservedWord:t});return}else if(t==="yield"){if(this.prodParam.hasYield){this.raise(u.YieldBindingIdentifier,s);return}}else if(t==="await"){if(this.prodParam.hasAwait){this.raise(u.AwaitBindingIdentifier,s);return}if(this.scope.inStaticBlock){this.raise(u.AwaitBindingIdentifierInStaticBlock,s);return}this.expressionScope.recordAsyncArrowParametersError(s)}else if(t==="arguments"&&this.scope.inClassAndNotInNonArrowFunction){this.raise(u.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(u.AwaitExpressionFormalParameter,s),this.eat(55)&&this.raise(u.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||Vt(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(u.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(u.ImportCallArity,t)}}return this.expect(11),this.finishNode(t,"ImportExpression")}checkPipelineAtInfixOperator(t,s){this.hasPlugin(["pipelineOperator",{proposal:"smart"}])&&t.type==="SequenceExpression"&&this.raise(u.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(u.PipelineBodyNoArrow,this.state.startLoc);this.topicReferenceWasUsedInCurrentContext()||this.raise(u.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},Tn={kind:2},wn=/[\uD800-\uDFFF]/u,is=/in(?:stanceof)?/y;function An(r,t,s){for(let e=0;e<r.length;e++){const i=r[e],{type:a}=i;typeof a=="number"&&(i.type=Fs(a))}return r}class Sn extends bn{parseTopLevel(t,s){return t.program=this.parseProgram(s),t.comments=this.comments,this.optionFlags&256&&(t.tokens=An(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(u.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",Q(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(ae(t)){if(is.lastIndex=s,is.test(this.input)){const e=this.codePointAtPos(is.lastIndex);if(!Ne(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?u.StrictFunction:this.options.annexB?u.SloppyFunctionAnnexB:u.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(u.AwaitUsingNotInAsyncContext,i):this.raise(u.UnexpectedLexicalDeclaration,i):this.raise(u.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(u.UnexpectedLexicalDeclaration,this.state.startLoc):this.raise(u.UnexpectedUsingDeclaration,this.state.startLoc),this.parseVarStatement(i,"using");case 100:{if(this.state.containsEsc)break;const l=this.nextTokenStart(),p=this.codePointAtPos(l);if(p!==91&&(!a&&this.hasFollowingLineBreak()||!this.chStartsBindingIdentifier(p,l)&&p!==123))break}case 75:a||this.raise(u.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(u.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(u.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(u.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(u.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(u.DecoratorExportClass,this.state.startLoc);else if(!this.canHaveLeadingDecorator())throw this.raise(u.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(u.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(u.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 p=this.startNode();let d;c?(d="await using",this.recordAwaitIfAllowed()||this.raise(u.AwaitUsingNotInAsyncContext,this.state.startLoc),this.next()):d=this.state.value,this.next(),this.parseVar(p,!0,d);const f=this.finishNode(p,"VariableDeclaration"),x=this.match(58);return x&&h&&this.raise(u.ForInUsing,f),(x||this.isContextual(102))&&f.declarations.length===1?this.parseForIn(t,f,s):(s!==null&&this.unexpected(s),this.parseFor(t,f))}}const i=this.isContextual(95),a=new ct,n=this.parseExpression(!0,a),o=this.isContextual(102);if(o&&(e&&this.raise(u.ForOfLet,n),s===null&&i&&n.type==="Identifier"&&this.raise(u.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(u.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(Tn),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(u.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(u.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(u.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(u.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(u.LabelRedeclaration,e,{labelName:s});const a=pa(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(u.ForInOfLoopInitializer,s,{type:i?"ForInStatement":"ForOfStatement"}),s.type==="AssignmentPattern"&&this.raise(u.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(u.DeclarationMissingInitializer,this.state.lastTokEndLoc,{kind:"destructuring"}):(e==="const"||e==="using"||e==="await using")&&!(this.match(58)||this.isContextual(102))&&this.raise(u.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(u.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(u.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(at(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(sn()),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(u.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(u.DecoratorConstructor,n)}}),this.state.strict=s,this.next(),i.length)throw this.raise(u.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,p=a;if(s.static=i,this.parsePropertyNamePrefixOperator(s),this.eat(55)){l.kind="method";const C=this.match(139);if(this.parseClassElementName(l),this.parsePostMemberNameModifiers(l),C){this.pushClassPrivateMethod(t,n,!0,!1);return}this.isNonstaticConstructor(a)&&this.raise(u.ConstructorIsGenerator,a.key),this.pushClassMethod(t,a,!0,!1,!1,!1);return}const d=!this.state.containsEsc&&D(this.state.type),f=this.parseClassElementName(s),x=d?f.name:null,A=this.isPrivateName(f),_=this.state.startLoc;if(this.parsePostMemberNameModifiers(p),this.isClassMethod()){if(l.kind="method",A){this.pushClassPrivateMethod(t,n,!1,!1);return}const C=this.isNonstaticConstructor(a);let O=!1;C&&(a.kind="constructor",e.hadConstructor&&!this.hasPlugin("typescript")&&this.raise(u.DuplicateConstructor,f),C&&this.hasPlugin("typescript")&&s.override&&this.raise(u.OverrideOnConstructor,f),e.hadConstructor=!0,O=e.hadSuperClass),this.pushClassMethod(t,a,!1,!1,C,O)}else if(this.isClassProperty())A?this.pushClassPrivateProperty(t,c):this.pushClassProperty(t,o);else if(x==="async"&&!this.isLineTerminator()){this.resetPreviousNodeTrailingComments(f);const C=this.eat(55);p.optional&&this.unexpected(_),l.kind="method";const O=this.match(139);this.parseClassElementName(l),this.parsePostMemberNameModifiers(p),O?this.pushClassPrivateMethod(t,n,C,!0):(this.isNonstaticConstructor(a)&&this.raise(u.ConstructorIsAsync,a.key),this.pushClassMethod(t,a,C,!0,!1,!1))}else if((x==="get"||x==="set")&&!(this.match(55)&&this.isLineTerminator())){this.resetPreviousNodeTrailingComments(f),l.kind=x;const C=this.match(139);this.parseClassElementName(a),C?this.pushClassPrivateMethod(t,n,!1,!1):(this.isNonstaticConstructor(a)&&this.raise(u.ConstructorIsAccessor,a.key),this.pushClassMethod(t,a,!1,!1,!1,!1)),this.checkGetterSetterParams(a)}else if(x==="accessor"&&!this.isLineTerminator()){this.expectPlugin("decoratorAutoAccessors"),this.resetPreviousNodeTrailingComments(f);const C=this.match(139);this.parseClassElementName(o),this.pushClassAccessorProperty(t,h,C)}else this.isLineTerminator()?A?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(u.StaticPrototype,this.state.startLoc),s===139){e==="constructor"&&this.raise(u.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(u.DecoratorStaticBlock,s)}pushClassProperty(t,s){!s.computed&&this.nameIsConstructor(s.key)&&this.raise(u.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(u.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(Gs()),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(u.MissingClassName,this.state.startLoc)}parseClassSuper(t){t.superClass=this.eat(81)?this.parseExprSubscripts():null}parseExport(t,s){var d;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(u.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 p;if(h||l){if(p=!1,s)throw this.raise(u.UnsupportedDecoratorExport,t);this.parseExportFrom(t,h)}else p=this.maybeParseExportDeclaration(t);if(h||l||p){const f=t;if(this.checkExport(f,!0,!1,!!f.source),((d=f.declaration)==null?void 0:d.type)==="ClassDeclaration")this.maybeTakeDecorators(s,f.declaration,f);else if(s)throw this.raise(u.UnsupportedDecoratorExport,t);return this.sawUnambiguousESM=!0,this.finishNode(f,"ExportNamedDeclaration")}if(this.eat(65)){const f=t,x=this.parseExportDefaultExpression();if(f.declaration=x,x.type==="ClassDeclaration")this.maybeTakeDecorators(s,x,f);else if(s)throw this.raise(u.UnsupportedDecoratorExport,t);return this.checkExport(f,!0,!0),this.sawUnambiguousESM=!0,this.finishNode(f,"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(u.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(u.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(u.DecoratorBeforeExport,this.state.startLoc),!0):this.isContextual(107)?(this.raise(u.UsingDeclarationExport,this.state.startLoc),!0):this.isContextual(96)&&this.startsAwaitUsing()?(this.raise(u.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(u.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(u.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(u.DuplicateDefaultExport,t):this.raise(u.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=wn.exec(t.value);return s&&this.raise(u.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(u.SourcePhaseImportRequiresDefault,s[0].loc.start):t.phase==="defer"?e!=="ImportNamespaceSpecifier"&&this.raise(u.DeferImportRequiresNamespace,s[0].loc.start):t.module&&(e!=="ImportDefaultSpecifier"&&this.raise(u.ImportReflectionNotBinding,s[0].loc.start),((i=t.assertions)==null?void 0:i.length)>0&&this.raise(u.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(u.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(te(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(u.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(u.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(u.ModuleAttributeDifferentFromType,e.key),s.has(e.key.name)&&this.raise(u.ModuleAttributesWithDuplicateKeys,e.key,{key:e.key.name}),s.add(e.key.name),this.expect(14),!this.match(134))throw this.raise(u.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(u.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(te(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(u.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(u.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 oi extends Sn{constructor(t,s,e){t=ra(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 Xt}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 In(r,t){if((t==null?void 0:t.sourceType)==="unambiguous"){t=Object.assign({},t);try{t.sourceType="module";const s=ht(t,r),e=s.parse();if(s.sawUnambiguousESM)return e;if(s.ambiguousScriptDifferentAst)try{return t.sourceType="script",ht(t,r).parse()}catch{}else e.program.sourceType="script";return e}catch(s){try{return t.sourceType="script",ht(t,r).parse()}catch{}throw s}}else return ht(t,r).parse()}function En(r){const t={};for(const s of Object.keys(r))t[s]=Fs(r[s]);return t}En(ca);function ht(r,t){let s=oi;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||{})}Pn(e),s=Cn(e)}return new s(r,t,e)}const ci=new Map;function Cn(r){const t=[];for(const i of gn)r.has(i)&&t.push(i);const s=t.join("|");let e=ci.get(s);if(!e){e=oi;for(const i of t)e=ni[i](e);ci.set(s,e)}return e}function lt(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]=lt(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 lt(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]=lt(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 Oe(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 hi(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=Oe(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=V.string();break}case"number":{o=V.number();break}case"boolean":{o=V.boolean();break}case"date":{o=V.date();break}case"json":{o=V.json();break}case"any":{o=V.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 V.entity(s)}function li(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=Oe(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]=hi(e,s.value.arguments[0])}return t}function Nn(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=Oe(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=li(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=hi(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 kn(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=Oe(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]=Nn(e,s.value)}return t}function vn(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=Oe(n);if(n.value.type!=="ObjectExpression")throw new Error(`Failed to extract ${o}, expected an \`ObjectExpression\`, got \`${n.value.type}\`.`);switch(Oe(n)){case"entities":{t=li(n.value);break}case"links":{s=lt(n.value)||{};break}case"rooms":{e=kn(n.value);break}}}}if(!t)throw new Error("Could not extract schema, did not find any entities.");return V.schema({entities:t,links:s,rooms:e})}function Dn(r,t="instant.schema.ts"){var e;const s=In(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 vn(s)}const ut={"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(ut).map(([r,t])=>[`${t.cardinality}-${t["unique?"]}`,r]));const ui=(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}),On=r=>{const t=`${r.forward.has}-${r.reverse.has}`;return{"checked-data-type":null,"index?":!1,...ut[t],"required?":!1,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}}},pt=(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},Ae=(r,t)=>{const s=pt(r.identifier,t);return{"attr-id":s.id,"forward-identity":s["forward-identity"]}},Ln={index:Ae,unique:Ae,required:Ae,"remove-index":Ae,"remove-unique":Ae,"remove-required":Ae,"delete-attr":(r,t)=>pt(r.identifier,t).id,"update-attr":(r,t)=>{const s=pt(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=ms(),e=[s,r.identifier.namespace,r.identifier.attrName],i=[];return i.push(["add-attr",{"forward-identity":e,"reverse-identity":r["reverse-identity"]?[ms(),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":Ae,"check-data-type":(r,t)=>{const s=pt(r.identifier,t);return{"attr-id":s.id,"checked-data-type":r["checked-data-type"],"forward-identity":s["forward-identity"]}}};function oe(r,t,s){var e;return!!((e=r[t])!=null&&e.has(s))}const Mn=(r,t)=>{if(!t)throw new Error("Existing attributes are required");const s=[];return r.forEach(e=>{const i=Ln[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},Fn=async(r,t,s,e)=>{var U,ce;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(R=>{oe(e,g,R)||i.push({type:"delete-attr",identifier:{attrName:R,namespace:g}})}),!oe(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){oe(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 R of Object.keys(n[g].attrs)){if(oe(e,g,R))continue;const W=n[g].attrs[R];i.push(ui(W,g,R))}}const p=o.filter(g=>c.includes(g));for(const g of p){const R=Object.keys(n[g].attrs).filter(B=>oe(e,g,B)?!1:!Object.keys(a[g].attrs).includes(B)),W=Object.keys(a[g].attrs).filter(B=>oe(e,g,B)?!1:!Object.keys(n[g].attrs).includes(B)),Se=await mi(R,W,s,{type:"attribute",entityName:g});Object.keys(a[g].attrs).filter(B=>Object.keys(n[g].attrs).includes(B)).forEach(B=>{oe(e,g,B)||i.push(...pi({attrName:B,namespace:g},a[g].attrs[B],n[g].attrs[B]))}),Se.deleted.forEach(B=>{i.push({type:"delete-attr",identifier:{attrName:B,namespace:g}})}),Se.created.forEach(B=>{const Je=t.entities[g].attrs[B];i.push(ui(Je,g,B))}),Se.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(...pi({attrName:B.from,namespace:g},a[g].attrs[B.from],n[g].attrs[B.to]))})}const d=Object.values(r.links).filter(g=>!oe(e,g.forward.on,g.forward.label)),f=Object.values(t.links).filter(g=>!oe(e,g.forward.on,g.forward.label)),x=g=>`${g.forward.on}<->${g.reverse.on}`,A=g=>`${g.forward.on}.${g.forward.label}<->${g.reverse.on}.${g.reverse.label}`,_=new Map,C=new Map;for(const g of f){const R=x(g),W=_.get(R)||[];W.push(g),_.set(R,W)}for(const g of d){const R=x(g),W=C.get(R)||[];W.push(g),C.set(R,W)}const O=new Set([...C.keys(),..._.keys()]);for(const g of O){const R=C.get(g)||[],W=_.get(g)||[],Se=R.map($=>A($)),yt=W.map($=>A($)),B=yt.filter($=>!Se.includes($)),Je=Se.filter($=>!yt.includes($));Se.filter($=>yt.includes($)).forEach($=>{const q=R.find(Ie=>A(Ie)===$),X=W.find(Ie=>A(Ie)===$);!q||!X||i.push(...fi({namespace:q.forward.on,attrName:q.forward.label},q,X))});const rs=await mi(B,Je,s,{type:"link",forwardEntityName:(U=R[0])==null?void 0:U.forward.on,reverseEntityName:(ce=R[0])==null?void 0:ce.reverse.on});rs.deleted.forEach($=>{const q=R.find(X=>A(X)===$);q&&i.push({type:"delete-attr",identifier:{attrName:q.forward.label,namespace:q.forward.on}})}),rs.created.forEach($=>{const q=W.find(X=>A(X)===$);q&&i.push(On(q))}),rs.renamed.forEach($=>{const q=R.find(Ie=>A(Ie)===$.from),X=W.find(Ie=>A(Ie)===$.to);!q||!X||(i.push({type:"update-attr",identifier:{attrName:q.forward.label,namespace:q.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(...fi({attrName:q.forward.label,namespace:q.forward.on},q,X)))})}return i},pi=(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},fi=(r,t,s)=>{const e=[],i=`${t.forward.has}-${t.reverse.has}`,{cardinality:a,"unique?":n}=ut[i],o=`${s.forward.has}-${s.reverse.has}`,{cardinality:c,"unique?":h}=ut[o];return!n&&h&&e.push({type:"unique",identifier:r}),!h&&h!==n&&e.push({type:"remove-unique",identifier:r}),(t.reverse.onDelete!==s.reverse.onDelete||t.forward.onDelete!==s.forward.onDelete||a!==c)&&e.push({type:"update-attr",identifier:r,partialAttr:{"value-type":"ref","on-delete-reverse":s.reverse.onDelete,"on-delete":s.forward.onDelete,cardinality:c}}),e},di=r=>typeof r=="object",mi=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(p=>({from:p,to:o})),h=[o,...c],l=await s(o,h,e);di(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};S.InstantOAuthError=v,S.OAuthHandler=or,S.PlatformApi=Jr,S.ProgressPromise=Dt,S.SchemaValidationError=ue,S.apiSchemaToInstantSchemaDef=$e,S.convertTxSteps=Mn,S.diffSchemas=Fn,S.exchangeCodeForToken=Ir,S.exchangeRefreshToken=ws,S.generatePermsTypescriptFile=cr,S.generateSchemaTypescriptFile=Ar,S.i=V,S.isRenamePromptItem=di,S.schemaTypescriptFileToInstantSchema=Dn,S.translatePlanSteps=Ss,S.validateSchema=Sr,S.version=Ee,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});